|
|
@ -86,42 +86,59 @@ namespace formula_manage.Windows |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
private void DataGridEquipment_LoadingRow(object sender, DataGridRowEventArgs e) |
|
|
private void DataGridEquipment_LoadingRow(object sender, DataGridRowEventArgs e) |
|
|
{ |
|
|
{ |
|
|
e.Row.Header = e.Row.GetIndex() + 1; |
|
|
// e.Row.Header = e.Row.GetIndex() + 1;
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static Boolean Button_sql = true; |
|
|
private async void Radiobutton(object sender, EventArgs e) |
|
|
public static int Buttontype_sql = -1; |
|
|
|
|
|
private void Radiobutton(object sender, EventArgs e) |
|
|
|
|
|
{ |
|
|
{ |
|
|
|
|
|
string Stuff_sql = null; |
|
|
System.Windows.Controls.RadioButton Radiobutton = (sender as System.Windows.Controls.RadioButton); |
|
|
System.Windows.Controls.RadioButton Radiobutton = (sender as System.Windows.Controls.RadioButton); |
|
|
string radiobutton = Radiobutton.Content.ToString(); |
|
|
string radiobutton = Radiobutton.Content.ToString(); |
|
|
if (radiobutton == "全部原料") Buttontype_sql = -1; |
|
|
if (radiobutton == "全部原料") |
|
|
if (radiobutton == "染料") Buttontype_sql = 0; |
|
|
Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY FROM [Dispensing].[dbo].[PRODUCT]";//查询语句
|
|
|
if (radiobutton == "助剂") Buttontype_sql = 1; |
|
|
else if (radiobutton == "染料") |
|
|
if (radiobutton == "粉体助剂") Buttontype_sql = 2; |
|
|
Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY FROM [Dispensing].[dbo].[PRODUCT] Where ProductType = '0' "; |
|
|
if (radiobutton == "液体染料") Buttontype_sql = 3; |
|
|
else if (radiobutton == "助剂") |
|
|
Button_sql = true; |
|
|
Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY FROM [Dispensing].[dbo].[PRODUCT] Where ProductType = '1' "; |
|
|
|
|
|
else if (radiobutton == "粉体助剂") |
|
|
|
|
|
Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY FROM [Dispensing].[dbo].[PRODUCT] Where ProductType = '2' "; |
|
|
|
|
|
else if (radiobutton == "液体染料") |
|
|
|
|
|
Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY FROM [Dispensing].[dbo].[PRODUCT] Where ProductType = '3' "; |
|
|
|
|
|
|
|
|
|
|
|
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
|
|
|
|
|
try |
|
|
|
|
|
{ |
|
|
|
|
|
await conn_SC.OpenAsync(); //打开数据连接
|
|
|
|
|
|
SqlDataAdapter Stuff_data = new SqlDataAdapter(Stuff_sql, Connstr_SC); //查询
|
|
|
|
|
|
|
|
|
|
|
|
DataTable dataTable = new DataTable(); //建立缓存
|
|
|
|
|
|
Stuff_data.Fill(dataTable); //查询结果存入缓存
|
|
|
|
|
|
conn_SC.Close(); //关闭连接
|
|
|
|
|
|
|
|
|
|
|
|
DataGridStuff.ItemsSource = dataTable.DefaultView; //数据加入表格
|
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception) |
|
|
|
|
|
{ |
|
|
|
|
|
System.Windows.MessageBox.Show("请求原料信息失败,检查连接"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件
|
|
|
private async void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件
|
|
|
{ |
|
|
{ |
|
|
Regex re_number = new Regex(@"^[0-9]+(.[0-9]{1,2})?$");//校验用正则表达式有1~2位小数的正实数
|
|
|
Regex re_number = new Regex(@"^[0-9]+(.[0-9]{1,2})?$");//校验用正则表达式有1~2位小数的正实数
|
|
|
Regex re_char = new Regex(@"^[A-Za-z0-9\s@()()/+!!_-]+$");//校验用正则表达式由数字,26个英文字母,空白字符和@()()/+!!_-组成的字符串
|
|
|
Regex re_char = new Regex(@"^[A-Za-z0-9\s@()()/+!!_-]+$");//校验用正则表达式由数字,26个英文字母,空白字符和@()()/+!!_-组成的字符串
|
|
|
int int_stuff_ProductType = 0; |
|
|
int int_stuff_ProductType; |
|
|
|
|
|
String Stuff_sql; |
|
|
if (this.stuff_ProductType.Text == "染料") //原料类型0。染料,1助剂,2粉体
|
|
|
if (this.stuff_ProductType.Text == "染料") //原料类型0。染料,1助剂,2粉体
|
|
|
{ |
|
|
|
|
|
int_stuff_ProductType = 0; |
|
|
int_stuff_ProductType = 0; |
|
|
this.stuff_Concentration.Text = "100"; |
|
|
else if (this.stuff_ProductType.Text == "助剂") |
|
|
} |
|
|
|
|
|
if (this.stuff_ProductType.Text == "助剂") |
|
|
|
|
|
int_stuff_ProductType = 1; |
|
|
int_stuff_ProductType = 1; |
|
|
if (this.stuff_ProductType.Text == "粉体助剂") |
|
|
else if (this.stuff_ProductType.Text == "粉体助剂") |
|
|
{ |
|
|
|
|
|
int_stuff_ProductType = 2; |
|
|
int_stuff_ProductType = 2; |
|
|
this.stuff_Concentration.Text = "100"; |
|
|
else if (this.stuff_ProductType.Text == "液体染料") |
|
|
} |
|
|
|
|
|
if (this.stuff_ProductType.Text == "液体染料") |
|
|
|
|
|
int_stuff_ProductType = 3; |
|
|
int_stuff_ProductType = 3; |
|
|
|
|
|
|
|
|
if (re_char.IsMatch(this.stuff_ProductCode.Text) == false) |
|
|
if (re_char.IsMatch(this.stuff_ProductCode.Text) == false) |
|
|
System.Windows.MessageBox.Show("ERR.C0101:无效的原料信息", "错误");//检查原料代码
|
|
|
System.Windows.MessageBox.Show("ERR.C0101:无效的原料信息", "错误");//检查原料代码
|
|
|
else |
|
|
else |
|
|
@ -145,6 +162,25 @@ namespace formula_manage.Windows |
|
|
else |
|
|
else |
|
|
if (float.Parse(this.stuff_Concentration.Text) < 0 || float.Parse(this.stuff_Concentration.Text) > 100) |
|
|
if (float.Parse(this.stuff_Concentration.Text) < 0 || float.Parse(this.stuff_Concentration.Text) > 100) |
|
|
System.Windows.MessageBox.Show("ERR.C0102-4:原料信息错误", "错误");//检查浓度输入数值
|
|
|
System.Windows.MessageBox.Show("ERR.C0102-4:原料信息错误", "错误");//检查浓度输入数值
|
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
|
|
|
|
|
Stuff_sql = "SELECT ProductCode FROM [Dispensing].[dbo].[PRODUCT] WHERE ProductCode = '" + stuff_ProductCode.Text +" '";//查询语句
|
|
|
|
|
|
|
|
|
|
|
|
await conn_SC.OpenAsync(); //打开数据连接
|
|
|
|
|
|
SqlCommand cmd = new SqlCommand(Stuff_sql, conn_SC); //查询记录数
|
|
|
|
|
|
int count = Convert.ToInt32(cmd.ExecuteScalar()); //显示记录数
|
|
|
|
|
|
conn_SC.Close(); //关闭连接
|
|
|
|
|
|
|
|
|
|
|
|
if (count == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
/* else |
|
|
/* else |
|
|
{ |
|
|
{ |
|
|
product.ProductCode = this.stuff_ProductCode.Text;//写入原料代码
|
|
|
product.ProductCode = this.stuff_ProductCode.Text;//写入原料代码
|
|
|
|