添加颜色名称页面
This commit is contained in:
commit
e6d467057a
4 files changed
+76
-23
No files matched your search
+26
-14
@@ -9,6 +9,10 @@
|
||||
mc:Ignorable="d" Loaded="color_Loaded"
|
||||
Title="color" Height="720" Width="1100" MaxHeight="720" MaxWidth="1100" MinHeight="720" MinWidth="1100"
|
||||
BorderBrush="White" Background="#FFE0E0E0">
|
||||
<Window.Resources>
|
||||
<!--引入转换器-->
|
||||
<ConvertMoels:ColorSQLConvert x:Key="ColorSQLConvert"/>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<!--原料表-->
|
||||
<DataGrid x:Name="DataGridcolor" MouseDoubleClick="DataGridcolor_MouseDoubleClick" SelectionMode="Single" AlternationCount="2" IsReadOnly="True" Margin="15,15,15,150" d:ItemsSource="{d:SampleData ItemCount=999}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||
@@ -52,33 +56,41 @@
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn Header="布种代码" Binding="{Binding Code}" Width="250" FontSize="15" MaxWidth="500" MinWidth="100" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="布种名称" Binding="{Binding Name}" Width="250" FontSize="15" MaxWidth="500" MinWidth="200" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="码重(g/Yard)" Binding="{Binding GYard}" Width="100" FontSize="15" MaxWidth="200" MinWidth="20" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="备注" Binding="{Binding Remark}" Width="500" FontSize="15" MaxWidth="1500" MinWidth="150" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="颜色代码" Binding="{Binding COLOR_CODE}" Width="250" FontSize="15" MaxWidth="500" MinWidth="100" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="颜色名称" Binding="{Binding COLOR_NAME}" Width="250" FontSize="15" MaxWidth="500" MinWidth="200" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="色彩" Width="100" FontSize="15" MaxWidth="200" MinWidth="20" CanUserReorder="False">
|
||||
<!--事件名称:色彩数字转色彩显示,转换器ColorSQLConvert-->
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Background" Value="{Binding COLOR_NO, Converter={StaticResource ColorSQLConvert}}"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Header="备注" Binding="{Binding COLOR_Remark}" Width="500" FontSize="15" MaxWidth="1500" MinWidth="150" CanUserReorder="False"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<!--布种代码-->
|
||||
<!--颜色代码-->
|
||||
<TextBox x:Name="color_code" HorizontalAlignment="Left" Height="30" Margin="105,0,0,100" Text=""
|
||||
VerticalAlignment="Bottom" Width="250" FontSize="22" MaxLines="1" MaxLength="25"
|
||||
InputMethod.IsInputMethodEnabled="False"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,0,0,100" TextWrapping="Wrap" Text="布种代码"
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,0,0,100" TextWrapping="Wrap" Text="颜色代码"
|
||||
VerticalAlignment="Bottom" Width="100" FontSize="20"/>
|
||||
<!--布种名称-->
|
||||
<!--颜色名称-->
|
||||
<TextBox x:Name="color_name" HorizontalAlignment="Left" Height="30" Margin="465,0,0,100" Text=""
|
||||
VerticalAlignment="Bottom" Width="250" FontSize="22" MaxLines="1" MaxLength="50"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="375,0,0,100" TextWrapping="Wrap" Text="布种名称"
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="375,0,0,100" TextWrapping="Wrap" Text="颜色名称"
|
||||
VerticalAlignment="Bottom" Width="100" FontSize="20"/>
|
||||
<!--备注-->
|
||||
<TextBox x:Name="color_Remark" HorizontalAlignment="Left" Height="30" Margin="105,0,0,50" Text=""
|
||||
VerticalAlignment="Bottom" Width="340" FontSize="22" MaxLines="1" MaxLength="25"/>
|
||||
VerticalAlignment="Bottom" Width="250" FontSize="22" MaxLines="1" MaxLength="25"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,0,0,50" TextWrapping="Wrap" Text="备注"
|
||||
VerticalAlignment="Bottom" Width="120" FontSize="20"/>
|
||||
<!--码重-->
|
||||
<TextBox x:Name="color_GYard" HorizontalAlignment="Left" Height="30" Margin="585,0,0,50" Text="500"
|
||||
VerticalAlignment="Bottom" Width="130" FontSize="22" MaxLines="1" MaxLength="25"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="465,0,0,50" TextWrapping="Wrap" Text="码重(g/Yard)"
|
||||
VerticalAlignment="Bottom" Width="120" FontSize="20"/>
|
||||
<!---->
|
||||
<TextBox x:Name="color_color" HorizontalAlignment="Left" Height="30" Margin="465,0,0,50" Text=""
|
||||
VerticalAlignment="Bottom" Width="250" FontSize="22" MaxLines="1" MaxLength="25"
|
||||
MouseDoubleClick="Color_MouseDoubleClick" IsReadOnly="True" Cursor="Arrow"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="375,0,0,50" TextWrapping="Wrap" Text="颜色"
|
||||
VerticalAlignment="Bottom" Width="40" FontSize="20"/>
|
||||
|
||||
<!--存储按钮-->
|
||||
<Button Content="存储" HorizontalAlignment="Left" Height="50" Margin="795,0,0,60"
|
||||
|
||||
+41
-9
@@ -65,7 +65,7 @@ namespace formula_manage.Windows
|
||||
Connstr_SC = "server=" + TEXT_SQLIP + ";database=" + TEXT_SQLNAME + ";User ID=" + TEXT_SQLUSER + ";Password=" + TEXT_SQLPASWOR;
|
||||
}
|
||||
|
||||
string color_sql = "SELECT Code ,Name , GYard , Remark FROM [dbo].[PRODUCTION_Material]";//查询语句
|
||||
string color_sql = "SELECT COLOR_CODE ,COLOR_NAME , COLOR_NO , COLOR_Remark FROM [dbo].[COLOR]";//查询语句
|
||||
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
try
|
||||
@@ -98,7 +98,7 @@ namespace formula_manage.Windows
|
||||
/// </summary>
|
||||
private async void GridSql()
|
||||
{
|
||||
string color_sql = "SELECT Code ,Name , GYard , Remark FROM [dbo].[PRODUCTION_Material]";//查询语句
|
||||
string color_sql = "SELECT COLOR_CODE ,COLOR_NAME , COLOR_NO , COLOR_Remark FROM [dbo].[COLOR]";//查询语句
|
||||
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
|
||||
@@ -124,8 +124,17 @@ namespace formula_manage.Windows
|
||||
{
|
||||
Regex re_number = new Regex(@"^[0-9]+(.[0-9]{1,4})?$");//校验用正则表达式有1~2位小数的正实数
|
||||
string color_sql;
|
||||
int ColorCode_SQL;
|
||||
|
||||
if ((re_number.IsMatch(this.color_GYard.Text) == false) && (color_GYard.Text != ""))
|
||||
string colorValue = color_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参数
|
||||
ColorCode_SQL = Convert.ToInt32(StuffColor, 16);//16进制转10进制
|
||||
if (ColorCode_SQL < 0) ColorCode_SQL = 16777215;//判断色彩数据是否有效
|
||||
|
||||
if ((re_number.IsMatch(this.color_color.Text) == false) && (color_color.Text != ""))
|
||||
System.Windows.MessageBox.Show("ERR:单位码重错误", "错误");//检查价格输入信息
|
||||
else
|
||||
if (string.IsNullOrEmpty(this.color_code.Text))
|
||||
@@ -138,7 +147,7 @@ namespace formula_manage.Windows
|
||||
try
|
||||
{
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
color_sql = "SELECT count(*) FROM [dbo].[PRODUCTION_Material] WHERE Code = '" + color_code.Text + " '";//查询语句
|
||||
color_sql = "SELECT count(*) FROM [dbo].[COLOR] WHERE COLOR_CODE = '" + color_code.Text + " '";//查询语句
|
||||
await conn_SC.OpenAsync(); //打开数据连
|
||||
SqlCommand cmd = new SqlCommand(color_sql, conn_SC); //查询记录数
|
||||
int count = Convert.ToInt32(cmd.ExecuteScalar()); //显示记录数
|
||||
@@ -146,8 +155,8 @@ namespace formula_manage.Windows
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
color_sql = string.Format("INSERT INTO [dbo].[PRODUCTION_Material](Code ,Name , GYard , Remark) " +
|
||||
"VALUES ('" + color_code.Text + "','" + color_name.Text + "','" + color_GYard.Text + "','" + color_Remark.Text + "')");
|
||||
color_sql = string.Format("INSERT INTO [dbo].[COLOR](COLOR_CODE ,COLOR_NAME , COLOR_NO , COLOR_Remark) " +
|
||||
"VALUES ('" + color_code.Text + "','" + color_name.Text + "','" + ColorCode_SQL + "','" + color_Remark.Text + "')");
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(color_sql, conn_SC);
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
@@ -165,7 +174,7 @@ namespace formula_manage.Windows
|
||||
}
|
||||
else
|
||||
{
|
||||
color_sql = string.Format("UPDATE [dbo].[PRODUCTION_Material] SET Name='" + color_name.Text + "',GYard='" + color_GYard.Text + "',Remark='" + color_Remark.Text + "' Where Code='"+ color_code.Text + "'");
|
||||
color_sql = string.Format("UPDATE [dbo].[COLOR] SET COLOR_NAME='" + color_name.Text + "',COLOR_NO='" + ColorCode_SQL + "',COLOR_Remark='" + color_Remark.Text + "' Where COLOR_CODE='" + color_code.Text + "'");
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(color_sql, conn_SC);
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
@@ -198,7 +207,7 @@ namespace formula_manage.Windows
|
||||
if (showProductName == MessageBoxResult.Yes)//判断是否删除
|
||||
{
|
||||
|
||||
string Stuff_sql = string.Format("DELETE FROM [dbo].[PRODUCTION_Material] WHERE Code ='" + color_code.Text.ToString() + "'");
|
||||
string Stuff_sql = string.Format("DELETE FROM [dbo].[COLOR] WHERE COLOR_CODE ='" + color_code.Text.ToString() + "'");
|
||||
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
try
|
||||
@@ -233,9 +242,32 @@ namespace formula_manage.Windows
|
||||
color_code.Text = (DataGridcolor.Columns[1].GetCellContent(DataGridcolor.Items[rownum]) as TextBlock).Text.TrimEnd();//定位第0列,代码
|
||||
color_name.Text = (DataGridcolor.Columns[2].GetCellContent(DataGridcolor.Items[rownum]) as TextBlock).Text.TrimEnd();//定位第1列,名称
|
||||
color_Remark.Text = (DataGridcolor.Columns[4].GetCellContent(DataGridcolor.Items[rownum]) as TextBlock).Text.TrimEnd();//定位,
|
||||
color_GYard.Text = (DataGridcolor.Columns[3].GetCellContent(DataGridcolor.Items[rownum]) as TextBlock).Text.TrimEnd();//定位,
|
||||
|
||||
if ((DataGridcolor.Columns[3].GetCellContent(DataGridcolor.Items[rownum]) as TextBlock).Background != null) //定位选中行单元格,色彩,判断参数是否有效
|
||||
{
|
||||
color_color.Background = (DataGridcolor.Columns[3].GetCellContent(DataGridcolor.Items[rownum]) as TextBlock).Background; //定位选中行单元格,色彩,有效背景色传递至色彩框背景色
|
||||
}
|
||||
else
|
||||
{
|
||||
color_color.Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 255, 255, 255));//白色传递至色彩框背景色
|
||||
}
|
||||
}
|
||||
}
|
||||
private void 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参数
|
||||
color_color.Background = new SolidColorBrush(MColor);//ARGB参数输出至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转存储数值
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user