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.
126 lines
4.0 KiB
C#
126 lines
4.0 KiB
C#
using Mesnac.Action.ChemicalWeighing.BinManage;
|
|
using Mesnac.Action.ChemicalWeighing.Entity;
|
|
using Mesnac.Action.ChemicalWeighing.Entity.Barrel;
|
|
using Mesnac.Action.ChemicalWeighing.Entity.material;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.Barrel
|
|
{
|
|
public partial class FrmBarrel : Form
|
|
{
|
|
public Hw_Barrel bar = new Hw_Barrel();
|
|
ActionType _actionType;
|
|
public FrmBarrel()
|
|
{
|
|
InitializeComponent();
|
|
|
|
bar.BarrelID = Guid.NewGuid().ToString("N").ToUpper();
|
|
}
|
|
public FrmBarrel(ActionType type, Hw_Barrel _barrel)
|
|
{
|
|
InitializeComponent();
|
|
_actionType = type;
|
|
bar = _barrel;
|
|
|
|
this.txtBarrelName.Text = _barrel.BarrelName;
|
|
this.txtBarCode.Text = _barrel.BarCode;
|
|
this.txtMaterialID.Text = _barrel.MaterialID;
|
|
this.txtMaterialName.Text = _barrel.MaterialName;
|
|
//if (bar.IsEnable=="是")
|
|
//{
|
|
// this.chcIsEnable.Checked = true;
|
|
//}
|
|
//else
|
|
//{
|
|
// this.chcIsEnable.Checked = false;
|
|
//}
|
|
|
|
}
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
if (string.IsNullOrEmpty(txtBarrelName.Text))
|
|
{
|
|
MessageBox.Show("桶名称不能为空!!");
|
|
this.txtBarrelName.Focus();
|
|
return;
|
|
}
|
|
if (string.IsNullOrEmpty(txtBarCode.Text))
|
|
{
|
|
MessageBox.Show("桶条码不能为空!!");
|
|
this.txtBarCode.Focus();
|
|
return;
|
|
}
|
|
|
|
bar.BarrelName = this.txtBarrelName.Text;
|
|
bar.BarCode = this.txtBarCode.Text;
|
|
bar.MaterialID = this.txtMaterialID.Text;
|
|
bar.MaterialName = this.txtMaterialName.Text;
|
|
bar.IsEnable = chcIsEnable.Checked == true ? "是" : "否";
|
|
xl_material material = (xl_material)comboBox1.SelectedItem;
|
|
bar.Material_KeyID = material.ID;
|
|
bar.Material_KeyName = material.Material_name;
|
|
//当修改桶时 条码唯一性都需要验证
|
|
if (_actionType == ActionType.Add || (_actionType == ActionType.Modify))
|
|
{
|
|
DataTable dt = BarrelHelper.QueryIsExeBarrel(bar.BarCode, bar.ID);
|
|
//桶条码唯一性验证
|
|
if (dt != null)
|
|
{
|
|
MessageBox.Show("桶条码已存在!!请更换桶条码!!");
|
|
return;
|
|
}
|
|
}
|
|
|
|
this.DialogResult = System.Windows.Forms.DialogResult.OK;
|
|
}
|
|
|
|
private void button2_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化控件数据
|
|
/// </summary>
|
|
public void InitData()
|
|
{
|
|
List<xl_material> lst = BinHelper.GetXlMaterialList();
|
|
this.comboBox1.Items.Clear();
|
|
foreach (xl_material m in lst)
|
|
{
|
|
this.comboBox1.Items.Add(m);
|
|
}
|
|
this.comboBox1.DisplayMember = "Material_name";
|
|
this.comboBox1.ValueMember = "ID";
|
|
//当操作类型为修改时,将选中行的数据填入到修改窗体的对应控件中
|
|
if (this._actionType == ActionType.Modify)
|
|
{
|
|
foreach (xl_material m in this.comboBox1.Items)
|
|
{
|
|
if (m.ID == this.bar.Material_KeyID)
|
|
{
|
|
this.comboBox1.SelectedItem = m;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
private void FrmBarrel_Load(object sender, EventArgs e)
|
|
{
|
|
InitData();
|
|
}
|
|
}
|
|
}
|