|
|
|
|
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 System.Drawing;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.PumpManage
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除计划业务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class DeleteAction : ChemicalWeighingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
#region 事件定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除计划事件定义
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static event EventHandler OnDeletePump;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 字段定义
|
|
|
|
|
|
|
|
|
|
private RuntimeParameter _runtime;
|
|
|
|
|
private DbMCControl _clientGridControl = null;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region IAction接口实现
|
|
|
|
|
|
|
|
|
|
public void Run(RuntimeParameter runtime)
|
|
|
|
|
{
|
|
|
|
|
base.RunIni(runtime);
|
|
|
|
|
this._runtime = runtime;
|
|
|
|
|
|
|
|
|
|
ICSharpCode.Core.LoggingService<DeleteAction>.Debug("投料泵管理—删除投料泵业务...");
|
|
|
|
|
|
|
|
|
|
DbMCControl clientGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Pmt_recipe").FirstOrDefault();
|
|
|
|
|
if (clientGridControl == null || !(clientGridControl.BaseControl is DataGridView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{投料泵管理—删除配方}缺少投料泵控件...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
this._clientGridControl = clientGridControl;
|
|
|
|
|
this.DoWork();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 方法定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected void DoWork()
|
|
|
|
|
{
|
|
|
|
|
this._runtime.BaseControl.MCEnabled = false;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DataGridView clientGridView = this._clientGridControl.BaseControl as DataGridView;
|
|
|
|
|
|
|
|
|
|
#region 1 变量定义
|
|
|
|
|
|
|
|
|
|
string selectId = clientGridView.SelectedRows[0].Cells["ID"].Value as string;
|
|
|
|
|
if (string.IsNullOrEmpty(selectId))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("未获到要删除泵信息?", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this._runtime.IsReturn = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 2 判断是否选择了要删除的物料
|
|
|
|
|
|
|
|
|
|
if (clientGridView.SelectedRows.Count != 1)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请选择一条要删除的泵信息吗?", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this._runtime.IsReturn = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//删除配方前询问
|
|
|
|
|
string msg1 = "确认删除当前信息吗?";
|
|
|
|
|
DialogResult result = MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
if (result == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
#region 执行删除操作
|
|
|
|
|
|
|
|
|
|
IFreeSql _freeSql = DBHelper.FreeHelper.Instance;
|
|
|
|
|
var t4 = _freeSql.Delete<Hw_Pump>(new { ID = int.Parse(selectId) }).ExecuteAffrows();
|
|
|
|
|
if (t4<=0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("泵信息删除失败!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 触发事件
|
|
|
|
|
if (OnDeletePump != null)
|
|
|
|
|
{
|
|
|
|
|
OnDeletePump(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
MessageBox.Show("泵信息删除成功!");
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<InsertAction>.Error("删除计划异常:" + ex.Message, ex);
|
|
|
|
|
|
|
|
|
|
#region 记录操作日志
|
|
|
|
|
|
|
|
|
|
base.DBLog(ex.Message);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
MessageBox.Show(ex.Message, Mesnac.Basic.LanguageHelper.WarnCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
this._runtime.BaseControl.MCEnabled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|