protected void btnSave_Click(object sender, EventArgs e) { string sWorkflowTemplagteName = this.txtWorkflowTemplate.Text.Trim(); string sWorkflowType = this.ddlWorkflowType.SelectedValue; string sDesc = this.txtDesc.Text.Trim(); string sCalcDueDateMethod = this.ddlCalcDueDateMethod.SelectedValue; bool bDefault = this.chkDefault.Checked; #region get stage data string sSequences = this.hdnSequences.Text; string sStageTempIDs = this.hdnStageIDs.Text; string sStageNames = this.hdnStageNames.Text; // Open$Submit$Approve string sEnableds = this.hdnEnableds.Text; string sDaysFromEstCloseDates = this.hdnDaysFromEstCloseDates.Text; string sDaysAfterCreationDates = this.hdnDaysAfterCreationDates.Text; #endregion Template_Workflow WorkflowTemplateManager = new Template_Workflow(); #region build stage list DataTable StageList = WorkflowTemplateManager.GetWflStageList(" and (1=0)"); if (sSequences != string.Empty) { string[] SequenceArray = sSequences.Split(','); string[] StageTempIDArray = sStageTempIDs.Split(','); string[] StageNameArray = sStageNames.Split(','); string[] EnabledArray = sEnableds.Split(','); string[] DaysFromEstCloseDateArray = sDaysFromEstCloseDates.Split(','); string[] DaysAfterCreationDateArray = sDaysAfterCreationDates.Split(','); for (int i = 0; i < SequenceArray.Length; i++) { string sSequence = SequenceArray[i]; string sStageTempID = StageTempIDArray[i]; string sStageNameBlock = StageNameArray[i]; string sEnabled = EnabledArray[i]; string sDaysFromEstCloseDate = DaysFromEstCloseDateArray[i]; string sDaysAfterCreationDate = DaysAfterCreationDateArray[i]; #region format StageName string sStageName = sStageNameBlock.Replace("[$", string.Empty); sStageName = sStageName.Replace("$]", string.Empty); #endregion #region add rows DataRow StageRow = StageList.NewRow(); StageRow["WflStageId"] = 0; StageRow["WflTemplId"] = 0; StageRow["Name"] = sStageName; StageRow["SequenceNumber"] = Convert.ToInt16(sSequence); StageRow["Enabled"] = Convert.ToBoolean(sEnabled); if (sCalcDueDateMethod == "Est Close Date") { if (sDaysFromEstCloseDate == "null") { StageRow["DaysFromEstClose"] = DBNull.Value; } else { StageRow["DaysFromEstClose"] = Convert.ToInt16(sDaysFromEstCloseDate); } StageRow["DaysFromCreation"] = DBNull.Value; StageRow["CalculationMethod"] = 1; } else { StageRow["DaysFromEstClose"] = DBNull.Value; if (sDaysAfterCreationDate == "null") { StageRow["DaysFromCreation"] = DBNull.Value; } else { StageRow["DaysFromCreation"] = Convert.ToInt16(sDaysAfterCreationDate); } StageRow["CalculationMethod"] = 2; } StageRow["TemplStageId"] = sStageTempID; StageList.Rows.Add(StageRow); #endregion } } #endregion // insert WorkflowTemplateManager.InsertWorkflowTemplate(sWorkflowTemplagteName, true, sDesc, sWorkflowType, bDefault, sCalcDueDateMethod, StageList); // success this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", "$('#divContainer').hide();alert('Create workflow template successfully.');window.location.href='WorkflowTemplateList.aspx';", true); }