|
|
@ -33,13 +33,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
/// ProductionPlanningEdit.xaml 的交互逻辑
|
|
|
|
/// </summary>
|
|
|
|
public partial class DyeingPlanView : UserControl |
|
|
|
{ |
|
|
|
{ |
|
|
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
|
|
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
|
|
|
DataTable ProgramName = new DataTable(); |
|
|
|
DataTable WorkOrder =new DataTable(); |
|
|
|
DataTable dat = new DataTable(); |
|
|
|
DataTable TEMPTable = new DataTable(); |
|
|
|
DataTable DyelotsBulkedRecipe=new DataTable(); |
|
|
|
public string WorkOrder_n; |
|
|
|
public DyeingPlanView() |
|
|
|
{ |
|
|
@ -72,21 +73,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
comboBoxDyelot.ItemsSource = DatDyelot.AsEnumerable().Select(rowdata => rowdata.Field<string>("Dyelot")).ToList();//转换代码
|
|
|
|
} |
|
|
|
} |
|
|
|
private void Multi_Click(object sender, RoutedEventArgs e)//机台组
|
|
|
|
{ |
|
|
|
MachineSelection machineSelection = new MachineSelection(); |
|
|
|
machineSelection.AddressUpdated += new MachineSelection.AddressUpdateHandler(Address_Multi_Click); |
|
|
|
//machineSelection.data = "ID";
|
|
|
|
machineSelection.ShowDialog(); |
|
|
|
} |
|
|
|
private void Address_Multi_Click(object sender, MachineSelection.AddressUpdateEventArgs e)//机台组返回结果
|
|
|
|
{ |
|
|
|
if(!string.IsNullOrEmpty(e.Groups)) comboBoxMachine.Text = e.Groups; |
|
|
|
comboBoxDyelot.Text = null; |
|
|
|
comboBoxDyelot.IsEnabled = false; |
|
|
|
} |
|
|
|
|
|
|
|
string color_ = "#FF336FA8"; |
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)//保存按钮
|
|
|
|
{ |
|
|
|
if (string.IsNullOrEmpty(comboBoxMachine.Text)) |
|
|
@ -211,6 +197,32 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
SQLiteHelpers.InsertData("WorkorderSteps", WorkOrder_DAT);//行插入
|
|
|
|
WorkOrder_DAT.Clear(); |
|
|
|
} |
|
|
|
if (!String.IsNullOrEmpty(comboBoxDyelot.Text))//料单信息
|
|
|
|
{ |
|
|
|
for (int x = 0; x < DyelotsBulkedRecipe.Rows.Count; x++) |
|
|
|
{ |
|
|
|
WorkOrder_DAT.Add("WorkOrder", comboBoxWorkOrder.Text); |
|
|
|
WorkOrder_DAT.Add("Dyelot", DyelotsBulkedRecipe.Rows[x]["Dyelot"]); |
|
|
|
WorkOrder_DAT.Add("Redye", DyelotsBulkedRecipe.Rows[x]["Redye"]); |
|
|
|
WorkOrder_DAT.Add("Step", DyelotsBulkedRecipe.Rows[x]["StepNumber"]); |
|
|
|
WorkOrder_DAT.Add("TIME", DyelotsBulkedRecipe.Rows[x]["Created"]); |
|
|
|
WorkOrder_DAT.Add("Tank", DyelotsBulkedRecipe.Rows[x]["TankNo"]); |
|
|
|
WorkOrder_DAT.Add("State", DyelotsBulkedRecipe.Rows[x]["DispenseResult"]); |
|
|
|
WorkOrder_DAT.Add("Machine", comboBoxMachine.Text); |
|
|
|
WorkOrder_DAT.Add("ProductCode", DyelotsBulkedRecipe.Rows[x]["ProductCode"]); |
|
|
|
WorkOrder_DAT.Add("ProductName", DyelotsBulkedRecipe.Rows[x]["ProductName"]); |
|
|
|
WorkOrder_DAT.Add("ProductType", DyelotsBulkedRecipe.Rows[x]["ProductType"]); |
|
|
|
WorkOrder_DAT.Add("Grams", DyelotsBulkedRecipe.Rows[x]["Grams"]); |
|
|
|
WorkOrder_DAT.Add("Amount", DyelotsBulkedRecipe.Rows[x]["Amount"]); |
|
|
|
WorkOrder_DAT.Add("DispenseStartTime", DyelotsBulkedRecipe.Rows[x]["DispenseStartTime"]); |
|
|
|
WorkOrder_DAT.Add("DispenseEndTime", DyelotsBulkedRecipe.Rows[x]["DispenseEndTime"]); |
|
|
|
WorkOrder_DAT.Add("DispenseGrams", DyelotsBulkedRecipe.Rows[x]["DispenseGrams"]); |
|
|
|
WorkOrder_DAT.Add("Dispense", DyelotsBulkedRecipe.Rows[x]["Dispenser"]); |
|
|
|
WorkOrder_DAT.Add("UserAccount", DyelotsBulkedRecipe.Rows[x]["UserAccount"]); |
|
|
|
SQLiteHelpers.InsertData("Dyelot", WorkOrder_DAT);//行插入
|
|
|
|
WorkOrder_DAT.Clear(); |
|
|
|
} |
|
|
|
} |
|
|
|
SQLiteHelpers.Close(); //关闭连接
|
|
|
|
|
|
|
|
LogGing.ExchangeDATA("Dyelot=" + comboBoxWorkOrder.Text + ";Machine=" + comboBoxMachine.Text + |
|
|
@ -248,7 +260,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
Grid_data.ItemsSource = dat.DefaultView; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void comboBoxProgram_TextChanged(object sender, TextChangedEventArgs e) |
|
|
|
{ |
|
|
|
dat.Clear(); |
|
|
@ -260,6 +271,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
string[] sArray = Regex.Split(text, @"\+", RegexOptions.IgnoreCase); |
|
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
|
|
/* if (!string.IsNullOrEmpty(WorkOrder_n)) |
|
|
|
{ |
|
|
|
dat = SQLiteHelpers.ExecuteDataSet( |
|
|
|
"select * from WorkorderSteps where WorkOrder='" + WorkOrder_n + "' order by Step asc", null).Tables[0]; //读取计划表写入缓存
|
|
|
|
}//插入工单不为空时载入细节信息*/
|
|
|
|
for (int i = 0; i < sArray.Length; i++) |
|
|
|
{ |
|
|
|
DataTable temp = SQLiteHelpers.ExecuteDataSet( |
|
|
@ -270,11 +286,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
dat.Rows.Add(drT.ItemArray); |
|
|
|
} |
|
|
|
}//以工艺名组合工艺细节
|
|
|
|
if (!string.IsNullOrEmpty(WorkOrder_n)) |
|
|
|
{ |
|
|
|
dat = SQLiteHelpers.ExecuteDataSet( |
|
|
|
"select * from WorkorderSteps where WorkOrder='" + WorkOrder_n + "' order by Step asc", null).Tables[0]; //读取计划表写入缓存
|
|
|
|
}//插入工单不为空时载入细节信息
|
|
|
|
|
|
|
|
SQLiteHelpers.Close(); //关闭连接
|
|
|
|
DatSteps(dat); |
|
|
|
Grid_data.ItemsSource = dat.DefaultView; |
|
|
@ -395,7 +407,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
} |
|
|
|
Grid_data.ItemsSource = dat.DefaultView; |
|
|
|
} |
|
|
|
|
|
|
|
private void TEMP() |
|
|
|
{ |
|
|
|
//处理计划温度图表
|
|
|
@ -461,14 +472,26 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
} |
|
|
|
} |
|
|
|
Picture.Content = new View.CurveTemp(TEMPTable); |
|
|
|
} |
|
|
|
|
|
|
|
} //计划温度图表
|
|
|
|
private async void comboBoxWorkOrder_KeyDown(object sender, KeyEventArgs e)//工单输入
|
|
|
|
{ |
|
|
|
if (e.Key == Key.Enter) |
|
|
|
if (e.Key == Key.Enter && MainWindowViewModel.DyelotsDispenser) |
|
|
|
{ |
|
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); |
|
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
|
|
int dat_c = SQLiteHelpers.ExecuteDataSet("select * from WorkOrder where WorkOrder = '" + comboBoxWorkOrder.Text + "'", null).Tables[0].Rows.Count;//缓存
|
|
|
|
SQLiteHelpers.Close(); |
|
|
|
|
|
|
|
if (dat_c > 0)//查询料单是否可用
|
|
|
|
{ |
|
|
|
comboBoxWorkOrder.Text = null; |
|
|
|
MessageBox.Show(Properties.Resources.TTAE, "WorkOrder", MessageBoxButton.OK, MessageBoxImage.Information); //连接成功提示是否保存
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
string Connstr_SC; |
|
|
|
string DYELOTS_sql = "SELECT * FROM [dbo].[DYELOTS] WHERE Dyelot = '" + comboBoxWorkOrder.Text + "'";//单号查询语句
|
|
|
|
string DyelotsBulkedRecipe_sql = "SELECT * FROM [dbo].[DyelotsBulkedRecipe] WHERE Dyelot = '" + comboBoxWorkOrder.Text + "'"; |
|
|
|
try |
|
|
|
{ |
|
|
|
if (MainWindowViewModel.SQMOD == "Windows Authentication") |
|
|
@ -482,9 +505,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
SqlConnection conn_SC = new SqlConnection(Connstr_SC); |
|
|
|
await conn_SC.OpenAsync(); //连接数据库
|
|
|
|
SqlDataAdapter DYELOTS_data = new SqlDataAdapter(DYELOTS_sql, Connstr_SC); //查询
|
|
|
|
SqlDataAdapter DyelotsBulkedRecipe_ = new SqlDataAdapter(DyelotsBulkedRecipe_sql, Connstr_SC); |
|
|
|
conn_SC.Close(); |
|
|
|
DyelotsBulkedRecipe_.Fill(DyelotsBulkedRecipe); |
|
|
|
|
|
|
|
|
|
|
|
DataTable ds = new DataTable(); |
|
|
|
DataTable ds = new DataTable();//载入信息
|
|
|
|
DYELOTS_data.Fill(ds); |
|
|
|
TEXTColorNumber.Text = ds.AsEnumerable().Select(row => row.Field<string>("ColorNo")).First(); |
|
|
|
TEXTColorName.Text = ds.AsEnumerable().Select(row => row.Field<string>("ColorName")).First(); |
|
|
@ -513,8 +539,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
string colorValue = string.Format("{0:X6}", ds.AsEnumerable().Select(row => row.Field<int>("color")).First());//十进制RGB数值转十六进制六位RGB并补0位例“C0C0C0”
|
|
|
|
color.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString( |
|
|
|
"#FF" + colorValue.Substring(4, 2) + colorValue.Substring(2, 2) + colorValue.Substring(0, 2))); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
@ -522,7 +547,77 @@ namespace SunlightCentralizedControlManagement_SCCM_.View |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
private async void comboBoxDyelot_KeyDown(object sender, KeyEventArgs e)//料单输入
|
|
|
|
{ |
|
|
|
if (e.Key == Key.Enter && MainWindowViewModel.DyelotsDispenser) |
|
|
|
{ |
|
|
|
string Connstr_SC; |
|
|
|
string DYELOTS_sql = "SELECT * FROM [dbo].[DYELOTS] WHERE Dyelot = '" + comboBoxDyelot.Text + "'";//单号查询语句
|
|
|
|
try |
|
|
|
{ |
|
|
|
SQLiteHelpers = new SQLiteHelper(DBAddress); |
|
|
|
SQLiteHelpers.Open(); //打开数据库
|
|
|
|
int dat_c = SQLiteHelpers.ExecuteDataSet("select * from Dyelot where Dyelot = '" + comboBoxDyelot.Text + "'", null).Tables[0].Rows.Count;//缓存
|
|
|
|
SQLiteHelpers.Close(); |
|
|
|
|
|
|
|
if (dat_c > 0)//查询料单是否可用
|
|
|
|
{ |
|
|
|
comboBoxDyelot.Text = null; |
|
|
|
MessageBox.Show(Properties.Resources.TPLHBU, "Dyelot", MessageBoxButton.OK, MessageBoxImage.Information); //连接成功提示是否保存
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (MainWindowViewModel.SQMOD == "Windows Authentication") |
|
|
|
{ |
|
|
|
Connstr_SC = "server=" + MainWindowViewModel.SQLIP + ";database=" + MainWindowViewModel.SQLNAME + ";Trusted_Connection=SSPI"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Connstr_SC = "server=" + MainWindowViewModel.SQLIP + ";database=" + MainWindowViewModel.SQLNAME + ";User ID=" + MainWindowViewModel.SQLUSER + ";Password=" + MainWindowViewModel.SQLPASWORD; |
|
|
|
} |
|
|
|
SqlConnection conn_SC = new SqlConnection(Connstr_SC); |
|
|
|
await conn_SC.OpenAsync(); //连接数据库
|
|
|
|
SqlDataAdapter DYELOTS_data = new SqlDataAdapter(DYELOTS_sql, Connstr_SC); //查询
|
|
|
|
conn_SC.Close(); |
|
|
|
|
|
|
|
DataTable ds = new DataTable();//载入信息
|
|
|
|
DYELOTS_data.Fill(ds); |
|
|
|
TEXTColorNumber.Text = ds.AsEnumerable().Select(row => row.Field<string>("ColorNo")).First(); |
|
|
|
TEXTColorName.Text = ds.AsEnumerable().Select(row => row.Field<string>("ColorName")).First(); |
|
|
|
TEXTClient.Text = ds.AsEnumerable().Select(row => row.Field<string>("CustomerName")).First(); |
|
|
|
TEXTClothSpecies.Text = ds.AsEnumerable().Select(row => row.Field<string>("FabricName")).First(); |
|
|
|
TEXTClothWeight.Text = ds.AsEnumerable().Select(row => row.Field<Double>("TotalWeight")).First().ToString(); |
|
|
|
TEXTBathRatio.Text = ds.AsEnumerable().Select(row => row.Field<string>("LiquidRatio")).First(); |
|
|
|
TEXTTotal.Text = ds.AsEnumerable().Select(row => row.Field<string>("TotalVolume")).First(); |
|
|
|
// comboBoxDyelot.Text = ds.AsEnumerable().Select(row => row.Field<string>("Dyelot")).First();
|
|
|
|
|
|
|
|
string machine_ = ds.AsEnumerable().Select(row => row.Field<string>("Machine")).First();//机台
|
|
|
|
if (MainWindowViewModel.Machines.Select("Name ='" + machine_ + "'").Length == 0) |
|
|
|
{ |
|
|
|
comboBoxMachine.Text = null; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
comboBoxMachine.Text = machine_; |
|
|
|
} |
|
|
|
string user_ = ds.AsEnumerable().Select(row => row.Field<string>("UserAccount")).First();//用户名
|
|
|
|
if (!String.IsNullOrEmpty(user_)) TEXTUSER.Text = user_; |
|
|
|
comboBoxProgram.Text = ds.AsEnumerable().Select(row => row.Field<string>("Program")).First(); |
|
|
|
|
|
|
|
if (ds.AsEnumerable().Select(row => row.Field<int>("color")).First() > 0)//颜色
|
|
|
|
{ |
|
|
|
string colorValue = string.Format("{0:X6}", ds.AsEnumerable().Select(row => row.Field<int>("color")).First());//十进制RGB数值转十六进制六位RGB并补0位例“C0C0C0”
|
|
|
|
color.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString( |
|
|
|
"#FF" + colorValue.Substring(4, 2) + colorValue.Substring(2, 2) + colorValue.Substring(0, 2))); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
LogGing.ERRDATA(ex); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
private void Tb_KeyTEXTClothWeight(object sender, TextCompositionEventArgs e)//输入事件
|
|
|
|
{ |
|
|
|
Regex numbeRegex = new Regex("^[.][0-9]+$|^[0-9]*[.]{0,1}[0-9]*$"); |
|
|
|