$PBExportHeader$w_bom_build_assist.srw forward global type w_bom_build_assist from w_publ_base end type type dw_1 from u_dw_rbtnfilter within w_bom_build_assist end type type cb_1 from uo_imflatbutton within w_bom_build_assist end type type st_1 from statictext within w_bom_build_assist end type type cb_2 from uo_imflatbutton within w_bom_build_assist end type type cb_edit from uo_imflatbutton within w_bom_build_assist end type type cb_3 from uo_imflatbutton within w_bom_build_assist end type type cb_addmx from uo_imflatbutton within w_bom_build_assist end type type cb_4 from uo_imflatbutton within w_bom_build_assist end type type cb_sort from uo_imflatbutton within w_bom_build_assist end type type cb_6 from uo_imflatbutton within w_bom_build_assist end type type cb_7 from uo_imflatbutton within w_bom_build_assist end type type cb_5 from uo_imflatbutton within w_bom_build_assist end type type ln_bar from line within w_bom_build_assist end type type ln_bar2 from line within w_bom_build_assist end type type ln_1 from line within w_bom_build_assist end type type ln_2 from line within w_bom_build_assist end type type r_bar from rectangle within w_bom_build_assist end type end forward global type w_bom_build_assist from w_publ_base integer width = 4224 integer height = 2328 string title = "物料清单辅助表" boolean maxbox = true boolean resizable = true windowstate windowstate = maximized! event ue_f8 ( ) event ue_f9 ( ) event ue_f10 ( ) event ue_save_modle ( ) event ue_save_modle_as ( ) event ue_save_bill ( ) event ue_save_bill_as ( ) event ue_open_bill ( ) event ue_pickmtrl ( ) event ue_addmx ( ) event ue_delmx ( ) dw_1 dw_1 cb_1 cb_1 st_1 st_1 cb_2 cb_2 cb_edit cb_edit cb_3 cb_3 cb_addmx cb_addmx cb_4 cb_4 cb_sort cb_sort cb_6 cb_6 cb_7 cb_7 cb_5 cb_5 ln_bar ln_bar ln_bar2 ln_bar2 ln_1 ln_1 ln_2 ln_2 r_bar r_bar end type global w_bom_build_assist w_bom_build_assist type variables long ins_column_count = 0 uo_cmpl_modle uo_modle uo_cmpl_bill uo_bill string ins_oldtitle // 区间 long ins_first = 8 long ins_last = 47 end variables forward prototypes public function integer wf_build_bom (ref string arg_msg) public function integer wf_checkrand (long checked_mtrlid, long obj_mtrlid) end prototypes event ue_f8();// TODO: 研究列添加的交互方式 IF NOT IsValid(W_mtrldef_edit) THEN s_edit_index_tran s_tranf8 //传递参数使用 s_tranf8.if_retrieve_all = FALSE //是否一次RETRIEVE所有行 s_tranf8.work_mode = 1 //0-单纯编辑模式 1-选择\编辑模式 s_tranf8.arg_pkid = 0 //目标定位PKID (备用) s_tranf8.arg_string_code = '' //查询列(物料编码)部分内容,用于初步筛选 s_tranf8.if_select_all = TRUE //多选 s_tranf8.b_long = 0 //选采购 s_tranf8.c_long = -1 Long chc = 1,ls_j OpenWithParm(W_mtrldef_edit,s_tranf8) //调用 s_mtrldef_array S_INSCUST S_INSCUST = Message.PowerObjectParm //接受返回结构 IF UpperBound(S_INSCUST.mtrlid) > 30 THEN MessageBox('提示', '一次最多只能选30个产品') RETURN END IF if upperBound(S_INSCUST.mtrlid) <= 0 then return if S_INSCUST.mtrlid[1] <= 0 then return dw_1.Reset() String ls_mod FOR ls_j = ins_first TO ins_last ls_mod = '#' + String(ls_j) + '.Visible = 0' ls_mod = dw_1.Modify(ls_mod) NEXT chc = 0 FOR ls_j = 1 TO UpperBound(S_INSCUST.mtrlid) IF S_INSCUST.mtrlid[ls_j] > 0 THEN chc ++ ls_mod = 'mtrl' + String(chc) + '.Visible = 1' ls_mod = dw_1.Modify(ls_mod) ls_mod = 'mtrl' + String(chc) + '_t.Text = ~''+String(S_INSCUST.mtrlname[ls_j])+'~'' ls_mod = dw_1.Modify(ls_mod) ls_mod = 'mtrl' + String(chc) + '_t.Tag = ~''+String(S_INSCUST.mtrlid[ls_j])+'~'' ls_mod = dw_1.Modify(ls_mod) ls_mod = 'mtrl' + String(chc) + '.Tag = ~''+String(S_INSCUST.mtrlcode[ls_j])+'~'' ls_mod = dw_1.Modify(ls_mod) END IF NEXT ins_column_count = chc FOR ls_j = (ins_first + 30) TO ins_last ls_mod = '#' + String(ls_j) + '.Visible = 1' ls_mod = dw_1.Modify(ls_mod) NEXT // // for ls_j = 1 to UpperBound(S_INSCUST.mtrlid) // if S_INSCUST.mtrlid[ls_j] > 0 then // chc = dw_2.insertrow(0) // dw_2.object.mtrlid[chc] = S_INSCUST.mtrlid[1] // dw_2.object.mtrlcode[chc] = S_INSCUST.mtrlcode[1] // dw_2.object.mtrlname[chc] = S_INSCUST.mtrlname[1] // // end if // next // // dw_1.Reset() END IF end event event ue_f9();long ll_product_mtrlid string ls_dscrp, ls_mode[] decimal ld_value if ins_column_count = 0 then MessageBox('提示', '请先选择产品') return end if IF NOT IsValid(w_bom_modle_ch) THEN Open(w_bom_modle_ch) //调用 long ls_j, ll_row, ll_col s_cmpl_modle_ch S_INSCUST S_INSCUST = Message.PowerObjectParm //接受返回结构 if S_INSCUST.modleid > 0 then uo_modle.modleid = s_inscust.modleid uo_modle.modlename = s_inscust.modlename dw_1.reset() st_1.Text = '模板名:' + S_INSCUST.modlename for ls_j = 1 to upperbound(S_INSCUST.printid) ll_row = dw_1.insertrow(0) dw_1.object.printid[ll_row] = S_INSCUST.printid[ls_j] dw_1.object.parmname[ll_row] = S_INSCUST.parmname[ls_j] dw_1.object.displayname[ll_row] = S_INSCUST.displayname[ls_j] dw_1.object.defaultvalue[ll_row] = S_INSCUST.defaultvalue[ls_j] dw_1.object.if_useformula[ll_row] = S_INSCUST.if_useformula[ls_j] dw_1.object.formula[ll_row] = S_INSCUST.formula[ls_j] dw_1.object.if_from_mtrl[ll_row] = S_INSCUST.if_from_mtrl[ls_j] dw_1.object.mtrlid[ll_row] = S_INSCUST.mtrlid[ls_j] dw_1.object.mtrl_pro[ll_row] = S_INSCUST.mtrl_pro[ls_j] dw_1.object.if_from_product[ll_row] = S_INSCUST.if_from_product[ls_j] dw_1.object.product_pro[ll_row] = S_INSCUST.product_pro[ls_j] dw_1.object.mtrlcode[ll_row] = S_INSCUST.mtrlcode[ls_j] dw_1.object.mtrlname[ll_row] = S_INSCUST.mtrlname[ls_j] dw_1.object.dscrp[ll_row] = S_INSCUST.dscrp[ls_j] dw_1.object.wrkGrpid[ll_row] = S_INSCUST.wrkGrpid[ls_j] dw_1.object.advancetime[ll_row] = S_INSCUST.advancetime[ls_j] dw_1.object.unit[ll_row] = S_INSCUST.unit[ls_j] //============================================================================== // 物料相关 //============================================================================== if S_INSCUST.if_from_mtrl[ls_j] = 1 then if S_INSCUST.mtrl_pro[ls_j] = '最新价' then // DONE: 获取物料最新价 SELECT price INTO :ld_value FROM v_maxprice_sptprice WHERE mtrlid = :S_INSCUST.mtrlid[ls_j]; if sqlca.sqlcode <> 0 then ld_value = 0 end if for ll_col = 1 to ins_column_count dw_1.SetItem(ll_row, 'mtrl' + string(ll_col), ld_value) next end if if S_INSCUST.mtrl_pro[ls_j] = '缩率' then // DONE: 获取物料缩率 SELECT zxmtrlmode INTO :ls_dscrp FROM u_mtrldef WHERE mtrlid = :S_INSCUST.mtrlid[ls_j]; if sqlca.sqlcode <> 0 then ls_dscrp = '0' end if if not IsNumber(ls_dscrp) then ls_dscrp = '0' end if ld_value = dec(ls_dscrp) for ll_col = 1 to ins_column_count dw_1.SetItem(ll_row, 'mtrl' + string(ll_col), ld_value) next end if end if //============================================================================== // 产品相关 //============================================================================== if S_INSCUST.if_from_product[ls_j] = 1 then if S_INSCUST.product_pro[ls_j] = '长' then for ll_col = 1 to ins_column_count ls_dscrp = dw_1.Describe('mtrl'+string(ll_col)+'_t.tag') ll_product_mtrlid = long(ls_dscrp) // DONE: 获取产品长 SELECT mtrlmode INTO :ls_dscrp FROM u_mtrldef WHERE mtrlid = :ll_product_mtrlid; if sqlca.sqlcode <> 0 then ls_dscrp = '0*0*0' end if f_str_split(ls_dscrp, '*', ls_mode) if upperbound(ls_mode) < 1 then ls_mode[1] = '0' end if if not isnumber(ls_mode[1]) then ls_mode[1] = '0' end if ld_value = dec(ls_mode[1]) dw_1.SetItem(ll_row, 'mtrl' + string(ll_col), ld_value) next end if if S_INSCUST.product_pro[ls_j] = '宽' then for ll_col = 1 to ins_column_count ls_dscrp = dw_1.Describe('mtrl'+string(ll_col)+'_t.tag') ll_product_mtrlid = long(ls_dscrp) // DONE: 获取产品宽 SELECT mtrlmode INTO :ls_dscrp FROM u_mtrldef WHERE mtrlid = :ll_product_mtrlid; if sqlca.sqlcode <> 0 then ls_dscrp = '0*0*0' end if f_str_split(ls_dscrp, '*', ls_mode) if upperbound(ls_mode) < 2 then ls_mode[2] = '0' end if if not isnumber(ls_mode[2]) then ls_mode[2] = '0' end if ld_value = dec(ls_mode[2]) dw_1.SetItem(ll_row, 'mtrl' + string(ll_col), ld_value) next end if if S_INSCUST.product_pro[ls_j] = '高' then for ll_col = 1 to ins_column_count ls_dscrp = dw_1.Describe('mtrl'+string(ll_col)+'_t.tag') ll_product_mtrlid = long(ls_dscrp) // DONE: 获取产品高 SELECT mtrlmode INTO :ls_dscrp FROM u_mtrldef WHERE mtrlid = :ll_product_mtrlid; if sqlca.sqlcode <> 0 then ls_dscrp = '0*0*0' end if f_str_split(ls_dscrp, '*', ls_mode) if upperbound(ls_mode) < 3 then ls_mode[3] = '0' end if if not isnumber(ls_mode[3]) then ls_mode[3] = '0' end if ld_value = dec(ls_mode[3]) dw_1.SetItem(ll_row, 'mtrl' + string(ll_col), ld_value) next end if end if if S_INSCUST.if_useformula[ls_j] = 1 then // DONE: 公式字段,手动触发 end if //============================================================================== // 不用公式,不相关物料,不相关产品 //============================================================================== // if S_INSCUST.if_useformula[ls_j] <> 1 AND S_INSCUST.if_from_product[ls_j] <> 1 AND S_INSCUST.if_from_mtrl[ls_j] <> 1 then // for ll_col = 1 to ins_column_count // dw_1.SetItem(ll_row, 'mtrl' + string(ll_col), S_INSCUST.defaultValue[ls_j]) // next // end if next end if END IF end event event ue_f10();s_cmpl_parm s_parms[] Long ll_row, ll_col String ls_msg Decimal ll_value if ins_column_count = 0 then MessageBox('提示', '请先选择产品') return end if if dw_1.RowCount() <= 0 then MessageBox('提示', '请先选择计价模板') return end if if dw_1.accepttext() <> 1 then return FOR ll_row = 1 TO dw_1.RowCount() FOR ll_col = 1 TO ins_column_count s_parms[ll_col].parmname[ll_row] = dw_1.Object.parmname[ll_row] s_parms[ll_col].DisplayName[ll_row] = dw_1.Object.DisplayName[ll_row] s_parms[ll_col].parmvalue[ll_row] = 0 IF dw_1.Object.if_useformula[ll_row] = 1 THEN IF f_cmpl_with_parms(dw_1.Object.formula[ll_row], s_parms[ll_col], ll_value, ls_msg) <> 1 THEN MessageBox('计算公式失败', ls_msg, stopsign!) dw_1.ScrollToRow(ll_row) dw_1.SetColumn('formula') dw_1.SetFocus() RETURN END IF dw_1.SetItem(ll_row, 'mtrl' + String(ll_col), ll_value) END IF s_parms[ll_col].parmvalue[ll_row] = dw_1.GetItemDecimal(ll_row, 'mtrl' + String(ll_col)) NEXT NEXT end event event ue_save_modle();// DONE: 保存模板 if dw_1.rowcount() <= 0 then MessageBox('提示', '没有内容不能保存') return end if s_inputbox s_parm string ls_return long i if dw_1.accepttext() <> 1 then return end if for i = 1 to dw_1.RowCount() if trim(dw_1.object.parmname[i]) = '' then MessageBox('提示', '参数名不能为空') dw_1.scrolltorow(i) dw_1.setcolumn('parmname') dw_1.SetFocus() return end if if trim(dw_1.object.displayname[i]) = '' then MessageBox('提示', '显示名不能为空') dw_1.scrolltorow(i) dw_1.setcolumn('displayname') dw_1.SetFocus() return end if if pos(dw_1.object.parmname[i], '[') > 0 then MessageBox('提示', '参数名不能包含字符"["') dw_1.scrolltorow(i) dw_1.setcolumn('parmname') dw_1.SetFocus() return end if if pos(dw_1.object.parmname[i], ']') > 0 then MessageBox('提示', '参数名不能包含字符"]"') dw_1.scrolltorow(i) dw_1.setcolumn('parmname') dw_1.SetFocus() return end if if dw_1.object.if_useformula[i] = 1 AND trim(dw_1.object.formula[i]) = '' then MEssageBox('提示', '请输入公式') dw_1.scrolltorow(i) dw_1.setcolumn('formula') dw_1.SetFocus() return end if if dw_1.object.if_from_mtrl[i] = 1 AND dw_1.object.mtrlid[i] <= 0 then MessageBox('提示', '请选择相关物料') dw_1.scrolltorow(i) dw_1.setcolumn('mtrlcode') dw_1.SetFocus() return end if if dw_1.object.if_from_mtrl[i] = 1 AND trim(dw_1.object.mtrl_pro[i]) = '' then MessageBox('提示', '请选择相关物料属性') dw_1.scrolltorow(i) dw_1.setcolumn('mtrl_pro') dw_1.SetFocus() return end if if dw_1.object.if_from_product[i] = 1 AND trim(dw_1.object.product_pro[i]) = '' then MessageBox('提示', '请选择相关产品属性') dw_1.scrolltorow(i) dw_1.setcolumn('product_pro') dw_1.SetFocus() return end if next string ls_msg if uo_modle.modleid = 0 then if uo_modle.newbegin(ls_msg) <> 1 then MessageBox('', ls_msg) return end if s_parm.title = '输入工作表名称' s_parm.old_text = '' openwithparm(w_inputbox, s_parm) ls_return = message.stringparm if ls_return = '' OR isnull(ls_return) then return uo_modle.ModleName = ls_return else if uo_modle.updatebegin(uo_modle.modleid, ls_msg) <> 1 then MessageBox('', ls_msg) return end if end if uo_modle.modletype = 2 // uo_modle.modlename = trim(sle_modlename.text) s_cmpl_modlemx tmp[] for i = 1 to dw_1.RowCount() dw_1.object.printid[i] = i tmp[i].modleid = 0 tmp[i].printid = dw_1.object.printid[i] tmp[i].parmName = dw_1.object.parmName[i] tmp[i].displayName = dw_1.object.displayName[i] tmp[i].defaultValue = dw_1.object.defaultValue[i] tmp[i].if_useformula = dw_1.object.if_useformula[i] tmp[i].formula = dw_1.object.formula[i] tmp[i].if_from_mtrl = dw_1.object.if_from_mtrl[i] tmp[i].mtrlid = dw_1.object.mtrlid[i] tmp[i].mtrl_pro = dw_1.object.mtrl_pro[i] tmp[i].if_from_product = dw_1.object.if_from_product[i] tmp[i].product_pro = dw_1.object.product_pro[i] next uo_modle.mxs = tmp if uo_modle.savesubmit(ls_msg) <> 1 then MessageBox('错误', ls_msg) return end if st_1.Text = '模板名:' + uo_modle.modlename end event event ue_save_modle_as();// DONE: 另存模板 long oldid oldid = uo_modle.modleid uo_modle.modleid = 0 this.triggerevent('ue_save_modle') if uo_modle.modleid = 0 then uo_modle.modleid = oldid end if end event event ue_save_bill();// DONE: 保存工作表 if dw_1.rowcount() <= 0 then MessageBox('提示', '没有内容不能保存') return end if s_inputbox s_parm string ls_return long i if dw_1.accepttext() <> 1 then return end if string ls_msg if uo_bill.ModleID = 0 then if uo_bill.Newbegin(ls_msg) <> 1 then MessageBox('', ls_msg) return end if s_parm.title = '输入工作表名称' s_parm.old_text = '' openwithparm(w_inputbox, s_parm) ls_return = message.stringparm if ls_return = '' OR isnull(ls_return) then return uo_bill.ModleName = ls_return else if uo_bill.UpdateBegin(uo_bill.Modleid, ls_msg) <> 1 then MessageBox('', ls_msg) return end if end if uo_bill.ModleType = 3 uo_bill.orgModleID = 0 s_cmpl_modlemx tmp[] s_cmpl_modlemx_mx tmp_mx[] long j = 0, ll_col = 0 string ls_dscrp for i = 1 to dw_1.RowCount() dw_1.object.printid[i] = i tmp[i].modleid = 0 tmp[i].printid = i tmp[i].parmName = dw_1.object.parmName[i] tmp[i].displayName = dw_1.object.displayName[i] tmp[i].defaultValue = 0 tmp[i].if_useformula = dw_1.object.if_useformula[i] tmp[i].formula = dw_1.object.formula[i] tmp[i].if_from_mtrl = dw_1.object.if_from_mtrl[i] tmp[i].mtrlid = dw_1.object.mtrlid[i] tmp[i].mtrl_pro = dw_1.object.mtrl_pro[i] tmp[i].if_from_product = dw_1.object.if_from_product[i] tmp[i].product_pro = dw_1.object.product_pro[i] for ll_col = 1 to ins_column_count j++ tmp_mx[j].ModleID = 0 tmp_mx[j].printid = i ls_dscrp = dw_1.Describe('mtrl'+string(ll_col)+'_t.tag') tmp_mx[j].mtrlid = long(ls_dscrp) tmp_mx[j].value = dw_1.GetItemDecimal(i, 'mtrl' + String(ll_col)) next next uo_bill.mxs = tmp uo_bill.mx_mxs = tmp_mx if uo_bill.savesubmit(ls_msg) <> 1 then MessageBox('错误', ls_msg) return end if this.Title = ins_oldTitle + '[' + uo_bill.ModleName + ']' end event event ue_save_bill_as();// DONE: 另存工作表 long oldid oldid = uo_bill.modleid uo_bill.modleid = 0 this.triggerevent('ue_save_bill') if uo_bill.modleid = 0 then uo_bill.modleid = oldid end if end event event ue_open_bill();// DONE: 打开工作表 Long arg_Modleid String ls_msg s_mtrldef_array S_INSCUST Long ll_col = 0, ls_j, chc, ll_row, ll_i Long ll_mtrlid String ll_mtrlcode String ll_mtrlname string ls_dscrp decimal ll_value IF NOT IsValid(w_bom_bill_ch) THEN Open(w_bom_bill_ch) //调用 s_cmpl_modle_ch s_choice s_choice = Message.PowerObjectParm //接受返回结构 if isnull(s_choice) then return if isnull(s_choice.modleid) then return if s_choice.modleid > 0 then arg_ModleID = s_choice.modleid IF uo_bill.GetINfo(arg_Modleid, ls_msg) <> 1 THEN MessageBox('', ls_msg) RETURN END IF this.title = ins_oldtitle + '[' + uo_bill.ModleName + ']' declare cur1 cursor for select DISTINCT u_cmpl_modleMx_Mx.mtrlid, u_mtrldef.mtrlcode, u_mtrldef.mtrlname from u_cmpl_modleMx_Mx inner JOIN u_mtrldef ON u_cmpl_modleMx_Mx.mtrlid = u_mtrldef.mtrlid Where (u_cmpl_modleMx_Mx.ModleID = :arg_Modleid); open cur1; fetch cur1 INTO :ll_mtrlid, :ll_mtrlcode, :ll_mtrlname; DO WHILE sqlca.SQLCode = 0 ll_col ++ S_INSCUST.mtrlid[ll_col] = ll_mtrlid S_INSCUST.mtrlcode[ll_col] = ll_mtrlcode S_INSCUST.mtrlname[ll_col] = ll_mtrlname fetch cur1 INTO :ll_mtrlid, :ll_mtrlcode, :ll_mtrlname; LOOP close cur1; dw_1.Reset() String ls_mod FOR ls_j = 8 TO 47 ls_mod = '#' + String(ls_j) + '.Visible = 0' ls_mod = dw_1.Modify(ls_mod) NEXT chc = 0 FOR ls_j = 1 TO UpperBound(S_INSCUST.mtrlid) IF S_INSCUST.mtrlid[ls_j] > 0 THEN chc ++ ls_mod = 'mtrl' + String(chc) + '.Visible = 1' ls_mod = dw_1.Modify(ls_mod) ls_mod = 'mtrl' + String(chc) + '_t.Text = ~''+String(S_INSCUST.mtrlname[ls_j])+'~'' ls_mod = dw_1.Modify(ls_mod) ls_mod = 'mtrl' + String(chc) + '_t.Tag = ~''+String(S_INSCUST.mtrlid[ls_j])+'~'' ls_mod = dw_1.Modify(ls_mod) ls_mod = 'mtrl' + String(chc) + '.Tag = ~''+String(S_INSCUST.mtrlcode[ls_j])+'~'' ls_mod = dw_1.Modify(ls_mod) END IF NEXT ins_column_count = chc FOR ls_j = 38 TO 47 ls_mod = '#' + String(ls_j) + '.Visible = 1' ls_mod = dw_1.Modify(ls_mod) NEXT FOR ll_i = 1 TO UpperBound(uo_bill.mxs) ll_row = dw_1.insertrow(0) dw_1.object.printid[ll_row] = uo_bill.mxs[ll_i].printid dw_1.object.parmname[ll_row] = uo_bill.mxs[ll_i].parmname dw_1.object.displayname[ll_row] = uo_bill.mxs[ll_i].displayname dw_1.object.defaultvalue[ll_row] = uo_bill.mxs[ll_i].defaultvalue dw_1.object.if_useformula[ll_row] = uo_bill.mxs[ll_i].if_useformula dw_1.object.formula[ll_row] = uo_bill.mxs[ll_i].formula dw_1.object.if_from_mtrl[ll_row] = uo_bill.mxs[ll_i].if_from_mtrl dw_1.object.mtrlid[ll_row] = uo_bill.mxs[ll_i].mtrlid dw_1.object.mtrl_pro[ll_row] = uo_bill.mxs[ll_i].mtrl_pro dw_1.object.if_from_product[ll_row] = uo_bill.mxs[ll_i].if_from_product dw_1.object.product_pro[ll_row] = uo_bill.mxs[ll_i].product_pro dw_1.object.wrkGrpid[ll_row] = uo_bill.mxs[ll_i].wrkGrpid dw_1.object.advancetime[ll_row] = uo_bill.mxs[ll_i].advancetime dw_1.object.dscrp[ll_row] = uo_bill.mxs[ll_i].dscrp dw_1.object.unit[ll_row] = uo_bill.mxs[ll_i].unit SELECT mtrlcode , mtrlname INTO :ll_mtrlcode, :ll_mtrlname FROM u_mtrldef WHERE mtrlid = :uo_bill.mxs[ll_i].mtrlid; if sqlca.sqlcode <> 0 then ll_mtrlcode = '' ll_mtrlname = '' dw_1.object.mtrlid[ll_row] = 0 end if dw_1.object.mtrlcode[ll_row] = ll_mtrlcode dw_1.object.mtrlname[ll_row] = ll_mtrlname for ll_col = 1 to ins_column_count ls_dscrp = dw_1.Describe('mtrl'+string(ll_col)+'_t.tag') ll_mtrlid = long(ls_dscrp) ll_value = 0 for ls_j = 1 to upperbound(uo_bill.mx_mxs) if uo_bill.mx_mxs[ls_j].printid = uo_bill.mxs[ll_i].printid & and uo_bill.mx_mxs[ls_j].mtrlid = ll_mtrlid then ll_value = uo_bill.mx_mxs[ls_j].value exit end if next dw_1.SetItem(ll_row, 'mtrl' + string(ll_col), ll_value) next NEXT end if end if end event event ue_pickmtrl(); IF NOT IsValid(W_mtrldef_edit) THEN s_edit_index_tran s_tranf8 //传递参数使用 s_tranf8.if_retrieve_all = FALSE //是否一次RETRIEVE所有行 s_tranf8.work_mode = 1 //0-单纯编辑模式 1-选择\编辑模式 s_tranf8.arg_pkid = 0 //目标定位PKID (备用) s_tranf8.arg_string_code = '' //查询列(物料编码)部分内容,用于初步筛选 s_tranf8.if_select_all = FALSE //多选 s_tranf8.b_long = 2 //选采购 s_tranf8.c_long = -1 s_tranf8.f_long = 2 Long chc = 1,ls_j IF dw_1.GetRow() > 0 THEN s_tranf8.arg_string_code = Trim(dw_1.Object.mtrlcode[dw_1.GetRow()]) OpenWithParm(W_mtrldef_edit,s_tranf8) //调用 s_mtrldef_array S_INSCUST S_INSCUST = Message.PowerObjectParm //接受返回结构 if UpperBound(S_INSCUST.mtrlid) > 0 then if S_INSCUST.mtrlid[1] > 0 then dw_1.object.mtrlid[dw_1.GetRow()] = S_INSCUST.mtrlid[1] dw_1.object.mtrlcode[dw_1.GetRow()] = S_INSCUST.mtrlcode[1] dw_1.object.mtrlname[dw_1.GetRow()] = S_INSCUST.mtrlname[1] dw_1.object.displayname[dw_1.GetRow()] = S_INSCUST.mtrlname[1] dw_1.object.unit[dw_1.GetRow()] = S_INSCUST.unit[1] end if end if end if end event event ue_addmx();long ll_row ll_row = dw_1.insertrow(0) dw_1.object.printid[ll_row] = ll_row dw_1.scrolltorow(ll_row) dw_1.setcolumn('mtrl1') dw_1.setfocus() end event event ue_delmx();if dw_1.GetRow() > 0 then dw_1.deleterow(dw_1.GetRow()) dw_1.setfocus() end if end event public function integer wf_build_bom (ref string arg_msg);Int rslt = 1 Long productid String productname Long ll_col Long ll_row Long ll_flag Long cnt = 0 Long ll_cnt = 0 Long ll_mtrlid String ll_pfcode String ll_pfgroup Long ll_SonMtrlid Long ll_ifreputate Long ll_ifover Decimal ll_updownrate Decimal ll_Sonscale Decimal ll_SonLoss Decimal ll_SonDECLosS Decimal ll_Sonahead String ll_dscrp Decimal ll_pfgroupqty String ll_pfgroupmode String ll_promode Long ll_printid Long ll_wrkgrpid String ll_status String ll_sonpfcode String ll_woodcode String ll_pcode Long ll_mtrlkind String ll_pfklmode Long ll_dipztype Decimal ll_scllloss Long ll_dytype Decimal ll_advancetime Decimal ll_sclldecloss Decimal ll_baseqty String ll_SonLossstr Decimal ll_buyarg String ls_mtrlmode Long li_sonpfflag Long li_ifpackpro Long li_ifpack Long ls_cr_rsl FOR ll_col = 1 To ins_column_count productid = Long(dw_1.Describe('mtrl' + String(ll_col) + '_t.tag')) IF productid <= 0 THEN rslt = 0 arg_msg = '非法产品唯一码' GOTO ext END IF SELECT flag INTO :ll_flag FROM u_mtrl_pf Where Mtrlid = :productid And pfcode = '[常规]'; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询物料清单状态失败,' + sqlca.SQLErrText GOTO ext END IF productname = dw_1.Describe('mtrl' + String(ll_col) + '_t.text') IF ll_flag = 1 THEN rslt = 0 arg_msg = '产品:' + productname +'物料清单已经审核' GOTO ext END IF DELETE From u_PrdPF Where Mtrlid = :productid And pfcode = '[常规]'; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '删除产品物料清单失败,' + sqlca.SQLErrText GOTO ext END IF SELECT ifpackpro INTO :li_ifpackpro FROM u_mtrldef Where Mtrlid = :productid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询物料是否全包件产品失败'+sqlca.SQLErrText GOTO ext END IF FOR ll_row = 1 To dw_1.RowCount() ll_Sonscale = dw_1.GetItemDecimal(ll_row, 'mtrl' + String(ll_col)) IF dw_1.Object.Mtrlid[ll_row] > 0 and ll_Sonscale <> 0 THEN ll_cnt ++ ll_mtrlid = productid ll_pfcode = '[常规]' ll_pfgroup = dw_1.Object.displayname[ll_row] ll_SonMtrlid = dw_1.Object.Mtrlid[ll_row] SELECT mtrlmode, mtrlkind INTO :ll_pfgroupmode, :ll_mtrlkind From u_mtrldef Where Mtrlid = :ll_SonMtrlid; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '查询物料属性失败,' + sqlca.SQLErrText GOTO ext END IF ll_ifreputate = 0 ll_ifover = 0 ll_updownrate = 0 ll_SonLoss = 0 ll_SonDECLosS = 0 ll_Sonahead = 1 ll_dscrp = dw_1.Object.dscrp[ll_row] ll_pfgroupqty = 0 ll_promode = 'B' ll_printid = ll_cnt ll_wrkgrpid = dw_1.Object.wrkGrpid[ll_row] ll_status = '' ll_sonpfcode = f_get_dft_pf(ll_SonMtrlid) ll_woodcode = '' ll_pcode = '' ll_pfklmode = '' ll_dipztype = 0 ll_scllloss = 0 ll_dytype = 0 ll_advancetime = dw_1.Object.advancetime[ll_row] ll_sclldecloss = 0 ll_baseqty = 1 ll_SonLossstr = '' ll_buyarg = 1 //==================================================================== // 合法性检测 //==================================================================== IF ll_Sonscale < 0 THEN rslt = 0 arg_msg = '第 '+String(ll_row)+' 行,不合理组成数量!在 '+productname+' ,请核对!' dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext END IF IF ll_SonLoss < 0 Or ll_SonLoss >= 1 THEN rslt = 0 arg_msg = '第 '+String(ll_row)+' 行,不合理损耗率!在 '+productname+' ,请核对!' dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext END IF IF ll_SonDECLosS < 0 THEN rslt = 0 arg_msg = '第 '+String(ll_row)+' 行,不合理附加损耗量!在 '+productname+' ,请核对!' dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext END IF IF ll_wrkgrpid = 0 THEN rslt = 0 arg_msg = '第 '+String(ll_row)+' 行,请先选择领用工组' dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext END IF IF ll_baseqty < 1 THEN rslt = 0 arg_msg = '第 '+String(ll_row)+' 行,基数必须大于1,请检查' dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext END IF IF ll_buyarg < 0 THEN rslt = 0 arg_msg = '第 '+String(ll_row)+' 行,采购参数不能小于0,请检查' dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext END IF SELECT count(*) INTO :cnt FROM u_mtrl_pf WHERE mtrlid = :ll_sonmtrlid And pfcode = :ll_sonpfcode; IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '第 '+String(ll_row)+' 行,查询部件物料,物料清单资料失败,可能资料不存在' dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext END IF IF cnt < 1 THEN rslt = 0 arg_msg = '第 '+String(ll_row)+' 行,部件物料,物料清单资料['+ll_sonpfcode+']不存在' dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext END IF IF cnt > 1 THEN rslt = 0 arg_msg = '第 '+String(ll_row)+' 行,部件物料,物料清单资料['+ll_sonpfcode+']重复' dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext END IF // IF sys_option_check_mtrl_pf = 1 THEN // SELECT flag INTO :li_sonpfflag // FROM u_mtrl_pf // WHERE mtrlid = :ll_sonmtrlid // And pfcode = :ll_sonpfcode; // IF sqlca.SQLCode <> 0 THEN // rslt = 0 // arg_msg = '第 '+String(ll_row)+' 行,查询部件物料,物料清单资料失败,可能资料不存在' // dw_1.ScrollToRow(ll_row) // dw_1.SetColumn('parmname') // dw_1.SetFocus() // GOTO ext // END IF // // IF li_sonpfflag = 0 THEN // rslt = 0 // arg_msg = '第 '+String(ll_row)+' 行,部件物料的物料清单没有审核,请检查' // dw_1.ScrollToRow(ll_row) // dw_1.SetColumn('parmname') // dw_1.SetFocus() // GOTO ext // END IF // END IF IF li_ifpackpro = 1 THEN SELECT ifpack INTO :li_ifpack FROM u_mtrldef Where Mtrlid = :ll_SonMtrlid; IF sqlca.SQLCode <> 0 THEN arg_msg = '第 '+String(ll_row)+' 行,查询部件物料是否属于包件失败'+sqlca.SQLErrText rslt = 0 dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext END IF IF li_ifpack = 0 THEN arg_msg = '第 '+String(ll_row)+' 行,全包件产品下级不能有非包件部件' rslt = 0 dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext END IF END IF //==================================================================== //检查有否环 //==================================================================== ls_cr_rsl = wf_checkrand(ll_SonMtrlid, productid) IF ls_cr_rsl = 1 THEN rslt = 0 arg_msg = '发现环!在第 '+String(ll_row)+' 行,请核对!' dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext ELSEIF ls_cr_rsl < 0 THEN arg_msg = '因为网络或其他原因导致查环操作失败!在第 '+String(ll_row)+' 行,请核对!' rslt = 0 dw_1.ScrollToRow(ll_row) dw_1.SetColumn('parmname') dw_1.SetFocus() GOTO ext END IF INSERT INTO u_PrdPF (mtrlid ,pfcode ,pfgroup ,SonMtrlid ,ifreputate ,ifover ,updownrate ,Sonscale ,SonLoss ,SonDECLosS ,Sonahead ,dscrp ,pfgroupqty ,pfgroupmode ,promode ,printid ,wrkgrpid ,status ,sonpfcode ,woodcode ,pcode ,mtrlkind ,pfklmode ,dipztype ,scllloss ,dytype ,advancetime ,sclldecloss ,baseqty ,SonLossstr ,buyarg) VALUES (:ll_mtrlid ,:ll_pfcode ,:ll_pfgroup ,:ll_SonMtrlid ,:ll_ifreputate ,:ll_ifover ,:ll_updownrate ,:ll_Sonscale ,:ll_SonLoss ,:ll_SonDECLosS ,:ll_Sonahead ,:ll_dscrp ,:ll_pfgroupqty ,:ll_pfgroupmode ,:ll_promode ,:ll_printid ,:ll_wrkgrpid ,:ll_status ,:ll_sonpfcode ,:ll_woodcode ,:ll_pcode ,:ll_mtrlkind ,:ll_pfklmode ,:ll_dipztype ,:ll_scllloss ,:ll_dytype ,:ll_advancetime ,:ll_sclldecloss ,:ll_baseqty ,:ll_SonLossstr ,:ll_buyarg); IF sqlca.SQLCode <> 0 THEN rslt = 0 arg_msg = '插入物料清单明细失败,' + sqlca.SQLErrText GOTO ext END IF END IF NEXT UPDATE u_mtrl_pf SET moddate = getdate() , modemp = :publ_operator Where Mtrlid = :productid; IF sqlca.SQLCode <> 0 THEN arg_msg = "因为网络或其他原因导致更新产品["+productname+"]物料构成修改时间>"+sqlca.SQLErrText rslt = 0 GOTO ext END IF NEXT ext: IF rslt = 0 THEN ROLLBACK; ELSEIF rslt = 1 THEN COMMIT; END IF RETURN rslt end function public function integer wf_checkrand (long checked_mtrlid, long obj_mtrlid);//wf_checkrand IF checked_mtrlid = obj_mtrlid THEN RETURN 1 Long ls_mtrlid Long rt_b,rt_s,count Long mtrlid[],ls_i DECLARE pf_cur CURSOR FOR SELECT u_PrdPF.SonMtrlid FROM u_PrdPF Where ( u_PrdPF.mtrlid = :checked_mtrlid ); OPEN pf_cur; count = 1 FETCH pf_cur INTO :mtrlid[count]; DO WHILE sqlca.SQLCode = 0 count++ FETCH pf_cur INTO :mtrlid[count]; LOOP count = count - 1 CLOSE pf_cur; FOR ls_i = 1 TO count rt_b = wf_checkrand(mtrlid[ls_i], obj_mtrlid) IF rt_b <> 0 THEN RETURN rt_b NEXT RETURN 0 //DO // //LOOP WHILE end function on w_bom_build_assist.create int iCurrent call super::create this.dw_1=create dw_1 this.cb_1=create cb_1 this.st_1=create st_1 this.cb_2=create cb_2 this.cb_edit=create cb_edit this.cb_3=create cb_3 this.cb_addmx=create cb_addmx this.cb_4=create cb_4 this.cb_sort=create cb_sort this.cb_6=create cb_6 this.cb_7=create cb_7 this.cb_5=create cb_5 this.ln_bar=create ln_bar this.ln_bar2=create ln_bar2 this.ln_1=create ln_1 this.ln_2=create ln_2 this.r_bar=create r_bar iCurrent=UpperBound(this.Control) this.Control[iCurrent+1]=this.dw_1 this.Control[iCurrent+2]=this.cb_1 this.Control[iCurrent+3]=this.st_1 this.Control[iCurrent+4]=this.cb_2 this.Control[iCurrent+5]=this.cb_edit this.Control[iCurrent+6]=this.cb_3 this.Control[iCurrent+7]=this.cb_addmx this.Control[iCurrent+8]=this.cb_4 this.Control[iCurrent+9]=this.cb_sort this.Control[iCurrent+10]=this.cb_6 this.Control[iCurrent+11]=this.cb_7 this.Control[iCurrent+12]=this.cb_5 this.Control[iCurrent+13]=this.ln_bar this.Control[iCurrent+14]=this.ln_bar2 this.Control[iCurrent+15]=this.ln_1 this.Control[iCurrent+16]=this.ln_2 this.Control[iCurrent+17]=this.r_bar end on on w_bom_build_assist.destroy call super::destroy destroy(this.dw_1) destroy(this.cb_1) destroy(this.st_1) destroy(this.cb_2) destroy(this.cb_edit) destroy(this.cb_3) destroy(this.cb_addmx) destroy(this.cb_4) destroy(this.cb_sort) destroy(this.cb_6) destroy(this.cb_7) destroy(this.cb_5) destroy(this.ln_bar) destroy(this.ln_bar2) destroy(this.ln_1) destroy(this.ln_2) destroy(this.r_bar) end on event open;call super::open;ins_oldtitle = This.Title uo_modle = Create uo_cmpl_modle uo_bill = Create uo_cmpl_bill DataWindowChild dw_wrkGrp if dw_1.GetChild('wrkgrpid', ref dw_wrkGrp) <> 1 then MessageBox('系统错误', '查询工组失败', stopsign!) cb_exit.postevent(clicked!) return end if dw_wrkGrp.SetTransObject(sqlca) dw_wrkGrp.retrieve() Long ls_j String ls_mod FOR ls_j = ins_first To (ins_first + 29) ls_mod = '#' + String(ls_j) + '.Visible = 0' ls_mod = dw_1.Modify(ls_mod) NEXT FOR ls_j = 1 To ins_last dw_1.SetTabOrder(ls_j, 10 * ls_j) NEXT end event event resize;call super::resize;if this.width < 3648 then this.width = 3648 if this.Height < 1996 then this.Height = 1996 ln_bar.EndX = THIS.Width ln_bar2.EndX = THIS.Width ln_1.EndX = THIS.Width ln_2.EndX = THIS.Width r_bar.Width = THIS.Width dw_1.height = this.height - 450 dw_1.width = this.width - 50 end event event close;call super::close;destroy uo_modle destroy uo_bill end event event ue_sort;call super::ue_sort; IF dw_1.AcceptText() <> 1 THEN RETURN dw_1.SetRedraw(False) dw_1.Sort() Long ll_row FOR ll_row = 1 To dw_1.RowCount() dw_1.Object.printid[ll_row] = ll_row NEXT dw_1.SetRedraw(True) end event event closequery;call super::closequery;IF MessageBox ("IF","将丢失未保存的修改,是否继续?",Question!,YesNo! ) = 2 THEN RETURN 1 end event type cb_func from w_publ_base`cb_func within w_bom_build_assist boolean visible = false integer x = 1166 end type type cb_exit from w_publ_base`cb_exit within w_bom_build_assist integer x = 2318 integer width = 151 integer height = 164 integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type type dw_1 from u_dw_rbtnfilter within w_bom_build_assist integer y = 296 integer width = 4087 integer height = 1920 integer taborder = 20 boolean bringtotop = true string dataobject = "dw_bom_mtrl30" boolean hscrollbar = true boolean vscrollbar = true boolean setcolumn_visible_use = false boolean autosave_filter_use = false boolean autosave_sort_use = false boolean autosave_setlayout_use = false boolean autosave_columnvisible_use = false end type event dwnkey;call super::dwnkey; //IF KeyDown(keydownarrow!) THEN // Long li_row // IF dw_1.GetRow() <> dw_1.RowCount() THEN // dw_1.ScrollToRow(dw_1.GetRow() + 1) // END IF //ELSEIF KeyDown(keyuparrow!) THEN // IF dw_1.GetRow() <> 1 THEN // dw_1.ScrollToRow(dw_1.GetRow() - 1) // END IF //ELSE long child_row long ls_mtrlid string ls_mtrlcode, ls_mtrlname, ls_unit long ls_storageid s_mtrldef_array arg_s_mtrldef IF KeyDown(keyenter!) And Not KeyDown(keycontrol!) And Not KeyDown(keyshift!) THEN IF dw_1.AcceptText() <> 1 THEN RETURN 1 IF dw_1.GetColumnName() = 'mtrlcode' THEN child_row = dw_1.GetRow() ls_mtrlcode = dw_1.Object.mtrlcode[child_row] ls_storageid = -1 IF Trim(ls_mtrlcode) = '' THEN dw_1.Object.mtrlid[child_row] = 0 dw_1.Object.mtrlcode[child_row] = '' dw_1.Object.mtrlname[child_row] = '' dw_1.Object.unit[child_row] = '' ELSE IF f_find_mtrl(ls_mtrlcode,ls_storageid,arg_s_mtrldef) = 0 THEN Parent.TriggerEvent('ue_f8') RETURN 1 ELSE ls_mtrlid = arg_s_mtrldef.mtrlid[1] ls_mtrlcode = arg_s_mtrldef.mtrlcode[1] ls_mtrlname = arg_s_mtrldef.mtrlname[1] ls_unit = arg_s_mtrldef.unit[1] END IF dw_1.Object.mtrlid[child_row] = ls_mtrlid dw_1.Object.mtrlcode[child_row] = ls_mtrlcode dw_1.Object.mtrlname[child_row] = ls_mtrlname dw_1.Object.displayname[child_row] = ls_mtrlname dw_1.Object.unit[child_row] = ls_unit END IF IF Key = keyenter! THEN keybd_event ( 9, 0, 0 , 0 ) // 按下tab keybd_event ( 9, 0, 2, 0 ) // 释放tab RETURN 1 END IF ELSEIF dw_1.GetColumnName( ) = 'advancetime' And dw_1.GetRow() = dw_1.RowCount() THEN parent.triggerevent('ue_addmx') RETURN 1 ELSE IF Key = keyenter! THEN keybd_event ( 9, 0, 0 , 0 ) // 按下tab keybd_event ( 9, 0, 2, 0 ) // 释放tab RETURN 1 END IF END IF END IF //END IF end event event itemchanged;call super::itemchanged;if dwo.name = 'if_useformula' OR dwo.name = 'if_from_mtrl' OR dwo.name = 'if_from_product' then if trim(data) = '1' then if dwo.name <> 'if_useformula' then this.object.if_useformula[row] = 0 end if if dwo.name <> 'if_from_mtrl' then this.object.if_from_mtrl[row] = 0 end if if dwo.name <> 'if_from_product' then this.object.if_from_product[row] = 0 end if end if end if if dwo.name = 'parmname' then if this.object.displayname[row] = this.object.parmname[row] then this.object.displayname[row] = data end if end if end event event doubleclicked;call super::doubleclicked; if this.accepttext() <> 1 then return if dwo.name = 'formula' then s_cmpl_parm s_parm long i for i = 1 to row - 1 s_parm.parmname[i] = this.object.parmname[i] s_parm.displayname[i] = this.object.displayname[i] s_parm.parmvalue[i] = this.object.defaultvalue[i] next s_parm.oldformula = this.object.formula[row] openwithparm(w_cmpl_formula_edit, s_parm) string ls_ret ls_ret = message.StringParm if ls_ret <> 'NULL' then this.object.formula[row] = ls_ret end if end if if dwo.name = 'mtrlcode' then // DONE: 选择物料 parent.triggerevent('ue_pickmtrl') end if end event type cb_1 from uo_imflatbutton within w_bom_build_assist integer width = 274 integer height = 164 integer taborder = 30 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;parent.triggerevent('ue_f8') end event type st_1 from statictext within w_bom_build_assist integer x = 23 integer y = 196 integer width = 1024 integer height = 72 boolean bringtotop = true integer textsize = -12 integer weight = 400 fontcharset fontcharset = gb2312charset! fontpitch fontpitch = variable! string facename = "宋体" long textcolor = 33554432 long backcolor = 134217739 string text = "模板名:" boolean focusrectangle = false end type type cb_2 from uo_imflatbutton within w_bom_build_assist integer x = 768 integer width = 151 integer height = 164 integer taborder = 30 boolean bringtotop = true string text = "计算" string normalpicname = "xls_efdppict.BMP" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;parent.triggerevent('ue_f10') end event type cb_edit from uo_imflatbutton within w_bom_build_assist integer x = 1303 integer width = 192 integer height = 164 integer taborder = 40 boolean bringtotop = true string text = "保存" string normalpicname = "Save.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;// DONE: 保存 IF dw_1.AcceptText() <> 1 THEN RETURN END IF IF dw_1.RowCount() <= 0 THEN MessageBox('提示', '没有内容不能保存') RETURN END IF s_inputbox s_parm String ls_return s_parm.Title = '输入工作表名称' s_parm.old_text = uo_bill.modlename OpenWithParm(w_inputbox, s_parm) ls_return = Message.StringParm IF ls_return = '' Or IsNull(ls_return) THEN RETURN Long ll_modleid String ll_modlename Long ll_cnt string ls_msg SELECT count(0) INTO :ll_cnt FROM u_cmpl_modle WHERE Modlename = :ls_return And modletype = 3; if sqlca.sqlcode <> 0 then MessageBox('系统错误', '数据库连接失败,' + sqlca.sqlerrtext, stopsign!) return end if if ll_cnt = 0 then // 新建 uo_bill.ModleID = 0 if uo_bill.Newbegin(ls_msg) <> 1 then MessageBox('系统错误', ls_msg, stopsign!) return end if uo_bill.modlename = ls_return else IF MessageBox ("IF","将覆盖同名工作表,是否继续?",Question!,YesNo! ) = 2 THEN RETURN SELECT modleid, modlename INTO :ll_modleid, :ll_modlename FROM u_cmpl_modle WHERE Modlename = :ls_return And modletype = 3; if sqlca.sqlcode <> 0 then MessageBox('系统错误', '数据库连接失败,' + sqlca.sqlerrtext, stopsign!) return end if uo_bill.modleid = ll_modleid uo_bill.modlename = ll_modlename if uo_bill.updatebegin(uo_bill.modleid, ls_msg) <> 1 then MessageBox('系统错误', ls_msg, stopsign!) return end if end if Long i uo_bill.modletype = 3 uo_bill.orgModleID = 0 s_cmpl_modlemx tmp[] s_cmpl_modlemx_mx tmp_mx[] Long j = 0, ll_col = 0 String ls_dscrp FOR i = 1 To dw_1.RowCount() dw_1.Object.printid[i] = i tmp[i].ModleID = 0 tmp[i].printid = i tmp[i].parmName = dw_1.Object.parmName[i] tmp[i].DisplayName = dw_1.Object.DisplayName[i] tmp[i].defaultValue = dw_1.object.defaultvalue[i] tmp[i].if_useformula = dw_1.Object.if_useformula[i] tmp[i].formula = dw_1.Object.formula[i] tmp[i].if_from_mtrl = dw_1.Object.if_from_mtrl[i] tmp[i].mtrlid = dw_1.Object.mtrlid[i] tmp[i].mtrl_pro = dw_1.Object.mtrl_pro[i] tmp[i].if_from_product = dw_1.Object.if_from_product[i] tmp[i].product_pro = dw_1.Object.product_pro[i] tmp[i].wrkGrpid = dw_1.object.wrkGrpid[i] tmp[i].advancetime = dw_1.object.advancetime[i] tmp[i].dscrp = dw_1.object.dscrp[i] tmp[i].unit = dw_1.object.unit[i] FOR ll_col = 1 To ins_column_count j++ tmp_mx[j].ModleID = 0 tmp_mx[j].printid = i ls_dscrp = dw_1.Describe('mtrl'+String(ll_col)+'_t.tag') tmp_mx[j].mtrlid = Long(ls_dscrp) tmp_mx[j].Value = dw_1.GetItemDecimal(i, 'mtrl' + String(ll_col)) NEXT NEXT uo_bill.mxs = tmp uo_bill.mx_mxs = tmp_mx IF uo_bill.savesubmit(ls_msg) <> 1 THEN MessageBox('错误', ls_msg) RETURN END IF Parent.Title = ins_oldTitle + '[' + uo_bill.modlename + ']' MessageBox('提示', '保存成功') end event type cb_3 from uo_imflatbutton within w_bom_build_assist integer x = 274 integer width = 494 integer height = 164 integer taborder = 40 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;parent.triggerevent('ue_f9') end event type cb_addmx from uo_imflatbutton within w_bom_build_assist integer x = 1687 integer width = 151 integer height = 164 integer taborder = 50 boolean bringtotop = true string text = "增行" string normalpicname = "mx1.BMP" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;parent.triggerevent('ue_addmx') end event type cb_4 from uo_imflatbutton within w_bom_build_assist integer x = 1838 integer width = 151 integer height = 164 integer taborder = 60 boolean bringtotop = true string text = "删行" string normalpicname = "mx2.BMP" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;parent.triggerevent('ue_delmx') end event type cb_sort from uo_imflatbutton within w_bom_build_assist integer x = 1989 integer width = 165 integer height = 164 integer taborder = 50 boolean bringtotop = true string text = "重排" string normalpicname = "p2.BMP" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;parent.triggerevent('ue_sort') end event type cb_6 from uo_imflatbutton within w_bom_build_assist integer x = 2153 integer width = 165 integer height = 164 integer taborder = 60 boolean bringtotop = true string text = "重置" string normalpicname = "Undo.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;// DONE: 打开工作表 Long arg_Modleid String ls_msg s_mtrldef_array S_INSCUST Long ll_col = 0, ls_j, chc, ll_row, ll_i Long ll_mtrlid String ll_mtrlcode String ll_mtrlname string ls_dscrp decimal ll_value IF MessageBox ("IF","重置将丢失未保存的修改,是否继续?",Question!,YesNo! ) = 2 THEN RETURN arg_ModleID = uo_bill.modleid if arg_ModleID = 0 then dw_1.Reset() return end if IF uo_bill.GetINfo(arg_Modleid, ls_msg) <> 1 THEN MessageBox('', ls_msg) RETURN END IF parent.title = ins_oldtitle + '[' + uo_bill.ModleName + ']' declare cur1 cursor for select DISTINCT u_cmpl_modleMx_Mx.mtrlid, u_mtrldef.mtrlcode, u_mtrldef.mtrlname from u_cmpl_modleMx_Mx inner JOIN u_mtrldef ON u_cmpl_modleMx_Mx.mtrlid = u_mtrldef.mtrlid Where (u_cmpl_modleMx_Mx.ModleID = :arg_Modleid); open cur1; fetch cur1 INTO :ll_mtrlid, :ll_mtrlcode, :ll_mtrlname; DO WHILE sqlca.SQLCode = 0 ll_col ++ S_INSCUST.mtrlid[ll_col] = ll_mtrlid S_INSCUST.mtrlcode[ll_col] = ll_mtrlcode S_INSCUST.mtrlname[ll_col] = ll_mtrlname fetch cur1 INTO :ll_mtrlid, :ll_mtrlcode, :ll_mtrlname; LOOP close cur1; dw_1.Reset() String ls_mod FOR ls_j = ins_first TO ins_last ls_mod = '#' + String(ls_j) + '.Visible = 0' ls_mod = dw_1.Modify(ls_mod) NEXT chc = 0 FOR ls_j = 1 TO UpperBound(S_INSCUST.mtrlid) IF S_INSCUST.mtrlid[ls_j] > 0 THEN chc ++ ls_mod = 'mtrl' + String(chc) + '.Visible = 1' ls_mod = dw_1.Modify(ls_mod) ls_mod = 'mtrl' + String(chc) + '_t.Text = ~''+String(S_INSCUST.mtrlname[ls_j])+'~'' ls_mod = dw_1.Modify(ls_mod) ls_mod = 'mtrl' + String(chc) + '_t.Tag = ~''+String(S_INSCUST.mtrlid[ls_j])+'~'' ls_mod = dw_1.Modify(ls_mod) ls_mod = 'mtrl' + String(chc) + '.Tag = ~''+String(S_INSCUST.mtrlcode[ls_j])+'~'' ls_mod = dw_1.Modify(ls_mod) END IF NEXT ins_column_count = chc FOR ls_j = ins_first + 30 TO ins_last ls_mod = '#' + String(ls_j) + '.Visible = 1' ls_mod = dw_1.Modify(ls_mod) NEXT FOR ll_i = 1 TO UpperBound(uo_bill.mxs) ll_row = dw_1.insertrow(0) dw_1.object.printid[ll_row] = uo_bill.mxs[ll_i].printid dw_1.object.parmname[ll_row] = uo_bill.mxs[ll_i].parmname dw_1.object.displayname[ll_row] = uo_bill.mxs[ll_i].displayname dw_1.object.defaultvalue[ll_row] = uo_bill.mxs[ll_i].defaultvalue dw_1.object.if_useformula[ll_row] = uo_bill.mxs[ll_i].if_useformula dw_1.object.formula[ll_row] = uo_bill.mxs[ll_i].formula dw_1.object.if_from_mtrl[ll_row] = uo_bill.mxs[ll_i].if_from_mtrl dw_1.object.mtrlid[ll_row] = uo_bill.mxs[ll_i].mtrlid dw_1.object.mtrl_pro[ll_row] = uo_bill.mxs[ll_i].mtrl_pro dw_1.object.if_from_product[ll_row] = uo_bill.mxs[ll_i].if_from_product dw_1.object.product_pro[ll_row] = uo_bill.mxs[ll_i].product_pro dw_1.object.wrkGrpid[ll_row] = uo_bill.mxs[ll_i].wrkGrpid dw_1.object.advancetime[ll_row] = uo_bill.mxs[ll_i].advancetime dw_1.object.dscrp[ll_row] = uo_bill.mxs[ll_i].dscrp dw_1.object.unit[ll_row] = uo_bill.mxs[ll_i].unit SELECT mtrlcode , mtrlname INTO :ll_mtrlcode, :ll_mtrlname FROM u_mtrldef WHERE mtrlid = :uo_bill.mxs[ll_i].mtrlid; if sqlca.sqlcode <> 0 then ll_mtrlcode = '' ll_mtrlname = '' dw_1.object.mtrlid[ll_row] = 0 end if dw_1.object.mtrlcode[ll_row] = ll_mtrlcode dw_1.object.mtrlname[ll_row] = ll_mtrlname for ll_col = 1 to ins_column_count ls_dscrp = dw_1.Describe('mtrl'+string(ll_col)+'_t.tag') ll_mtrlid = long(ls_dscrp) ll_value = 0 for ls_j = 1 to upperbound(uo_bill.mx_mxs) if uo_bill.mx_mxs[ls_j].printid = uo_bill.mxs[ll_i].printid & and uo_bill.mx_mxs[ls_j].mtrlid = ll_mtrlid then ll_value = uo_bill.mx_mxs[ls_j].value exit end if next dw_1.SetItem(ll_row, 'mtrl' + string(ll_col), ll_value) next NEXT end event type cb_7 from uo_imflatbutton within w_bom_build_assist integer x = 919 integer width = 384 integer height = 164 integer taborder = 30 boolean bringtotop = true string text = "生成物料清单" string normalpicname = "update.BMP" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;// DONE: 生成物料清单 if dw_1.acceptText() <> 1 then return if ins_column_count <= 0 then MessageBox('提示', '请先选择产品') return end if if dw_1.RowCount() <= 0 then MessageBox('提示', '没有内容,不能生成物料清单') return end if IF MessageBox ("IF","生成物料清单,将删除旧的物料清单,是否继续?",Question!,YesNo! ) = 2 THEN RETURN string ls_msg if wf_build_bom(ls_msg) <> 1 then MessageBox('错误', ls_msg) return end if MessageBox('提示', '物料清单保存成功') end event type cb_5 from uo_imflatbutton within w_bom_build_assist integer x = 1495 integer width = 192 integer height = 164 integer taborder = 50 boolean bringtotop = true string text = "打开" string normalpicname = "open.bmp" integer picsize = 16 toolbaralignment pic_align = alignattop! boolean border = false end type event clicked;call super::clicked;// DONE: 打开 parent.triggerevent('ue_open_bill') end event type ln_bar from line within w_bom_build_assist long linecolor = 268435456 integer linethickness = 4 integer beginy = 172 integer endx = 3200 integer endy = 172 end type type ln_bar2 from line within w_bom_build_assist long linecolor = 16777215 integer linethickness = 4 integer beginx = 9 integer beginy = 176 integer endx = 3273 integer endy = 176 end type type ln_1 from line within w_bom_build_assist long linecolor = 268435456 integer linethickness = 4 integer beginy = 284 integer endx = 3250 integer endy = 284 end type type ln_2 from line within w_bom_build_assist long linecolor = 16777215 integer linethickness = 4 integer beginy = 288 integer endx = 3282 integer endy = 288 end type type r_bar from rectangle within w_bom_build_assist long linecolor = 16777215 integer linethickness = 4 long fillcolor = 1073741824 integer x = 2249 integer y = 40 integer width = 87 integer height = 68 end type event constructor;this.fillcolor = 14215660 this.linecolor = 14215660 this.x = -1 this.y = -1 this.height = ln_bar.beginy - 5 end event