示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region 校验必要参数

            // WorkflowTemplateID
            bool bIsValid = PageCommon.ValidateQueryString(this, "WorkflowTemplateID", QueryStringType.ID);
            if (bIsValid == false)
            {
                PageCommon.WriteJsEnd(this, "Missing required query string.", "window.parent.location.href=window.parent.location.href");
            }
            this.iWorkflowTemplateID = Convert.ToInt32(this.Request.QueryString["WorkflowTemplateID"]);

            #endregion

            if (Request.Url != null)
            {
                FromURL = Request.Url.ToString();
            }

            Template_Workflow WorkflowTemplateManager = new Template_Workflow();

            #region 加载Workflow Template信息

            DataTable WorkflowTemplateInfo = WorkflowTemplateManager.GetWorkflowTemplateInfo(this.iWorkflowTemplateID);
            if (WorkflowTemplateInfo.Rows.Count == 0)
            {
                PageCommon.WriteJsEnd(this, "Invalid required query string.", "window.parent.location.href=window.parent.location.href");
            }

            #endregion

            // is custom
            this.hdnIsCustom.Text = WorkflowTemplateInfo.Rows[0]["Custom"].ToString();
            this.gWorkflowType    = WorkflowTemplateInfo.Rows[0]["WorkflowType"].ToString();

            // __doPostBack
            this.GetPostBackEventReference(this.btnSave);

            if (this.IsPostBack == false)
            {
                #region build ddlSeq options

                StringBuilder sbSeqOptions = new StringBuilder();
                for (int i = 0; i < 999; i++)
                {
                    int iSeq = i + 1;
                    sbSeqOptions.AppendLine("<option value=\"" + iSeq + "\">" + iSeq + "</option>");
                }
                this.ltrSeqOptions.Text = sbSeqOptions.ToString();

                #endregion

                #region 加载Stage Template List

                Template_Stages StageTemplateManager = new Template_Stages();

                // Processing and Prospect
                DataTable StageTemplateList = StageTemplateManager.GetStageTemplateList(" and [Enabled]=1");
                this.ddlStageTemplateList.DataSource = StageTemplateList;
                this.ddlStageTemplateList.DataBind();

                // Processing
                DataView StageTemplateListView1 = new DataView(StageTemplateList);
                StageTemplateListView1.RowFilter   = "WorkflowType='Processing'";
                this.StageTemplateList1            = this.AddSelectStageRow(StageTemplateListView1.ToTable());
                this.ddlStageProcessing.DataSource = StageTemplateList1;
                this.ddlStageProcessing.DataBind();

                // Prospect
                DataView StageTemplateListView2 = new DataView(StageTemplateList);
                StageTemplateListView2.RowFilter = "WorkflowType='Prospect'";
                this.StageTemplateList2          = this.AddSelectStageRow(StageTemplateListView2.ToTable());
                this.ddlStageProspect.DataSource = StageTemplateList2;
                this.ddlStageProspect.DataBind();

                #endregion

                #region 绑定数据

                if (WorkflowTemplateInfo.Rows[0]["Name"] == DBNull.Value)
                {
                    this.txtWorkflowTemplate.Text = "";
                }
                else
                {
                    this.txtWorkflowTemplate.Text = WorkflowTemplateInfo.Rows[0]["Name"].ToString();
                }
                if ((WorkflowTemplateInfo.Rows[0]["WorkflowType"] == DBNull.Value) ||
                    (WorkflowTemplateInfo.Rows[0]["WorkflowType"].ToString() == ""))
                {
                    this.ddlWorkflowType.SelectedValue = "Processing";
                }
                else
                {
                    //this.ddlWorkflowType.SelectedValue = WorkflowTemplateInfo.Rows[0]["WorkflowType"].ToString();
                    if (WorkflowTemplateInfo.Rows[0]["WorkflowType"].ToString().ToUpper() == "PROCESSING")
                    {
                        this.ddlWorkflowType.SelectedValue = "Processing";
                    }
                    if (WorkflowTemplateInfo.Rows[0]["WorkflowType"].ToString().ToUpper() == "PROSPECT")
                    {
                        this.ddlWorkflowType.SelectedValue = "Prospect";
                    }
                }

                if (WorkflowTemplateInfo.Rows[0]["Desc"] != DBNull.Value)
                {
                    this.txtDesc.Text = WorkflowTemplateInfo.Rows[0]["Desc"].ToString();
                }

                if (WorkflowTemplateInfo.Rows[0]["Enabled"] == DBNull.Value)
                {
                    this.chkEnabled.Checked = false;
                }
                else
                {
                    this.chkEnabled.Checked = Convert.ToBoolean(WorkflowTemplateInfo.Rows[0]["Enabled"]);
                }

                // cr47
                if (this.chkEnabled.Checked == true)
                {
                    this.btnRegen.Disabled = false;
                }
                else
                {
                    this.btnRegen.Disabled = true;
                }

                if (WorkflowTemplateInfo.Rows[0]["CalculationMethod"] == DBNull.Value)
                {
                    this.ddlCalcDueDateMethod.SelectedValue = "Est Close Date";
                }
                else if (WorkflowTemplateInfo.Rows[0]["CalculationMethod"].ToString() == "1")
                {
                    this.ddlCalcDueDateMethod.SelectedValue = "Est Close Date";
                }
                else if (WorkflowTemplateInfo.Rows[0]["CalculationMethod"].ToString() == "2")
                {
                    this.ddlCalcDueDateMethod.SelectedValue = "Creation Date";
                }
                else
                {
                    this.ddlCalcDueDateMethod.SelectedValue = "Completion Date of the previous Stage";
                }

                //this.ddlCalcDueDateMethod.SelectedValue = WorkflowTemplateInfo.Rows[0]["CalculationMethod"].ToString() == "1" ? "Est Close Date" : "Creation Date";

                if (WorkflowTemplateInfo.Rows[0]["Default"] == DBNull.Value)
                {
                    this.chkDefault.Checked = false;
                }
                else
                {
                    this.chkDefault.Checked = Convert.ToBoolean(WorkflowTemplateInfo.Rows[0]["Default"]);
                }

                #endregion

                #region 加载Workflow Stage List

                DataTable WflStageListData = WorkflowTemplateManager.GetWflStageList(this.iWorkflowTemplateID);
                this.gridStageList.DataSource = WflStageListData;
                this.gridStageList.DataBind();

                #endregion

                // set counter
                this.hdnCounter.Value = WflStageListData.Rows.Count.ToString();
            }
        }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验必要参数

        // from
        if (this.Request.QueryString["from"] == null)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing3", "$('#divContainer').hide();alert('Missing required query string.');window.parent.location.href='WorkflowTemplateList.aspx');", true);
            return;
        }
        else
        {
            this.sFrom = this.Request.QueryString["from"];
        }

        bool bIsValid = PageCommon.ValidateQueryString(this, "WflStageID", QueryStringType.ID);
        if (bIsValid == false)
        {
            string sWflStageID = this.Request.QueryString["WflStageID"].ToString();
            if (sWflStageID != "0")
            {
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing1", "$('#divContainer').hide();alert('Missing required query string.');window.parent.location.href='" + this.sFrom + "';", true);
                return;
            }
        }
        this.iWflStageID = Convert.ToInt32(this.Request.QueryString["WflStageID"]);

        bIsValid = PageCommon.ValidateQueryString(this, "WorkflowTemplateID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing2", "$('#divContainer').hide();alert('Missing required query string.');window.parent.location.href='" + this.sFrom + "';", true);
            return;
        }
        this.iWorkflowTemplateID = Convert.ToInt32(this.Request.QueryString["WorkflowTemplateID"]);

        if (this.Request.QueryString["PageIndex"] != null) // PageIndex
        {
            try
            {
                PageIndex = int.Parse(this.Request.QueryString["PageIndex"].ToString());
            }
            catch
            {
                PageIndex = 1;
            }
        }
        else
        {
            PageIndex = AspNetPager1.CurrentPageIndex;
        }



        #endregion

        Template_Workflow WorkflowTemplateManager = new Template_Workflow();

        #region 加载Workflow Stage信息

        DataTable WflStageInfo = null;
        if (this.iWflStageID > 0)
        {
            WflStageInfo = WorkflowTemplateManager.GetWflStageInfo(this.iWflStageID);
            if (WflStageInfo.Rows.Count == 0)
            {
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Invalid1", "$('#divContainer').hide();alert('Invalid required query string.');window.parent..location.href='" + this.sFrom + "';", true);
                return;
            }
        }

        #endregion

        #region 加载Workflow Template信息

        DataTable WorkflowTemplateInfo = WorkflowTemplateManager.GetWorkflowTemplateInfo(this.iWorkflowTemplateID);
        if (WorkflowTemplateInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Invalid2", "$('#divContainer').hide();alert('Invalid required query string.');window.parent..location.href='" + this.sFrom + "';", true);
            return;
        }

        string sWorkflowTemplate = WorkflowTemplateInfo.Rows[0]["Name"].ToString();
        string sWorkflowType     = WorkflowTemplateInfo.Rows[0]["WorkflowType"].ToString();
        string sCalcMethod       = WorkflowTemplateInfo.Rows[0]["CalculationMethod"].ToString();

        this.lbWorkflowTemplate.Text = sWorkflowTemplate;
        this.lbWorkflowType.Text     = sWorkflowType;

        #endregion

        #region 加载Workflow Task List

        Template_Stages StageTemplateManager = new Template_Stages();

        string sSql       = string.Empty;
        string sOrderName = string.Empty;
        if (this.iWflStageID == 0)   // // All Stages
        {
            //sSql = "select top(10) a.*, b.Name as PrerequisiteTask, c.Name as StageName, case when a.Enabled=1 then 'Yes' else 'No' end as TaskEnabled "
            //            + "from Template_Wfl_Tasks as a left join Template_Wfl_Tasks as b on a.PrerequisiteTaskId = b.TemplTaskId "
            //            + "inner join Template_Wfl_Stages as c on a.WflStageId = c.WflStageId "
            //            + "where a.WflStageId in (select WflStageId from Template_Wfl_Stages where WflTemplId=" + this.iWorkflowTemplateID + ")";
            sSql       = " AND WflTemplId='" + this.iWorkflowTemplateID + "'";
            sOrderName = "StageName";
        }
        else
        {
            //sSql = "select top(10) a.*, b.Name as PrerequisiteTask, c.Name as StageName, case when a.Enabled=1 then 'Yes' else 'No' end as TaskEnabled "
            //            + "from Template_Wfl_Tasks as a left join Template_Wfl_Tasks as b on a.PrerequisiteTaskId = b.TemplTaskId "
            //            + "inner join Template_Wfl_Stages as c on a.WflStageId = c.WflStageId "
            //            + "where a.WflStageId=" + this.iWflStageID;
            sSql       = " AND WflStageId='" + this.iWflStageID + "'";
            sOrderName = "SequenceNumber";
        }
        int pageSize    = AspNetPager1.PageSize;
        int pageIndex   = PageIndex;
        int recordCount = 0;

        //DataTable TaskListData = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql);
        LPWeb.BLL.Template_Wfl_Tasks tBLL = new Template_Wfl_Tasks();
        DataSet TaskListData = tBLL.GetWorkflowStageTasks(pageSize, pageIndex, sOrderName, sSql, out recordCount);

        AspNetPager1.PageSize    = pageSize;
        AspNetPager1.RecordCount = recordCount;

        this.gridWorkflowTaskList.DataSource = TaskListData;
        this.gridWorkflowTaskList.DataBind();

        #endregion

        if (this.IsPostBack == false)
        {
            #region 加载Workflow Stage List

            DataTable WflStageListData = WorkflowTemplateManager.GetWflStageList(this.iWorkflowTemplateID);

            DataRow NewStageRow = WflStageListData.NewRow();
            NewStageRow["TemplStageId"] = DBNull.Value;
            NewStageRow["Name"]         = "All Stages";
            WflStageListData.Rows.InsertAt(NewStageRow, 0);

            this.ddlStage.DataSource = WflStageListData;
            this.ddlStage.DataBind();

            #endregion

            #region 绑定数据

            if (this.iWflStageID == 0)  // All Stages
            {
            }
            else
            {
                this.ddlStage.SelectedValue = this.iWflStageID.ToString();
                this.chkEnabled.Checked     = Convert.ToBoolean(WflStageInfo.Rows[0]["Enabled"]);
                this.txtSeq.Text            = WflStageInfo.Rows[0]["SequenceNumber"].ToString();
                if (WflStageInfo.Rows[0]["CalculationMethod"].ToString() != "" &&
                    WflStageInfo.Rows[0]["CalculationMethod"].ToString() != "0")
                {
                    sCalcMethod = WflStageInfo.Rows[0]["CalculationMethod"].ToString();
                }

                if (sCalcMethod != "3")
                {
                    if (sCalcMethod != "" && sCalcMethod != "0")
                    {
                        this.hdnCalcDueDateMethod.Value = sCalcMethod == "1" ? "Est Close Date" : "Creation Date";
                        //this.ddlCalcDueDateMethod.SelectedValue = sCalcMethod == "1" ? "Est Close Date" : "Creation Date";
                    }
                    if (sCalcMethod == "1")
                    {
                        this.txtDaysFromEstClose.Text     = WflStageInfo.Rows[0]["DaysFromEstClose"].ToString();
                        this.txtDaysFromEstClose.Enabled  = true;
                        this.txtDaysAfterCreation.Enabled = false;
                    }
                    else
                    {
                        this.txtDaysFromEstClose.Enabled  = false;
                        this.txtDaysAfterCreation.Text    = WflStageInfo.Rows[0]["DaysFromCreation"].ToString();
                        this.txtDaysAfterCreation.Enabled = true;
                    }
                }
                else
                {
                    this.hdnCalcDueDateMethod.Value = "Completion Date of the previous Stage";
                }
            }
            #endregion
        }
        Template_Wfl_Stages tempWflStages = new Template_Wfl_Stages();
        this.hdnMinStagesSeq.Value = tempWflStages.GetMinStageSeqNumByWflTempID(this.iWorkflowTemplateID).ToString();
        this.hdnSecStagesSeq.Value = tempWflStages.GetSecStageSeqNumByWflTempID(this.iWorkflowTemplateID).ToString();
    }