sc 2 years ago
parent
commit
c16e2e6f8d
  1. 4
      MainWindow.xaml
  2. 2
      MainWindow.xaml.cs
  3. 4
      ViewModel/StuffViewModel.cs
  4. 18
      Windows/Stuff.xaml
  5. 78
      Windows/Stuff.xaml.cs

4
MainWindow.xaml

@ -96,9 +96,9 @@
Margin="5,325,5,80" d:ItemsSource="{d:SampleData ItemCount=99}" AutoGenerateColumns="False" MinColumnWidth="30"
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2"
CanUserReorderColumns="False" CanUserSortColumns="False"
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False"
CanUserAddRows="False" CanUserDeleteRows="False"
Background="White" SelectionMode="Single" FontSize="15" CanUserResizeRows="False">
Background="White" SelectionMode="Single" FontSize="15" >
<DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>

2
MainWindow.xaml.cs

@ -252,7 +252,7 @@ namespace formula_manage
}
}
private void Proportion(object sender, TextChangedEventArgs e) //
private void Proportion(object sender, TextChangedEventArgs e) //浴比输入
{
float a, b, c;
b = float.Parse(list_Proportion.Text);

4
ViewModel/StuffViewModel.cs

@ -49,14 +49,14 @@ namespace formula_manage.ViewModel
void Tick_Event(object sender, EventArgs e)//Tick_Event周期执行事件
{
if (Stuff.Button_sql == true)//获取按钮状态
// if (Stuff.Button_sql == true)//获取按钮状态
{
// if (Stuff.Buttontype_sql == -1) Product = new ProductProvider().Select();
// if (Stuff.Buttontype_sql == 0) Product = new ProductProvider().Selects0();
// if (Stuff.Buttontype_sql == 1) Product = new ProductProvider().Selects1();
// if (Stuff.Buttontype_sql == 2) Product = new ProductProvider().Selects2();
// if (Stuff.Buttontype_sql == 3) Product = new ProductProvider().Selects3();
Stuff.Button_sql = false;//清除按钮状态
// Stuff.Button_sql = false;//清除按钮状态
}
}
}

18
Windows/Stuff.xaml

@ -18,9 +18,9 @@
<DataGrid x:Name="DataGridStuff" MouseDoubleClick="DataGridStuff_MouseDoubleClick" SelectionMode="Single" AlternationCount="2" IsReadOnly="True"
HorizontalAlignment="Left" Margin="15,15,0,150" d:ItemsSource="{d:SampleData ItemCount=200}" AutoGenerateColumns="False" MinColumnWidth="30"
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" CanUserReorderColumns="False"
CanUserResizeRows="False" CanUserSortColumns="False" CanUserResizeColumns="False"
CanUserAddRows="False" CanUserDeleteRows="False">
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2"
CanUserResizeRows="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False"
CanUserResizeColumns="False" CanUserSortColumns="False">
<DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}">
<Style.Triggers>
@ -28,7 +28,7 @@
<Setter Property="Background" Value="#FFFFFFFF" />
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#FFF5F5F5" />
<Setter Property="Background" Value="#FFF0F0F0" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
</Trigger>
@ -83,15 +83,15 @@
</DataGrid>
<!--搜索类型-->
<RadioButton Content="染料" x:Name="Button_0" Click="Radiobutton" HorizontalAlignment="Left" Height="20" Margin="995,265,0,0"
VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" FontSize="14"/>
VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" FontSize="14" />
<RadioButton Content="助剂" x:Name="Button_1" Click="Radiobutton" HorizontalAlignment="Left" Height="20" Margin="995,295,0,0"
VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" FontSize="14"/>
VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" FontSize="14" />
<RadioButton Content="粉体助剂" x:Name="Button_2" Click="Radiobutton" HorizontalAlignment="Left" Height="20" Margin="995,325,0,0"
VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" FontSize="14"/>
<RadioButton Content="液体染料" x:Name="Button_3" Click="Radiobutton" HorizontalAlignment="Left" Height="20" Margin="995,355,0,0"
VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" FontSize="14"/>
VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" FontSize="14" />
<RadioButton Content="全部原料" x:Name="Button_all" Click="Radiobutton" HorizontalAlignment="Left" Height="20" Margin="995,385,0,0"
VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" IsChecked="True" FontSize="14"/>
VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" IsChecked="True" FontSize="14" />
<!--原料代码-->
<TextBox x:Name="stuff_ProductCode" HorizontalAlignment="Left" Height="30" Margin="105,0,0,100" Text=""
VerticalAlignment="Bottom" Width="130" FontSize="22" MaxLines="1" MaxLength="25"
@ -133,7 +133,7 @@
VerticalAlignment="Bottom" Width="45" FontSize="20"/>
<!--浓度-->
<TextBox x:Name="stuff_Concentration" HorizontalAlignment="Left" Height="30" Margin="585,0,0,50" Text="100"
VerticalAlignment="Bottom" Width="50" FontSize="22" MaxLines="1" MaxLength="5"
VerticalAlignment="Bottom" Width="50" FontSize="22" MaxLines="1" MaxLength="7"
InputMethod.IsInputMethodEnabled="False"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="540,0,0,50" TextWrapping="Wrap" Text="浓度"
VerticalAlignment="Bottom" Width="45" FontSize="20"/>

78
Windows/Stuff.xaml.cs

@ -86,42 +86,59 @@ namespace formula_manage.Windows
/// </summary>
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;
public static int Buttontype_sql = -1;
private void Radiobutton(object sender, EventArgs e)
private async void Radiobutton(object sender, EventArgs e)
{
string Stuff_sql = null;
System.Windows.Controls.RadioButton Radiobutton = (sender as System.Windows.Controls.RadioButton);
string radiobutton = Radiobutton.Content.ToString();
if (radiobutton == "全部原料") Buttontype_sql = -1;
if (radiobutton == "染料") Buttontype_sql = 0;
if (radiobutton == "助剂") Buttontype_sql = 1;
if (radiobutton == "粉体助剂") Buttontype_sql = 2;
if (radiobutton == "液体染料") Buttontype_sql = 3;
Button_sql = true;
if (radiobutton == "全部原料")
Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY FROM [Dispensing].[dbo].[PRODUCT]";//查询语句
else if (radiobutton == "染料")
Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY FROM [Dispensing].[dbo].[PRODUCT] Where ProductType = '0' ";
else if (radiobutton == "助剂")
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_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粉体
{
int_stuff_ProductType = 0;
this.stuff_Concentration.Text = "100";
}
if (this.stuff_ProductType.Text == "助剂")
else if (this.stuff_ProductType.Text == "助剂")
int_stuff_ProductType = 1;
if (this.stuff_ProductType.Text == "粉体助剂")
{
else if (this.stuff_ProductType.Text == "粉体助剂")
int_stuff_ProductType = 2;
this.stuff_Concentration.Text = "100";
}
if (this.stuff_ProductType.Text == "液体染料")
else if (this.stuff_ProductType.Text == "液体染料")
int_stuff_ProductType = 3;
if (re_char.IsMatch(this.stuff_ProductCode.Text) == false)
System.Windows.MessageBox.Show("ERR.C0101:无效的原料信息", "错误");//检查原料代码
else
@ -145,6 +162,25 @@ namespace formula_manage.Windows
else
if (float.Parse(this.stuff_Concentration.Text) < 0 || float.Parse(this.stuff_Concentration.Text) > 100)
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
{
product.ProductCode = this.stuff_ProductCode.Text;//写入原料代码

Loading…
Cancel
Save