Browse Source

机台设置及选择

master
sc 2 years ago
parent
commit
778b231542
  1. 2
      MainWindow.xaml
  2. 17
      MainWindow.xaml.cs
  3. 23
      Windows/Machine.xaml.cs

2
MainWindow.xaml

@ -65,7 +65,7 @@
<TextBox x:Name="Anew" HorizontalAlignment="Left" Height="30" Margin="300,35,0,0" TextWrapping="Wrap" Text="0" VerticalAlignment="Top" Width="30" FontSize="20"
MaxLines="1" MaxLength="2" PreviewTextInput="Tb_KeyPress" InputMethod.IsInputMethodEnabled="False" Focusable ="False"/>
<TextBox HorizontalAlignment="Left" Height="30" Margin="95,105,0,0" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="200" FontSize="20" KeyUp="SearchBox_OnKeyDownd" IsTabStop="False"/>
<ComboBox x:Name="Machine" HorizontalAlignment="Left" Height="30" Margin="95,140,0,0" Text="" VerticalAlignment="Top" Width="130" FontSize="20" IsEditable="True" KeyUp="SearchBox_OnKeyDownd"/>
<ComboBox x:Name="Machine" DisplayMemberPath="Name" HorizontalAlignment="Left" Height="30" Margin="95,140,0,0" Text="" VerticalAlignment="Top" Width="130" FontSize="20" IsEditable="True" KeyUp="SearchBox_OnKeyDownd"/>
<TextBox x:Name="Procedures_N" HorizontalAlignment="Left" Height="30" Margin="305,140,0,0" TextWrapping="Wrap" Text="1" VerticalAlignment="Top" Width="80" FontSize="20"
KeyUp="SearchBox_OnKeyDownd" MaxLines="1" MaxLength="3" PreviewTextInput="Tb_KeyPress" InputMethod.IsInputMethodEnabled="False"/>
<Button Content="+" HorizontalAlignment="Left" Height="15" Width="20" Margin="385,140,0,0" VerticalAlignment="Top" FontSize="10"

17
MainWindow.xaml.cs

@ -1,4 +1,5 @@
using System;
using formula_manage.Windows;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
@ -32,6 +33,7 @@ namespace formula_manage
{
DataTable STUFFdataTable = new DataTable(); //建立STUFF缓存
DataTable MACHINEdataTable = new DataTable(); //建立Machine缓存
public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "formula.ini"; //配置文件路径
@ -106,16 +108,19 @@ namespace formula_manage
Connstr_SC = "server=" + TEXT_SQLIP + ";database=" + TEXT_SQLNAME + ";User ID=" + TEXT_SQLUSER + ";Password=" + TEXT_SQLPASWOR;
}
string Stuff_sql = "SELECT ProductCode ,ProductName ,ProductType ,Concentration FROM [Dispensing].[dbo].[PRODUCT]";//查询语句
string Stuff_sql = "SELECT ProductCode ,ProductName ,ProductType ,Concentration FROM [Dispensing].[dbo].[PRODUCT]";//查询STUFF语句
string MAC_sql = "SELECT Name ,MacGroup ,Capacity ,Volume ,Industry ,Categories ,Note FROM [Dispensing].[dbo].[MACHINE]";
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
try
{
await conn_SC.OpenAsync(); //打开数据连接
SqlDataAdapter Stuff_data = new SqlDataAdapter(Stuff_sql, Connstr_SC); //查询
SqlDataAdapter Stuff_data = new SqlDataAdapter(Stuff_sql, Connstr_SC); //查询stuff
SqlDataAdapter Mac_data = new SqlDataAdapter(MAC_sql, Connstr_SC); //查询machine
Stuff_data.Fill(STUFFdataTable); //stuff查询结果存入缓存
Mac_data.Fill(MACHINEdataTable); //machine查询结果存入缓存
//DataTable dataTable = new DataTable(); //建立缓存
Stuff_data.Fill(STUFFdataTable); //查询结果存入缓存
conn_SC.Close(); //关闭连接
//DataGridStuff.ItemsSource = dataTable.DefaultView; //数据加入表格
}
@ -124,6 +129,8 @@ namespace formula_manage
System.Windows.MessageBox.Show("请求原料信息失败,检查连接");
return;
}
Machine.ItemsSource = MACHINEdataTable.DefaultView; // MACHINEdataTable数据集传递到ComboBox:machine
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) //窗口关闭事件

23
Windows/Machine.xaml.cs

@ -60,19 +60,20 @@ namespace formula_manage.Windows
Connstr_SC = "server=" + TEXT_SQLIP + ";database=" + TEXT_SQLNAME + ";User ID=" + TEXT_SQLUSER + ";Password=" + TEXT_SQLPASWOR;
}
string Stuff_sql = "SELECT Name ,MacGroup ,Capacity ,Volume ,Industry ,Categories ,Note FROM [Dispensing].[dbo].[MACHINE]";//查询语句
string MAC_sql = "SELECT Name ,MacGroup ,Capacity ,Volume ,Industry ,Categories ,Note FROM [Dispensing].[dbo].[MACHINE]";//查询语句
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
try
{
await conn_SC.OpenAsync(); //打开数据连接
SqlDataAdapter Stuff_data = new SqlDataAdapter(Stuff_sql, Connstr_SC); //查询
SqlDataAdapter Stuff_data = new SqlDataAdapter(MAC_sql, Connstr_SC); //查询
DataTable dataTable = new DataTable(); //建立缓存
Stuff_data.Fill(dataTable); //查询结果存入缓存
conn_SC.Close(); //关闭连接
DataGridMac.ItemsSource = dataTable.DefaultView; //数据加入表格
DataGridMac.DisplayMemberPath = "Name";
}
catch (Exception)
{
@ -94,14 +95,14 @@ namespace formula_manage.Windows
/// </summary>
private async void GridSql()
{
string Stuff_sql = "SELECT Name ,MacGroup ,Capacity ,Volume ,Industry ,Categories ,Note FROM [Dispensing].[dbo].[MACHINE]";//查询语句
string MAC_sql = "SELECT Name ,MacGroup ,Capacity ,Volume ,Industry ,Categories ,Note FROM [Dispensing].[dbo].[MACHINE]";//查询语句
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
try
{
await conn_SC.OpenAsync(); //打开数据连接
SqlDataAdapter Stuff_data = new SqlDataAdapter(Stuff_sql, Connstr_SC); //查询
SqlDataAdapter Stuff_data = new SqlDataAdapter(MAC_sql, Connstr_SC); //查询
DataTable dataTable = new DataTable(); //建立缓存
Stuff_data.Fill(dataTable); //查询结果存入缓存
@ -150,7 +151,7 @@ namespace formula_manage.Windows
string Mac_industry = mac_Industry.Text;
string Mac_categories = mac_Categories.Text;
string Mac_note = mac_Note.Text;
string Stuff_sql;
string MAC_sql;
if (Mac_industry == "浸染") Mac_industry = "0";
else if (Mac_industry == "连染") Mac_industry = "1";
@ -174,18 +175,18 @@ namespace formula_manage.Windows
try
{
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
Stuff_sql = "SELECT count(*) FROM [Dispensing].[dbo].[MACHINE] WHERE Name = '" + Mac_name + " '";//查询语句
MAC_sql = "SELECT count(*) FROM [Dispensing].[dbo].[MACHINE] WHERE Name = '" + Mac_name + " '";//查询语句
await conn_SC.OpenAsync(); //打开数据连
SqlCommand cmd = new SqlCommand(Stuff_sql, conn_SC); //查询记录数
SqlCommand cmd = new SqlCommand(MAC_sql, conn_SC); //查询记录数
int count = Convert.ToInt32(cmd.ExecuteScalar()); //显示记录数
conn_SC.Close(); //关闭连接
if (count == 0)
{
Stuff_sql = string.Format("INSERT INTO[Dispensing].[dbo].[MACHINE](Name ,MacGroup ,Capacity ,Volume ,Industry ,Categories ,Note ) " +
MAC_sql = string.Format("INSERT INTO[Dispensing].[dbo].[MACHINE](Name ,MacGroup ,Capacity ,Volume ,Industry ,Categories ,Note ) " +
"VALUES ('" + Mac_name + "','" + Mac_group + "'," + Mac_capacity + "," + Mac_volume + "," + Mac_industry + "," + Mac_categories + ",'" + Mac_note + "')");
await conn_SC.OpenAsync(); //打开数据连接
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC);
SqlCommand INSERT_cmd = new SqlCommand(MAC_sql, conn_SC);
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
conn_SC.Close(); //关闭连接
if (sql_in == 0)
@ -199,9 +200,9 @@ namespace formula_manage.Windows
}
else
{
Stuff_sql = string.Format("UPDATE [dbo].[MACHINE] SET MacGroup ='" + Mac_group + "',Capacity=" + Mac_capacity + " ,Volume=" + Mac_volume + " ,Industry=" + Mac_industry + " ,Categories=" + Mac_categories + " ,Note='" + Mac_note + "' Where Name ='" + Mac_name + "'");
MAC_sql = string.Format("UPDATE [dbo].[MACHINE] SET MacGroup ='" + Mac_group + "',Capacity=" + Mac_capacity + " ,Volume=" + Mac_volume + " ,Industry=" + Mac_industry + " ,Categories=" + Mac_categories + " ,Note='" + Mac_note + "' Where Name ='" + Mac_name + "'");
await conn_SC.OpenAsync(); //打开数据连接
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC);
SqlCommand INSERT_cmd = new SqlCommand(MAC_sql, conn_SC);
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
conn_SC.Close(); //关闭连接

Loading…
Cancel
Save