using Mesnac.Action.Base; using Mesnac.Controls.Base; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Mesnac.Action.Base; using Mesnac.Codd.Session; using Mesnac.Controls.Base; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Mesnac.Action.ChemicalWeighing.LjPlanning { public class SelectAction : ChemicalWeighingAction, IAction { 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 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.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.Debug("{榄菊计划报表查询} 缺少key值为enddate的时间查询条件..."); return; } sbSql.Append(" ORDER BY CreateTime desc"); dbHelper.CommandText = sbSql.ToString(); dbHelper.CommandType = System.Data.CommandType.Text; DataTable table = dbHelper.ToDataTable(); _materialGridControl.BaseControl.BindDataSource = table; } } }