做一个供料退货的页面。除crud操作外,还需选择合同,通过新增/保存/退货/删除的方法结合完成供料退货。
一、设计页面
打开系统退货页面(图1-1),点击合同号按钮,会有一个合同查询选择的弹框(图1-2),查询并选择一个合同且仅能选择一个,完成之后页面就会出现所选合同号。
![](https://i-blog.csdnimg.cn/direct/47312790efe644bd9d07c90d2b689f77.png)
![](https://i-blog.csdnimg.cn/direct/e032e4817be342ff9d619053b0402016.png)
二、画面信息注册维护
前台:
到EPESOBJ中注册前台画面,如图2-1所示。注意,下列按钮的信息需要单独注册,不随复制新增而保留。
![](https://i-blog.csdnimg.cn/direct/09530fea33014f7c85d34ad6bdc134f2.png)
后台:
在EPEA01中,注册后端文件,如图2-2所示。
![](https://i-blog.csdnimg.cn/direct/3bd27a1b1eab4fc39c8622100615e8c3.png)
参数信息:
因为有子母画面,所以要在EPESPARA中配置画面参数信息,如图2-3所示。
![](https://i-blog.csdnimg.cn/direct/34e857f3cc5140b19ce529bd0c5e56e0.png)
三、代码详情
前台:
1)YMSRLG09GL 主页面
private void FormYMSRLG09GL_EF_START_FORM_BY_EP(object sender, EF.EF_Args i_args)
{ //对应EPESPARA
this.table_name = ("" != i_args.GetCallParamsByName("TABLE_NAME").Trim() ? i_args.GetCallParamsByName("TABLE_NAME").Trim() : "");
this.eped54_name = ("" != i_args.GetCallParamsByName("EPED54_NAME").Trim() ? i_args.GetCallParamsByName("EPED54_NAME").Trim() : "");
this.stock_type = ("" != i_args.GetCallParamsByName("STOCK_TYPE").Trim() ? i_args.GetCallParamsByName("STOCK_TYPE").Trim() : "");
this.stock_type1 = ("" != i_args.GetCallParamsByName("STOCK_TYPE1").Trim() ? i_args.GetCallParamsByName("STOCK_TYPE1").Trim() : "");
this.pop_table_name = ("" != i_args.GetCallParamsByName("POP_TABLE_NAME").Trim() ? i_args.GetCallParamsByName("POP_TABLE_NAME").Trim() : "");
this.mat_kind = ("" != i_args.GetCallParamsByName("MAT_KIND").Trim() ? i_args.GetCallParamsByName("MAT_KIND").Trim() : "");
this.in_stock_mode = ("" != i_args.GetCallParamsByName("IN_STOCK_MODE").Trim() ? i_args.GetCallParamsByName("IN_STOCK_MODE").Trim() : "");
}
#region Load事件
private void FormYMSRLG09GL_Load(object sender, EventArgs e)
{
String sqlStr = "";
EI.EIInfo outBlock;
curr_part_name = this.ef_args.formPartition;
EFX.EFCGrid.InitMultiGridColumn(new EF.EFDevGrid[] { this.efDevGrid1 }, new string[] { eped54_name }, this.ef_args.formPartition);
YMUtility.DEV_Init_grid2(efDevGrid1, "1");
this.efDevGrid1.ShowSelectionColumn = true;
this.efDevGrid1.ShowAddCopyRowButton = true;
EFX.EFCGrid.GetEFCGridBase(this.efDevGrid1).TitleEditEnableColor = Color.Red;
EFX.EFCGrid.GetEFCGridBase(this.efDevGrid1).TitleEditEnableFont = new System.Drawing.Font(this.Font.FontFamily, this.Font.Size, System.Drawing.FontStyle.Bold);
#region 材料状态
//维护材料下拉信息
sqlStr = "SELECT CODE,CODE_DESC_1_CONTENT FROM TEP0002 WHERE CODE_CLASS ='YMCTLG'";
outBlock = EF.Utility.ExecQueryPart(curr_part_name, sqlStr);
if (outBlock.GetSys().flag == 0 && outBlock.Tables[0].Rows.Count > 0)
{
this.efDevLookUpEdit1.Properties.DataSource = outBlock.Tables[0];
BE2.Common.Utility.SetLookUpEditProperty(this.efDevLookUpEdit1, outBlock.Tables[0], "CODE_DESC_1_CONTENT", "CODE", true);
}
#endregion
this.lb_choose_txt.Text = "当前选中0支,共计0吨。";
}
#endregion
#region F2查询事件
private void FormYMSRLG09GL_EF_DO_F2(object sender, EF.EF_Args e)
{
currentPage = 1;
query_data(0, this.efDevGrid1.PageSize);
}
#endregion
#region F3新增
//formC
private void FormYMSRLG09GL_EF_DO_F3(object sender, EF.EF_Args e)
{
if (this.sale_order_sub_no_I.Text.Trim() == "")
{
EF.EFMessageBox.Show("请选择合同。", EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.ef_args.buttonStatusHold = true;
return;
}
//从库存选择材料退货
if (mat_kind == "TR")
{
EF.EF_Args.common_parameter_1 = this.sale_order_sub_no_I.Text;
EF.EF_Args.common_parameter_2 = this.stock_type;
EF.EF_Args.common_parameter_3 = this.mat_kind;
EF.EF_Args.common_parameter_4 = this.stock_type1;
/*
* 不修改
*/
PopFormYMSRLG09GLC popformymsrlg09glc = new PopFormYMSRLG09GLC();
popformymsrlg09glc.ShowDialog();
if (EF.EF_Args.common_object_1 == null) return;
DataRow[] dr = (DataRow[])EF.EF_Args.common_object_1;
EF.EF_Args.common_object_1 = null;
string v_sale_order_sub_no = sale_order_sub_no_I.Text;
//string v_supplier_code = "";
//string v_supplier_name = "";
string v_mtrl_no = "";
string v_mtrl_text = "";
string v_prod_code = "";
string v_prod_cname = "";
double v_ord_spec1 = 0;
//合同表
string sql_supplier = "select t.* from tqmtolg01 t where t.sale_order_sub_no = '" + v_sale_order_sub_no + "'";
EI.EIInfo outBlock = EF.Utility.ExecQuery(sql_supplier);
if (outBlock.GetSys().flag == 0 && outBlock.Tables[0].Rows.Count > 0)
{
//v_supplier_code = outBlock.Tables[0].Rows[0]["SUPPLIER_CODE"].ToString();
//v_supplier_name = outBlock.Tables[0].Rows[0]["SUPPLIER_NAME"].ToString();
v_mtrl_no = outBlock.Tables[0].Rows[0]["MTRL_NO"].ToString();
v_mtrl_text = outBlock.Tables[0].Rows[0]["MTRL_TEXT"].ToString();
v_prod_code = outBlock.Tables[0].Rows[0]["PROD_CODE"].ToString();
v_prod_cname = outBlock.Tables[0].Rows[0]["PROD_CNAME"].ToString();
v_ord_spec1 = Convert.ToDouble(outBlock.Tables[0].Rows[0]["ORD_SPEC1"].ToString());
}
for (int i = 0; i < dr.Length; i++)
{
gridView1.AddNewRow();
//赋初始值
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["COMPANY_CODE"] = dr[i]["COMPANY_CODE"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["COMPANY_CNAME"] = dr[i]["COMPANY_CNAME"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["MAT_NO"] = dr[i]["MAT_NO"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["HEAT_NO"] = dr[i]["HEAT_NO"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["MAT_SPEC1"] = dr[i]["MAT_SPEC1"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["MAT_SPEC2"] = dr[i]["MAT_SPEC2"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["MAT_SPEC3"] = dr[i]["MAT_SPEC3"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["MAT_WT"] = dr[i]["MAT_WT"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["MAT_NUM"] = dr[i]["MAT_NUM"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["MAT_QTY"] = dr[i]["MAT_QTY"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["SG_SIGN"] = dr[i]["SG_SIGN"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["PROD_CODE"] = dr[i]["PROD_CODE"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["PROD_CNAME"] = dr[i]["PROD_CNAME"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["MTRL_NO"] = dr[i]["MTRL_NO"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["MTRL_TEXT"] = dr[i]["MTRL_TEXT"];
//this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["SUPPLIER_CODE"] = v_supplier_code;
//this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["SUPPLIER_NAME"] = v_supplier_name;
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["MAT_SPEC_DESC"] = dr[i]["MAT_SPEC_DESC"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["STOCK_NO"] = dr[i]["STOCK_NO"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["PROD_CLASS_CODE"] = dr[i]["PROD_CLASS_CODE"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["MAT_KIND"] = dr[i]["MAT_KIND"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["COME_PROC_FLAG"] = dr[i]["COME_PROC_FLAG"];
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["SALE_ORDER_SUB_NO"] = this.sale_order_sub_no_I.Text.Trim();
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["IN_STOCK_MODE"] = in_stock_mode;
this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["QTY_UNIT_CODE"] = dr[i]["QTY_UNIT_CODE"];
//this.gridView1.GetDataRow(this.gridView1.FocusedRowHandle)["SALE_ORDER_SUB_NO"] = dr[i]["SALE_ORDER_SUB_NO"];
}
this.gridView1.FocusedRowHandle = this.gridView1.RowCount - 1;
this.gridView1.BestFitColumns();//调整列宽
}
}
#endregion
#region F4保存
//sav
private void FormYMSRLG09GL_EF_DO_F4(object sender, EF.EF_Args e)
{
if (this.efDevGrid1.GetSelectedDataRow().Rows.Count <= 0)
{
EF.EFMessageBox.Show("请选择可以操作的记录。", EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.ef_args.buttonStatusHold = true;
return;
}
EI.EIInfo inblock = new EI.EIInfo();
inblock.Tables[0].Merge(efDevGrid1.GetSelectedDataRow());
inblock.Tables.Add();
inblock.Tables[1].Columns.Add("TABLE_NAME");
inblock.Tables[1].Columns.Add("MAT_KIND");
inblock.Tables[1].Rows.Add();
inblock.Tables[1].Rows[0]["TABLE_NAME"] = table_name;
inblock.Tables[1].Rows[0]["MAT_KIND"] = mat_kind;
EI.EIInfo outInfo = EI.EITuxedo.CallService("ymsrlg09gl_sav", inblock);
EI.EIInfo.eiinfo_sys s = outInfo.GetSys(); //获取返回信息s
//设置返回信息
if (s.flag == 0)
{
currentPage = 1;
query_data(0, this.efDevGrid1.PageSize);
this.EFMsgInfo = string.Format("保存成功!");
}
else
{
this.EFSysInfo = s; //获取异常信息
EF.EFMessageBox.Show(s.msg, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
#endregion
#region F5退货
//ct
private void FormYMSRLG09GL_EF_DO_F5(object sender, EF.EF_Args e)
{
if (this.efDevGrid1.GetSelectedDataRow().Rows.Count <= 0)
{
EF.EFMessageBox.Show("请选择可以操作的记录。", EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.ef_args.buttonStatusHold = true;
return;
}
EI.EIInfo inblock = new EI.EIInfo();
inblock.Tables[0].Merge(efDevGrid1.GetSelectedDataRow());
//压入子画面调用参数
inblock.Tables.Add();
inblock.Tables[1].Columns.Add("TABLE_NAME");
inblock.Tables[1].Columns.Add("MAT_KIND");
inblock.Tables[1].Columns.Add("STOCK_TYPE");
inblock.Tables[1].Columns.Add("IN_STOCK_MODE");
inblock.Tables[1].Rows.Add();
inblock.Tables[1].Rows[0]["TABLE_NAME"] = table_name;
inblock.Tables[1].Rows[0]["MAT_KIND"] = mat_kind;
inblock.Tables[1].Rows[0]["STOCK_TYPE"] = stock_type;
inblock.Tables[1].Rows[0]["IN_STOCK_MODE"] = in_stock_mode;
EI.EIInfo outInfo = EI.EITuxedo.CallService("ymsrlg09gl_ct", inblock);
EI.EIInfo.eiinfo_sys s = outInfo.GetSys(); //获取返回信息s
//设置返回信息
if (s.flag == 0)
{
currentPage = 1;
query_data(0, this.efDevGrid1.PageSize);
this.EFMsgInfo = string.Format("退货成功!");
}
else
{
this.EFSysInfo = s; //获取异常信息
EF.EFMessageBox.Show(s.msg, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
#endregion
#region 查询事件
//inq
private void query_data(int recordFrom, int pageSize)
{
try
{
EI.EIInfo inBlock = new EI.EIInfo();
inBlock.Tables[0].Columns.Add("MAT_NO");
inBlock.Tables[0].Columns.Add("ORIGIN_HEAT_NO");
inBlock.Tables[0].Columns.Add("SALE_ORDER_SUB_NO");
inBlock.Tables[0].Columns.Add("STOCK_TYPE");
inBlock.Tables[0].Columns.Add("MAT_STATUS");
inBlock.Tables[0].Columns.Add("MAT_KIND");
inBlock.Tables[0].Rows.Add();
inBlock.Tables[0].Rows[0]["MAT_NO"] = this.mat_no_Q.Text.Trim();
inBlock.Tables[0].Rows[0]["ORIGIN_HEAT_NO"] = this.pono_no_Q.Text.Trim();
inBlock.Tables[0].Rows[0]["SALE_ORDER_SUB_NO"] = this.purcOrderCode_efDevTextEdit.Text.Trim();
inBlock.Tables[0].Rows[0]["STOCK_TYPE"] = stock_type;
inBlock.Tables[0].Rows[0]["MAT_STATUS"] = (this.efDevLookUpEdit1.EditValue == null || this.efDevLookUpEdit1.EditValue.ToString().Trim() == "" ? " " : this.efDevLookUpEdit1.EditValue.ToString().Trim());
inBlock.Tables[0].Rows[0]["MAT_KIND"] = mat_kind;
//分页信息
EF.DSUtility.PageInfoDataTable pageInfo = new EF.DSUtility.PageInfoDataTable();
pageInfo.AddPageInfoRow(recordFrom, pageSize);
inBlock.Tables.Add("PageInfo");
inBlock.Tables["PageInfo"].Merge(pageInfo);
//调用后台
EI.EIInfo outBlock = EI.EITuxedo.CallService("ymsrlg09gl_inq", inBlock);
//设置返回信息
if (outBlock.sys_info.flag != 0)
{
this.EFMsgInfo = outBlock.sys_info.msg;
EF.EFMessageBox.Show(outBlock.sys_info.msg, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
//将信息压入指定的GRID,
EF.Utility.SetCustomGridValue(efDevGrid1, outBlock, false);
//设置分页显示信息
YMUtility.DEV_grid_RecordCountMessage(efDevGrid1, currentPage, outBlock);
//列宽自动调整。
this.gridView1.BestFitColumns();
this.EFMsgInfo = string.Format("查询到[{0}]条记录。", outBlock.Tables[0].Rows.Count);
}
}
catch (Exception err)
{
EF.EFMessageBox.Show(err.Message, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.EFArgs.buttonStatusHold = true;
return;
}
}
#endregion
#region DevGrid事件
private void efDevGrid1_EF_GridBar_First_Event(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
{
try
{
if (currentPage == 1)
{
this.EFMsgInfo = "已经是第一页。";
return;
}
currentPage = 1;
//查询
query_data((currentPage - 1) * this.efDevGrid1.PageSize, this.efDevGrid1.PageSize);
}
catch (Exception ex)
{
EF.EFMessageBox.Show(ex.Message, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void efDevGrid1_EF_GridBar_Last_Event(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
{
try
{
//如果当前页不等于总页数 则查询
if (currentPage != totalPageCount)
{
//设置当前页
currentPage = totalPageCount;
//查询
query_data((currentPage - 1) * this.efDevGrid1.PageSize, this.efDevGrid1.PageSize);
}
else
{
this.EFMsgInfo = "已是最后一页!";
return;
}
}
catch (Exception ex)
{
EF.EFMessageBox.Show(ex.Message, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void efDevGrid1_EF_GridBar_NextPage_Event(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
{
try
{
//如果当前页不等于总页数 则查询
if (currentPage != totalPageCount)
{
//设置当前页
currentPage++;
//查询
query_data((currentPage - 1) * this.efDevGrid1.PageSize, this.efDevGrid1.PageSize);
}
else
{
this.EFMsgInfo = "已是最后一页!";
return;
}
}
catch (Exception ex)
{
EF.EFMessageBox.Show(ex.Message, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void efDevGrid1_EF_GridBar_PageTo_Event(object sender, EF.EFDevGrid.EFNavigatorButtonClickEventArgs e)
{
try
{
if (currentPage != e.PageTo || efDevGrid1.PageSize != e.PageSize)
{
//设置当前页
currentPage = e.PageTo;
efDevGrid1.PageSize = e.PageSize;
//查询
query_data((currentPage - 1) * efDevGrid1.PageSize, efDevGrid1.PageSize);
}
}
catch (Exception ex)
{
EF.EFMessageBox.Show(ex.Message, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void efDevGrid1_EF_GridBar_PrePage_Event(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
{
try
{
if (currentPage <= 1)
{
this.EFMsgInfo = "已经是第一页。";
return;
}
currentPage--;
query_data((currentPage - 1) * this.efDevGrid1.PageSize, this.efDevGrid1.PageSize);
}
catch (Exception ex)
{
EF.EFMessageBox.Show(ex.Message, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
#endregion
private void efDevButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
}
#region F6删除
//del
private void FormYMSRLG09GL_EF_DO_F6(object sender, EF.EF_Args e)
{
if (this.efDevGrid1.GetSelectedDataRow().Rows.Count <= 0)
{
EF.EFMessageBox.Show("请选择可以操作的记录。", EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
this.ef_args.buttonStatusHold = true;
return;
}
EI.EIInfo inblock = new EI.EIInfo();
inblock.Tables[0].Merge(efDevGrid1.GetSelectedDataRow());
EI.EIInfo outInfo = EI.EITuxedo.CallService("ymsrlg09gl_del", inblock);
EI.EIInfo.eiinfo_sys s = outInfo.GetSys(); //获取返回信息s
//设置返回信息
if (s.flag == 0)
{
currentPage = 1;
query_data(0, this.efDevGrid1.PageSize);
this.EFMsgInfo = string.Format("删除成功!");
}
else
{
this.EFSysInfo = s; //获取异常信息
EF.EFMessageBox.Show(s.msg, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
#endregion
#region 选择勾选框触发
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
for (int i = 0; i < gridView1.DataRowCount; i++)
{
if (efDevGrid1.GetSelectedColumnChecked(i))
{
weight = Convert.ToDecimal(weight) + Convert.ToDecimal(gridView1.GetRowCellValue(i, "MAT_WT"));//重量累加
num1 = Convert.ToDecimal(num1) + Convert.ToDecimal(gridView1.GetRowCellValue(i, "MAT_NUM"));//重量累加
//num = num + 1;//支数累加
weight1 = weight;
num2 = num1;
}
}
if (num1 != 0)
{
this.lb_choose_txt.Text = "当前选中" + num1 + "支,共计" + weight + "吨。";
// this.lb_choose_txt.Text = string.Format("选中材料:件/实重[{0}/{1}]", v_num, v_act_wt);
}
else
{
this.lb_choose_txt.Text = "当前选中0支,共计0吨。";
}
weight = 0;
num1 = 0;
}
#endregion
//form
private void sale_order_sub_no_I_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
EF.EF_Args.common_object_2 = mat_kind;
PopFormYMSRLG09GL popformymsrlg09gl = new PopFormYMSRLG09GL();
popformymsrlg09gl.ShowDialog();
if (EF.EF_Args.common_object_1 == null) return;
DataRow[] dr = (DataRow[])EF.EF_Args.common_object_1;
EF.EF_Args.common_object_1 = null;
this.sale_order_sub_no_I.EditValue = dr[0]["SALE_ORDER_SUB_NO"].ToString();
}
2)PopFormYMSRLG09GLC 新增弹窗
新增方法中,根据合同号查询
tqmtolg01
表,获取相关的材料和产品信息,并将这些信息存储在变量中以供后续使用。如果查询成功并且结果集中有数据,它将提取特定的字段值;如果查询失败或没有结果,这些变量将不会被赋值。使用
for
循环遍历DataRow
数组dr
,并将每个DataRow
的数据填充到数据网格控件gridView1
中。这包括为每个新添加的行设置多个列的值。即新增弹窗中查询显示的数据结果。
新增调用popformymsrlg09glc弹窗。下列为glc代码部分
#region Load事件
private void PopFormYMSRLG09GLC_Load(object sender, EventArgs e)
{
purc_sub_order_sub_no = EF.EF_Args.common_parameter_1.ToString();
stock_type = EF.EF_Args.common_parameter_2.ToString();
mat_kind = EF.EF_Args.common_parameter_3.ToString();
if(mat_kind=="TR")
{
eped54_name = "YMSRLG09GL_POPC_INQ";
}
else if (mat_kind == "TM")
{
eped54_name = "YMSRLG09GL_POPY_INQ";
}
else
{
eped54_name = "YMSRLG09GL_POPJ_INQ";
}
EF.Utility.SetGridColumn(new EF.EFDevGrid[] { this.efDevGrid1 }, new string[] { eped54_name });
pop_table_name = EF.EF_Args.common_parameter_1.ToString();
stock_type = EF.EF_Args.common_parameter_2.ToString();
stock_type1 = EF.EF_Args.common_parameter_4.ToString();
#region 仓库选择
//2016-11-15 改为从SI0215页面获取辅料库区
EI.EIInfo inBlock = new EI.EIInfo();
随意传个值即可
inBlock.Tables[0].Columns.Add("STOCK_TYPE");
inBlock.Tables[0].Columns.Add("REMARK");
inBlock.Tables[0].Rows.Add();
inBlock.Tables[0].Rows[0]["STOCK_TYPE"] = stock_type;
inBlock.Tables[0].Rows[0]["REMARK"] = stock_type1;
//inBlock.Tables[0].Rows.Add(stock_type,stock_type1);//库区性质
EI.EIInfo outBlock_CHECK = EI.EITuxedo.CallService("ymsrlg09_inqstock", inBlock);
if (outBlock_CHECK.sys_info.flag >= 0)
{
this.stockNo_efDevLookUpEdit.Properties.DataSource = outBlock_CHECK.Tables[0];
this.stockNo_efDevLookUpEdit.Properties.ValueMember = "STOCK_NO";
this.stockNo_efDevLookUpEdit.Properties.DisplayMember = "CODE_DESC_1_CONTENT";
this.stockNo_efDevLookUpEdit.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("STOCK_NO", "代码"));
this.stockNo_efDevLookUpEdit.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CODE_DESC_1_CONTENT", "库区"));
}
if (mat_kind == "TR")
{
this.stockNo_efDevLookUpEdit.EditValue = "JLY03";
}
else if (mat_kind == "TM")
{
this.stockNo_efDevLookUpEdit.EditValue = "JLY01";
}
this.stockNo_efDevLookUpEdit.Properties.ReadOnly = true;
#endregion
this.efDevGrid1.ShowSelectedColumn = false;
YMUtility.DEV_Init_grid2(efDevGrid1, "1");
}
#endregion
#region 查询
private void search_Button_Click(object sender, EventArgs e)
{
currentPage = 1;
query_data(0, this.efDevGrid1.PageSize);
}
#endregion
#region 选择
private void choose_Button_Click(object sender, EventArgs e)
{
if (1 > this.efDevGrid1.GetSelectedDataRow().Rows.Count)
{
EF.EFMessageBox.Show("请选择库存信息!", EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
this.POSY05DataTable = this.efDevGrid1.GetSelectedDataRow();
DataRow[] dr = this.POSY05DataTable.Select();
EF.EF_Args.common_object_1 = dr;
this.Close();
}
}
#endregion
#region 查询函数
private void query_data(int recordFrom, int pageSize)
{
try
{
EI.EIInfo inBlock = new EI.EIInfo();
inBlock.Tables[0].Columns.Add("SALE_ORDER_SUB_NO");
inBlock.Tables[0].Columns.Add("STOCK_NO");
inBlock.Tables[0].Columns.Add("POP_TABLE_NAME");
inBlock.Tables[0].Columns.Add("STOCK_TYPE");
inBlock.Tables[0].Columns.Add("MAT_KIND");
inBlock.Tables[0].Rows.Add();
inBlock.Tables[0].Rows[0]["SALE_ORDER_SUB_NO"] = this.purc_order_sub_no_Q.Text.Trim();
inBlock.Tables[0].Rows[0]["STOCK_NO"] = (this.stockNo_efDevLookUpEdit.EditValue == null ? "" : this.stockNo_efDevLookUpEdit.EditValue);
inBlock.Tables[0].Rows[0]["POP_TABLE_NAME"] = pop_table_name;
inBlock.Tables[0].Rows[0]["STOCK_TYPE"] = stock_type;
inBlock.Tables[0].Rows[0]["MAT_KIND"] = mat_kind;
//分页信息
EF.DSUtility.PageInfoDataTable pageInfo = new EF.DSUtility.PageInfoDataTable();
pageInfo.AddPageInfoRow(recordFrom, pageSize);
inBlock.Tables.Add("PageInfo");
inBlock.Tables["PageInfo"].Merge(pageInfo);
//调用后台
EI.EIInfo outBlock = EI.EITuxedo.CallService("ymsrlg09gl_pop_inqc", inBlock);
//设置返回信息
if (outBlock.sys_info.flag != 0)
{
EF.EFMessageBox.Show(outBlock.sys_info.msg, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
//将信息压入指定的GRID,
EF.Utility.SetCustomGridValue(efDevGrid1, outBlock, false);
//设置分页显示信息
YMUtility.DEV_grid_RecordCountMessage(efDevGrid1, currentPage, outBlock);
//列宽自动调整。
this.gridView1.BestFitColumns();
}
}
catch (Exception err)
{
EF.EFMessageBox.Show(err.Message, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
#endregion
#region DevGrid事件
private void efDevGrid1_EF_GridBar_First_Event(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
{
try
{
if (currentPage == 1)
{
return;
}
currentPage = 1;
//查询
query_data((currentPage - 1) * this.efDevGrid1.PageSize, this.efDevGrid1.PageSize);
}
catch (Exception ex)
{
EF.EFMessageBox.Show(ex.Message, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void efDevGrid1_EF_GridBar_Last_Event(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
{
try
{
//如果当前页不等于总页数 则查询
if (currentPage != totalPageCount)
{
//设置当前页
currentPage = totalPageCount;
//查询
query_data((currentPage - 1) * this.efDevGrid1.PageSize, this.efDevGrid1.PageSize);
}
else
{
return;
}
}
catch (Exception ex)
{
EF.EFMessageBox.Show(ex.Message, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void efDevGrid1_EF_GridBar_NextPage_Event(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
{
try
{
//如果当前页不等于总页数 则查询
if (currentPage != totalPageCount)
{
//设置当前页
currentPage++;
//查询
query_data((currentPage - 1) * this.efDevGrid1.PageSize, this.efDevGrid1.PageSize);
}
else
{
return;
}
}
catch (Exception ex)
{
EF.EFMessageBox.Show(ex.Message, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void efDevGrid1_EF_GridBar_PageTo_Event(object sender, EF.EFDevGrid.EFNavigatorButtonClickEventArgs e)
{
try
{
if (currentPage != e.PageTo || efDevGrid1.PageSize != e.PageSize)
{
//设置当前页
currentPage = e.PageTo;
efDevGrid1.PageSize = e.PageSize;
//查询
query_data((currentPage - 1) * efDevGrid1.PageSize, efDevGrid1.PageSize);
}
}
catch (Exception ex)
{
EF.EFMessageBox.Show(ex.Message, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void efDevGrid1_EF_GridBar_PrePage_Event(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
{
try
{
if (currentPage <= 1)
{
return;
}
currentPage--;
query_data((currentPage - 1) * this.efDevGrid1.PageSize, this.efDevGrid1.PageSize);
}
catch (Exception ex)
{
EF.EFMessageBox.Show(ex.Message, EF.EF_Args.epEname, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
#endregion
#region 选择勾选框触发
private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
{
int row = e.RowHandle;
decimal total_mat_wt = 0;
decimal total_mat_num = 0;
//停止gridView1_CellValueChanged事件
gridView1.CellValueChanged -= new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(gridView1_CellValueChanged);
for (int i = 0; i < efDevGrid1.GetSelectedDataRow().Rows.Count; i++)
{
total_mat_wt = total_mat_wt + Decimal.Parse(efDevGrid1.GetSelectedDataRow().Rows[i]["MAT_WT"].ToString());
total_mat_num = total_mat_num + Decimal.Parse(efDevGrid1.GetSelectedDataRow().Rows[i]["MAT_NUM"].ToString());
}
this.mat_wt_I.Text = "重量:" + total_mat_wt.ToString();
this.mat_num_I.Text = "支数:" + total_mat_num.ToString();
//恢复gridView1_CellValueChanged事件
gridView1.CellValueChanged += new DevExpress.XtraGrid.Views.Base.CellValueChangedEventHandler(gridView1_CellValueChanged);
}
#endregion
3)PopFormYMSRLG09GL 合同弹窗
功能简单,只有基本的查询。
后端:
ymsrlg09gl_ct 执行退货
#include "stdafx.h"
BM2_FUNCTION_IMPORT
int f_update_stock_tr_in_lg(CString io_stock_mode, CString call_step, CString roll_back_flag, EIClass * bcls_rec, EIClass * bcls_ret, CDbConnection * conn);
CString f_get_recId_lg();//生成记录流水号
CString f_GetNextSeq(CString seq_code, CDbConnection * conn, CString prefix = "");
//int f_so_xsthd_snd(EIClass * bcls_rec, EIClass * bcls_ret, CDbConnection * conn); //产成品入库单
int f_ym100003_snd(EIClass * bcls_rec, EIClass * bcls_ret, CDbConnection * conn);
BM2F_ENTERACE(ymsrlg09gl_ct)
int f_ymsrlg09gl_ct(EIClass * bcls_rec, EIClass * bcls_ret, CDbConnection * conn)
{
int doFlag = 0;
CString s_datrnow = CDateTime::Now().ToString("yyyyMMddHHmmss");
CString s_inv_id;
CString table_name_storage;
CString c_mat_no;
CString mat_kind, stock_type, in_stock_mode = " ";
CString sale_order_sub_no;
CDecimal return_qty = 0;//计划退货量
CDecimal mat_wt = 0;//退货量
CDecimal sum_wt = 0;//已经退货量
CString user_name = s.username;
CString user_id = s.userid;
CModel tqmtolg01("TQMTOLG01");//合同表
CModel tymsrlg24gl("TYMSRLG24GL");
CModel tqmtolg00("TQMTOLG00");
CModel mym00001lg("MYM00001LG");//库存模板表
CModel mym00001lg_inq("MYM00001LG");//库存模板表
CDbCommand cmd2(conn);
CDbCommand cmd3(conn);
/* 数据库操作类定义 */
CDbCommand cmd_inq(conn);
CString sqlstr = " ";
CString sqlstr_upd = " ";
try
{
table_name_storage = bcls_rec->Tables[1].Rows[0]["TABLE_NAME"]; //库存表名
mat_kind = bcls_rec->Tables[1].Rows[0]["MAT_KIND"];
stock_type = bcls_rec->Tables[1].Rows[0]["STOCK_TYPE"];
in_stock_mode = bcls_rec->Tables[1].Rows[0]["IN_STOCK_MODE"];
Log::Trace("", "", "table_name_storage={0}", table_name_storage);
Log::Trace("", "", "mat_kind={0}", mat_kind);
Log::Trace("", "", "stock_type={0}", stock_type);
Log::Trace("", "", "in_stock_mode={0}", in_stock_mode);
if (table_name_storage.Trim() == "")
{
strcpy(s.msg, "业务表不能为空!");
s.flag = -1;
return -1;
}
EIClass bcls_ym09;
bcls_ym09.Tables.Add();
bcls_ym09.Tables[0].set_TableName("YMTR01");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "SALE_ORDER_SUB_NO");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "IN_STOCK_NO");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "OUT_STOCK_NO");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "MAT_NO");
bcls_ym09.Tables[0].Columns.Add(DT_DECIMAL, "MAT_NUM");
bcls_ym09.Tables[0].Columns.Add(DT_DECIMAL, "MAT_WT");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "MAT_KIND");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "ORIGIN_HEAT_NO");
bcls_ym09.Tables[0].Columns.Add(DT_DECIMAL, "MAT_QTY");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "IOSTOCK_DATE");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "BRANCH_CODE");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "COMPANY_CODE");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "OPERATE_TYPE");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "REMARK_1");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "REMARK_2");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "REMARK_3");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "REMARK_4");
bcls_ym09.Tables[0].Columns.Add(DT_STRING, "REMARK_5");
bcls_ym09.Tables[0].Columns.Add(DT_DECIMAL, "REMARK_NUM1");
bcls_ym09.Tables[0].Columns.Add(DT_DECIMAL, "REMARK_NUM2");
bcls_ym09.Tables[0].Columns.Add(DT_DECIMAL, "REMARK_NUM3");
bcls_ym09.Tables[0].Columns.Add(DT_DECIMAL, "REMARK_NUM4");
bcls_ym09.Tables[0].Columns.Add(DT_DECIMAL, "REMARK_NUM5");
Log::Trace("", "", "cx={0}", bcls_rec->Tables[0].Rows.get_Count());
for (int i = 0; i < bcls_rec->Tables[0].Rows.get_Count(); i++)
{
mym00001lg.Reset();
tqmtolg00.Reset();
tymsrlg24gl.MergeFrom(bcls_rec->Tables[0].Rows[i]);
c_mat_no = tymsrlg24gl["MAT_NO"];
mat_wt = (-1)*bcls_rec->Tables[0].Rows[i]["MAT_WT"].ToDecimal();
Log::Trace("", "", "c_mat_no={0}", c_mat_no);
Log::Trace("", "", "table_name_storage={0}", table_name_storage);
EIClass bcls_matInfo; //获取退料表信息
sqlstr = "select * from TYMSRLG24GL where mat_no = @mat_no ";
cmd_inq.SetCommandText(sqlstr);
cmd_inq.Parameters.Set("mat_no", c_mat_no);
cmd_inq.ExecuteQuery(bcls_matInfo.Tables[0]);
cmd_inq.Close();
Log::Trace("", "", "sqlstr={0}", sqlstr);
if (bcls_matInfo.Tables[0].Rows.get_Count() < 1)
{
strcpy(s.msg, "业务表未查到材料信息" + bcls_matInfo.Tables[0].Rows[0]["MAT_NO"].ToString() + ",请保存后再操作!");
s.flag = -1;
return -1;
}
EIClass bcls_matInfo1; //获取库存表捆号信息
if (stock_type == "Y")
{
sqlstr = "select * from TYMSRLGC01Y where mat_no = @mat_no ";
}
else
{
sqlstr = "select * from TYMSRLGC01C where mat_no = @mat_no ";
}
cmd_inq.SetCommandText(sqlstr);
cmd_inq.Parameters.Set("mat_no", c_mat_no);
cmd_inq.ExecuteQuery(bcls_matInfo1.Tables[0]);
cmd_inq.Close();
Log::Trace("", "", "sqlstr={0}", sqlstr);
Log::Trace("", "", "CONFM_FLAG={0}", bcls_matInfo1.Tables[0].Rows[0]["CONFM_FLAG"].ToString().Trim());
if (bcls_matInfo1.Tables[0].Rows[0]["CONFM_FLAG"].ToString().Trim() == "1")
{
strcpy(s.msg, "材料号【" + c_mat_no + "】已准发不允许退货!");
s.flag = -1;
return -1;
}
mym00001lg.MergeFrom(bcls_matInfo1.Tables[0].Rows[0]); //组织出库函数数据
Log::Trace("", "", "1111");
if (mym00001lg["SALE_ORDER_SUB_NO"].ToString().Trim() != "")
{
tqmtolg00["SALE_ORDER_SUB_NO"] = mym00001lg["SALE_ORDER_SUB_NO"];
}
//组织传入数据
EIClass bcls_ym02;
bcls_ym02.Tables.Add();
bcls_ym02.Tables[0].set_TableName("YMTR01");
bcls_ym02.Tables[0].Columns.Add(mym00001lg);
bcls_ym02.Tables["YMTR01"].Rows.Clear();
mym00001lg.MergeTo(bcls_ym02.Tables["YMTR01"], false);
//调用入库函数处理块
EIClass bcls_temp;
bcls_temp.Tables.Add();
bcls_temp.Tables[0].set_TableName("YMTR01");
bcls_temp.Tables[0].Columns.Add(mym00001lg);
bcls_temp.Tables["YMTR01"].Rows.Add();
bcls_temp.Tables["YMTR01"].Rows[0].Merge(bcls_ym02.Tables["YMTR01"].Rows[0]);
bcls_temp.Tables["YMTR01"].Rows[0]["MAT_NUM"] = (-1)*bcls_ym02.Tables["YMTR01"].Rows[0]["MAT_NUM"].ToDecimal();
bcls_temp.Tables["YMTR01"].Rows[0]["MAT_WT"] = (-1)*bcls_ym02.Tables["YMTR01"].Rows[0]["MAT_WT"].ToDecimal();
bcls_temp.Tables["YMTR01"].Rows[0]["MAT_QTY"] = (-1)*bcls_ym02.Tables["YMTR01"].Rows[0]["MAT_QTY"].ToDecimal();
if (bcls_temp.Tables["YMTR01"].Rows[0]["MAT_ID"].ToString().Trim() == "")
{
bcls_temp.Tables["YMTR01"].Rows[0]["MAT_ID"] = f_get_recId_lg();
}
//调用一步出库函数处理
if (bcls_temp.Tables["YMTR01"].Rows.get_Count() > 0)
{
Log::Debug("", __FUNCTION__, "调用函数=[{0}]", "f_update_stock_tr_out");
doFlag = f_update_stock_tr_in_lg(in_stock_mode, "1", "0", &bcls_temp, bcls_ret, conn);
if (doFlag != 0)
{
throw CApplicationException(-1, s.msg, s.svc_name);
}
Log::Debug("", __FUNCTION__, "----调用函数f_update_stock_tr_in_lg结束---");
}
else
{
strcpy(s.msg, "调用函数f_update_stock_tr_in_lg失败,传入块中无数据,请检查!");
s.flag = -1;
return -1;
}
//修改退货表数据
sqlstr_upd = " UPDATE TYMSRLG24GL set FLAG_6 = '02' where mat_no = @mat_no";
cmd_inq.SetCommandText(sqlstr_upd);
cmd_inq.Parameters.Set("mat_no", c_mat_no);
int rows_affected = cmd_inq.ExecuteNonQuery();
Log::Trace("", __FUNCTION__, "sqlstr_upd = [{0}]", sqlstr_upd);
cmd_inq.Close();
}
}
catch (CDbException& ex)
{
CFormattable arguments[] = { ex.GetCode() };
CMessageFormat::Format(s.msg, "数据库处理出错,sqlcode=[{0}],请联系开发人员", arguments, 1);
CString str = sqlstr + "\r\n" + ex.GetMsg();
strncpy(s.sysmsg, (const char*)str, sizeof(s.sysmsg) - 1);
s.flag = -1;
doFlag = -1;
}
catch (CApplicationException& ex)
{
s.flag = ex.GetCode();
doFlag = -1;
}
catch (CException& ex)
{
strcpy(s.msg, ex.GetMsg());
s.flag = ex.GetCode();
doFlag = -1;
}
return doFlag;
}
在页面勾选需要退货的材料,确定之后,将勾选的信息参数压入子画面进行调用。创建
EIClass bcls_ym09
对象,并添加表格和列。使用for
循环遍历bcls_rec->Tables[0].Rows
中的所有行。在循环内部,重置一些EIClass对象,并使用MergeFrom
方法将bcls_rec
中的数据合并到tymsrlg24gl
对象中。记录当前处理的材料编号(c_mat_no
)和库存表名。构建SQL查询字符串(sqlstr
),查询TYMSRLG24GL
表中与当前材料编号相关的信息,并将结果存储在bcls_matInfo
对象中。根据库存类型(
stock_type
),查询对应的库存表(TYMSRLGC01Y
或TYMSRLGC01C
),获取捆号信息。将查询到的捆号信息合并到mym00001lg
对象中。创建bcls_ym02
对象,复制mym00001lg
的数据到该对象中。创建bcls_temp
对象,调用f_update_stock_tr_in_lg
函数处理入库逻辑,更新库存数据。构建更新SQL语句(sqlstr_upd
),将TYMSRLG24GL
表中对应材料编号的FLAG_6
字段设置为"02",表示退货操作。
四、编译过程中错误总结
1、后台只需要编译上传即可运行,不需要退出程序。
2、后台先上传再编译。
3、STOCK-TYPE:y原料,c成品;
mat-kind:tm未加工成管;tr加工成管;
4、报错查位置,日志确定位置、报错在日志下面
5、int f_update_stock_tr_in_lg(CString io_stock_mode, CString call_step, CString roll_back_flag, EIClass * bcls_rec, EIClass * bcls_ret, CDbConnection * conn)
step1/2:一步入库/两步:比较重要的
CString io_stock_mode;A1/GI/...
EIClass * bcls_rec:返回序号(类似于主键)
EIClass * bcls_ret:0/9
0入库成功/9:回退(入出库履历保存)