$PBExportHeader$w_fx_check_bill.srw
forward
global type w_fx_check_bill from w_publ_base_style
end type
type cb_refresh from uo_imflatbutton within w_fx_check_bill
end type
type cb_new from uo_imflatbutton within w_fx_check_bill
end type
type cb_delete from uo_imflatbutton within w_fx_check_bill
end type
type cb_audit from uo_imflatbutton within w_fx_check_bill
end type
type cb_cancle_audit from uo_imflatbutton within w_fx_check_bill
end type
type cb_print from uo_imflatbutton within w_fx_check_bill
end type
type cb_confirm_return from uo_imflatbutton within w_fx_check_bill
end type
type ddlb_status from dropdownlistbox within w_fx_check_bill
end type
type st_2 from statictext within w_fx_check_bill
end type
type em_datea from editmask within w_fx_check_bill
end type
type em_datez from editmask within w_fx_check_bill
end type
type st_3 from statictext within w_fx_check_bill
end type
type dw_fx_outware_free from datawindow within w_fx_check_bill
end type
type cb_add_mx from commandbutton within w_fx_check_bill
end type
type cb_delete_mx from commandbutton within w_fx_check_bill
end type
type cb_modify from uo_imflatbutton within w_fx_check_bill
end type
type dw_fx_outware from u_dw_rbtnfilter within w_fx_check_bill
end type
type dw_fx_outware_mx from u_dw_rbtnfilter within w_fx_check_bill
end type
type cb_1 from uo_imflatbutton within w_fx_check_bill
end type
type dw_itemmx from u_dw_rbtnfilter within w_fx_check_bill
end type
type st_1 from statictext within w_fx_check_bill
end type
type cb_input from commandbutton within w_fx_check_bill
end type
end forward

global type w_fx_check_bill from w_publ_base_style
integer width = 4608
integer height = 2880
string title = "质量自检单"
boolean maxbox = true
windowstate windowstate = maximized!
event ue_print_outware_all ( )
event ue_print_outware_mx ( )
event ue_print_outware_all_mt ( )
cb_refresh cb_refresh
cb_new cb_new
cb_delete cb_delete
cb_audit cb_audit
cb_cancle_audit cb_cancle_audit
cb_print cb_print
cb_confirm_return cb_confirm_return
ddlb_status ddlb_status
st_2 st_2
em_datea em_datea
em_datez em_datez
st_3 st_3
dw_fx_outware_free dw_fx_outware_free
cb_add_mx cb_add_mx
cb_delete_mx cb_delete_mx
cb_modify cb_modify
dw_fx_outware dw_fx_outware
dw_fx_outware_mx dw_fx_outware_mx
cb_1 cb_1
dw_itemmx dw_itemmx
st_1 st_1
cb_input cb_input
end type
global w_fx_check_bill w_fx_check_bill

type variables

end variables

forward prototypes
public subroutine wf_btn_enabled ()
public subroutine wf_retrieve_outware ()
public subroutine wf_retrieve_outware_mx (long arg_outwareid)
public function integer wf_change_taborder (integer arg_taborder)
public function integer wf_cus_select ()
public function integer wf_send_checkbill (ref string arg_msg)
public subroutine wf_retrieve_outware_itemmx (long arg_outwareid)
public subroutine wf_filtermx ()
end prototypes

event ue_print_outware_all();long ll_row

ll_row = dw_fx_outware.GetRow()

if ll_row <= 0 then
	MessageBox('提示', '请先选择要打印的单据')
	return
end if

string ls_autocode
string ls_outwarecode
string ls_custname

ls_autocode = dw_fx_outware.Object.outwarecode[ll_row]
ls_custname = dw_fx_outware.Object.cusname[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_fx_outware_mx.rowcount()
	if Trim(dw_fx_outware_mx.Object.autocode[i]) <> Trim(ls_autocode) then continue
	
	mx_row = ds_report.InsertRow(0)
	ds_report.Object.tid[mx_row] = dw_fx_outware_mx.Object.tid[i]
	ds_report.Object.taskcode[mx_row] = dw_fx_outware_mx.Object.taskcode[i]
	ds_report.Object.outwarecode[mx_row] = dw_fx_outware_mx.Object.outwarecode[i]
	ds_report.Object.username[mx_row] = dw_fx_outware_mx.Object.username[i]
	ds_report.Object.outwaredate[mx_row] = dw_fx_outware_mx.Object.outwaredate[i]
	ds_report.Object.autocode[mx_row] = Trim(dw_fx_outware_mx.Object.autocode[i])
	
	ds_report.Object.mtrlcode[mx_row] = dw_fx_outware_mx.Object.mtrlcode[i]
	ds_report.Object.mtrlname[mx_row] = dw_fx_outware_mx.Object.mtrlname[i]
	ds_report.Object.mtrlmode[mx_row] = dw_fx_outware_mx.Object.mtrlmode[i]
	ds_report.Object.unit[mx_row] = dw_fx_outware_mx.Object.unit[i]
	ds_report.Object.qty[mx_row] = dw_fx_outware_mx.Object.qty[i]
	ds_report.Object.mxcode[mx_row] = trim(dw_fx_outware_mx.Object.mxcode[i])
	
	ds_report.Object.custname[mx_row] = ls_custname //客户名称
	ds_report.Object.sptname[mx_row] = trim(dw_fx_outware_mx.Object.sptname[i]) //供应商名称
	
//	ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mtrlcuscode[i]) //产品批号（销售订单相关号）
	ds_report.Object.dscrp[mx_row] = dw_fx_outware_mx.Object.mxdscrp[i]
	IF trim(dw_fx_outware_mx.Object.mtrlcuscode[i]) = '' THEN
		ds_report.Object.mtrlcuscode[mx_row] = dw_fx_outware_mx.Object.mxdscrp[i]
	 ELSE
		ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mtrlcuscode[i])
	END IF
	ds_report.Object.saletask_mxid[mx_row] = dw_fx_outware_mx.Object.fx_saletaskmx_saletask_mxid[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

event ue_print_outware_mx();long row
row = dw_fx_outware.GetRow()
if (row <= 0) then 
	messagebox('提示', '请先选择要打印的单据')
	return
end if	


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


long i, ll_row
for i = 1 to dw_fx_outware_mx.RowCount()
	ll_row = ds_report.InsertRow(0)
	
	ds_report.Object.taskcode[ll_row] =  dw_fx_outware_mx.Object.taskcode[i]
	ds_report.Object.mtrlcode[ll_row] = dw_fx_outware_mx.Object.mtrlcode[i]
	ds_report.Object.mtrlname[ll_row] =  dw_fx_outware_mx.Object.mtrlname[i]
	ds_report.Object.mtrlmode[ll_row] = dw_fx_outware_mx.Object.mtrlmode[i]
	ds_report.Object.status[ll_row] =  dw_fx_outware_mx.Object.status[i]
	ds_report.Object.qty[ll_row] =  dw_fx_outware_mx.Object.qty[i]
	ds_report.Object.requiredate[ll_row] =  dw_fx_outware_mx.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)

end event

event ue_print_outware_all_mt();long ll_row

ll_row = dw_fx_outware.GetRow()

if ll_row <= 0 then
	MessageBox('提示', '请先选择要打印的单据')
	return
end if

string ls_autocode
string ls_outwarecode
string ls_custname

ls_autocode = dw_fx_outware.Object.outwarecode[ll_row]
ls_custname = dw_fx_outware.Object.cusname[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_fx_outware_mx.rowcount()
	if Trim(dw_fx_outware_mx.Object.autocode[i]) <> Trim(ls_autocode) then continue
	
	mx_row = ds_report.InsertRow(0)
	ds_report.Object.tid[mx_row] = dw_fx_outware_mx.Object.tid[i]
	ds_report.Object.taskcode[mx_row] = dw_fx_outware_mx.Object.taskcode[i]
	ds_report.Object.outwarecode[mx_row] = dw_fx_outware_mx.Object.outwarecode[i]
	ds_report.Object.username[mx_row] = dw_fx_outware_mx.Object.username[i]
	ds_report.Object.outwaredate[mx_row] = dw_fx_outware_mx.Object.outwaredate[i]
	ds_report.Object.autocode[mx_row] = Trim(dw_fx_outware_mx.Object.autocode[i])
	
	ds_report.Object.mtrlcode[mx_row] = dw_fx_outware_mx.Object.mtrlcode[i]
	ds_report.Object.mtrlname[mx_row] = dw_fx_outware_mx.Object.mtrlname[i]
	ds_report.Object.mtrlmode[mx_row] = dw_fx_outware_mx.Object.mtrlmode[i]
	ds_report.Object.unit[mx_row] = dw_fx_outware_mx.Object.unit[i]
	ds_report.Object.qty[mx_row] = dw_fx_outware_mx.Object.qty[i]
	ds_report.Object.mxcode[mx_row] = trim(dw_fx_outware_mx.Object.mxcode[i])
	
	ds_report.Object.custname[mx_row] = ls_custname //客户名称
	ds_report.Object.sptname[mx_row] = trim(dw_fx_outware_mx.Object.sptname[i]) //供应商名称
	ds_report.Object.order_mtrlname_str[mx_row] = dw_fx_outware_mx.Object.order_mtrlname_str[i]
	
//	ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mtrlcuscode[i]) //产品批号（销售订单相关号）
	ds_report.Object.dscrp[mx_row] = trim(dw_fx_outware_mx.Object.mxdscrp[i])
	IF trim(dw_fx_outware_mx.Object.mtrlcuscode[i]) = '' THEN
		ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mxdscrp[i])
	 ELSE
		ds_report.Object.mtrlcuscode[mx_row] = trim(dw_fx_outware_mx.Object.mtrlcuscode[i])
	END IF
	ds_report.Object.saletask_mxid[mx_row] = dw_fx_outware_mx.Object.fx_saletaskmx_saletask_mxid[i] //供应商名称
next

ds_report.SetSort("mtrlcuscode A,mtrlname A, mtrlmode A")

ds_report.Sort()

S_print_MSG LS_PRMSG

LS_PRMSG.obj_dwNAME='dw_print_outware_fx_mx_mt'
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

public subroutine wf_btn_enabled ();if dw_edit_mode OR if_modify_mode then
	cb_refresh.enabled = false
	cb_new.text = '保存'
	cb_new.normalpicname = "save.bmp"
	cb_modify.text = '放弃'
	cb_modify.normalpicname = "undo.bmp"
	cb_delete.enabled = false
	cb_audit.enabled = false
	cb_cancle_audit.enabled = false
	cb_print.enabled = false
	cb_confirm_return.enabled = false
	cb_add_mx.enabled = true
	cb_delete_mx.enabled = true
//	cb_input.enabled = true
else
	cb_refresh.enabled = true
	cb_new.text = '新建'
	cb_new.normalpicname = "new.bmp"
	cb_modify.text = '修改'
	cb_modify.normalpicname = "open.bmp"
	cb_delete.enabled = true
	cb_audit.enabled = true
	cb_cancle_audit.enabled = true
	cb_print.enabled = true
	cb_confirm_return.enabled = true
	cb_add_mx.enabled = false
	cb_delete_mx.enabled = false
//	cb_input.enabled = false
end if

cb_new.of_init_draw()
cb_new.of_paint()
cb_new.TriggerEvent('ue_textchange')
cb_modify.of_init_draw()
cb_modify.of_paint()
cb_modify.TriggerEvent('ue_textchange')
end subroutine

public subroutine wf_retrieve_outware ();long status, ll_ifback

//if cbx_ifback.checked = false then
//	ll_ifback = 0
//else
//	ll_ifback = 1
//end if

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 arg_msg
oleobject request,response,FxOutwares,item

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

request.SetInt('flag', status)
request.SetInt('billtype', 0) //自检
request.SetDateTime('begindate', dateA)
request.SetDateTime('enddate', dateZ)

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

if (arg_msg <> '') then
    messagebox('提示', '获取质检单列表失败，原因：' + arg_msg)
    return
end if

dw_fx_outware.Reset()
dw_fx_outware_mx.Reset()
dw_fx_outware.SetRedraw(false)

FxOutwares = response.GetArrOfPBDictionary('billList')
long i,row
for i = 1 to FxOutwares.Count
    item = FxOutwares.GetItem(i - 1)
    
    row = dw_fx_outware.InsertRow(0)


dw_fx_outware.setitem(row,'billid', item.GetInt('billid'))
dw_fx_outware.setitem(row,'billcode', item.GetString('billcode'))
dw_fx_outware.setitem(row,'billtype', item.GetInt('billtype'))
dw_fx_outware.setitem(row,'flag', item.GetInt('flag'))
dw_fx_outware.setitem(row,'billdate', item.GetDateTime('billdate'))
dw_fx_outware.setitem(row,'cuscomid',item.GetInt('cuscomid'))
dw_fx_outware.setitem(row,'sptcomid', item.GetInt('sptcomid'))
dw_fx_outware.setitem(row,'sptid_erp', item.GetInt('sptid_erp'))
dw_fx_outware.setitem(row,'cusname', item.GetString('cuscomname'))
dw_fx_outware.setitem(row,'dscrp', item.GetString('dscrp'))
dw_fx_outware.setitem(row,'sync_flag', item.GetInt('sync_flag'))
dw_fx_outware.setitem(row,'sync_time',item.GetDateTime('sync_time'))

dw_fx_outware.setitem(row,'opemp', item.GetString('opemp'))
dw_fx_outware.setitem(row,'opdate', item.GetDateTime('opdate'))
dw_fx_outware.setitem(row,'modemp', item.GetString('modemp'))
dw_fx_outware.setitem(row,'moddate',item.GetDateTime('moddate'))
dw_fx_outware.setitem(row,'auditemp',item.GetString('auditemp'))
dw_fx_outware.setitem(row,'auditdate', item.GetDateTime('auditdate'))
dw_fx_outware.setitem(row,'erp_affirmemp', item.GetString('erp_affirmemp'))
dw_fx_outware.setitem(row,'erp_affirmdate', item.GetDateTime('erp_affirmdate'))
dw_fx_outware.setitem(row,'erp_begindate', item.GetDateTime('erp_begindate'))
dw_fx_outware.setitem(row,'finishdate', item.GetDateTime('finishdate'))
dw_fx_outware.setitem(row,'cancel_emp', item.GetString('cancel_emp'))
dw_fx_outware.setitem(row,'cancel_date', item.GetDateTime('cancel_date'))










next
dw_fx_outware.sort()
dw_fx_outware.SetRedraw(true)

if (dw_fx_outware.RowCount() > 0) then
	dw_fx_outware.SelectRow(0, false)
	dw_fx_outware.SelectRow(1, true)
	dw_fx_outware.SetRow(1)
	dw_fx_outware.post event RowFocusChanged(1)
end if
end subroutine

public subroutine wf_retrieve_outware_mx (long arg_outwareid);IF IsNull(arg_outwareid) Or arg_outwareid <= 0 THEN
	RETURN
END IF

String arg_msg
oleobject request, response
oleobject list, Item

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

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

If (arg_msg <> '') THEN
	MessageBox('提示', '获取明细失败:' + arg_msg)
	RETURN
END IF

list = response.GetPBArray('mxList')

DateTime dt
Any acceptdate, outwaredate
dt = DateTime(Date('1899-12-30'), Time('00:00:00'))

dw_fx_outware_mx.Reset()
dw_fx_outware_mx.SetRedraw(False)
Long i,row
FOR i = 1 To list.Count
	Item = list.GetPBDictionary(i - 1)
	
	row = dw_fx_outware_mx.InsertRow(0)
	
	dw_fx_outware_mx.SetItem(row,'billid', Item.GetInt('billid'))
	dw_fx_outware_mx.SetItem(row,'printid', Item.GetInt('printid'))
	dw_fx_outware_mx.SetItem(row,'taskcode', Item.GetString('taskcode'))
	dw_fx_outware_mx.SetItem(row,'reltaskid', Item.GetInt('reltaskid'))
	dw_fx_outware_mx.SetItem(row,'relprintid', Item.GetInt('relprintid'))
	dw_fx_outware_mx.SetItem(row,'forqty', Item.GetDouble('forqty'))
	dw_fx_outware_mx.SetItem(row,'passqty', Item.GetDouble('passqty'))
	dw_fx_outware_mx.SetItem(row,'checktype', Item.GetInt('checktype'))
	dw_fx_outware_mx.SetItem(row,'checkqty', Item.GetDouble('checkqty'))
	dw_fx_outware_mx.SetItem(row,'goodqty', Item.GetDouble('goodqty'))
	dw_fx_outware_mx.SetItem(row,'badqty', Item.GetDouble('badqty'))
	dw_fx_outware_mx.SetItem(row,'finishflag', Item.GetInt('finishflag'))
	dw_fx_outware_mx.SetItem(row,'checkemp', Item.GetString('checkemp'))
	dw_fx_outware_mx.SetItem(row,'checkdate', Item.GetDateTime('checkdate'))
	dw_fx_outware_mx.SetItem(row,'mxdscrp', Item.GetString('mxdscrp'))
	dw_fx_outware_mx.SetItem(row,'mtrlcode', Item.GetString('mtrlcode'))
	dw_fx_outware_mx.SetItem(row,'mtrlname', Item.GetString('mtrlname'))
	dw_fx_outware_mx.SetItem(row,'mtrlmode', Item.GetString('mtrlmode'))
	dw_fx_outware_mx.SetItem(row,'status', Item.GetString('status'))
	dw_fx_outware_mx.SetItem(row,'woodcode', Item.GetString('woodcode'))
	dw_fx_outware_mx.SetItem(row,'pcode', Item.GetString('pcode'))
	
	
	
	
	
NEXT

IF dw_fx_outware_mx.RowCount() > 0 THEN
	dw_fx_outware_mx.SelectRow(0, False)
	dw_fx_outware_mx.SelectRow(1, True)
	dw_fx_outware_mx.SetRow(1)
	wf_filtermx()
END IF


dw_fx_outware_mx.SetRedraw(True)

















end subroutine

public function integer wf_change_taborder (integer arg_taborder);IF arg_taborder = 0 THEN
	dw_fx_outware_free.SetTabOrder('billdate', 0)
	dw_fx_outware_free.SetTabOrder('cusname', 0)
	
	dw_fx_outware_free.SetTabOrder('dscrp', 0)
	
	dw_fx_outware_mx.SetTabOrder('checktype', 0)
	dw_fx_outware_mx.SetTabOrder('checkqty', 0)
	dw_fx_outware.Enabled = True
	
ELSE
	dw_fx_outware_free.SetTabOrder('billdate', 10)
	dw_fx_outware_free.SetTabOrder('cusname', 20)
	dw_fx_outware_free.SetTabOrder('dscrp', 30)
	
	
	dw_fx_outware_mx.SetTabOrder('checktype', 20)
	dw_fx_outware_mx.SetTabOrder('checkqty', 30)
	dw_fx_outware.Enabled = False
END IF

RETURN 1


end function

public function integer wf_cus_select ();IF NOT dw_edit_mode THEN RETURN 0
long ori_cuscomid, new_cuscomid, row
row = dw_fx_outware_free.GetRow()
ori_cuscomid = dw_fx_outware_free.Object.cuscomid[row]
IF ori_cuscomid > 0 THEN
      IF dw_fx_outware_mx.RowCount() > 0 THEN
            MessageBox('','修改客户前需要先清除单据明细')
            RETURN 0
      END IF
END IF

s_fx_company s_tran, s_ret
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_fx_outware_mx.Reset() // 重选客户，清空明细
		END IF
		
		dw_fx_outware_free.Object.cuscomid[row] = new_cuscomid
		dw_fx_outware_free.Object.cusname[row] = s_ret.comname[1]
		dw_fx_outware_free.Object.sptid_erp[row] = s_ret.relid[1] 
		
		dw_fx_outware_free.AcceptText()
		RETURN 1
	END IF
END IF
RETURN 0
end function

public function integer wf_send_checkbill (ref string arg_msg);Int rslt = 1
Long j
If (dw_fx_outware_mx.RowCount() <= 0) THEN
	rslt = 0
	arg_msg = '没有明细'
	GOTO ext
END IF

Long ll_getrow, ll_billid
ll_getrow = dw_fx_outware_free.GetRow()


String ls_dscrp
DateTime ldt_billdate
Date ld_tempdate

dw_fx_outware_free.AcceptText()
ls_dscrp = dw_fx_outware_free.Object.dscrp[ll_getrow]

ld_tempdate = Date(dw_fx_outware_free.Object.billdate[ll_getrow])
ldt_billdate = DateTime(ld_tempdate, Now())

IF if_modify_mode THEN
	ll_billid = dw_fx_outware_free.Object.billid[ll_getrow]
ELSE
	ll_billid = 0
END IF

IF IsNull(dw_fx_outware_free.Object.cuscomid[ll_getrow]) Or (dw_fx_outware_free.Object.cuscomid[ll_getrow]) = 0 THEN
	rslt = 0
	arg_msg = '请选择客户！'
	GOTO ext
END IF



dw_fx_outware_free.AcceptText()
dw_fx_outware_mx.AcceptText()

dw_itemmx.SetFilter('')
dw_itemmx.Filter()
dw_itemmx.AcceptText()

IF  IsNull(ll_billid) THEN ll_billid = 0
IF  IsNull( dw_fx_outware_free.Object.billcode[ll_getrow]) THEN  dw_fx_outware_free.Object.billcode[ll_getrow] = ''
IF IsNull(ls_dscrp) THEN ls_dscrp = ''
IF IsNull(dw_fx_outware_free.Object.cuscomid[ll_getrow]) THEN dw_fx_outware_free.Object.cuscomid[ll_getrow] = 0


dw_fx_outware_free.AcceptText()
oleobject Item,Item_1, outware, mxs,fx_fileList,fileList,itemList
fx_fileList = FXAppCom.NewPBArray()
fileList =  FXAppCom.NewPBArray()
    //      FXAppCom.NewPBArray()

outware = FXAppCom.CreatePbDictionary()
outware.SetInt('billid', ll_billid)
outware.SetInt('billtype', 0) //质量自检单
outware.SetInt('flag', 0) //
outware.SetInt('sync_flag', 0) //
outware.SetString('opemp', '')
outware.SetString('modemp', '')
outware.SetString('auditemp', '')
outware.SetString('erp_affirmemp', '')
outware.SetString('cancel_emp', '')


outware.SetInt('billid', ll_billid)
outware.SetString('billcode', dw_fx_outware_free.Object.billcode[ll_getrow])
outware.SetString('dscrp', ls_dscrp)
outware.SetDateTime('billdate', ldt_billdate)
outware.SetInt('cuscomid',dw_fx_outware_free.Object.cuscomid[ll_getrow])
outware.SetInt('sptid_erp',dw_fx_outware_free.Object.sptid_erp[ll_getrow])


mxs = FXAppCom.CreArrOfPbDictionary()
//mxitem = FXAppCom.CreArrOfPbDictionary()
Long i, cnt = 0
DateTime ld_now
ld_now = DateTime(Today(),Now())
FOR i = 1 To dw_fx_outware_mx.RowCount()
	
	IF IsNull(dw_fx_outware_mx.Object.billid[i]) THEN dw_fx_outware_mx.Object.billid[i] = 0
	IF IsNull(dw_fx_outware_mx.Object.printid[i]) THEN dw_fx_outware_mx.Object.printid[i] = 0
	IF IsNull(dw_fx_outware_mx.Object.taskcode[i]) THEN dw_fx_outware_mx.Object.taskcode[i] = ''
	IF IsNull(dw_fx_outware_mx.Object.reltaskid[i]) THEN dw_fx_outware_mx.Object.reltaskid[i] = 0
	IF IsNull(dw_fx_outware_mx.Object.relprintid[i]) THEN dw_fx_outware_mx.Object.relprintid[i] = 0
	IF IsNull(dw_fx_outware_mx.Object.forqty[i]) THEN dw_fx_outware_mx.Object.forqty[i] = 0
	IF IsNull(dw_fx_outware_mx.Object.passqty[i]) THEN dw_fx_outware_mx.Object.passqty[i] = 0
	IF IsNull(dw_fx_outware_mx.Object.checktype[i]) THEN dw_fx_outware_mx.Object.checktype[i] = 0
	IF IsNull(dw_fx_outware_mx.Object.checkqty[i]) THEN dw_fx_outware_mx.Object.checkqty[i] = 0
	IF IsNull(dw_fx_outware_mx.Object.goodqty[i]) THEN dw_fx_outware_mx.Object.goodqty[i] = 0
	IF IsNull(dw_fx_outware_mx.Object.badqty[i]) THEN dw_fx_outware_mx.Object.badqty[i] = 0
	IF IsNull(dw_fx_outware_mx.Object.finishflag[i]) THEN dw_fx_outware_mx.Object.finishflag[i] = 0
	IF IsNull(dw_fx_outware_mx.Object.checkemp[i]) THEN dw_fx_outware_mx.Object.checkemp[i] = ''
	IF IsNull(dw_fx_outware_mx.Object.mxdscrp[i]) THEN dw_fx_outware_mx.Object.mxdscrp[i] = ''
	
	
	
	
	
	
	If (dw_fx_outware_mx.Object.checkqty[i] <= 0) THEN CONTINUE
	
	If (dw_fx_outware_mx.Object.checkqty[i] > dw_fx_outware_mx.Object.forqty[i]) THEN
		rslt = 0
		arg_msg = "行:" + String(dw_fx_outware_mx.Object.compute_2[i]) + "检验数不能大于【代表批量】"
		GOTO ext
	END IF
	
	cnt ++
	Item = FXAppCom.CreatePbDictionary()
	
	Item.SetInt('printid', cnt)
	Item.SetString('taskcode', dw_fx_outware_mx.Object.taskcode[i])
	Item.SetInt('reltaskid', dw_fx_outware_mx.Object.reltaskid[i])
	Item.SetInt('relprintid', dw_fx_outware_mx.Object.relprintid[i])
	Item.SetDouble('forqty', dw_fx_outware_mx.Object.forqty[i])
	Item.SetInt('checktype', dw_fx_outware_mx.Object.checktype[i])
	Item.SetDouble('checkqty', dw_fx_outware_mx.Object.checkqty[i])
	
	Item.SetDouble('passqty', dw_fx_outware_mx.Object.passqty[i])
	Item.SetDouble('goodqty', dw_fx_outware_mx.Object.goodqty[i])
	Item.SetDouble('badqty', dw_fx_outware_mx.Object.badqty[i])
	Item.SetDouble('finishflag', dw_fx_outware_mx.Object.finishflag[i])
	Item.SetString('checkemp', dw_fx_outware_mx.Object.checkemp[i])
	Item.SetString('mxdscrp', dw_fx_outware_mx.Object.mxdscrp[i])
	Item.SetObject('fx_fileList', fx_fileList)
	Item.SetObject('fileList', fileList)
	
	
	
	// 传入检查项目
	itemList  = FXAppCom.CreArrOfPbDictionary()    
	FOR j = 1 To dw_itemmx.RowCount()
		
		IF dw_itemmx.Object.fx_check_bill_itemmx_printid[j] = dw_fx_outware_mx.Object.printid[i] THEN
			IF IsNull(dw_itemmx.Object.fx_check_bill_itemmx_billid[j]) THEN dw_itemmx.Object.fx_check_bill_itemmx_billid[j] = 0
			IF IsNull(dw_itemmx.Object.fx_check_bill_itemmx_printid[j]) THEN dw_itemmx.Object.fx_check_bill_itemmx_printid[j] = 0
			IF IsNull(dw_itemmx.Object.fx_check_bill_itemmx_mxid[j]) THEN dw_itemmx.Object.fx_check_bill_itemmx_mxid[j] = 0
			IF IsNull(dw_itemmx.Object.fx_check_bill_itemmx_itemid_erp[j]) THEN dw_itemmx.Object.fx_check_bill_itemmx_itemid_erp[j] = 0
			IF IsNull(dw_itemmx.Object.fx_check_bill_itemmx_qcresult[j]) THEN dw_itemmx.Object.fx_check_bill_itemmx_qcresult[j] = 0
			IF IsNull(dw_itemmx.Object.fx_check_bill_itemmx_goodqty[j]) THEN dw_itemmx.Object.fx_check_bill_itemmx_goodqty[j] = 0
			IF IsNull(dw_itemmx.Object.fx_check_bill_itemmx_badqty[j]) THEN dw_itemmx.Object.fx_check_bill_itemmx_badqty[j] = 0
			
			Item_1 = FXAppCom.CreatePbDictionary()
			Item_1.SetInt('billid', dw_itemmx.Object.fx_check_bill_itemmx_billid[j])
			Item_1.SetInt('printid', dw_itemmx.Object.fx_check_bill_itemmx_printid[j])
			Item_1.SetInt('mxid', dw_itemmx.Object.fx_check_bill_itemmx_mxid[j])
			Item_1.SetInt('itemid_erp', dw_itemmx.Object.fx_check_bill_itemmx_itemid_erp[j])
			Item_1.SetString('qcresult', dw_itemmx.Object.fx_check_bill_itemmx_qcresult[j])
			Item_1.SetDouble('goodqty', dw_itemmx.Object.fx_check_bill_itemmx_goodqty[j])
			Item_1.SetDouble('badqty', dw_itemmx.Object.fx_check_bill_itemmx_badqty[j])
			
			itemList.Add(Item_1)
		END IF
		
	NEXT
	
	
	
	Item.SetObject('itemList', itemList)
	
	
	
	
	
	mxs.Add(Item)
	
NEXT

If (cnt <= 0) THEN
	rslt = 0
	arg_msg = '没有明细'
	GOTO ext
END IF












//mxs.Add(fx_fileList)
//mxs.Add('fx_fileList', fx_fileList)
//mxs.SetObject('fx_fileList', fx_fileList)


oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('bill', outware)
request.SetObject('mxList', mxs)



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

If (arg_msg <> '') THEN
	rslt = 0
	GOTO ext
END IF

ext:
RETURN rslt





end function

public subroutine wf_retrieve_outware_itemmx (long arg_outwareid);IF IsNull(arg_outwareid) Or arg_outwareid <= 0 THEN
	RETURN
END IF

String arg_msg
oleobject request, response
oleobject list, Item

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetInt('billid', arg_outwareid)
request.SetInt('printid', -1)

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

If (arg_msg <> '') THEN
	MessageBox('提示', '获取明细失败:' + arg_msg)
	RETURN
END IF

list = response.GetPBArray('mxList')

DateTime dt
Any acceptdate, outwaredate
dt = DateTime(Date('1899-12-30'), Time('00:00:00'))

dw_itemmx.Reset()
dw_itemmx.SetRedraw(False)
Long i,row
FOR i = 1 To list.Count
	Item = list.GetPBDictionary(i - 1)
	
	row = dw_itemmx.InsertRow(0)
	
	
dw_itemmx.SetItem(row,'fx_check_bill_itemmx_billid', Item.GetInt('billid'))
dw_itemmx.SetItem(row,'fx_check_bill_itemmx_printid', Item.GetInt('printid'))
dw_itemmx.SetItem(row,'fx_check_bill_itemmx_mxid', Item.GetInt('mxid'))
dw_itemmx.SetItem(row,'fx_check_bill_itemmx_itemid_erp', Item.GetInt('itemid_erp'))
dw_itemmx.SetItem(row,'fx_check_bill_itemmx_qcresult', Item.GetString('qcresult'))
dw_itemmx.SetItem(row,'fx_check_bill_itemmx_goodqty', Item.GetDouble('goodqty'))
dw_itemmx.SetItem(row,'fx_check_bill_itemmx_badqty', Item.GetDouble('badqty'))
dw_itemmx.SetItem(row,'fx_checkitem_itemname', Item.GetString('itemname'))
	
	
	

	

	
NEXT
dw_itemmx.sort()
dw_itemmx.SetRedraw(True)

end subroutine

public subroutine wf_filtermx ();Long row
String ls_filter = ''

row = dw_fx_outware_mx.GetRow()
IF row <= 0 THEN
	ls_filter = '1 = 0'
ELSE
	
	ls_filter = "fx_check_bill_itemmx_printid = " + String(dw_fx_outware_mx.Object.printid[row])
	
END IF
dw_itemmx.SetFilter(ls_filter)
dw_itemmx.Filter()

end subroutine

on w_fx_check_bill.create
int iCurrent
call super::create
this.cb_refresh=create cb_refresh
this.cb_new=create cb_new
this.cb_delete=create cb_delete
this.cb_audit=create cb_audit
this.cb_cancle_audit=create cb_cancle_audit
this.cb_print=create cb_print
this.cb_confirm_return=create cb_confirm_return
this.ddlb_status=create ddlb_status
this.st_2=create st_2
this.em_datea=create em_datea
this.em_datez=create em_datez
this.st_3=create st_3
this.dw_fx_outware_free=create dw_fx_outware_free
this.cb_add_mx=create cb_add_mx
this.cb_delete_mx=create cb_delete_mx
this.cb_modify=create cb_modify
this.dw_fx_outware=create dw_fx_outware
this.dw_fx_outware_mx=create dw_fx_outware_mx
this.cb_1=create cb_1
this.dw_itemmx=create dw_itemmx
this.st_1=create st_1
this.cb_input=create cb_input
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_refresh
this.Control[iCurrent+2]=this.cb_new
this.Control[iCurrent+3]=this.cb_delete
this.Control[iCurrent+4]=this.cb_audit
this.Control[iCurrent+5]=this.cb_cancle_audit
this.Control[iCurrent+6]=this.cb_print
this.Control[iCurrent+7]=this.cb_confirm_return
this.Control[iCurrent+8]=this.ddlb_status
this.Control[iCurrent+9]=this.st_2
this.Control[iCurrent+10]=this.em_datea
this.Control[iCurrent+11]=this.em_datez
this.Control[iCurrent+12]=this.st_3
this.Control[iCurrent+13]=this.dw_fx_outware_free
this.Control[iCurrent+14]=this.cb_add_mx
this.Control[iCurrent+15]=this.cb_delete_mx
this.Control[iCurrent+16]=this.cb_modify
this.Control[iCurrent+17]=this.dw_fx_outware
this.Control[iCurrent+18]=this.dw_fx_outware_mx
this.Control[iCurrent+19]=this.cb_1
this.Control[iCurrent+20]=this.dw_itemmx
this.Control[iCurrent+21]=this.st_1
this.Control[iCurrent+22]=this.cb_input
end on

on w_fx_check_bill.destroy
call super::destroy
destroy(this.cb_refresh)
destroy(this.cb_new)
destroy(this.cb_delete)
destroy(this.cb_audit)
destroy(this.cb_cancle_audit)
destroy(this.cb_print)
destroy(this.cb_confirm_return)
destroy(this.ddlb_status)
destroy(this.st_2)
destroy(this.em_datea)
destroy(this.em_datez)
destroy(this.st_3)
destroy(this.dw_fx_outware_free)
destroy(this.cb_add_mx)
destroy(this.cb_delete_mx)
destroy(this.cb_modify)
destroy(this.dw_fx_outware)
destroy(this.dw_fx_outware_mx)
destroy(this.cb_1)
destroy(this.dw_itemmx)
destroy(this.st_1)
destroy(this.cb_input)
end on

event resize;call super::resize;int li_free_width,li_free_height

li_free_width = 1810 //dw_fx_outwar_free宽度 
li_free_height = 1220 //dw_fx_outware_free高度

//dw_fx_outware_free
dw_fx_outware_free.width =  li_free_width
dw_fx_outware_free.height =   li_free_height
//dw_fx_outware
dw_fx_outware.x = li_free_width + 30
dw_fx_outware.y = dw_fx_outware_free.y
dw_fx_outware.width = this.workspacewidth() - li_free_width
dw_fx_outware.height = dw_fx_outware_free.height
//cb_add_mx, cb_delete_mx
cb_add_mx.x = 40
cb_add_mx.y = dw_fx_outware_free.y + li_free_height + 20
cb_delete_mx.x = cb_add_mx.width + 20
cb_delete_mx.y = cb_add_mx.y


cb_input.x = cb_delete_mx.width + cb_add_mx.width +  20
cb_input.y = cb_delete_mx.y

//dw_fx_outware_mx
dw_fx_outware_mx.y = cb_add_mx.y + cb_add_mx.height + 30
dw_fx_outware_mx.width = this.workspacewidth() / 5 * 3
dw_fx_outware_mx.height = this.workspaceheight() - cb_add_mx.y - cb_add_mx.height - 30


dw_itemmx.x=  dw_fx_outware_mx.x + dw_fx_outware_mx.width 
dw_itemmx.y = dw_fx_outware_mx.y
dw_itemmx.width = this.workspacewidth() / 5 * 2 - 50
dw_itemmx.height = dw_fx_outware_mx.height




end event

event open;call super::open;wf_movetocenter()

dw_fx_outware_free.insertrow(0)


ddlb_status.SelectItem(6)

em_dateA.Text = String(RelativeDate(Today(), - 30))
em_dateZ.Text = String(Today())

wf_retrieve_outware()
end event

type cb_func from w_publ_base_style`cb_func within w_fx_check_bill
boolean visible = false
integer x = 1618
end type

type cb_exit from w_publ_base_style`cb_exit within w_fx_check_bill
integer x = 1166
integer y = 4
end type

event cb_exit::clicked;if dw_edit_mode or if_modify_mode then
	IF MessageBox('提示','是否放弃新建/修改,并退出?',Question! ,OKCancel! , 1 ) = 2 THEN
		return
	END IF
end if 

close(parent)
end event

type ln_bar from w_publ_base_style`ln_bar within w_fx_check_bill
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_fx_check_bill
end type

type r_bar from w_publ_base_style`r_bar within w_fx_check_bill
integer x = 2135
end type

type cb_refresh from uo_imflatbutton within w_fx_check_bill
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_outware()
end event

type cb_new from uo_imflatbutton within w_fx_check_bill
integer x = 155
integer width = 165
integer height = 164
integer taborder = 10
boolean bringtotop = true
string text = "新建"
string normalpicname = "new.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long rslt = 1
string arg_msg
if dw_edit_mode then // 新建/修改保存
	if wf_send_checkbill(ref arg_msg) = 0 then
		messagebox('提示', '保存失败,原因:' + arg_msg)
		rslt = 0
		goto ext
	end if
	wf_change_taborder(0)
	
	Messagebox('提示', '保存成功')
	wf_retrieve_outware()
else
	long li_row
	dw_fx_outware.reset()
	li_row = dw_fx_outware.insertrow(0)
	dw_fx_outware.Object.billdate[li_row]  = today()
	dw_fx_outware.Object.billid[li_row]  = 0
     dw_fx_outware.Object.billcode[li_row]  = ''
	
	dw_fx_outware_mx.reset()
	
	dw_fx_outware_free.Reset()
	dw_fx_outware.RowsCopy(li_row, li_row, Primary!, dw_fx_outware_free, 1, Primary!)
	wf_change_taborder(1)

end if

ext:
if rslt = 1 then 
	dw_edit_mode = Not dw_edit_mode
	if_modify_mode = false
	wf_btn_enabled()
end if
end event

type cb_delete from uo_imflatbutton within w_fx_check_bill
integer x = 494
integer width = 165
integer height = 164
integer taborder = 10
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 ll_row, ll_flag,ll_billid
	
ll_row = dw_fx_outware.GetRow()

IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能删除!')
end if	

IF MessageBox ("IF","是否确定要删除当前单据吗",Question!,YesNo! ) = 2 THEN RETURN


ll_flag = dw_fx_outware.Object.flag[ll_row]
ll_billid = dw_fx_outware.Object.billid[ll_row]
if ll_flag <> 0 then
	messagebox('提示', '不是待审核单据,不能删除!')
	return
end if

oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('billid', ll_billid)

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

if (arg_msg <> '') then
	messagebox('提示', '删除失败,' + arg_msg)
else
	messagebox('提示', '删除成功！')
	wf_retrieve_outware()
end if
end event

type cb_audit from uo_imflatbutton within w_fx_check_bill
integer x = 663
integer width = 165
integer height = 164
integer taborder = 10
boolean bringtotop = true
string text = "审核"
string normalpicname = "audit.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long ll_row, ll_flag, ll_billid
	
ll_row = dw_fx_outware.GetRow()

IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能审核!')
    return
end if	

IF MessageBox ("IF","是否确定要审核当前单据吗",Question!,YesNo! ) = 2 THEN RETURN


ll_flag = dw_fx_outware.Object.flag[ll_row]
ll_billid = dw_fx_outware.Object.billid[ll_row]

if ll_flag <> 0 then
	messagebox('提示', '不是待审核单据,不能审核!')
	return
end if


oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('billid', ll_billid)
request.SetObject('flag', 1)

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

if (arg_msg <> '') then
	messagebox('提示', '审核失败,' + arg_msg)
else
	messagebox('提示', '审核成功！')
	wf_retrieve_outware()
end if


end event

type cb_cancle_audit from uo_imflatbutton within w_fx_check_bill
integer x = 832
integer width = 165
integer height = 164
integer taborder = 20
boolean bringtotop = true
string text = "撤审"
string normalpicname = "caudit.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long ll_row, ll_flag, ll_billid
	
ll_row = dw_fx_outware.GetRow()

IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能撤审!')
    return
end if	

IF MessageBox ("IF","是否确定要撤审当前单据吗",Question!,YesNo! ) = 2 THEN RETURN


ll_flag = dw_fx_outware.Object.flag[ll_row]
ll_billid = dw_fx_outware.Object.billid[ll_row]

if ll_flag <> 1 then
	messagebox('提示', '不是质检状态,不能撤审!')
	return
end if


oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('billid', ll_billid)
request.SetObject('flag', 0)

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

if (arg_msg <> '') then
	messagebox('提示', '撤审失败,' + arg_msg)
else
	messagebox('提示', '撤审成功！')
	wf_retrieve_outware()
end if


end event

type cb_print from uo_imflatbutton within w_fx_check_bill
integer x = 997
integer y = 4
integer width = 165
integer height = 164
integer taborder = 20
boolean bringtotop = true
string text = "打印"
string normalpicname = "print.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

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

long ll_row, ll_status
	
ll_row = dw_fx_outware.GetRow()
IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能打印!')
end if	

ll_status = dw_fx_outware.Object.status[ll_row]


if ll_status = 0 then
	messagebox('提示', '待审核单据,不能打印！')
	return
end if

Parent.TriggerEvent('ue_print_outware_all')


end event

type cb_confirm_return from uo_imflatbutton within w_fx_check_bill
boolean visible = false
integer x = 1170
integer width = 274
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "退货已收"
string normalpicname = "ok.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

event clicked;call super::clicked;long ll_row, ll_status, ll_outwareid
	
ll_row = dw_fx_outware.GetRow()
IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能退货!')
end if	

ll_status = dw_fx_outware.Object.status[ll_row]
ll_outwareid = dw_fx_outware.Object.outwareid[ll_row]

if ll_status <> 4 then
	messagebox('提示', '单据状态不是退货中,不能确认退货!')
	return
end if


oleobject request,response

request = FXAppCom.CreatePbDictionary()
request.SetString('token', app_token_fx)
request.SetObject('outwareid', ll_outwareid)
request.SetObject('status', 5)

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

if (arg_msg <> '') then
	messagebox('提示', '确认失败,' + arg_msg)
else
	messagebox('提示', '确认成功！')
	wf_retrieve_outware()
end if
end event

type ddlb_status from dropdownlistbox within w_fx_check_bill
integer x = 329
integer y = 188
integer width = 379
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[] = {"待审核[0]","质检中[1]","已通知客户[2]","客户已确认[3]","作废[9]","全部"}
borderstyle borderstyle = stylelowered!
end type

event selectionchanged;wf_retrieve_outware()
end event

type st_2 from statictext within w_fx_check_bill
integer x = 722
integer y = 204
integer width = 288
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 = "质检日期从"
alignment alignment = center!
boolean focusrectangle = false
end type

event constructor;this.backcolor = parent.backcolor
end event

type em_datea from editmask within w_fx_check_bill
integer x = 1033
integer y = 192
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 em_datez from editmask within w_fx_check_bill
integer x = 1527
integer y = 188
integer width = 389
integer height = 84
integer taborder = 100
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_fx_check_bill
integer x = 1422
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

event constructor;this.backcolor = parent.backcolor
end event

type dw_fx_outware_free from datawindow within w_fx_check_bill
integer x = 37
integer y = 288
integer width = 1792
integer height = 1132
integer taborder = 30
boolean bringtotop = true
string title = "none"
string dataobject = "dw_fx_check_bill_edit"
boolean livescroll = true
borderstyle borderstyle = stylelowered!
end type

event doubleclicked;if (not dw_edit_mode) then return

if (row <= 0) then return

if dwo.Type = 'column' and dwo.Name = 'cusname' then
	wf_cus_select()
end if
end event

type cb_add_mx from commandbutton within w_fx_check_bill
integer x = 32
integer y = 1452
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 = "宋体"
boolean enabled = false
string text = "增明细"
end type

event clicked;Long currow, cuscomid
currow = dw_fx_outware_free.GetRow()
cuscomid = dw_fx_outware_free.Object.cuscomid[currow]
IF IsNull(cuscomid) Or cuscomid = 0 THEN
	MessageBox('','请先选择客户')
	IF wf_cus_select() = 0 THEN RETURN
	cuscomid = dw_fx_outware_free.Object.cuscomid[currow]
END IF
datastore arg_ds
arg_ds = Create datastore
arg_ds.DataObject = 'dw_fx_check_bill_saletaskmx_choose'


s_edit_index_tran s_ch_tran //传递参数使用
s_ch_tran.b_long=cuscomid
s_ch_tran.c_long=1   //质量自检单
OpenWithParm(w_fx_check_bill_saletaskmx_choose1, s_ch_tran)



arg_ds = Message.PowerObjectParm
IF IsValid(arg_ds) THEN
	dw_fx_outware_mx.SetRedraw(False)
	Long row, i
	String ls_findstr
	DateTime ld_now
	ld_now = DateTime(Today(),Now())
	FOR i = arg_ds.RowCount() To 1 Step -1
		
		IF arg_ds.Object.fx_saletaskmx_reltaskid[i] <= 0 THEN CONTINUE
		
		row = dw_fx_outware_mx.InsertRow(0)
		
		
		dw_fx_outware_mx.Object.taskcode[row] =  arg_ds.Object.taskcode[i]
		dw_fx_outware_mx.Object.reltaskid[row] = arg_ds.Object.fx_saletaskmx_reltaskid[i]
		dw_fx_outware_mx.Object.relprintid[row] = arg_ds.Object.fx_saletaskmx_relprintid[i]
		
		
		dw_fx_outware_mx.Object.mtrlcode[row] =  arg_ds.Object.mtrlcode[i]
		dw_fx_outware_mx.Object.mtrlname[row] =  arg_ds.Object.mtrlname[i]
		dw_fx_outware_mx.Object.mtrlmode[row] =  arg_ds.Object.mtrlmode[i]
		dw_fx_outware_mx.Object.status[row] =  arg_ds.Object.status[i]
		dw_fx_outware_mx.Object.woodcode[row] =  arg_ds.Object.woodcode[i]
		dw_fx_outware_mx.Object.pcode[row] =   arg_ds.Object.pcode[i]
		dw_fx_outware_mx.Object.forqty[row] =   arg_ds.Object.forqty[i]
		dw_fx_outware_mx.Object.checkqty[row] =   arg_ds.Object.forqty[i]
		dw_fx_outware_mx.Object.checktype[row] =   1
		
		
		
		
		
		//		dw_fx_outware_mx.Object.taskid[row] = arg_ds.Object.taskid[i]
		//		dw_fx_outware_mx.Object.printid[row] = arg_ds.Object.printid[i]
		//		dw_fx_outware_mx.Object.mxcode[row] = arg_ds.Object.mxcode[i]
		//		dw_fx_outware_mx.Object.fxmtrlid[row] = arg_ds.Object.fxmtrlid[i]
		//		dw_fx_outware_mx.Object.mtrlid[row] = arg_ds.Object.mtrlid[i]
		//		dw_fx_outware_mx.Object.mtrlcode[row] = arg_ds.Object.mtrlcode[i]
		//		dw_fx_outware_mx.Object.mtrlname[row] = arg_ds.Object.mtrlname[i]
		//		dw_fx_outware_mx.Object.mtrlmode[row] = arg_ds.Object.mtrlmode[i]
		//		dw_fx_outware_mx.Object.status[row] = arg_ds.Object.status[i]
		//		dw_fx_outware_mx.Object.woodcode[row] = arg_ds.Object.woodcode[i]
		//		dw_fx_outware_mx.Object.pcode[row] = arg_ds.Object.pcode[i]
		//		dw_fx_outware_mx.Object.taskqty[row] = arg_ds.Object.qty[i] //订单数量
		//		dw_fx_outware_mx.Object.qty_wait[row] = arg_ds.Object.qty_wait[i]
		//		dw_fx_outware_mx.Object.cus_receiveqty[row] = arg_ds.Object.cus_receiveqty[i]
		////		IF arg_ds.Object.earliestsenddate[i] > ld_now THEN
		////			dw_fx_outware_mx.Object.qty[row] = 0 //发货数量
		////		ELSE 
		//			dw_fx_outware_mx.Object.qty[row] = arg_ds.Object.outqty[i]
		////		END IF
		//		
		//		dw_fx_outware_mx.Object.outwarecode[row] = ''
		//		dw_fx_outware_mx.Object.requiredate[row] = arg_ds.Object.requiredate[i]
		//	//	dw_fx_outware_mx.Object.price[row] = arg_ds.Object.price[i]row] = arg_ds.Object.mxdscrp[i]
		////		dw_fx_outware_mx.Object.mxdscrp2[row] = arg_ds.Object.mxdscrp2[i]
		//		dw_fx_outware_mx.Object.mtrlcuscode[row] = arg_ds.Object.mtrlcuscode[i]
		////		dw_fx_outware_mx.Object.plancode[row] = arg_ds.Object.plancode[i]
		//		dw_fx_outware_mx.Object.cus_mtrldef_senddays[row] = arg_ds.Object.cus_mtrldef_senddays[i]
		////		dw_fx_outware_mx.Object.mxdscrp[
		//		dw_fx_outware_mx.Object.earliestsenddate[row] = arg_ds.Object.earliestsenddate[i]
		//		dw_fx_outware_mx.Object.tid[row] = arg_ds.Object.tid[i]
		//		dw_fx_outware_mx.Object.taskcode[row] = arg_ds.Object.taskcode[i]
		//		dw_fx_outware_mx.Object.unit[row] = arg_ds.Object.unit[i]
		//		dw_fx_outware_mx.Object.fx_saletaskmx_saletask_mxid[row] = arg_ds.Object.saletask_mxid[i]
		//		
		//		dw_fx_outware_mx.Object.tempqty[row] = arg_ds.Object.outqty[i] //临时发货数，判断限制使用
	NEXT
	dw_fx_outware_mx.SetRedraw(True)
END IF


end event

type cb_delete_mx from commandbutton within w_fx_check_bill
integer x = 347
integer y = 1452
integer width = 306
integer height = 84
integer taborder = 40
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
boolean enabled = false
string text = "删明细"
end type

event clicked;IF dw_fx_outware_mx.RowCount() <= 0 THEN
	MessageBox('提示', '请先添加明细！')
	RETURN
END IF

Long i, Index
Index = 0


IF dw_fx_outware_mx.GetRow() > 0 THEN
	dw_fx_outware_mx.DeleteRow(dw_fx_outware_mx.GetRow() )
END IF

//IF index = 0 THEN
//	MessageBox('提示', '请先勾选要删除的发货明细!')
//END IF

end event

type cb_modify from uo_imflatbutton within w_fx_check_bill
integer x = 325
integer width = 165
integer height = 164
integer taborder = 20
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;if dw_edit_mode then
	if MessageBox('提示','是否放弃新建/修改操作?',Question! ,OKCancel! , 1 ) = 1 then
		wf_change_taborder(0)
		
		dw_edit_mode = false
	     if_modify_mode = false	  
		wf_btn_enabled()
		wf_retrieve_outware()
	end if
else
	long ll_row, ll_status
	
	ll_row = dw_fx_outware.GetRow()
	IF ll_row <= 0 THEN
		messagebox('提示', '请选择当前行,不能修改!')
	end if	
	
	ll_status = dw_fx_outware.Object.flag[ll_row]
	
	if ll_status <> 0 then
		messagebox('提示', '不是待审核单据,不能修改!')
		return
	end if
	
	wf_change_taborder(1)
	dw_edit_mode = true
	if_modify_mode = true
	wf_btn_enabled()
end if


end event

type dw_fx_outware from u_dw_rbtnfilter within w_fx_check_bill
integer x = 1842
integer y = 276
integer width = 1714
integer height = 1148
integer taborder = 20
boolean bringtotop = true
boolean titlebar = true
string dataobject = "dw_fx_check_bill_index"
boolean controlmenu = true
boolean maxbox = true
boolean hscrollbar = true
boolean vscrollbar = true
boolean resizable = true
boolean border = false
boolean hsplitscroll = true
borderstyle borderstyle = styleshadowbox!
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
boolean autosave_setlayout_use = false
boolean autosave_columnvisible_use = false
end type

event rowfocuschanged;call super::rowfocuschanged;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)

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

long ll_billid
ll_billid = this.Object.billid[currentrow]
wf_retrieve_outware_itemmx(ll_billid)

wf_retrieve_outware_mx(ll_billid)

end event

type dw_fx_outware_mx from u_dw_rbtnfilter within w_fx_check_bill
integer x = 27
integer y = 1564
integer width = 2624
integer height = 828
integer taborder = 20
boolean bringtotop = true
boolean titlebar = true
string title = "单据明细"
string dataobject = "dw_fx_check_bill_mx"
boolean hscrollbar = true
boolean vscrollbar = true
boolean livescroll = false
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

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

event rowfocuschanged;call super::rowfocuschanged;IF currentrow > 0 THEN
	This.SelectRow(0, False)
	This.SelectRow(currentrow, True)
	This.SetRow(currentrow)
	wf_filtermx()
END IF


end event

type cb_1 from uo_imflatbutton within w_fx_check_bill
boolean visible = false
integer x = 1161
integer y = 4
integer width = 274
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "唛头打印"
string normalpicname = "print.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

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

long ll_row, ll_status
	
ll_row = dw_fx_outware.GetRow()
IF ll_row <= 0 THEN
	messagebox('提示', '请选择当前行,不能打印!')
end if	

ll_status = dw_fx_outware.Object.status[ll_row]


if ll_status = 0 then
	messagebox('提示', '待审核单据,不能打印！')
	return
end if

Parent.TriggerEvent('ue_print_outware_all_mt')


end event

type dw_itemmx from u_dw_rbtnfilter within w_fx_check_bill
integer x = 2711
integer y = 1564
integer width = 2624
integer height = 828
integer taborder = 30
boolean bringtotop = true
boolean titlebar = true
string title = "质检项目明细"
string dataobject = "dw_fx_check_bill_itemmx"
boolean hscrollbar = true
boolean vscrollbar = true
boolean livescroll = false
boolean rbutton_filter_use = true
boolean rbutton_setposition_use = true
boolean titleclick_sort_use = true
end type

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

type st_1 from statictext within w_fx_check_bill
integer x = 23
integer y = 204
integer width = 288
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 = "状态"
alignment alignment = center!
boolean focusrectangle = false
end type

event constructor;this.backcolor = parent.backcolor
end event

type cb_input from commandbutton within w_fx_check_bill
integer x = 677
integer y = 1452
integer width = 384
integer height = 84
integer taborder = 50
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
string text = "录入质检结果"
end type

event clicked;//IF dw_fx_outware_mx.RowCount() <= 0 THEN
//	MessageBox('提示', '请先添加明细！')
//	RETURN
//END IF
//
//Long i, Index
//Index = 0
//
//
//IF dw_fx_outware_mx.GetRow() > 0 THEN
//	dw_fx_outware_mx.DeleteRow(dw_fx_outware_mx.GetRow() )
//END IF
//
Long ll_row
Long cnt,i

IF  dw_fx_outware_free.GetRow() > 0 THEN
	IF dw_fx_outware_free.Object.flag[dw_fx_outware_free.GetRow()] <> 1 THEN
		MessageBox('提示', '单据不是质检中状态，不能录入质检结果！')
		RETURN
	END IF
	
END IF




ll_row = dw_fx_outware_mx.GetRow()
IF  ll_row <= 0 THEN
	MessageBox('提示', '请选择明细！')
	RETURN
END IF
s_check_bill_mx s_mx

s_mx.billid = dw_fx_outware_mx.Object.billid[ll_row]
s_mx.printid = dw_fx_outware_mx.Object.printid[ll_row]
s_mx.taskcode = dw_fx_outware_mx.Object.taskcode[ll_row]
s_mx.reltaskid = dw_fx_outware_mx.Object.reltaskid[ll_row]
s_mx.relprintid = dw_fx_outware_mx.Object.relprintid[ll_row]
s_mx.forqty = dw_fx_outware_mx.Object.forqty[ll_row]
s_mx.passqty = dw_fx_outware_mx.Object.passqty[ll_row]
s_mx.checktype = dw_fx_outware_mx.Object.checktype[ll_row]
s_mx.checkqty = dw_fx_outware_mx.Object.checkqty[ll_row]
s_mx.goodqty = dw_fx_outware_mx.Object.goodqty[ll_row]
s_mx.badqty = dw_fx_outware_mx.Object.badqty[ll_row]
s_mx.finishflag = dw_fx_outware_mx.Object.finishflag[ll_row]
s_mx.checkemp = dw_fx_outware_mx.Object.checkemp[ll_row]
s_mx.checkdate = dw_fx_outware_mx.Object.checkdate[ll_row]
s_mx.mxdscrp = dw_fx_outware_mx.Object.mxdscrp[ll_row]
s_mx.mtrlcode = dw_fx_outware_mx.Object.mtrlcode[ll_row]
s_mx.mtrlname = dw_fx_outware_mx.Object.mtrlname[ll_row]
s_mx.mtrlmode = dw_fx_outware_mx.Object.mtrlmode[ll_row]
s_mx.status = dw_fx_outware_mx.Object.status[ll_row]
s_mx.woodcode = dw_fx_outware_mx.Object.woodcode[ll_row]
s_mx.pcode = dw_fx_outware_mx.Object.pcode[ll_row]

cnt = 0
FOR i = 1 To dw_itemmx.RowCount()
	IF dw_itemmx.Object.fx_check_bill_itemmx_printid[i] = s_mx.printid THEN
		cnt++
		s_mx.itemmx[cnt].billid = dw_itemmx.Object.fx_check_bill_itemmx_billid[i]
		s_mx.itemmx[cnt].printid = dw_itemmx.Object.fx_check_bill_itemmx_printid[i]
		s_mx.itemmx[cnt].mxid = dw_itemmx.Object.fx_check_bill_itemmx_mxid[i]
		s_mx.itemmx[cnt].itemid_erp = dw_itemmx.Object.fx_check_bill_itemmx_itemid_erp[i]
		s_mx.itemmx[cnt].qcresult = dw_itemmx.Object.fx_check_bill_itemmx_qcresult[i]
		s_mx.itemmx[cnt].goodqty = dw_itemmx.Object.fx_check_bill_itemmx_goodqty[i]
		s_mx.itemmx[cnt].badqty = dw_itemmx.Object.fx_check_bill_itemmx_badqty[i]
		s_mx.itemmx[cnt].itemname = dw_itemmx.Object.fx_checkitem_itemname[i]
		
	END IF
	
	
NEXT


IF  cnt = 0 THEN
	MessageBox('提示', '没有质检明细！')
	RETURN
END IF



openwithparm(w_fx_check_bill_result,s_mx )
wf_retrieve_outware_itemmx(s_mx.billid)
wf_retrieve_outware_mx(s_mx.billid)































end event

