机台设置页面
This commit is contained in:
commit
9e4d938ef8
7 files changed
+382
-15
No files matched your search
@@ -0,0 +1,78 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
namespace formula_manage.ConvertMoels
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设备类型数值转换器
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
internal class CategoriesSQLConvert : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
string Categories = System.Convert.ToString(value);
|
||||||
|
if (Categories == "0")//类型
|
||||||
|
{
|
||||||
|
return "溢流";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Categories == "1")
|
||||||
|
{
|
||||||
|
return "气流";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Categories == "2")
|
||||||
|
{
|
||||||
|
return "轧染";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Categories == "3")
|
||||||
|
{
|
||||||
|
return "卷染";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Categories == "4")
|
||||||
|
{
|
||||||
|
return "喷染";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Categories == "5")
|
||||||
|
{
|
||||||
|
return "筒纱";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Categories == "7")
|
||||||
|
{
|
||||||
|
return "成衣";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "未知类型";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Data;
|
||||||
|
|
||||||
|
namespace formula_manage.ConvertMoels
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设备数值转换器
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
internal class IndustrySQLConvert : IValueConverter
|
||||||
|
{
|
||||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
string Industry = System.Convert.ToString(value);
|
||||||
|
if (Industry == "0")//类型
|
||||||
|
{
|
||||||
|
return "浸染";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Industry == "1")
|
||||||
|
{
|
||||||
|
return "连染";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (Industry == "2")
|
||||||
|
{
|
||||||
|
return "印染";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "未知类型";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// </summary>
|
||||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+34
-13
@@ -4,13 +4,20 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
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"
|
xmlns:ConvertMoels="clr-namespace:formula_manage.ConvertMoels"
|
||||||
Title="MAC_SET" Height="720" Width="1100"
|
xmlns:viewmodel="clr-namespace:formula_manage.ViewModel"
|
||||||
|
mc:Ignorable="d" Loaded="MAC_Loaded"
|
||||||
|
Title="MAC_SET" Height="720" Width="1100" MaxHeight="720" MaxWidth="1100" MinHeight="720" MinWidth="1100"
|
||||||
BorderBrush="White" Background="#FFE0E0E0">
|
BorderBrush="White" Background="#FFE0E0E0">
|
||||||
|
<Window.Resources>
|
||||||
|
<!--引入转换器-->
|
||||||
|
<ConvertMoels:CategoriesSQLConvert x:Key="CategoriesSQLConvert"/>
|
||||||
|
<ConvertMoels:IndustrySQLConvert x:Key="IndustrySQLConvert"/>
|
||||||
|
</Window.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<!--设备表-->
|
<!--设备表-->
|
||||||
<DataGrid x:Name="DataGridMac" MouseDoubleClick="DataGridMac_MouseDoubleClick" SelectionMode="Single" AlternationCount="2" IsReadOnly="True"
|
<DataGrid x:Name="DataGridMac" MouseDoubleClick="DataGridMac_MouseDoubleClick" SelectionMode="Single" AlternationCount="2" IsReadOnly="True"
|
||||||
Margin="15,15,15,150" d:ItemsSource="{d:SampleData ItemCount=200}" AutoGenerateColumns="False" MinColumnWidth="30"
|
Margin="15,15,15,150" d:ItemsSource="{d:SampleData ItemCount=999}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||||
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
|
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
|
||||||
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2"
|
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2"
|
||||||
CanUserResizeRows="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False"
|
CanUserResizeRows="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False"
|
||||||
@@ -55,8 +62,22 @@
|
|||||||
<DataGridTextColumn Header="机组" Binding="{Binding MacGroup}" Width="100" FontSize="15" MaxWidth="100" MinWidth="100" CanUserReorder="False"/>
|
<DataGridTextColumn Header="机组" Binding="{Binding MacGroup}" Width="100" FontSize="15" MaxWidth="100" MinWidth="100" CanUserReorder="False"/>
|
||||||
<DataGridTextColumn Header="载量(KG)" Binding="{Binding Capacity}" Width="100" FontSize="15" MaxWidth="100" MinWidth="100" CanUserReorder="False"/>
|
<DataGridTextColumn Header="载量(KG)" Binding="{Binding Capacity}" Width="100" FontSize="15" MaxWidth="100" MinWidth="100" CanUserReorder="False"/>
|
||||||
<DataGridTextColumn Header="容量(L)" Binding="{Binding Volume}" Width="100" FontSize="15" MaxWidth="100" MinWidth="100" CanUserReorder="False"/>
|
<DataGridTextColumn Header="容量(L)" Binding="{Binding Volume}" Width="100" FontSize="15" MaxWidth="100" MinWidth="100" CanUserReorder="False"/>
|
||||||
<DataGridTextColumn Header="染色方式" Binding="{Binding Industry}" Width="100" FontSize="15" MaxWidth="100" MinWidth="100" CanUserReorder="False"/>
|
<DataGridTextColumn Header="染色方式" Width="100" FontSize="15" MaxWidth="100" MinWidth="100" CanUserReorder="False">
|
||||||
<DataGridTextColumn Header="类型" Binding="{Binding Categories}" Width="100" FontSize="15" MaxWidth="100" MinWidth="100" CanUserReorder="False"/>
|
<!--事件名称:方式类型数字转文字显示,转换器IndustrySQLConvert-->
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="{x:Type TextBlock}">
|
||||||
|
<Setter Property="Text" Value="{Binding Industry, Converter={StaticResource IndustrySQLConvert}}"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
|
<DataGridTextColumn Header="类型" Width="100" FontSize="15" MaxWidth="100" MinWidth="100" CanUserReorder="False">
|
||||||
|
<!--事件名称:类型类型数字转文字显示,转换器IndustrySQLConvert-->
|
||||||
|
<DataGridTextColumn.ElementStyle>
|
||||||
|
<Style TargetType="{x:Type TextBlock}">
|
||||||
|
<Setter Property="Text" Value="{Binding Categories, Converter={StaticResource CategoriesSQLConvert}}"/>
|
||||||
|
</Style>
|
||||||
|
</DataGridTextColumn.ElementStyle>
|
||||||
|
</DataGridTextColumn>
|
||||||
<DataGridTextColumn Header="备注" Binding="{Binding Note}" Width="600" FontSize="15" MinWidth="100" CanUserReorder="False"/>
|
<DataGridTextColumn Header="备注" Binding="{Binding Note}" Width="600" FontSize="15" MinWidth="100" CanUserReorder="False"/>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
@@ -64,12 +85,12 @@
|
|||||||
<TextBox x:Name="mac_Name" HorizontalAlignment="Left" Height="30" Margin="105,0,0,100" Text=""
|
<TextBox x:Name="mac_Name" HorizontalAlignment="Left" Height="30" Margin="105,0,0,100" Text=""
|
||||||
VerticalAlignment="Bottom" Width="100" FontSize="22" MaxLines="1" MaxLength="50" />
|
VerticalAlignment="Bottom" Width="100" FontSize="22" MaxLines="1" MaxLength="50" />
|
||||||
<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"/>
|
VerticalAlignment="Bottom" Width="85" FontSize="20"/>
|
||||||
<!--机组-->
|
<!--机组-->
|
||||||
<TextBox x:Name="mac_MacGroup" HorizontalAlignment="Left" Height="30" Margin="275,0,0,100" Text=""
|
<TextBox x:Name="mac_MacGroup" HorizontalAlignment="Left" Height="30" Margin="275,0,0,100" Text=""
|
||||||
VerticalAlignment="Bottom" Width="100" FontSize="22" MaxLines="1" MaxLength="50"/>
|
VerticalAlignment="Bottom" Width="100" FontSize="22" MaxLines="1" MaxLength="50"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="225,0,0,100" TextWrapping="Wrap" Text="机组"
|
<TextBlock HorizontalAlignment="Left" Height="30" Margin="225,0,0,100" TextWrapping="Wrap" Text="机组"
|
||||||
VerticalAlignment="Bottom" Width="100" FontSize="20"/>
|
VerticalAlignment="Bottom" Width="45" FontSize="20"/>
|
||||||
<!--染色方式-->
|
<!--染色方式-->
|
||||||
<ComboBox x:Name="mac_Industry" HorizontalAlignment="Left" Height="30" Margin="435,0,0,100" Text=""
|
<ComboBox x:Name="mac_Industry" HorizontalAlignment="Left" Height="30" Margin="435,0,0,100" Text=""
|
||||||
VerticalAlignment="Bottom" Width="100" FontSize="16" IsReadOnly="True" IsEditable="True">
|
VerticalAlignment="Bottom" Width="100" FontSize="16" IsReadOnly="True" IsEditable="True">
|
||||||
@@ -78,7 +99,7 @@
|
|||||||
<ComboBoxItem Content="印染"></ComboBoxItem>
|
<ComboBoxItem Content="印染"></ComboBoxItem>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="390,0,0,100" TextWrapping="Wrap" Text="方式"
|
<TextBlock HorizontalAlignment="Left" Height="30" Margin="390,0,0,100" TextWrapping="Wrap" Text="方式"
|
||||||
VerticalAlignment="Bottom" Width="100" FontSize="20"/>
|
VerticalAlignment="Bottom" Width="45" FontSize="20"/>
|
||||||
<!--类型-->
|
<!--类型-->
|
||||||
<ComboBox x:Name="mac_Categories" HorizontalAlignment="Left" Height="30" Margin="600,0,0,100" Text=""
|
<ComboBox x:Name="mac_Categories" HorizontalAlignment="Left" Height="30" Margin="600,0,0,100" Text=""
|
||||||
VerticalAlignment="Bottom" Width="100" FontSize="16" IsReadOnly="True" IsEditable="True">
|
VerticalAlignment="Bottom" Width="100" FontSize="16" IsReadOnly="True" IsEditable="True">
|
||||||
@@ -91,24 +112,24 @@
|
|||||||
<ComboBoxItem Content="成衣"></ComboBoxItem>
|
<ComboBoxItem Content="成衣"></ComboBoxItem>
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="550,0,0,100" TextWrapping="Wrap" Text="类型"
|
<TextBlock HorizontalAlignment="Left" Height="30" Margin="550,0,0,100" TextWrapping="Wrap" Text="类型"
|
||||||
VerticalAlignment="Bottom" Width="100" FontSize="20"/>
|
VerticalAlignment="Bottom" Width="45" FontSize="20"/>
|
||||||
<!--载量-->
|
<!--载量-->
|
||||||
<TextBox x:Name="mac_Capacity" HorizontalAlignment="Left" Height="30" Margin="105,0,0,50" Text=""
|
<TextBox x:Name="mac_Capacity" HorizontalAlignment="Left" Height="30" Margin="105,0,0,50" Text=""
|
||||||
VerticalAlignment="Bottom" Width="100" FontSize="22" MaxLines="1" MaxLength="25"
|
VerticalAlignment="Bottom" Width="100" FontSize="22" MaxLines="1" MaxLength="25"
|
||||||
InputMethod.IsInputMethodEnabled="False"/>
|
InputMethod.IsInputMethodEnabled="False" PreviewTextInput="Tb_KeyFloating"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,0,0,50" TextWrapping="Wrap" Text="载量"
|
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,0,0,50" TextWrapping="Wrap" Text="载量"
|
||||||
VerticalAlignment="Bottom" Width="80" FontSize="20"/>
|
VerticalAlignment="Bottom" Width="80" FontSize="20"/>
|
||||||
<!--容量-->
|
<!--容量-->
|
||||||
<TextBox x:Name="mac_Volume" HorizontalAlignment="Left" Height="30" Margin="275,0,0,50" Text=""
|
<TextBox x:Name="mac_Volume" HorizontalAlignment="Left" Height="30" Margin="275,0,0,50" Text=""
|
||||||
VerticalAlignment="Bottom" Width="100" FontSize="22" MaxLines="1" MaxLength="25"
|
VerticalAlignment="Bottom" Width="100" FontSize="22" MaxLines="1" MaxLength="25"
|
||||||
InputMethod.IsInputMethodEnabled="False"/>
|
InputMethod.IsInputMethodEnabled="False" PreviewTextInput="Tb_KeyFloating"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="225,0,0,50" TextWrapping="Wrap" Text="容量"
|
<TextBlock HorizontalAlignment="Left" Height="30" Margin="225,0,0,50" TextWrapping="Wrap" Text="容量"
|
||||||
VerticalAlignment="Bottom" Width="80" FontSize="20"/>
|
VerticalAlignment="Bottom" Width="45" FontSize="20"/>
|
||||||
<!--备注-->
|
<!--备注-->
|
||||||
<TextBox x:Name="mac_Note" HorizontalAlignment="Left" Height="30" Margin="435,0,0,50"
|
<TextBox x:Name="mac_Note" HorizontalAlignment="Left" Height="30" Margin="435,0,0,50"
|
||||||
VerticalAlignment="Bottom" Width="265" FontSize="22" MaxLines="1"/>
|
VerticalAlignment="Bottom" Width="265" FontSize="22" MaxLines="1"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="390,0,0,50" TextWrapping="Wrap" Text="备注"
|
<TextBlock HorizontalAlignment="Left" Height="30" Margin="390,0,0,50" TextWrapping="Wrap" Text="备注"
|
||||||
VerticalAlignment="Bottom" Width="50" FontSize="20"/>
|
VerticalAlignment="Bottom" Width="40" FontSize="20"/>
|
||||||
|
|
||||||
<!--存储按钮-->
|
<!--存储按钮-->
|
||||||
<Button Content="存储" HorizontalAlignment="Left" Height="50" Margin="795,0,0,60"
|
<Button Content="存储" HorizontalAlignment="Left" Height="50" Margin="795,0,0,60"
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -11,6 +12,13 @@ using System.Windows.Input;
|
|||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using GalaSoft.MvvmLight;
|
||||||
|
using formula_manage.SQLModels;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.Data;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;
|
||||||
|
using Xceed.Wpf.AvalonDock.Themes;
|
||||||
|
|
||||||
namespace formula_manage.Windows
|
namespace formula_manage.Windows
|
||||||
{
|
{
|
||||||
@@ -19,22 +27,231 @@ namespace formula_manage.Windows
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Machine : Window
|
public partial class Machine : Window
|
||||||
{
|
{
|
||||||
|
public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "formula.ini"; //配置文件路径
|
||||||
|
|
||||||
|
string TEXT_SQLIP;
|
||||||
|
string TEXT_SQLNAME;
|
||||||
|
string TEXT_SQMOD;
|
||||||
|
string TEXT_SQLUSER;
|
||||||
|
string TEXT_SQLPASWOR;
|
||||||
|
string Connstr_SC;
|
||||||
public Machine()
|
public Machine()
|
||||||
{
|
{
|
||||||
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async void MAC_Loaded(object sender, RoutedEventArgs e)//打开页面执行
|
||||||
|
{
|
||||||
|
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);//生效配置读取
|
||||||
|
this.DataGridMac.LoadingRow += new EventHandler<DataGridRowEventArgs>(this.DataGridEquipment_LoadingRow);//生成序列号
|
||||||
|
|
||||||
|
TEXT_SQLIP = Configini.IniReadvalue("SQL_SERVER", "SQL1"); //读配置文件
|
||||||
|
TEXT_SQLNAME = Configini.IniReadvalue("SQL_SERVER", "SQL2");
|
||||||
|
TEXT_SQMOD = Configini.IniReadvalue("SQL_SERVER", "SQL3");
|
||||||
|
TEXT_SQLUSER = Configini.IniReadvalue("SQL_SERVER", "SQL4");
|
||||||
|
TEXT_SQLPASWOR = Configini.IniReadvalue("SQL_SERVER", "SQL5");
|
||||||
|
if (TEXT_SQMOD == "0") //判断连接方式
|
||||||
|
{
|
||||||
|
Connstr_SC = "server=" + TEXT_SQLIP + ";database=" + TEXT_SQLNAME + ";Trusted_Connection=SSPI";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Connstr_SC = "server=" + TEXT_SQLIP + ";database=" + TEXT_SQLNAME + ";User ID=" + TEXT_SQLUSER + ";Password=" + TEXT_SQLPASWOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
string Stuff_sql = "SELECT Name ,MacGroup ,Capacity ,Volume ,Industry ,Categories ,Note FROM [Dispensing].[dbo].[MACHINE]";//查询语句
|
||||||
|
|
||||||
|
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(); //关闭连接
|
||||||
|
|
||||||
|
DataGridMac.ItemsSource = dataTable.DefaultView; //数据加入表格
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("请求信息失败,检查连接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成序列号的方法
|
||||||
|
/// </summary>
|
||||||
|
private void DataGridEquipment_LoadingRow(object sender, DataGridRowEventArgs e)
|
||||||
|
{
|
||||||
|
e.Row.Header = e.Row.GetIndex() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询数据库的方法
|
||||||
|
/// </summary>
|
||||||
|
private async void GridSql()
|
||||||
|
{
|
||||||
|
string Stuff_sql = "SELECT Name ,MacGroup ,Capacity ,Volume ,Industry ,Categories ,Note FROM [Dispensing].[dbo].[MACHINE]";//查询语句
|
||||||
|
|
||||||
|
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(); //关闭连接
|
||||||
|
|
||||||
|
DataGridMac.ItemsSource = dataTable.DefaultView; //数据加入表格
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("请求信息失败,检查连接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Tb_KeyFloating(object sender, TextCompositionEventArgs e)//输入事件
|
||||||
|
{
|
||||||
|
//Regex re = new Regex("[^0-9.-]+");
|
||||||
|
Regex re = new Regex(@"^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$");// 非负浮点数
|
||||||
|
e.Handled = !re.IsMatch(e.Text);
|
||||||
|
}
|
||||||
|
|
||||||
private void DataGridMac_MouseDoubleClick(object sender, MouseButtonEventArgs e)//数据表双击事件
|
private void DataGridMac_MouseDoubleClick(object sender, MouseButtonEventArgs e)//数据表双击事件
|
||||||
{
|
{
|
||||||
|
int rownum = DataGridMac.SelectedIndex;//获取鼠标选中行并定义变量
|
||||||
|
if (rownum != -1)//判断鼠标定位是否有效
|
||||||
|
{
|
||||||
|
/*定位选中行及指定列单元格文本信息*/
|
||||||
|
mac_Name.Text = (DataGridMac.Columns[1].GetCellContent(DataGridMac.Items[rownum]) as TextBlock).Text.Trim();//定位第列
|
||||||
|
mac_MacGroup.Text = (DataGridMac.Columns[2].GetCellContent(DataGridMac.Items[rownum]) as TextBlock).Text.Trim();//
|
||||||
|
mac_Capacity.Text = (DataGridMac.Columns[3].GetCellContent(DataGridMac .Items[rownum]) as TextBlock).Text.Trim();//
|
||||||
|
mac_Volume.Text = (DataGridMac.Columns[4].GetCellContent(DataGridMac.Items[rownum]) as TextBlock).Text.Trim();//
|
||||||
|
mac_Industry.Text = (DataGridMac.Columns[5].GetCellContent(DataGridMac.Items[rownum]) as TextBlock).Text.Trim();//
|
||||||
|
mac_Categories.Text = (DataGridMac.Columns[6].GetCellContent(DataGridMac.Items[rownum]) as TextBlock).Text.Trim();//
|
||||||
|
mac_Note.Text = (DataGridMac.Columns[7].GetCellContent(DataGridMac.Items[rownum]) as TextBlock).Text.Trim();//
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async 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个英文字母,空白字符和@()()/+!!_-组成的字符串
|
||||||
|
string Mac_name = mac_Name.Text;
|
||||||
|
string Mac_group = mac_MacGroup.Text;
|
||||||
|
string Mac_capacity = mac_Capacity.Text;
|
||||||
|
string Mac_volume = mac_Volume.Text;
|
||||||
|
string Mac_industry = mac_Industry.Text;
|
||||||
|
string Mac_categories = mac_Categories.Text;
|
||||||
|
string Mac_note = mac_Note.Text;
|
||||||
|
string Stuff_sql;
|
||||||
|
|
||||||
|
if (Mac_industry == "浸染") Mac_industry = "0";
|
||||||
|
else if (Mac_industry == "连染") Mac_industry = "1";
|
||||||
|
else if (Mac_industry == "印染") Mac_industry = "2";
|
||||||
|
|
||||||
|
if (Mac_categories == "溢流") Mac_categories = "0";
|
||||||
|
else if (Mac_categories == "气流") Mac_categories = "1";
|
||||||
|
else if (Mac_categories == "轧染") Mac_categories = "2";
|
||||||
|
else if (Mac_categories == "卷染") Mac_categories = "3";
|
||||||
|
else if (Mac_categories == "喷染") Mac_categories = "4";
|
||||||
|
else if (Mac_categories == "筒纱") Mac_categories = "5";
|
||||||
|
else if (Mac_categories == "成衣") Mac_categories = "6";
|
||||||
|
|
||||||
|
if (Mac_capacity == "") Mac_capacity = "NULL";
|
||||||
|
if (Mac_volume == "") Mac_volume = "NULL";
|
||||||
|
if (Mac_industry == "") Mac_industry = "NULL";
|
||||||
|
if (Mac_categories == "") Mac_categories = "NULL";
|
||||||
|
|
||||||
|
if (mac_Name.Text != null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||||
|
Stuff_sql = "SELECT count(*) FROM [Dispensing].[dbo].[MACHINE] WHERE Name = '" + Mac_name + " '";//查询语句
|
||||||
|
await conn_SC.OpenAsync(); //打开数据连
|
||||||
|
SqlCommand cmd = new SqlCommand(Stuff_sql, conn_SC); //查询记录数
|
||||||
|
int count = Convert.ToInt32(cmd.ExecuteScalar()); //显示记录数
|
||||||
|
conn_SC.Close(); //关闭连接
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
Stuff_sql = string.Format("INSERT INTO[Dispensing].[dbo].[MACHINE](Name ,MacGroup ,Capacity ,Volume ,Industry ,Categories ,Note ) " +
|
||||||
|
"VALUES ('" + Mac_name + "','" + Mac_group + "'," + Mac_capacity + "," + Mac_volume + "," + Mac_industry + "," + Mac_categories + ",'" + Mac_note + "')");
|
||||||
|
await conn_SC.OpenAsync(); //打开数据连接
|
||||||
|
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC);
|
||||||
|
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||||
|
conn_SC.Close(); //关闭连接
|
||||||
|
if (sql_in == 0)
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("添加失败");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GridSql();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Stuff_sql = string.Format("UPDATE [dbo].[MACHINE] SET MacGroup ='" + Mac_group + "',Capacity=" + Mac_capacity + " ,Volume=" + Mac_volume + " ,Industry=" + Mac_industry + " ,Categories=" + Mac_categories + " ,Note='" + Mac_note + "' Where Name ='" + Mac_name + "'");
|
||||||
|
await conn_SC.OpenAsync(); //打开数据连接
|
||||||
|
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC);
|
||||||
|
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||||
|
conn_SC.Close(); //关闭连接
|
||||||
|
|
||||||
|
if (sql_in == 0)
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("修改失败");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GridSql();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("请求失败,检查连接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
|
private async void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
|
||||||
{
|
{
|
||||||
|
string Mac_name = "是否删除【" + this.mac_Name.Text + "】";//获取原料信息并拼接提示字符串
|
||||||
|
MessageBoxResult mac_name = System.Windows.MessageBox.Show(Mac_name, "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes);//弹窗提示是否删除目标原料
|
||||||
|
if (mac_name == MessageBoxResult.Yes)//判断是否删除原料
|
||||||
|
{
|
||||||
|
string Stuff_sql = string.Format("DELETE FROM [dbo].[MACHINE] WHERE Name ='" + mac_Name.Text.ToString() + "'");
|
||||||
|
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await conn_SC.OpenAsync(); //打开数据连接
|
||||||
|
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC);
|
||||||
|
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||||
|
conn_SC.Close(); //关闭连接
|
||||||
|
if (sql_in == 0)
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("ERR.C0110-2:删除失败", "错误");//判断执行是否成功
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GridSql();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
System.Windows.MessageBox.Show("请求失败,检查连接");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -17,7 +17,7 @@
|
|||||||
<Grid>
|
<Grid>
|
||||||
<!--原料表-->
|
<!--原料表-->
|
||||||
<DataGrid x:Name="DataGridStuff" MouseDoubleClick="DataGridStuff_MouseDoubleClick" SelectionMode="Single" AlternationCount="2" IsReadOnly="True"
|
<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=500}" AutoGenerateColumns="False" MinColumnWidth="30"
|
HorizontalAlignment="Left" Margin="15,15,0,150" d:ItemsSource="{d:SampleData ItemCount=999}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||||
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
|
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
|
||||||
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2"
|
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2"
|
||||||
CanUserResizeRows="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False"
|
CanUserResizeRows="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False"
|
||||||
|
|||||||
@@ -177,7 +177,6 @@ namespace formula_manage.Windows
|
|||||||
else if (this.stuff_ProductType.Text == "液体染料")
|
else if (this.stuff_ProductType.Text == "液体染料")
|
||||||
int_stuff_ProductType = 3;
|
int_stuff_ProductType = 3;
|
||||||
|
|
||||||
|
|
||||||
if ((re_number.IsMatch(this.stuff_Price.Text) == false)&&(stuff_Price.Text != ""))
|
if ((re_number.IsMatch(this.stuff_Price.Text) == false)&&(stuff_Price.Text != ""))
|
||||||
System.Windows.MessageBox.Show("ERR:价格信息错误", "错误");//检查价格输入信息
|
System.Windows.MessageBox.Show("ERR:价格信息错误", "错误");//检查价格输入信息
|
||||||
if (re_char.IsMatch(this.stuff_ProductCode.Text) == false)
|
if (re_char.IsMatch(this.stuff_ProductCode.Text) == false)
|
||||||
|
|||||||
@@ -118,9 +118,11 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Compile Include="ConvertMoels\CategoriesSQLConvert.cs" />
|
||||||
<Compile Include="ConvertMoels\ColorSQLConvert.cs" />
|
<Compile Include="ConvertMoels\ColorSQLConvert.cs" />
|
||||||
<Compile Include="ConvertMoels\DeviationConvert.cs" />
|
<Compile Include="ConvertMoels\DeviationConvert.cs" />
|
||||||
<Compile Include="ConvertMoels\GramsSQLConvert.cs" />
|
<Compile Include="ConvertMoels\GramsSQLConvert.cs" />
|
||||||
|
<Compile Include="ConvertMoels\IndustrySQLConvert.cs" />
|
||||||
<Compile Include="ConvertMoels\ProductTypeSQLConvert.cs" />
|
<Compile Include="ConvertMoels\ProductTypeSQLConvert.cs" />
|
||||||
<Compile Include="ConvertMoels\StatenConvert.cs" />
|
<Compile Include="ConvertMoels\StatenConvert.cs" />
|
||||||
<Compile Include="ConvertMoels\StatenERRConvert.cs" />
|
<Compile Include="ConvertMoels\StatenERRConvert.cs" />
|
||||||
|
|||||||
Reference in new issue
Block a user