sc 2 years ago
parent
commit
d6e4e0dd60
  1. 3
      MainWindow.xaml
  2. 188
      MainWindow.xaml.cs
  3. 4
      Windows/APP_set.xaml
  4. 5
      Windows/APP_set.xaml.cs

3
MainWindow.xaml

@ -171,7 +171,7 @@
Text="{Binding PRODUCT_CODE}" IsTextSearchEnabled="True" StaysOpenOnEdit="True" Text="{Binding PRODUCT_CODE}" IsTextSearchEnabled="True" StaysOpenOnEdit="True"
BorderBrush="{x:Null}" Background="{x:Null}" IsEditable="True" BorderBrush="{x:Null}" Background="{x:Null}" IsEditable="True"
KeyDown="CP_PRODUCT_CODE_KeyUp" KeyDown="CP_PRODUCT_CODE_KeyUp"
LostFocus="CP_PRODUCT_CODE_LostFocus"> DropDownClosed="CP_PRODUCT_CODE_DropDownClosed">
</ComboBox> </ComboBox>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
@ -204,6 +204,7 @@
ItemsSource="{Binding stuff_Product, Source={StaticResource MainWindowViewModel}}" ItemsSource="{Binding stuff_Product, Source={StaticResource MainWindowViewModel}}"
DisplayMemberPath="ProductName" DisplayMemberPath="ProductName"
Text="{Binding PRODUCT_NAME}" Text="{Binding PRODUCT_NAME}"
DropDownClosed="CP_PRODUCT_NAME_DropDownClosed"
BorderBrush="{x:Null}" Background="{x:Null}" IsEditable="True" IsReadOnly="True" Focusable="True" IsTabStop="False"/> BorderBrush="{x:Null}" Background="{x:Null}" IsEditable="True" IsReadOnly="True" Focusable="True" IsTabStop="False"/>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>

188
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; 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_() private async void Permissions_()
@ -463,18 +467,45 @@ namespace formula_manage
if (e.Key == Key.Enter) if (e.Key == Key.Enter)
{ {
System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox; System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox;
int grid_row = Grid_RRODUCT.SelectedIndex; //获取当前行
Code_ = curComboBox.Text; 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;
DataRow[] r = MainWindowViewModel.STUFFdatatemp.Select("ProductCode ='" + Code_ + "'"); Procedures_P.Text = (int.Parse(Procedures_P.Text) + 1).ToString();
PressKey.PressKeys(Keys.Tab, false);
PressKey.PressKeys(Keys.Tab, true);
return;
}
}
if (!r.Any()) DataRow[] r = MainWindowViewModel.STUFFdatatemp.Select("ProductCode ='" + Code_ + "'"); //查询判断原料代码是否有效
if (!r.Any()) //检查原料信息
{ {
System.Windows.MessageBox.Show("原料不存在"); System.Windows.MessageBox.Show("原料不存在");
curComboBox.Text = ""; curComboBox.Text = "";
return; return;
} }
DataRow[] c = RRODUCTdataTable.Select("PRODUCT_CODE ='" + Code_ + "'");//查询判断原料代码是否重复
if (c.Any())
{
System.Windows.MessageBox.Show("重复原料");
return;
}
Name_ = r[0].ItemArray[1].ToString(); Name_ = r[0].ItemArray[1].ToString();
Type_ = r[0].ItemArray[2].ToString(); Type_ = r[0].ItemArray[2].ToString();
Conc_ = r[0].ItemArray[3].ToString(); Conc_ = r[0].ItemArray[3].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.BeginEdit();
row["PRODUCT_CODE"] = Code_; row["PRODUCT_CODE"] = Code_;
row["PRODUCT_NAME"] = Name_; row["PRODUCT_NAME"] = Name_;
row["SHIFT"] = Type_; row["SHIFT"] = Type_;
row.EndEdit(); 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
{
PressKey.PressKeys(Keys.Right, false); PressKey.PressKeys(Keys.Right, false);
PressKey.PressKeys(Keys.Right, true); PressKey.PressKeys(Keys.Right, true);
PressKey.PressKeys(Keys.Up, false);
PressKey.PressKeys(Keys.Up, true);
PressKey.PressKeys(Keys.Tab, false); PressKey.PressKeys(Keys.Tab, false);
PressKey.PressKeys(Keys.Tab, true); PressKey.PressKeys(Keys.Tab, true);
} }
}
DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid
} }
private void CP_CONC_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)//目标饱和度输入事件 private void CP_CONC_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)//目标饱和度输入事件
@ -535,6 +576,7 @@ namespace formula_manage
double conc=0; double conc=0;
System.Windows.Controls.TextBox curTextBox = sender as System.Windows.Controls.TextBox; System.Windows.Controls.TextBox curTextBox = sender as System.Windows.Controls.TextBox;
int grid_row = Grid_RRODUCT.SelectedIndex; //获取当前行
if (e.Key == Key.Enter) if (e.Key == Key.Enter)
{ {
@ -542,6 +584,7 @@ namespace formula_manage
{ {
System.Windows.MessageBox.Show("错误,重新输入"); System.Windows.MessageBox.Show("错误,重新输入");
curTextBox.Text = ""; curTextBox.Text = "";
return;
} }
else else
{ {
@ -552,14 +595,19 @@ namespace formula_manage
curTextBox.Text = ""; curTextBox.Text = "";
return; return;
} }
else
{
double Weight_t = Weight_ * conc;
Weight_ = Weight_* conc; DataRow row = RRODUCTdataTable.Rows[grid_row]; //ID列
DataRow row = RRODUCTdataTable.Rows[ID_N - 1]; //ID列
row.BeginEdit(); row.BeginEdit();
row["TARGET_WT"] = Weight_; row["STEP"] = Procedures_P.Text;
row["CONC"] = string.Format("{0:N6}", conc);
row["TARGET_WT"] = string.Format("{0:N3}", Weight_t);
row.EndEdit(); row.EndEdit();
if (grid_row == (ID_N - 1))
{
PressKey.PressKeys(Keys.Left, false); PressKey.PressKeys(Keys.Left, false);
PressKey.PressKeys(Keys.Left, true); PressKey.PressKeys(Keys.Left, true);
PressKey.PressKeys(Keys.Tab, false); PressKey.PressKeys(Keys.Tab, false);
@ -573,24 +621,124 @@ namespace formula_manage
rowadd["UNIT"] = "g"; rowadd["UNIT"] = "g";
// row["STEP"] = Procedures_P.Text; // row["STEP"] = Procedures_P.Text;
RRODUCTdataTable.Rows.Add(rowadd); RRODUCTdataTable.Rows.Add(rowadd);
}
}
DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid
} }
} }
} //目标饱和度输入事件 } //目标饱和度输入事件
private void CP_PRODUCT_CODE_LostFocus(object sender, RoutedEventArgs e) 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; //获取当前行
Code_ = curComboBox.Text;
if (Code_ == "")
{
if (Procedures_N.Text == Procedures_P.Text)
{ {
/* System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox; MessageBoxResult P = System.Windows.MessageBox.Show("是否保存", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); //提示
string a = curComboBox.Text; 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()) //检查原料信息
{
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";
if (double.TryParse(list_Total.Text, out ang))
{
Weight_ = double.Parse(list_Total.Text) * double.Parse(Conc_) / 100;
}
else
{
System.Windows.MessageBox.Show("请先确认重量及浴比");
return;
}
}
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
{
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
}
DataTable data = null; private void CP_PRODUCT_NAME_DropDownClosed(object sender, EventArgs e)//原料名选择事件
if (a != "")
{ {
data = MainWindowViewModel.STUFFdatatemp.Select("ProductCode ='" + a + "'").CopyToDataTable();
//Grid_RRODUCT.ItemsSource = data.Columns.//Add("ProductName").ToString();
}*/
} }
} }
} }

4
Windows/APP_set.xaml

@ -20,6 +20,10 @@
<TextBox x:Name="TimeFormat" HorizontalAlignment="Left" Height="20" Margin="85,250,0,0" TextWrapping="Wrap" Text="yyyyMMddHHmmss" VerticalAlignment="Top" Width="125"/> <TextBox x:Name="TimeFormat" HorizontalAlignment="Left" Height="20" Margin="85,250,0,0" TextWrapping="Wrap" Text="yyyyMMddHHmmss" VerticalAlignment="Top" Width="125"/>
<TextBlock HorizontalAlignment="Left" Height="20" Margin="10,280,0,0" TextWrapping="Wrap" Text="排序格式" VerticalAlignment="Top" Width="75" FontSize="14"/> <TextBlock HorizontalAlignment="Left" Height="20" Margin="10,280,0,0" TextWrapping="Wrap" Text="排序格式" VerticalAlignment="Top" Width="75" FontSize="14"/>
<TextBox x:Name="Order" HorizontalAlignment="Left" Height="20" Margin="85,280,0,0" TextWrapping="Wrap" Text="0001" VerticalAlignment="Top" Width="125"/> <TextBox x:Name="Order" HorizontalAlignment="Left" Height="20" Margin="85,280,0,0" TextWrapping="Wrap" Text="0001" VerticalAlignment="Top" Width="125"/>
<TextBlock HorizontalAlignment="Left" Height="20" Margin="10,310,0,0" TextWrapping="Wrap" Text="常用重量" VerticalAlignment="Top" Width="75" FontSize="14"/>
<TextBox x:Name="Weight" HorizontalAlignment="Left" Height="20" Margin="85,310,0,0" TextWrapping="Wrap" Text="0000" VerticalAlignment="Top" Width="125"/>
<TextBlock HorizontalAlignment="Left" Height="20" Margin="10,340,0,0" TextWrapping="Wrap" Text="常用浴比" VerticalAlignment="Top" Width="75" FontSize="14"/>
<TextBox x:Name="Proportion" HorizontalAlignment="Left" Height="20" Margin="85,340,0,0" TextWrapping="Wrap" Text="0000" VerticalAlignment="Top" Width="125"/>
</Grid> </Grid>
</Window> </Window>

5
Windows/APP_set.xaml.cs

@ -45,6 +45,8 @@ namespace formula_manage.Windows
Configini.IniWritevalue("SOFTWARE_SET", " T1", Prepose.Text); Configini.IniWritevalue("SOFTWARE_SET", " T1", Prepose.Text);
Configini.IniWritevalue("SOFTWARE_SET", " T2", TimeFormat.Text); Configini.IniWritevalue("SOFTWARE_SET", " T2", TimeFormat.Text);
Configini.IniWritevalue("SOFTWARE_SET", " T3", Order.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);//生成日志文件目录 System.IO.DirectoryInfo log = new System.IO.DirectoryInfo(@logpath);//生成日志文件目录
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write); FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
@ -70,7 +72,8 @@ namespace formula_manage.Windows
Prepose.Text = Configini.IniReadvalue("SOFTWARE_SET", "T1"); //自定义料单前缀 Prepose.Text = Configini.IniReadvalue("SOFTWARE_SET", "T1"); //自定义料单前缀
TimeFormat.Text = Configini.IniReadvalue("SOFTWARE_SET", "T2"); //自定义料单时间格式 TimeFormat.Text = Configini.IniReadvalue("SOFTWARE_SET", "T2"); //自定义料单时间格式
Order.Text = Configini.IniReadvalue("SOFTWARE_SET", "T3"); //自定义料单排序 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) private void Login_LINK_Checked(object sender, RoutedEventArgs e)
{ {

Loading…
Cancel
Save