using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using Mesnac.Action.ChemicalWeighing.LjMaterial; using Mesnac.Action.ChemicalWeighing.LjMetageFormula; using Mesnac.Action.ChemicalWeighing.LjMixFormula; using Mesnac.Action.ChemicalWeighing.LjProdcutLine; namespace Mesnac.Action.ChemicalWeighing.LjPlanning { public partial class FrmPlanning : Form { public FrmPlanning() { InitializeComponent(); FillController(); } private int _id; private LjPlanningView view = new LjPlanningView(); public FrmPlanning(int id) : this() { } private List productLineViews; // private List lsList; private List lsAMixList; private List lsBMixList; private List lsCMixList; private void FillController() { productLineViews = ProductLineDb.GetList(); DrpProductLine.DataSource=productLineViews; FillComboBox(DrpProductLine); //var selectedIndex = DrpProductLine.SelectedIndex; //var productLineView = productLineViews[selectedIndex]; //this.label1.Text=productLineView.DryName; IEnumerable ien = MetageFormulaDb.GetMetageNmaValue(); var drpA = ien.ToList(); var drpB = ien.ToList(); var drpC = ien.ToList(); FillComboBox(DrpMetageA); DrpMetageA.DataSource = drpA; FillComboBox(DrpMetageB1); DrpMetageB1.DataSource = drpB; FillComboBox(DrpMetageB2); DrpMetageB2.DataSource = drpC; lsAMixList = MixDb.GetMyNameValueStrs(2); DrpMixA.DataSource = lsAMixList; FillComboBox(DrpMixA); lsBMixList= MixDb.GetMyNameValueStrs(1); DrpMixB.DataSource = lsBMixList; FillComboBox(DrpMixB); lsCMixList = MixDb.GetMyNameValueStrs(3); DrpMixC.DataSource = lsCMixList; FillComboBox(DrpMixC); } private void FillComboBox(ComboBox combo) { combo.ValueMember = "Id"; combo.DisplayMember = "Name"; } private void DrpProductLine_SelectedIndexChanged(object sender, System.EventArgs e) { var selectedIndex = DrpProductLine.SelectedIndex; var productLineView = productLineViews[selectedIndex]; this.label1.Text = productLineView.DryName; } private void btnCancel_Click(object sender, System.EventArgs e) { this.Close(); } private void btnOK_Click(object sender, System.EventArgs e) { string carNumber = txtCarNumber.Text.Trim(); if (string.IsNullOrEmpty(carNumber)) { MessageBox.Show(@"请输入车次"); return; } if (!int.TryParse(carNumber, out var carNo)) { MessageBox.Show(@"请输入正确的车次"); return; } view.CreateTime = DateTime.Now; view.UpdateTime = DateTime.Now; view.NumCar = carNo; view.MetageAId = DrpMetageA.SelectedValue.ToString(); view.MetageAName = DrpMetageA.Text; view.MixAId = DrpMetageA.SelectedValue.ToString(); view.MixAName = DrpMetageA.Text; view.MetageB1Id = DrpMetageB1.SelectedValue.ToString(); view.MetageB1Name= DrpMetageB1.Text; view.MetageB2Id = DrpMetageB2.SelectedValue.ToString(); view.MetageB2Name= DrpMetageB2.Text; view.MixBId= DrpMixB.SelectedValue.ToString(); view.MixBName=DrpMixB.Text; view.MixCId =DrpMixC.SelectedValue.ToString(); view.MixCName=DrpMixC.Text; if (_id == 0) { LjPlanningDb.Add(view); } } } }