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/LjStock/FrmStock.cs

89 lines
2.5 KiB
C#

using System;
using System.Windows.Forms;
using Mesnac.Action.ChemicalWeighing.LjMaterial;
namespace Mesnac.Action.ChemicalWeighing.LjStock
{
public partial class FrmStock : Form
{
public FrmStock()
{
InitializeComponent();
}
private StockView viewl;
public FrmStock(StockView view) : this()
{
this.viewl = view;
Init();
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void Init()
{
var dataTable = StockDbHelp.GetById(viewl.Id);
if (dataTable.Rows.Count == 1)
{
var dr = dataTable.Rows[0];
viewl.MTypeId = Convert.ToInt32(dr["MTypeId"]);
viewl.MId = Convert.ToInt32(dr["MId"]);
viewl.StockName = dr["StockName"].ToString();
this.TankName.Text = viewl.StockName;
this.TankName.Enabled = false;
}
var drpMtype = MaterialInfoTypeHelp.GetType();
DrpType.ValueMember = "Id";
DrpType.DisplayMember = "Name";
this.DrpType.DataSource = drpMtype;
foreach (MyNameValue combo in DrpType.Items)
{
if (combo.Id == viewl.MTypeId)
{
DrpType.SelectedItem = combo;
DrpType.Enabled = false;
break;
}
}
}
private void btnOK_Click(object sender, EventArgs e)
{
viewl.MId = Convert.ToInt32(comboBox2.SelectedValue);
viewl.MName = comboBox2.Text;
StockDbHelp.Update(viewl);
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
private void DrpType_SelectedIndexChanged(object sender, EventArgs e)
{
var nameValueCollection = MaterialInfoTypeHelp.GetALLByTypeId(Convert.ToInt32(DrpType.SelectedValue));
this.comboBox2.DataSource = nameValueCollection;
comboBox2.ValueMember = "Id";
comboBox2.DisplayMember = "Name";
foreach (MyNameValue combo in comboBox2.Items)
{
if (combo.Id == viewl.MId)
{
comboBox2.SelectedItem = combo;
break;
}
}
}
}
}