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/LjMaterial/FrmMaterial.cs

74 lines
2.1 KiB
C#

1 year ago
using System;
using System.Windows.Forms;
using Mesnac.Action.ChemicalWeighing.Entity;
namespace Mesnac.Action.ChemicalWeighing.LjMaterial
{
public partial class FrmMaterial : Form
{
private MaterialInfoType _materialInfoType;
private ActionType _actionType = ActionType.Add; //操作类型0-为添加1-为修改
public FrmMaterial(ActionType actionType)
{
this._actionType = actionType;
InitializeComponent();
}
public FrmMaterial(ActionType actionType, MaterialInfoType materialInfoType):this(actionType)
{
_materialInfoType = materialInfoType;
this.MNameTB.Text = materialInfoType.MaterialInfoTypeName;
}
private void btnOK_Click(object sender, EventArgs e)
{
var materialinfoTypeName = MNameTB.Text.Trim();
if (string.IsNullOrEmpty(materialinfoTypeName))
{
MessageBox.Show("物料名不能为空!!");
this.MNameTB.Focus();
return;
}
var exist = MaterialInfoTypeHelp.Exist(materialinfoTypeName);
if (_actionType == ActionType.Add && exist>0)
{
MessageBox.Show("物料名已经存在!!");
this.MNameTB.Focus();
return;
}
if (_actionType == ActionType.Modify && exist>0)
{
MessageBox.Show("物料名已经存在!!");
this.MNameTB.Focus();
return;
}
if (_actionType == ActionType.Add)
{
MaterialInfoTypeHelp.Add(materialinfoTypeName);
}
if (_actionType == ActionType.Modify)
{
MaterialInfoTypeHelp.Update(_materialInfoType.Id,materialinfoTypeName);
}
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
}
}