|
|
@ -128,8 +128,16 @@ namespace formula_manage.Windows |
|
|
{ |
|
|
{ |
|
|
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; |
|
|
int int_stuff_ProductType = 0; |
|
|
String Stuff_sql; |
|
|
int ColorCode_SQL; |
|
|
|
|
|
string Stuff_sql; |
|
|
|
|
|
string Product_Code = stuff_ProductCode.Text; |
|
|
|
|
|
string Product_Name = stuff_ProductName.Text; |
|
|
|
|
|
string _Price = stuff_Price.Text; |
|
|
|
|
|
string _SUPPLIER = stuff_SUPPLIER.Text; |
|
|
|
|
|
string _Concentration = stuff_Concentration.Text; |
|
|
|
|
|
string _GRAVITY = stuff_GRAVITY.Text; |
|
|
|
|
|
|
|
|
if (this.stuff_ProductType.Text == "染料") //原料类型0。染料,1助剂,2粉体
|
|
|
if (this.stuff_ProductType.Text == "染料") //原料类型0。染料,1助剂,2粉体
|
|
|
int_stuff_ProductType = 0; |
|
|
int_stuff_ProductType = 0; |
|
|
else if (this.stuff_ProductType.Text == "助剂") |
|
|
else if (this.stuff_ProductType.Text == "助剂") |
|
|
@ -164,8 +172,27 @@ namespace formula_manage.Windows |
|
|
System.Windows.MessageBox.Show("ERR.C0102-4:原料信息错误", "错误");//检查浓度输入数值
|
|
|
System.Windows.MessageBox.Show("ERR.C0102-4:原料信息错误", "错误");//检查浓度输入数值
|
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
if (int_stuff_ProductType == 0 || int_stuff_ProductType == 3)//判断是否为染料,非染料写空
|
|
|
|
|
|
{ |
|
|
|
|
|
string colorValue = stuff_Color.Background.ToString();//获取色彩框背景色"#FFC1C2C3"
|
|
|
|
|
|
string StuffColor_R = string.Format("{0:X2}", colorValue.Substring(3, 2));//获取红色参数C1
|
|
|
|
|
|
string StuffColor_G = string.Format("{0:X2}", colorValue.Substring(5, 2));//获取绿色参数C2
|
|
|
|
|
|
string StuffColor_B = string.Format("{0:X2}", colorValue.Substring(7, 2));//获取蓝色参数C3
|
|
|
|
|
|
string StuffColor = StuffColor_B + StuffColor_G + StuffColor_R;//合并16进制rgb参数
|
|
|
|
|
|
ColorCode_SQL = Convert.ToInt32(StuffColor, 16);//16进制转10进制
|
|
|
|
|
|
if (ColorCode_SQL < 0) ColorCode_SQL = 16777215;//判断色彩数据是否有效
|
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
ColorCode_SQL = 16777215; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (stuff_SUPPLIER.Text == null) _SUPPLIER = "null"; |
|
|
|
|
|
if (stuff_Price.Text == null) _Price = "null"; |
|
|
|
|
|
|
|
|
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
|
|
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
|
|
Stuff_sql = "SELECT ProductCode FROM [Dispensing].[dbo].[PRODUCT] WHERE ProductCode = '" + stuff_ProductCode.Text +" '";//查询语句
|
|
|
Stuff_sql = "SELECT ProductCode FROM [Dispensing].[dbo].[PRODUCT] WHERE ProductCode = '" + Product_Code + " '";//查询语句
|
|
|
|
|
|
|
|
|
await conn_SC.OpenAsync(); //打开数据连接
|
|
|
await conn_SC.OpenAsync(); //打开数据连接
|
|
|
SqlCommand cmd = new SqlCommand(Stuff_sql, conn_SC); //查询记录数
|
|
|
SqlCommand cmd = new SqlCommand(Stuff_sql, conn_SC); //查询记录数
|
|
|
@ -174,7 +201,13 @@ namespace formula_manage.Windows |
|
|
|
|
|
|
|
|
if (count == 0) |
|
|
if (count == 0) |
|
|
{ |
|
|
{ |
|
|
|
|
|
Stuff_sql = "INSERT INTO[Dispensing].[dbo].[PRODUCT](ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY ) " + |
|
|
|
|
|
"VALUES (" + Product_Code + "," + Product_Name + "," + _Price + "," + _SUPPLIER + "," + int_stuff_ProductType + "," + ColorCode_SQL + "," + _Concentration + "," + _GRAVITY + ")"; |
|
|
|
|
|
|
|
|
|
|
|
await conn_SC.OpenAsync(); //打开数据连接
|
|
|
|
|
|
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC); //查询记录数
|
|
|
|
|
|
int INSERT_count = Convert.ToInt32(INSERT_cmd.ExecuteScalar()); //显示记录数
|
|
|
|
|
|
conn_SC.Close(); //关闭连接
|
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
|