sc 2 years ago
parent
commit
e8eedd0b1e
  1. 2
      MainWindow.xaml
  2. 5
      MainWindow.xaml.cs
  3. 40
      Windows/Stuff.xaml
  4. 139
      Windows/Stuff.xaml.cs
  5. 1
      formula_manage.csproj

2
MainWindow.xaml

@ -139,7 +139,7 @@
<DataGrid.Columns> <DataGrid.Columns>
<!--列信息绑定--> <!--列信息绑定-->
<DataGridTextColumn Header="序列" Width="50" FontSize="15" MaxWidth="50" MinWidth="50" IsReadOnly="True" Binding="{Binding ID}" CellStyle="{StaticResource CellStyle}"/> <DataGridTextColumn Header="序列" Width="50" FontSize="15" MaxWidth="50" MinWidth="50" IsReadOnly="True" Binding="{Binding ID}" CellStyle="{StaticResource CellStyle}"/>
<DataGridTemplateColumn Header="原料代码" Width="200" MaxWidth="400" MinWidth="100"> <DataGridTemplateColumn Header="原料代码" Width="200" MaxWidth="400" MinWidth="100" IsReadOnly="False">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<ComboBox x:Name="CP_PRODUCT_CODE" BorderThickness="0,0,0,0" Text="{Binding PRODUCT_CODE}" BorderBrush="{x:Null}" Background="{x:Null}" IsEditable="True" KeyDown="CP_PRODUCT_CODE_KeyUp"/> <ComboBox x:Name="CP_PRODUCT_CODE" BorderThickness="0,0,0,0" Text="{Binding PRODUCT_CODE}" BorderBrush="{x:Null}" Background="{x:Null}" IsEditable="True" KeyDown="CP_PRODUCT_CODE_KeyUp"/>

5
MainWindow.xaml.cs

@ -267,6 +267,7 @@ namespace formula_manage
private void CP_PRODUCT_CODE_KeyUp(object sender, System.Windows.Input.KeyEventArgs e) private void CP_PRODUCT_CODE_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
{ {
//string dsa= CP_PRODUCT_CODE //Grid_RRODUCT.SelectedItems[0].ToString(); //string dsa= CP_PRODUCT_CODE //Grid_RRODUCT.SelectedItems[0].ToString();
// int index = Grid_RRODUCT.CurrentCell; // int index = Grid_RRODUCT.CurrentCell;
@ -297,6 +298,10 @@ namespace formula_manage
if (e.Key == Key.Enter) if (e.Key == Key.Enter)
{ {
UserClass.PressKey.PressKeys(Keys.Right, false);
UserClass.PressKey.PressKeys(Keys.Right, true);
UserClass.PressKey.PressKeys(Keys.Up, false);
UserClass.PressKey.PressKeys(Keys.Up, true);
UserClass.PressKey.PressKeys(Keys.Tab, false); UserClass.PressKey.PressKeys(Keys.Tab, false);
UserClass.PressKey.PressKeys(Keys.Tab, true); UserClass.PressKey.PressKeys(Keys.Tab, true);
} }

40
Windows/Stuff.xaml

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:formula_manage.Windows" xmlns:local="clr-namespace:formula_manage.Windows"
mc:Ignorable="d" mc:Ignorable="d"
Title="Stuff" Height="720" Width="1280" BorderBrush="White" Background="#FFE0E0E0"> Title="Stuff" Height="720" Width="1100" BorderBrush="White" Background="#FFE0E0E0">
<Grid> <Grid>
<!--原料表--> <!--原料表-->
@ -73,16 +73,16 @@
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
<!--搜索类型--> <!--搜索类型-->
<!-- <RadioButton Content="染料" x:Name="Button_0" Click="Radiobutton" HorizontalAlignment="Left" Height="40" Margin="995,265,0,0" <RadioButton Content="染料" x:Name="Button_0" Click="Radiobutton" HorizontalAlignment="Left" Height="20" Margin="995,265,0,0"
VerticalAlignment="Top" Width="100" FontSize="18" BorderBrush="{x:Null}" Background="{x:Null}" Grid.Column="1"/> VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" FontSize="14"/>
<RadioButton Content="助剂" x:Name="Button_1" Click="Radiobutton" HorizontalAlignment="Left" Height="40" Margin="995,305,0,0" <RadioButton Content="助剂" x:Name="Button_1" Click="Radiobutton" HorizontalAlignment="Left" Height="20" Margin="995,295,0,0"
VerticalAlignment="Top" Width="100" FontSize="18" BorderBrush="{x:Null}" Background="{x:Null}" Grid.Column="1"/> VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" FontSize="14"/>
<RadioButton Content="粉体助剂" x:Name="Button_2" Click="Radiobutton" HorizontalAlignment="Left" Height="40" Margin="995,345,0,0" <RadioButton Content="粉体助剂" x:Name="Button_2" Click="Radiobutton" HorizontalAlignment="Left" Height="20" Margin="995,325,0,0"
VerticalAlignment="Top" Width="100" FontSize="18" BorderBrush="{x:Null}" Background="{x:Null}" Grid.Column="1"/> VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" FontSize="14"/>
<RadioButton Content="液体染料" x:Name="Button_3" Click="Radiobutton" HorizontalAlignment="Left" Height="40" Margin="995,385,0,0" <RadioButton Content="液体染料" x:Name="Button_3" Click="Radiobutton" HorizontalAlignment="Left" Height="20" Margin="995,355,0,0"
VerticalAlignment="Top" Width="100" FontSize="18" BorderBrush="{x:Null}" Background="{x:Null}" Grid.Column="1"/> VerticalAlignment="Top" Width="100" BorderBrush="Black" Background="White" Grid.Column="1" FontSize="14"/>
<RadioButton Content="全部原料" x:Name="Button_all" Click="Radiobutton" HorizontalAlignment="Left" Height="40" Margin="995,425,0,0" <RadioButton Content="全部原料" x:Name="Button_all" Click="Radiobutton" HorizontalAlignment="Left" Height="20" Margin="995,385,0,0"
VerticalAlignment="Top" Width="100" FontSize="18" BorderBrush="{x:Null}" Background="{x:Null}" Grid.Column="1" IsChecked="True"/>--> 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="" <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" VerticalAlignment="Bottom" Width="130" FontSize="22" MaxLines="1" MaxLength="25"
@ -106,7 +106,8 @@
VerticalAlignment="Bottom" Width="100" FontSize="20"/> VerticalAlignment="Bottom" Width="100" FontSize="20"/>
<!--色彩--> <!--色彩-->
<TextBox x:Name="stuff_Color" HorizontalAlignment="Left" Height="30" Margin="445,0,0,50" <TextBox x:Name="stuff_Color" HorizontalAlignment="Left" Height="30" Margin="445,0,0,50"
VerticalAlignment="Bottom" Width="80" MaxLines="1" IsReadOnly="True" Cursor="Arrow"/> VerticalAlignment="Bottom" Width="80" MaxLines="1" IsReadOnly="True" Cursor="Arrow"
MouseDoubleClick="Stuff_Color_MouseDoubleClick"/>
<TextBlock HorizontalAlignment="Left" Height="30" Margin="400,0,0,50" TextWrapping="Wrap" Text="色彩" <TextBlock HorizontalAlignment="Left" Height="30" Margin="400,0,0,50" TextWrapping="Wrap" Text="色彩"
VerticalAlignment="Bottom" Width="50" FontSize="20"/> VerticalAlignment="Bottom" Width="50" FontSize="20"/>
<!--供应商--> <!--供应商-->
@ -134,13 +135,14 @@
<TextBlock HorizontalAlignment="Left" Height="30" Margin="650,0,0,50" TextWrapping="Wrap" Text="比重" <TextBlock HorizontalAlignment="Left" Height="30" Margin="650,0,0,50" TextWrapping="Wrap" Text="比重"
VerticalAlignment="Bottom" Width="45" FontSize="20"/> VerticalAlignment="Bottom" Width="45" FontSize="20"/>
<!--存储按钮--> <!--存储按钮-->
<!-- <Button Content="存储" HorizontalAlignment="Left" Height="65" Margin="795,0,0,60" <Button Content="存储" HorizontalAlignment="Left" Height="50" Margin="795,0,0,60"
VerticalAlignment="Bottom" Width="145" FontSize="40" BorderBrush="{x:Null}" Background="#FFEFEFEF" VerticalAlignment="Bottom" Width="100" FontSize="30" Background="#FFEFEFEF" BorderBrush="White"
Click="Button_Preservation"> Click="Button_Preservation">
</Button> --> </Button>
<!--删除按钮--> <!--删除按钮-->
<!-- <Button Content="删除" HorizontalAlignment="Left" Height="65" Margin="975,0,0,60" <Button Content="删除" HorizontalAlignment="Left" Height="50" Margin="935,0,0,60"
VerticalAlignment="Bottom" Width="145" FontSize="40" BorderBrush="{x:Null}" Background="#FFEFEFEF" VerticalAlignment="Bottom" Width="100" FontSize="30" Background="#FFEFEFEF" BorderBrush="White"
Click="Button_Delete"> </Button> --> Click="Button_Delete">
</Button>
</Grid> </Grid>
</Window> </Window>

139
Windows/Stuff.xaml.cs

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
@ -12,6 +13,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace formula_manage.Windows namespace formula_manage.Windows
{ {
/// <summary> /// <summary>
@ -24,5 +26,140 @@ namespace formula_manage.Windows
WindowStartupLocation = WindowStartupLocation.CenterScreen; WindowStartupLocation = WindowStartupLocation.CenterScreen;
InitializeComponent(); InitializeComponent();
} }
}
private void Radiobutton(object sender, EventArgs e)
{
/* 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;
*/ }
private 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;
if (this.stuff_ProductType.Text == "染料") //原料类型0。染料,1助剂,2粉体
{
int_stuff_ProductType = 0;
this.stuff_Concentration.Text = "100";
}
if (this.stuff_ProductType.Text == "助剂")
int_stuff_ProductType = 1;
if (this.stuff_ProductType.Text == "粉体助剂")
{
int_stuff_ProductType = 2;
this.stuff_Concentration.Text = "100";
}
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
if (string.IsNullOrEmpty(this.stuff_ProductName.Text))
System.Windows.MessageBox.Show("ERR.C0101-2:无效的原料信息", "错误");//检查原料名称
else
if (string.IsNullOrEmpty(this.stuff_ProductType.Text))
System.Windows.MessageBox.Show("ERR.C0101-3:无效的原料信息", "错误");//检查原料类型
else
if (string.IsNullOrEmpty(this.stuff_GRAVITY.Text))
System.Windows.MessageBox.Show("ERR.C0101-1:无效的原料信息", "错误");//检查原料比重
else
if (re_number.IsMatch(this.stuff_GRAVITY.Text) == false)
System.Windows.MessageBox.Show("ERR.C0102-1:原料信息错误", "错误");//检查比重输入信息
else
if (re_number.IsMatch(this.stuff_Concentration.Text) == false)
System.Windows.MessageBox.Show("ERR.C0102-3:原料信息错误", "错误");//检查浓度输入信息
else
if (float.Parse(this.stuff_GRAVITY.Text) < 0 || float.Parse(this.stuff_GRAVITY.Text) > 5)
System.Windows.MessageBox.Show("ERR.C0102-2:原料信息错误", "错误");//检查比重输入数值
else
if (float.Parse(this.stuff_Concentration.Text) < 0 || float.Parse(this.stuff_Concentration.Text) > 100)
System.Windows.MessageBox.Show("ERR.C0102-4:原料信息错误", "错误");//检查浓度输入数值
/* else
{
product.ProductCode = this.stuff_ProductCode.Text;//写入原料代码
product.ProductName = this.stuff_ProductName.Text;//写入原料名称
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参数
int ColorCode_SQL = Convert.ToInt32(StuffColor, 16);//16进制转10进制
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_SUPPLIER.Text) == false)
product.SUPPLIER = this.stuff_SUPPLIER.Text;//判断供应商数据是否有效,有效写
product.GRAVITY = Double.Parse(this.stuff_GRAVITY.Text);//写入原料比重
if (this.stuff_ProductType.Text == "染料" || this.stuff_ProductType.Text == "粉体助剂")
product.Concentration = 0;
else
product.Concentration = Double.Parse(this.stuff_Concentration.Text);//写入原料浓度
product.ProductType = int_stuff_ProductType;//写入原料类型
product.ProductCode = this.stuff_ProductCode.Text;//写入原料代码
if (new ProductProvider().Selectsql(product).Count == 0)//判断数据库设定目标信息是否存在。
{
var count = new ProductProvider().Insert(product);//添加数据库信息。
if (count == 0)
System.Windows.MessageBox.Show("ERR.C0110-1:添加失败", "错误");//判断执行是否成功
else
Button_sql = true;
}
else
{
var count = new ProductProvider().Update(product);//添加数据库信息。
if (count == 0)
System.Windows.MessageBox.Show("ERR.C0102-5:更新失败", "错误");//执行是否成功
else
Button_sql = true;
}
}
*/
}
private void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
{
/* product.ProductCode = this.stuff_ProductCode.Text;//原料代码
string ShowProductName = "是否删除原料【" + this.stuff_ProductName.Text + "】" + this.stuff_ProductCode.Text;//获取原料信息并拼接提示字符串
MessageBoxResult showProductName = System.Windows.MessageBox.Show(ShowProductName, "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes);//弹窗提示是否删除目标原料
if (showProductName == MessageBoxResult.Yes)//判断是否删除原料
{
var count = new ProductProvider().Delete(product);//删除数据库目标信息。
if (count == 0) System.Windows.MessageBox.Show("ERR.C0110-2:删除失败", "错误");//判断执行是否成功
else Button_sql = true;}
*/
}
private void Stuff_Color_MouseDoubleClick(object sender, MouseButtonEventArgs e)//色彩框双击事件
{
System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog();//使用调色盘控件ColorDialog
if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)//打开调色盘
{
System.Drawing.Color DColor = colorDialog.Color;////获取选中色彩信息
//System.Windows.Media.Color MColor = new System.Windows.Media.Color();//转换
System.Windows.Media.Color MColor = System.Windows.Media.Color.FromArgb(DColor.A, DColor.R, DColor.G, DColor.B);//转换并配置ARGB参数
stuff_Color.Background = new SolidColorBrush(MColor);//ARGB参数输出至stuff_Color的背景色
//string colorCode = string.Format("{0:X2}", DColor.B) + string.Format("{0:X2}", DColor.G) + string.Format("{0:X2}", DColor.R);//反向十六进制RGB
//string colorCode = string.Format("{0:X2}", DColor.R) + string.Format("{0:X2}", DColor.G) + string.Format("{0:X2}", DColor.B);//正向十六进制RGB
//ColorCode_SQL = Convert.ToInt32(colorCode, 16);//十六进制RGB转存储数值
}
}
}
} }

1
formula_manage.csproj

@ -65,6 +65,7 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

Loading…
Cancel
Save