void frmAddPlan_e_OnReturnTaskPlanItem(TaskPlanItem planItem) { planItem.TaskPlanItemID = taskPlanItemList.Count + 1; taskPlanItemList.Add(planItem); this.dgvTaskPlan.RemoveBind(); this.dgvTaskPlan.ReBind(TaskPlanItem.GetDataTable(taskPlanItemList), false); this.dgvTaskPlan.ClearSelection(); }
private void btnRemove_Click(object sender, EventArgs e) { if (dgvTaskPlan.SelectedRows.Count > 0) { int taskPlanItemID = DMSFrame.TryParse.StrToInt(dgvTaskPlan[colTaskPlanItemID.Index, dgvTaskPlan.SelectedRows[0].Index].Value); if (taskPlanItemID > 0) { TaskPlanItem entity = taskPlanItemList.Where(q => q.TaskPlanItemID == taskPlanItemID).FirstOrDefault(); if (entity != null) { taskPlanItemList.Remove(entity); this.dgvTaskPlan.RemoveBind(); this.dgvTaskPlan.ReBind(TaskPlanItem.GetDataTable(taskPlanItemList), false); this.dgvTaskPlan.ClearSelection(); } } } }
public frmPlan(string planName) { InitializeComponent(); string errMsg = string.Empty; string dirPath = Program.GetConfigPath(@"plan"); if (!System.IO.Directory.Exists(dirPath)) { System.IO.Directory.CreateDirectory(dirPath); } if (!string.IsNullOrEmpty(planName)) { string filePath = Program.GetConfigPath(@"plan\" + planName + ".xml"); taskPlanEntity = XmlHelper.LoadFromXml <TaskPlan>(filePath, ref errMsg); if (!string.IsNullOrEmpty(errMsg)) { WinFormLib.Core.MessageBoxHelper.ShowError(errMsg); } } else { taskPlanEntity = new TaskPlan(); } lbTaskPlanName.DataViewValue = taskPlanEntity.PlanName.Value; lbRemark.DataViewValue = taskPlanEntity.Remark.Value; if (taskPlanEntity.ExpireFlag) { chkExpireFlag.Checked = true; if (taskPlanEntity.ExpireType == EnumGloabParas.EnumExpireType.Count) { raNumber.Checked = true; numExpireCount.Value = taskPlanEntity.ExpireCount; } else { raDateTime.Checked = true; dateExpireTime.Value = taskPlanEntity.ExpireTime; } } else { chkExpireFlag.Checked = false; } dateStartDate.Value = taskPlanEntity.StartDate; if (taskPlanEntity.PlanExcuteType == EnumGloabParas.EnumPlanExcuteType.One) { raOneTime.Checked = true; oneStartTime.Value = taskPlanEntity.StartTime; } else if (taskPlanEntity.PlanExcuteType == EnumGloabParas.EnumPlanExcuteType.Day) { raDay.Checked = true; dayStartTime.Value = taskPlanEntity.StartTime; string[] str = taskPlanEntity.PlanExcuteString.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (str.Length == 2) { DateTime[] dateTime = Array.ConvertAll <string, DateTime>(str, item => DMSFrame.TryParse.StrToDate(item)); dayStartTime1.Value = dateTime[0]; dayStartTime2.Value = dateTime[1]; } } else if (taskPlanEntity.PlanExcuteType == EnumGloabParas.EnumPlanExcuteType.Weekly) { raWeekly.Checked = true; weeklyStartTime.Value = taskPlanEntity.StartTime; string[] str = taskPlanEntity.PlanExcuteString.Value.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (str.Length == 7) { int index = 0; foreach (var item in str) { CheckBox chkWeekly = pnlWeekly.Controls["chkWeekly" + index] as CheckBox; if (chkWeekly != null) { if (item == "1") { chkWeekly.Checked = true; } else { chkWeekly.Checked = false; } } index++; } } } else if (taskPlanEntity.PlanExcuteType == EnumGloabParas.EnumPlanExcuteType.Custom) { raCustom.Checked = true; cusStartTime.Value = taskPlanEntity.StartTime; cusInterval.Value = DMSFrame.TryParse.StrToDecimal(taskPlanEntity.PlanExcuteString); } ShowExcuteTypePanel(); taskPlanItemList = taskPlanEntity.PlanItemList; if (taskPlanItemList.Count > 0) { //this.dgvTaskPlan.RemoveBind(); this.dgvTaskPlan.ReBind(TaskPlanItem.GetDataTable(taskPlanItemList), false); this.dgvTaskPlan.ClearSelection(); } }