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 Mesnac.Action.ChemicalWeighing.Entity.material;
namespace Mesnac.Action.ChemicalWeighing.Warehouse
{
///
/// 配方管理-选择数业务
///
public class SelectAction : ChemicalWeighingAction, IAction
{
#region 字段定义
private RuntimeParameter _runtime;
private DbMCControl _clientGridControl = null;
public static event EventHandler OnSelect;
#endregion
#region 业务入口
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用的
this._runtime = runtime;
#region 获取界面物料控件
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Hw_Warehouse").FirstOrDefault();
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService.Error("{投料釜管理—选择物料}缺少物料管理控件...");
return;
}
this._clientGridControl = clientGridControl;
#endregion
this.DoWork();
}
#endregion
#region 方法定义
protected void DoWork()
{
#region 1 判断是否选择了一条物料并显示物料信息
DataGridView materialGridView = this._clientGridControl.BaseControl as DataGridView;
if (materialGridView.SelectedRows.Count == 1)
{
#region 变量定义
int selectId;
#endregion
#region 2.1 获取界面weigh控件
DbMCControl gridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Hw_WareHouse_Sub").FirstOrDefault();
if (gridControl == null || !(gridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService.Error("{投料釜管理—选择物料}缺少物料显示控件...");
return;
}
DataGridView weighGridView = gridControl.BaseControl as DataGridView;
#endregion
#region 获取投料的物料信息List
selectId = (int)materialGridView.SelectedRows[0].Cells["ID"].Value;
#endregion
DataTable table = WarehouseHelper.GetMaterial(selectId);
lock (String.Empty)
{
//本地计划
if (gridControl != null && table != null)
{
gridControl.BaseControl.BindDataSource = null;
gridControl.BaseControl.BindDataSource = table;
}
else
{
gridControl.BaseControl.BindDataSource = null;
}
}
}
else
{
return;
}
#endregion
//if (OnSelect != null)
//{
// OnSelect(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
//}
}
#endregion
}
}