private Int64 SaveTaskPlan() { cPlan NewPlan = new cPlan(); Int64 Nid = GetNewID(); if (Nid == 0) { throw new cSoukeyException(rm.GetString("Error21")); } NewPlan.PlanID = Nid; NewPlan.PlanName = this.txtPlanName.Text; NewPlan.PlanRemark = this.txtPlanDemo.Text; //系统自动判断当前任务的状态 if (this.cboxIsDisabled.Checked == true) { if (this.raNumber.Checked == true) { if (this.DisabledRunNum.Value == 1 && DateTime.Compare(DateTime.Now, this.RunOnceTime.Value) > 0) { NewPlan.PlanState = (int)cGlobalParas.PlanState.Disabled; } else { NewPlan.PlanState = (int)cGlobalParas.PlanState.Enabled; } } else if (this.raDateTime.Checked == true) { if (DateTime.Compare(DateTime.Now, this.DisabledDateTime.Value) < 0) { NewPlan.PlanState = (int)cGlobalParas.PlanState.Disabled; } else { NewPlan.PlanState = (int)cGlobalParas.PlanState.Enabled; } } } else { NewPlan.PlanState = (int)cGlobalParas.PlanState.Enabled; } if (this.cboxIsRun.Checked == true) { NewPlan.IsOverRun = true; } else { NewPlan.IsOverRun = false; } if (this.cboxIsDisabled.Checked == true) { NewPlan.IsDisabled = true; } else { NewPlan.IsDisabled = false; } if (this.raNumber.Checked == true) { NewPlan.DisabledType = (int)cGlobalParas.PlanDisabledType.RunTime; } else if (this.raDateTime.Checked == true) { NewPlan.DisabledType = (int)cGlobalParas.PlanDisabledType.RunDateTime; } NewPlan.DisabledTime = int.Parse(this.DisabledRunNum.Value.ToString()); NewPlan.DisabledDateTime = this.DisabledDateTime.Value; cTaskPlan tp; for (int i = 0; i < this.listTask.Items.Count; i++) { tp = new cTaskPlan(); tp.RunTaskType = cGlobalParas.ConvertID(this.listTask.Items[i].Text); if (cGlobalParas.ConvertID(this.listTask.Items[i].Text) == (int)cGlobalParas.RunTaskType.DataTask) { tp.RunTaskName = cGlobalParas.ConvertID(this.listTask.Items[i].SubItems[1].Text.ToString()).ToString(); } else { tp.RunTaskName = this.listTask.Items[i].SubItems[1].Text.ToString(); } tp.RunTaskPara = this.listTask.Items[i].SubItems[2].Text.ToString(); NewPlan.RunTasks.Add(tp); } if (this.raOneTime.Checked == true) { NewPlan.RunTaskPlanType = (int)cGlobalParas.RunTaskPlanType.Ones; } else if (this.raDay.Checked == true) { if (this.raRunones.Checked == true) { NewPlan.RunTaskPlanType = (int)cGlobalParas.RunTaskPlanType.DayOnes; } else if (this.raRuntwice.Checked == true) { NewPlan.RunTaskPlanType = (int)cGlobalParas.RunTaskPlanType.DayTwice; } } else if (this.raWeekly.Checked == true) { NewPlan.RunTaskPlanType = (int)cGlobalParas.RunTaskPlanType.Weekly; } else if (this.raCustom.Checked == true) { NewPlan.RunTaskPlanType = (int)cGlobalParas.RunTaskPlanType.Custom; } NewPlan.EnabledDateTime = this.EnabledDate.Value.ToLongDateString(); NewPlan.RunOnesTime = this.RunOnceTime.Value.ToString(); NewPlan.RunDayTime = this.RunDayOnesTime.Value.ToLongTimeString(); NewPlan.RunAMTime = this.RunDayTwice1Time.Value.ToLongTimeString(); NewPlan.RunPMTime = this.RunDayTwice2Time.Value.ToLongTimeString(); NewPlan.RunWeeklyTime = this.RunWeeklyTime.Value.ToLongTimeString(); NewPlan.FirstRunTime = this.FirstRunTime.Value.ToLongTimeString(); NewPlan.RunInterval = this.udRunInterval.Value.ToString(); string runWeekly = ""; if (this.cboxSunday.Checked == true) { runWeekly = "0"; } if (this.cboxMonday.Checked == true) { runWeekly += ",1"; } if (this.cboxTuesday.Checked == true) { runWeekly += ",2"; } if (this.cboxWednesday.Checked == true) { runWeekly += ",3"; } if (this.cboxThursday.Checked == true) { runWeekly += ",4"; } if (this.cboxFriday.Checked == true) { runWeekly += ",5"; } if (this.cboxSturday.Checked == true) { runWeekly += ",6"; } NewPlan.RunWeekly = runWeekly; cPlans p = new cPlans(); if (this.FormState == cGlobalParas.FormState.New) { p.InsertPlan(NewPlan); } else if (this.FormState == cGlobalParas.FormState.Edit) { p.EditPlan(NewPlan); } p = null; return(Nid); }