diff --git a/View/ProgramstepsView .xaml.cs b/View/ProgramstepsView .xaml.cs index 8e32d0c..626022d 100644 --- a/View/ProgramstepsView .xaml.cs +++ b/View/ProgramstepsView .xaml.cs @@ -25,6 +25,7 @@ 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.VisualStyles.VisualStyleElement; @@ -135,7 +136,47 @@ namespace SunlightCentralizedControlManagement_SCCM_.View StepTime = (Grid_step.Columns[16].GetCellContent(Grid_step.Items[rownum]) as TextBlock).Text;// if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; } - if (ID == null) ID = Step.Rows.Count.ToString(); + if (string.IsNullOrEmpty(ID)) + { + DataRow dr = Step.NewRow();//添加表数据 + dr["ProgramID"] = ProgramID; + dr["Program"] = ProgramNAME; + dr["Parameter1"] = 0; + dr["Parameter2"] = 0; + dr["Parameter3"] = 0; + dr["Parameter4"] = 0; + dr["Parameter5"] = 0; + dr["Parameter6"] = 0; + dr["Parameter7"] = 0; + dr["Parameter8"] = 0; + dr["Parameter9"] = 0; + dr["Parameter10"] = 0; + dr["Parameter1_S1"] = 0; + dr["Parameter2_S1"] = 0; + dr["Parameter3_S1"] = 0; + dr["Parameter4_S1"] = 0; + dr["Parameter5_S1"] = 0; + dr["Parameter1_S2"] = 0; + dr["Parameter2_S2"] = 0; + dr["Parameter3_S2"] = 0; + dr["Parameter4_S2"] = 0; + dr["Parameter5_S2"] = 0; + dr["Parameter1_S3"] = 0; + dr["Parameter2_S3"] = 0; + dr["Parameter3_S3"] = 0; + dr["Parameter4_S3"] = 0; + dr["Parameter5_S3"] = 0; + dr["StepName_S1"] = " "; + dr["StepName_S2"] = " "; + dr["StepName_S3"] = " "; + dr["StepID_S1"] = "000"; + dr["StepID_S2"] = "000"; + dr["StepID_S3"] = "000"; + Step.Rows.InsertAt(dr, Step.Rows.Count); + Dat(Step); + ID = (Step.Rows.Count).ToString(); + } + ViewStep viewstop = new ViewStep(Numder, Step.Select("STEP = " + ID).First()); viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked); viewstop.data = ID; @@ -154,7 +195,46 @@ namespace SunlightCentralizedControlManagement_SCCM_.View Insert.IsEnabled = false; Delete.IsEnabled = false; if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; } - if (ID == null) ID = Step.Rows.Count.ToString(); + if (string.IsNullOrEmpty(ID)) + { + DataRow dr = Step.NewRow();//添加表数据 + dr["ProgramID"] = ProgramID; + dr["Program"] = ProgramNAME; + dr["Parameter1"] = 0; + dr["Parameter2"] = 0; + dr["Parameter3"] = 0; + dr["Parameter4"] = 0; + dr["Parameter5"] = 0; + dr["Parameter6"] = 0; + dr["Parameter7"] = 0; + dr["Parameter8"] = 0; + dr["Parameter9"] = 0; + dr["Parameter10"] = 0; + dr["Parameter1_S1"] = 0; + dr["Parameter2_S1"] = 0; + dr["Parameter3_S1"] = 0; + dr["Parameter4_S1"] = 0; + dr["Parameter5_S1"] = 0; + dr["Parameter1_S2"] = 0; + dr["Parameter2_S2"] = 0; + dr["Parameter3_S2"] = 0; + dr["Parameter4_S2"] = 0; + dr["Parameter5_S2"] = 0; + dr["Parameter1_S3"] = 0; + dr["Parameter2_S3"] = 0; + dr["Parameter3_S3"] = 0; + dr["Parameter4_S3"] = 0; + dr["Parameter5_S3"] = 0; + dr["StepName_S1"] = " "; + dr["StepName_S2"] = " "; + dr["StepName_S3"] = " "; + dr["StepID_S1"] = "000"; + dr["StepID_S2"] = "000"; + dr["StepID_S3"] = "000"; + Step.Rows.InsertAt(dr, Step.Rows.Count); + Dat(Step); + ID = Step.Rows.Count.ToString(); + } ViewStep viewstop = new ViewStep(Numder, Step.Select("STEP = " + ID).First()); viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked); viewstop.data = ID; @@ -163,16 +243,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.View private void Address_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果 { int i = Step.Rows.Count; - int n = StrToInt.To16Convert10(ID); - if (i == n) - { - DataRow dr_ = Step.NewRow();//添加表数据 - dr_["ProgramID"] = ProgramID; - dr_["Program"] = ProgramNAME; - Step.Rows.Add(dr_); - Dat(Step); - ID = (n + 1).ToString(); - } + int n = Convert.ToInt16(ID); + int steptime = 0;//时间秒 string[] time_D = { "001", "013", "015", "017", "065" }; string[] time_J = { "031", "093" }; @@ -249,6 +321,37 @@ namespace SunlightCentralizedControlManagement_SCCM_.View DataRow dr = Step.NewRow();//添加表数据 dr["ProgramID"] = ProgramID; dr["Program"] = ProgramNAME; + dr["Parameter1"] = 0; + dr["Parameter2"] = 0; + dr["Parameter3"] = 0; + dr["Parameter4"] = 0; + dr["Parameter5"] = 0; + dr["Parameter6"] = 0; + dr["Parameter7"] = 0; + dr["Parameter8"] = 0; + dr["Parameter9"] = 0; + dr["Parameter10"] = 0; + dr["Parameter1_S1"] = 0; + dr["Parameter2_S1"] = 0; + dr["Parameter3_S1"] = 0; + dr["Parameter4_S1"] = 0; + dr["Parameter5_S1"] = 0; + dr["Parameter1_S2"] = 0; + dr["Parameter2_S2"] = 0; + dr["Parameter3_S2"] = 0; + dr["Parameter4_S2"] = 0; + dr["Parameter5_S2"] = 0; + dr["Parameter1_S3"] = 0; + dr["Parameter2_S3"] = 0; + dr["Parameter3_S3"] = 0; + dr["Parameter4_S3"] = 0; + dr["Parameter5_S3"] = 0; + dr["StepName_S1"] = " "; + dr["StepName_S2"] = " "; + dr["StepName_S3"] = " "; + dr["StepID_S1"] = "000"; + dr["StepID_S2"] = "000"; + dr["StepID_S3"] = "000"; Step.Rows.InsertAt(dr, d - 1); ID = null; @@ -267,7 +370,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View data_t = Step.Clone(); int a = Step.Rows.Count; - for (int i = 0; i < a - 1; i++) + for (int i = 0; i < a ; i++) { data_t.Clear();//清空 @@ -299,13 +402,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.View Insert.IsEnabled = false; Delete.IsEnabled = false; - int d = 0; int a = Step.Rows.Count; - - if (ID != null) { d = Convert.ToInt32(ID); } else { return; } - if (a != d)//如果删除不是最后一行执行 - { - Step.Rows.RemoveAt(d - 1); + int rownum = Grid_step.SelectedIndex; + if (rownum >= 0 && rownum