|
|
|
|
using ICSharpCode.Core;
|
|
|
|
|
using Mesnac.Action.Base;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.XlMaterialManage
|
|
|
|
|
{
|
|
|
|
|
class DeleteMaterialAction : ChemicalWeighingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
#region 事件定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除物料事件定义
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static event EventHandler OnDeleteMaterial;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 字段定义
|
|
|
|
|
|
|
|
|
|
private RuntimeParameter _runtime;
|
|
|
|
|
private DbMCControl _clientGridControl = null; //物料信息控件
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.RunIni(runtime); //必须调用
|
|
|
|
|
this._runtime = runtime;
|
|
|
|
|
|
|
|
|
|
DbMCControl materialDGV = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "xl_material").FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (materialDGV == null)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<DeleteMaterialAction>.Error("删除物料失败:未知列表项");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this._clientGridControl = materialDGV;
|
|
|
|
|
this.DoWork();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 删除物料方法定义
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据ID删除物料
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected void DoWork()
|
|
|
|
|
{
|
|
|
|
|
this._runtime.BaseControl.MCEnabled = false;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DataGridView clientGridView = this._clientGridControl.BaseControl as DataGridView;
|
|
|
|
|
if (clientGridView.SelectedRows.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
string mID = clientGridView.SelectedRows[0].Cells["ID"].Value as string;
|
|
|
|
|
string mName = clientGridView.SelectedRows[0].Cells["Material_name"].Value as string;
|
|
|
|
|
string msg1 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_MaterialManage_DeleteMaterialAction_msg1")); //确认删除当前物料(物料名:{0})吗?
|
|
|
|
|
msg1 = String.Format(msg1, mName);
|
|
|
|
|
DialogResult result = MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
if (result == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
//删除本地数据库中的用户信息
|
|
|
|
|
MaterialHelper.deleteMaterial(mID);
|
|
|
|
|
|
|
|
|
|
#region 触发事件
|
|
|
|
|
|
|
|
|
|
if (OnDeleteMaterial != null)
|
|
|
|
|
{
|
|
|
|
|
OnDeleteMaterial(null, System.EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string msg2 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_MaterialManage_DeleteMaterialAction_msg2")); //请选择一条要删除物料信息!
|
|
|
|
|
MessageBox.Show(msg2, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<DeleteMaterialAction>.Error("删除物料异常:" + ex.Message, ex);
|
|
|
|
|
MessageBox.Show(ex.Message, Mesnac.Basic.LanguageHelper.WarnCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
this._runtime.BaseControl.MCEnabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|