diff --git a/MainWindow.xaml b/MainWindow.xaml index e004355..2dd11ad 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -65,7 +65,7 @@ - + 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(); //关闭连接