|
|
|
|
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.Technical.PmtRecipe.entity;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Technical.PmtRecipe
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除计划业务
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class DeleteAction : ChemicalWeighingAction, IAction
|
|
|
|
|
{
|
|
|
|
|
#region 事件定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除计划事件定义
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static event EventHandler OnDeleteRecipe;
|
|
|
|
|
|
|
|
|
|
#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("配方管理—删除配方业务...");
|
|
|
|
|
|
|
|
|
|
List<DbMCControl> recipeControlList = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "Base_RecipeInfo");
|
|
|
|
|
|
|
|
|
|
DbMCControl recipeTreeGridControl = recipeControlList.Where(x => x.BaseControl is TreeView).FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (recipeTreeGridControl == null || !(recipeTreeGridControl.BaseControl is TreeView))
|
|
|
|
|
{
|
|
|
|
|
ICSharpCode.Core.LoggingService<RefreshAction>.Error("{配方管理—删除配方}缺少配方管理控件...");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._clientGridControl = recipeTreeGridControl;
|
|
|
|
|
this.DoWork();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 方法定义
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 删除计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected void DoWork()
|
|
|
|
|
{
|
|
|
|
|
this._runtime.BaseControl.MCEnabled = false;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
TreeView clientGridView = this._clientGridControl.BaseControl as TreeView;
|
|
|
|
|
|
|
|
|
|
#region 1 变量定义
|
|
|
|
|
|
|
|
|
|
string selectRecipeName = null;
|
|
|
|
|
string selectRecipeId = null;
|
|
|
|
|
Base_RecipeInfo pmt_Recipe = null;
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 2 判断是否选择了要修改的配方
|
|
|
|
|
|
|
|
|
|
if (clientGridView.SelectedNode == null)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请选择一条要删除的配方!", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this._runtime.IsReturn = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 3 判断该配方是否可进行删除(如果配方正在RT_Plan表中,查不允许删除)
|
|
|
|
|
|
|
|
|
|
selectRecipeName = clientGridView.SelectedNode.Text as string;
|
|
|
|
|
selectRecipeId = clientGridView.SelectedNode.Name as string;
|
|
|
|
|
if (Product.PptPlan.PlanHelper.PlanExistsRecipeName(selectRecipeName))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("该配方正在计划列表中,不能进行删除!", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
this._runtime.IsReturn = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//删除配方前询问
|
|
|
|
|
string msg1 = StringParser.Parse(ResourceService.GetString("Mesnac_Action_ChemicalWeighing_Technical_PmtRecipe_DeleteAction_msg1")); //确认删除当前配方(配方名:{0})吗?
|
|
|
|
|
msg1 = String.Format(msg1, selectRecipeName);
|
|
|
|
|
DialogResult result = MessageBox.Show(msg1, Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
|
|
|
|
if (result == DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
#region 4 获取配方实体
|
|
|
|
|
|
|
|
|
|
pmt_Recipe = RecipeHelper.GetRecipeById(selectRecipeId);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 5 执行删除操作
|
|
|
|
|
|
|
|
|
|
if (pmt_Recipe != null)
|
|
|
|
|
{
|
|
|
|
|
#region 5.1 删除配方信息
|
|
|
|
|
|
|
|
|
|
RecipeHelper.DeleteRecipe(pmt_Recipe.recipeId);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 5.2 删除配方对应物料信息
|
|
|
|
|
|
|
|
|
|
RecipeHelper.DelWeighByRecipeID(pmt_Recipe.recipeId);
|
|
|
|
|
|
|
|
|
|
//删除配方对应的工艺参数
|
|
|
|
|
RecipeHelper.DelCratParamByRecipeId(pmt_Recipe.recipeId);
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 5.3 触发事件
|
|
|
|
|
|
|
|
|
|
if (OnDeleteRecipe != null)
|
|
|
|
|
{
|
|
|
|
|
OnDeleteRecipe(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
|
|
|
|
|
}
|
|
|
|
|
}
|