|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Windows.Forms;
|
|
|
using System.Data;
|
|
|
using Mesnac.Action.Base;
|
|
|
using Mesnac.Codd.Session;
|
|
|
using System.Reflection;
|
|
|
using Mesnac.Controls.Base;
|
|
|
using System.Timers;
|
|
|
using Mesnac.Action.ChemicalWeighing.DBHelper;
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Product.XlPlan
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 当班计划窗体初始化业务
|
|
|
/// </summary>
|
|
|
public class InitFormAction : ChemicalWeighingAction,IAction
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 刷新
|
|
|
/// </summary>
|
|
|
public static event EventHandler OnRefreshPlan;
|
|
|
|
|
|
#region 字段定义
|
|
|
|
|
|
public static bool IsFirstRun = true; //是否首次运行
|
|
|
public static bool IsRun = true; //是否首次运行
|
|
|
private RuntimeParameter _runtime;
|
|
|
//private DbMCControl _planDateControl = null; //计划日期
|
|
|
//private DbMCControl _pptShiftControl = null; //班次
|
|
|
private DbMCControl _clientGridControl = null; //本地计划控件
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
{
|
|
|
base.RunIni(runtime);
|
|
|
|
|
|
#region 首次执行,进行事件订阅
|
|
|
|
|
|
if (IsFirstRun)
|
|
|
{
|
|
|
IsFirstRun = false;
|
|
|
ICSharpCode.Core.LoggingService<InitFormAction>.Debug("当班计划-窗体初始化业务...");
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
PlanHelper.IsInit = false; //先设置是否已初始化标记为False
|
|
|
|
|
|
#region 初始化
|
|
|
|
|
|
#region 获取界面控件
|
|
|
|
|
|
string source = string.Empty;
|
|
|
//DbMCControl planDateControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "[xl_plan].[Plan_Date]").FirstOrDefault();
|
|
|
//DbMCControl pptShiftControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_Shiftime").FirstOrDefault();
|
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "xl_plan").FirstOrDefault(); //获取本机台计划网格控件
|
|
|
|
|
|
if (clientGridControl == null)
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<InitFormAction>.Error("{当班计划-窗体加载} 缺少计划列表网格控件...");
|
|
|
return;
|
|
|
}
|
|
|
this._runtime = runtime;
|
|
|
this._clientGridControl = clientGridControl;
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#region 初始化操作
|
|
|
|
|
|
DataGridView clientGrid = (clientGridControl.BaseControl as DataGridView);
|
|
|
|
|
|
this.InitGridViewEvent(clientGrid);
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
PlanHelper.IsInit = true; //初始化完毕后,再设置是否已初始化标记为True
|
|
|
}
|
|
|
|
|
|
#region 方法定义
|
|
|
|
|
|
#region 网格事件处理方法
|
|
|
|
|
|
/// <summary>
|
|
|
/// 初始化网格样式
|
|
|
/// </summary>
|
|
|
/// <param name="dgv">DataGridView网格控件对象</param>
|
|
|
private void InitGridViewEvent(DataGridView dgv)
|
|
|
{
|
|
|
if (dgv != null)
|
|
|
{
|
|
|
PlanHelper.SetDataGridViewStyle(dgv); //设置网格样式
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void Cms_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
//ShowMsg("11111");
|
|
|
//MessageBox.Show("11111");
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|
|
|
protected void DoWork()
|
|
|
{
|
|
|
#region 业务实现
|
|
|
|
|
|
//int shiftID = Global.PublicVar.Instance.globalShiftID;
|
|
|
//int.TryParse(this._pptShiftControl.BaseControl.MCValue.ToString(), out shiftID);
|
|
|
string equipCode = base.CurrEquipCode; //当前机台
|
|
|
//DateTime selectedDate = Convert.ToDateTime(this._planDateControl.BaseControl.MCValue);
|
|
|
//DataTable table = PlanHelper.GetPlanData(selectedDate, shiftID);
|
|
|
//DataTable table = PlanHelper.GetPlanData(selectedDate);
|
|
|
//DataTable table = PlanHelper.GetPlanData();
|
|
|
IFreeSql fsql = FreeHelper.Instance;
|
|
|
string sql = @"select *from (SELECT Batch,ProductName,Plan_Serial,Recipe_ID,Recipe_Name,Equip_Code,Version,Plan_Id,Plan_Num,Real_Num,Plan_State,Plan_StateText,Start_Date,End_Date,Plan_Date,IsPrenatalTest,CreateTime FROM xl_plan
|
|
|
where IsPrenatalTest=0 or IsPrenatalTest IS NULL
|
|
|
) t where datediff(day, t.CreateTime,getdate())=0 ";
|
|
|
DataTable table = fsql.Select<object>().WithSql(sql).OrderBy("Plan_State").ToDataTable("*");
|
|
|
|
|
|
lock (String.Empty)
|
|
|
{
|
|
|
//本地计划
|
|
|
if (this._clientGridControl != null && this._clientGridControl.BaseControl != null)
|
|
|
{
|
|
|
this._clientGridControl.BaseControl.BindDataSource = null;
|
|
|
this._clientGridControl.BaseControl.BindDataSource = table;
|
|
|
|
|
|
#region 根据计划状态处理背景色
|
|
|
|
|
|
DataGridView clientGrid = this._clientGridControl.BaseControl as DataGridView;
|
|
|
PlanHelper.SetBackColor(clientGrid);
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
ICSharpCode.Core.LoggingService<RefreshAction>.Warn("刷新本地计划失败:本地计划控件为Null...");
|
|
|
}
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|