sc 4 years ago
parent
commit
ae312c8c36
  1. 6
      View/StuffView.xaml
  2. 17
      View/StuffView.xaml.cs
  3. 1
      ViewModel/StuffViewModel.cs

6
View/StuffView.xaml

@ -56,7 +56,7 @@
<DataGridTextColumn Header="原料代码" Width="130" FontSize="15" Binding="{Binding ProductCode}" MaxWidth="130" MinWidth="100" CanUserReorder="False"/> <DataGridTextColumn Header="原料代码" Width="130" FontSize="15" Binding="{Binding ProductCode}" MaxWidth="130" MinWidth="100" CanUserReorder="False"/>
<DataGridTextColumn Header="原料名称" Width="200" FontSize="15" Binding="{Binding ProductName}" MaxWidth="200" MinWidth="200" CanUserReorder="False"/> <DataGridTextColumn Header="原料名称" Width="200" FontSize="15" Binding="{Binding ProductName}" MaxWidth="200" MinWidth="200" CanUserReorder="False"/>
<DataGridTextColumn Header="价格(¥/kg)" Width="100" FontSize="15" Binding="{Binding Price}" MaxWidth="100" MinWidth="100" CanUserReorder="False"/> <DataGridTextColumn Header="价格(¥/kg)" Width="100" FontSize="15" Binding="{Binding Price}" MaxWidth="100" MinWidth="100" CanUserReorder="False"/>
<DataGridTextColumn Header="供应商" Width="150" FontSize="15" Binding="{Binding ProductUnit}" MaxWidth="150" MinWidth="150" CanUserReorder="False"/> <DataGridTextColumn Header="供应商代码" Width="150" FontSize="15" Binding="{Binding ProductUnit}" MaxWidth="150" MinWidth="150" CanUserReorder="False"/>
<DataGridTextColumn Header="原料类型" Width="80" FontSize="15" MaxWidth="80" MinWidth="70" CanUserReorder="False"> <DataGridTextColumn Header="原料类型" Width="80" FontSize="15" MaxWidth="80" MinWidth="70" CanUserReorder="False">
<DataGridTextColumn.ElementStyle> <DataGridTextColumn.ElementStyle>
<Style TargetType="{x:Type TextBlock}"> <Style TargetType="{x:Type TextBlock}">
@ -80,7 +80,7 @@
<RadioButton Content="助剂" x:Name="Button_1" GroupName="button" HorizontalAlignment="Left" Height="40" Margin="995,305,0,0" VerticalAlignment="Top" Width="100" FontSize="18" BorderBrush="{x:Null}" Background="{x:Null}" Grid.Column="1"/> <RadioButton Content="助剂" x:Name="Button_1" GroupName="button" HorizontalAlignment="Left" Height="40" Margin="995,305,0,0" VerticalAlignment="Top" Width="100" FontSize="18" BorderBrush="{x:Null}" Background="{x:Null}" Grid.Column="1"/>
<RadioButton Content="粉体助剂" x:Name="Button_2" GroupName="button" HorizontalAlignment="Left" Height="40" Margin="995,345,0,0" VerticalAlignment="Top" Width="100" FontSize="18" BorderBrush="{x:Null}" Background="{x:Null}" Grid.Column="1"/> <RadioButton Content="粉体助剂" x:Name="Button_2" GroupName="button" HorizontalAlignment="Left" Height="40" Margin="995,345,0,0" VerticalAlignment="Top" Width="100" FontSize="18" BorderBrush="{x:Null}" Background="{x:Null}" Grid.Column="1"/>
<RadioButton Content="全部原料" x:Name="Button_all" GroupName="button" HorizontalAlignment="Left" Height="40" Margin="995,385,0,0" VerticalAlignment="Top" Width="100" FontSize="18" BorderBrush="{x:Null}" Background="{x:Null}" Grid.Column="1" IsChecked="True"/> <RadioButton Content="全部原料" x:Name="Button_all" GroupName="button" HorizontalAlignment="Left" Height="40" Margin="995,385,0,0" VerticalAlignment="Top" Width="100" FontSize="18" BorderBrush="{x:Null}" Background="{x:Null}" Grid.Column="1" IsChecked="True"/>
<TextBox x:Name="stuff_ProductCode" HorizontalAlignment="Left" Height="30" Margin="105,0,0,100" Text="" VerticalAlignment="Bottom" Width="130" FontSize="16" MaxLines="1" MaxLength="25"/> <TextBox x:Name="stuff_ProductCode" HorizontalAlignment="Left" Height="30" Margin="105,0,0,100" Text="" VerticalAlignment="Bottom" Width="130" FontSize="16" MaxLines="1" MaxLength="25" InputMethod.IsInputMethodEnabled="False"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,0,0,100" TextWrapping="Wrap" Text="原料代码" VerticalAlignment="Bottom" Width="100" FontSize="20"/> <TextBlock HorizontalAlignment="Left" Height="30" Margin="15,0,0,100" TextWrapping="Wrap" Text="原料代码" VerticalAlignment="Bottom" Width="100" FontSize="20"/>
<TextBox x:Name="stuff_ProductName" HorizontalAlignment="Left" Height="30" Margin="345,0,0,100" Text="" VerticalAlignment="Bottom" Width="200" FontSize="16" MaxLines="1" MaxLength="50"/> <TextBox x:Name="stuff_ProductName" HorizontalAlignment="Left" Height="30" Margin="345,0,0,100" Text="" VerticalAlignment="Bottom" Width="200" FontSize="16" MaxLines="1" MaxLength="50"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="255,0,0,100" TextWrapping="Wrap" Text="原料名称" VerticalAlignment="Bottom" Width="100" FontSize="20"/> <TextBlock HorizontalAlignment="Left" Height="30" Margin="255,0,0,100" TextWrapping="Wrap" Text="原料名称" VerticalAlignment="Bottom" Width="100" FontSize="20"/>
@ -92,7 +92,7 @@
<TextBlock HorizontalAlignment="Left" Height="30" Margin="560,0,0,100" TextWrapping="Wrap" Text="原料类型" VerticalAlignment="Bottom" Width="100" FontSize="20"/> <TextBlock HorizontalAlignment="Left" Height="30" Margin="560,0,0,100" TextWrapping="Wrap" Text="原料类型" VerticalAlignment="Bottom" Width="100" FontSize="20"/>
<TextBox x:Name="stuff_Color" MouseDoubleClick="Stuff_Color_MouseDoubleClick" HorizontalAlignment="Left" Height="30" Margin="445,0,0,50" Text="" VerticalAlignment="Bottom" Width="80" MaxLines="1" IsReadOnly="True" Cursor="Arrow"/> <TextBox x:Name="stuff_Color" MouseDoubleClick="Stuff_Color_MouseDoubleClick" HorizontalAlignment="Left" Height="30" Margin="445,0,0,50" Text="" VerticalAlignment="Bottom" Width="80" MaxLines="1" IsReadOnly="True" Cursor="Arrow"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="400,0,0,50" TextWrapping="Wrap" Text="色彩" VerticalAlignment="Bottom" Width="50" FontSize="20"/> <TextBlock HorizontalAlignment="Left" Height="30" Margin="400,0,0,50" TextWrapping="Wrap" Text="色彩" VerticalAlignment="Bottom" Width="50" FontSize="20"/>
<TextBox x:Name="stuff_ProductUnit" HorizontalAlignment="Left" Height="30" Margin="105,0,0,50" Text="" VerticalAlignment="Bottom" Width="130" FontSize="16" MaxLines="1" MaxLength="25"/> <TextBox x:Name="stuff_ProductUnit" HorizontalAlignment="Left" Height="30" Margin="105,0,0,50" Text="" VerticalAlignment="Bottom" Width="130" FontSize="16" MaxLines="1" MaxLength="25" InputMethod.IsInputMethodEnabled="False" PreviewTextInput="Limitnumber"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,0,0,50" TextWrapping="Wrap" Text="供应商" VerticalAlignment="Bottom" Width="80" FontSize="20"/> <TextBlock HorizontalAlignment="Left" Height="30" Margin="15,0,0,50" TextWrapping="Wrap" Text="供应商" VerticalAlignment="Bottom" Width="80" FontSize="20"/>
<TextBox x:Name="stuff_Price" HorizontalAlignment="Left" Height="30" Margin="305,0,0,50" Text="" VerticalAlignment="Bottom" Width="80" FontSize="16" MaxLines="1" MaxLength="25" InputMethod.IsInputMethodEnabled="False" PreviewTextInput="Limitnumber"/> <TextBox x:Name="stuff_Price" HorizontalAlignment="Left" Height="30" Margin="305,0,0,50" Text="" VerticalAlignment="Bottom" Width="80" FontSize="16" MaxLines="1" MaxLength="25" InputMethod.IsInputMethodEnabled="False" PreviewTextInput="Limitnumber"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="255,0,0,50" TextWrapping="Wrap" Text="价格" VerticalAlignment="Bottom" Width="45" FontSize="20"/> <TextBlock HorizontalAlignment="Left" Height="30" Margin="255,0,0,50" TextWrapping="Wrap" Text="价格" VerticalAlignment="Bottom" Width="45" FontSize="20"/>

17
View/StuffView.xaml.cs

@ -15,6 +15,7 @@ using System.Windows.Shapes;
using System.Windows.Forms; using System.Windows.Forms;
using System.Drawing; using System.Drawing;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Models;
namespace Audit.View namespace Audit.View
{ {
@ -42,10 +43,14 @@ namespace Audit.View
} }
private Product product = new Product();
private void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件 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 = 1;
if (this.stuff_ProductType.Text == "粉体助剂") int_stuff_ProductType = 2;
if (string.IsNullOrEmpty(this.stuff_ProductCode.Text)) System.Windows.MessageBox.Show("ERR.C0101:无效的原料信息");//检查原料代码 if (string.IsNullOrEmpty(this.stuff_ProductCode.Text)) System.Windows.MessageBox.Show("ERR.C0101:无效的原料信息");//检查原料代码
else else
if (string.IsNullOrEmpty(this.stuff_ProductName.Text)) System.Windows.MessageBox.Show("ERR.C0101-2:无效的原料信息,名称不可为空");//检查原料名称 if (string.IsNullOrEmpty(this.stuff_ProductName.Text)) System.Windows.MessageBox.Show("ERR.C0101-2:无效的原料信息,名称不可为空");//检查原料名称
@ -59,7 +64,15 @@ namespace Audit.View
if(int.Parse(this.stuff_Concentration.Text) < 0 || int.Parse(this.stuff_Concentration.Text) > 10) System.Windows.MessageBox.Show("ERR.C0102-2:原料信息错误,浓度错误");//检查浓度输入数值 if(int.Parse(this.stuff_Concentration.Text) < 0 || int.Parse(this.stuff_Concentration.Text) > 10) System.Windows.MessageBox.Show("ERR.C0102-2:原料信息错误,浓度错误");//检查浓度输入数值
else else
{ {
product.ProductCode = this.stuff_ProductCode.Text;
product.ProductName = this.stuff_ProductName.Text;
product.Price = int.Parse(this.stuff_Price.Text);
product.GRAVITY = int.Parse(this.stuff_GRAVITY.Text);
product.ProductUnit = int.Parse(this.stuff_ProductUnit.Text);
product.Concentration = int.Parse(this.stuff_Concentration.Text);
product.ProductType = int_stuff_ProductType;
product.Color = ColorCode_SQL;
//var count = Product().Insert(product);
} }
} }

1
ViewModel/StuffViewModel.cs

@ -18,6 +18,7 @@ namespace Audit.ViewModel
public class StuffViewModel : ViewModelBase public class StuffViewModel : ViewModelBase
{ {
private List<Product> products = new List<Product>(); private List<Product> products = new List<Product>();
/// <summary> /// <summary>
/// 所有原料 /// 所有原料
/// </summary> /// </summary>

Loading…
Cancel
Save