$PBExportHeader$w_saletask_fx.srw
$PBExportComments$分销系统--销售订单页
forward
global type w_saletask_fx from w_publ_base_style
end type
type dw_saletask_list from u_dw_rbtnfilter within w_saletask_fx
end type
type dw_saletask from datawindow within w_saletask_fx
end type
type tab_1 from tab within w_saletask_fx
end type
type tabpage_1 from userobject within tab_1
end type
type dw_saletaskmx from u_dw_rbtnfilter within tabpage_1
end type
type tabpage_1 from userobject within tab_1
dw_saletaskmx dw_saletaskmx
end type
type tabpage_2 from userobject within tab_1
end type
type cb_1 from commandbutton within tabpage_2
end type
type dw_fx_outware_badqc from u_dw_rbtnfilter within tabpage_2
end type
type dw_outware_log from u_dw_rbtnfilter within tabpage_2
end type
type tabpage_2 from userobject within tab_1
cb_1 cb_1
dw_fx_outware_badqc dw_fx_outware_badqc
dw_outware_log dw_outware_log
end type
type tabpage_3 from userobject within tab_1
end type
type cb_qty_ready_copy from commandbutton within tabpage_3
end type
type cb_quit_qty_ready from commandbutton within tabpage_3
end type
type cb_edit_qty_ready from commandbutton within tabpage_3
end type
type st_split from u_lbs_stsplitbar within tabpage_3
end type
type cb_quit_jd from commandbutton within tabpage_3
end type
type cb_delrow from commandbutton within tabpage_3
end type
type cb_addrow from commandbutton within tabpage_3
end type
type cb_edit_jd from commandbutton within tabpage_3
end type
type dw_jd from u_dw_rbtnfilter within tabpage_3
end type
type dw_jd_ordermx from u_dw_rbtnfilter within tabpage_3
end type
type tabpage_3 from userobject within tab_1
cb_qty_ready_copy cb_qty_ready_copy
cb_quit_qty_ready cb_quit_qty_ready
cb_edit_qty_ready cb_edit_qty_ready
st_split st_split
cb_quit_jd cb_quit_jd
cb_delrow cb_delrow
cb_addrow cb_addrow
cb_edit_jd cb_edit_jd
dw_jd dw_jd
dw_jd_ordermx dw_jd_ordermx
end type
type tab_1 from tab within w_saletask_fx
tabpage_1 tabpage_1
tabpage_2 tabpage_2
tabpage_3 tabpage_3
end type
type st_1 from statictext within w_saletask_fx
end type
type ddlb_status from dropdownlistbox within w_saletask_fx
end type
type st_2 from statictext within w_saletask_fx
end type
type em_datea from editmask within w_saletask_fx
end type
type st_3 from statictext within w_saletask_fx
end type
type em_datez from editmask within w_saletask_fx
end type
type st_4 from statictext within w_saletask_fx
end type
type sle_likestr from u_sleedit within w_saletask_fx
end type
type cb_toppage from uo_imflatbutton within w_saletask_fx
end type
type cb_page_ch from uo_imflatbutton within w_saletask_fx
end type
type em_pagesize from editmask within w_saletask_fx
end type
type cb_outware from uo_imflatbutton within w_saletask_fx
end type
type cb_retrieve from uo_imflatbutton within w_saletask_fx
end type
type cb_print from uo_imflatbutton within w_saletask_fx
end type
type cb_2 from uo_imflatbutton within w_saletask_fx
end type
type cb_file from uo_imflatbutton within w_saletask_fx
end type
type st_5 from statictext within w_saletask_fx
end type
type cb_3 from commandbutton within w_saletask_fx
end type
type cb_4 from commandbutton within w_saletask_fx
end type
end forward

global type w_saletask_fx from w_publ_base_style
integer width = 4713
integer height = 2756
string title = "材料采购订单"
boolean maxbox = true
boolean resizable = true
long backcolor = 16777215
string icon = "graphics\chain_link_128px.ico"
dw_saletask_list dw_saletask_list
dw_saletask dw_saletask
tab_1 tab_1
st_1 st_1
ddlb_status ddlb_status
st_2 st_2
em_datea em_datea
st_3 st_3
em_datez em_datez
st_4 st_4
sle_likestr sle_likestr
cb_toppage cb_toppage
cb_page_ch cb_page_ch
em_pagesize em_pagesize
cb_outware cb_outware
cb_retrieve cb_retrieve
cb_print cb_print
cb_2 cb_2
cb_file cb_file
st_5 st_5
cb_3 cb_3
cb_4 cb_4
end type
global w_saletask_fx w_saletask_fx

type variables
long ins_cur_pageNum = 1 // 用于记录当前页码
long ins_totalPages = 1 // 用于记录总页数

datawindow dw_saletaskmx // 订单明细
datawindow dw_jd_ordermx // 工组进度左表
datawindow dw_jd // 工组进度右表
datawindow dw_outware_log, dw_fx_outware_badqc // 发货记录

datastore ins_ds_jd

boolean edit_jd = false // 工组进度编辑状态
boolean edit_qty_ready = false // 已分配数编辑状态

s_fx_wrkgrp_jd ins_s_jds_del // 用于存放需要删除的进度ID
end variables

forward prototypes
public function integer wf_retrieve_saletask ()
public function integer wf_retrieve_saletaskmx (readonly long arg_taskid)
public function integer wf_retrieve_jd ()
public function integer wf_save_jd ()
public function integer wf_retrieve_outwarelog ()
public subroutine wf_face ()
public subroutine wf_init_split ()
public function integer wf_save_qty_ready ()
public subroutine wf_copy_qty_ready (long a_mode)
public subroutine wf_retrieve_badqc ()
end prototypes

public function integer wf_retrieve_saletask ();int rslt = 1

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

long status
long ll_pos
ll_pos = Pos(ddlb_status.Text, '[')
if (ll_pos <= 0) then
	status = -1
else
	status = Long(Mid(ddlb_status.Text, ll_pos + 1, Len(ddlb_status.Text) - ll_pos - 1))
end if

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,request
//obj = FXAppCom.GetSaletask(app_token_fx, pageSize, pageNum, status, String(dateA), String(dateZ), likeStr, ref arg_msg)

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetInt('pageSize', pageSize)
request.SetInt('pageNum', pageNum)
request.SetInt('status', status)
request.SetString('dateA', String(dateA))
request.SetString('dateZ', String(dateZ))
request.SetString('likeStr', likeStr)
request.SetInt('billtype', 0)	//材料采购订单

obj = FXAppCom.DoExecute('GetSaletask', request)
arg_msg = obj.GetString('ErrMsg')


if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

dw_saletask_list.Reset( )
dw_saletask.Reset( )
dw_saletaskmx.Reset( )

dw_saletask_list.SetRedraw(false)
long i, row
any moddate, replyrqdate, replydate, accomplishdate,erpConfirmDate 
ins_totalPages = obj.GetInt('totalPages')
oleobject list, item
list = obj.GetArrOfPBDictionary('saletasks')
for i = 1 to list.Count
	item = list.GetItem(i - 1)
	
	row = dw_saletask_list.InsertRow(0)
	long taskidd
	taskidd = item.GetInt('taskid')
	dw_saletask_list.Object.taskid[row] = item.GetInt('taskid') // 订单ID int
	dw_saletask_list.Object.cuscomid[row] = item.GetInt('cuscomid') // cuscomid int
	dw_saletask_list.Object.tid[row] = item.GetString('tid') // 云端订单编号 varchar(50)
	dw_saletask_list.Object.taskdate[row] = item.GetDateTime('taskdate') // 下单日期 datetime
	dw_saletask_list.Object.cus_rep[row] = item.GetString('cus_rep') // 收货人 varchar(30)
	dw_saletask_list.Object.cus_tele[row] = item.GetString('cus_tele') // 联系电话 varchar(100)
	dw_saletask_list.Object.cus_address[row] = item.GetString('cus_address') // 收货地址 varchar(255)
	dw_saletask_list.Object.freight[row] = item.GetString('freight') // 货运部 varchar(50)
	dw_saletask_list.Object.freight_tele[row] = item.GetString('freight_tele') // 货运部电话 varchar(50)
	dw_saletask_list.Object.opemp[row] = item.GetString('opemp') // 建立人 varchar(255)
	dw_saletask_list.Object.opdate[row] = item.GetDateTime('opdate') // 建立时间 datetime
	dw_saletask_list.Object.modemp[row] = item.GetString('modemp') // 修改人 varchar(255)
	moddate = item.GetDateTime('moddate') // 修改时间 datetime
	if (not IsNull(moddate)) then
		dw_saletask_list.Object.moddate[row] = moddate
	end if
	dw_saletask_list.Object.buyer_name[row] = item.GetString('buyer_name') // 客户名称 varchar(30)
	dw_saletask_list.Object.buyer_tele[row] = item.GetString('buyer_tele') // 客户电话 varchar(100)
	dw_saletask_list.Object.requiredate[row] = item.GetDateTime('requiredate') // 要求交期 datetime
	dw_saletask_list.Object.temp1[row] = item.GetString('temp1') // 备注 dscrp varchar(255)
	dw_saletask_list.Object.temp2[row] = item.GetString('temp2') // 生产备注 dscrp2 varchar(255)
	dw_saletask_list.Object.temp3[row] = item.GetString('temp3') // 辅助备注 dscrp3 varchar(255)
	dw_saletask_list.Object.temp4[row] = item.GetString('temp4') // 自定义4 varchar(255)
	dw_saletask_list.Object.temp5[row] = item.GetString('temp5') // 自定义5 varchar(255)
	dw_saletask_list.Object.temp6[row] = item.GetString('temp6') // 自定义6 varchar(255)
	dw_saletask_list.Object.price_emp[row] = item.GetString('price_emp') // 报价人 varchar(255)
	replyrqdate = item.GetDateTime('replyrqdate') // 回复交期 datetime
	if (not IsNull(replyrqdate)) then
		dw_saletask_list.Object.replyrqdate[row] = replyrqdate
	end if
	dw_saletask_list.Object.replydscrp[row] = item.GetString('replydscrp') // 审核意见 varchar(255)
	replydate = item.GetDateTime('replydate') // 回复时间 datetime
	if (not IsNull(replydate)) then
		dw_saletask_list.Object.replydate[row] = item.GetDateTime('replydate')
	end if
	dw_saletask_list.Object.confirmemp[row] = item.GetString('confirmemp') // 下单人 varchar(255)
	dw_saletask_list.Object.confirmdate[row] = item.GetDateTime('confirmdate') // 下单时间 datetime
	dw_saletask_list.Object.status[row] = item.GetInt('status') // 订单状态 tinyint
	dw_saletask_list.Object.taskcode[row] = item.GetString('taskcode') // ERP订单编号 varchar(30)
	dw_saletask_list.Object.outwarecode[row] = item.GetString('outwarecode') // ERP发货单编号 varchar(30)
	dw_saletask_list.Object.fstatus[row] = item.GetInt('fstatus') // 工厂进度 int
	dw_saletask_list.Object.myrelcode[row] = item.GetString('relcode') // 分销企业在ERP企业内的编号
	dw_saletask_list.Object.daynum[row] = item.GetInt('daynum')//延期列
	accomplishdate = item.GetDateTime('accomplishdate') 
	if (not isNull(accomplishdate)) then
		dw_saletask_list.Object.accomplishdate[row] = item.GetDateTime('accomplishdate') // 完成时间 datetime
	end if
	dw_saletask_list.Object.erpConfirmEmp[row] = item.GetString('erpConfirmEmp') // 接收人
	erpConfirmDate = item.GetDateTime('erpConfirmDate') 
	if (not isNull(erpConfirmDate)) then
		dw_saletask_list.Object.erpConfirmDate[row] = erpConfirmDate // 接收时间 datetime
	end if
	dw_saletask_list.Object.mtfj_status[row] = item.GetString('mtfj_status') // 唛头附件状态
next
dw_saletask_list.SetRedraw(true)

//if (arg_msg <> '') then
//	rslt = 0
//	goto ext
//end if

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

return rslt
end function

public function integer wf_retrieve_saletaskmx (readonly long arg_taskid);int rslt = 1

if (IsNull(arg_taskid)) then return 0

string arg_msg = ''
oleobject list,request,response
request = FXAppCom.CreatePbDictionary()
request.SetString("token",app_token_fx)
request.SetInt("taskid",arg_taskid)
response = FXAppCom.DoExecute("GetSaletaskmx", request)
if (arg_msg <> '') then
	rslt = 0
	MessageBox('提示', '获取订单明细有误:' + arg_msg)
	goto ext
end if
list = response.GetArrOfPBDictionary('mxs')
// 订单明细
dw_saletaskmx.Reset( )
dw_saletaskmx.SetRedraw(false)
long i
any requiredate
oleobject item

IF ISNULL(list) THEN 
	return rslt
END IF

for i = 1 to list.Count
	item = list.GetItem(i - 1)
	
	dw_saletaskmx.Object.taskid[i] = item.GetInt('taskid')
	dw_saletaskmx.Object.printid[i] = item.GetInt('printid')
	dw_saletaskmx.Object.mxcode[i] = item.GetString('mxcode')
	dw_saletaskmx.Object.fxmtrlid[i] = item.GetInt('fxmtrlid')
	dw_saletaskmx.Object.mtrlid[i] = item.GetInt('mtrlid')
	dw_saletaskmx.Object.mtrlcode[i] = item.GetString('mtrlcode')
	dw_saletaskmx.Object.mtrlname[i] = item.GetString('mtrlname')
	dw_saletaskmx.Object.mtrlmode[i] = item.GetString('mtrlmode')
	dw_saletaskmx.Object.status[i] = item.GetString('status')
	dw_saletaskmx.Object.woodcode[i] = item.GetString('woodcode')
	dw_saletaskmx.Object.pcode[i] = item.GetString('pcode')
	dw_saletaskmx.Object.qty[i] = item.GetDouble('qty')
	dw_saletaskmx.Object.qty_wait[i] = item.GetDouble('qtyWait')
	dw_saletaskmx.Object.cus_receiveqty[i] = item.GetDouble('cus_receiveqty')
	dw_saletaskmx.Object.price[i] = item.GetDouble('price')
	dw_saletaskmx.Object.mxdscrp[i] = item.GetString('mxdscrp')
	dw_saletaskmx.Object.mxdscrp2[i] = item.GetString('mxdscrp2')
	dw_saletaskmx.Object.mtrlcuscode[i] = item.GetString('mtrlcuscode')
	dw_saletaskmx.Object.plancode[i] = item.GetString('plancode')
	dw_saletaskmx.Object.cus_mtrldef_senddays[i] = item.GetDouble('cus_mtrldef_senddays')
	dw_saletaskmx.SetItem(i, 'earliestsenddate', item.GetDateTime('earliestSendDate'))
	requiredate = item.GetDateTime('requiredate')
	if (not IsNull(requiredate)) then
		dw_saletaskmx.Object.requiredate[i] = requiredate
	end if
	dw_saletaskmx.Object.qty_ready[i] = item.GetDouble('qty_ready')
	dw_saletaskmx.Object.sptflagstr[i] = item.GetString('sptFlagStr')
	dw_saletaskmx.Object.date_confirm_flag[i] = item.GetInt('date_confirm_flag')
     
	dw_saletaskmx.Object.stopQty[i] = item.GetDouble('stopQty')
	dw_saletaskmx.Object.stopEmp[i] = item.GetString('stopEmp')
	IF NOT IsNull(item.GetDateTime('stopDate')) THEN
		dw_saletaskmx.Object.stopDate[i] =  item.GetDateTime('stopDate')
	END IF
	dw_saletaskmx.Object.stopReason[i] = item.GetString('stopReason')
	dw_saletaskmx.Object.gydscrp[i] = item.GetString('gydscrp')
	dw_saletaskmx.Object.order_mtrlname_str[i] = item.GetString('order_mtrlname_str')
	dw_saletaskmx.Object.saletask_mxid[i] = item.GetInt('saletask_mxid')
	dw_saletaskmx.Object.finishqty[i] = item.GetDouble('finishqty')
	dw_saletaskmx.Object.nofinishqty[i] = item.GetDouble('nofinishqty')
	dw_saletaskmx.Object.l1unit[i] = item.GetString('L1unit')
	dw_saletaskmx.Object.storagename[i] = item.GetString('storagename')
	dw_saletaskmx.Object.relcodestr[i] = item.GetString('relcodestr')
	dw_saletaskmx.Object.taskcodestr[i] = item.GetString('taskcodestr')
next
dw_saletaskmx.AcceptText()
dw_saletaskmx.SetSort('printid')
dw_saletaskmx.Sort()
dw_saletaskmx.SetRedraw(true)

// 工组进度 左侧dw
dw_jd_ordermx.Reset()
dw_jd_ordermx.SetRedraw(false)
for i = 1 to dw_saletaskmx.RowCount()
	dw_jd_ordermx.Object.taskid[i] = dw_saletaskmx.Object.taskid[i]
	dw_jd_ordermx.Object.printid[i] = dw_saletaskmx.Object.printid[i]
	dw_jd_ordermx.Object.mtrlcode[i] = dw_saletaskmx.Object.mtrlcode[i]
	dw_jd_ordermx.Object.mtrlname[i] = dw_saletaskmx.Object.mtrlname[i]
	dw_jd_ordermx.Object.qty[i] = dw_saletaskmx.Object.qty[i]
	dw_jd_ordermx.Object.qty_ready[i] = dw_saletaskmx.Object.qty_ready[i]
	dw_jd_ordermx.Object.mtrlcuscode[i] = dw_saletaskmx.Object.mtrlcuscode[i]
	dw_jd_ordermx.Object.plancode[i] = dw_saletaskmx.Object.plancode[i]
next
if (dw_jd_ordermx.RowCount() > 0) then
	dw_jd_ordermx.SelectRow(0, false)
	dw_jd_ordermx.SelectRow(1, true)
end if
dw_jd_ordermx.SetRedraw(true)

if (f_find_fx_user_power(31, ref arg_msg) <> 1) then // 31-采购订单查看(单价)
	dw_saletaskmx.Modify('destroy price_t ~r~n destroy price ~r~n')
end if

ext:
return rslt


end function

public function integer wf_retrieve_jd ();int rslt = 1

if tab_1.control[tab_1.SelectedTab].text <> '进度' then goto ext // 当前tab不是工组进度，跳出

dw_jd.Reset()

string arg_msg
long row, taskid
row = dw_saletask_list.GetRow()
if IsNull(row) then goto ext
if (row <= 0) then goto ext
taskid = dw_saletask_list.Object.taskid[row]
if IsNull(taskid) then goto ext

// 获取工组进度(按订单获取，不区分明细)
if (ins_ds_jd.RowCount() <= 0) then
	if (row <= 0) then
		rslt = 0
		MessageBox('提示', '当前没有订单,获取工组进度失败')
		goto ext
	end if
	
	if (taskid <= 0) then goto ext
	
	oleobject list, item
	list = FXAppCom.GetWrkgrpJdByTaskid(app_token_fx, taskid, ref arg_msg)
	if (arg_msg <> '') then
		rslt = 0
		MessageBox('提示', '获取工组进度失败:' + arg_msg)
		goto ext
	end if
	
	for row = 1 to list.Count
		item = list.GetItem(row - 1)
		
		ins_ds_jd.Object.taskid[row] = item.GetInt('taskid')
		ins_ds_jd.Object.printid[row] = item.GetInt('printid')
		ins_ds_jd.Object.jdprintid[row] = item.GetInt('jdprintid')
		ins_ds_jd.Object.wrkgrpname[row] = item.GetString('wrkgrpname')
		ins_ds_jd.Object.orderqty[row] = item.GetDouble('orderqty')
		ins_ds_jd.Object.taskqty[row] = item.GetDouble('taskqty')
		ins_ds_jd.Object.finishqty[row] = item.GetDouble('finishqty')
		ins_ds_jd.Object.username[row] = item.GetString('username')
		ins_ds_jd.Object.editdate[row] = item.GetDateTime('editdate')
	next
end if

if (ins_ds_jd.RowCount() <= 0) then goto ext

row = dw_jd_ordermx.GetRow()
if not dw_jd_ordermx.IsSelected(row) then goto ext // 工组进度左侧dw没有选中明细，跳出

long printid
printid = dw_jd_ordermx.Object.printid[row]

dw_jd.SetRedraw(false)
long indexA = 1, indexZ
string findstr
findstr = 'taskid=' + string(taskid) + ' and printid=' + string(printid)
indexZ = ins_ds_jd.RowCount()
indexA = ins_ds_jd.Find(findstr, indexA, indexZ)
do while indexA > 0
	row = dw_jd.InsertRow(0)
	
	dw_jd.Object.taskid[row] = ins_ds_jd.Object.taskid[indexA]
	dw_jd.Object.printid[row] = ins_ds_jd.Object.printid[indexA]
	dw_jd.Object.jdprintid[row] = ins_ds_jd.Object.jdprintid[indexA]
	dw_jd.Object.wrkgrpname[row] = ins_ds_jd.Object.wrkgrpname[indexA]
	dw_jd.Object.orderqty[row] = ins_ds_jd.Object.orderqty[indexA]
	dw_jd.Object.taskqty[row] = ins_ds_jd.Object.taskqty[indexA]
	dw_jd.Object.finishqty[row] = ins_ds_jd.Object.finishqty[indexA]
	dw_jd.Object.username[row] = ins_ds_jd.Object.username[indexA]
	dw_jd.Object.editdate[row] = ins_ds_jd.Object.editdate[indexA]
	
	if (indexA + 1 <= indexZ) then
		indexA = ins_ds_jd.Find(findstr, indexA + 1, indexZ)
	else
		exit
	end if
loop
dw_jd.SetRedraw(true)


ext:
return rslt


end function

public function integer wf_save_jd ();int rslt = 1

if not edit_jd then return 0

if dw_jd.RowCount() <= 0 then
	rslt = 0
	MessageBox('提示', '没有需要保存的内容')
	goto ext
end if

long i = 0, temp_row = 0
long rows[]
do
	temp_row = dw_jd.GetNextModified(temp_row, Primary!) // 获取增/改部分
	if (temp_row > 0) then
		i ++
		rows[i] = temp_row
	end if
loop while temp_row > 0

if (UpperBound(rows) <= 0) then
	rslt = 0
	MessageBox('提示', '没有更改,或点击"放弃"返回')
	goto ext
end if

for i = 1 to dw_jd.RowCount()
	if Trim(dw_jd.Object.wrkgrpname[i]) = '' then
		rslt = 0
		MessageBox('提示', '工组名称不能为空')
		goto ext
	end if
	if (dw_jd.Object.taskqty[i] < 0) then
		rslt = 0
		MessageBox('提示', '已派工数不能小于0')
		goto ext
	end if
	if (dw_jd.Object.finishqty[i] < 0) then
		rslt = 0
		MessageBox('提示', '已完工数不能小于0')
		goto ext
	end if
next

oleobject list, item
list = FXAppCom.CreArrOfPbDictionary()
for i = 1 to UpperBound(rows)
	item = FXAppCom.CreatePbDictionary()
	
	item.SetInt('taskid', dw_jd.Object.taskid[rows[i]])
	item.SetInt('printid', dw_jd.Object.printid[rows[i]])
	item.SetInt('jdprintid', dw_jd.Object.jdprintid[rows[i]])
	item.SetString('wrkgrpname', dw_jd.Object.wrkgrpname[rows[i]])
	item.SetDouble('orderqty', dw_jd.Object.orderqty[rows[i]])
	item.SetDouble('taskqty', dw_jd.Object.taskqty[rows[i]])
	item.SetDouble('finishqty', dw_jd.Object.finishqty[rows[i]])
	
	list.Add(item)
next

string arg_msg
FXAppCom.AddWrkgrpJd(app_token_fx, list, ref arg_msg)

if (arg_msg <> '') then
	rslt = 0
	MessageBox('提示', '修改工组进度失败:' + arg_msg)
	goto ext
end if

if (UpperBound(ins_s_jds_del.jdprintid) > 0) then // 删除部分
	list = FXAppCom.CreArrOfPbDictionary()
	for i = 1 to UpperBound(ins_s_jds_del.jdprintid)
		item = FXAppCom.CreatePbDictionary()
		
		item.SetInt('taskid', ins_s_jds_del.taskid[i])
		item.SetInt('printid', ins_s_jds_del.printid[i])
		item.SetInt('jdprintid', ins_s_jds_del.jdprintid[i])
		
		list.Add(item)
	next
	
	FXAppCom.DelWrkgrpJd(app_token_fx, list, ref arg_msg)
	
	if (arg_msg <> '') then
		rslt = 0
		MessageBox('提示', '删除工组进度失败:' + arg_msg)
		goto ext
	end if
end if

ext:
if rslt = 1 then
	ins_ds_jd.Reset()
	wf_retrieve_jd()
	MessageBox('提示', '保存成功')
end if

return rslt


end function

public function integer wf_retrieve_outwarelog ();int rslt = 1

if tab_1.control[tab_1.SelectedTab].text <> '发货记录' then goto ext // 当前tab不是发货记录，跳出

if (dw_outware_log.RowCount() > 0) then goto ext // 当前已有记录，跳出

dw_outware_log.Reset()

string arg_msg
long row, taskid
row = dw_saletask_list.GetRow()
if IsNull(row) then goto ext
if (row <= 0) then goto ext
taskid = dw_saletask_list.Object.taskid[row]
if IsNull(taskid) then goto ext

oleobject request, response
oleobject list, item

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetInt('taskid', taskid)

response = FXAppCom.DoExecute('GetOutwareLogByTaskid', request)
arg_msg = response.GetString('ErrMsg')

if (arg_msg <> '') then
	rslt = 0
	MessageBox('提示', '获取发货记录失败:' + arg_msg)
	goto ext
end if

list = response.GetPBArray('logs')

datetime dt
any acceptdate, outwaredate
dt = datetime(date('1899-12-30'), time('00:00:00'))

dw_outware_log.SetRedraw(false)
long i
for i = 1 to list.Count
	item = list.GetPBDictionary(i - 1)
	
	row = dw_outware_log.InsertRow(0)

	dw_outware_log.SetItem(row, 'logid', item.GetInt('logid'))
	dw_outware_log.SetItem(row, 'taskid', item.GetInt('taskid'))
	dw_outware_log.SetItem(row, 'printid', item.GetInt('printid'))
	dw_outware_log.SetItem(row, 'mxcode', item.GetString('mxcode'))
	dw_outware_log.SetItem(row, 'qty', item.GetDouble('qty'))
	dw_outware_log.SetItem(row, 'userid', item.GetInt('userid'))
	dw_outware_log.SetItem(row, 'username', item.GetString('username'))
	dw_outware_log.SetItem(row, 'outwaredate', item.GetDateTime('outwaredate'))
	dw_outware_log.SetItem(row, 'outwarecode', item.GetString('outwarecode'))
	dw_outware_log.SetItem(row, 'acceptQty', item.GetDouble('acceptQty'))
	dw_outware_log.SetItem(row, 'logStatus', item.GetInt('logStatus'))
	dw_outware_log.SetItem(row, 'acceptUserName', item.GetString('acceptUserName'))
	dw_outware_log.SetItem(row, 'acceptdate', item.GetDateTime('acceptdate'))
	dw_outware_log.SetItem(row, 'inwarecode_erp', item.GetString('inwarecode_erp'))

	dw_outware_log.SetItem(row, 'tmpacceptqty', item.GetDouble('tmpacceptqty'))
	dw_outware_log.SetItem(row, 'tmpacceptemp', item.GetString('tmpacceptemp'))
	dw_outware_log.SetItem(row, 'checkqty', item.GetDouble('checkqty'))
	dw_outware_log.SetItem(row, 'goodqty', item.GetDouble('goodqty'))
	dw_outware_log.SetItem(row, 'badqty', item.GetDouble('badqty'))
	dw_outware_log.SetItem(row, 'goodinqty', item.GetDouble('goodinqty'))
	dw_outware_log.SetItem(row, 'badinqty', item.GetDouble('badinqty'))	
	dw_outware_log.SetItem(row, 'autocode', item.GetString('autocode'))	
	dw_outware_log.SetItem(row, 'mtrlcode', item.GetString('mtrlcode'))	
	dw_outware_log.SetItem(row, 'mtrlname', item.GetString('mtrlname'))	
	dw_outware_log.SetItem(row, 'mtrlmode', item.GetString('mtrlmode'))	
	dw_outware_log.SetItem(row, 'unit', item.GetString('unit'))	
next
dw_outware_log.SetRedraw(true)
wf_retrieve_badqc()

ext:
return rslt
end function

public subroutine wf_face ();string arg_msg
if edit_jd or edit_qty_ready then
	cb_retrieve.Enabled = false
	cb_outware.Enabled = false
	cb_exit.Enabled = false
	em_pagesize.Enabled = false
	cb_toppage.Enabled = false
	cb_page_ch.Enabled = false
	cb_print.Enabled = false
	ddlb_status.Enabled = false
	em_datea.Enabled = false
	em_datez.Enabled = false
	sle_likestr.Enabled = false
	
	if (edit_jd) then
		tab_1.tabpage_3.cb_addrow.Enabled = true
		tab_1.tabpage_3.cb_delrow.Enabled = true
		tab_1.tabpage_3.cb_quit_jd.Enabled = true
		tab_1.tabpage_3.cb_edit_qty_ready.Enabled = false
		
		dw_jd.SetTabOrder('wrkgrpname', 10)
		dw_jd.SetTabOrder('taskqty', 20)
		dw_jd.SetTabOrder('finishqty', 30)
		
		tab_1.tabpage_3.cb_edit_jd.Text = '保存'	
	elseif (edit_qty_ready) then
		tab_1.tabpage_3.cb_quit_qty_ready.Enabled = true
		tab_1.tabpage_3.cb_qty_ready_copy.Enabled = true
		tab_1.tabpage_3.cb_edit_jd.Enabled = false
		
		dw_jd_ordermx.SetTabOrder('qty_ready', 10)
		
		tab_1.tabpage_3.cb_edit_qty_ready.Text = '保存'
	end if
else
	cb_retrieve.Enabled = true
	if (f_find_fx_user_power(31, ref arg_msg) = 1) then // 31-销售订单发货
		cb_outware.Enabled = true
	end if
	cb_exit.Enabled = true
	em_pagesize.Enabled = true
	cb_toppage.Enabled = true
	cb_page_ch.Enabled = true
	if (f_find_fx_user_power(27, ref arg_msg) = 1) then // 27-销售订单数据发送
		cb_print.Enabled = true
	end if
	ddlb_status.Enabled = true
	em_datea.Enabled = true
	em_datez.Enabled = true
	sle_likestr.Enabled = true
	
	tab_1.tabpage_3.cb_addrow.Enabled = false
	tab_1.tabpage_3.cb_delrow.Enabled = false
	tab_1.tabpage_3.cb_quit_jd.Enabled = false
	dw_jd.SetTabOrder('wrkgrpname', 0)
	dw_jd.SetTabOrder('taskqty', 0)
	dw_jd.SetTabOrder('finishqty', 0)
	tab_1.tabpage_3.cb_edit_jd.Text = '修改工组进度'
	
	tab_1.tabpage_3.cb_quit_qty_ready.Enabled = false
	tab_1.tabpage_3.cb_qty_ready_copy.Enabled = false
	dw_jd_ordermx.SetTabOrder('qty_ready', 0)
	tab_1.tabpage_3.cb_edit_qty_ready.Text = '修改分配数'
	
	if (f_find_fx_user_power(38, ref arg_msg) = 1) then // 38-采购订单工组进度修改
		tab_1.tabpage_3.cb_edit_jd.Enabled = true
		tab_1.tabpage_3.cb_edit_qty_ready.Enabled = true
	end if
	if (f_find_fx_user_power(36, ref arg_msg) = 1) then // 36-采购订单数据发送
		cb_print.Enabled = true
	end if
end if


end subroutine

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

public function integer wf_save_qty_ready ();int rslt = 1

if (not edit_qty_ready) then return 0

if (dw_jd_ordermx.RowCount() <= 0) then
	rslt = 0
	MessageBox('提示', '没有需要保存的内容')
	goto ext
end if

long i
oleobject list, item, parm
list = FXAppCom.NewPBArray()
for i = 1 to dw_jd_ordermx.RowCount()
	item = FXAppCom.CreatePbDictionary()
	
	item.SetInt('taskid', dw_jd_ordermx.Object.taskid[i])
	item.SetInt('printid', dw_jd_ordermx.Object.printid[i])
	item.SetDouble('qty_ready', dw_jd_ordermx.Object.qty_ready[i])
	
	list.AddObject(item)
next

parm = FXAppCom.CreatePbDictionary()
parm.SetString('token', app_token_fx)
parm.SetObject('list', list)

string arg_msg
FXAppCom.EditSaletaskmxQtyReady(parm, ref arg_msg)
if (arg_msg <> '') then
	rslt = 0
	MessageBox('提示', '修改分配数失败:' + arg_msg)
	goto ext
end if

ext:
if (rslt = 1) then
	MessageBox('提示', '保存成功')
end if
return rslt




end function

public subroutine wf_copy_qty_ready (long a_mode);// 修改/保存/放弃 编辑分配数使用

// a_mode：
// 1 - 从tabpage_1的复制到tabpage_3的
// 3 - 从tabpage_3的复制到tabpage_1的

dw_saletaskmx.SetFilter('')
dw_saletaskmx.Filter()

dw_jd_ordermx.SetFilter('')
dw_jd_ordermx.Filter()

long i
long tmp_taskid, tmp_printid, findRow
decimal tmp_qty_ready
string findStr
if (a_mode = 1) then // 从tabpage_1的复制到tabpage_3的  失败/放弃的时候
	for i = 1 to dw_saletaskmx.RowCount()
		tmp_taskid = dw_saletaskmx.Object.taskid[i]
		tmp_printid = dw_saletaskmx.Object.printid[i]
		tmp_qty_ready = dw_saletaskmx.Object.qty_ready[i]
		
		findStr = 'taskid = ' + string(tmp_taskid) + ' and printid = ' + string(tmp_printid)
		findRow = dw_jd_ordermx.Find(findStr, 1, dw_jd_ordermx.RowCount())
		if (findRow > 0) then
			dw_jd_ordermx.Object.qty_ready[findRow] = tmp_qty_ready
		end if
	next
elseif (a_mode = 3) then // 从tabpage_3的复制到tabpage_1的  修改成功的时候
	for i = 1 to dw_jd_ordermx.RowCount()
		tmp_taskid = dw_jd_ordermx.Object.taskid[i]
		tmp_printid = dw_jd_ordermx.Object.printid[i]
		tmp_qty_ready = dw_jd_ordermx.Object.qty_ready[i]
		
		findStr = 'taskid = ' + string(tmp_taskid) + ' and printid = ' + string(tmp_printid)
		findRow = dw_saletaskmx.Find(findStr, 1, dw_saletaskmx.RowCount())
		if (findRow > 0) then
			dw_saletaskmx.Object.qty_ready[findRow] = tmp_qty_ready
		end if
	next
end if

dw_saletaskmx.AcceptText()
dw_jd_ordermx.AcceptText()




end subroutine

public subroutine wf_retrieve_badqc ();Long ll_row
String arg_msg

Int rslt = 1

dw_fx_outware_badqc.Reset()

ll_row = dw_outware_log.GetRow()

IF ll_row <= 0 THEN RETURN

Long ll_logid
ll_logid = dw_outware_log.Object.LogID[ll_row]

IF ll_logid <= 0 THEN RETURN

oleobject req, rsp

req = FXAppCom.CreatePbDictionary()
req.SetString('token', app_token_fx)
req.SetInt('logid', ll_logid)

rsp = FXAppCom.DoExecute('GetFxOutwareBadQc', req)
arg_msg = rsp.GetString('ErrMsg')

If (arg_msg <> '') THEN
	rslt = 0
	MessageBox('提示', '获取发货记录的质检进度失败:' + arg_msg)
	GOTO ext
END IF

oleobject list, Item
list = rsp.GetPBArray('badQcList')

dw_fx_outware_badqc.SetRedraw(False)
Long i, row
FOR i = 1 To list.Count
	Item = list.GetPBDictionary(i - 1)
	
	row = dw_fx_outware_badqc.InsertRow(0)
	
	dw_fx_outware_badqc.SetItem(row, 'logid', Item.GetInt('logid'))
	dw_fx_outware_badqc.SetItem(row, 'printid', Item.GetInt('printid'))
	dw_fx_outware_badqc.SetItem(row, 'itemname', Item.GetString('itemname'))
	dw_fx_outware_badqc.SetItem(row, 'badqty', Item.GetDouble('badqty'))
	dw_fx_outware_badqc.SetItem(row, 'goodqty', Item.GetDouble('goodqty'))
	dw_fx_outware_badqc.SetItem(row, 'mxdscrp', Item.GetString('mxdscrp'))
	dw_fx_outware_badqc.SetItem(row, 'checkemp', Item.GetString('checkemp'))
	dw_fx_outware_badqc.SetItem(row, 'QcResult', Item.GetString('QcResult'))
	dw_fx_outware_badqc.SetItem(row, 'Environmen', Item.GetString('Environmen'))
	dw_fx_outware_badqc.SetItem(row, 'Method', Item.GetString('Method'))
	dw_fx_outware_badqc.SetItem(row, 'Basis', Item.GetString('Basis'))
	dw_fx_outware_badqc.SetItem(row, 'Equipment', Item.GetString('Equipment'))
	dw_fx_outware_badqc.SetItem(row, 'Standard', Item.GetString('Standard'))
	dw_fx_outware_badqc.SetItem(row, 'checkqty', Item.GetDouble('checkqty'))
	
NEXT
dw_fx_outware_badqc.SetRedraw(True)

ext:


end subroutine

on w_saletask_fx.create
int iCurrent
call super::create
this.dw_saletask_list=create dw_saletask_list
this.dw_saletask=create dw_saletask
this.tab_1=create tab_1
this.st_1=create st_1
this.ddlb_status=create ddlb_status
this.st_2=create st_2
this.em_datea=create em_datea
this.st_3=create st_3
this.em_datez=create em_datez
this.st_4=create st_4
this.sle_likestr=create sle_likestr
this.cb_toppage=create cb_toppage
this.cb_page_ch=create cb_page_ch
this.em_pagesize=create em_pagesize
this.cb_outware=create cb_outware
this.cb_retrieve=create cb_retrieve
this.cb_print=create cb_print
this.cb_2=create cb_2
this.cb_file=create cb_file
this.st_5=create st_5
this.cb_3=create cb_3
this.cb_4=create cb_4
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.dw_saletask_list
this.Control[iCurrent+2]=this.dw_saletask
this.Control[iCurrent+3]=this.tab_1
this.Control[iCurrent+4]=this.st_1
this.Control[iCurrent+5]=this.ddlb_status
this.Control[iCurrent+6]=this.st_2
this.Control[iCurrent+7]=this.em_datea
this.Control[iCurrent+8]=this.st_3
this.Control[iCurrent+9]=this.em_datez
this.Control[iCurrent+10]=this.st_4
this.Control[iCurrent+11]=this.sle_likestr
this.Control[iCurrent+12]=this.cb_toppage
this.Control[iCurrent+13]=this.cb_page_ch
this.Control[iCurrent+14]=this.em_pagesize
this.Control[iCurrent+15]=this.cb_outware
this.Control[iCurrent+16]=this.cb_retrieve
this.Control[iCurrent+17]=this.cb_print
this.Control[iCurrent+18]=this.cb_2
this.Control[iCurrent+19]=this.cb_file
this.Control[iCurrent+20]=this.st_5
this.Control[iCurrent+21]=this.cb_3
this.Control[iCurrent+22]=this.cb_4
end on

on w_saletask_fx.destroy
call super::destroy
destroy(this.dw_saletask_list)
destroy(this.dw_saletask)
destroy(this.tab_1)
destroy(this.st_1)
destroy(this.ddlb_status)
destroy(this.st_2)
destroy(this.em_datea)
destroy(this.st_3)
destroy(this.em_datez)
destroy(this.st_4)
destroy(this.sle_likestr)
destroy(this.cb_toppage)
destroy(this.cb_page_ch)
destroy(this.em_pagesize)
destroy(this.cb_outware)
destroy(this.cb_retrieve)
destroy(this.cb_print)
destroy(this.cb_2)
destroy(this.cb_file)
destroy(this.st_5)
destroy(this.cb_3)
destroy(this.cb_4)
end on

event open;dw_saletaskmx = tab_1.tabpage_1.dw_saletaskmx
dw_jd_ordermx = tab_1.tabpage_3.dw_jd_ordermx
dw_jd = tab_1.tabpage_3.dw_jd
dw_outware_log = tab_1.tabpage_2.dw_outware_log
dw_fx_outware_badqc = tab_1.tabpage_2.dw_fx_outware_badqc
// 因为resize内对dw使用了以上缩写，父类open事件首先触发resize，会造成null object问题
this.triggerevent('ue_before_open')
wf_movetocenter()

wf_init_split()

string arg_msg // 30-采购订单 31-采购订单查看(单价)
if (f_find_fx_user_power(30, ref arg_msg) <> 1 &
		and f_find_fx_user_power(31, 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())

ddlb_status.SelectItem(6)

ins_ds_jd = create datastore
ins_ds_jd.DataObject = 'dw_fx_wrkgrp_jd'
ins_ds_jd.Reset()

wf_retrieve_saletask( )

//dw_saletaskmx.Modify("cus_receiveqty_t.Text = '已发货数'")
//dw_saletaskmx.Modify("destroy mxcode_t~n destroy mxcode~n")

//dw_jd_ordermx.Modify("destroy mxcode_t~n destroy mxcode~n")
//dw_jd_ordermx.Modify("destroy mtrlmode_t~n destroy mtrlmode~n")
//dw_jd_ordermx.Modify("destroy qty_wait_t~n destroy qty_wait~n")
//dw_jd_ordermx.Modify("destroy cus_receiveqty_t~n destroy cus_receiveqty~n")
//dw_jd_ordermx.Modify("destroy requiredate_t~n destroy requiredate~n")
//dw_jd_ordermx.Modify("destroy price_t~n destroy price~n")
//dw_jd_ordermx.Modify("destroy mtrlcuscode_t~n destroy mtrlcuscode~n")
//dw_jd_ordermx.Modify("destroy mxdscrp_t~n destroy mxdscrp~n")
//dw_jd_ordermx.Modify("destroy mxdscrp2_t~n destroy mxdscrp2~n")
//dw_jd_ordermx.Modify("destroy status_t~n destroy status~n")
//dw_jd_ordermx.Modify("destroy woodcode_t~n destroy woodcode~n")
//dw_jd_ordermx.Modify("destroy pcode_t~n destroy pcode~n")

//dw_jd_ordermx.Modify("mxcode_t.visible=false~r~n mxcode.visible=false~r~n")
//dw_jd_ordermx.Modify("mtrlmode_t.visible=false~r~n mtrlmode.visible=false~r~n")
//dw_jd_ordermx.Modify("qty_wait_t.visible=false~r~n qty_wait.visible=false~r~n")
//dw_jd_ordermx.Modify("cus_receiveqty_t.visible=false~r~n cus_receiveqty.visible=false~r~n")
//dw_jd_ordermx.Modify("requiredate_t.visible=false~r~n requiredate.visible=false~r~n")
//dw_jd_ordermx.Modify("price_t.visible=false~r~n price.visible=false~r~n")
//dw_jd_ordermx.Modify("mtrlcuscode_t.visible=false~r~n mtrlcuscode.visible=false~r~n")
//dw_jd_ordermx.Modify("mxdscrp_t.visible=false~r~n mxdscrp.visible=false~r~n")
//dw_jd_ordermx.Modify("mxdscrp2_t.visible=false~r~n mxdscrp2.visible=false~r~n")
//dw_jd_ordermx.Modify("status_t.visible=false~r~n status.visible=false~r~n")
//dw_jd_ordermx.Modify("woodcode_t.visible=false~r~n woodcode.visible=false~r~n")
//dw_jd_ordermx.Modify("pcode_t.visible=false~r~n pcode.visible=false~r~n")

if (f_find_fx_user_power(36, ref arg_msg) <> 1) then // 36-采购订单数据发送
	cb_print.Enabled = false
end if

if (f_find_fx_user_power(37, ref arg_msg) <> 1) then // 37-采购订单工组进度查看
	tab_1.tabpage_3.Visible = false
elseif (f_find_fx_user_power(38, ref arg_msg) <> 1) then // 38-采购订单工组进度修改
	tab_1.tabpage_3.cb_edit_jd.Enabled = false
	tab_1.tabpage_3.cb_edit_qty_ready.Enabled = false
end if

if (f_find_fx_user_power(39, ref arg_msg) <> 1) then // 39-采购订单发货记录查看
	tab_1.tabpage_2.Visible = false
end if
if (f_find_fx_user_power(40, ref arg_msg) <> 1) then // 40-采购订单发货
	cb_outware.Enabled = false
end if



end event

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

dw_saletask_list.Width = this.workspacewidth( ) - dw_saletask.Width - 10

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

// 按钮靠右
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

// 订单明细
dw_saletaskmx.Width = tab_1.Width - 20
dw_saletaskmx.Height = tab_1.Height - 200
// 发货记录
dw_outware_log.Width = tab_1.Width - 20 - dw_fx_outware_badqc.width
dw_outware_log.Height = tab_1.Height - (876 - 772) - dw_outware_log.Y
dw_fx_outware_badqc.X = dw_outware_log.X + dw_outware_log.Width
dw_fx_outware_badqc.Height = dw_outware_log.Height + dw_outware_log.Y
// 工组进度
dw_jd_ordermx.Height = tab_1.Height - 200
if (dw_jd_ordermx.Width + 200 >= tab_1.tabpage_3.Width) then
	dw_jd_ordermx.Width = tab_1.tabpage_3.Width / 2 * 1
end if
dw_jd.Width = tab_1.Width - dw_jd_ordermx.Width - 55
dw_jd.Height = dw_jd_ordermx.Height
// 工组进度-分割条
tab_1.tabpage_3.st_split.Y =  dw_jd_ordermx.Y
tab_1.tabpage_3.st_split.X = dw_jd_ordermx.X + dw_jd_ordermx.Width
tab_1.tabpage_3.st_split.Height = dw_jd_ordermx.Height
// 工组进度-按钮
dw_jd.X = tab_1.tabpage_3.st_split.X + tab_1.tabpage_3.st_split.Width
tab_1.tabpage_3.cb_edit_jd.X = dw_jd.X
tab_1.tabpage_3.cb_quit_jd.X = tab_1.tabpage_3.cb_edit_jd.X + tab_1.tabpage_3.cb_edit_jd.Width + 5
tab_1.tabpage_3.cb_addrow.X = tab_1.tabpage_3.cb_quit_jd.X + tab_1.tabpage_3.cb_quit_jd.Width + 5
tab_1.tabpage_3.cb_delrow.X = tab_1.tabpage_3.cb_addrow.X + tab_1.tabpage_3.cb_addrow.Width + 5

end event

event closequery;call super::closequery;if edit_jd or edit_qty_ready then return 1
end event

type cb_func from w_publ_base_style`cb_func within w_saletask_fx
boolean visible = false
integer x = 2469
integer taborder = 0
boolean enabled = false
end type

type cb_exit from w_publ_base_style`cb_exit within w_saletask_fx
integer x = 3735
integer taborder = 20
end type

type ln_bar from w_publ_base_style`ln_bar within w_saletask_fx
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_saletask_fx
end type

type r_bar from w_publ_base_style`r_bar within w_saletask_fx
integer x = 526
end type

type dw_saletask_list from u_dw_rbtnfilter within w_saletask_fx
integer x = 2126
integer y = 284
integer width = 1947
integer height = 1328
integer taborder = 120
boolean bringtotop = true
boolean titlebar = true
string title = "订单列表"
string dataobject = "dw_fx_saletask"
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 rowfocuschanged;call super::rowfocuschanged;if edit_jd or edit_qty_ready then return

if IsNull(currentrow) then
	IF THIS.rowcount() > 0 then
		THIS.SelectRow(0,FALSE)
		THIS.SelectRow(1,TRUE)
		THIS.setrow(1)
		currentrow =1
	end if
end if

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

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

// 根据单据状态 控制按钮
long status
status = this.Object.status[currentrow]
if (status = 3 or status = 6 or status = 7) then // 已下单 进行中 完成
	string arg_msg
	if (f_find_fx_user_power(40, ref arg_msg) = 1) then // 40-采购订单发货
		cb_outware.Enabled = true
	end if
else
	cb_outware.Enabled = false
end if

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

long taskid
taskid = this.Object.taskid[currentrow]
wf_retrieve_saletaskmx(taskid)

ins_ds_jd.Reset() // 切换新的订单，清空工组进度ds
dw_outware_log.ReSet() // 切换新的订单，清空发货记录

// 切换新的订单，根据当前tab页是否停留在"工组进度"进行获取进度信息
//if tab_1.control[ tab_1.SelectedTab].text = '工组进度' then wf_retrieve_jd()

// 切换新的订单，根据当前tab页是否停留在"发货记录"进行获取发货记录信息
//if tab_1.control[ tab_1.SelectedTab].text = '发货记录' then wf_retrieve_jd()
string tabText
tabText = tab_1.control[tab_1.SelectedTab].text
choose case tabText
	case '发货记录'
		wf_retrieve_outwarelog()
	case '进度'
		wf_retrieve_jd()
	case else
		
end choose




end event

type dw_saletask from datawindow within w_saletask_fx
integer x = 9
integer y = 288
integer width = 2117
integer height = 1316
integer taborder = 110
boolean bringtotop = true
string title = "none"
string dataobject = "dw_fx_saletask_ff"
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

type tab_1 from tab within w_saletask_fx
integer x = 5
integer y = 1616
integer width = 3840
integer height = 856
integer taborder = 130
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
tabpage_2 tabpage_2
tabpage_3 tabpage_3
end type

on tab_1.create
this.tabpage_1=create tabpage_1
this.tabpage_2=create tabpage_2
this.tabpage_3=create tabpage_3
this.Control[]={this.tabpage_1,&
this.tabpage_2,&
this.tabpage_3}
end on

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

event selectionchanged;string tabText
tabText = control[newindex].text
choose case tabText
	case '发货记录'
		wf_retrieve_outwarelog()
	case '进度'
		wf_retrieve_jd()
	case else
		
end choose
end event

event selectionchanging;if edit_jd or edit_qty_ready then
	MessageBox('提示', '修改状态不能切换当前操作页面')
	return 1
end if
end event

type tabpage_1 from userobject within tab_1
integer x = 18
integer y = 96
integer width = 3803
integer height = 744
long backcolor = 16777215
string text = "订单明细"
long tabtextcolor = 33554432
long tabbackcolor = 16777215
long picturemaskcolor = 536870912
dw_saletaskmx dw_saletaskmx
end type

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

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

type dw_saletaskmx from u_dw_rbtnfilter within tabpage_1
integer y = 88
integer width = 3237
integer height = 648
integer taborder = 20
string dataobject = "dw_fx_saletaskmx"
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 clicked;call super::clicked;if dw_edit_mode then return

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

event doubleclicked;call super::doubleclicked;//If (dwo.Name = "u_saletaskmx_status" AND row > 0 Then

long dw_row
dw_row = dw_saletask_list.GetROW()
if This.Object.fxmtrlid[row] > 0 then
	s_edit_index_tran s_mtrl
	s_mtrl.d_string  = '物料质检项目[' + This.Object.mtrlname[row] + ']'
	s_mtrl.d_long = This.Object.fxmtrlid[row] 
	s_mtrl.e_long = dw_saletask_list.Object.cuscomid[dw_row] 
	OpenWithParm(w_fx_checkitem_bymtrl,s_mtrl)
end if
end event

type tabpage_2 from userobject within tab_1
integer x = 18
integer y = 96
integer width = 3803
integer height = 744
long backcolor = 16777215
string text = "发货记录"
long tabtextcolor = 33554432
long tabbackcolor = 16777215
long picturemaskcolor = 536870912
cb_1 cb_1
dw_fx_outware_badqc dw_fx_outware_badqc
dw_outware_log dw_outware_log
end type

on tabpage_2.create
this.cb_1=create cb_1
this.dw_fx_outware_badqc=create dw_fx_outware_badqc
this.dw_outware_log=create dw_outware_log
this.Control[]={this.cb_1,&
this.dw_fx_outware_badqc,&
this.dw_outware_log}
end on

on tabpage_2.destroy
destroy(this.cb_1)
destroy(this.dw_fx_outware_badqc)
destroy(this.dw_outware_log)
end on

type cb_1 from commandbutton within tabpage_2
integer width = 439
integer height = 96
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "打印收货通知单"
end type

event clicked;long ll_row

ll_row = dw_outware_log.GetRow()

if ll_row <= 0 then
	MessageBox('提示', '请选择打印对象')
	return
end if

string ls_autocode

ls_autocode = dw_outware_log.Object.autocode[ll_row]

datastore ds_report
ds_report = create datastore
ds_report.dataobject = 'dw_print_outware_fx_mx_data'

long mx_row, i

for i = 1 to dw_outware_log.rowcount()
	if dw_outware_log.Object.autocode[i] <> ls_autocode then continue
	
	mx_row = ds_report.InsertRow(0)
	ds_report.Object.tid[mx_row] = dw_saletask_list.Object.tid[dw_saletask_list.GetRow()]
	ds_report.Object.taskcode[mx_row] = dw_saletask_list.Object.taskcode[dw_saletask_list.GetRow()]
	ds_report.Object.outwarecode[mx_row] = dw_outware_log.Object.outwarecode[i]
	ds_report.Object.username[mx_row] = dw_outware_log.Object.username[i]
	ds_report.Object.outwaredate[mx_row] = dw_outware_log.Object.outwaredate[i]
	ds_report.Object.autocode[mx_row] = dw_outware_log.Object.autocode[i]
	
	ds_report.Object.mtrlcode[mx_row] = dw_outware_log.Object.mtrlcode[i]
	ds_report.Object.mtrlname[mx_row] = dw_outware_log.Object.mtrlname[i]
	ds_report.Object.mtrlmode[mx_row] = dw_outware_log.Object.mtrlmode[i]
	ds_report.Object.unit[mx_row] = dw_outware_log.Object.unit[i]
	ds_report.Object.qty[mx_row] = dw_outware_log.Object.qty[i]
	ds_report.Object.mxcode[mx_row] = dw_outware_log.Object.mxcode[i]
next

S_print_MSG LS_PRMSG

LS_PRMSG.obj_dwNAME='dw_print_outware_fx_mx'
LS_PRMSG.SHARE_DW=ds_report
LS_PRMSG.TAG_TEXT='收货通知单'
LS_PRMSG.SETUP_FLAG=0
LS_PRMSG.PAGECH_FLAG=1

Openwithparm(w_publ_preview,LS_PRMSG)





end event

type dw_fx_outware_badqc from u_dw_rbtnfilter within tabpage_2
integer x = 2318
integer width = 1472
integer height = 772
integer taborder = 30
string dataobject = "dw_fx_outware_badqc"
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 clicked;call super::clicked;if dw_edit_mode then return

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

type dw_outware_log from u_dw_rbtnfilter within tabpage_2
integer y = 96
integer width = 2295
integer height = 672
integer taborder = 20
string dataobject = "dw_fx_outware_log"
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 clicked;call super::clicked;if dw_edit_mode then return

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

event rowfocuschanged;call super::rowfocuschanged;This.SelectRow(0, False)

IF currentrow > 0 THEN
	This.SelectRow(currentrow, True)
END IF

wf_retrieve_badqc()

end event

type tabpage_3 from userobject within tab_1
integer x = 18
integer y = 96
integer width = 3803
integer height = 744
long backcolor = 16777215
string text = "进度"
long tabtextcolor = 33554432
long tabbackcolor = 16777215
long picturemaskcolor = 536870912
cb_qty_ready_copy cb_qty_ready_copy
cb_quit_qty_ready cb_quit_qty_ready
cb_edit_qty_ready cb_edit_qty_ready
st_split st_split
cb_quit_jd cb_quit_jd
cb_delrow cb_delrow
cb_addrow cb_addrow
cb_edit_jd cb_edit_jd
dw_jd dw_jd
dw_jd_ordermx dw_jd_ordermx
end type

on tabpage_3.create
this.cb_qty_ready_copy=create cb_qty_ready_copy
this.cb_quit_qty_ready=create cb_quit_qty_ready
this.cb_edit_qty_ready=create cb_edit_qty_ready
this.st_split=create st_split
this.cb_quit_jd=create cb_quit_jd
this.cb_delrow=create cb_delrow
this.cb_addrow=create cb_addrow
this.cb_edit_jd=create cb_edit_jd
this.dw_jd=create dw_jd
this.dw_jd_ordermx=create dw_jd_ordermx
this.Control[]={this.cb_qty_ready_copy,&
this.cb_quit_qty_ready,&
this.cb_edit_qty_ready,&
this.st_split,&
this.cb_quit_jd,&
this.cb_delrow,&
this.cb_addrow,&
this.cb_edit_jd,&
this.dw_jd,&
this.dw_jd_ordermx}
end on

on tabpage_3.destroy
destroy(this.cb_qty_ready_copy)
destroy(this.cb_quit_qty_ready)
destroy(this.cb_edit_qty_ready)
destroy(this.st_split)
destroy(this.cb_quit_jd)
destroy(this.cb_delrow)
destroy(this.cb_addrow)
destroy(this.cb_edit_jd)
destroy(this.dw_jd)
destroy(this.dw_jd_ordermx)
end on

type cb_qty_ready_copy from commandbutton within tabpage_3
integer x = 571
integer width = 233
integer height = 84
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
boolean enabled = false
string text = "齐货"
end type

event clicked;long i
for i = 1 to dw_jd_ordermx.RowCount()
	dw_jd_ordermx.Object.qty_ready[i] = dw_jd_ordermx.Object.qty[i]
next
dw_jd_ordermx.AcceptText()
end event

type cb_quit_qty_ready from commandbutton within tabpage_3
integer x = 334
integer width = 233
integer height = 84
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
boolean enabled = false
string text = "放弃"
end type

event clicked;//page1复制到page3
wf_copy_qty_ready(1)

edit_qty_ready = false
wf_face()
end event

type cb_edit_qty_ready from commandbutton within tabpage_3
integer width = 329
integer height = 84
integer taborder = 40
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "修改分配数"
end type

event clicked;dw_jd_ordermx.SetFilter('')
dw_jd_ordermx.Filter()
dw_jd_ordermx.AcceptText()

long row
row = dw_saletask_list.GetRow()
if (row <= 0) then
	MessageBox('提示', '没有选中的订单')
	return
end if

if (edit_qty_ready) then // 保存
	if (wf_save_qty_ready() = 0) then
		return // 保存失败
	else
		//复制到page1 wf_copy_qty_ready(1)
		wf_copy_qty_ready(3)
	end if
else // 修改
	
end if

edit_qty_ready = not edit_qty_ready
wf_face()


end event

type st_split from u_lbs_stsplitbar within tabpage_3
integer x = 2304
integer y = 92
integer width = 14
integer height = 660
end type

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

type cb_quit_jd from commandbutton within tabpage_3
integer x = 2711
integer width = 233
integer height = 84
integer taborder = 60
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
boolean enabled = false
string text = "放弃"
end type

event clicked;wf_retrieve_jd()

edit_jd = false
wf_face()
end event

type cb_delrow from commandbutton within tabpage_3
integer x = 3186
integer width = 233
integer height = 84
integer taborder = 50
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
boolean enabled = false
string text = "删明细"
end type

event clicked;long row
row = dw_jd.GetRow()
if (row <= 0) then return

if not dw_jd.IsSelected(row) then
	MessageBox('提示', '请选中需要删除的明细项')
	return
end if

long index
if (dw_jd.Object.jdprintid[row] > 0) then
	index = UpperBound(ins_s_jds_del.jdprintid) + 1
	
	ins_s_jds_del.taskid[index] = dw_jd.Object.taskid[row]
	ins_s_jds_del.printid[index] = dw_jd.Object.printid[row]
	ins_s_jds_del.jdprintid[index] = dw_jd.Object.jdprintid[row]
end if

dw_jd.DeleteRow(row)

if (row - 1 > 0 and row - 1 <= dw_jd.RowCount()) then
	dw_jd.SelectRow(0, false)
	dw_jd.SelectRow(row - 1, true)
	dw_jd.SetRow(row - 1)
end if


end event

type cb_addrow from commandbutton within tabpage_3
integer x = 2949
integer width = 233
integer height = 84
integer taborder = 40
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
boolean enabled = false
string text = "增明细"
end type

event clicked;long row, taskid
row = dw_saletask_list.GetRow()
taskid = dw_saletask_list.Object.taskid[row]
if (taskid <= 0) then return

row = dw_jd_ordermx.GetRow()
if not dw_jd_ordermx.IsSelected(row) then return
long printid
printid = dw_jd_ordermx.Object.printid[row]
if (printid <= 0) then return

row = dw_jd.InsertRow(0)
dw_jd.Object.taskid[row] = taskid
dw_jd.Object.printid[row] = printid
dw_jd.Object.jdprintid[row] = 0
dw_jd.Object.wrkgrpname[row] = ''
dw_jd.Object.orderqty[row] = dw_jd_ordermx.Object.qty[dw_jd_ordermx.GetRow()]
dw_jd.Object.taskqty[row] = 0
dw_jd.Object.finishqty[row] = 0
dw_jd.Object.username[row] = ''
dw_jd.Object.editdate[row] = Today()
end event

type cb_edit_jd from commandbutton within tabpage_3
integer x = 2322
integer width = 384
integer height = 84
integer taborder = 30
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "修改工组进度"
end type

event clicked;dw_jd.AcceptText()

long row
row = dw_saletask_list.GetRow()
if (row <= 0) then
	MessageBox('提示', '没有选中的订单')
	return
end if

if edit_jd then // 保存
	if (wf_save_jd() = 0) then
		return // 保存失败
	else
		ins_ds_jd.Reset()
	end if
else // 修改
	s_fx_wrkgrp_jd s_empty
	ins_s_jds_del = s_empty // 进入修改模式，将存放待删的列表清空
end if

edit_jd = not edit_jd
wf_face()


end event

type dw_jd from u_dw_rbtnfilter within tabpage_3
integer x = 2322
integer y = 92
integer width = 2098
integer height = 752
integer taborder = 20
string dataobject = "dw_fx_wrkgrp_jd"
boolean hscrollbar = true
boolean vscrollbar = true
boolean rbutton_setposition_use = true
end type

event clicked;call super::clicked;if (row <= 0) then return

dw_jd.SelectRow(0, false)
dw_jd.SelectRow(row, true)

dw_jd.SetRow(row)
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 = 'wrkgrpname' or colName = 'taskqty' or colName = 'finishqty') then
		this.SelectText(1, Len(this.GetText()))
	end if
end if
end event

type dw_jd_ordermx from u_dw_rbtnfilter within tabpage_3
integer y = 92
integer width = 2304
integer height = 676
integer taborder = 20
string dataobject = "dw_fx_saletaskmx_jd"
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 clicked;call super::clicked;if edit_jd then return

if (row <= 0) then return

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

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

if IsNUll(currentrow) then return

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

wf_retrieve_jd()
end event

type st_1 from statictext within w_saletask_fx
integer x = 5
integer y = 204
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_saletask_fx
integer x = 279
integer y = 184
integer width = 320
integer height = 496
integer taborder = 70
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;wf_retrieve_saletask( )
end event

type st_2 from statictext within w_saletask_fx
integer x = 613
integer y = 204
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 em_datea from editmask within w_saletask_fx
integer x = 905
integer y = 188
integer width = 389
integer height = 84
integer taborder = 80
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "0000-00-00"
borderstyle borderstyle = stylelowered!
maskdatatype maskdatatype = datemask!
string mask = "yyyy-mm-dd"
boolean spin = true
end type

type st_3 from statictext within w_saletask_fx
integer x = 1298
integer y = 204
integer width = 96
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 em_datez from editmask within w_saletask_fx
integer x = 1390
integer y = 188
integer width = 389
integer height = 84
integer taborder = 90
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long textcolor = 33554432
string text = "0000-00-00"
borderstyle borderstyle = stylelowered!
maskdatatype maskdatatype = datemask!
string mask = "yyyy-mm-dd"
boolean spin = true
end type

type st_4 from statictext within w_saletask_fx
integer x = 1829
integer y = 204
integer width = 224
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 sle_likestr from u_sleedit within w_saletask_fx
integer x = 2034
integer y = 188
integer height = 84
integer taborder = 100
boolean bringtotop = true
end type

event keydown;call super::keydown;if (key = KeyEnter!) then
	ins_cur_pageNum = 1
	wf_retrieve_saletask( )
end if
end event

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

event clicked;call super::clicked;ins_cur_pageNum = 1
wf_retrieve_saletask( )
end event

type cb_page_ch from uo_imflatbutton within w_saletask_fx
integer x = 3643
integer width = 82
integer height = 164
integer taborder = 50
boolean bringtotop = true
string text = "▼"
toolbaralignment pic_align = alignattop!
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_saletask_fx
integer x = 3177
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 = right!
borderstyle borderstyle = stylelowered!
string mask = "#####0"
boolean spin = true
double increment = 1
string minmax = "1~~"
end type

type cb_outware from uo_imflatbutton within w_saletask_fx
boolean visible = false
integer x = 155
integer width = 151
integer height = 164
boolean bringtotop = true
string text = "发货"
string normalpicname = "graphics\fn1146.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;if (edit_jd or edit_qty_ready) then return

string arg_msg
if (f_find_fx_user_power(40, ref arg_msg) <> 1) then // 40-采购订单发货
	MessageBox('权限提示', arg_msg)
	return
end if

long row
row = dw_saletask_list.GetRow()
if (row <= 0) then
	MessageBox('提示', '请选择需要发货的订单')
	return
end if

dw_saletaskmx.SetFilter('')
dw_saletaskmx.Filter()

long cnt
cnt = dw_saletaskmx.RowCount()
if (cnt <= 0) then
	MessageBox('提示', '订单没有明细内容')
	return
end if

datastore ds
ds = create datastore
ds.DataObject = 'dw_fx_saletaskmx'
ds.Object.Data = dw_saletaskmx.Object.Data

OpenWithParm(w_outware_fx, ds)

long ret
ret = Message.DoubleParm
if not IsNull(ret) then
	if (ret = 1) then // 发货成功
		dw_outware_log.ReSet()
		wf_retrieve_outwarelog()
	end if
end if
end event

type cb_retrieve from uo_imflatbutton within w_saletask_fx
integer width = 151
integer height = 164
integer taborder = 10
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_saletask( )
end event

type cb_print from uo_imflatbutton within w_saletask_fx
boolean visible = false
integer x = 311
integer width = 151
integer height = 164
integer taborder = 60
boolean bringtotop = true
integer weight = 700
string text = "打印"
string normalpicname = "print.BMP"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;if (edit_jd or edit_qty_ready) then return

string arg_msg
if (f_find_fx_user_power(36, ref arg_msg) <> 1) then // 36-采购订单数据发送
	MessageBox('权限提示', arg_msg)
	return
end if

long row
row = dw_saletask_list.GetRow()
if (row <= 0) then return
if (not dw_saletask_list.IsSelected(row)) then return
if (dw_saletaskmx.RowCount() <= 0) then return


datastore ds_report
ds_report = create datastore
ds_report.dataobject = 'dw_fx_print_saletask_qc'


//long i
//s_fx_saletaskmx mx[]
//for i = 1 to dw_saletaskmx.RowCount()
//	mx[i].printid = dw_saletaskmx.Object.printid[i]
//	mx[i].mtrlcode = dw_saletaskmx.Object.mtrlcode[i]
//	mx[i].mtrlname = dw_saletaskmx.Object.mtrlname[i]
//	mx[i].status = dw_saletaskmx.Object.status[i]
//	mx[i].woodcode = dw_saletaskmx.Object.woodcode[i]
//	mx[i].pcode = dw_saletaskmx.Object.pcode[i]
//	mx[i].qty = dw_saletaskmx.Object.qty[i]
//	mx[i].price = dw_saletaskmx.Object.price[i]
//	mx[i].mxdscrp = dw_saletaskmx.Object.mxdscrp[i]
//	mx[i].mxdscrp2 = dw_saletaskmx.Object.mxdscrp2[i]
//	mx[i].mtrlcuscode = dw_saletaskmx.Object.mtrlcuscode[i]
//	mx[i].mtrlmode = dw_saletaskmx.Object.mtrlmode[i]
//	mx[i].requiredate = dw_saletaskmx.Object.requiredate[i]
//next
//
//s_fx_saletask s_tran
//s_tran.tid = dw_saletask_list.Object.tid[row]
//s_tran.requiredate = dw_saletask_list.Object.requiredate[row]
//s_tran.cus_rep = dw_saletask_list.Object.cus_rep[row]
//s_tran.cus_tele = dw_saletask_list.Object.cus_tele[row]
//s_tran.cus_address = dw_saletask_list.Object.cus_address[row]
//s_tran.freight = dw_saletask_list.Object.freight[row]
//s_tran.freight_tele = dw_saletask_list.Object.freight_tele[row]
//s_tran.buyer_name = dw_saletask_list.Object.buyer_name[row]
//s_tran.buyer_tele = dw_saletask_list.Object.buyer_tele[row]
//s_tran.temp1 = dw_saletask_list.Object.temp1[row]
//s_tran.temp2 = dw_saletask_list.Object.temp2[row]
//s_tran.temp3 = dw_saletask_list.Object.temp3[row]
//s_tran.taskcode = dw_saletask_list.Object.taskcode[row]
//s_tran.mx = mx

//OpenWithParm(w_print_saletask_fx, s_tran)


long i, ll_row
for i = 1 to dw_saletaskmx.RowCount()
	ll_row = ds_report.InsertRow(0)
	
	ds_report.Object.taskcode[ll_row] =  dw_saletask_list.Object.taskcode[row]
	ds_report.Object.mtrlcode[ll_row] = dw_saletaskmx.Object.mtrlcode[i]
	ds_report.Object.mtrlname[ll_row] =  dw_saletaskmx.Object.mtrlname[i]
	ds_report.Object.mtrlmode[ll_row] = dw_saletaskmx.Object.mtrlmode[i]
	ds_report.Object.status[ll_row] =  dw_saletaskmx.Object.status[i]
	ds_report.Object.qty[ll_row] =  dw_saletaskmx.Object.qty[i]
	ds_report.Object.requiredate[ll_row] =  dw_saletaskmx.Object.requiredate[i]
next


S_print_MSG LS_PRMSG

LS_PRMSG.obj_dwNAME='dw_fx_print_saletask_qc'
LS_PRMSG.SHARE_DW=ds_report
LS_PRMSG.TAG_TEXT='销售发货单'
LS_PRMSG.SETUP_FLAG=0
LS_PRMSG.PAGECH_FLAG=1

Openwithparm(w_publ_preview,LS_PRMSG)

//s_tran.taskdate = dw_saletask_list.Object.taskdate[i]
//s_tran.opemp = dw_saletask_list.Object.opemp[i]
//s_tran.opdate = dw_saletask_list.Object.opdate[i]
//s_tran.modemp = dw_saletask_list.Object.modemp[i]
//s_tran.moddate = dw_saletask_list.Object.moddate[i]
//s_tran.temp4 = dw_saletask_list.Object.temp4[i]
//s_tran.temp5 = dw_saletask_list.Object.temp5[i]
//s_tran.temp6 = dw_saletask_list.Object.temp6[i]
//s_tran.price_emp = dw_saletask_list.Object.price_emp[i]
//s_tran.replyrqdate = dw_saletask_list.Object.replyrqdate[i]
//s_tran.replydscrp = dw_saletask_list.Object.replydscrp[i]
//s_tran.replydate = dw_saletask_list.Object.replydate[i]
//s_tran.confirmemp = dw_saletask_list.Object.confirmemp[i]
//s_tran.confirmdate = dw_saletask_list.Object.confirmdate[i]
//s_tran.status = dw_saletask_list.Object.status[i]
//s_tran.taskcode = dw_saletask_list.Object.taskcode[i]
//s_tran.outwarecode = dw_saletask_list.Object.outwarecode[i]
//s_tran.fstatus = dw_saletask_list.Object.fstatus[i]

end event

type cb_2 from uo_imflatbutton within w_saletask_fx
integer x = 1262
integer width = 549
integer height = 164
integer taborder = 40
boolean bringtotop = true
string text = "采购订单明细跟踪表"
string normalpicname = "graphics\p1.jpg"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;s_edit_index_tran s_tran
openwithparm(w_saletaskmx_tracking,s_tran)
end event

type cb_file from uo_imflatbutton within w_saletask_fx
integer x = 155
integer height = 164
integer taborder = 40
boolean bringtotop = true
string text = "附件管理"
string normalpicname = "fj.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long currentrow
string ls_taskcode,ls_mtfj_status
currentrow = dw_saletask_list.GetRow()

IF currentrow <= 0 THEN
	MessageBox('提示', '请先选择权限!')
	RETURN
END IF

ls_taskcode = dw_saletask_list.Object.taskcode[currentrow]
ls_mtfj_status = dw_saletask_list.Object.mtfj_status[currentrow]

s_edit_index_tran s_pic
s_pic.d_string  = '附件管理[' + ls_taskcode + ']'
s_pic.e_string = ls_mtfj_status
s_pic.d_long = 401 
s_pic.e_long = dw_saletask_list.Object.taskid[currentrow]
s_pic.f_long = 0

OpenWithParm(w_fj_manage_saletask,s_pic)
end event

type st_5 from statictext within w_saletask_fx
integer x = 795
integer y = 1640
integer width = 754
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 = "*双击明细可查看物料质检项目"
long bordercolor = 16777215
boolean focusrectangle = false
end type

type cb_3 from commandbutton within w_saletask_fx
integer x = 27
integer y = 1708
integer width = 315
integer height = 84
integer taborder = 140
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "录入完工"
end type

event clicked;long row 
row = dw_saletask_list.getrow()

IF row <= 0 THEN RETURN

s_edit_index_tran s_tran
s_tran.b_long = dw_saletask_list.object.taskid[row]
s_tran.b_string = dw_saletask_list.object.outwarecode[row]
openwithparm(w_saletask_fx_finish_edit,s_tran)
end event

type cb_4 from commandbutton within w_saletask_fx
integer x = 347
integer y = 1708
integer width = 315
integer height = 84
integer taborder = 150
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "删除完工"
end type

event clicked;long row 
row = dw_saletask_list.getrow()

IF row <= 0 THEN RETURN

s_edit_index_tran s_tran
s_tran.b_long = dw_saletask_list.object.taskid[row]
s_tran.b_string = dw_saletask_list.object.outwarecode[row]
openwithparm(w_saletask_fx_finish_edit_del,s_tran)
end event

