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.

110 lines
3.6 KiB
C#

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.XtraRichEdit.Fields.Expression;
namespace Mesnac.Action.ChemicalWeighing.Warehouse
{
/// <summary>
/// 投料管理
/// </summary>
public class ModifyAction : ChemicalWeighingAction, IAction
{
#region 字段定义
private RuntimeParameter _runtime;
private DbMCControl _clientGridControl = null;
#endregion
#region 事件定义
/// <summary>
/// 修改计划数事件定义
/// </summary>
public static event EventHandler OnModify;
#endregion
#region 业务入口
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须要调用的
this._runtime = runtime;
ICSharpCode.Core.LoggingService<ModifyAction>.Debug("投料管理-修改");
try
{
#region 1 获取界面控件
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Hw_WareHouse_Sub").FirstOrDefault();
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
{
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{投料管理—编辑}缺少物料管理控件...");
return;
}
this._clientGridControl = clientGridControl;
this._runtime = runtime;
DataGridView clientGridView = this._clientGridControl.BaseControl as DataGridView;
#endregion
#region 2 判断是否选择了要修改的物料
if (clientGridView.SelectedRows.Count != 1)
{
MessageBox.Show("请选择一条要修改的物料", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
this._runtime.IsReturn = true;
return;
}
#endregion
int selectId = (int)clientGridView.SelectedRows[0].Cells["ID"].Value;
Hw_WareHouse_Sub sub = WarehouseHelper.GetWareHouseMaterialId(selectId);
FrmNewMaterial frmNewMaterial = new FrmNewMaterial(ActionType.Modify, sub);
frmNewMaterial.ShowDialog(this._runtime.BaseControl.MCRoot as Control);
if (frmNewMaterial.DialogResult == DialogResult.OK)
{
var ware = frmNewMaterial._sub;
WarehouseHelper.UpdateWareHouseSub(ware);
#region 触发事件
if (OnModify != null)
{
OnModify(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
#endregion
frmNewMaterial.Dispose();
MessageBox.Show("修改物料成功!");
}
else
{
frmNewMaterial.Dispose();
}
}
catch (Exception ex)
{
ICSharpCode.Core.LoggingService<ModifyAction>.Error("修改物料失败:" + ex.Message, ex);
MessageBox.Show(ex.Message, Mesnac.Basic.LanguageHelper.ErrorCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
#endregion
}
}