You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
5.2 KiB
C#
113 lines
5.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Data;
|
|
using Mesnac.Action.Base;
|
|
using Mesnac.Controls.Base;
|
|
using System.Windows.Forms;
|
|
using Mesnac.Codd.Session;
|
|
using Mesnac.Action.Intake.Qingquan.MaterialManager;
|
|
|
|
namespace Mesnac.Action.Intake.Qingquan.SaveData
|
|
{
|
|
public class UpdateSmallDayBin : DatabaseAction, IAction
|
|
{
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
///确定要添加吗?
|
|
if (MessageBox.Show(Language(5), Language(1), MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
|
|
{
|
|
runtime.IsReturn = true;
|
|
return;
|
|
}
|
|
base.RunIni(runtime); //必须调用
|
|
|
|
#region 控件数据合法性验证
|
|
|
|
bool isValidFlag = true;
|
|
foreach (DbMCControl control in GetAllDbMCControls())
|
|
{
|
|
if (control.BaseControl.IsValid == false)
|
|
{
|
|
//MessageBox.Show(Language(31), Language(1), MessageBoxButtons.OK);
|
|
isValidFlag = false;
|
|
break;
|
|
}
|
|
}
|
|
if (isValidFlag == false)
|
|
{
|
|
ShowMsg(Language(31));
|
|
runtime.IsReturn = true;
|
|
return;
|
|
}
|
|
|
|
#endregion
|
|
|
|
ShowMsg(Language(0));
|
|
foreach (DbMCSource dbsource in GetAllDbMCSources())
|
|
{
|
|
if (string.IsNullOrWhiteSpace(dbsource.DesignSource) ||
|
|
string.IsNullOrWhiteSpace(dbsource.DataTable.ToString()))
|
|
{
|
|
continue;
|
|
}
|
|
string source = dbsource.DesignSource;
|
|
DbHelper dbHelper = NewDbHelper(source);
|
|
if (dbHelper == null)
|
|
{
|
|
continue;
|
|
}
|
|
dbHelper.ClearParameter();
|
|
dbHelper.CommandType = CommandType.Text;
|
|
|
|
DbMCControl cbRecipe = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[pst_DayBin].[Mater_ID]").FirstOrDefault();
|
|
ComboBox cmb = cbRecipe.BaseControl as ComboBox;// this.GetDbMCControlByKey("[pst_DayBin].[Mater_ID]").FirstOrDefault();
|
|
DbMCControl txtBinNum = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[pst_DayBin].[Bin_Num]").FirstOrDefault();
|
|
DbMCControl lblid = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[pst_DayBin].[ObjId]").FirstOrDefault();
|
|
|
|
DbMCControl equipcode = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[pst_DayBin].[Equip_Code]").FirstOrDefault();
|
|
DbMCControl silonum = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[pst_DayBin].[Silo_num]").FirstOrDefault();
|
|
DbMCControl pri = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[pst_DayBin].[PRI]").FirstOrDefault();
|
|
DbMCControl auto = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[pst_DayBin].[Auto]").FirstOrDefault();
|
|
if (Material.IsEXistsSmallDayBinNumByID(lblid.BaseControl.MCValue.ToString(), "1", txtBinNum.BaseControl.MCValue.ToString(),equipcode.BaseControl.MCValue.ToString()))
|
|
{
|
|
MessageBox.Show(Language(402), Language(1), MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
runtime.IsReturn = true; //终止执行
|
|
return;
|
|
}
|
|
if (cbRecipe == null)
|
|
{
|
|
base.LogError("{大罐设置} 缺少key值为[pst_DayBin].[Mater_ID]的盛放物料列表控件...");
|
|
runtime.IsReturn = true;
|
|
return;
|
|
}
|
|
if (txtBinNum == null)
|
|
{
|
|
base.LogError("{大罐设置} 缺少key值为[pst_DayBin].[Bin_Num]的罐号控件...");
|
|
runtime.IsReturn = true;
|
|
return;
|
|
}
|
|
StringBuilder sql = new StringBuilder();
|
|
sql.Append(@"update dbo.pst_DayBin set Bin_Num=@num ,Mater_ID=@materid ,Mater_Name=@matername,
|
|
Equip_Code=@equipcode,Silo_num=@silonum,PRI=@pri,Auto=@auto where objid=@id");
|
|
|
|
dbHelper.CommandText = sql.ToString();
|
|
dbHelper.AddParameter("@num", txtBinNum.BaseControl.MCValue.ToString());
|
|
dbHelper.AddParameter("@matername", cmb.Text);
|
|
dbHelper.AddParameter("@materid", cmb.SelectedValue.ToString());
|
|
|
|
dbHelper.AddParameter("@equipcode", equipcode.BaseControl.MCValue.ToString());
|
|
dbHelper.AddParameter("@silonum", silonum.BaseControl.MCValue.ToString());
|
|
dbHelper.AddParameter("@pri", pri.BaseControl.MCValue.ToString());
|
|
dbHelper.AddParameter("@auto", (auto.BaseControl.MCValue.ToString().ToLower()=="true"?1:0).ToString());
|
|
|
|
|
|
dbHelper.AddParameter("@id", lblid.BaseControl.MCValue.ToString());
|
|
dbHelper.ExecuteNonQuery();
|
|
}
|
|
ShowMsg(Language(4));
|
|
}
|
|
}
|
|
}
|