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.
91 lines
3.4 KiB
C#
91 lines
3.4 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;
|
|
namespace Mesnac.Action.Intake.Qingquan.SaveData
|
|
{
|
|
public class InsertBigDayBin : DatabaseAction, IAction
|
|
{
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
///确定要添加吗?
|
|
if (MessageBox.Show(Language(3), 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();
|
|
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(@"INSERT INTO dbo.pst_DayBin( Bin_Type ,Bin_Num ,Mater_ID ,Mater_Name )");
|
|
sql.Append("VALUES (2,");
|
|
sql.Append(txtBinNum.BaseControl.MCValue.ToString());
|
|
sql.Append(","+cmb.SelectedValue.ToString()+",'");
|
|
sql.Append(cmb.Text.ToString()+"')");
|
|
|
|
dbHelper.CommandText = sql.ToString();
|
|
dbHelper.ExecuteNonQuery();
|
|
}
|
|
ShowMsg(Language(4));
|
|
}
|
|
}
|
|
}
|