$PBExportHeader$w_outware_receive_fx.srw
$PBExportComments$销售发货单 转 采购收货单
forward
global type w_outware_receive_fx from w_publ_base_style
end type
type cb_accept from uo_imflatbutton within w_outware_receive_fx
end type
type cb_reject from uo_imflatbutton within w_outware_receive_fx
end type
type dw_tempoutware from datawindow within w_outware_receive_fx
end type
type st_1 from statictext within w_outware_receive_fx
end type
type mle_summary from multilineedit within w_outware_receive_fx
end type
type tab_1 from tab within w_outware_receive_fx
end type
type tabpage_1 from userobject within tab_1
end type
type dw_tempoutwaremx from u_dw_rbtnfilter within tabpage_1
end type
type tabpage_1 from userobject within tab_1
dw_tempoutwaremx dw_tempoutwaremx
end type
type tab_1 from tab within w_outware_receive_fx
tabpage_1 tabpage_1
end type
type st_2 from statictext within w_outware_receive_fx
end type
type mle_postscript from multilineedit within w_outware_receive_fx
end type
type st_3 from statictext within w_outware_receive_fx
end type
type mle_remark from multilineedit within w_outware_receive_fx
end type
end forward

global type w_outware_receive_fx from w_publ_base_style
integer width = 3771
integer height = 2372
string title = "供应商销售发货单"
boolean minbox = false
windowtype windowtype = response!
windowstate windowstate = maximized!
long backcolor = 16777215
string icon = "graphics\chain_link_128px.ico"
boolean center = true
cb_accept cb_accept
cb_reject cb_reject
dw_tempoutware dw_tempoutware
st_1 st_1
mle_summary mle_summary
tab_1 tab_1
st_2 st_2
mle_postscript mle_postscript
st_3 st_3
mle_remark mle_remark
end type
global w_outware_receive_fx w_outware_receive_fx

type variables
s_open_packet s_tran

datawindow dw_tempoutwaremx
end variables

forward prototypes
public function integer wf_retrieve (readonly string arg_sn, ref string arg_msg)
public subroutine wf_accept ()
public function integer wf_reject (readonly string arg_postscript)
end prototypes

public function integer wf_retrieve (readonly string arg_sn, ref string arg_msg);int rslt = 1

dw_tempoutware.Reset( )
dw_tempoutwaremx.Reset( )

if (arg_sn = '') then
	rslt = 0
	arg_msg = 'SN号为空'
	goto ext
end if

oleobject outwareInfo
outwareInfo = FXAppCom.GetOutWare(app_token_fx, arg_sn, ref arg_msg)
if (arg_msg <> '') then
	rslt = 0
	goto ext
end if

oleobject outware, outwaremxs, mxItem

outware = outwareInfo.GetPBDictionary('outware')
long row
dw_tempoutware.SetRedraw(false)
row = dw_tempoutware.InsertRow(0)

dw_tempoutware.Object.outwarecode[row] = outware.GetString('outwarecode')
dw_tempoutware.Object.flag_bill[row] = outware.GetInt('flag_bill')
dw_tempoutware.Object.part[row] = outware.GetString('part')
dw_tempoutware.Object.sptname[row] = outware.GetString('sptname')
dw_tempoutware.Object.rel_address[row] = outware.GetString('rel_address')
dw_tempoutware.Object.relstr_1[row] = outware.GetString('relstr_1')
dw_tempoutware.Object.relstr_2[row] = outware.GetString('relstr_2')
dw_tempoutware.Object.damt[row] = outware.GetDouble('damt')
dw_tempoutware.Object.otheramt[row] = outware.GetDouble('otheramt')
if ( not IsNull(outware.GetDateTime('outdate'))) then
	dw_tempoutware.Object.outdate[row] = outware.GetDateTime('outdate')
end if
if (not IsNull(outware.GetDateTime('viewdate'))) then
	dw_tempoutware.Object.viewdate[row] = outware.GetDateTime('viewdate')
end if
dw_tempoutware.Object.outrep[row] = outware.GetString('outrep')
dw_tempoutware.Object.upname[row] = outware.GetString('upname')
dw_tempoutware.Object.dscrp[row] = outware.GetString('dscrp')
dw_tempoutware.Object.opemp[row] = outware.GetString('opemp')
if (not IsNull(outware.GetDateTime('opdate'))) then
	dw_tempoutware.Object.opdate[row] = outware.GetDateTime('opdate')
end if
dw_tempoutware.Object.auditingrep[row] = outware.GetString('auditingrep')
if (not IsNull(outware.GetDateTime('auditingdate'))) then
	dw_tempoutware.Object.auditingdate[row] = outware.GetDateTime('auditingdate')
end if
dw_tempoutware.Object.confirmuser[row] = outware.GetString('confirmuser')
if (not IsNull(outware.GetDateTime('confirmtime'))) then
	dw_tempoutware.Object.confirmtime[row] = outware.GetDateTime('confirmtime')
end if
dw_tempoutware.SetRedraw(true)

outwaremxs = outwareInfo.GetArrOfPBDictionary('outwaremxs')
long i
dw_tempoutwaremx.SetRedraw(false)
for i = 1 to outwaremxs.Count
	mxItem = outwaremxs.GetItem(i - 1)
	row = dw_tempoutwaremx.InsertRow(0)
	
	dw_tempoutwaremx.Object.fiebrelcode[row] = mxItem.GetString('fiebrelcode')
	dw_tempoutwaremx.Object.mxcode[row] = mxItem.GetString('mxcode')
	dw_tempoutwaremx.Object.mtrlcode[row] = mxItem.GetString('mtrlcode')
	dw_tempoutwaremx.Object.mtrlname[row] = mxItem.GetString('mtrlname')
	dw_tempoutwaremx.Object.mtrlmode[row] = mxItem.GetString('mtrlmode')
	dw_tempoutwaremx.Object.qty[row] = mxItem.GetDouble('qty')
	dw_tempoutwaremx.Object.accept_qty[row] = mxItem.GetDouble('accept_qty')
	dw_tempoutwaremx.Object.accepted_qty[row] = mxItem.GetDouble('accepted_qty')
	dw_tempoutwaremx.Object.task_qty[row] = mxItem.GetDouble('task_qty')
	dw_tempoutwaremx.Object.unit[row] = Trim(mxItem.GetString('unit'))
	dw_tempoutwaremx.Object.enprice[row] = mxItem.GetDouble('enprice')
	dw_tempoutwaremx.Object.rebate[row] = mxItem.GetDouble('rebate')
	dw_tempoutwaremx.Object.taxrate[row] = mxItem.GetDouble('taxrate')
	dw_tempoutwaremx.Object.net_weight[row] = mxItem.GetDouble('net_weight')
	dw_tempoutwaremx.Object.gross_weight[row] = mxItem.GetDouble('gross_weight')
	dw_tempoutwaremx.Object.cubage[row] = mxItem.GetDouble('cubage')
	dw_tempoutwaremx.Object.fxmtrlid[row] = mxItem.GetInt('fxmtrlid')
	dw_tempoutwaremx.Object.taskid[row] = mxItem.GetInt('taskid')
	dw_tempoutwaremx.Object.printid[row] = mxItem.GetInt('printid')
next
dw_tempoutwaremx.SetRedraw(true)

ext:
return rslt
end function

public subroutine wf_accept ();oleobject item, list
list = FXAppCom.CreArrOfPbDictionary()

long i
for i = 1 to dw_tempoutwaremx.RowCount( )
	if (dw_tempoutwaremx.Object.accept_qty[i] <= 0) then continue
	
	item = FXAppCom.CreatePbDictionary()
	
	item.SetInt('taskid', dw_tempoutwaremx.Object.taskid[i])
	item.SetInt('printid', dw_tempoutwaremx.Object.printid[i])
	item.SetDouble('qty', dw_tempoutwaremx.Object.accept_qty[i])
	item.SetString('mxcode', dw_tempoutware.Object.outwarecode[1]) // 存放供应商相关发货单号
	
	list.Add(item)
next

string arg_msg
FXAppCom.AcceptOutware(app_token_fx, list, s_tran.sn, ref arg_msg)

if (arg_msg <> '') then
	MessageBox('操作失败', arg_msg)
else
	MessageBox('提示', '成功!')
	Close(this)
	return
end if
end subroutine

public function integer wf_reject (readonly string arg_postscript);int rslt = 1

string arg_msg
FXAppCom.RejectOutware(app_token_fx, s_tran.sn, arg_postscript, ref arg_msg)

if (arg_msg <> '') then
	MessageBox('提示', '拒绝操作失败:' + arg_msg)
else
	MessageBox('提示' ,'成功')
	Close(this)
end if

return rslt
end function

on w_outware_receive_fx.create
int iCurrent
call super::create
this.cb_accept=create cb_accept
this.cb_reject=create cb_reject
this.dw_tempoutware=create dw_tempoutware
this.st_1=create st_1
this.mle_summary=create mle_summary
this.tab_1=create tab_1
this.st_2=create st_2
this.mle_postscript=create mle_postscript
this.st_3=create st_3
this.mle_remark=create mle_remark
iCurrent=UpperBound(this.Control)
this.Control[iCurrent+1]=this.cb_accept
this.Control[iCurrent+2]=this.cb_reject
this.Control[iCurrent+3]=this.dw_tempoutware
this.Control[iCurrent+4]=this.st_1
this.Control[iCurrent+5]=this.mle_summary
this.Control[iCurrent+6]=this.tab_1
this.Control[iCurrent+7]=this.st_2
this.Control[iCurrent+8]=this.mle_postscript
this.Control[iCurrent+9]=this.st_3
this.Control[iCurrent+10]=this.mle_remark
end on

on w_outware_receive_fx.destroy
call super::destroy
destroy(this.cb_accept)
destroy(this.cb_reject)
destroy(this.dw_tempoutware)
destroy(this.st_1)
destroy(this.mle_summary)
destroy(this.tab_1)
destroy(this.st_2)
destroy(this.mle_postscript)
destroy(this.st_3)
destroy(this.mle_remark)
end on

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

dw_tempoutwaremx = tab_1.tabpage_1.dw_tempoutwaremx

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

string arg_msg
wf_retrieve(s_tran.sn, ref arg_msg)

if (arg_msg <> '') then
	MessageBox('提示', arg_msg)
	Close(this)
	return
end if
end event

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

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

tab_1.Width = this.workspacewidth( )
tab_1.tabpage_1.dw_tempoutwaremx.Width = tab_1.Width - 40

tab_1.Height = this.workspaceheight( ) - tab_1.Y
tab_1.tabpage_1.dw_tempoutwaremx.Height = tab_1.Height - 118

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

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

type cb_exit from w_publ_base_style`cb_exit within w_outware_receive_fx
integer x = 2766
end type

type ln_bar from w_publ_base_style`ln_bar within w_outware_receive_fx
end type

type ln_bar2 from w_publ_base_style`ln_bar2 within w_outware_receive_fx
end type

type r_bar from w_publ_base_style`r_bar within w_outware_receive_fx
end type

type cb_accept from uo_imflatbutton within w_outware_receive_fx
integer width = 384
integer height = 164
integer taborder = 30
boolean bringtotop = true
string text = "确认本次收货"
string normalpicname = "ok.bmp"
integer picsize = 16
toolbaralignment pic_align = alignattop!
boolean border = false
end type

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

long cnt
cnt = dw_tempoutwaremx.RowCount( )

if (cnt <= 0) then
	MessageBox('提示', '没有收货明细')
	return
end if

dw_tempoutwaremx.AcceptText( )

string sum_msg
long i
boolean pass = true
for i = 1 to cnt
	if (dw_tempoutwaremx.Object.accept_qty[i] <= 0) then
		sum_msg += '第' + string(i) + '行,物料名称[' + string(dw_tempoutwaremx.Object.mtrlname[i]) + '],本次收货数为0~r~n'
	end if
	
	if (dw_tempoutwaremx.Object.accept_qty[i] > dw_tempoutwaremx.Object.qty[i]) then
		sum_msg += '第' + string(i) + '行,物料名称[' + string(dw_tempoutwaremx.Object.mtrlname[i]) + '],本次收货数大于发货数~r~n'
		pass = false
	end if
	
	if (dw_tempoutwaremx.Object.accept_qty[i] + dw_tempoutwaremx.Object.accepted_qty[i] > dw_tempoutwaremx.Object.task_qty[i]) then
		sum_msg += '第' + string(i) + '行,物料名称[' + string(dw_tempoutwaremx.Object.mtrlname[i]) + '],总收货数大于订单采购数~r~n'
		pass = false
	end if
next

if (sum_msg <> '' and pass) then
	if (MessageBox('提示', sum_msg + '~r~n确认继续?', Question!, YesNoCancel!) <> 1) then
		return
	end if
elseif (sum_msg <> '' and (not pass)) then
	OpenWithParm(w_message_err,  '存在本次收货数大于发货数 / 总收货数大于订单采购数的明细,请检查:~r~n' + sum_msg)
	return
end if

wf_accept( )

end event

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

event clicked;call super::clicked;Open(w_packet_msg_edit_fx)

s_open_packet s_ret
s_ret = Message.PowerObjectParm

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

wf_reject(s_ret.postscript)
end event

type dw_tempoutware from datawindow within w_outware_receive_fx
integer y = 172
integer width = 1801
integer height = 1104
integer taborder = 20
boolean bringtotop = true
string title = "none"
string dataobject = "dw_tempoutware"
boolean livescroll = true
end type

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

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

type tab_1 from tab within w_outware_receive_fx
integer x = 5
integer y = 1280
integer width = 3771
integer height = 848
integer taborder = 40
boolean bringtotop = true
integer textsize = -9
integer weight = 400
fontcharset fontcharset = gb2312charset!
fontpitch fontpitch = variable!
string facename = "宋体"
long backcolor = 16777215
boolean raggedright = true
boolean focusonbuttondown = true
integer selectedtab = 1
tabpage_1 tabpage_1
end type

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

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

type tabpage_1 from userobject within tab_1
integer x = 18
integer y = 96
integer width = 3735
integer height = 736
long backcolor = 16777215
string text = "发货明细"
long tabtextcolor = 33554432
long tabbackcolor = 16777215
long picturemaskcolor = 536870912
dw_tempoutwaremx dw_tempoutwaremx
end type

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

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

type dw_tempoutwaremx from u_dw_rbtnfilter within tabpage_1
integer width = 3707
integer height = 548
integer taborder = 20
string dataobject = "dw_tempoutwaremx"
boolean hscrollbar = true
boolean vscrollbar = true
borderstyle borderstyle = stylebox!
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 return

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

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

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

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

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

