diff --git a/MainWindow.xaml b/MainWindow.xaml index 077e102..d595d72 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -171,7 +171,7 @@ Text="{Binding PRODUCT_CODE}" IsTextSearchEnabled="True" StaysOpenOnEdit="True" BorderBrush="{x:Null}" Background="{x:Null}" IsEditable="True" KeyDown="CP_PRODUCT_CODE_KeyUp" - LostFocus="CP_PRODUCT_CODE_LostFocus"> + DropDownClosed="CP_PRODUCT_CODE_DropDownClosed"> @@ -204,6 +204,7 @@ ItemsSource="{Binding stuff_Product, Source={StaticResource MainWindowViewModel}}" DisplayMemberPath="ProductName" Text="{Binding PRODUCT_NAME}" + DropDownClosed="CP_PRODUCT_NAME_DropDownClosed" BorderBrush="{x:Null}" Background="{x:Null}" IsEditable="True" IsReadOnly="True" Focusable="True" IsTabStop="False"/> diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index e7aef92..e01e4b0 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -131,6 +131,10 @@ namespace formula_manage { Connstr_SC = "server=" + TEXT_SQLIP + ";database=" + TEXT_SQLNAME + ";User ID=" + TEXT_SQLUSER + ";Password=" + TEXT_SQLPASWOR; } + + list_Weight.Text = Configini.IniReadvalue("SOFTWARE_SET", "T4"); //自定义 + list_Proportion.Text = Configini.IniReadvalue("SOFTWARE_SET", "T5"); //自定义 + list_Total.Text =(double.Parse(list_Proportion.Text)* double.Parse(list_Weight.Text)).ToString(); } private async void Permissions_() @@ -463,17 +467,44 @@ namespace formula_manage if (e.Key == Key.Enter) { System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox; + int grid_row = Grid_RRODUCT.SelectedIndex; //获取当前行 + Code_ = curComboBox.Text; - if (Code_ == "") return; + if (Code_ == "") + { + if (Procedures_N.Text == Procedures_P.Text) + { + MessageBoxResult P = System.Windows.MessageBox.Show("是否保存", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); //提示 + if (P == MessageBoxResult.Cancel) { } + return; + } + else + { + MessageBoxResult P = System.Windows.MessageBox.Show("是否进入下一步", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); //提示 + if (P == MessageBoxResult.Cancel) return; + + Procedures_P.Text = (int.Parse(Procedures_P.Text) + 1).ToString(); + PressKey.PressKeys(Keys.Tab, false); + PressKey.PressKeys(Keys.Tab, true); + return; - DataRow[] r = MainWindowViewModel.STUFFdatatemp.Select("ProductCode ='" + Code_ + "'"); + } + } - if (!r.Any()) + DataRow[] r = MainWindowViewModel.STUFFdatatemp.Select("ProductCode ='" + Code_ + "'"); //查询判断原料代码是否有效 + if (!r.Any()) //检查原料信息 { System.Windows.MessageBox.Show("原料不存在"); curComboBox.Text = ""; return; - } + } + + DataRow[] c = RRODUCTdataTable.Select("PRODUCT_CODE ='" + Code_ + "'");//查询判断原料代码是否重复 + if (c.Any()) + { + System.Windows.MessageBox.Show("重复原料"); + return; + } Name_ = r[0].ItemArray[1].ToString(); Type_ = r[0].ItemArray[2].ToString(); @@ -512,21 +543,31 @@ namespace formula_manage } } - DataRow row = RRODUCTdataTable.Rows[ID_N-1]; //ID列 + if (grid_row == -1) grid_row = 0; + DataRow row = RRODUCTdataTable.Rows[grid_row]; //ID列 row.BeginEdit(); row["PRODUCT_CODE"] = Code_; row["PRODUCT_NAME"] = Name_; row["SHIFT"] = Type_; row.EndEdit(); - - - PressKey.PressKeys(Keys.Right, false); - PressKey.PressKeys(Keys.Right, true); - PressKey.PressKeys(Keys.Tab, false); - PressKey.PressKeys(Keys.Tab, true); + if (grid_row == (ID_N - 1)) + { + PressKey.PressKeys(Keys.Right, false); + PressKey.PressKeys(Keys.Right, true); + PressKey.PressKeys(Keys.Tab, false); + PressKey.PressKeys(Keys.Tab, true); + } + else + { + PressKey.PressKeys(Keys.Right, false); + PressKey.PressKeys(Keys.Right, true); + PressKey.PressKeys(Keys.Up, false); + PressKey.PressKeys(Keys.Up, true); + PressKey.PressKeys(Keys.Tab, false); + PressKey.PressKeys(Keys.Tab, true); + } } DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid - } private void CP_CONC_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)//目标饱和度输入事件 @@ -535,6 +576,7 @@ namespace formula_manage double conc=0; System.Windows.Controls.TextBox curTextBox = sender as System.Windows.Controls.TextBox; + int grid_row = Grid_RRODUCT.SelectedIndex; //获取当前行 if (e.Key == Key.Enter) { @@ -542,6 +584,7 @@ namespace formula_manage { System.Windows.MessageBox.Show("错误,重新输入"); curTextBox.Text = ""; + return; } else { @@ -552,45 +595,150 @@ namespace formula_manage curTextBox.Text = ""; return; } + else + { + double Weight_t = Weight_ * conc; + + DataRow row = RRODUCTdataTable.Rows[grid_row]; //ID列 + row.BeginEdit(); + row["STEP"] = Procedures_P.Text; + row["CONC"] = string.Format("{0:N6}", conc); + row["TARGET_WT"] = string.Format("{0:N3}", Weight_t); + row.EndEdit(); + + if (grid_row == (ID_N - 1)) + { + PressKey.PressKeys(Keys.Left, false); + PressKey.PressKeys(Keys.Left, true); + PressKey.PressKeys(Keys.Tab, false); + PressKey.PressKeys(Keys.Tab, true); + + DataRow rowadd = RRODUCTdataTable.NewRow(); //ID列 + rowadd = RRODUCTdataTable.NewRow(); + ID_N++; + rowadd["ID"] = ID_N; + // row["STEP"] = "1"; + rowadd["UNIT"] = "g"; + // row["STEP"] = Procedures_P.Text; + RRODUCTdataTable.Rows.Add(rowadd); + } + } + DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid + } + } + } //目标饱和度输入事件 - Weight_ = Weight_* conc; + private void CP_PRODUCT_CODE_DropDownClosed(object sender, EventArgs e)//原料代码选择事件 + { + double ang; + + System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox; + int grid_row = Grid_RRODUCT.SelectedIndex; //获取当前行 - DataRow row = RRODUCTdataTable.Rows[ID_N - 1]; //ID列 - row.BeginEdit(); - row["TARGET_WT"] = Weight_; - row.EndEdit(); + Code_ = curComboBox.Text; + if (Code_ == "") + { + if (Procedures_N.Text == Procedures_P.Text) + { + MessageBoxResult P = System.Windows.MessageBox.Show("是否保存", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); //提示 + if (P == MessageBoxResult.Cancel) { } + return; + } + else + { + MessageBoxResult P = System.Windows.MessageBox.Show("是否进入下一步", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); //提示 + if (P == MessageBoxResult.Cancel) return; - PressKey.PressKeys(Keys.Left, false); - PressKey.PressKeys(Keys.Left, true); + Procedures_P.Text = (int.Parse(Procedures_P.Text) + 1).ToString(); PressKey.PressKeys(Keys.Tab, false); PressKey.PressKeys(Keys.Tab, true); + return; - DataRow rowadd = RRODUCTdataTable.NewRow(); //ID列 - rowadd = RRODUCTdataTable.NewRow(); - ID_N++; - rowadd["ID"] = ID_N; - // row["STEP"] = "1"; - rowadd["UNIT"] = "g"; - // row["STEP"] = Procedures_P.Text; - RRODUCTdataTable.Rows.Add(rowadd); + } + } - DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid + DataRow[] r = MainWindowViewModel.STUFFdatatemp.Select("ProductCode ='" + Code_ + "'"); //查询判断原料代码是否有效 + if (!r.Any()) //检查原料信息 + { + System.Windows.MessageBox.Show("原料不存在"); + curComboBox.Text = ""; + return; + } + + DataRow[] c = RRODUCTdataTable.Select("PRODUCT_CODE ='" + Code_ + "'");//查询判断原料代码是否重复 + if (c.Any()) + { + System.Windows.MessageBox.Show("重复原料"); + return; + } + + Name_ = r[0].ItemArray[1].ToString(); + Type_ = r[0].ItemArray[2].ToString(); + Conc_ = r[0].ItemArray[3].ToString(); + + if (double.TryParse(list_Weight.Text, out ang)) + { + Weight_ = double.Parse(list_Weight.Text) * double.Parse(Conc_) / 100; + } + + 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"; - private void CP_PRODUCT_CODE_LostFocus(object sender, RoutedEventArgs e) - { - /* System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox; - string a = curComboBox.Text; + if (double.TryParse(list_Total.Text, out ang)) + { + Weight_ = double.Parse(list_Total.Text) * double.Parse(Conc_) / 100; + } + else + { + System.Windows.MessageBox.Show("请先确认重量及浴比"); + return; + } + } - DataTable data = null; - if (a != "") + if (grid_row == -1) grid_row = 0; + DataRow row = RRODUCTdataTable.Rows[grid_row]; //ID列 + row.BeginEdit(); + row["PRODUCT_CODE"] = Code_; + row["PRODUCT_NAME"] = Name_; + row["SHIFT"] = Type_; + row.EndEdit(); + if (grid_row == (ID_N - 1)) + { + PressKey.PressKeys(Keys.Right, false); + PressKey.PressKeys(Keys.Right, true); + PressKey.PressKeys(Keys.Tab, false); + PressKey.PressKeys(Keys.Tab, true); + } + else { - data = MainWindowViewModel.STUFFdatatemp.Select("ProductCode ='" + a + "'").CopyToDataTable(); - //Grid_RRODUCT.ItemsSource = data.Columns.//Add("ProductName").ToString(); + PressKey.PressKeys(Keys.Right, false); + PressKey.PressKeys(Keys.Right, true); + PressKey.PressKeys(Keys.Up, false); + PressKey.PressKeys(Keys.Up, true); + PressKey.PressKeys(Keys.Tab, false); + PressKey.PressKeys(Keys.Tab, true); + } + + DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid + } + + private void CP_PRODUCT_NAME_DropDownClosed(object sender, EventArgs e)//原料名选择事件 + { - }*/ } } } diff --git a/Windows/APP_set.xaml b/Windows/APP_set.xaml index 2c83b02..977c546 100644 --- a/Windows/APP_set.xaml +++ b/Windows/APP_set.xaml @@ -20,6 +20,10 @@ + + + + diff --git a/Windows/APP_set.xaml.cs b/Windows/APP_set.xaml.cs index 7adb080..0ab0d74 100644 --- a/Windows/APP_set.xaml.cs +++ b/Windows/APP_set.xaml.cs @@ -45,6 +45,8 @@ namespace formula_manage.Windows Configini.IniWritevalue("SOFTWARE_SET", " T1", Prepose.Text); Configini.IniWritevalue("SOFTWARE_SET", " T2", TimeFormat.Text); Configini.IniWritevalue("SOFTWARE_SET", " T3", Order.Text); + Configini.IniWritevalue("SOFTWARE_SET", " T4", Weight.Text); + Configini.IniWritevalue("SOFTWARE_SET", " T5", Proportion.Text); System.IO.DirectoryInfo log = new System.IO.DirectoryInfo(@logpath);//生成日志文件目录 FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write); @@ -70,7 +72,8 @@ namespace formula_manage.Windows Prepose.Text = Configini.IniReadvalue("SOFTWARE_SET", "T1"); //自定义料单前缀 TimeFormat.Text = Configini.IniReadvalue("SOFTWARE_SET", "T2"); //自定义料单时间格式 Order.Text = Configini.IniReadvalue("SOFTWARE_SET", "T3"); //自定义料单排序 - + Weight.Text = Configini.IniReadvalue("SOFTWARE_SET", "T4"); //自定义 + Proportion.Text = Configini.IniReadvalue("SOFTWARE_SET", "T5"); //自定义 } private void Login_LINK_Checked(object sender, RoutedEventArgs e) {