diff --git a/UserClass/AsyncTcpServer.cs b/UserClass/AsyncTcpServer.cs index 73f5e57..2be67a3 100644 --- a/UserClass/AsyncTcpServer.cs +++ b/UserClass/AsyncTcpServer.cs @@ -217,19 +217,22 @@ namespace DyeingComputer.UserClass /**编辑行信息**/ DataRow drtt = TechnologicalProcessView.sql.Tables[0].Rows[d - 1]; drtt.BeginEdit(); - drtt["StepID"] = dat_821.GetValue("STEPID").ToString(); - drtt["StepName"] = dat_821.GetValue("STEPNAME").ToString(); - drtt["ParameterName"] = dat_821.GetValue("PNAME").ToString(); - drtt["Parameter1"] = dat_821.GetValue("P1").ToString(); - drtt["Parameter2"] = dat_821.GetValue("P2").ToString(); - drtt["Parameter3"] = dat_821.GetValue("P3").ToString(); - drtt["Parameter4"] = dat_821.GetValue("P4").ToString(); - drtt["Parameter5"] = dat_821.GetValue("P5").ToString(); + drtt["StepID"] = dat_821.GetValue("StepID").ToString(); + drtt["StepName"] = dat_821.GetValue("StepName").ToString(); + drtt["ParameterName"] = dat_821.GetValue("ParameterName").ToString(); + drtt["Parameter1"] = dat_821.GetValue("Parameter1").ToString(); + drtt["Parameter2"] = dat_821.GetValue("Parameter2").ToString(); + drtt["Parameter3"] = dat_821.GetValue("Parameter3").ToString(); + drtt["Parameter4"] = dat_821.GetValue("Parameter4").ToString(); + drtt["Parameter5"] = dat_821.GetValue("Parameter5").ToString(); + + drtt["RUN"] = "0"; + drtt["DYELOT"] = MainWindowViewModel.WorkNumder; drtt.EndEdit(); - var _TechnologicalProcessView = Application.Current.Windows.Cast().FirstOrDefault(window => window is TechnologicalProcessView) as TechnologicalProcessView;//跨页面 - _TechnologicalProcessView.Grid.ItemsSource = TechnologicalProcessView.sql.Tables[0].DefaultView; - _TechnologicalProcessView.Grid.SelectedIndex = -1; + // var _TechnologicalProcessView = Application.Current.Windows.Cast().FirstOrDefault(window => window is TechnologicalProcessView) as TechnologicalProcessView;//跨页面 + // _TechnologicalProcessView.Grid.ItemsSource = TechnologicalProcessView.sql.Tables[0].DefaultView; + //_TechnologicalProcessView.Grid.SelectedIndex = -1; /**存入信息**/ TechnologicalProcessView.SQLiteHelpers.Delete("RUN", null, null); DataTable data_t = new DataTable(); @@ -244,9 +247,6 @@ namespace DyeingComputer.UserClass DataRow drT = data_t.NewRow(); drT.ItemArray = dt.ItemArray; data_t.Rows.InsertAt(drT, 0); - drT.BeginEdit(); //添加订单号 - drT["DYELOT"] = MainWindowViewModel.WorkNumder; - drT.EndEdit(); TechnologicalProcessView.SQLiteHelpers.InsertData("RUN", TechnologicalProcessView.SQLiteHelpers.DataTableToDictionary(data_t));//行插入 } @@ -349,7 +349,7 @@ namespace DyeingComputer.UserClass if (SYSKEY == MainWindowViewModel.SYSKEY) { - client.SendAsync("SC831" + "[" + MainWindowViewModel.S01 + "]" +TechnologicalProcessView.sql.Tables[0].ToJsonString()); + client.SendAsync("SC831" + "[" + MainWindowViewModel.S01 + "]" +MainWindowViewModel.dt_TP.ToJsonString()); } else { client.SendAsync("SC999"); } }//当前工作表 diff --git a/View/TechnologicalProcessView.xaml b/View/TechnologicalProcessView.xaml index 6f9ccaf..b9471aa 100644 --- a/View/TechnologicalProcessView.xaml +++ b/View/TechnologicalProcessView.xaml @@ -12,7 +12,8 @@ d:DesignHeight="630" d:DesignWidth="1280"> (sql.Tables[0]); + + // Grid.ItemsSource = dt_m.DE sql.Tables[0].DefaultView; //转换显示计划表 name.Text = Program_Name; } } diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index ecdb403..7c9e08a 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -1563,6 +1563,7 @@ namespace DyeingComputer.ViewModel public static DataTable dt_d = new DataTable("DIO"); public static DataTable dt_a = new DataTable("AIO"); public static DataTable dt_m = new DataTable("M"); + public static DataTable dt_TP = new DataTable(); public static void SQL_data()//获得io表 { SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径 @@ -1625,6 +1626,12 @@ namespace DyeingComputer.ViewModel if ((bool)D_view) SYSData_D = ToObservableCollection(dt_d); } catch (Exception ex) { Name_err = "IO_SYSData_D" + "(" + ex.Message + ")"; } + try + { + TechnologicalProcess_View = ToObservableCollection(dt_TP); + + } + catch (Exception) { } }); } public static double Selet_dtm(string key)//M寄存器 @@ -1822,6 +1829,7 @@ namespace DyeingComputer.ViewModel ObservableCollection sysData_A = new ObservableCollection(); ObservableCollection sysData_D = new ObservableCollection(); ObservableCollection sysData_M = new ObservableCollection(); + ObservableCollection technologicalProcess_View = new ObservableCollection(); public ObservableCollection SYSData_A { @@ -1852,6 +1860,16 @@ namespace DyeingComputer.ViewModel RaisePropertyChanged("SYSData_M"); } } + public ObservableCollection TechnologicalProcess_View + { + + get { return technologicalProcess_View; } + set + { + technologicalProcess_View = value; + RaisePropertyChanged("TechnologicalProcess_View"); + } + } public class DATA_A { public string IOName { get; set; } @@ -1876,6 +1894,25 @@ namespace DyeingComputer.ViewModel public string PLC { get; set; } public string type { get; set; } } + public class TechnologicalProcess + { + public string Program { get; set; } + public double Step { get; set; } + public string StepID { get; set; } + public string StepName { get; set; } + public string ParameterName { get; set; } + public string Parameter1 { get; set; } + public string Parameter2 { get; set; } + public string Parameter3 { get; set; } + public string Parameter4 { get; set; } + public string Parameter5 { get; set; } + public string Parameter6 { get; set; } + public string Parameter7 { get; set; } + public string Parameter8 { get; set; } + public string Parameter9 { get; set; } + public string Parameter10 { get; set; } + public string DYELOT { get; set; } + } public ObservableCollection ToObservableCollection(DataTable dt) where T : class, new() { Type t = typeof(T);