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.
121 lines
4.6 KiB
C#
121 lines
4.6 KiB
C#
using Mesnac.Action.Base;
|
|
using Mesnac.Controls.Base;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Mesnac.Codd.Session;
|
|
using Mesnac.Controls.Default;
|
|
using Mesnac.Action.ChemicalWeighing.LjMaterial;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.LjPlanning
|
|
{
|
|
public class SelectAction : ChemicalWeighingAction, IAction
|
|
{
|
|
//public static event EventHandler OnSelect;
|
|
|
|
private DbMCControl _materialGridControl = null; //物料列表控件
|
|
private RuntimeParameter _runtime;
|
|
public void Run(RuntimeParameter runtime)
|
|
{
|
|
base.RunIni(runtime); //必须调用
|
|
this._runtime = runtime;
|
|
|
|
DbMCControl _materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "lj_planning").FirstOrDefault();
|
|
|
|
DbHelper dbHelper = Mesnac.Basic.DataSourceFactory.Instance.GetDbHelper(Mesnac.Basic.DataSourceFactory.MCDbType.Local);
|
|
dbHelper.ClearParameter();
|
|
|
|
StringBuilder sbSql = new StringBuilder(@" select Id, PlanName, PlanNo, Status, CreateTime, UpdateTime, BegTime, EndTime, NumCar, Unit, Remark, IsEnable, FormulaId, FormulaName,'' as StatusName
|
|
,ClassName from lj_planning where IsEnable=1");
|
|
|
|
|
|
|
|
|
|
|
|
List<DbMCControl> mcControllist = GetAllDbMCControlsByOption(DbOptionTypes.Query);//获取所有待初始化控件
|
|
|
|
IBaseControl startdate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "startdate").FirstOrDefault().BaseControl;
|
|
if (startdate != null)
|
|
{
|
|
//Append
|
|
sbSql.AppendLine(@" and CreateTime >='" + Convert.ToDateTime(startdate.MCValue).ToString("yyyy-MM-dd") + " 00:00:00.000' ");
|
|
}
|
|
else
|
|
{
|
|
ICSharpCode.Core.LoggingService<SelectAction>.Debug("{榄菊计划报表查询} 缺少key值为startdate的时间查询条件...");
|
|
return;
|
|
}
|
|
|
|
IBaseControl enddate = mcControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey.ToLower() == "enddate").FirstOrDefault().BaseControl;
|
|
if (enddate != null)
|
|
{
|
|
sbSql.AppendLine(@"AND CreateTime <='" + Convert.ToDateTime(enddate.MCValue).ToString("yyyy-MM-dd") + " 23:59:59.999' ");
|
|
}
|
|
else
|
|
{
|
|
ICSharpCode.Core.LoggingService<SelectAction>.Debug("{榄菊计划报表查询} 缺少key值为enddate的时间查询条件...");
|
|
return;
|
|
}
|
|
MCCombobox PlanStatus = mcControllist.FirstOrDefault(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey == "PlanStatus").BaseControl as MCCombobox;
|
|
|
|
if (Convert.ToString(PlanStatus.MCValue) != "-2")
|
|
{
|
|
sbSql.Append(@" and Status = " + PlanStatus.MCValue);
|
|
}
|
|
|
|
|
|
sbSql.Append(@" ORDER BY CreateTime desc");
|
|
|
|
dbHelper.CommandText = sbSql.ToString();
|
|
dbHelper.CommandType = System.Data.CommandType.Text;
|
|
DataTable table = dbHelper.ToDataTable();
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
_materialGridControl.BaseControl.BindDataSource = table;
|
|
|
|
}
|
|
}
|
|
}
|