mvvm模式升级从 packages.config 迁移到 PackageReference
This commit is contained in:
commit
83a38deaa6
56 files changed
+612
-1158
No files matched your search
+2
-13
@@ -1,17 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
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;
|
||||
|
||||
namespace formula_manage.Windows
|
||||
{
|
||||
@@ -33,7 +22,7 @@ namespace formula_manage.Windows
|
||||
string Log_time = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:";
|
||||
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) //窗口关闭事件
|
||||
{
|
||||
MessageBoxResult result = System.Windows.MessageBox.Show("设置完成后请重启程序","提示", MessageBoxButton.OKCancel, MessageBoxImage.None, MessageBoxResult.Cancel);
|
||||
MessageBoxResult result = System.Windows.MessageBox.Show("设置完成后请重启程序", "提示", MessageBoxButton.OKCancel, MessageBoxImage.None, MessageBoxResult.Cancel);
|
||||
|
||||
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
|
||||
Configini.IniWritevalue("SOFTWARE_SET", " L1", Loginlink.ToString());
|
||||
@@ -53,7 +42,7 @@ namespace formula_manage.Windows
|
||||
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
||||
StreamWriter wr = new StreamWriter(fs);//创建文件
|
||||
wr.WriteLine(Log_time + "FORMULA_SET:INIFile_Write");
|
||||
wr.Close();
|
||||
wr.Close();
|
||||
}
|
||||
|
||||
bool Loginlink;
|
||||
|
||||
+13
-30
@@ -1,23 +1,6 @@
|
||||
using formula_manage.UserClass;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
|
||||
namespace formula_manage.Windows
|
||||
@@ -59,13 +42,13 @@ namespace formula_manage.Windows
|
||||
sn_time.Text = "注册有效时间: --------";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sn_time.Text = "注册有效时间: --------";
|
||||
else
|
||||
{
|
||||
sn_time.Text = "注册有效时间: --------";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else
|
||||
{
|
||||
sn_time.Text = "注册有效时间: --------";
|
||||
}
|
||||
|
||||
@@ -77,16 +60,16 @@ namespace formula_manage.Windows
|
||||
//string hardDiskSerialNumber = HardwareSN.GetHardDiskSerialNumber();
|
||||
// 获取网卡地址
|
||||
//string netCardMACAddress = HardwareSN.GetNetCardMACAddress();
|
||||
sn_id.Text = MD5check.MD5Encrypt16(cpuSerialNumber+ biosSerialNumber);//生成id基于硬件值的md5校验
|
||||
sn_id.Text = MD5check.MD5Encrypt16(cpuSerialNumber + biosSerialNumber);//生成id基于硬件值的md5校验
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Button_Click_2(object sender, RoutedEventArgs e) //cdk确认按钮
|
||||
{
|
||||
string id_1;
|
||||
id_1 = sn_id.Text.Substring(5, 1) + sn_id.Text.Substring(0, 1) + sn_id.Text.Substring(4, 1) + sn_id.Text.Substring(1, 1) + sn_id.Text.Substring(3, 1) + sn_id.Text.Substring(2, 1);
|
||||
|
||||
if(cdk.Text.Length != 16)
|
||||
if (cdk.Text.Length != 16)
|
||||
{
|
||||
System.Windows.MessageBox.Show("CDKEY: 无效注册码", "ERR", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
return;
|
||||
@@ -110,7 +93,7 @@ namespace formula_manage.Windows
|
||||
{
|
||||
if (string.Compare(D, DD) >= 0)
|
||||
{
|
||||
System.Windows.MessageBox.Show("CDKEY: 注册成功,请重启软件", "KEY",MessageBoxButton.OK,MessageBoxImage.Asterisk);
|
||||
System.Windows.MessageBox.Show("CDKEY: 注册成功,请重启软件", "KEY", MessageBoxButton.OK, MessageBoxImage.Asterisk);
|
||||
sn_time.Text = "注册有效时间: " + Y + "-" + M + "-" + D;
|
||||
|
||||
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
|
||||
@@ -147,7 +130,7 @@ namespace formula_manage.Windows
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Windows.MessageBox.Show("CDKEY: 注册码过期","WARNING",MessageBoxButton.OK,MessageBoxImage.Warning);
|
||||
System.Windows.MessageBox.Show("CDKEY: 注册码过期", "WARNING", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -155,9 +138,9 @@ namespace formula_manage.Windows
|
||||
System.Windows.MessageBox.Show("CDKEY: 无效注册码", "ERR", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
System.Windows.MessageBox.Show("CDKEY: 无效注册码", "ERR" , MessageBoxButton.OK,MessageBoxImage.Error);
|
||||
System.Windows.MessageBox.Show("CDKEY: 无效注册码", "ERR", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+17
-31
@@ -1,24 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
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
|
||||
{
|
||||
@@ -127,7 +113,7 @@ namespace formula_manage.Windows
|
||||
string Dissolve_sql;
|
||||
int int_ion = 0;
|
||||
|
||||
if ((name.Text == "") ||(Code.Text == ""))
|
||||
if ((name.Text == "") || (Code.Text == ""))
|
||||
{
|
||||
System.Windows.MessageBox.Show("请输入代码或名称");
|
||||
return;
|
||||
@@ -171,33 +157,33 @@ namespace formula_manage.Windows
|
||||
conn_SC.Close(); //关闭连接
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
{
|
||||
Dissolve_sql = string.Format("INSERT INTO[dbo].[Dissolve](DissolveCode ,DissolveName ,REMARK ,MaterialType ,WeightMIN ,WeightMAX) " +
|
||||
"VALUES ('" + Code.Text + "','" + name.Text + "','" + Remark.Text + "','" + int_ion + "','"+ min.Text + "','" + max.Text + "')");
|
||||
"VALUES ('" + Code.Text + "','" + name.Text + "','" + Remark.Text + "','" + int_ion + "','" + min.Text + "','" + max.Text + "')");
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(Dissolve_sql, conn_SC);
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
conn_SC.Close(); //关闭连接
|
||||
if (sql_in == 0)
|
||||
{
|
||||
{
|
||||
System.Windows.MessageBox.Show("添加失败");
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
GridSql();
|
||||
System.Windows.MessageBox.Show("添加完成");//
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dissolve_sql = string.Format("UPDATE [dbo].[Dissolve] SET DissolveName ='" + name.Text + "',REMARK='" + Remark.Text + "',MaterialType='" + int_ion + "',WeightMIN='" + min.Text + "',WeightMAX='" + max.Text + "' Where DissolveCode ='" + Code.Text + "'");
|
||||
}
|
||||
else
|
||||
{
|
||||
Dissolve_sql = string.Format("UPDATE [dbo].[Dissolve] SET DissolveName ='" + name.Text + "',REMARK='" + Remark.Text + "',MaterialType='" + int_ion + "',WeightMIN='" + min.Text + "',WeightMAX='" + max.Text + "' Where DissolveCode ='" + Code.Text + "'");
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(Dissolve_sql, conn_SC);
|
||||
SqlCommand INSERT_cmd = new SqlCommand(Dissolve_sql, conn_SC);
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
conn_SC.Close(); //关闭连接
|
||||
|
||||
if (sql_in == 0)
|
||||
{
|
||||
|
||||
if (sql_in == 0)
|
||||
{
|
||||
System.Windows.MessageBox.Show("修改失败");
|
||||
}
|
||||
else
|
||||
@@ -213,7 +199,7 @@ namespace formula_manage.Windows
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
|
||||
{
|
||||
|
||||
+16
-30
@@ -1,24 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
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
|
||||
{
|
||||
@@ -132,7 +118,7 @@ namespace formula_manage.Windows
|
||||
/*定位选中行及指定列单元格文本信息*/
|
||||
mac_Name.Text = (DataGridMac.Columns[1].GetCellContent(DataGridMac.Items[rownum]) as TextBlock).Text.TrimEnd();//定位第列
|
||||
mac_MacGroup.Text = (DataGridMac.Columns[2].GetCellContent(DataGridMac.Items[rownum]) as TextBlock).Text.TrimEnd();//
|
||||
mac_Capacity.Text = (DataGridMac.Columns[3].GetCellContent(DataGridMac .Items[rownum]) as TextBlock).Text.TrimEnd();//
|
||||
mac_Capacity.Text = (DataGridMac.Columns[3].GetCellContent(DataGridMac.Items[rownum]) as TextBlock).Text.TrimEnd();//
|
||||
mac_Volume.Text = (DataGridMac.Columns[4].GetCellContent(DataGridMac.Items[rownum]) as TextBlock).Text.TrimEnd();//
|
||||
mac_Industry.Text = (DataGridMac.Columns[5].GetCellContent(DataGridMac.Items[rownum]) as TextBlock).Text.TrimEnd();//
|
||||
mac_Categories.Text = (DataGridMac.Columns[6].GetCellContent(DataGridMac.Items[rownum]) as TextBlock).Text.TrimEnd();//
|
||||
@@ -182,7 +168,7 @@ namespace formula_manage.Windows
|
||||
conn_SC.Close(); //关闭连接
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
{
|
||||
MAC_sql = string.Format("INSERT INTO [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(); //打开数据连接
|
||||
@@ -190,25 +176,25 @@ namespace formula_manage.Windows
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
conn_SC.Close(); //关闭连接
|
||||
if (sql_in == 0)
|
||||
{
|
||||
{
|
||||
System.Windows.MessageBox.Show("添加失败");
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
GridSql();
|
||||
System.Windows.MessageBox.Show("添加完成");//
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MAC_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 + "'");
|
||||
}
|
||||
else
|
||||
{
|
||||
MAC_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(MAC_sql, conn_SC);
|
||||
SqlCommand INSERT_cmd = new SqlCommand(MAC_sql, conn_SC);
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
conn_SC.Close(); //关闭连接
|
||||
|
||||
if (sql_in == 0)
|
||||
{
|
||||
|
||||
if (sql_in == 0)
|
||||
{
|
||||
System.Windows.MessageBox.Show("修改失败");
|
||||
}
|
||||
else
|
||||
@@ -224,7 +210,7 @@ namespace formula_manage.Windows
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
|
||||
{
|
||||
|
||||
+14
-32
@@ -1,30 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using ThoughtWorks.QRCode.Codec;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Drawing.Printing;
|
||||
using FastReport;
|
||||
using formula_manage.UserClass;
|
||||
using System.Xml.Linq;
|
||||
using FastReport.Format;
|
||||
using Svg;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Printing;
|
||||
using System.IO;
|
||||
using System.Windows.Media.Media3D;
|
||||
using System.Reflection;
|
||||
using FastReport;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace formula_manage.Windows
|
||||
{
|
||||
@@ -57,7 +39,7 @@ namespace formula_manage.Windows
|
||||
string Temp_M, Temp_S;
|
||||
private void Window_Print(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
|
||||
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
|
||||
|
||||
Printer = Boolean.Parse(Configini.IniReadvalue("PRINTER", "P1"));
|
||||
@@ -152,13 +134,13 @@ namespace formula_manage.Windows
|
||||
|
||||
private void Button_Click_1(object sender, RoutedEventArgs e) //编辑模板
|
||||
{
|
||||
if (string.IsNullOrEmpty(Template_M.Text))
|
||||
if (string.IsNullOrEmpty(Template_M.Text))
|
||||
{
|
||||
System.Windows.MessageBox.Show("模板不能为空");
|
||||
return;
|
||||
}
|
||||
|
||||
var tuple = PrintHelper.Design(Print_path.Text+"/" + Template_M.Text);
|
||||
var tuple = PrintHelper.Design(Print_path.Text + "/" + Template_M.Text);
|
||||
if (!tuple.Item1)
|
||||
{
|
||||
System.Windows.MessageBox.Show($"打开设计器失败:{tuple.Item2}");
|
||||
@@ -172,7 +154,7 @@ namespace formula_manage.Windows
|
||||
return;
|
||||
}
|
||||
|
||||
var tuple = PrintHelper.Design(Print_path2.Text +"/" + Template_S.Text);
|
||||
var tuple = PrintHelper.Design(Print_path2.Text + "/" + Template_S.Text);
|
||||
if (!tuple.Item1)
|
||||
{
|
||||
System.Windows.MessageBox.Show($"打开设计器失败:{tuple.Item2}");
|
||||
@@ -255,7 +237,7 @@ namespace formula_manage.Windows
|
||||
return;
|
||||
}
|
||||
|
||||
File.WriteAllText(Template_path + ".frx", Template_DATA);
|
||||
File.WriteAllText(Template_path + ".frx", Template_DATA);
|
||||
var tuple = PrintHelper.Design(Template_path + ".frx");
|
||||
if (!tuple.Item1)
|
||||
{
|
||||
@@ -272,11 +254,11 @@ namespace formula_manage.Windows
|
||||
|
||||
private void Button_Click_4(object sender, RoutedEventArgs e)//删除指定模板
|
||||
{
|
||||
try
|
||||
try
|
||||
{
|
||||
string Template_path = Print_path.Text + "/" + Template.Text;
|
||||
File.Delete(Template_path);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
System.Windows.MessageBox.Show("删除失败");
|
||||
|
||||
+6
-33
@@ -1,41 +1,14 @@
|
||||
using formula_manage.Windows;
|
||||
using formula_manage.UserClass;
|
||||
using formula_manage.ViewModel;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Threading;
|
||||
using formula_manage.ViewModel;
|
||||
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using formula_manage.UserClass;
|
||||
using System.Drawing;
|
||||
using System.Diagnostics;
|
||||
using System.Printing;
|
||||
using System.Drawing.Printing;
|
||||
using static System.Drawing.Printing.PrinterSettings;
|
||||
using formula_manage.View;
|
||||
using FastReport.DevComponents.AdvTree;
|
||||
|
||||
namespace formula_manage.Windows
|
||||
{
|
||||
@@ -164,10 +137,10 @@ namespace formula_manage.Windows
|
||||
{
|
||||
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 Dissolve_sql;
|
||||
// int int_ion = 0;
|
||||
|
||||
}
|
||||
// string Dissolve_sql;
|
||||
// int int_ion = 0;
|
||||
|
||||
}
|
||||
|
||||
private async void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
|
||||
{
|
||||
|
||||
+16
-27
@@ -1,18 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
|
||||
|
||||
@@ -50,7 +39,7 @@ namespace formula_manage.Windows
|
||||
SQLNAME = Configini.IniReadvalue("SQL_SERVER", "SQL2");
|
||||
int.TryParse(Configini.IniReadvalue("SQL_SERVER", "SQL3"), out i); //读数据库状态配置文件
|
||||
if (i == 0) SQLMOD = false;
|
||||
else SQLMOD = true;
|
||||
else SQLMOD = true;
|
||||
SQLUSER = Configini.IniReadvalue("SQL_SERVER", "SQL4");
|
||||
SQLPASS = Configini.IniReadvalue("SQL_SERVER", "SQL5");
|
||||
|
||||
@@ -59,7 +48,7 @@ namespace formula_manage.Windows
|
||||
SQLTIME = Boolean.Parse(Configini.IniReadvalue("SQL_BAK", "S3"));
|
||||
int.TryParse(Configini.IniReadvalue("SQL_BAK", "S4"), out Time);
|
||||
if (Time == 0) SQL_TIME.Text = "日";
|
||||
else if(Time == 1) SQL_TIME.Text = "周";
|
||||
else if (Time == 1) SQL_TIME.Text = "周";
|
||||
else if (Time == 2) SQL_TIME.Text = "月";
|
||||
else if (Time == 3) SQL_TIME.Text = "季";
|
||||
else if (Time == 4) SQL_TIME.Text = "年";
|
||||
@@ -77,7 +66,7 @@ namespace formula_manage.Windows
|
||||
SQL_DISPEN_bak.IsEnabled = SQLBAK;
|
||||
SQL_DISPEN_BUT.IsEnabled = SQLBAK;
|
||||
}
|
||||
|
||||
|
||||
private void SQL_bak_time_Checked(object sender, RoutedEventArgs e) //自动保存
|
||||
{
|
||||
SQLTIME = SQL_bak_time.IsChecked.GetValueOrDefault();
|
||||
@@ -90,8 +79,8 @@ namespace formula_manage.Windows
|
||||
Dilog.SelectedPath = SQL_DISPEN_bak.Text; //打开目录
|
||||
Dilog.ShowNewFolderButton = false; //不显示新建文件夹按钮
|
||||
//
|
||||
if (Dilog.ShowDialog() == System.Windows.Forms.DialogResult.OK )
|
||||
{
|
||||
if (Dilog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
SQL_DISPEN_bak.Text = Dilog.SelectedPath; //返回选择的字符串
|
||||
}
|
||||
}
|
||||
@@ -207,23 +196,23 @@ namespace formula_manage.Windows
|
||||
{
|
||||
ok = Backup(SQLNAME, SQL_DISPEN_bak.Text + "\\" + SQLNAME + System.DateTime.Now.ToString("yyyy_MM_dd_HHmmss") + ".bak"); //指定地址备份
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
ok = Backup(SQLNAME, "C:\\SUNLIGHT\\" + SQLNAME + System.DateTime.Now.ToString("yyyy_MM_dd_HHmmss") + ".bak"); //默认备份到文档文件夹
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
System.Windows.MessageBox.Show("备份成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Windows.MessageBox.Show("备份失败");
|
||||
}
|
||||
|
||||
if (ok)
|
||||
{
|
||||
System.Windows.MessageBox.Show("备份成功");
|
||||
}
|
||||
else
|
||||
{
|
||||
System.Windows.MessageBox.Show("备份失败");
|
||||
}
|
||||
}
|
||||
|
||||
private async void Button_Click_2(object sender, RoutedEventArgs e)
|
||||
{
|
||||
{
|
||||
if (!SQLMOD) //连接数据库测试
|
||||
{
|
||||
Connstr_SC = "server=" + SQLIP + ";database=" + SQLNAME + ";Trusted_Connection=SSPI";
|
||||
|
||||
+1
-16
@@ -1,21 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
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 System.Data.SqlClient;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.ComponentModel;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Windows;
|
||||
|
||||
|
||||
namespace formula_manage.Windows
|
||||
|
||||
+57
-70
@@ -1,24 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
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
|
||||
{
|
||||
@@ -88,34 +75,34 @@ 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;
|
||||
}
|
||||
|
||||
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 == "全部原料")
|
||||
if (radiobutton == "全部原料")
|
||||
{
|
||||
GridSql(0);
|
||||
Button_ID = 0;
|
||||
GridSql(0);
|
||||
Button_ID = 0;
|
||||
}
|
||||
else if (radiobutton == "染料")
|
||||
else if (radiobutton == "染料")
|
||||
{
|
||||
GridSql(1);
|
||||
Button_ID = 1;
|
||||
Button_ID = 1;
|
||||
}
|
||||
else if (radiobutton == "助剂")
|
||||
else if (radiobutton == "助剂")
|
||||
{
|
||||
GridSql(2);
|
||||
GridSql(2);
|
||||
Button_ID = 2;
|
||||
}
|
||||
else if (radiobutton == "粉体助剂")
|
||||
else if (radiobutton == "粉体助剂")
|
||||
{
|
||||
GridSql(3);
|
||||
Button_ID = 3;
|
||||
Button_ID = 3;
|
||||
}
|
||||
else if (radiobutton == "液体染料")
|
||||
else if (radiobutton == "液体染料")
|
||||
{
|
||||
GridSql(4);
|
||||
Button_ID = 4;
|
||||
@@ -125,15 +112,15 @@ namespace formula_manage.Windows
|
||||
/// <summary>
|
||||
/// 查询数据库的方法
|
||||
/// </summary>
|
||||
private async void GridSql(int e )
|
||||
private async void GridSql(int e)
|
||||
{
|
||||
string Stuff_sql = null;
|
||||
if (e == 0) Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY ,ProductIon_Type FROM [dbo].[PRODUCT]";//查询语句
|
||||
else if (e == 1) Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY ,ProductIon_Type FROM [dbo].[PRODUCT] Where ProductType = '0' ";
|
||||
else if (e == 1) Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY ,ProductIon_Type FROM [dbo].[PRODUCT] Where ProductType = '0' ";
|
||||
else if (e == 2) Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY ,ProductIon_Type FROM [dbo].[PRODUCT] Where ProductType = '1' ";
|
||||
else if (e == 3) Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY ,ProductIon_Type FROM [dbo].[PRODUCT] Where ProductType = '2' ";
|
||||
else if (e == 4) Stuff_sql = "SELECT ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY ,ProductIon_Type FROM [dbo].[PRODUCT] Where ProductType = '3' ";
|
||||
|
||||
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
|
||||
try
|
||||
@@ -155,7 +142,7 @@ namespace formula_manage.Windows
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -171,14 +158,14 @@ namespace formula_manage.Windows
|
||||
|
||||
if (this.stuff_ProductType.Text == "染料") //原料类型0。染料,1助剂,2粉体
|
||||
int_stuff_ProductType = 0;
|
||||
else if (this.stuff_ProductType.Text == "助剂")
|
||||
int_stuff_ProductType = 1;
|
||||
else if (this.stuff_ProductType.Text == "粉体助剂")
|
||||
int_stuff_ProductType = 2;
|
||||
else if (this.stuff_ProductType.Text == "液体染料")
|
||||
else if (this.stuff_ProductType.Text == "助剂")
|
||||
int_stuff_ProductType = 1;
|
||||
else if (this.stuff_ProductType.Text == "粉体助剂")
|
||||
int_stuff_ProductType = 2;
|
||||
else if (this.stuff_ProductType.Text == "液体染料")
|
||||
int_stuff_ProductType = 3;
|
||||
|
||||
if(Stuff_ion.Text == "分散") int_stuff_ion = 0;
|
||||
if (Stuff_ion.Text == "分散") int_stuff_ion = 0;
|
||||
else if (Stuff_ion.Text == "酸性") int_stuff_ion = 1;
|
||||
else if (Stuff_ion.Text == "活性") int_stuff_ion = 2;
|
||||
else if (Stuff_ion.Text == "中性") int_stuff_ion = 3;
|
||||
@@ -215,37 +202,37 @@ namespace formula_manage.Windows
|
||||
if (float.Parse(this.stuff_Concentration.Text) < 0 || float.Parse(this.stuff_Concentration.Text) > 100)
|
||||
System.Windows.MessageBox.Show("ERR:浓度错误", "错误");//检查浓度输入数值
|
||||
else
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
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参数
|
||||
ColorCode_SQL = Convert.ToInt32(StuffColor, 16);//16进制转10进制
|
||||
if (ColorCode_SQL < 0) ColorCode_SQL = 16777215;//判断色彩数据是否有效
|
||||
if (ColorCode_SQL < 0) ColorCode_SQL = 16777215;//判断色彩数据是否有效
|
||||
}
|
||||
else
|
||||
{
|
||||
ColorCode_SQL = 16777215;
|
||||
else
|
||||
{
|
||||
ColorCode_SQL = 16777215;
|
||||
}
|
||||
|
||||
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
Stuff_sql = "SELECT count(*) FROM [dbo].[PRODUCT] WHERE ProductCode = '" + Product_Code + " '";//查询语句
|
||||
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 [dbo].[PRODUCT](ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY ) " +
|
||||
"VALUES ('" + Product_Code + "','" + Product_Name + "','" + _Price + "','" + _SUPPLIER + "','" + int_stuff_ProductType + "','" + ColorCode_SQL + "','" + _Concentration + "','" + _GRAVITY + "')");
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
Stuff_sql = string.Format("INSERT INTO [dbo].[PRODUCT](ProductCode ,ProductName , Price , SUPPLIER ,ProductType ,Color ,Concentration , GRAVITY ) " +
|
||||
"VALUES ('" + Product_Code + "','" + Product_Name + "','" + _Price + "','" + _SUPPLIER + "','" + int_stuff_ProductType + "','" + ColorCode_SQL + "','" + _Concentration + "','" + _GRAVITY + "')");
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC);
|
||||
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC);
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
|
||||
if (Stuff_ion.Text != "") Stuff_sql = string.Format("UPDATE [dbo].[PRODUCT] SET [ProductIon_Type] =" + int_stuff_ion + " Where ProductCode='" + Product_Code + "'");
|
||||
@@ -267,10 +254,10 @@ namespace formula_manage.Windows
|
||||
else if (Button_ID == 4) GridSql(4);
|
||||
System.Windows.MessageBox.Show("添加完成");
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
Stuff_sql = string.Format("UPDATE [dbo].[PRODUCT] SET ProductName='" + Product_Name + "',Price='" + _Price + "',SUPPLIER='" + _SUPPLIER + "',ProductType=" + int_stuff_ProductType + ",Color=" + ColorCode_SQL + ",Concentration=" + _Concentration + ",GRAVITY=" + _GRAVITY + " Where ProductCode='"+ Product_Code+"'");
|
||||
Stuff_sql = string.Format("UPDATE [dbo].[PRODUCT] SET ProductName='" + Product_Name + "',Price='" + _Price + "',SUPPLIER='" + _SUPPLIER + "',ProductType=" + int_stuff_ProductType + ",Color=" + ColorCode_SQL + ",Concentration=" + _Concentration + ",GRAVITY=" + _GRAVITY + " Where ProductCode='" + Product_Code + "'");
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC);
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
@@ -286,7 +273,7 @@ namespace formula_manage.Windows
|
||||
System.Windows.MessageBox.Show("修改失败");
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
if (Button_ID == 0) GridSql(0);
|
||||
else if (Button_ID == 1) GridSql(1);
|
||||
else if (Button_ID == 2) GridSql(2);
|
||||
@@ -301,44 +288,44 @@ namespace formula_manage.Windows
|
||||
System.Windows.MessageBox.Show("请求失败,检查连接");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
|
||||
{
|
||||
{
|
||||
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)//判断是否删除原料
|
||||
{
|
||||
|
||||
|
||||
string Stuff_sql = string.Format("DELETE FROM [dbo].[PRODUCT] WHERE ProductCode ='" + stuff_ProductCode.Text.ToString() + "'");
|
||||
|
||||
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
try
|
||||
{
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC);
|
||||
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
|
||||
{
|
||||
if (Button_ID == 0) GridSql(0);
|
||||
else if (Button_ID == 1) GridSql(1);
|
||||
else if (Button_ID == 2) GridSql(2);
|
||||
else if (Button_ID == 3) GridSql(3);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Button_ID == 0) GridSql(0);
|
||||
else if (Button_ID == 1) GridSql(1);
|
||||
else if (Button_ID == 2) GridSql(2);
|
||||
else if (Button_ID == 3) GridSql(3);
|
||||
else if (Button_ID == 4) GridSql(4);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Windows.MessageBox.Show("请求失败,检查连接");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridStuff_MouseDoubleClick(object sender, MouseButtonEventArgs e)//数据表双击事件
|
||||
@@ -388,7 +375,7 @@ namespace formula_manage.Windows
|
||||
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参数
|
||||
@@ -399,5 +386,5 @@ namespace formula_manage.Windows
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+55
-69
@@ -1,24 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
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
|
||||
{
|
||||
@@ -141,49 +127,49 @@ namespace formula_manage.Windows
|
||||
string note = Note.Text;
|
||||
string Stuff_sql;
|
||||
|
||||
if(Capacity.Text == "停用") Cap = 0;
|
||||
if (Capacity.Text == "停用") Cap = 0;
|
||||
else if (Capacity.Text == "限制") Cap = 1;
|
||||
else if (Capacity.Text == "启用") Cap = 2;
|
||||
|
||||
if (name != "")
|
||||
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(); //关闭连接
|
||||
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 (count == 0)
|
||||
{
|
||||
if (password == "")
|
||||
{
|
||||
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
|
||||
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 == "")
|
||||
{
|
||||
@@ -193,26 +179,26 @@ namespace formula_manage.Windows
|
||||
{
|
||||
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(); //关闭连接
|
||||
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();
|
||||
}
|
||||
if (sql_in == 0)
|
||||
{
|
||||
System.Windows.MessageBox.Show("修改失败");
|
||||
}
|
||||
else
|
||||
{
|
||||
GridSql();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Windows.MessageBox.Show("请求失败,检查连接");
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Windows.MessageBox.Show("请求失败,检查连接");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+29
-44
@@ -1,25 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
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;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace formula_manage.Windows
|
||||
{
|
||||
@@ -71,7 +56,7 @@ namespace formula_manage.Windows
|
||||
{
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlDataAdapter client_data = new SqlDataAdapter(client_sql, Connstr_SC); //查询
|
||||
|
||||
|
||||
client_data.Fill(dataTable); //查询结果存入缓存
|
||||
conn_SC.Close(); //关闭连接
|
||||
|
||||
@@ -89,13 +74,13 @@ 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询数据库的方法
|
||||
/// </summary>
|
||||
private async void GridSql()
|
||||
private async void GridSql()
|
||||
{
|
||||
string client_sql = "SELECT Code ,Name , Remark FROM [dbo].[Client]";//查询语句
|
||||
|
||||
@@ -120,7 +105,7 @@ namespace formula_manage.Windows
|
||||
}
|
||||
|
||||
private async void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件
|
||||
{
|
||||
{
|
||||
Regex re_number = new Regex(@"^[0-9]+(.[0-9]{1,4})?$");//校验用正则表达式有1~2位小数的正实数
|
||||
string client_sql;
|
||||
|
||||
@@ -130,22 +115,22 @@ namespace formula_manage.Windows
|
||||
if (string.IsNullOrEmpty(this.client_name.Text))
|
||||
System.Windows.MessageBox.Show("ERR:无效的名称", "错误");//检查原料名
|
||||
else
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
client_sql = "SELECT count(*) FROM [dbo].[Client] WHERE Code = '" + client_code.Text + " '";//查询语句
|
||||
await conn_SC.OpenAsync(); //打开数据连
|
||||
SqlCommand cmd = new SqlCommand(client_sql, conn_SC); //查询记录数
|
||||
int count = Convert.ToInt32(cmd.ExecuteScalar()); //显示记录数
|
||||
conn_SC.Close(); //关闭连接
|
||||
|
||||
if (count == 0)
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
client_sql = string.Format("INSERT INTO [dbo].[Client](Code ,Name , Remark) " +
|
||||
"VALUES ('" + client_code.Text + "','" + client_name.Text + "','" + client_Remark.Text + "')");
|
||||
"VALUES ('" + client_code.Text + "','" + client_name.Text + "','" + client_Remark.Text + "')");
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(client_sql, conn_SC);
|
||||
SqlCommand INSERT_cmd = new SqlCommand(client_sql, conn_SC);
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
|
||||
conn_SC.Close(); //关闭连接
|
||||
@@ -158,10 +143,10 @@ namespace formula_manage.Windows
|
||||
GridSql();
|
||||
System.Windows.MessageBox.Show("添加完成");
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
client_sql = string.Format("UPDATE [dbo].[Client] SET Name='" + client_name.Text + "',Remark='" + client_Remark.Text + "' Where Code='"+ client_code.Text + "'");
|
||||
client_sql = string.Format("UPDATE [dbo].[Client] SET Name='" + client_name.Text + "',Remark='" + client_Remark.Text + "' Where Code='" + client_code.Text + "'");
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(client_sql, conn_SC);
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
@@ -172,9 +157,9 @@ namespace formula_manage.Windows
|
||||
System.Windows.MessageBox.Show("C0110-1:修改失败");
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
GridSql();
|
||||
|
||||
|
||||
System.Windows.MessageBox.Show("修改完成");
|
||||
}
|
||||
}
|
||||
@@ -184,40 +169,40 @@ namespace formula_manage.Windows
|
||||
System.Windows.MessageBox.Show("请求失败,检查连接");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
|
||||
{
|
||||
{
|
||||
string ShowProductName = "是否删除【" + this.client_name.Text + "】" + this.client_code.Text;//获取信息并拼接提示字符串
|
||||
MessageBoxResult showProductName = System.Windows.MessageBox.Show(ShowProductName, "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes);//弹窗提示是否删除目标原料
|
||||
if (showProductName == MessageBoxResult.Yes)//判断是否删除
|
||||
{
|
||||
|
||||
|
||||
string Stuff_sql = string.Format("DELETE FROM [dbo].[Client] WHERE Code ='" + client_code.Text.ToString() + "'");
|
||||
|
||||
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
try
|
||||
{
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC);
|
||||
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("C0110-2:删除失败", "错误");//判断执行是否成功
|
||||
}
|
||||
else
|
||||
{
|
||||
GridSql();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GridSql();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Windows.MessageBox.Show("请求失败,检查连接");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridclient_MouseDoubleClick(object sender, MouseButtonEventArgs e)//数据表双击事件
|
||||
@@ -232,5 +217,5 @@ namespace formula_manage.Windows
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
-43
@@ -1,25 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
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;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace formula_manage.Windows
|
||||
{
|
||||
@@ -31,7 +17,7 @@ namespace formula_manage.Windows
|
||||
public string INIPath = Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "formula.ini"; //配置文件路径
|
||||
|
||||
DataTable dataTable = new DataTable(); //建立缓存
|
||||
|
||||
|
||||
string TEXT_SQLIP;
|
||||
string TEXT_SQLNAME;
|
||||
string TEXT_SQMOD;
|
||||
@@ -71,7 +57,7 @@ namespace formula_manage.Windows
|
||||
{
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlDataAdapter color_data = new SqlDataAdapter(color_sql, Connstr_SC); //查询
|
||||
|
||||
|
||||
color_data.Fill(dataTable); //查询结果存入缓存
|
||||
conn_SC.Close(); //关闭连接
|
||||
|
||||
@@ -89,13 +75,13 @@ 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询数据库的方法
|
||||
/// </summary>
|
||||
private async void GridSql()
|
||||
private async void GridSql()
|
||||
{
|
||||
string color_sql = "SELECT COLOR_CODE ,COLOR_NAME , COLOR_NO , COLOR_Remark FROM [dbo].[COLOR]";//查询语句
|
||||
|
||||
@@ -120,7 +106,7 @@ namespace formula_manage.Windows
|
||||
}
|
||||
|
||||
private async void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件
|
||||
{
|
||||
{
|
||||
Regex re_number = new Regex(@"^[0-9]+(.[0-9]{1,4})?$");//校验用正则表达式有1~2位小数的正实数
|
||||
string color_sql;
|
||||
int ColorCode_SQL;
|
||||
@@ -142,22 +128,22 @@ namespace formula_manage.Windows
|
||||
if (string.IsNullOrEmpty(this.color_name.Text))
|
||||
System.Windows.MessageBox.Show("ERR:无效的原料名称", "错误");//检查原料名
|
||||
else
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
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()); //显示记录数
|
||||
conn_SC.Close(); //关闭连接
|
||||
|
||||
if (count == 0)
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
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 + "')");
|
||||
"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);
|
||||
SqlCommand INSERT_cmd = new SqlCommand(color_sql, conn_SC);
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
|
||||
conn_SC.Close(); //关闭连接
|
||||
@@ -170,8 +156,8 @@ namespace formula_manage.Windows
|
||||
GridSql();
|
||||
System.Windows.MessageBox.Show("添加完成");
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
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(); //打开数据连接
|
||||
@@ -184,9 +170,9 @@ namespace formula_manage.Windows
|
||||
System.Windows.MessageBox.Show("C0110-1:修改失败");
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
GridSql();
|
||||
|
||||
|
||||
System.Windows.MessageBox.Show("修改完成");
|
||||
}
|
||||
}
|
||||
@@ -196,40 +182,40 @@ namespace formula_manage.Windows
|
||||
System.Windows.MessageBox.Show("请求失败,检查连接");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
|
||||
{
|
||||
{
|
||||
string ShowProductName = "是否删除【" + this.color_name.Text + "】" + this.color_code.Text;//获取信息并拼接提示字符串
|
||||
MessageBoxResult showProductName = System.Windows.MessageBox.Show(ShowProductName, "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes);//弹窗提示是否删除目标原料
|
||||
if (showProductName == MessageBoxResult.Yes)//判断是否删除
|
||||
{
|
||||
|
||||
|
||||
string Stuff_sql = string.Format("DELETE FROM [dbo].[COLOR] WHERE COLOR_CODE ='" + color_code.Text.ToString() + "'");
|
||||
|
||||
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
try
|
||||
{
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC);
|
||||
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("C0110-2:删除失败", "错误");//判断执行是否成功
|
||||
}
|
||||
else
|
||||
{
|
||||
GridSql();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GridSql();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Windows.MessageBox.Show("请求失败,检查连接");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridcolor_MouseDoubleClick(object sender, MouseButtonEventArgs e)//数据表双击事件
|
||||
@@ -268,5 +254,5 @@ namespace formula_manage.Windows
|
||||
//ColorCode_SQL = Convert.ToInt32(colorCode, 16);//十六进制RGB转存储数值
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+29
-44
@@ -1,25 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
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;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace formula_manage.Windows
|
||||
{
|
||||
@@ -71,7 +56,7 @@ namespace formula_manage.Windows
|
||||
{
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlDataAdapter fabric_data = new SqlDataAdapter(fabric_sql, Connstr_SC); //查询
|
||||
|
||||
|
||||
fabric_data.Fill(dataTable); //查询结果存入缓存
|
||||
conn_SC.Close(); //关闭连接
|
||||
|
||||
@@ -89,13 +74,13 @@ 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询数据库的方法
|
||||
/// </summary>
|
||||
private async void GridSql()
|
||||
private async void GridSql()
|
||||
{
|
||||
string fabric_sql = "SELECT Code ,Name , GYard , Remark FROM [dbo].[PRODUCTION_Material]";//查询语句
|
||||
|
||||
@@ -120,7 +105,7 @@ namespace formula_manage.Windows
|
||||
}
|
||||
|
||||
private async void Button_Preservation(object sender, RoutedEventArgs e)//保存按钮事件
|
||||
{
|
||||
{
|
||||
Regex re_number = new Regex(@"^[0-9]+(.[0-9]{1,4})?$");//校验用正则表达式有1~2位小数的正实数
|
||||
string fabric_sql;
|
||||
|
||||
@@ -133,22 +118,22 @@ namespace formula_manage.Windows
|
||||
if (string.IsNullOrEmpty(this.fabric_name.Text))
|
||||
System.Windows.MessageBox.Show("ERR:无效的原料名称", "错误");//检查原料名
|
||||
else
|
||||
{
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
fabric_sql = "SELECT count(*) FROM [dbo].[PRODUCTION_Material] WHERE Code = '" + fabric_code.Text + " '";//查询语句
|
||||
await conn_SC.OpenAsync(); //打开数据连
|
||||
SqlCommand cmd = new SqlCommand(fabric_sql, conn_SC); //查询记录数
|
||||
int count = Convert.ToInt32(cmd.ExecuteScalar()); //显示记录数
|
||||
conn_SC.Close(); //关闭连接
|
||||
|
||||
if (count == 0)
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
fabric_sql = string.Format("INSERT INTO [dbo].[PRODUCTION_Material](Code ,Name , GYard , Remark) " +
|
||||
"VALUES ('" + fabric_code.Text + "','" + fabric_name.Text + "','" + fabric_GYard.Text + "','" + fabric_Remark.Text + "')");
|
||||
"VALUES ('" + fabric_code.Text + "','" + fabric_name.Text + "','" + fabric_GYard.Text + "','" + fabric_Remark.Text + "')");
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(fabric_sql, conn_SC);
|
||||
SqlCommand INSERT_cmd = new SqlCommand(fabric_sql, conn_SC);
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
|
||||
conn_SC.Close(); //关闭连接
|
||||
@@ -161,10 +146,10 @@ namespace formula_manage.Windows
|
||||
GridSql();
|
||||
System.Windows.MessageBox.Show("添加完成");
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
fabric_sql = string.Format("UPDATE [dbo].[PRODUCTION_Material] SET Name='" + fabric_name.Text + "',GYard='" + fabric_GYard.Text + "',Remark='" + fabric_Remark.Text + "' Where Code='"+ fabric_code.Text + "'");
|
||||
fabric_sql = string.Format("UPDATE [dbo].[PRODUCTION_Material] SET Name='" + fabric_name.Text + "',GYard='" + fabric_GYard.Text + "',Remark='" + fabric_Remark.Text + "' Where Code='" + fabric_code.Text + "'");
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(fabric_sql, conn_SC);
|
||||
int sql_in = INSERT_cmd.ExecuteNonQuery(); //执行语句
|
||||
@@ -175,9 +160,9 @@ namespace formula_manage.Windows
|
||||
System.Windows.MessageBox.Show("C0110-1:修改失败");
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
GridSql();
|
||||
|
||||
|
||||
System.Windows.MessageBox.Show("修改完成");
|
||||
}
|
||||
}
|
||||
@@ -187,40 +172,40 @@ namespace formula_manage.Windows
|
||||
System.Windows.MessageBox.Show("请求失败,检查连接");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void Button_Delete(object sender, RoutedEventArgs e)//删除按钮事件
|
||||
{
|
||||
{
|
||||
string ShowProductName = "是否删除【" + this.fabric_name.Text + "】" + this.fabric_code.Text;//获取信息并拼接提示字符串
|
||||
MessageBoxResult showProductName = System.Windows.MessageBox.Show(ShowProductName, "提示", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.Yes);//弹窗提示是否删除目标原料
|
||||
if (showProductName == MessageBoxResult.Yes)//判断是否删除
|
||||
{
|
||||
|
||||
|
||||
string Stuff_sql = string.Format("DELETE FROM [dbo].[PRODUCTION_Material] WHERE Code ='" + fabric_code.Text.ToString() + "'");
|
||||
|
||||
|
||||
SqlConnection conn_SC = new SqlConnection(Connstr_SC); //实例化
|
||||
try
|
||||
{
|
||||
await conn_SC.OpenAsync(); //打开数据连接
|
||||
SqlCommand INSERT_cmd = new SqlCommand(Stuff_sql, conn_SC);
|
||||
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("C0110-2:删除失败", "错误");//判断执行是否成功
|
||||
}
|
||||
else
|
||||
{
|
||||
GridSql();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GridSql();
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
System.Windows.MessageBox.Show("请求失败,检查连接");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DataGridfabric_MouseDoubleClick(object sender, MouseButtonEventArgs e)//数据表双击事件
|
||||
@@ -236,5 +221,5 @@ namespace formula_manage.Windows
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user