$PBExportHeader$w_quote_rece_fx.srw
$PBExportComments$分销系统--供应商报价单接收窗口
forward
global type w_quote_rece_fx from w_publ_base_style
end type
type cb_accept from uo_imflatbutton within w_quote_rece_fx
end type
type cb_reject from uo_imflatbutton within w_quote_rece_fx
end type
type dw_main from datawindow within w_quote_rece_fx
end type
type st_2 from statictext within w_quote_rece_fx
end type
type mle_postscript from multilineedit within w_quote_rece_fx
end type
type st_3 from statictext within w_quote_rece_fx
end type
type mle_remark from multilineedit within w_quote_rece_fx
end type
type dw_mx from u_dw_rbtnfilter within w_quote_rece_fx
end type
type cbx_audit from checkbox within w_quote_rece_fx
end type
end forward

global type w_quote_rece_fx from w_publ_base_style
integer width = 3771
integer height = 2372
string title = "接收-销售报价单"
boolean minbox = false
windowtype windowtype = response!
windowstate windowstate = maximized!
long backcolor = 16777215
string icon = "graphics\chain_link_128px.ico"
cb_accept cb_accept
cb_reject cb_reject
dw_main dw_main
st_2 st_2
mle_postscript mle_postscript
st_3 st_3
mle_remark mle_remark
dw_mx dw_mx
cbx_audit cbx_audit
end type
global w_quote_rece_fx w_quote_rece_fx

type variables
s_open_packet s_tran

long ins_ifmatch // 0-与原询价单不匹配 1-匹配 (-1)-获取原询价单失败
long ins_complete // packet是否被处理 1-已处理 0-未处理
end variables

forward prototypes
public subroutine wf_retrieve ()
end prototypes

public subroutine wf_retrieve ();dw_main.ReSet()
dw_mx.ReSet()

oleobject parm, retParm
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetString('sn', s_tran.sn)
string arg_msg
retParm = FXAppCom.GetReceQuote(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '获取供应商报价单失败:' + arg_msg)
	return
end if

long row
dw_main.SetRedraw(false)
oleobject quote
quote = retParm.GetPBDictionary('quote')
row = dw_main.InsertRow(0)
dw_main.Object.quotecode[row] = quote.GetString('quotecode')
if (not IsNull(quote.GetDateTime('quotedate'))) then
	dw_main.Object.quotedate[row] = quote.GetDateTime('quotedate')
end if
dw_main.Object.assign_emp[row] = quote.GetString('assign_emp')
dw_main.Object.dscrp[row] = quote.GetString('dscrp')
dw_main.Object.opemp[row] = quote.GetString('opemp')
if (not IsNull(quote.GetDateTime('opdate'))) then
	dw_main.Object.opdate[row] = quote.GetDateTime('opdate')
end if
dw_main.Object.moneyname[row] = quote.GetString('moneyname')
dw_main.Object.fiebrelcode[row] = quote.GetString('fiebrelcode')
if (not IsNull(quote.GetDateTime('ConfirmTime'))) then
	dw_main.Object.ConfirmTime[row] = quote.GetDateTime('ConfirmTime')
end if
dw_main.Object.ConfirmUser[row] = quote.GetString('ConfirmUser')
dw_main.Object.comname[row] = quote.GetString('comname')
dw_main.SetRedraw(true)

long i
dw_mx.SetRedraw(false)
oleobject quotemxs, item
quotemxs = retParm.GetArrOfPBDictionary('quotemxs')
for i = 1 to quotemxs.Count
	row = dw_mx.InsertRow(0)
	item = quotemxs.GetItem(i - 1)
	
	if (not IsNull(item.GetDateTime('requiredate'))) then
		dw_mx.Object.requiredate[row] = item.GetDateTime('requiredate')
		dw_mx.Object.ifmatch[row] = 1
	else
		dw_mx.Object.ifmatch[row] = 0
	end if
	dw_mx.Object.printid[row] = item.GetInt('printid')
	dw_mx.Object.mtrlcode[row] = item.GetString('mtrlcode')
	dw_mx.Object.mtrlname[row] = item.GetString('mtrlname')
	dw_mx.Object.mtrlmode[row] = item.GetString('mtrlmode')
	dw_mx.Object.unit[row] = item.GetString('unit')
	dw_mx.Object.price[row] = item.GetDouble('price')
	if (not IsNull(item.GetDouble('oriPrice'))) then
		dw_mx.Object.oriPrice[row] = item.GetDouble('oriPrice')
	end if
	dw_mx.Object.qty[row] = item.GetDouble('qty')
	dw_mx.Object.qty1[row] = item.GetDouble('qty1')
	dw_mx.Object.status[row] = item.GetString('status')
	dw_mx.Object.woodcode[row] = item.GetString('woodcode')
	dw_mx.Object.pcode[row] = item.GetString('pcode')
	dw_mx.Object.reBuyDays[row] = item.GetDouble('reBuyDays')
	if (not IsNull(item.GetDouble('buydays'))) then
		dw_mx.Object.buydays[row] = item.GetDouble('buydays')
	end if
	dw_mx.Object.perfinishdate[row] = item.GetDateTime('perfinishdate')
next
dw_mx.SetRedraw(true)

ins_ifmatch = retParm.GetInt('ifmatch') // 0-与原询价单不匹配 1-匹配 (-1)-获取原询价单失败
ins_complete = quote.GetInt('Complete')

if (f_find_fx_user_power(131, ref arg_msg) <> 1) then // 131-销售报价单查看(单价)
	dw_mx.Modify('destroy price_t ~r~n destroy price ~r~n')
	dw_mx.Modify('destroy oriprice_t ~r~n destroy oriprice ~r~n')
end if

if (ins_complete <> 1 and f_find_fx_user_power(132, ref arg_msg) = 1) then // 132-销售报价单确认
	cb_accept.Enabled = true
else
	cb_accept.Enabled = false
end if

if (ins_complete <> 1 and f_find_fx_user_power(133, ref arg_msg) = 1) then // 133-销售报价单拒绝
	cb_reject.Enabled = true
else
	cb_reject.Enabled = false
end if

if (f_find_fx_user_power(138, ref arg_msg) <> 1) then // 138-销售报价单审核
	cbx_audit.Enabled = false
end if


end subroutine

on w_quote_rece_fx.create
int iCurrent
call super::create
this.cb_accept=create cb_accept
this.cb_reject=create cb_reject
this.dw_main=create dw_main
this.st_2=create st_2
this.mle_postscript=create mle_postscript
this.st_3=create st_3
this.mle_remark=create mle_remark
this.dw_mx=create dw_mx
this.cbx_audit=create cbx_audit
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_accept
this.Control[iCurrent+2]=this.cb_reject
this.Control[iCurrent+3]=this.dw_main
this.Control[iCurrent+4]=this.st_2
this.Control[iCurrent+5]=this.mle_postscript
this.Control[iCurrent+6]=this.st_3
this.Control[iCurrent+7]=this.mle_remark
this.Control[iCurrent+8]=this.dw_mx
this.Control[iCurrent+9]=this.cbx_audit
end on

on w_quote_rece_fx.destroy
call super::destroy
destroy(this.cb_accept)
destroy(this.cb_reject)
destroy(this.dw_main)
destroy(this.st_2)
destroy(this.mle_postscript)
destroy(this.st_3)
destroy(this.mle_remark)
destroy(this.dw_mx)
destroy(this.cbx_audit)
end on

event open;call super::open;s_tran = Message.PowerObjectParm
if IsNUll(s_tran) then
	MessageBox('提示', '打开方式有误,SN号为空')
	Close(this)
	return
end if

cbx_audit.BackColor = 14215660

string arg_msg // 130-销售报价单 131-销售报价单查看(单价)
if (f_find_fx_user_power(130, ref arg_msg) <> 1 &
		and f_find_fx_user_power(131, ref arg_msg) <> 1) then
	MessageBox('权限提示', arg_msg)
	Close(this)
	return
end if

mle_postscript.Text = s_tran.postscript
mle_remark.Text = s_tran.remark

ins_ifmatch = 0

wf_retrieve()


end event

event resize;call super::resize;if (this.Width < 3762) then this.Width = 3762
if (this.Height < 2292) then this.Height = 2292

mle_postscript.Width = this.workspacewidth( ) - mle_postscript.X - 14
mle_remark.Width = mle_postscript.Width

dw_mx.Width = this.workspacewidth( )
dw_mx.Height = this.workspaceheight( ) - dw_mx.Y

cb_exit.X = this.workspacewidth( ) - cb_exit.Width
end event

type cb_func from w_publ_base_style`cb_func within w_quote_rece_fx
boolean visible = false
end type

type cb_exit from w_publ_base_style`cb_exit within w_quote_rece_fx
integer x = 2359
end type

type ln_bar from w_publ_base_style`ln_bar within w_quote_rece_fx
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_quote_rece_fx
end type

type r_bar from w_publ_base_style`r_bar within w_quote_rece_fx
integer x = 1367
end type

type cb_accept from uo_imflatbutton within w_quote_rece_fx
integer width = 329
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "更新询价单"
string normalpicname = "ok.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;dw_mx.SetFilter('')
dw_mx.Filter()

if (dw_mx.RowCount() <= 0) then
	MessageBox('提示', '没有报价明细')
	return
end if

string arg_msg
if (f_find_fx_user_power(132, ref arg_msg) <> 1) then // 132-销售报价单确认
	MessageBox('权限提示', arg_msg)
	return
end if

string fiebrelcode
long row
row = dw_main.GetRow()
if (row > 0) then
	fiebrelcode = Trim(dw_main.Object.fiebrelcode[row])
end if

long mode // 1-直接更新 2-新建询价单
mode = 0

if (ins_ifmatch = 1) then // 1-匹配
	mode = 1
elseif (ins_ifmatch = 0) then // 0-与原询价单不匹配
	if (MessageBox('提示', '该报价单与原询价单在某些明细项存在不匹配的情况,是否以该报价单为准,新建询价单?', Question!, YesNoCancel!) <> 1) then return
	mode = 2
elseif (ins_ifmatch = -1) then // (-1)-获取原询价单失败
	if (MessageBox('提示', '原询价单[' + fiebrelcode + ']不存在(可能已被删除),是否以该报价单为准,新建询价单?', Question!, YesNoCancel!) <> 1) then return
	mode = 2
else
	return
end if

if (mode = 2) then
	if (f_find_fx_user_power(134, ref arg_msg) <> 1) then // 134-询价单新建
		MessageBox('权限提示', arg_msg)
		return
	end if
end if

long audit
if (cbx_audit.Checked) then
	if (f_find_fx_user_power(138, ref arg_msg) <> 1) then // 138-销售报价单审核
		MessageBox('权限提示', arg_msg)
		return
	end if
	audit = 1
else
	audit = 0
end if

oleobject parm, retParm
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetString('sn', s_tran.sn)
parm.SetString('fiebrelcode', fiebrelcode)
parm.SetInt('mode', mode)
parm.SetInt('audit', audit)
retParm = FXAppCom.AcceptQuote(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '更新询价单操作失败:' + arg_msg)
	return
end if

MessageBox('提示', '操作成功')
if (mode = 2) then
	if (IsValid(s_win_open[130].win)) then // 130-销售报价单
		Close(s_win_open[130].win)
	end if
	
	Open(w_spt_price_change_fx)
end if
Close(parent)

end event

type cb_reject from uo_imflatbutton within w_quote_rece_fx
integer x = 334
integer width = 165
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "拒绝"
string normalpicname = "DELETE.BMP"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;string arg_msg
if (f_find_fx_user_power(133, ref arg_msg) <> 1) then // 133-销售报价单拒绝
	MessageBox('权限提示', arg_msg)
	return
end if

Open(w_packet_msg_edit_fx)

s_open_packet s_ret
s_ret = Message.PowerObjectParm

if (s_ret.returnflag = 0) then
	MessageBox('提示', '操作已取消')
	return
end if

oleobject parm
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetString('sn', s_tran.sn)
parm.SetString('postscript', s_ret.postscript)
FXAppCom.RejectQuote(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('', arg_msg)
	return
end if

MessageBox('提示', '操作成功')
Close(parent)
end event

type dw_main from datawindow within w_quote_rece_fx
integer y = 172
integer width = 1801
integer height = 920
integer taborder = 20
boolean bringtotop = true
string title = "none"
string dataobject = "dw_tempquote"
boolean livescroll = true
end type

type st_2 from statictext within w_quote_rece_fx
integer x = 1824
integer y = 172
integer width = 146
integer height = 48
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 16777215
string text = "附言"
boolean focusrectangle = false
end type

type mle_postscript from multilineedit within w_quote_rece_fx
integer x = 1824
integer y = 232
integer width = 1929
integer height = 392
integer taborder = 40
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean vscrollbar = true
boolean autovscroll = true
end type

type st_3 from statictext within w_quote_rece_fx
integer x = 1824
integer y = 636
integer width = 146
integer height = 48
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 16777215
string text = "备注"
boolean focusrectangle = false
end type

type mle_remark from multilineedit within w_quote_rece_fx
integer x = 1824
integer y = 700
integer width = 1929
integer height = 392
integer taborder = 40
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean vscrollbar = true
boolean autovscroll = true
end type

type dw_mx from u_dw_rbtnfilter within w_quote_rece_fx
integer y = 1096
integer width = 3648
integer height = 1132
integer taborder = 20
boolean bringtotop = true
boolean titlebar = true
string title = "单据明细内容"
string dataobject = "dw_tempquotemx"
boolean controlmenu = true
boolean maxbox = true
boolean hscrollbar = true
boolean vscrollbar = true
boolean resizable = true
boolean border = false
boolean hsplitscroll = true
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

type cbx_audit from checkbox within w_quote_rece_fx
integer x = 503
integer y = 52
integer width = 658
integer height = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
long backcolor = 16777215
string text = "更新询价单后审核单据"
end type

