using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using DevExpress.Utils; using Mesnac.Action.ChemicalWeighing.LjMaterial; using Mesnac.Action.ChemicalWeighing.LjMetageFormula; using Mesnac.Action.ChemicalWeighing.LjMixFormula; namespace Mesnac.Action.ChemicalWeighing.LjMixManager { public partial class FrmMixA : Form { public FrmMixA() { InitializeComponent(); } private int _id = 0; public FrmMixA(int id) : this() { this._id = id; FillController(); } private LjMixManagerView view; private void FillController() { view = LjMixManagerDb.GetById(_id); IEnumerable ien = MetageFormulaDb.GetMetageNmaValue(); var drpA = ien.ToList(); FillComboBox(DrpMetageA); DrpMetageA.DataSource = drpA; Checked(DrpMetageA, view.MetageAId); var lsAMixList = MixDb.GetMyNameValueStrs(2); FillComboBox(DrpMixA); DrpMixA.DataSource = lsAMixList; Checked(DrpMixA,view.MixAId); } private void btnCancel_Click(object sender, EventArgs e) { this.Close(); } private void FillComboBox(ComboBox combo) { combo.ValueMember = "Id"; combo.DisplayMember = "Name"; } private void Checked(ComboBox alBox,string checkId) { foreach (MyNameValueStr combo in alBox.Items) { if (combo.Id == checkId) { alBox.SelectedItem = combo; break; } } } private void btnOK_Click(object sender, EventArgs e) { view.MetageAId = DrpMetageA.SelectedValue.ToString(); view.MetageAName = DrpMetageA.Text; view.MixAId = DrpMixA.SelectedValue.ToString(); view.MixAName = DrpMixA.Text; view.UpdateTime=DateTime.Now; LjMixManagerDb.UpdateMixA(view); view.Id = _id; this.DialogResult = DialogResult.OK; } } }