Merge branch 'master' of http://www.scserverddns.top:13000/sc/formula_manage
This commit is contained in:
commit
9407221589
6 files changed
+479
-5
No files matched your search
@@ -0,0 +1,48 @@
|
||||
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
|
||||
{
|
||||
internal class UserSQLConvert : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
string Capacity = System.Convert.ToString(value);
|
||||
if (Capacity == "0")//类型
|
||||
{
|
||||
return "停用";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Capacity == "1")
|
||||
{
|
||||
return "限制";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Capacity == "2")
|
||||
{
|
||||
return "启用";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
return "未知类型";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -52,7 +52,6 @@
|
||||
<TextBox x:Name="USER" HorizontalAlignment="Right" Height="30" Margin="0,0,155,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="100" FontSize="14"
|
||||
Background="{x:Null}" BorderBrush="{x:Null}" SelectionBrush="{x:Null}" IsReadOnly="True" IsUndoEnabled="False" MaxLines="1" IsEnabled="False"/>
|
||||
|
||||
|
||||
<Button Content="新工单" HorizontalAlignment="Left" Margin="335,35,0,0" Height="30" VerticalAlignment="Top" Width="70" Background="#FFF9F9F9" FontSize="20" Click="Button_NewOrder" Focusable ="False"/>
|
||||
<Button Content="归属订单" HorizontalAlignment="Left" Margin="300,70,0,0" Height="30" VerticalAlignment="Top" Width="105" Background="#FFF9F9F9" FontSize="20" Focusable ="False" Click="Button_Technology"/>
|
||||
<Button Content="预设工艺" HorizontalAlignment="Left" Margin="300,105,0,0" Height="30" VerticalAlignment="Top" Width="105" Background="#FFF9F9F9" FontSize="20" Focusable ="False" Click="Button_Technology"/>
|
||||
@@ -150,7 +149,9 @@
|
||||
<DataGridTemplateColumn Header="原料代码" Width="200" MaxWidth="400" MinWidth="100" IsReadOnly="False">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<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"
|
||||
>
|
||||
</ComboBox>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
|
||||
+61
-3
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -31,6 +33,15 @@ namespace formula_manage
|
||||
|
||||
DataTable STUFFdataTable = new DataTable(); //建立STUFF缓存
|
||||
|
||||
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 MainWindow()
|
||||
{
|
||||
int ID_N = 1;
|
||||
@@ -41,6 +52,14 @@ namespace formula_manage
|
||||
|
||||
USER.Text = App.USER_Purview;
|
||||
|
||||
sql_Stuff();//查询stuff表
|
||||
|
||||
//bindDataGridDatas
|
||||
//SelectionList = STUFFdataTable;
|
||||
// Grid_RRODUCT.ItemsSource
|
||||
|
||||
//Grid_RRODUCT.ItemsSource = STUFFdataTable.DefaultView; //new ObservableCollection<string>();
|
||||
|
||||
CountDown();//执行循环方法
|
||||
|
||||
DataTable dataTable = new DataTable();
|
||||
@@ -67,6 +86,46 @@ namespace formula_manage
|
||||
Grid_RRODUCT.ItemsSource = dataTable.DefaultView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private async void sql_Stuff()
|
||||
{
|
||||
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);//生效配置读取
|
||||
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 ProductCode ,ProductName ,ProductType ,Concentration FROM [Dispensing].[dbo].[PRODUCT]";//查询语句
|
||||
|
||||
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(STUFFdataTable); //查询结果存入缓存
|
||||
conn_SC.Close(); //关闭连接
|
||||
//DataGridStuff.ItemsSource = dataTable.DefaultView; //数据加入表格
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Windows.MessageBox.Show("请求原料信息失败,检查连接");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) //窗口关闭事件
|
||||
{
|
||||
string logpath = System.Environment.CurrentDirectory + "\\Log";//日志文件目录
|
||||
@@ -103,8 +162,6 @@ namespace formula_manage
|
||||
}
|
||||
}
|
||||
|
||||
public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "formula.ini";
|
||||
|
||||
string Prepose; //料单前置
|
||||
string PreposeT; //料单时间
|
||||
|
||||
@@ -155,7 +212,8 @@ namespace formula_manage
|
||||
|
||||
private void USER_SET(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
Windows.User user_set = new Windows.User();
|
||||
user_set.ShowDialog();//实例化并置顶打开用户窗口
|
||||
}
|
||||
|
||||
private void HELP(object sender, RoutedEventArgs e)
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
<Window x:Class="formula_manage.Windows.User"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:formula_manage.Windows"
|
||||
xmlns:ConvertMoels="clr-namespace:formula_manage.ConvertMoels"
|
||||
xmlns:viewmodel="clr-namespace:formula_manage.ViewModel"
|
||||
mc:Ignorable="d" Loaded="user_Loaded"
|
||||
Title="MAC_SET" Height="720" Width="1100" MaxHeight="720" MaxWidth="1100" MinHeight="720" MinWidth="1100"
|
||||
BorderBrush="White" Background="#FFE0E0E0">
|
||||
<Window.Resources>
|
||||
<!--引入转换器-->
|
||||
<ConvertMoels:UserSQLConvert x:Key="UserSQLConvert"/>
|
||||
</Window.Resources>
|
||||
<Grid>
|
||||
<!--表-->
|
||||
<DataGrid x:Name="DataGriduser" MouseDoubleClick="DataGridMac_MouseDoubleClick" SelectionMode="Single" AlternationCount="2" IsReadOnly="True"
|
||||
Margin="15,15,15,150" d:ItemsSource="{d:SampleData ItemCount=999}" AutoGenerateColumns="False" MinColumnWidth="30"
|
||||
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
|
||||
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2"
|
||||
CanUserResizeRows="False" CanUserAddRows="False" CanUserDeleteRows="False" CanUserReorderColumns="False"
|
||||
CanUserResizeColumns="False" CanUserSortColumns="False" HeadersVisibility ="Column">
|
||||
<DataGrid.RowStyle >
|
||||
<Style TargetType="{x:Type DataGridRow}">
|
||||
<Style.Triggers>
|
||||
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
|
||||
<Setter Property="Background" Value="#FFFFFFFF" />
|
||||
</Trigger>
|
||||
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
|
||||
<Setter Property="Background" Value="#FFF0F0F0" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="False">
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
<DataGrid.CellStyle>
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="MinWidth" Value="20"/>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="#FFC0C0C0"/>
|
||||
<Setter Property="BorderBrush" Value="#FFC0C0C0"/>
|
||||
<Setter Property="Foreground" Value="#000000"/>
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</DataGrid.CellStyle>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="用户名" Binding="{Binding UserCode}" Width="200" FontSize="15" MaxWidth="200" MinWidth="200" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="用户组" Binding="{Binding GROUP_CODE}" Width="200" FontSize="15" MaxWidth="200" MinWidth="200" CanUserReorder="False"/>
|
||||
<DataGridTextColumn Header="许可" Width="100" FontSize="15" MaxWidth="100" MinWidth="100" CanUserReorder="False">
|
||||
<!--事件名称:数字转文字显示,转换器UserSQLConvert-->
|
||||
<DataGridTextColumn.ElementStyle>
|
||||
<Style TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Text" Value="{Binding Capacity, Converter={StaticResource UserSQLConvert}}"/>
|
||||
</Style>
|
||||
</DataGridTextColumn.ElementStyle>
|
||||
</DataGridTextColumn>
|
||||
<DataGridTextColumn Header="备注" Binding="{Binding Note}" Width="600" FontSize="15" MinWidth="100" CanUserReorder="False"/>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
<!--名-->
|
||||
<TextBox x:Name="_Name" HorizontalAlignment="Left" Height="30" Margin="105,0,0,100" Text=" "
|
||||
VerticalAlignment="Bottom" Width="250" FontSize="22" MaxLines="1" MaxLength="50" />
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,0,0,100" TextWrapping="Wrap" Text="用户名"
|
||||
VerticalAlignment="Bottom" Width="85" FontSize="20"/>
|
||||
<!--密码-->
|
||||
<TextBox x:Name="Pasword" HorizontalAlignment="Left" Height="30" Margin="105,0,0,50" Text=""
|
||||
VerticalAlignment="Bottom" Width="250" FontSize="22" MaxLines="1" MaxLength="25"
|
||||
InputMethod.IsInputMethodEnabled="False" />
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="15,0,0,50" TextWrapping="Wrap" Text="密码"
|
||||
VerticalAlignment="Bottom" Width="80" FontSize="20"/>
|
||||
<!--组-->
|
||||
<ComboBox x:Name="GROUP" HorizontalAlignment="Left" Height="30" Margin="435,0,0,100" Text="USER"
|
||||
VerticalAlignment="Bottom" Width="100" FontSize="16" IsReadOnly="True" IsEditable="True">
|
||||
<ComboBoxItem Content="CHIEF"></ComboBoxItem>
|
||||
<ComboBoxItem Content="POWERUSER"></ComboBoxItem>
|
||||
<ComboBoxItem Content="USER"></ComboBoxItem>
|
||||
</ComboBox>
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="390,0,0,100" TextWrapping="Wrap" Text="组别"
|
||||
VerticalAlignment="Bottom" Width="45" FontSize="20"/>
|
||||
<!--许可-->
|
||||
<ComboBox x:Name="Capacity" HorizontalAlignment="Left" Height="30" Margin="600,0,0,100" Text="限制"
|
||||
VerticalAlignment="Bottom" Width="100" FontSize="16" IsReadOnly="True" IsEditable="True">
|
||||
<ComboBoxItem Content="启用"></ComboBoxItem>
|
||||
<ComboBoxItem Content="停用"></ComboBoxItem>
|
||||
<ComboBoxItem Content="限制"></ComboBoxItem>
|
||||
</ComboBox>
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="550,0,0,100" TextWrapping="Wrap" Text="许可"
|
||||
VerticalAlignment="Bottom" Width="45" FontSize="20"/>
|
||||
<!--备注-->
|
||||
<TextBox x:Name="Note" HorizontalAlignment="Left" Height="30" Margin="435,0,0,50"
|
||||
VerticalAlignment="Bottom" Width="265" FontSize="22" MaxLines="1"/>
|
||||
<TextBlock HorizontalAlignment="Left" Height="30" Margin="390,0,0,50" TextWrapping="Wrap" Text="备注"
|
||||
VerticalAlignment="Bottom" Width="40" FontSize="20"/>
|
||||
|
||||
<!--存储按钮-->
|
||||
<Button Content="存储" HorizontalAlignment="Left" Height="50" Margin="795,0,0,60"
|
||||
VerticalAlignment="Bottom" Width="100" FontSize="30" Background="#FFEFEFEF" BorderBrush="White"
|
||||
Click="Button_Preservation">
|
||||
</Button>
|
||||
<!--删除按钮-->
|
||||
<Button Content="删除" HorizontalAlignment="Left" Height="50" Margin="935,0,0,60"
|
||||
VerticalAlignment="Bottom" Width="100" FontSize="30" Background="#FFEFEFEF" BorderBrush="White"
|
||||
Click="Button_Delete">
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,248 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// Machine.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class User : 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 User()
|
||||
{
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private async void user_Loaded(object sender, RoutedEventArgs e)//打开页面执行
|
||||
{
|
||||
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);//生效配置读取
|
||||
|
||||
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 UserCode ,PassWord ,UserSetup ,Capacity ,GROUP_CODE ,Note FROM [Dispensing].[dbo].[UserAccount]";//查询语句
|
||||
|
||||
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(); //关闭连接
|
||||
|
||||
DataGriduser.ItemsSource = dataTable.DefaultView; //数据加入表格
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Windows.MessageBox.Show("请求信息失败,检查连接");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询数据库的方法
|
||||
/// </summary>
|
||||
private async void GridSql()
|
||||
{
|
||||
string Stuff_sql = "SELECT UserCode ,PassWord ,Capacity ,GROUP_CODE ,Note FROM [Dispensing].[dbo].[UserAccount]";//查询语句
|
||||
|
||||
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(); //关闭连接
|
||||
|
||||
DataGriduser.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)//数据表双击事件
|
||||
{
|
||||
int rownum = DataGriduser.SelectedIndex;//获取鼠标选中行并定义变量
|
||||
if (rownum != -1)//判断鼠标定位是否有效
|
||||
{
|
||||
/*定位选中行及指定列单元格文本信息*/
|
||||
_Name.Text = (DataGriduser.Columns[0].GetCellContent(DataGriduser.Items[rownum]) as TextBlock).Text.Trim();//定位第列
|
||||
GROUP.Text = (DataGriduser.Columns[1].GetCellContent(DataGriduser.Items[rownum]) as TextBlock).Text.Trim();
|
||||
Capacity.Text = (DataGriduser.Columns[2].GetCellContent(DataGriduser.Items[rownum]) as TextBlock).Text.Trim();
|
||||
Note.Text = (DataGriduser.Columns[3].GetCellContent(DataGriduser.Items[rownum]) as TextBlock).Text.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
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 name = _Name.Text;
|
||||
string password = Pasword.Text;
|
||||
string Group = GROUP.Text;
|
||||
int Cap = 0;
|
||||
string note = Note.Text;
|
||||
string Stuff_sql;
|
||||
|
||||
if(Capacity.Text == "停用") Cap = 0;
|
||||
else if (Capacity.Text == "限制") Cap = 1;
|
||||
else if (Capacity.Text == "启用") Cap = 2;
|
||||
|
||||
if (name != "")
|
||||
{
|
||||
try
|
||||
{
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
Stuff_sql = "SELECT count(*) FROM [Dispensing].[dbo].[UserAccount] WHERE UserCode = '" + 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)
|
||||
{
|
||||
if (password == "")
|
||||
{
|
||||
Stuff_sql = "INSERT INTO[Dispensing].[dbo].[UserAccount](UserCode ,PassWord ,GROUP_CODE ,Capacity ,Note ) " +
|
||||
"VALUES ('" + name + "',null,'" + Group + "'," + Cap + ",'" + note + "')";
|
||||
}
|
||||
else
|
||||
{
|
||||
Stuff_sql = "INSERT INTO[Dispensing].[dbo].[UserAccount](UserCode ,PassWord ,GROUP_CODE ,Capacity ,Note ) " +
|
||||
"VALUES ('" + name + "'," + password + ",'" + Group + "'," + Cap + ",'" + 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
|
||||
{
|
||||
|
||||
if (password == "")
|
||||
{
|
||||
Stuff_sql = string.Format("UPDATE [dbo].[UserAccount] SET PassWord=null ,GROUP_CODE='" + Group + " ',Capacity=" + Cap + " ,Note='" + note + "' Where UserCode ='" + name + "'");
|
||||
}
|
||||
else
|
||||
{
|
||||
Stuff_sql = string.Format("UPDATE [dbo].[UserAccount] SET PassWord=" + password + " ,GROUP_CODE='" + Group + "' ,Capacity=" + Cap + " ,Note='" + note + "' Where UserCode ='" + 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)//删除按钮事件
|
||||
{
|
||||
string Mac_name = "是否删除账号【" + this._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].[UserAccount] WHERE UserCode ='" + _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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,6 +126,7 @@
|
||||
<Compile Include="ConvertMoels\ProductTypeSQLConvert.cs" />
|
||||
<Compile Include="ConvertMoels\StatenConvert.cs" />
|
||||
<Compile Include="ConvertMoels\StatenERRConvert.cs" />
|
||||
<Compile Include="ConvertMoels\UserSQLConvert.cs" />
|
||||
<Compile Include="IProvider.cs" />
|
||||
<Compile Include="Login.xaml.cs">
|
||||
<DependentUpon>Login.xaml</DependentUpon>
|
||||
@@ -143,6 +144,9 @@
|
||||
<Compile Include="Windows\APP_set.xaml.cs">
|
||||
<DependentUpon>APP_set.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\User.xaml.cs">
|
||||
<DependentUpon>User.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Windows\Machine.xaml.cs">
|
||||
<DependentUpon>Machine.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -190,6 +194,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Windows\User.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Windows\Machine.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
Reference in new issue
Block a user