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.

170 lines
6.4 KiB
C#

1 year ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data;
using ICSharpCode.Core;
using Mesnac.Controls.Base;
using Mesnac.Action.Base;
using Mesnac.Codd.Session;
using Mesnac.Action.ChemicalWeighing.Entity;
using DevExpress.Office.Utils;
namespace Mesnac.Action.ChemicalWeighing.Station
{
/// <summary>
/// 生产管理-修改计划数业务
/// </summary>
public class SelectStation : ChemicalWeighingAction, IAction
{
#region 字段定义
private RuntimeParameter _runtime;
private DbMCControl _stationGridControl = null;
private DbMCControl _subGridControl = null;
List<xl_station_sub> subList = null;
#endregion
#region 业务入口
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用的
this._runtime = runtime;
#region 获取界面recipe控件
DbMCControl gridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "xl_station").FirstOrDefault();
if (gridControl == null || !(gridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{工位管理—选择工位}缺少配方管理控件...");
return;
}
this._stationGridControl = gridControl;
#endregion
this.DoWork();
}
#endregion
#region 方法定义
protected void DoWork()
{
#region 1 判断是否选择了一条工位信息
DataGridView stationGridView = this._stationGridControl.BaseControl as DataGridView;
if (stationGridView.SelectedRows.Count == 1)
{
#region 变量定义
string selectID = null;
#endregion
#region 2.1 获取界面控件
DbMCControl subGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "xl_station_sub").FirstOrDefault();
if (subGridControl == null || !(subGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{工位管理—选择工位}缺少工位显示控件...");
return;
}
this._subGridControl = subGridControl;
DataGridView subGridView = this._subGridControl.BaseControl as DataGridView;
#endregion
#region 获取工位信息List
selectID = stationGridView.SelectedRows[0].Cells["ID"].Value as string;
#endregion
subList = StationHelper.GetStationSubList(selectID);
DataTable table = DataListShow();
lock (String.Empty)
{
//本地计划
if (this._subGridControl != null && table != null)
{
this._subGridControl.BaseControl.BindDataSource = null;
this._subGridControl.BaseControl.BindDataSource = table;
}
}
}
else
{
return;
}
#endregion
}
#region DataTable数据整理显示
private DataTable DataListShow()
{
DataTable dataTable = null;
if (subList != null && subList.Count > 0)
{
dataTable = new DataTable();
DataColumn ID = new DataColumn("ID", Type.GetType("System.String"));
DataColumn MainId = new DataColumn("MainId", Type.GetType("System.String"));
DataColumn StationSubName = new DataColumn("StationSubName", Type.GetType("System.String"));
DataColumn Station_Weight_Medium = new DataColumn("Station_Weight_Medium", Type.GetType("System.String"));
DataColumn Station_Weight_Low = new DataColumn("Station_Weight_Low", Type.GetType("System.String"));
DataColumn Station_Weight_Advance = new DataColumn("Station_Weight_Advance", Type.GetType("System.String"));
DataColumn Station_Speed_Hight = new DataColumn("Station_Speed_Hight", Type.GetType("System.String"));
DataColumn Station_Speed_Medium = new DataColumn("Station_Speed_Medium", Type.GetType("System.String"));
DataColumn Station_Speed_Low = new DataColumn("Station_Speed_Low", Type.GetType("System.String"));
//DataColumn Station_CreateDateTime = new DataColumn("reateDateTime", Type.GetType("System.String"));
dataTable.Columns.Add(ID);
dataTable.Columns.Add(MainId);
dataTable.Columns.Add(StationSubName);
dataTable.Columns.Add(Station_Weight_Medium);
dataTable.Columns.Add(Station_Weight_Low);
dataTable.Columns.Add(Station_Weight_Advance);
dataTable.Columns.Add(Station_Speed_Hight);
dataTable.Columns.Add(Station_Speed_Medium);
dataTable.Columns.Add(Station_Speed_Low);
//dataTable.Columns.Add(Station_CreateDateTime);
for (int i = 0; i < subList.Count; i++)
{
DataRow dataRow = dataTable.NewRow();
dataRow["ID"] = subList[i].ID.ToString();
dataRow["MainId"] = subList[i].MainId.ToString();
dataRow["StationSubName"] = subList[i].StationSubName.ToString();
dataRow["Station_Weight_Medium"] = subList[i].Station_Weight_Medium.ToString();
dataRow["Station_Weight_Low"] = subList[i].Station_Weight_Low.ToString();
dataRow["Station_Weight_Advance"] = subList[i].Station_Weight_Advance.ToString();
dataRow["Station_Speed_Hight"] = subList[i].Station_Speed_Hight.ToString();
dataRow["Station_Speed_Medium"] = subList[i].Station_Speed_Medium.ToString();
dataRow["Station_Speed_Low"] = subList[i].Station_Speed_Low.ToString();
//dataRow["CreateDateTime"] = subList[i].CreateDateTime.ToString();
dataTable.Rows.Add(dataRow);
}
}
return dataTable;
}
#endregion
#endregion
}
}