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.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/InItDbAction.cs

141 lines
5.0 KiB
C#

1 year ago
using System;
using System.Collections.Generic;
1 year ago
using System.Data;
using System.Linq;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.LjMaterial;
using Mesnac.Controls.Base;
using Mesnac.Controls.Default;
1 year ago
namespace Mesnac.Action.ChemicalWeighing.LjPlanning
{
public class InItDbAction:ChemicalWeighingAction, IAction
1 year ago
{
private DbMCControl _materialGridControl = null; //物料列表控件
private RuntimeParameter _runtime;
private MCCombobox PlanStatus;
1 year ago
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
this._runtime = runtime;
1 year ago
AddAction.OnAdd -= Process_Event;
AddAction.OnAdd += Process_Event;
1 year ago
UpdateAction.OnUpdate -= Process_Event;
UpdateAction.OnUpdate += Process_Event;
DownloadAction.OnDown -= Process_Event;
DownloadAction.OnDown += Process_Event;
//SelectAction.OnSelect -= Process_Event;
//SelectAction.OnSelect += Process_Event;
1 year ago
DbMCControl materialGridControl =
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "lj_planning")
.FirstOrDefault(); //获取物料数据控件
this._materialGridControl = materialGridControl;
List<DbMCControl> mcControllist = GetAllDbMCControlsByOption(DbOptionTypes.Query);//获取所有待初始化控件
IBaseControl startdate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "startdate").FirstOrDefault().BaseControl;
startdate.MCValue = DateTime.Now.AddDays(-7);
PlanStatus = mcControllist.FirstOrDefault(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey == "PlanStatus").BaseControl as MCCombobox;
string sql = @"select statusid as CmbValue ,statusname as CmbDisplay from lj_planning_status";
DataTable dataTable = DBHelp.GetTable(sql);
var dr = dataTable.NewRow();
dr[0] = "-2";
dr[1] = "全部";
dataTable.Rows.InsertAt(dr, 0);
PlanStatus.DataSource = dataTable;
1 year ago
FileControl();
}
private void FileControl()
{
DataTable table =
DBHelp.GetTable(@"select Id,PlanName, PlanNo, Status, CreateTime, UpdateTime, BegTime, EndTime, NumCar, Unit, Remark, IsEnable, FormulaId, FormulaName,'' as StatusName
,ClassName from lj_planning where IsEnable=1 order by CreateTime desc ");
1 year ago
if (this._materialGridControl != null && this._materialGridControl.BaseControl != null)
{
if (table.Columns["StatusName"].ReadOnly)
{
table.Columns["StatusName"].ReadOnly = false;
}
table.Columns["StatusName"].MaxLength = 20;
//-1 任务暂停 0 新建任务 1 任务下发 2 重发 3执行中 10 任务完成 11 放弃 20 异常
foreach (DataRow tableRow in table.Rows)
{
int status = Convert.ToInt32(tableRow["Status"].ToString());
string statusName = "";
switch (status)
{
case -1:
statusName = "任务暂停";
break;
case 0:
statusName = "新建任务";
break;
case 1:
statusName = "任务下发";
break;
case 2:
statusName = "重发";
break;
case 3:
statusName = "执行中";
break;
case 10:
statusName = "任务完成";
break;
case 20:
statusName = "异常";
break;
}
tableRow["StatusName"] = statusName;
}
1 year ago
this._materialGridControl.BaseControl.BindDataSource = null;
this._materialGridControl.BaseControl.BindDataSource = table;
DBLog("下发计划!");
1 year ago
}
else
{
ICSharpCode.Core.LoggingService<InitDbAction>.Warn("刷新物料信息失败物料数据控件为Null...");
}
}
#region 事件处理方法
private void Process_Event(object sender, EventArgs e)
{
if (sender is RuntimeParameter)
{
this.Run(sender as RuntimeParameter);
}
else
{
this.Run(this._runtime);
}
}
#endregion
}
}