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.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/LjPlanning/DelAction.cs

72 lines
2.2 KiB
C#

1 year ago
using System;
1 year ago
using System.Collections.Generic;
1 year ago
using System.Linq;
using System.Windows.Forms;
using Mesnac.Action.Base;
namespace Mesnac.Action.ChemicalWeighing.LjPlanning
{
public class DelAction:ChemicalWeighingAction, IAction
{
private DbMCControl _materialGridControl = null; //物料列表控件
private RuntimeParameter _runtime;
1 year ago
public static event EventHandler OnDelete;
1 year ago
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
this._runtime = runtime;
DbMCControl materialGridControl =
this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "lj_planning")
.FirstOrDefault(); //获取物料数据控件
this._materialGridControl = materialGridControl;
DataGridView clientGridView = this._materialGridControl.BaseControl as DataGridView;
1 year ago
1 year ago
//验证是否选中某物料
if (clientGridView.SelectedRows.Count != 1)
{
1 year ago
MessageBox.Show("请选择要修改的数据", Mesnac.Basic.LanguageHelper.Caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
1 year ago
this._runtime.IsReturn = true;
return;
}
1 year ago
List<int> ls = new List<int>()
{
0
};
if (MessageBox.Show("确定删除?", "删除确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
var dataGridViewRow = clientGridView.SelectedRows[0];
var id = Convert.ToInt32(dataGridViewRow.Cells["Id"].Value);
var status=LjPlanningDb.GetStatusById(id);
if (ls.Contains(status))
{
LjPlanningDb.SoftDel(id);
}
else
{
MessageBox.Show("禁止删除");
}
}
else
{
return;
}
1 year ago
if (OnDelete != null)
{
OnDelete(this._runtime.BaseControl.MCRoot, System.EventArgs.Empty);
}
1 year ago
}
}
}