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.

100 lines
3.3 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 Mesnac.Controls.Default;
using System.Windows.Forms;
using Mesnac.Codd.Session;
namespace Mesnac.Action.Feeding.Technology
{
public class NewRecipe : FeedingAction, IAction
{
private DataTable IniWeightData()
{
string sqlstr = "SELECT weight_id as SeqInx,* FROM pmt_weigh WHERE 1=2";
DbMCSource dbsource = base.GetAllDbMCSources().FirstOrDefault();
DbHelper dbHelper = NewDbHelper(dbsource.DesignSource);
if (dbHelper == null)
{
return new DataTable();
}
dbHelper.CommandType = CommandType.Text;
dbHelper.ClearParameter();
dbHelper.CommandText = sqlstr;
DataTable weight = dbHelper.ToDataTable();
foreach (DataColumn dc in weight.Columns)
{
dc.ReadOnly = false;
dc.AllowDBNull = true;
}
for (int i = 1; i <= 10; i++)
{
DataRow dr = weight.NewRow();
dr["ObjID"] = i;
dr["weight_id"] = i;
dr["SeqInx"] = i;
dr["act_code"] = string.Empty;
dr["child_name"] = string.Empty;
weight.Rows.Add(dr);
}
return weight;
}
private DataTable IniMixingData()
{
string sqlstr = "SELECT mix_id as SeqInx,* FROM pmt_mix WHERE 1=2";
DbMCSource dbsource = base.GetAllDbMCSources().FirstOrDefault();
DbHelper dbHelper = NewDbHelper(dbsource.DesignSource);
if (dbHelper == null)
{
return new DataTable();
}
dbHelper.CommandType = CommandType.Text;
dbHelper.ClearParameter();
dbHelper.CommandText = sqlstr;
DataTable mixing = dbHelper.ToDataTable();
foreach (DataColumn dc in mixing.Columns)
{
dc.ReadOnly = false;
dc.AllowDBNull = true;
}
for (int i = 1; i <= 30; i++)
{
DataRow dr = mixing.NewRow();
dr["ObjID"] = i;
dr["mix_id"] = i;
dr["SeqInx"] = i;
dr["act_code"] = string.Empty;
dr["term_code"] = string.Empty;
mixing.Rows.Add(dr);
}
return mixing;
}
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
List<MCDataGridView> gridList = GetTControls<MCDataGridView>();
foreach (MCDataGridView grid in gridList)
{
if (grid.MCKey != null && grid.MCKey.ToLower().StartsWith("PmtWeight.".ToLower()))
{
int iType = 0;
if (int.TryParse(grid.MCKey.Substring("PmtWeight.".Length).Trim(), out iType))
{
grid.DataSource = IniWeightData();
}
}
if (grid.MCKey != null && grid.MCKey.ToLower() == "PmtMixing".ToLower())
{
grid.DataSource = IniMixingData();
}
}
}
}
}