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

global type w_spt_price_rece_fx from w_publ_base_style
integer width = 4686
integer height = 2104
string title = "接收-询价单"
boolean minbox = false
windowtype windowtype = response!
windowstate windowstate = maximized!
long backcolor = 16777215
string icon = "graphics\chain_link_128px.ico"
boolean center = true
cb_accept cb_accept
dw_main dw_main
st_1 st_1
mle_summary mle_summary
st_2 st_2
mle_postscript mle_postscript
st_3 st_3
mle_remark mle_remark
dw_mx dw_mx
end type
global w_spt_price_rece_fx w_spt_price_rece_fx

type variables
s_open_packet s_tran

long ins_ret = 0 // 1-关闭并打开供应商询价单界面
end variables

forward prototypes
public function integer wf_retrieve ()
public subroutine wf_send (readonly string arg_postscript)
end prototypes

public function integer wf_retrieve ();int rslt = 1

dw_main.ReSet()
dw_mx.ReSet()

oleobject obj, sptPrice, sptPricemx, mxItem

string arg_msg
obj = FXAppCom.GetReceSptPrice(app_token_fx, s_tran.sn, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '获取供应商询价单信息失败:' + arg_msg)
	rslt = 0
	goto ext
end if

dw_main.SetRedraw(false)
long row
row = dw_main.InsertRow(0)
sptPrice = obj.GetPBDictionary('sptPrice')

dw_main.Object.billcode[row] = sptPrice.GetString('billcode')
if (not IsNull(sptPrice.GetDateTime('billdate'))) then
	dw_main.Object.billdate[row] = sptPrice.GetDateTime('billdate')
end if
dw_main.Object.inrep[row] = sptPrice.GetString('inrep')
dw_main.Object.dscrp[row] = sptPrice.GetString('dscrp')
dw_main.Object.moneyname[row] = sptPrice.GetString('moneyname')
dw_main.Object.opemp[row] = sptPrice.GetString('opemp')
if (not IsNull(sptPrice.GetDateTime('opdate'))) then
	dw_main.Object.opdate[row] = sptPrice.GetDateTime('opdate')
end if
dw_main.Object.ConfirmUser[row] = sptPrice.GetString('ConfirmUser')
if (not IsNull(sptPrice.GetDateTime('ConfirmTime'))) then
	dw_main.Object.ConfirmTime[row] = sptPrice.GetDateTime('ConfirmTime')
end if
dw_main.Object.comname[row] = sptPrice.GetString('comname')
if (not IsNull(sptPrice.GetDateTime('requiredate'))) then
	dw_main.Object.requiredate[row] = sptPrice.GetDateTime('requiredate')
end if
dw_main.SetRedraw(true)


dw_mx.SetRedraw(false)
sptPricemx = obj.GetArrOfPBDictionary('sptPricemx')
long i
for i = 1 to sptPricemx.Count
	row = dw_mx.InsertRow(0)
	mxItem = sptPricemx.GetItem(i - 1)
	
	dw_mx.Object.printid[row] = mxItem.GetInt('printid')
	dw_mx.Object.mtrlid[row] = mxItem.GetInt('mtrlid')
	dw_mx.Object.sptmtrlcode[row] = mxItem.GetString('sptmtrlcode')
	dw_mx.Object.sptmtrlname[row] = mxItem.GetString('sptmtrlname')
	dw_mx.Object.sptmtrlmode[row] = mxItem.GetString('sptmtrlmode')
	dw_mx.Object.unit[row] = mxItem.GetString('unit')
	dw_mx.Object.price[row] = mxItem.GetDouble('price')
//	dw_mx.Object.reprice[row] = mxItem.GetDouble('price')
//	dw_mx.Object.rebate[row] = 1
	dw_mx.Object.qty[row] = mxItem.GetDouble('qty')
	dw_mx.Object.qty1[row] = mxItem.GetDouble('qty1')
	dw_mx.Object.dscrp[row] = mxItem.GetString('dscrp')
	dw_mx.Object.status[row] = mxItem.GetString('status')
	dw_mx.Object.woodcode[row] = mxItem.GetString('woodcode')
	dw_mx.Object.pcode[row] = mxItem.GetString('pcode')
	dw_mx.Object.jgdscrp[row] = mxItem.GetString('jgdscrp')
	dw_mx.Object.buydays[row] = mxItem.GetDouble('buydays')
next
dw_mx.SetRedraw(true)

if (f_find_fx_user_power(11, ref arg_msg) <> 1) then // 11-供应商询价单查看(单价)
	dw_mx.Modify('destroy price_t ~r~n destroy price ~r~n')
//	dw_mx.Modify('destroy reprice_t ~r~n destroy reprice ~r~n')
//	dw_mx.Modify('destroy rebate_t ~r~n destroy rebate ~r~n')
//	dw_mx.Modify('destroy compute_price_t ~r~n destroy compute_price ~r~n')
end if

if (sptPrice.GetInt('Complete') <> 1 and f_find_fx_user_power(12, ref arg_msg) = 1) then // 12-供应商询价单接收
	cb_accept.Enabled = true
else
	cb_accept.Enabled = false
end if

ext:
return rslt
end function

public subroutine wf_send (readonly string arg_postscript);//oleobject mxs, mxItem
//mxs = FXAppCom.CreArrOfPbDictionary()
//
//long i
//for i = 1 to dw_mx.RowCount()
//	mxItem = FXAppCom.CreatePbDictionary()
//	
//	mxItem.SetInt('printid', dw_mx.Object.printid[i])
//	mxItem.SetInt('mtrlid', dw_mx.Object.mtrlid[i])
//	mxItem.SetString('sptmtrlcode', dw_mx.Object.sptmtrlcode[i])
//	mxItem.SetString('sptmtrlname', dw_mx.Object.sptmtrlname[i])
//	mxItem.SetString('sptmtrlmode', dw_mx.Object.sptmtrlmode[i])
//	mxItem.SetString('unit', dw_mx.Object.unit[i])
//	mxItem.SetDouble('reprice', dw_mx.Object.reprice[i])
//	mxItem.SetDouble('rebate', dw_mx.Object.rebate[i])
//	mxItem.SetDouble('qty', dw_mx.Object.qty[i])
//	mxItem.SetDouble('qty1', dw_mx.Object.qty1[i])
//	mxItem.SetString('dscrp', dw_mx.Object.dscrp[i])
//	mxItem.SetString('status', dw_mx.Object.status[i])
//	mxItem.SetString('woodcode', dw_mx.Object.woodcode[i])
//	mxItem.SetString('pcode', dw_mx.Object.pcode[i])
//	mxItem.SetDouble('buydays', dw_mx.Object.buydays[i])
//	
//	mxs.Add(mxItem)
//next
//
//string arg_msg
//FXAppCom.SendQuote(app_token_fx, s_tran.sn, arg_postscript, mxs, ref arg_msg)
//
//if (arg_msg <> '') then
//	MessageBox('提示', '报价失败:' + arg_msg)
//else
//	MessageBox('提示', '报价成功!')
//	Close(this)
//end if
end subroutine

on w_spt_price_rece_fx.create
int iCurrent
call super::create
this.cb_accept=create cb_accept
this.dw_main=create dw_main
this.st_1=create st_1
this.mle_summary=create mle_summary
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
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_accept
this.Control[iCurrent+2]=this.dw_main
this.Control[iCurrent+3]=this.st_1
this.Control[iCurrent+4]=this.mle_summary
this.Control[iCurrent+5]=this.st_2
this.Control[iCurrent+6]=this.mle_postscript
this.Control[iCurrent+7]=this.st_3
this.Control[iCurrent+8]=this.mle_remark
this.Control[iCurrent+9]=this.dw_mx
end on

on w_spt_price_rece_fx.destroy
call super::destroy
destroy(this.cb_accept)
destroy(this.dw_main)
destroy(this.st_1)
destroy(this.mle_summary)
destroy(this.st_2)
destroy(this.mle_postscript)
destroy(this.st_3)
destroy(this.mle_remark)
destroy(this.dw_mx)
end on

event open;call super::open;s_tran = Message.PowerObjectParm
if IsNUll(s_tran) then
	MessageBox('提示', '打开方式有误')
	Close(this)
	return
end if
if (not IsValid(s_tran)) then
	MessageBox('提示', '打开方式无效')
	Close(this)
	return
end if

string arg_msg // 10-供应商询价单 11-供应商询价单查看(单价)
if (f_find_fx_user_power(10, ref arg_msg) <> 1 &
		and f_find_fx_user_power(11, ref arg_msg) <> 1) then
	MessageBox('权限提示', arg_msg)
	Close(this)
	return
end if

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

//if (s_tran.ifread = 1) then
//	cb_accept.Enabled = false
//end if

if (wf_retrieve( ) = 0) then
	Close(this)
end if
end event

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

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

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

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

event close;call super::close;CloseWithReturn(this, ins_ret)
end event

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

type cb_exit from w_publ_base_style`cb_exit within w_spt_price_rece_fx
integer x = 3136
end type

type ln_bar from w_publ_base_style`ln_bar within w_spt_price_rece_fx
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_spt_price_rece_fx
end type

type r_bar from w_publ_base_style`r_bar within w_spt_price_rece_fx
end type

type cb_accept from uo_imflatbutton within w_spt_price_rece_fx
integer width = 430
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()
//dw_mx.AcceptText()

if (dw_mx.RowCount() <= 0) then
	MessageBox('提示', '没有报价明细,或者是获取询价明细失败')
	return
end if

//string sum_msg
//long i
//for i = 1 to dw_mx.RowCount()
//	if (dw_mx.Object.reprice[i] <= 0) then
//		sum_msg = '第' + string(i) + '行,回复报价为0~r~n'
//	end if
//next

string arg_msg
if (f_find_fx_user_power(12, ref arg_msg) <> 1) then // 12-供应商询价单接收
	MessageBox('权限提示', arg_msg)
	return
end if

//if (MessageBox('提示', sum_msg + '确定发送给客户进行报价?', Question!, YesNoCancel!) <> 1) then return

//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
//
//if (Len(s_ret.postscript) > 500) then
//	MessageBox('提示', '留言板信息超长(500)，请进行删减')
//	return
//end if

//wf_send(s_ret.postscript)

oleobject parm
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetString('sn', s_tran.sn)
FXAppCom.AcceptReceSptPrice(parm, ref arg_msg)
if (arg_msg <> '') then
	MessageBox('提示', '操作失败:' + arg_msg)
	return
else
	if (MessageBox('提示', '操作成功，现在需要跳转到供应商询价单界面吗？', Question!, YesNo!) = 1) then
		ins_ret = 1
	else
		ins_ret = 0
	end if
	Close(parent)
end if



end event

type dw_main from datawindow within w_spt_price_rece_fx
integer y = 172
integer width = 1888
integer height = 780
integer taborder = 20
boolean bringtotop = true
string title = "none"
string dataobject = "dw_tempsptprice"
boolean livescroll = true
end type

type st_1 from statictext within w_spt_price_rece_fx
boolean visible = false
integer x = 1906
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_summary from multilineedit within w_spt_price_rece_fx
boolean visible = false
integer x = 1906
integer y = 232
integer width = 1847
integer height = 300
integer taborder = 30
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_2 from statictext within w_spt_price_rece_fx
integer x = 1906
integer y = 176
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_spt_price_rece_fx
integer x = 1906
integer y = 232
integer width = 1847
integer height = 320
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_spt_price_rece_fx
integer x = 1906
integer y = 572
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_spt_price_rece_fx
integer x = 1906
integer y = 632
integer width = 1847
integer height = 320
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_spt_price_rece_fx
integer y = 956
integer width = 4654
integer height = 1060
integer taborder = 20
boolean bringtotop = true
boolean titlebar = true
string title = "单据明细内容"
string dataobject = "dw_tempsptpricemx"
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

event clicked;call super::clicked;if (row > 0) then
	this.SelectRow(0, false)
	this.SelectRow(row, true)
	this.SetRow(row)
end if
end event

event dwnkey;call super::dwnkey;if (key = KeyDownArrow!) then
	//dw_mx.SelectText(1, Len(dw_mx.GetText()))
elseif (key = KeyUpArrow!) then
	
end if
end event

event rowfocuschanged;call super::rowfocuschanged;if (currentrow > 0) then
	string colName
	colName = this.GetColumnName()
	if (colName = 'reprice' or colName = 'rebate') then
		this.SelectText(1, Len(this.GetText()))
	end if
end if
end event

event itemfocuschanged;call super::itemfocuschanged;if (row > 0) then
	this.SelectRow(0, false)
	this.SelectRow(row, true)
	this.SetRow(row)
	
	string colName
	colName = this.GetColumnName()
	if (colName = 'reprice' or colName = 'rebate') then
		this.SelectText(1, Len(this.GetText()))
	end if
end if
end event

