diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 07f58d9..e7aef92 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -451,6 +451,7 @@ namespace formula_manage } } + string Code_; string Name_; string Type_; string Conc_; @@ -462,7 +463,7 @@ namespace formula_manage if (e.Key == Key.Enter) { System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox; - string Code_ = curComboBox.Text; + Code_ = curComboBox.Text; if (Code_ == "") return; DataRow[] r = MainWindowViewModel.STUFFdatatemp.Select("ProductCode ='" + Code_ + "'"); @@ -472,9 +473,7 @@ namespace formula_manage System.Windows.MessageBox.Show("原料不存在"); curComboBox.Text = ""; return; - } - - + } Name_ = r[0].ItemArray[1].ToString(); Type_ = r[0].ItemArray[2].ToString(); @@ -485,10 +484,33 @@ namespace formula_manage Weight_ = double.Parse(list_Weight.Text) * double.Parse(Conc_) / 100; } - if ((Type_ == "0") || (Type_ == "3")) Type_ = "%"; - if ((Type_ == "1") || (Type_ == "2")) Type_ = "g/L"; + if ((Type_ == "0") || (Type_ == "3")) + { + Type_ = "%"; + if (double.TryParse(list_Weight.Text, out ang)) + { + Weight_ = double.Parse(list_Weight.Text) * double.Parse(Conc_) *10; + } + else + { + System.Windows.MessageBox.Show("请先确认重量及浴比"); + return; + } + } + if ((Type_ == "1") || (Type_ == "2")) + { + Type_ = "g/L"; - //RRODUCTdataTable.Load(r.ElementAt(1).ToString()); + if (double.TryParse(list_Total.Text, out ang)) + { + Weight_ = double.Parse(list_Total.Text) * double.Parse(Conc_) / 100; + } + else + { + System.Windows.MessageBox.Show("请先确认重量及浴比"); + return; + } + } DataRow row = RRODUCTdataTable.Rows[ID_N-1]; //ID列 row.BeginEdit(); @@ -530,19 +552,27 @@ namespace formula_manage curTextBox.Text = ""; return; } + + Weight_ = Weight_* conc; + + DataRow row = RRODUCTdataTable.Rows[ID_N - 1]; //ID列 + row.BeginEdit(); + row["TARGET_WT"] = Weight_; + row.EndEdit(); + PressKey.PressKeys(Keys.Left, false); PressKey.PressKeys(Keys.Left, true); PressKey.PressKeys(Keys.Tab, false); PressKey.PressKeys(Keys.Tab, true); - DataRow row = RRODUCTdataTable.NewRow(); //ID列 - row = RRODUCTdataTable.NewRow(); + DataRow rowadd = RRODUCTdataTable.NewRow(); //ID列 + rowadd = RRODUCTdataTable.NewRow(); ID_N++; - row["ID"] = ID_N; + rowadd["ID"] = ID_N; // row["STEP"] = "1"; - row["UNIT"] = "g"; + rowadd["UNIT"] = "g"; // row["STEP"] = Procedures_P.Text; - RRODUCTdataTable.Rows.Add(row); + RRODUCTdataTable.Rows.Add(rowadd); DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid }