忱 沈 4 years ago
parent
commit
4ae6df4e79
  1. 4
      Models/ProductProvider.cs
  2. 24
      View/StuffView.xaml.cs

4
Models/ProductProvider.cs

@ -24,8 +24,8 @@ namespace Models
if (t == null) return 0;
if (String.IsNullOrEmpty(t.ProductCode)) return 0;
db.Product.Add(t);
int count = db.SaveChanges();
return count;
int counti = db.SaveChanges();
return counti;
}
public List<Product> Select()

24
View/StuffView.xaml.cs

@ -48,7 +48,7 @@ namespace Audit.View
private void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件
{
int int_stuff_ProductType = 0;
if (this.stuff_ProductType.Text == "染料") int_stuff_ProductType = 0;
if (this.stuff_ProductType.Text == "染料") int_stuff_ProductType = 0;//原料类型0。染料,1助剂,2粉体
if (this.stuff_ProductType.Text == "助剂") int_stuff_ProductType = 1;
if (this.stuff_ProductType.Text == "粉体助剂") int_stuff_ProductType = 2;
if (string.IsNullOrEmpty(this.stuff_ProductCode.Text)) System.Windows.MessageBox.Show("ERR.C0101:无效的原料信息");//检查原料代码
@ -71,17 +71,17 @@ namespace Audit.View
product.ProductName = this.stuff_ProductName.Text;//写入原料名称
product.GRAVITY = Double.Parse(this.stuff_GRAVITY.Text);//写入原料比重
product.Concentration = Double.Parse(this.stuff_Concentration.Text);//写入原料浓度
product.ProductType = int_stuff_ProductType;//写入原料类型
var count = new ProductProvider().Insert(product);//实例化并添加数据库信息。
if (count == 0)//判断执行是否成功
{
System.Windows.MessageBox.Show("ERR.C0110-1:添加失败");
}
else
{
System.Windows.MessageBox.Show("添加完成");
}
}
product.ProductType = int_stuff_ProductType;//写入原料类型
var count = new ProductProvider().Insert(product);//实例化并添加数据库信息。
if (count == 0)//判断执行是否成功
{
System.Windows.MessageBox.Show("ERR.C0110-1:添加失败");
}
else
{
System.Windows.MessageBox.Show("添加完成");
}
}
}
private void Button_Delete(object sender, RoutedEventArgs e)

Loading…
Cancel
Save