$PBExportHeader$w_quote_fx.srw
$PBExportComments$供应商协同(主动)销售报价单
forward
global type w_quote_fx from w_publ_base_style
end type
type cb_retrieve from uo_imflatbutton within w_quote_fx
end type
type cb_toppage from uo_imflatbutton within w_quote_fx
end type
type cb_page_ch from uo_imflatbutton within w_quote_fx
end type
type em_pagesize from editmask within w_quote_fx
end type
type cb_1 from uo_imflatbutton within w_quote_fx
end type
type st_3 from statictext within w_quote_fx
end type
type sle_likestr from singlelineedit within w_quote_fx
end type
type dw_main_ff from datawindow within w_quote_fx
end type
type cb_neworsave from uo_imflatbutton within w_quote_fx
end type
type cb_editorundo from uo_imflatbutton within w_quote_fx
end type
type cb_del from uo_imflatbutton within w_quote_fx
end type
type cb_mxfun from uo_imflatbutton within w_quote_fx
end type
type dw_main from u_dw_rbtnfilter within w_quote_fx
end type
type dw_mx from u_dw_rbtnfilter within w_quote_fx
end type
type cb_ljfieb from uo_imflatbutton within w_quote_fx
end type
type tab_1 from tab within w_quote_fx
end type
type tabpage_1 from userobject within tab_1
end type
type dw_quote_his from u_dw_rbtnfilter within tabpage_1
end type
type tabpage_1 from userobject within tab_1
dw_quote_his dw_quote_his
end type
type tab_1 from tab within w_quote_fx
tabpage_1 tabpage_1
end type
type st_split from u_lbs_stsplitbar within w_quote_fx
end type
type st_1 from statictext within w_quote_fx
end type
type ddlb_status from dropdownlistbox within w_quote_fx
end type
end forward

global type w_quote_fx from w_publ_base_style
integer width = 4713
integer height = 2604
string title = "供应商询价单"
boolean maxbox = true
boolean resizable = true
long backcolor = 16777215
string icon = "graphics\chain_link_128px.ico"
event ue_page_next ( )
event ue_page_before ( )
event ue_page_end ( )
event type integer ue_add_mx ( )
event type integer ue_del_mx ( )
event type integer ue_send_ljfieb ( )
event ue_quote_his_fx ( )
cb_retrieve cb_retrieve
cb_toppage cb_toppage
cb_page_ch cb_page_ch
em_pagesize em_pagesize
cb_1 cb_1
st_3 st_3
sle_likestr sle_likestr
dw_main_ff dw_main_ff
cb_neworsave cb_neworsave
cb_editorundo cb_editorundo
cb_del cb_del
cb_mxfun cb_mxfun
dw_main dw_main
dw_mx dw_mx
cb_ljfieb cb_ljfieb
tab_1 tab_1
st_split st_split
st_1 st_1
ddlb_status ddlb_status
end type
global w_quote_fx w_quote_fx

type variables
long ins_cur_pageNum = 1 // 用于记录当前页码
long ins_totalPages = 1 // 用于记录总页数
long ins_flag = 0
//dw_fx_cust_ch
//datastore ins_ds_cust


end variables

forward prototypes
public function integer wf_retrieve_quote ()
public function integer wf_retrieve_quotemx (readonly long a_quoteid)
public subroutine wf_face ()
public subroutine wf_taborder ()
public function integer wf_save_quote ()
public function integer wf_chk (ref string arg_msg)
public function integer wf_retrieve_quote_his (long a_row_mx)
public subroutine wf_init_split ()
end prototypes

event ue_page_next();// 下页
if (ins_cur_pageNum = ins_totalPages) then return

ins_cur_pageNum ++

wf_retrieve_quote()
end event

event ue_page_before();// 上页
if (ins_cur_pageNum = 1) then return

ins_cur_pageNum --

wf_retrieve_quote()
end event

event ue_page_end();// 末页
if (ins_cur_pageNum = ins_totalPages) then return

ins_cur_pageNum = ins_totalPages

wf_retrieve_quote()
end event

event type integer ue_add_mx();int rslt = 1
string arg_msg

if (not if_modify_mode) then return 0

long row
row = dw_main_ff.GetRow()
if (row <= 0) then
	rslt = 0
	arg_msg = '当前没有编辑的单据'
	goto ext
end if

long cuscomid
cuscomid = dw_main_ff.Object.cuscomid[row]
if (cuscomid <= 0) then
	rslt = 0
	arg_msg ='请双击"客户简称"选择客户'
	goto ext
end if

long i, insertRow, findRow
string findStr
s_fx_mtrldef s_tran, s_ret
s_tran.ifrelation = true
s_tran.myreltype = 1 // 我是供应商
s_tran.partner_comid = cuscomid
OpenWithParm(w_mtrl_ch_by_comid_fx, s_tran)
s_ret = Message.PowerObjectParm
if (not IsNull(s_ret)) then
	if (IsValid(s_ret)) then
		if (s_ret.ifselect) then
			dw_mx.SetRedraw(false)
			for i = 1 to UpperBound(s_ret.fxmtrlid)
				findStr = 'fxmtrlid = ' + string(s_ret.fxmtrlid[i]) + ' and status = "" and woodcode = "" and pcode = "" and qty = 0 and qty1 = 0'
				findRow = dw_mx.Find(findStr, 1, dw_mx.RowCount())
				if (findRow > 0) then continue
				
				insertRow = dw_mx.InsertRow(0)
				
				dw_mx.Object.ch[insertRow] = 0
				dw_mx.Object.quoteid[insertRow] = dw_main_ff.Object.quoteid[row]
				dw_mx.Object.printid[insertRow] = 0
				dw_mx.Object.fxmtrlid[insertRow] = s_ret.fxmtrlid[i]
				dw_mx.Object.mtrlid[insertRow] = s_ret.mtrlid[i]
				dw_mx.Object.mtrlcode[insertRow] = s_ret.mtrlcode[i]
				dw_mx.Object.mtrlname[insertRow] = s_ret.mtrlname[i]
				dw_mx.Object.mtrlmode[insertRow] = s_ret.mtrlmode[i]
				// requiredate perfinishdate
				dw_mx.Object.sumprice[insertRow] = 0
				dw_mx.Object.sumprice_1[insertRow] = 0
				dw_mx.Object.rebate[insertRow] = 1
				dw_mx.Object.rebuydays[insertRow] = 0
				dw_mx.Object.buydays[insertRow] = 0
				dw_mx.Object.taxrate[insertRow] = 0
				dw_mx.Object.unit[insertRow] = s_ret.unit[i]
				dw_mx.Object.status[insertRow] = ''
				dw_mx.Object.woodcode[insertRow] = ''
				dw_mx.Object.pcode[insertRow] = ''
				dw_mx.Object.jgdscrp[insertRow] = ''
				// configcodetype
				dw_mx.Object.statusflag[insertRow] = s_ret.statusflag[i]
				dw_mx.Object.statustype[insertRow] = s_ret.statustype[i]
				dw_mx.Object.woodcodeflag[insertRow] = s_ret.woodcodeflag[i]
				dw_mx.Object.woodcodetype[insertRow] = s_ret.woodcodetype[i]
				dw_mx.Object.pcodeflag[insertRow] = s_ret.pcodeflag[i]
				dw_mx.Object.pcodetype[insertRow] = s_ret.pcodetype[i]
				
				dw_mx.Object.qty[insertRow] = 0
				dw_mx.Object.qty1[insertRow] = 0
				dw_mx.Object.mxdscrp[insertRow] = '' //'[' + s_tran.mtrlsectype[i] + '],[' + s_tran.zxmtrlmode[i] + '],[' + s_tran.usermtrlmode[i] + ']'
				dw_mx.Object.mxdscrp2[insertRow] = ''
				dw_mx.Object.latestquoteprice[insertRow] = 0
				dw_mx.Object.latestquoterebate[insertRow] = 0
				dw_mx.Object.latestacceptprice[insertRow] = 0
				dw_mx.Object.latestacceptrebate[insertRow] = 0
			next
			dw_mx.AcceptText()
			if (dw_mx.RowCount() > 0) then
				dw_mx.SelectRow(0, false)
				dw_mx.SelectRow(dw_mx.RowCount(), false)
				dw_mx.SetRow(dw_mx.RowCount())
				
				dw_mx.post event rowfocuschanged(dw_mx.RowCount())
			end if
			
			dw_mx.SetRedraw(true)
		end if
	end if
end if


ext:
if (rslt <> 1) then
	MessageBox('提示', arg_msg)
end if

return rslt
end event

event type integer ue_del_mx();int rslt = 1

if (not if_modify_mode) then return 0
if (dw_mx.RowCount() <= 0) then return 0

string arg_msg
long findRow, index = 0
long rows[]
findRow = dw_mx.Find('ch = 1', 1, dw_mx.RowCount())
if (findRow > 0) then // 多选删除
	do while findRow > 0
		index++
		rows[index] = findRow
		
		if (findRow >= dw_mx.RowCount()) then exit
		findRow = dw_mx.Find('ch = 1', findRow + 1, dw_mx.RowCount())
	loop
else // 单选
	findRow = dw_mx.GetRow()
	if (findRow > 0) then
		if (dw_mx.IsSelected(findRow)) then
			index++
			rows[index] = findRow
		end if
	end if
end if

if (index <= 0) then
	rslt = 0
	arg_msg = '请选中/勾选需要删除的明细项'
	goto ext
end if

long i
for i = UpperBound(rows) to 1 step - 1
	dw_mx.DeleteRow(rows[i])
next

ext:
if (rslt <> 1) then
	MessageBox('提示', arg_msg)
end if
return rslt
end event

event type integer ue_send_ljfieb();int rslt = 1

string arg_msg
long row
row = dw_main.GetRow()
if (row <= 0) then
	rslt = 0
	arg_msg = '请选择单据'
	goto ext
end if

if (not dw_main.IsSelected(row)) then
	rslt = 0
	arg_msg = '请选择单据'
	goto ext
end if


long quoteid
quoteid = dw_main.Object.quoteid[row]
oleobject parm, response
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetInt('quoteid', quoteid)
response = FXAppCom.DoExecute('SendQuote', parm)
arg_msg = response.GetString('ErrMsg')
if (arg_msg <> '') then
	rslt = 0
	goto ext
end if


ext:
if (rslt <> 1) then
	MessageBox('提示', '操作失败:' + arg_msg)
else
	MessageBox('提示', '发送成功!')
	wf_retrieve_quote()
//	dw_main.Object.responseemp[row] = app_username
//	dw_main.Object.responsedate[row] = DateTime(Today(), Now())
//	row = dw_main_ff.GetRow()
//	if (row > 0) then
//		dw_main_ff.Object.responseemp[row] = app_username
//		dw_main_ff.Object.responsedate[row] = DateTime(Today(), Now())
//	end if
end if

return rslt
//int rslt = 1
//
//string arg_msg
//long row
//row = dw_main.GetRow()
//if (row <= 0) then
//	rslt = 0
//	arg_msg = '请选择单据'
//	goto ext
//end if
//
//if (not dw_main.IsSelected(row)) then
//	rslt = 0
//	arg_msg = '请选择单据'
//	goto ext
//end if
//
//if (dw_main.Object.flag[row] <> 1) then
//	rslt = 0
//	arg_msg = '当前单据不处于审核状态,不能发送'
//	goto ext
//end if
//
//OpenWithParm(w_packet_msg_edit_fx, arg_msg)
//s_open_packet s_ret
//s_ret = Message.PowerObjectParm
//if (s_ret.returnflag = 0) then
//	MessageBox('提示', '操作取消')
//	return 0
//end if
//
//string postscript
//postscript = s_ret.postscript
//if IsNull(postscript) then
//	postscript = ''
//end if
//if (Len(postscript) > 500) then
//	rslt = 0
//	arg_msg = '留言板信息超长(500)，请进行删减'
//	goto ext
//end if
//
//long quoteid
//quoteid = dw_main.Object.quoteid[row]
//oleobject parm
//parm = FXAppCom.CreatePbDictionary()
//parm.SetString('token', app_token_fx)
//parm.SetInt('quoteid', quoteid)
//parm.SetString('postscript', postscript)
//FXAppCom.SendSaleQuote(parm, ref arg_msg)
//if (arg_msg <> '') then
//	rslt = 0
//	goto ext
//end if
//
//ext:
//if (rslt <> 1) then
//	MessageBox('提示', '操作失败:' + arg_msg)
//else
//	MessageBox('提示', '成功添加至发送队列')
//	dw_main.Object.sendemp[row] = app_username
//	dw_main.Object.senddate[row] = DateTime(Today(), Now())
//	row = dw_main_ff.GetRow()
//	if (row > 0) then
//		dw_main_ff.Object.sendemp[row] = app_username
//		dw_main_ff.Object.senddate[row] = DateTime(Today(), Now())
//	end if
//end if
//
//return rslt
//
//
end event

event ue_quote_his_fx();Open(w_quote_his_fx)
end event

public function integer wf_retrieve_quote ();int rslt = 1

if (if_modify_mode) then return 0

long oriRow
oriRow = dw_main.GetRow()

string arg_msg
long pageSize
pageSize = long(em_pagesize.Text)
if (pageSize <= 0) then
	rslt = 0
	arg_msg = '每页显示行数必须大于0'
	em_pagesize.SetFocus( )
	em_pagesize.SelectText(1, Len(em_pagesize.Text))
	goto ext
end if

long pageNum
pageNum = ins_cur_pageNum

//datetime dateA, dateZ
//dateA = DateTime(Date(em_dateA.Text), Time(0))
//dateZ = DateTime(Date(em_dateZ.Text), Time('23:59:59'))

string likeStr
likeStr = Trim(sle_likestr.Text)

oleobject obj, parm, list, item
parm = FxAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetInt('pageSize', pageSize)
parm.SetInt('pageNum', pageNum)
IF ins_flag <> -1 THEN
	parm.SetInt('flag', ins_flag)
END IF
//parm.SetDateTime('dateA', dateA)
//parm.SetDateTime('dateZ', dateZ)
parm.SetString('likeStr', likeStr)
obj = FXAppCom.DoExecute('GetQuote', parm)
arg_msg = obj.GetString('ErrMsg')
if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

dw_main.Reset()
dw_main_ff.Reset()
dw_mx.Reset()

dw_main.SetRedraw(false)
long i, row
list = obj.GetPBArray('list')
for i = 1 to list.Count
	item = list.GetPBDictionary(i - 1)
	row = dw_main.InsertRow(0)
	
	dw_main.Object.quoteid[row] = item.GetInt("quoteid")
	dw_main.Object.quotecode[row] = item.GetString("quotecode")
	dw_main.Object.billcode_cus[row] = item.GetString("billcode_cus")
	dw_main.Object.sptcomid[row] = item.GetInt("sptcomid")
	dw_main.Object.cuscomid[row] = item.GetInt("cuscomid")
	dw_main.Object.moneyname[row] = item.GetString("moneyname")
	dw_main.Object.flag[row] = item.GetInt("flag")
	dw_main.Object.billtype[row] = item.GetInt("billtype")
	dw_main.Object.simplename[row] = item.GetString("simplename")
	dw_main.Object.comname[row] = item.GetString("comname")
	dw_main.Object.assign_emp[row] = item.GetString("assign_emp")
	dw_main.Object.dscrp[row] = item.GetString("dscrp")
	dw_main.Object.sendemp[row] = item.GetString("sendemp")
	if (not IsNull(item.GetDateTime("senddate"))) then
		dw_main.Object.senddate[row] = item.GetDateTime("senddate")
	end if
	if (not IsNull(item.GetDateTime("requiredate"))) then
		dw_main.Object.requiredate[row] = item.GetDateTime("requiredate")
	end if
	dw_main.Object.modemp[row] = item.GetString("modemp")
	if (not IsNull(item.GetDateTime("moddate"))) then
		dw_main.Object.moddate[row] = item.GetDateTime("moddate")
	end if
	dw_main.Object.responseemp[row] = item.GetString("responseemp")
	if (not IsNull(item.GetDateTime("responsedate"))) then
		dw_main.Object.responsedate[row] = item.GetDateTime("responsedate")
	end if
next
dw_main.SetRedraw(true)

if (not IsNull(obj.GetInt('totalPages'))) then
	if (obj.GetInt('totalPages') > 0) then
		ins_totalPages = obj.GetInt('totalPages')
	else
		ins_totalPages = 1
	end if
else
	ins_totalPages = 1
end if

ext:
if (rslt = 1) then
	if (dw_main.RowCount() > 0) then
		dw_main.SelectRow(0, false)
		if (oriRow > 0 and oriRow <= dw_main.RowCount()) then
			dw_main.SelectRow(oriRow, true)
			dw_main.SetRow(oriRow)
			dw_main.post event RowFocusChanged(oriRow)
		else
			dw_main.SelectRow(1, true)
			dw_main.SetRow(1)
			dw_main.post event RowFocusChanged(1)
		end if
	end if
else
	MessageBox('提示', arg_msg)
end if
return rslt
end function

public function integer wf_retrieve_quotemx (readonly long a_quoteid);int rslt = 1

if (IsNull(a_quoteid)) then return 0
if (a_quoteid <= 0) then return 0

string arg_msg = ''
oleobject obj, parm, list, item
parm = FxAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetString('quoteid', a_quoteid)
obj = FXAppCom.DoExecute('GetQuoteMx', parm)
arg_msg = obj.GetString('ErrMsg')
if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

dw_mx.Reset()
dw_mx.SetRedraw(false)
long i, row
list = obj.GetPBArray('list')
for i = 1 to list.Count
	item = list.GetPBDictionary(i - 1)
	row = dw_mx.InsertRow(0)
	
	dw_mx.Object.quoteid[row] = item.GetInt("quoteid")
	dw_mx.Object.printid[row] = item.GetInt("printid")
	dw_mx.Object.fxmtrlid[row] = item.GetInt("fxmtrlid")
	dw_mx.Object.sumprice[row] = item.GetDouble("sumprice")
	dw_mx.Object.rebate[row] = item.GetDouble("rebate")
	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.qty[row] = item.GetDouble("qty")
	dw_mx.Object.qty1[row] = item.GetDouble("qty1")
	dw_mx.Object.unit[row] = item.GetString("unit")
	dw_mx.Object.mxdscrp[row] = item.GetString("mxdscrp")
	if (not IsNull(item.GetDateTime("effdate"))) then
		dw_mx.Object.effdate[row] = item.GetDateTime("effdate")
	end if
	if (not IsNull(item.GetDateTime("effdate_end"))) then
		dw_mx.Object.effdate_end[row] = item.GetDateTime("effdate_end")
	end if
	dw_mx.Object.mtrlid[row] = item.GetInt("mtrlid")
	dw_mx.Object.mtrlcode[row] = item.GetString("mtrlcode")
	dw_mx.Object.mtrlname[row] = item.GetString("mtrlname")
	dw_mx.Object.mtrlmode[row] = item.GetString("mtrlmode")
next

//if (f_find_fx_user_power(11, ref arg_msg) <> 1) then // 11-供应商询价单查看(单价)
//	dw_mx.Modify('destroy sumprice_1_t ~r~n destroy sumprice_1 ~r~n')
//	dw_mx.Modify('destroy sumprice_t ~r~n destroy sumprice ~r~n')
//	dw_mx.Modify('destroy rebate_t ~r~n destroy rebate ~r~n')
//	dw_mx.Modify('destroy compute_3_t ~r~n destroy compute_3 ~r~n')
//	dw_mx.Modify('destroy taxrate_t ~r~n destroy taxrate ~r~n')
//	dw_mx.Modify('destroy latestquoteprice_t ~r~n destroy latestquoteprice ~r~n')
//	dw_mx.Modify('destroy latestquoterebate_t ~r~n destroy latestquoterebate ~r~n')
//	dw_mx.Modify('destroy compute_4_t ~r~n destroy compute_4 ~r~n')
//	dw_mx.Modify('destroy latestacceptprice_t ~r~n destroy latestacceptprice ~r~n')
//	dw_mx.Modify('destroy latestacceptrebate_t ~r~n destroy latestacceptrebate ~r~n')
//	dw_mx.Modify('destroy compute_5_t ~r~n destroy compute_5 ~r~n')
//end if
dw_mx.AcceptText()
dw_mx.SetRedraw(true)

if (dw_mx.RowCount() > 0) then
	dw_mx.post event rowfocuschanged(1)
ELSE
	wf_retrieve_quote_his(0)
end if

ext:
if (rslt <> 1) then
	MessageBox('提示', arg_msg)
end if

return rslt
end function

public subroutine wf_face ();string arg_msg
long row, billtype
boolean ifProtectOriData
row = dw_main.GetRow()
if (row > 0) then
	billtype = dw_main.Object.billtype[row]
end if
if (row > 0 and billtype = 0) then // 被动报价单-保护原始数据
	ifProtectOriData = true
else
	ifProtectOriData = false
end if

if (if_modify_mode) then
	cb_retrieve.Enabled = false
	
	cb_neworsave.Enabled = true
//	cb_neworsave.Text = '保存'
//	cb_neworsave.normalpicname = 'Save.bmp'
	
	cb_editorundo.Text = '放弃'
	cb_editorundo.normalpicname = 'Undo.bmp'
	
//	cb_del.Enabled = false
//	cb_audit.Enabled = false
	cb_exit.Enabled = false
	em_pagesize.Enabled = false
	cb_toppage.Enabled = false
	cb_page_ch.Enabled = false
//	em_datea.Enabled = false
//	em_datez.Enabled = false
	sle_likestr.Enabled = false
	
	if (not ifProtectOriData) then
		cb_mxfun.Enabled = true
	end if
	cb_ljfieb.Enabled = false
else
	cb_retrieve.Enabled = true
	
	cb_neworsave.Enabled = false
//	cb_neworsave.Text = '新建'
//	cb_neworsave.normalpicname = 'new.bmp'
	
	cb_editorundo.Text = '修改'
	cb_editorundo.normalpicname = 'open.bmp'
	
//	if (f_find_fx_user_power(16, ref arg_msg) = 1) then // 16-销售报价单删除
//		cb_del.Enabled = true
//	end if
//	if (f_find_fx_user_power(17, ref arg_msg) = 1) then // 17-销售报价单审核
//		cb_audit.Enabled = true
//	end if
	cb_exit.Enabled = true
	em_pagesize.Enabled = true
	cb_toppage.Enabled = true
	cb_page_ch.Enabled = true
//	em_datea.Enabled = true
//	em_datez.Enabled = true
	sle_likestr.Enabled = true
	
	cb_mxfun.Enabled = false
//	if (f_find_fx_user_power(18, ref arg_msg) = 1) then // 18-销售报价单发送
		cb_ljfieb.Enabled = true
//	end if
end if

cb_neworsave.of_init_draw()
cb_neworsave.of_paint()
cb_neworsave.TriggerEvent('ue_textchange')

cb_editorundo.of_init_draw()
cb_editorundo.of_paint()
cb_editorundo.TriggerEvent('ue_textchange')
end subroutine

public subroutine wf_taborder ();long i = 0

if (if_modify_mode) then
	i += 10
	dw_mx.SetTabOrder('ch', i)
	i += 10
	dw_mx.SetTabOrder('sumprice', i)
	i += 10
	dw_mx.SetTabOrder('rebate', i)
	i += 10
	dw_mx.SetTabOrder('qty', i)
	i += 10
	dw_mx.SetTabOrder('qty1', i)
	i += 10
	dw_mx.SetTabOrder('effdate', i)
	i += 10
	dw_mx.SetTabOrder('effdate_end', i)
	i += 10
	dw_mx.SetTabOrder('mxdscrp', i)
else
	dw_mx.SetTabOrder('ch', 0)
	dw_mx.SetTabOrder('sumprice', 0)
	dw_mx.SetTabOrder('rebate', 0)
	dw_mx.SetTabOrder('qty', 0)
	dw_mx.SetTabOrder('qty1', 0)
	dw_mx.SetTabOrder('effdate', 0)
	dw_mx.SetTabOrder('effdate_end', 0)
	dw_mx.SetTabOrder('mxdscrp', 0)
end if
end subroutine

public function integer wf_save_quote ();int rslt = 1

string arg_msg
if (wf_chk(ref arg_msg) <> 1) then
	rslt = 0
	goto ext
end if

oleobject parm, main, mx, item, response
parm = FXAppCom.CreatePbDictionary()
main = FXAppCom.CreatePbDictionary()
mx = FXAppCom.NewPBArray()

dw_main_ff.AcceptText()
long row
row = dw_main_ff.GetRow()
main.SetInt('quoteid', dw_main_ff.Object.quoteid[row])
//main.SetInt('cuscomid', dw_main_ff.Object.cuscomid[row])
//main.SetInt('sptcomid', dw_main_ff.Object.sptcomid[row])
//main.SetString('assign_emp', dw_main_ff.Object.assign_emp[row])
//main.SetString('relcode', dw_main_ff.Object.relcode[row])
//main.SetString('dscrp', dw_main_ff.Object.dscrp[row])

long i
for i = 1 to dw_mx.RowCount()
	item = FXAppCom.CreatePbDictionary()
	
	item.SetInt('printid', dw_mx.Object.printid[i])
	item.SetDouble('sumprice', dw_mx.Object.sumprice[i])
	item.SetDouble('rebate', dw_mx.Object.rebate[i])
	item.SetDouble('qty', dw_mx.Object.qty[i])
	item.SetDouble('qty1', dw_mx.Object.qty1[i])
	item.SetDateTime('effdate', dw_mx.Object.effdate[i])
	item.SetDateTime('effdate_end', dw_mx.Object.effdate_end[i])
	item.SetString('mxdscrp', dw_mx.Object.mxdscrp[i])

//	item.SetInt('fxmtrlid', dw_mx.Object.fxmtrlid[i])
//	
//	item.SetDouble('sumprice', dw_mx.Object.sumprice[i])
//	item.SetDouble('rebate', dw_mx.Object.rebate[i])
//	item.SetDouble('sumprice_1', dw_mx.Object.sumprice_1[i])
//	item.SetDouble('qty', dw_mx.Object.qty[i])
//	item.SetDouble('qty1', dw_mx.Object.qty1[i])
//	item.SetDouble('rebuydays', dw_mx.Object.rebuydays[i])
//	item.SetDouble('buydays', dw_mx.Object.buydays[i])
//	item.SetDouble('taxrate', dw_mx.Object.taxrate[i])
//	
//	item.SetString('unit', dw_mx.Object.unit[i])
//	item.SetString('status', dw_mx.Object.status[i])
//	item.SetString('woodcode', dw_mx.Object.woodcode[i])
//	item.SetString('pcode', dw_mx.Object.pcode[i])
//	item.SetString('jgdscrp', dw_mx.Object.jgdscrp[i])
//	item.SetString('mxdscrp', dw_mx.Object.mxdscrp[i])
//	item.SetString('mxdscrp2', dw_mx.Object.mxdscrp2[i])
//	
//	item.SetDateTime('requiredate', dw_mx.Object.requiredate[i])
//	item.SetDateTime('perfinishdate', dw_mx.Object.perfinishdate[i])
	
	mx.AddObject(item)
next
main.SetObject('mxList', mx)

parm.SetString('token', app_token_fx)
parm.SetObject('quote', main)
//parm.SetObject('mx', mx)
//FXAppCom.AddQuote(parm, ref arg_msg)
response = FXAppCom.DoExecute('SaveQuote', parm)
arg_msg = response.GetString('ErrMsg')
if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

ext:
if (rslt <> 1) then
	MessageBox('提示', '操作失败:' + arg_msg)
else
	MessageBox('提示', '操作成功')
end if
return rslt
end function

public function integer wf_chk (ref string arg_msg);int rslt = 1

long row
row = dw_main_ff.GetRow()
if (row <= 0) then
	rslt = 0
	arg_msg = '获取当前编辑的单据失败'
	goto ext
end if

long cuscomid
cuscomid = dw_main_ff.Object.cuscomid[row]
if (cuscomid <= 0) then
	rslt = 0
	arg_msg = '请双击"客户简称"选择客户'
	goto ext
end if

string assign_emp
assign_emp = dw_main_ff.Object.assign_emp[row]
if (Trim(assign_emp) = '') then
	rslt = 0
	arg_msg = '请填写经手人'
	goto ext
end if

dw_mx.SetFilter('')
dw_mx.Filter()
dw_mx.AcceptText()
if (dw_mx.RowCount() <= 0) then
	rslt = 0
	arg_msg = '当前单据没有明细内容'
	goto ext
end if

// 检查重复
long i, findRow
string findStr, msg
for i = 1 to dw_mx.RowCount() - 1
	findStr = 'fxmtrlid = ' + string(dw_mx.Object.fxmtrlid[i]) &
			+ ' and status = "' + dw_mx.Object.status[i] + '" and woodcode = "' + dw_mx.Object.woodcode[i] + '" and pcode = "' + dw_mx.Object.pcode[i] &
			+ '" and qty = ' + string(dw_mx.Object.qty[i]) + ' and qty1 = ' + string(dw_mx.Object.qty1[i])
	findRow = dw_mx.Find(findStr, i + 1, dw_mx.RowCount())
	if (findRow > 0) then
		rslt = 0
		msg += '第' + string(i) + '行物料发现与第' + string(findRow) + '行重复(配置、数量)~r~n'
	end if
next
if (rslt <> 1) then
	arg_msg = '~r~n' + msg
	goto ext
end if



ext:
return rslt



end function

public function integer wf_retrieve_quote_his (long a_row_mx);int rslt = 1
tab_1.tabpage_1.dw_quote_his.Reset()
string arg_msg
//if (f_find_fx_user_power(19, ref arg_msg) <> 1) then // 19-最新报价统计表
//	return 0
//end if

if (dw_mx.GetRow() <= 0) then return 0
if (IsNull(a_row_mx)) then return 0
if (a_row_mx <= 0) then return 0

long a_row_main, ll_cuscomid
a_row_main = dw_main_ff.GetRow()
if (a_row_main <= 0) then return 0
ll_cuscomid = dw_main_ff.Object.cuscomid[a_row_main]
if (IsNull(ll_cuscomid)) then return 0
if (ll_cuscomid <= 0) then return 0

long ll_fxmtrlid
ll_fxmtrlid = dw_mx.Object.fxmtrlid[a_row_mx]
if (IsNull(ll_fxmtrlid)) then return 0
if (ll_fxmtrlid <= 0) then return 0

oleobject parm, obj, list, item
parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetInt('fxmtrlid', ll_fxmtrlid)
parm.SetInt('cuscomid', ll_cuscomid)
obj = FXAppCom.DoExecute('GetMtrlQuoteHistory', parm)
arg_msg = obj.GetString('ErrMsg')
if (arg_msg <> '') then
	rslt = 0
	goto ext
end if


long i, row
tab_1.tabpage_1.dw_quote_his.SetRedraw(false)
list = obj.GetPBArray('list')
for i = 1 to list.Count
	item = list.GetPBDictionary(i - 1)
	row = tab_1.tabpage_1.dw_quote_his.InsertRow(0)
	
	tab_1.tabpage_1.dw_quote_his.Object.quoteid[row] = item.GetInt("quoteid")
	tab_1.tabpage_1.dw_quote_his.Object.quotecode[row] = item.GetString("quotecode")
	tab_1.tabpage_1.dw_quote_his.Object.billcode_cus[row] = item.GetString("billcode_cus")
	tab_1.tabpage_1.dw_quote_his.Object.sptcomid[row] = item.GetInt("sptcomid")
	tab_1.tabpage_1.dw_quote_his.Object.cuscomid[row] = item.GetInt("cuscomid")
	tab_1.tabpage_1.dw_quote_his.Object.moneyname[row] = item.GetString("moneyname")
	tab_1.tabpage_1.dw_quote_his.Object.flag[row] = item.GetInt("flag")
	tab_1.tabpage_1.dw_quote_his.Object.billtype[row] = item.GetInt("billtype")
	if (not IsNull(item.GetDateTime("responsedate"))) then
		tab_1.tabpage_1.dw_quote_his.Object.responsedate[row] = item.GetDateTime("responsedate")
	end if
	tab_1.tabpage_1.dw_quote_his.Object.sumprice[row] = item.GetDouble("sumprice")
	tab_1.tabpage_1.dw_quote_his.Object.rebate[row] = item.GetDouble("rebate")
	tab_1.tabpage_1.dw_quote_his.Object.qty[row] = item.GetDouble("qty")
	tab_1.tabpage_1.dw_quote_his.Object.qty1[row] = item.GetDouble("qty1")
	tab_1.tabpage_1.dw_quote_his.Object.unit[row] = item.GetString("unit")
	tab_1.tabpage_1.dw_quote_his.Object.status[row] = item.GetString("status")
	tab_1.tabpage_1.dw_quote_his.Object.woodcode[row] = item.GetString("woodcode")
	tab_1.tabpage_1.dw_quote_his.Object.pcode[row] = item.GetString("pcode")
	tab_1.tabpage_1.dw_quote_his.Object.printid[row] = item.GetInt("printid")
	tab_1.tabpage_1.dw_quote_his.Object.fxmtrlid[row] = item.GetInt("fxmtrlid")
next
tab_1.tabpage_1.dw_quote_his.AcceptText()
tab_1.tabpage_1.dw_quote_his.SetSort('opdate desc')
tab_1.tabpage_1.dw_quote_his.Sort()
tab_1.tabpage_1.dw_quote_his.SetRedraw(true)

ext:
return rslt




end function

public subroutine wf_init_split ();// 将所有该分割条的上下的object都进行注册
st_split.of_Reset() 
st_split.of_Register(dw_mx, st_split.LEFT) // LEFT/RIGHT
st_split.of_Register(tab_1, st_split.RIGHT)
// 定位拖动条--以tv_1为位移基准
st_split.uf_possplitbar(dw_mx)
end subroutine

on w_quote_fx.create
int iCurrent
call super::create
this.cb_retrieve=create cb_retrieve
this.cb_toppage=create cb_toppage
this.cb_page_ch=create cb_page_ch
this.em_pagesize=create em_pagesize
this.cb_1=create cb_1
this.st_3=create st_3
this.sle_likestr=create sle_likestr
this.dw_main_ff=create dw_main_ff
this.cb_neworsave=create cb_neworsave
this.cb_editorundo=create cb_editorundo
this.cb_del=create cb_del
this.cb_mxfun=create cb_mxfun
this.dw_main=create dw_main
this.dw_mx=create dw_mx
this.cb_ljfieb=create cb_ljfieb
this.tab_1=create tab_1
this.st_split=create st_split
this.st_1=create st_1
this.ddlb_status=create ddlb_status
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_retrieve
this.Control[iCurrent+2]=this.cb_toppage
this.Control[iCurrent+3]=this.cb_page_ch
this.Control[iCurrent+4]=this.em_pagesize
this.Control[iCurrent+5]=this.cb_1
this.Control[iCurrent+6]=this.st_3
this.Control[iCurrent+7]=this.sle_likestr
this.Control[iCurrent+8]=this.dw_main_ff
this.Control[iCurrent+9]=this.cb_neworsave
this.Control[iCurrent+10]=this.cb_editorundo
this.Control[iCurrent+11]=this.cb_del
this.Control[iCurrent+12]=this.cb_mxfun
this.Control[iCurrent+13]=this.dw_main
this.Control[iCurrent+14]=this.dw_mx
this.Control[iCurrent+15]=this.cb_ljfieb
this.Control[iCurrent+16]=this.tab_1
this.Control[iCurrent+17]=this.st_split
this.Control[iCurrent+18]=this.st_1
this.Control[iCurrent+19]=this.ddlb_status
end on

on w_quote_fx.destroy
call super::destroy
destroy(this.cb_retrieve)
destroy(this.cb_toppage)
destroy(this.cb_page_ch)
destroy(this.em_pagesize)
destroy(this.cb_1)
destroy(this.st_3)
destroy(this.sle_likestr)
destroy(this.dw_main_ff)
destroy(this.cb_neworsave)
destroy(this.cb_editorundo)
destroy(this.cb_del)
destroy(this.cb_mxfun)
destroy(this.dw_main)
destroy(this.dw_mx)
destroy(this.cb_ljfieb)
destroy(this.tab_1)
destroy(this.st_split)
destroy(this.st_1)
destroy(this.ddlb_status)
end on

event open;call super::open;//ins_ds_cust = create datastore
//ins_ds_cust.DataObject = 'dw_fx_cust_ch'
//
//uo_pz = create uo_fx_pz
//uo_pz.init()

//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

//em_datea.Text = String(RelativeDate(Today(), - 30))
//em_datez.Text = String(Today())

wf_face()
wf_taborder()

wf_retrieve_quote()

wf_init_split()
end event

event close;call super::close;//destroy ins_ds_cust
//destroy uo_pz
end event

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

dw_main.Width = this.workspacewidth( ) - dw_main.X

// 下
dw_mx.Height = this.workspaceheight( ) - dw_mx.Y
if (dw_mx.Width + 200 >= this.workspacewidth( )) then
	dw_mx.Width = this.workspacewidth( ) / 4 * 3
end if
st_split.X = dw_mx.X + dw_mx.Width
st_split.Height = dw_mx.Height
tab_1.X = st_split.X + st_split.Width
tab_1.Width = this.workspacewidth( ) - st_split.X - st_split.Width
tab_1.Height = dw_mx.Height
tab_1.tabpage_1.dw_quote_his.Width = tab_1.Width - 20
tab_1.tabpage_1.dw_quote_his.Height = tab_1.Height - 110

// 按钮靠右
cb_exit.X = this.workspacewidth( ) - cb_exit.Width
cb_page_ch.X = cb_exit.X - cb_page_ch.Width - 5
cb_toppage.X = cb_page_ch.X - cb_toppage.Width - 5
em_pagesize.X = cb_toppage.X - em_pagesize.Width - 5
end event

type cb_func from w_publ_base_style`cb_func within w_quote_fx
boolean visible = false
integer x = 777
string normalpicname = "setting.BMP"
integer picsize = 16
end type

event cb_func::clicked;call super::clicked;m_Dfc_Control_PopupMenu dmPopupMenu
string menustr

string arg_msg
if (f_find_fx_user_power(19, ref arg_msg) = 1) then // 19-最新报价统计表
	menustr = 'Text=最新报价统计表~tEvent=ue_quote_his_fx'
end if
//menustr += '|' + 'Text=修改~tEvent=ue_del_boundtype'

if len(trim(menustr))<>0 then
	dmPopupMenu = Create m_Dfc_Control_PopupMenu
	dmPopupMenu.mf_BuildMenu(This, menustr)
	dmPopupMenu.mf_PopMenu()
	Destroy dmPopupMenu
end if
end event

type cb_exit from w_publ_base_style`cb_exit within w_quote_fx
integer x = 4229
end type

type ln_bar from w_publ_base_style`ln_bar within w_quote_fx
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_quote_fx
end type

type r_bar from w_publ_base_style`r_bar within w_quote_fx
end type

type cb_retrieve from uo_imflatbutton within w_quote_fx
integer width = 151
integer height = 164
integer taborder = 20
boolean bringtotop = true
string text = "刷新"
string normalpicname = "refresh.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;wf_retrieve_quote()
end event

type cb_toppage from uo_imflatbutton within w_quote_fx
integer x = 3986
integer width = 151
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "首页"
boolean border = false
end type

event clicked;call super::clicked;ins_cur_pageNum = 1

wf_retrieve_quote()
end event

type cb_page_ch from uo_imflatbutton within w_quote_fx
integer x = 4146
integer width = 82
integer height = 164
integer taborder = 40
boolean bringtotop = true
string text = "▼"
boolean border = false
end type

event clicked;call super::clicked;m_Dfc_Control_PopupMenu dmPopupMenu
string menustr

menustr="Text=下页~tEvent=ue_page_next"
menustr = menustr + "|" + "Text=上页~tEvent=ue_page_before"
menustr = menustr + "|" + "Text=末页~tEvent=ue_page_end"
	
if len(trim(menustr))<>0 then
	dmPopupMenu = Create m_Dfc_Control_PopupMenu
	dmPopupMenu.mf_BuildMenu(This, menustr)
	dmPopupMenu.mf_PopMenu()
	Destroy dmPopupMenu
end if
end event

type em_pagesize from editmask within w_quote_fx
integer x = 3680
integer y = 44
integer width = 306
integer height = 84
integer taborder = 30
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "100"
alignment alignment = center!
borderstyle borderstyle = stylelowered!
string mask = "#####"
boolean spin = true
double increment = 1
string minmax = "1~~"
end type

type cb_1 from uo_imflatbutton within w_quote_fx
boolean visible = false
integer x = 2496
integer width = 151
integer height = 164
integer taborder = 20
boolean bringtotop = true
boolean enabled = false
string text = "打印"
end type

type st_3 from statictext within w_quote_fx
integer x = 745
integer y = 200
integer width = 178
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 = "单号含"
boolean focusrectangle = false
end type

type sle_likestr from singlelineedit within w_quote_fx
integer x = 923
integer y = 184
integer width = 503
integer height = 84
integer taborder = 60
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
borderstyle borderstyle = stylelowered!
end type

type dw_main_ff from datawindow within w_quote_fx
integer y = 284
integer width = 1970
integer height = 988
integer taborder = 50
boolean bringtotop = true
string title = "none"
string dataobject = "dw_fx_quote_ff"
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event doubleclicked;if (not if_modify_mode) then return

if (row <= 0) then return

//if ((dwo.Type = 'column' and (dwo.Name = 'simplename' or dwo.Name = 'comname')) &
//		or (dwo.Type = 'text' and (dwo.Name = 'simplename_t' or dwo.Name = 'comname_t'))) then
//	if (this.Object.billtype[row] = 0) then return // 被动报价不能修改客户
//	
//	long ori_cuscomid, new_cuscomid
//	ori_cuscomid = this.Object.cuscomid[row]
//	
//	s_fx_company s_tran, s_ret
//	s_tran.ds = ins_ds_cust
//	OpenWithParm(w_cus_ch_fx, s_tran)
//	s_ret = Message.PowerObjectParm
//	if not IsNull(s_ret) then
//		if (s_ret.ifselect) then
//			new_cuscomid = s_ret.comid[1]
//			if (ori_cuscomid <> new_cuscomid) then
//				dw_mx.Reset() // 重选客户，清空明细物料
//				if (new_cuscomid > 0) then
//					uo_pz.init()
//					uo_pz.ins_comid = new_cuscomid
//					string arg_msg
//					if (uo_pz.uof_before_ready(ref arg_msg) <> 1) then
//						MessageBox('提示', arg_msg)
//					end if
//				end if
//			end if
//			
//			this.Object.cuscomid[row] = new_cuscomid
//			this.Object.comname[row] = s_ret.comname[1]
//			this.Object.simplename[row] = s_ret.simplename[1]
//			
//			this.AcceptText()
//		end if
//	end if
//end if
end event

type cb_neworsave from uo_imflatbutton within w_quote_fx
integer x = 155
integer width = 165
integer height = 164
integer taborder = 40
boolean bringtotop = true
string text = "保存"
string normalpicname = "Save.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;string arg_msg
long row

if (if_modify_mode) then // 保存功能
	if (wf_save_quote() <> 1) then return
else // 新建功能
//	if (f_find_fx_user_power(14, ref arg_msg) <> 1) then // 14-销售报价单新建
//		MessageBox('权限提示', arg_msg)
//		return
//	end if
//	
//	if (wf_new_quote() <> 1) then return
end if

if_modify_mode = not if_modify_mode
wf_face()
wf_taborder()

if (not if_modify_mode) then
	wf_retrieve_quote()
end if
end event

type cb_editorundo from uo_imflatbutton within w_quote_fx
integer x = 311
integer width = 151
integer height = 164
integer taborder = 50
boolean bringtotop = true
string text = "修改"
string normalpicname = "open.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long row
row = dw_main.GetRow()
if (row <= 0) then
	MessageBox('提示', '请选择单据')
	return
end if

string arg_msg
if (if_modify_mode) then // 放弃
	if (MessageBox('提示', '放弃当前修改？', Question!, YesNo!) <> 1) then return
	if (dw_main.Object.quoteid[row] = 0) then
		dw_main.DeleteRow(row)
		dw_main_ff.Reset()
		dw_mx.Reset()
		if (dw_main.RowCount() > 0) then
			row = 1
		else
			row = 0
		end if
	end if
else // 修改
//	if (f_find_fx_user_power(15, ref arg_msg) <> 1) then // 15-销售报价单修改
//		MessageBox('权限提示', arg_msg)
//		return
//	end if
	
	if (dw_main.Object.responseemp[row] <> '') then
		MessageBox('提示', '当前单据已发送，不能修改')
		return
	end if
//	if (uo_pz.ins_comid <> dw_main.Object.cuscomid[row]) then
//		uo_pz.init()
//		uo_pz.ins_comid = dw_main.Object.cuscomid[row]
//		if (uo_pz.uof_before_ready(ref arg_msg) <> 1) then
//			MessageBox('提示', arg_msg)
//		end if
//	end if
end if

if_modify_mode = not if_modify_mode
wf_face()
wf_taborder()

if (not if_modify_mode) then
	if (row > 0) then
		dw_main.post event rowfocuschanged(row)
	end if
end if
end event

type cb_del from uo_imflatbutton within w_quote_fx
boolean visible = false
integer x = 466
integer width = 151
integer height = 164
integer taborder = 60
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;//long row
//row = dw_main.GetRow()
//if (row <= 0) then
//	MessageBox('提示', '请选择单据')
//	return
//end if
//
//string arg_msg
//if (f_find_fx_user_power(16, ref arg_msg) <> 1) then // 16-销售报价单删除
//	MessageBox('权限提示', arg_msg)
//	return
//end if
//
//if (dw_main.Object.flag[row] <> 0) then
//	MessageBox('提示', '当前单据不处于待审核状态,不能删除')
//	return
//end if
//
//if (MessageBox('提示', '确认进行删除操作？', Question!, YesNo!) <> 1) then return
//
//long quoteid
//quoteid = dw_main.Object.quoteid[row]
//if (wf_del_quote(quoteid) = 1) then
//	dw_main.DeleteRow(row)
//	dw_main_ff.Reset()
//	dw_mx.Reset()
//	if (dw_main.RowCount() > 0) then
//		if (row <= dw_main.RowCount()) then
//			dw_main.post event rowfocuschanged(row)
//		else
//			dw_main.post event rowfocuschanged(1)
//		end if
//	end if
//end if
end event

type cb_mxfun from uo_imflatbutton within w_quote_fx
boolean visible = false
integer x = 933
integer width = 274
integer height = 164
integer taborder = 70
boolean bringtotop = true
string text = "明细功能"
string normalpicname = "mx.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;if (not if_modify_mode) then return

m_Dfc_Control_PopupMenu dmPopupMenu
string menustr

menustr = 'Text=增明细~tEvent=ue_add_mx'
menustr += '|' + 'Text=删明细~tEvent=ue_del_mx'

if len(trim(menustr))<>0 then
	dmPopupMenu = Create m_Dfc_Control_PopupMenu
	dmPopupMenu.mf_BuildMenu(This, menustr)
	dmPopupMenu.mf_PopMenu()
	Destroy dmPopupMenu
end if
end event

type dw_main from u_dw_rbtnfilter within w_quote_fx
integer x = 1970
integer y = 284
integer width = 2510
integer height = 988
integer taborder = 20
boolean titlebar = true
string title = "单据列表"
string dataobject = "dw_fx_quote"
boolean controlmenu = true
boolean maxbox = true
boolean hscrollbar = true
boolean vscrollbar = true
boolean resizable = true
boolean hsplitscroll = true
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

event rowfocuschanged;call super::rowfocuschanged;if if_modify_mode then return

if IsNull(currentrow) then
	currentrow = this.GetRow()
	if IsNull(currentrow) then return
end if
if (currentrow <= 0) then return

this.SelectRow(0, false)
this.SelectRow(currentrow, true)

dw_main_ff.Reset( )
this.RowsCopy(currentrow, currentrow, Primary!, dw_main_ff, 1, Primary!)

long quoteid
quoteid = this.Object.quoteid[currentrow]
wf_retrieve_quotemx(quoteid)

string arg_msg
if (this.Object.flag[currentrow] <> 0) then
	cb_editorundo.Enabled = false
	cb_ljfieb.Enabled = false
else
	cb_editorundo.Enabled = true
	cb_ljfieb.Enabled = true
end if
end event

event clicked;call super::clicked;if (if_modify_mode) then return

if (IsNull(row)) then return

if (row > 0) then
	this.SelectRow(0, false)
	this.SelectRow(row, true)
	this.SetRow(row)
end if
end event

type dw_mx from u_dw_rbtnfilter within w_quote_fx
event ue_dwndropdown pbm_dwndropdown
integer y = 1260
integer width = 3451
integer height = 1168
integer taborder = 20
boolean bringtotop = true
boolean titlebar = true
string title = "明细内容"
string dataobject = "dw_fx_quotemx"
boolean controlmenu = true
boolean maxbox = true
boolean hscrollbar = true
boolean vscrollbar = true
boolean hsplitscroll = true
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

event ue_dwndropdown;////
//if (not if_modify_mode) then return
//
//long row
//row = this.GetRow()
//if (row <= 0) then return
//
//string arg_msg
//if (not uo_pz.ins_isReady) then
//	uo_pz.uof_get_ready(ref arg_msg)
//	if (arg_msg <> '') then
//		MessageBox('提示', '获取配置失败:' + arg_msg)
//		return
//	end if
//end if
//
//s_fx_pzwin_open s_tran
//s_tran.arg_mtrlid = this.Object.fxmtrlid[row]
//s_tran.arg_mtrlid_erp = this.Object.mtrlid[row]
//s_tran.arg_statusflag = this.Object.statusflag[row]
//s_tran.arg_statustype = this.Object.statustype[row]
//s_tran.arg_woodcodeflag = this.Object.woodcodeflag[row]
//s_tran.arg_woodcodetype = this.Object.woodcodetype[row]
//s_tran.arg_pcodeflag = this.Object.pcodeflag[row]
//s_tran.arg_pcodetype = this.Object.pcodetype[row]
//s_tran.arg_colname = this.GetColumnName()
//s_tran.arg_x = parent.X + this.X + this.Pointerx()
//s_tran.arg_y = parent.Y + this.Y + this.Pointery()
//
//string ret
//ret = uo_pz.uof_open_pzwin(s_tran, ref arg_msg)
//if (arg_msg <> '') then
//	MessageBox('提示', arg_msg)
//end if
//
//this.SetItem(row, s_tran.arg_colname, ret)
//
//
//
end event

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 doubleclicked;call super::doubleclicked;// 双击空白处
if (not if_modify_mode) then return

if (dwo.Type <> 'datawindow') then return

parent.post event ue_add_mx( )
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 = 'requiredate') then
//		this.SelectText(1, Len(this.GetText()))
//	end if
end if
wf_retrieve_quote_his(row)
end event

event rowfocuschanged;call super::rowfocuschanged;string arg_msg
if (currentrow > 0) then
	this.SelectRow(0, false)
	this.SelectRow(currentrow, true)
	this.SetRow(currentrow)
	
//	if (f_find_fx_user_power(19, ref arg_msg) = 1) then // 19-最新报价统计表
		wf_retrieve_quote_his(currentrow)
//	end if
end if
end event

type cb_ljfieb from uo_imflatbutton within w_quote_fx
integer x = 466
integer width = 151
integer height = 164
integer taborder = 40
boolean bringtotop = true
string text = "发送"
string normalpicname = "graphics\fx_send.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;Parent.PostEvent('ue_send_ljfieb')
end event

type tab_1 from tab within w_quote_fx
integer x = 3488
integer y = 1264
integer width = 1166
integer height = 1056
integer taborder = 30
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long backcolor = 16777215
boolean raggedright = true
boolean focusonbuttondown = true
integer selectedtab = 1
tabpage_1 tabpage_1
end type

on tab_1.create
this.tabpage_1=create tabpage_1
this.Control[]={this.tabpage_1}
end on

on tab_1.destroy
destroy(this.tabpage_1)
end on

type tabpage_1 from userobject within tab_1
integer x = 18
integer y = 96
integer width = 1129
integer height = 944
long backcolor = 16777215
string text = "历史"
long tabtextcolor = 33554432
long tabbackcolor = 16777215
long picturemaskcolor = 536870912
dw_quote_his dw_quote_his
end type

on tabpage_1.create
this.dw_quote_his=create dw_quote_his
this.Control[]={this.dw_quote_his}
end on

on tabpage_1.destroy
destroy(this.dw_quote_his)
end on

type dw_quote_his from u_dw_rbtnfilter within tabpage_1
integer width = 1120
integer height = 800
integer taborder = 20
string dataobject = "dw_fx_quote_his_simple"
boolean hscrollbar = true
boolean vscrollbar = true
boolean hsplitscroll = true
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

type st_split from u_lbs_stsplitbar within w_quote_fx
integer x = 3461
integer y = 1264
integer width = 14
integer height = 500
boolean bringtotop = true
end type

event clicked;call super::clicked;parent.postevent('resize')
end event

type st_1 from statictext within w_quote_fx
integer x = 14
integer y = 208
integer width = 288
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 = "单据状态"
alignment alignment = center!
boolean focusrectangle = false
end type

type ddlb_status from dropdownlistbox within w_quote_fx
integer x = 293
integer y = 188
integer width = 320
integer height = 496
integer taborder = 80
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
boolean sorted = false
boolean vscrollbar = true
string item[] = {"全部","未报价","已报价"}
borderstyle borderstyle = stylelowered!
end type

event selectionchanged;CHOOSE CASE Index
	CASE 1
		ins_flag = -1
	CASE 2
		ins_flag = 0
	CASE 3
		ins_flag = 1
END CHOOSE

cb_retrieve.PostEvent(Clicked!)

end event

event constructor;selectItem(2)
//postEvent('SelectionChanged');
end event

