diff --git a/View/StuffView.xaml b/View/StuffView.xaml index ac32ba7..234ed7b 100644 --- a/View/StuffView.xaml +++ b/View/StuffView.xaml @@ -144,17 +144,12 @@ diff --git a/View/StuffView.xaml.cs b/View/StuffView.xaml.cs index 961054e..4b8fb3e 100644 --- a/View/StuffView.xaml.cs +++ b/View/StuffView.xaml.cs @@ -65,7 +65,14 @@ namespace Audit.View if(float.Parse(this.stuff_Concentration.Text) < 0 || float.Parse(this.stuff_Concentration.Text) > 100) System.Windows.MessageBox.Show("ERR.C0102-2:原料信息错误,浓度错误");//检查浓度输入数值 else { - if (ColorCode_SQL > 0) product.Color = ColorCode_SQL;//判断色彩数据是否有效,有效写入 + if (int_stuff_ProductType == 0)//判断是否为染料,非染料写空 + { + if (ColorCode_SQL >= 0) product.Color = ColorCode_SQL;//判断色彩数据是否有效,有效写入 + } + else + { + product.Color = null;//色彩栏写空 + } if (string.IsNullOrEmpty(this.stuff_Price.Text) == false) product.Price = Double.Parse(this.stuff_Price.Text);//判断价格数据是否有效,有效写入 if (string.IsNullOrEmpty(this.stuff_ProductUnit.Text) == false) product.ProductUnit = int.Parse(this.stuff_ProductUnit.Text);//判断供应商数据是否有效,有效写入 product.ProductCode = this.stuff_ProductCode.Text;//写入原料代码 @@ -73,7 +80,8 @@ namespace Audit.View 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);//实例化并添加数据库信息。 + new ProductProvider().Delete(product);//删除数据库原目标信息。 + var count = new ProductProvider().Insert(product);//添加数据库信息。 if (count == 0)//判断执行是否成功 { System.Windows.MessageBox.Show("ERR.C0110-1:添加失败"); @@ -85,9 +93,18 @@ namespace Audit.View } } - private void Button_Delete(object sender, RoutedEventArgs e) + private void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件 { - + product.ProductCode = this.stuff_ProductCode.Text;//原料代码 + var count = new ProductProvider().Delete(product);//删除数据库目标信息。 + if (count == 0)//判断执行是否成功 + { + System.Windows.MessageBox.Show("ERR.C0110-2:删除失败"); + } + else + { + System.Windows.MessageBox.Show("删除完成"); + } } private void DataGridStuff_MouseDoubleClick(object sender, MouseButtonEventArgs e)//数据表双击事件 @@ -112,7 +129,7 @@ namespace Audit.View /*stuff_Color.Text = DataGridStuff_Color.ToString();//填入色彩数据*/ stuff_Concentration.Text = DataGridStuff_Concentration.ToString();//填入浓度 stuff_GRAVITY.Text = DataGridStuff_GRAVITY.ToString();//填入比重 - /*if (DataGridStuff_ProductType.ToString() == "0") stuff_ProductType.Text = "染料";//判断类型1-染料。2-助剂。3-粉体助剂。填入 + /*if (DataGridStuff_ProductType.ToString() == "0") stuff_ProductType.Text = "染料";//判断类型1-染料。2-助剂。3-粉体助剂。 if (DataGridStuff_ProductType.ToString() == "1") stuff_ProductType.Text = "助剂"; if (DataGridStuff_ProductType.ToString() == "2") stuff_ProductType.Text = "粉体助剂";*/ if ((DataGridStuff.Columns[6].GetCellContent(DataGridStuff.Items[rownum]) as TextBlock).Background != null) //定位第5列选中行单元格,色彩,判断参数是否有效 @@ -121,7 +138,7 @@ namespace Audit.View } else { - stuff_Color.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 255, 255));//有效背景色传递至色彩框背景色 + stuff_Color.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 255, 255));//白色传递至色彩框背景色 } } @@ -145,7 +162,7 @@ namespace Audit.View stuff_Color.Foreground = new SolidColorBrush(MColor);//ARGB参数输出至stuff_Color的前景色 string colorCode = Convert.ToString(DColor.B,16) + Convert.ToString(DColor.G,16) + Convert.ToString(DColor.R,16);//反向十六进制RGB //string colorCode = Convert.ToString(DColor.R,16) + Convert.ToString(DColor.G,16) + Convert.ToString(DColor.B,16);//正向十六进制RGB - ColorCode_SQL = Convert.ToInt32(colorCode, 16);//十六进制RGB转存储数值 // + ColorCode_SQL = Convert.ToInt32(colorCode, 16);//十六进制RGB转存储数值 } } } diff --git a/ViewModel/StuffViewModel.cs b/ViewModel/StuffViewModel.cs index ee302ec..ef4e7ec 100644 --- a/ViewModel/StuffViewModel.cs +++ b/ViewModel/StuffViewModel.cs @@ -43,7 +43,7 @@ namespace Audit.ViewModel { products = new ProductProvider().Select(); DispatcherTimer timer = new DispatcherTimer();//每5秒调用一次Tick_Event - timer.Interval = TimeSpan.FromSeconds(10); + timer.Interval = TimeSpan.FromSeconds(5); timer.Tick += Tick_Event; timer.Start(); }