using Newtonsoft.Json.Linq;
using nGantt.GanttChart;
using ScottPlot.Palettes;
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml.Linq;
using TouchSocket.Core;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep;
using static System.Windows.Forms.AxHost;
namespace SunlightCentralizedControlManagement_SCCM_.View
{
///
/// ProductionPlanningEdit.xaml 的交互逻辑
///
public partial class DyeingPlanView : UserControl
{
DataTable ProgramName = new DataTable();
DataTable WorkOrder =new DataTable();
DataTable dat = new DataTable();
DataTable TEMPTable = new DataTable();
DataTable DyelotsBulkedRecipe=new DataTable();
public string WorkOrder_n;
string Numder = null;
string ID = null;
string P1, P2, P3, P4, P5;
public DyeingPlanView()
{
InitializeComponent();
ProgramName = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from ProgramName order by ProgramID desc", null).Tables[0];//缓存
comboBoxMachine.ItemsSource = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field("name")).ToList();//转换机台
comboBoxProgram.ItemsSource = ProgramName.AsEnumerable().Select(rowdata => rowdata.Field("ProgramName")).ToList();//转换工艺代码
TEXTUSER.Text = MainWindow.user_;
TEMPTable.Columns.Add("Time", Type.GetType("System.String"));
TEMPTable.Columns.Add("MST", Type.GetType("System.Double"));
}
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
}
private void comboBoxMachine_DropDownClosed(object sender, EventArgs e)//机台选择
{
string[] sArray = Regex.Split(comboBoxMachine.Text, @"\+", RegexOptions.IgnoreCase);
if (sArray.Length <= 1)
{
comboBoxDyelot.IsEnabled = true;
DataTable DatDyelot = MainWindowViewModel.SQLiteHelpers.ExecuteDataSet("select * from Dyelot where Machine='" + comboBoxMachine.Text + "' and State='101' order by Dyelot desc", null).Tables[0]; //读取计划表写入缓存
comboBoxDyelot.ItemsSource = DatDyelot.AsEnumerable().Select(rowdata => rowdata.Field("Dyelot")).ToList();//转换代码
}
}
private void Button_Click(object sender, RoutedEventArgs e)//保存按钮
{
if (string.IsNullOrEmpty(comboBoxMachine.Text))
{
MessageBox.Show("Not Machine", "SCCM", MessageBoxButton.OK, MessageBoxImage.Question);
return;
}
if (string.IsNullOrEmpty(comboBoxProgram.Text))
{
MessageBox.Show("Not Program", "SCCM", MessageBoxButton.OK, MessageBoxImage.Question);
return;
}
string[] pArray = Regex.Split(comboBoxProgram.Text, @"\+", RegexOptions.IgnoreCase);
//单机器信息写入
string sTime;
string StartTime_;
string WorkOrder_ = comboBoxMachine.Text + "_" + DateTime.Now.ToString("yyMMddHHmmss");
if (!string.IsNullOrEmpty(comboBoxWorkOrder.Text)) WorkOrder_ = comboBoxWorkOrder.Text;
string ProgramName_ = comboBoxProgram.Text;
string ProgramID_ = null;
for (int j = 0; j < pArray.Length; j++)
{
try
{
if (j == 0)
{
ProgramID_ = ProgramName.Select("ProgramName='" + pArray[j] + "'").
First().Field