diff --git a/MainWindow.xaml b/MainWindow.xaml index 2e78d03..077e102 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -180,7 +180,8 @@ + BorderBrush="{x:Null}" Background="{x:Null}" + KeyDown="CP_CONC_KeyUp"/> @@ -188,7 +189,8 @@ + 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 da9e720..775ae14 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -450,19 +450,46 @@ namespace formula_manage } } - private void CP_PRODUCT_CODE_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) + string Type_; + string Conc_; + double Weight_=0; + + private void CP_PRODUCT_CODE_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)//原料代码输入 { + double ang; if (e.Key == Key.Enter) { System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox; string a = curComboBox.Text; if (a == "") return; + DataRow[] r = MainWindowViewModel.STUFFdatatemp.Select("ProductCode ='" + a + "'"); + + if (!r.Any()) + { + System.Windows.MessageBox.Show("原料不存在"); + curComboBox.Text = ""; + return; + } + + + string 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; + } + + + //RRODUCTdataTable.Load(r.ElementAt(1).ToString()); + + + PressKey.PressKeys(Keys.Right, false); PressKey.PressKeys(Keys.Right, true); PressKey.PressKeys(Keys.Tab, false); PressKey.PressKeys(Keys.Tab, true); - } DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid @@ -491,7 +518,6 @@ namespace formula_manage curTextBox.Text = ""; return; } - PressKey.PressKeys(Keys.Left, false); PressKey.PressKeys(Keys.Left, true); PressKey.PressKeys(Keys.Tab, false); @@ -513,7 +539,7 @@ namespace formula_manage private void CP_PRODUCT_CODE_LostFocus(object sender, RoutedEventArgs e) { - System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox; + /* System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox; string a = curComboBox.Text; DataTable data = null; @@ -522,7 +548,7 @@ namespace formula_manage data = MainWindowViewModel.STUFFdatatemp.Select("ProductCode ='" + a + "'").CopyToDataTable(); //Grid_RRODUCT.ItemsSource = data.Columns.//Add("ProductName").ToString(); - } + }*/ } } }