You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
800 lines
32 KiB
800 lines
32 KiB
using formula_manage.Windows;
|
|
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;
|
|
|
|
namespace formula_manage
|
|
{
|
|
/// <summary>
|
|
/// MainWindow.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
Font font = new Font("Microsoft YaHei", 20);
|
|
|
|
|
|
bool quit = false;
|
|
// DataTable DissolvedataTable = new DataTable(); //建立Dissolve缓存
|
|
// DataTable STUFFdataTable = new DataTable(); //建立STUFF缓存
|
|
// DataTable MACHINEdataTable = new DataTable(); //建立Machine缓存
|
|
DataTable RRODUCTdataTable = new DataTable(); //建立RRODUCT缓存
|
|
// DataTable RecipedataTable = new DataTable(); //建立Recipe缓存
|
|
|
|
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;
|
|
int ID_N = 1;
|
|
|
|
public MainWindow()
|
|
{
|
|
DataContext = new MainWindowViewModel();
|
|
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
|
InitializeComponent();
|
|
this.Closing += Window_Closing; //添加窗口关闭事件
|
|
|
|
USER.Text = App.USER_Purview;
|
|
|
|
RRODUCTdataTable.Columns.Add("ID", typeof(int));
|
|
RRODUCTdataTable.Columns.Add("DYELOT", typeof(int));
|
|
RRODUCTdataTable.Columns.Add("STEP", typeof(string));
|
|
RRODUCTdataTable.Columns.Add("PRODUCT_CODE", typeof(string));
|
|
RRODUCTdataTable.Columns.Add("CONC", typeof(string));
|
|
RRODUCTdataTable.Columns.Add("SHIFT", typeof(string));
|
|
RRODUCTdataTable.Columns.Add("PRODUCT_NAME", typeof(string));
|
|
RRODUCTdataTable.Columns.Add("TARGET_WT", typeof(float));
|
|
RRODUCTdataTable.Columns.Add("UNIT", typeof(string));
|
|
RRODUCTdataTable.Columns.Add("REMARK", typeof(string));
|
|
|
|
if (USER.Text == "ENGINEER") //工程师允许功能
|
|
{
|
|
_SQL.IsEnabled = true;
|
|
_SQLBAK.IsEnabled = true;
|
|
_SOFTWARE_SET.IsEnabled = true;
|
|
_USER_SET.IsEnabled = true;
|
|
_RECIPE.IsEnabled = true;
|
|
_PROCESS.IsEnabled = true;
|
|
_WORKFLOW.IsEnabled = true;
|
|
_MAC_SET.IsEnabled = true;
|
|
_STUFF.IsEnabled = true;
|
|
_fabric.IsEnabled = true;
|
|
_variety.IsEnabled = true;
|
|
_client.IsEnabled = true;
|
|
_color.IsEnabled = true;
|
|
_statistics.IsEnabled = true;
|
|
}
|
|
|
|
sql_();
|
|
Permissions_(); //权限管理
|
|
|
|
DataRow row = RRODUCTdataTable.NewRow(); //ID列
|
|
row["ID"] = ID_N;
|
|
row["STEP"] = Procedures_P.Text;
|
|
row["UNIT"] = "g";
|
|
//row["SHIFT"] = "g";
|
|
RRODUCTdataTable.Rows.Add(row);
|
|
|
|
Grid_RRODUCT.ItemsSource = RRODUCTdataTable.DefaultView;
|
|
}
|
|
|
|
private void sql_()
|
|
{
|
|
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;
|
|
}
|
|
|
|
list_Weight.Text = Configini.IniReadvalue("SOFTWARE_SET", "T4"); //自定义
|
|
list_Proportion.Text = Configini.IniReadvalue("SOFTWARE_SET", "T5"); //自定义
|
|
list_Total.Text =(double.Parse(list_Proportion.Text)* double.Parse(list_Weight.Text)).ToString();
|
|
}
|
|
|
|
private async void Permissions_()
|
|
{
|
|
DataTable logindataTable = new DataTable(); //建立login缓存
|
|
SqlConnection conn_SC = new SqlConnection(Connstr_SC);
|
|
string user_sql = "SELECT UserCode ,PassWord ,UserSetup ,Capacity ,GROUP_CODE ,Note FROM [Dispensing].[dbo].[UserAccount] WHERE Capacity != 0";//查询语句
|
|
|
|
try
|
|
{
|
|
await conn_SC.OpenAsync(); //打开数据连接
|
|
SqlDataAdapter Stuff_data = new SqlDataAdapter(user_sql, Connstr_SC); //查询
|
|
|
|
Stuff_data.Fill(logindataTable); //查询结果存入缓存
|
|
conn_SC.Close(); //关闭连接
|
|
}
|
|
catch (Exception)
|
|
{
|
|
System.Windows.MessageBox.Show("请求信息失败,检查连接");
|
|
return;
|
|
}
|
|
|
|
string var_POWERUSER = "[UserCode]='" + USER.Text + "' and [GROUP_CODE] ='POWERUSER '"; //查询字符
|
|
string var_CHIEF = "[UserCode]='" + USER.Text + "' and [GROUP_CODE] ='CHIEF '"; //查询字符
|
|
|
|
var CHIEF = logindataTable.Select(var_CHIEF).FirstOrDefault(); //查询账号信息是否正确,不正确返回null
|
|
|
|
if (CHIEF != null)
|
|
{
|
|
_SQL.IsEnabled = true;
|
|
_SQLBAK.IsEnabled = true;
|
|
_SOFTWARE_SET.IsEnabled = true;
|
|
_USER_SET.IsEnabled = true;
|
|
_RECIPE.IsEnabled = true;
|
|
_PROCESS.IsEnabled = true;
|
|
_WORKFLOW.IsEnabled = true;
|
|
_MAC_SET.IsEnabled = true;
|
|
_STUFF.IsEnabled = true;
|
|
_fabric.IsEnabled = true;
|
|
_variety.IsEnabled = true;
|
|
_client.IsEnabled = true;
|
|
_color.IsEnabled = true;
|
|
_statistics.IsEnabled = true;
|
|
}
|
|
else
|
|
{
|
|
var POWERUSER = logindataTable.Select(var_POWERUSER).FirstOrDefault(); //查询账号信息是否正确,不正确返回null
|
|
if (POWERUSER != null)
|
|
{
|
|
_SQLBAK.IsEnabled = true;
|
|
_RECIPE.IsEnabled = true;
|
|
_PROCESS.IsEnabled = true;
|
|
_WORKFLOW.IsEnabled = true;
|
|
_MAC_SET.IsEnabled = true;
|
|
_STUFF.IsEnabled = true;
|
|
_fabric.IsEnabled = true;
|
|
_variety.IsEnabled = true;
|
|
_client.IsEnabled = true;
|
|
_color.IsEnabled = true;
|
|
_statistics.IsEnabled = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) //窗口关闭事件
|
|
{
|
|
string logpath = System.Environment.CurrentDirectory + "\\Log";//日志文件目录
|
|
string logPath = "" + System.Environment.CurrentDirectory + "\\Log\\Log.txt";//日志文件
|
|
string Log_time = "[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]:";
|
|
|
|
if (!quit)
|
|
{
|
|
MessageBoxResult result = System.Windows.MessageBox.Show("您确定要退出吗?", "SUNLIGHT", MessageBoxButton.OKCancel, MessageBoxImage.None, MessageBoxResult.Cancel);
|
|
|
|
if (result == MessageBoxResult.Cancel) //判断是否确认
|
|
{
|
|
e.Cancel = true; // 中断点击事件
|
|
}
|
|
}
|
|
|
|
System.IO.DirectoryInfo log = new System.IO.DirectoryInfo(@logpath);//生成日志文件目录
|
|
FileStream fs = new FileStream(logPath, FileMode.Append, FileAccess.Write);
|
|
StreamWriter wr = new StreamWriter(fs);//创建文件
|
|
wr.WriteLine(Log_time + "FORMULA_STOP");
|
|
wr.Close();
|
|
}
|
|
private void SearchBox_OnKeyDownd(object sender, System.Windows.Input.KeyEventArgs e) //回车跳转功能
|
|
{
|
|
if (e.Key == Key.Enter)
|
|
{
|
|
UserClass.PressKey.PressKeys(Keys.Tab, false);
|
|
UserClass.PressKey.PressKeys(Keys.Tab, true);
|
|
}
|
|
}
|
|
|
|
string Prepose; //料单前置
|
|
string PreposeT; //料单时间
|
|
string PreposeS; //料单序列格式
|
|
int PreposeSl;
|
|
string str_Prepose;
|
|
bool Loginprint;
|
|
bool Loginanew;
|
|
|
|
private void Window_MIN(object sender, RoutedEventArgs e)
|
|
{
|
|
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
|
|
Loginprint = Boolean.Parse(Configini.IniReadvalue("SOFTWARE_SET", "L2")); //是否立即打印料单
|
|
Loginanew = Boolean.Parse(Configini.IniReadvalue("SOFTWARE_SET", "L3")); //是否立即打印料单
|
|
Machine.IsReadOnly = Boolean.Parse(Configini.IniReadvalue("SOFTWARE_SET", "L4")); //允许自定义机台
|
|
|
|
Prepose = Configini.IniReadvalue("SOFTWARE_SET", "T1"); //自定义料单前缀
|
|
PreposeT = Configini.IniReadvalue("SOFTWARE_SET", "T2"); //自定义料单时间
|
|
PreposeS = Configini.IniReadvalue("SOFTWARE_SET", "T3"); //自定义料单格式
|
|
PreposeSl = int.Parse(PreposeS);
|
|
|
|
Number_Event();
|
|
//Number.Text = Prepose + System.DateTime.Now.ToString(PreposeT); //生成料单号
|
|
}
|
|
private void Number_Event() //生成料单号事件
|
|
{
|
|
int preposeL = PreposeS.Length;
|
|
|
|
PreposeSl = PreposeSl + 1;
|
|
str_Prepose = String.Format("{0:D" + preposeL + "}", PreposeSl);
|
|
|
|
Number.Text = Prepose + System.DateTime.Now.ToString(PreposeT) + str_Prepose; //生成料单号
|
|
}
|
|
private void Tb_KeyPress(object sender, TextCompositionEventArgs e)//输入事件
|
|
{
|
|
|
|
//Regex re = new Regex("[^0-9.-]+");
|
|
Regex re = new Regex(@"^[0-9]+(.[0-9]{1,3})?$");// 非零的正整数
|
|
e.Handled = !re.IsMatch(e.Text);
|
|
}
|
|
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 logout(object sender, RoutedEventArgs e)
|
|
{
|
|
quit = true;
|
|
Window window = Window.GetWindow(this);
|
|
Login login = new Login();
|
|
window.Close();
|
|
login.ShowDialog();//实例化并置顶打开登录窗口
|
|
}
|
|
private void SQL(object sender, RoutedEventArgs e)
|
|
{
|
|
System.Windows.MessageBox.Show("进入数据库设置请您明确操作目的及可能需承担的后果", "警告");
|
|
Windows.Sql sql = new Windows.Sql();
|
|
sql.ShowDialog();//实例化并置顶打开数据库设置窗口
|
|
}
|
|
private void SQLBAK(object sender, RoutedEventArgs e)
|
|
{
|
|
MessageBoxResult sql_bak = System.Windows.MessageBox.Show("注意此功能仅作用与本地数据库(Dispensing)对于远端数据库的操作可能失败如果需要继续操作单击确定", "SQL", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); //连接失败提示
|
|
if (sql_bak == MessageBoxResult.OK)
|
|
{
|
|
Windows.SQL_BAK sqlbak = new Windows.SQL_BAK();
|
|
sqlbak.ShowDialog();//实例化并置顶打开数据库备份窗口
|
|
}
|
|
}
|
|
private void SOFTWARE_SET(object sender, RoutedEventArgs e)
|
|
{
|
|
Windows.APP_set APP_set = new Windows.APP_set();
|
|
APP_set.ShowDialog();//实例化并置顶打开设置窗口
|
|
}
|
|
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)
|
|
{
|
|
Help help_page = new Help();
|
|
help_page.ShowDialog();//实例化并置顶打开信息窗口
|
|
}
|
|
private void MAC_SET(object sender, RoutedEventArgs e)
|
|
{
|
|
Windows.Machine mac = new Windows.Machine();
|
|
mac.ShowDialog();//实例化并置顶打开设置窗口
|
|
}
|
|
private void STUFF(object sender, RoutedEventArgs e)
|
|
{
|
|
Windows.Stuff stuff = new Windows.Stuff();
|
|
stuff.ShowDialog();//实例化并置顶打开设置窗口
|
|
}
|
|
private void RECIPE(object sender, RoutedEventArgs e)
|
|
{
|
|
}
|
|
|
|
private void PROCESS(object sender, RoutedEventArgs e)
|
|
{
|
|
}
|
|
|
|
private void WORKFLOW(object sender, RoutedEventArgs e)
|
|
{
|
|
Windows.Dissolve dissolve = new Windows.Dissolve();
|
|
dissolve.ShowDialog();//实例化并置顶打开设置窗口
|
|
}
|
|
|
|
private void print(object sender, RoutedEventArgs e)
|
|
{
|
|
}
|
|
|
|
private void fabric(object sender, RoutedEventArgs e)
|
|
{
|
|
}
|
|
|
|
private void variety(object sender, RoutedEventArgs e)
|
|
{
|
|
}
|
|
|
|
private void color(object sender, RoutedEventArgs e)
|
|
{
|
|
}
|
|
|
|
private void client(object sender, RoutedEventArgs e)
|
|
{
|
|
}
|
|
private void confirm(object sender, RoutedEventArgs e)
|
|
{
|
|
}
|
|
|
|
private void delete(object sender, RoutedEventArgs e)
|
|
{
|
|
}
|
|
|
|
private void save(object sender, RoutedEventArgs e) //保存按钮
|
|
{
|
|
if(Machine.Text =="")
|
|
{
|
|
System.Windows.MessageBox.Show("请选择机台", "注意",MessageBoxButton.OK , MessageBoxImage.Question) ;
|
|
return;
|
|
}
|
|
|
|
if (int.Parse(Procedures_N.Text) > int.Parse(Procedures_P.Text))
|
|
{
|
|
MessageBoxResult result = System.Windows.MessageBox.Show("当前步骤与总步骤设定不符是否继续", "注意", MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.Cancel);
|
|
if (result == MessageBoxResult.OK)
|
|
{
|
|
|
|
} else return;
|
|
}
|
|
|
|
Procedures_N.Text = "1";
|
|
Procedures_P.Text = "1";
|
|
|
|
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath); //记录当前单序号
|
|
Configini.IniWritevalue("SOFTWARE_SET", " T3", str_Prepose);
|
|
}
|
|
|
|
private void Button_NewOrder(object sender, RoutedEventArgs e) //新料单按钮
|
|
{
|
|
Number_Event();
|
|
}
|
|
|
|
private void Button_up(object sender, RoutedEventArgs e)//总步加
|
|
{
|
|
int i = int.Parse(Procedures_N.Text);
|
|
if (i < 999) Procedures_N.Text = (i + 1).ToString();
|
|
}
|
|
private void Button_dow(object sender, RoutedEventArgs e)//总步减
|
|
{
|
|
int i = int.Parse(Procedures_N.Text);
|
|
int P = int.Parse(Procedures_P.Text);
|
|
if (i > 1) Procedures_N.Text = (i - 1).ToString();
|
|
if (P >= i) Procedures_P.Text = Procedures_N.Text;
|
|
}
|
|
private void Button_StepUp(object sender, RoutedEventArgs e)//步加
|
|
{
|
|
int I = int.Parse(Procedures_N.Text);
|
|
int P = int.Parse(Procedures_P.Text);
|
|
if (P < I) Procedures_P.Text = (P + 1).ToString();
|
|
}
|
|
private void Button_StepDow(object sender, RoutedEventArgs e)//步减
|
|
{
|
|
int P = int.Parse(Procedures_P.Text);
|
|
if (P > 1) Procedures_P.Text = (P - 1).ToString();
|
|
}
|
|
|
|
private void Button_Technology(object sender, RoutedEventArgs e)
|
|
{
|
|
Deputy.Content = new View.ViewProcess(); //打开工艺选择
|
|
}
|
|
|
|
private void Button_Formula(object sender, RoutedEventArgs e)
|
|
{
|
|
Deputy.Content = new View.Formula(); //打开配方选择
|
|
}
|
|
|
|
private void DataGrid_InitializingNewItem(object sender, InitializingNewItemEventArgs e) //DetailedGrid生成行事件
|
|
{
|
|
}
|
|
|
|
private void Weight(object sender, TextChangedEventArgs e) //重量输入框
|
|
{
|
|
float a, b, c;
|
|
a = float.Parse(list_Weight.Text);
|
|
if (list_Proportion.Text != "") //判断比例是否有效
|
|
{
|
|
b = float.Parse(list_Proportion.Text);
|
|
c = a * b;
|
|
string listtotal = c.ToString();
|
|
list_Total.Text = listtotal;
|
|
}
|
|
}
|
|
|
|
private void Proportion(object sender, TextChangedEventArgs e) //浴比输入
|
|
{
|
|
float a, b, c;
|
|
b = float.Parse(list_Proportion.Text);
|
|
if (list_Weight.Text != "") //判断比例是否有效
|
|
{
|
|
a = float.Parse(list_Weight.Text);
|
|
c = a * b;
|
|
string listtotal = c.ToString();
|
|
list_Total.Text = listtotal;
|
|
}
|
|
}
|
|
|
|
string Code_;
|
|
string Name_;
|
|
string Type_;
|
|
string Conc_;
|
|
double Weight_=0;
|
|
|
|
private void CP_PRODUCT_CODE_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)//原料代码输入事件
|
|
{
|
|
double ang;
|
|
if (e.Key == Key.Enter)
|
|
{
|
|
System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox;
|
|
int grid_row = Grid_RRODUCT.SelectedIndex; //获取当前行
|
|
|
|
Code_ = curComboBox.Text;
|
|
if (Code_ == "")
|
|
{
|
|
if (Procedures_N.Text == Procedures_P.Text)
|
|
{
|
|
MessageBoxResult P = System.Windows.MessageBox.Show("是否保存", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); //提示
|
|
if (P == MessageBoxResult.Cancel) { }
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
MessageBoxResult P = System.Windows.MessageBox.Show("是否进入下一步", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); //提示
|
|
if (P == MessageBoxResult.Cancel) return;
|
|
|
|
Procedures_P.Text = (int.Parse(Procedures_P.Text) + 1).ToString();
|
|
PressKey.PressKeys(Keys.Tab, false);
|
|
PressKey.PressKeys(Keys.Tab, true);
|
|
return;
|
|
|
|
}
|
|
}
|
|
|
|
DataRow[] r = MainWindowViewModel.STUFFdatatemp.Select("ProductCode ='" + Code_ + "'"); //查询判断原料代码是否有效
|
|
if (!r.Any()) //检查原料信息
|
|
{
|
|
System.Windows.MessageBox.Show("原料不存在");
|
|
curComboBox.Text = "";
|
|
return;
|
|
}
|
|
|
|
DataRow[] c = RRODUCTdataTable.Select("PRODUCT_CODE ='" + Code_ + "'");//查询判断原料代码是否重复
|
|
if (c.Any())
|
|
{
|
|
System.Windows.MessageBox.Show("重复原料");
|
|
return;
|
|
}
|
|
|
|
Name_ = r[0].ItemArray[1].ToString();
|
|
Type_ = r[0].ItemArray[2].ToString();
|
|
Conc_ = r[0].ItemArray[3].ToString();
|
|
|
|
if (double.TryParse(list_Weight.Text, out ang))
|
|
{
|
|
Weight_ = double.Parse(list_Weight.Text) * double.Parse(Conc_) / 100;
|
|
}
|
|
|
|
if ((Type_ == "0") || (Type_ == "3"))
|
|
{
|
|
Type_ = "%";
|
|
if (double.TryParse(list_Weight.Text, out ang))
|
|
{
|
|
Weight_ = double.Parse(list_Weight.Text) * double.Parse(Conc_) *10;
|
|
}
|
|
else
|
|
{
|
|
System.Windows.MessageBox.Show("请先确认重量及浴比");
|
|
return;
|
|
}
|
|
}
|
|
if ((Type_ == "1") || (Type_ == "2"))
|
|
{
|
|
Type_ = "g/L";
|
|
|
|
if (double.TryParse(list_Total.Text, out ang))
|
|
{
|
|
Weight_ = double.Parse(list_Total.Text) * double.Parse(Conc_) / 100;
|
|
}
|
|
else
|
|
{
|
|
System.Windows.MessageBox.Show("请先确认重量及浴比");
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (grid_row == -1) grid_row = 0;
|
|
DataRow row = RRODUCTdataTable.Rows[grid_row]; //ID列
|
|
row.BeginEdit();
|
|
row["PRODUCT_CODE"] = Code_;
|
|
row["PRODUCT_NAME"] = Name_;
|
|
row["SHIFT"] = Type_;
|
|
row.EndEdit();
|
|
if (grid_row == (ID_N - 1))
|
|
{
|
|
PressKey.PressKeys(Keys.Right, false);
|
|
PressKey.PressKeys(Keys.Right, true);
|
|
PressKey.PressKeys(Keys.Tab, false);
|
|
PressKey.PressKeys(Keys.Tab, true);
|
|
}
|
|
else
|
|
{
|
|
PressKey.PressKeys(Keys.Right, false);
|
|
PressKey.PressKeys(Keys.Right, true);
|
|
PressKey.PressKeys(Keys.Up, false);
|
|
PressKey.PressKeys(Keys.Up, true);
|
|
PressKey.PressKeys(Keys.Tab, false);
|
|
PressKey.PressKeys(Keys.Tab, true);
|
|
}
|
|
}
|
|
DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid
|
|
}
|
|
private void CP_CONC_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)//目标饱和度输入事件
|
|
{
|
|
double ang;
|
|
double conc=0;
|
|
|
|
System.Windows.Controls.TextBox curTextBox = sender as System.Windows.Controls.TextBox;
|
|
int grid_row = Grid_RRODUCT.SelectedIndex; //获取当前行
|
|
|
|
if (e.Key == Key.Enter)
|
|
{
|
|
if (!double.TryParse(curTextBox.Text, out ang))
|
|
{
|
|
System.Windows.MessageBox.Show("错误,重新输入");
|
|
curTextBox.Text = "";
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
if (curTextBox.Text != "") conc = double.Parse(curTextBox.Text); //转换后判断数值输入是否异常
|
|
if (conc > 100)
|
|
{
|
|
System.Windows.MessageBox.Show("比例错误");
|
|
curTextBox.Text = "";
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
double Weight_t = Weight_ * conc;
|
|
|
|
DataRow row = RRODUCTdataTable.Rows[grid_row]; //ID列
|
|
row.BeginEdit();
|
|
row["STEP"] = Procedures_P.Text;
|
|
row["CONC"] = string.Format("{0:N6}", conc);
|
|
row["TARGET_WT"] = string.Format("{0:N3}", Weight_t);
|
|
row.EndEdit();
|
|
|
|
if (grid_row == (ID_N - 1))
|
|
{
|
|
PressKey.PressKeys(Keys.Left, false);
|
|
PressKey.PressKeys(Keys.Left, true);
|
|
PressKey.PressKeys(Keys.Tab, false);
|
|
PressKey.PressKeys(Keys.Tab, true);
|
|
|
|
DataRow rowadd = RRODUCTdataTable.NewRow(); //ID列
|
|
rowadd = RRODUCTdataTable.NewRow();
|
|
ID_N++;
|
|
rowadd["ID"] = ID_N;
|
|
// row["STEP"] = "1";
|
|
rowadd["UNIT"] = "g";
|
|
// row["STEP"] = Procedures_P.Text;
|
|
RRODUCTdataTable.Rows.Add(rowadd);
|
|
}
|
|
}
|
|
DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid
|
|
}
|
|
}
|
|
}
|
|
private void CP_PRODUCT_CODE_DropDownClosed(object sender, EventArgs e)//原料代码选择事件
|
|
{
|
|
double ang;
|
|
|
|
System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox;
|
|
int grid_row = Grid_RRODUCT.SelectedIndex; //获取当前行
|
|
|
|
Code_ = curComboBox.Text;
|
|
if (Code_ == "")
|
|
{
|
|
if (Procedures_N.Text == Procedures_P.Text)
|
|
{
|
|
MessageBoxResult P = System.Windows.MessageBox.Show("是否保存", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); //提示
|
|
if (P == MessageBoxResult.Cancel) { }
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
MessageBoxResult P = System.Windows.MessageBox.Show("是否进入下一步", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Exclamation); //提示
|
|
if (P == MessageBoxResult.Cancel) return;
|
|
|
|
Procedures_P.Text = (int.Parse(Procedures_P.Text) + 1).ToString();
|
|
PressKey.PressKeys(Keys.Tab, false);
|
|
PressKey.PressKeys(Keys.Tab, true);
|
|
return;
|
|
|
|
}
|
|
}
|
|
|
|
DataRow[] r = MainWindowViewModel.STUFFdatatemp.Select("ProductCode ='" + Code_ + "'"); //查询判断原料代码是否有效
|
|
if (!r.Any()) //检查原料信息
|
|
{
|
|
System.Windows.MessageBox.Show("原料不存在");
|
|
curComboBox.Text = "";
|
|
return;
|
|
}
|
|
|
|
DataRow[] c = RRODUCTdataTable.Select("PRODUCT_CODE ='" + Code_ + "'");//查询判断原料代码是否重复
|
|
if (c.Any())
|
|
{
|
|
System.Windows.MessageBox.Show("重复原料");
|
|
return;
|
|
}
|
|
|
|
Name_ = r[0].ItemArray[1].ToString();
|
|
Type_ = r[0].ItemArray[2].ToString();
|
|
Conc_ = r[0].ItemArray[3].ToString();
|
|
|
|
if (double.TryParse(list_Weight.Text, out ang))
|
|
{
|
|
Weight_ = double.Parse(list_Weight.Text) * double.Parse(Conc_) / 100;
|
|
}
|
|
|
|
if ((Type_ == "0") || (Type_ == "3"))
|
|
{
|
|
Type_ = "%";
|
|
if (double.TryParse(list_Weight.Text, out ang))
|
|
{
|
|
Weight_ = double.Parse(list_Weight.Text) * double.Parse(Conc_) * 10;
|
|
}
|
|
else
|
|
{
|
|
System.Windows.MessageBox.Show("请先确认重量及浴比");
|
|
return;
|
|
}
|
|
}
|
|
if ((Type_ == "1") || (Type_ == "2"))
|
|
{
|
|
Type_ = "g/L";
|
|
|
|
if (double.TryParse(list_Total.Text, out ang))
|
|
{
|
|
Weight_ = double.Parse(list_Total.Text) * double.Parse(Conc_) / 100;
|
|
}
|
|
else
|
|
{
|
|
System.Windows.MessageBox.Show("请先确认重量及浴比");
|
|
return;
|
|
}
|
|
}
|
|
|
|
if (grid_row == -1) grid_row = 0;
|
|
DataRow row = RRODUCTdataTable.Rows[grid_row]; //ID列
|
|
row.BeginEdit();
|
|
row["PRODUCT_CODE"] = Code_;
|
|
row["PRODUCT_NAME"] = Name_;
|
|
row["SHIFT"] = Type_;
|
|
row.EndEdit();
|
|
if (grid_row == (ID_N - 1))
|
|
{
|
|
PressKey.PressKeys(Keys.Right, false);
|
|
PressKey.PressKeys(Keys.Right, true);
|
|
PressKey.PressKeys(Keys.Tab, false);
|
|
PressKey.PressKeys(Keys.Tab, true);
|
|
}
|
|
else
|
|
{
|
|
PressKey.PressKeys(Keys.Right, false);
|
|
PressKey.PressKeys(Keys.Right, true);
|
|
PressKey.PressKeys(Keys.Up, false);
|
|
PressKey.PressKeys(Keys.Up, true);
|
|
PressKey.PressKeys(Keys.Tab, false);
|
|
PressKey.PressKeys(Keys.Tab, true);
|
|
}
|
|
|
|
DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid
|
|
}
|
|
private void CP_PRODUCT_NAME_DropDownClosed(object sender, EventArgs e)//原料名选择事件
|
|
{
|
|
double ang;
|
|
|
|
System.Windows.Controls.ComboBox curComboBox = sender as System.Windows.Controls.ComboBox;
|
|
int grid_row = Grid_RRODUCT.SelectedIndex; //获取当前行
|
|
|
|
if (curComboBox.Text != "")
|
|
{
|
|
Name_ = curComboBox.Text;
|
|
|
|
DataRow[] r = MainWindowViewModel.STUFFdatatemp.Select("ProductName ='" + Name_ + "'"); //查询判断原料代码是否有效
|
|
|
|
DataRow[] c = RRODUCTdataTable.Select("PRODUCT_NAME ='" + Name_ + "'");//查询判断原料代码是否重复
|
|
if (c.Any())
|
|
{
|
|
System.Windows.MessageBox.Show("重复原料");
|
|
return;
|
|
}
|
|
Code_ = r[0].ItemArray[0].ToString();
|
|
Type_ = r[0].ItemArray[2].ToString();
|
|
Conc_ = r[0].ItemArray[3].ToString();
|
|
|
|
if (double.TryParse(list_Weight.Text, out ang))
|
|
{
|
|
Weight_ = double.Parse(list_Weight.Text) * double.Parse(Conc_) / 100;
|
|
}
|
|
|
|
if ((Type_ == "0") || (Type_ == "3"))
|
|
{
|
|
Type_ = "%";
|
|
if (double.TryParse(list_Weight.Text, out ang))
|
|
{
|
|
Weight_ = double.Parse(list_Weight.Text) * double.Parse(Conc_) * 10;
|
|
}
|
|
else
|
|
{
|
|
System.Windows.MessageBox.Show("请先确认重量及浴比");
|
|
return;
|
|
}
|
|
}
|
|
if ((Type_ == "1") || (Type_ == "2"))
|
|
{
|
|
Type_ = "g/L";
|
|
|
|
if (double.TryParse(list_Total.Text, out ang))
|
|
{
|
|
Weight_ = double.Parse(list_Total.Text) * double.Parse(Conc_) / 100;
|
|
}
|
|
else
|
|
{
|
|
System.Windows.MessageBox.Show("请先确认重量及浴比");
|
|
return;
|
|
}
|
|
}
|
|
if (grid_row == -1) grid_row = 0;
|
|
DataRow row = RRODUCTdataTable.Rows[grid_row]; //ID列
|
|
row.BeginEdit();
|
|
row["PRODUCT_CODE"] = Code_;
|
|
row["PRODUCT_NAME"] = Name_;
|
|
row["SHIFT"] = Type_;
|
|
row.EndEdit();
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|