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/LjTanNum/FrmTankNum.cs

105 lines
3.2 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows.Forms;
using Mesnac.Action.ChemicalWeighing.LjMaterial;
namespace Mesnac.Action.ChemicalWeighing.LjTanNum
{
public partial class FrmTankNum : Form
{
public FrmTankNum()
{
InitializeComponent();
}
private TankNumCodingView _tankNumCodingView;
public FrmTankNum(TankNumCodingView view) : this()
{
_tankNumCodingView = view;
var dataTable = TankNumCodingDbHelp.GetById(view.Id);
if (dataTable.Rows.Count == 1)
{
var da = dataTable.Rows[0];
_tankNumCodingView.MTypeId = Convert.ToInt32(da["MTypeId"]);
_tankNumCodingView.MId = Convert.ToInt32(da["MId"]);
_tankNumCodingView.DayBinName = da["DayBinName"].ToString();
this.DayBinName.Text = _tankNumCodingView.DayBinName;
this.DayBinName.Enabled = false;
}
Init();
}
private void Init()
{
var drpMtype = MaterialInfoTypeHelp.GetType();
DrpType.ValueMember = "Id";
DrpType.DisplayMember = "Name";
this.DrpType.DataSource = drpMtype;
foreach (MyNameValue combo in DrpType.Items)
{
if (combo.Id == _tankNumCodingView.MTypeId)
{
DrpType.SelectedItem = combo;
break;
}
}
//
// var nameValueCollection = MaterialInfoTypeHelp.GetALLByTypeId(Convert.ToInt32(DrpType.SelectedValue));
// this.comboBox1.DataSource = nameValueCollection;
// comboBox1.ValueMember = "Id";
// comboBox1.DisplayMember = "Name";
//
//
// foreach (MyNameValue combo in comboBox1.Items)
// {
// if (combo.Id == _tankNumCodingView.MId)
// {
// comboBox1.SelectedItem = combo;
// break;
// }
// }
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOK_Click(object sender, EventArgs e)
{
_tankNumCodingView.MTypeId =Convert.ToInt32(DrpType.SelectedValue);
_tankNumCodingView.MId =Convert.ToInt32(comboBox1.SelectedValue);
_tankNumCodingView.MTypeName = DrpType.Text;
_tankNumCodingView.MName = comboBox1.Text;
TankNumCodingDbHelp.Update(_tankNumCodingView);
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
private void DrpType_SelectedIndexChanged(object sender, EventArgs e)
{
var nameValueCollection = MaterialInfoTypeHelp.GetALLByTypeId(Convert.ToInt32(DrpType.SelectedValue));
this.comboBox1.DataSource = nameValueCollection;
comboBox1.ValueMember = "Id";
comboBox1.DisplayMember = "Name";
}
private void FrmTankNum_Load(object sender, EventArgs e)
{
}
}
}