private void SetControlsReadyonly()
        {
            this.tbxTemplateName.ReadOnly = true;

            this.tbxTaskName.ReadOnly                 = false;
            this.tbxDescription.ReadOnly              = false;
            this.tbxDueDaysByDate.ReadOnly            = false;
            this.tbxDueDaysByTask.ReadOnly            = false;
            this.tbxDaysDueAfterCreationDate.ReadOnly = false;
            this.ddlStage.Enabled            = true;
            this.ddlOwner.Enabled            = true;
            this.ddlPrerequisiteTask.Enabled = true;
            //this.ddlCompletionEmail.Enabled = true;
            this.ddlOverdueEmail.Enabled    = true;
            this.ddlWarningEmail.Enabled    = true;
            this.chkEnable.Enabled          = true;
            this.chkExternalViewing.Enabled = true;

            if (this.iTaskID == 0)
            {
                this.btnDelete.Enabled = false;
            }
            else
            {
                this.btnDelete.Enabled = true;
            }
            this.btnDelete.Visible = true;
            this.btnSave.Visible   = true;

            Template_Workflow templateMgr = new Template_Workflow();

            LPWeb.Model.Template_Workflow tempModel = new Model.Template_Workflow();
            tempModel = templateMgr.GetModel(this.iTemplateID);
            this.hdnCustomTemplate.Value = tempModel.Custom.ToString();
            if (tempModel.Custom == false)
            {
                this.tbxTemplateName.Enabled = false;

                this.tbxTaskName.Enabled                 = false;
                this.tbxDescription.Enabled              = false;
                this.tbxDueDaysByDate.Enabled            = false;
                this.tbxDueDaysByTask.Enabled            = false;
                this.tbxDaysDueAfterCreationDate.Enabled = false;
                this.ddlStage.Enabled            = false;
                this.ddlOwner.Enabled            = false;
                this.ddlPrerequisiteTask.Enabled = false;
                //this.ddlCompletionEmail.Enabled = false;
                this.ddlOverdueEmail.Enabled    = false;
                this.ddlWarningEmail.Enabled    = false;
                this.chkEnable.Enabled          = false;
                this.chkExternalViewing.Enabled = false;

                this.btnSave.Enabled   = false;
                this.btnDelete.Enabled = false;
            }
        }
 private void BindControls()
 {
     if (WflTemplId == 0)
     {
         return;
     }
     try
     {
         LPWeb.Model.Template_Workflow model = new Model.Template_Workflow();
         model = template.GetModel(WflTemplId);
         if (model == null)
         {
             return;
         }
         txbTemplateName.Text = model.Name;
         txbEescription.Text  = model.Desc;
         cbEnabled.Checked    = model.Enabled;
     }
     catch
     { }
     try
     {
         string strWhere           = string.Format(" WflTemplId= {0} AND WflStageId = {1}", WflTemplId.ToString(), StageID);
         Template_Wfl_Stages stage = new Template_Wfl_Stages();
         DataSet             ds    = stage.GetList(strWhere);
         if (ds == null || ds.Tables.Count < 1 || ds.Tables[0].Rows.Count < 1)
         {
             txbEstClose.Text = string.Empty;
         }
         else
         {
             txbEstClose.Text = ds.Tables[0].Rows[0]["DaysFromEstClose"].ToString();
         }
     }
     catch
     { }
 }
示例#3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string sErrorJs = string.Empty;

        if (this.Request.QueryString["CloseDialogCodes"] == null)
        {
            sErrorJs = "window.parent.RefreshPage();";
        }
        else
        {
            sErrorJs = this.Request.QueryString["CloseDialogCodes"] + ";";
        }

        int iStageID = Convert.ToInt32(this.LoanTaskInfo.Rows[0]["LoanStageId"]);

        int iCurrentUserID = this.CurrUser.iUserID;

        string sTaskName = string.Empty;

        if (radTaskList.Checked == true)
        {
            sTaskName = this.ddlTaskList.SelectedValue;
            if (sTaskName == "-- select --")
            {
                sTaskName = string.Empty;
            }
        }
        else
        {
            sTaskName = this.txtTaskName.Text.Trim();
        }
        string sDesc = this.txtDescription.Text.Trim();

        int    iOwnerID = Convert.ToInt32(this.ddlOwner.SelectedItem.Value);
        string sDueDate = this.txtDueDate.Text.Trim();

        int iPrerequisiteID = Convert.ToInt32(this.ddlPrerequisite.SelectedItem.Value);

        //Get task template Calculation Method
        int iCalculationMethod = 0;

        if (this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString() != "" && this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString() != "0")
        {
            LPWeb.BLL.Template_Wfl_Tasks   taskTempMgr   = new Template_Wfl_Tasks();
            LPWeb.Model.Template_Wfl_Tasks taskTempModel = taskTempMgr.GetModel(int.Parse(this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString()));

            if (taskTempModel != null)
            {
                LPWeb.BLL.Template_Wfl_Stages   stageWflMgr = new Template_Wfl_Stages();
                LPWeb.Model.Template_Wfl_Stages stageModel  = stageWflMgr.GetModel(taskTempModel.WflStageId);
                if (stageModel != null)
                {
                    LPWeb.BLL.Template_Workflow   templateMgr   = new Template_Workflow();
                    LPWeb.Model.Template_Workflow templateModel = templateMgr.GetModel(stageModel.WflTemplId);
                    if (templateModel != null)
                    {
                        iCalculationMethod = templateModel.CalculationMethod;
                    }

                    if (stageModel.CalculationMethod != null && stageModel.CalculationMethod.Value != 0)
                    {
                        iCalculationMethod = stageModel.CalculationMethod.Value;
                    }
                }
            }
        }

        int iDaysToEstClose = 0;

        if (this.txtDaysToEst.Text != string.Empty)
        {
            if (iCalculationMethod == 2 && this.txtDaysAfterCreation.Text != string.Empty)
            {
                iDaysToEstClose        = 0;
                this.txtDaysToEst.Text = "";
            }
            else
            {
                iDaysToEstClose = Convert.ToInt32(this.txtDaysToEst.Text);
            }
        }

        int iDaysAfterCreation = 0;

        if (this.txtDaysAfterCreation.Text != string.Empty)
        {
            if (iCalculationMethod == 1 && this.txtDaysToEst.Text != string.Empty)
            {
                iDaysAfterCreation             = -1;
                this.txtDaysAfterCreation.Text = "";
            }
            else
            {
                iDaysAfterCreation = Convert.ToInt32(this.txtDaysAfterCreation.Text);
            }
        }

        int iDaysDueAfterPre = 0;

        if (this.txtDaysDueAfter.Text != string.Empty)
        {
            iDaysDueAfterPre = Convert.ToInt32(this.txtDaysDueAfter.Text);
        }

        int iWarningEmailID = Convert.ToInt32(this.ddlWarningEmail.SelectedItem.Value);
        int iOverdueEmailID = Convert.ToInt32(this.ddlOverdueEmail.SelectedItem.Value);

        // 原Loan Stage ID
        int iOldStageID = string.IsNullOrEmpty(ddlStage.SelectedValue) ? Convert.ToInt32(this.LoanTaskInfo.Rows[0]["LoanStageId"]) : Convert.ToInt32(ddlStage.SelectedValue);  //CR54 this.iCurrentLoanStageId; //Convert.ToInt32(this.LoanTaskInfo.Rows[0]["LoanStageId"]);

        #region 检查任务名称重复
        if (string.IsNullOrEmpty(sTaskName) || sTaskName.Trim() == string.Empty)
        {
            PageCommon.AlertMsg(this, "The task name cannot be blank.");
            return;
        }

        var loanInfo = this.LoanManager.GetModel(this.iLoanID);
        if (loanInfo == null || loanInfo.Status != "Prospect")  //CR54 当为Prospect时检查重复
        {
            bool bIsExist = this.LoanTaskManager.IsLoanTaskExists_Update(this.iLoanID, this.iTaskID, sTaskName);
            if (bIsExist == true)
            {
                PageCommon.AlertMsg(this, "The task name is already taken.");
                return;
            }
        }

        LPWeb.Model.LoanTasks taskModel = new LPWeb.Model.LoanTasks();
        taskModel.LoanTaskId  = iTaskID;
        taskModel.Name        = sTaskName.Trim();
        taskModel.Desc        = sDesc.Trim();
        taskModel.LoanStageId = iStageID;
        if (iStageID == iOldStageID || iOldStageID <= 0)
        {
            taskModel.OldLoanStageId = 0;
        }
        else
        {
            taskModel.OldLoanStageId = iOldStageID;
        }

        taskModel.Owner        = iOwnerID;
        taskModel.ModifiedBy   = iCurrentUserID;
        taskModel.LastModified = DateTime.Now;
        taskModel.FileId       = iLoanID;

        if (string.IsNullOrEmpty(sDueDate))
        {
            taskModel.Due = DateTime.MinValue;
        }
        else
        {
            taskModel.Due = DateTime.Parse(sDueDate);
        }

        string sDueTime = this.ddlDueTime_hour.Text + ":" + this.ddlDueTime_min.Text;
        sDueTime = sDueTime.Replace("am", "").Replace("pm", "");
        DateTime DTN           = DateTime.Now;
        string   sDueTime_Span = null;
        TimeSpan DueTime       = new TimeSpan();

        if (sDueTime == string.Empty)
        {
            taskModel.DueTime = null;
        }
        else
        {
            taskModel.DueTime = null;
            if (DateTime.TryParse(sDueTime, out DTN) == true)
            {
                sDueTime_Span = DTN.ToString("HH:mm");
                if (TimeSpan.TryParse(sDueTime_Span, out DueTime) == true)
                {
                    taskModel.DueTime = DueTime;
                }
            }
        }

        taskModel.DaysDueFromEstClose      = (short)iDaysToEstClose;
        taskModel.DaysFromCreation         = (short)iDaysAfterCreation;
        taskModel.PrerequisiteTaskId       = iPrerequisiteID;
        taskModel.DaysDueAfterPrerequisite = (short)iDaysDueAfterPre;

        taskModel.WarningEmailId = iWarningEmailID;
        taskModel.OverdueEmailId = iOverdueEmailID;

        taskModel.ExternalViewing = false;

        if (this.chkCompleted.Checked == true)
        {
            taskModel.Completed   = DateTime.Now;
            taskModel.CompletedBy = iCurrentUserID;
        }

        #endregion

        // update
        bool bIsSuccess1 = LPWeb.BLL.WorkflowManager.UpdateTask(taskModel, this.txtDaysToEst.Text.Trim(), this.txtDaysAfterCreation.Text.Trim(), this.txtDaysDueAfter.Text.Trim(), this.txtDaysDueAfterPrevStage.Text.Trim());
        if (bIsSuccess1 == true)
        {
            SaveCompletetionEmails(iTaskID);

            #region completed

            if (chkCompleted.Checked == true)
            {
                string sResult = this.CompleteTask(this.iTaskID);
                if (sResult != string.Empty)
                {
                    this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed", "$('#divContainer').hide();alert('Failed to complete task.');" + sErrorJs, true);
                }
            }

            #endregion

            // save and create
            if (((Button)sender).Text == "Save and Create Another")
            {
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Redirect", "$('#divContainer').hide();alert('Saved successfully.');window.parent.CloseDialog_EditTask();window.parent.ShowDialog_AddTask();", true);
            }
            else
            {
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", "$('#divContainer').hide();alert('Saved successfully.');" + sErrorJs, true);
            }
        }
        else
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed", "$('#divContainer').hide();alert('Failed to save the record.');" + sErrorJs, true);
        }
    }
        private LPWeb.Model.Template_Wfl_Tasks SetTaskModel()
        {
            Template_Workflow templateMgr = new Template_Workflow();

            LPWeb.Model.Template_Workflow tempModel = new Model.Template_Workflow();
            tempModel = templateMgr.GetModel(this.iTemplateID);

            Template_Wfl_Stages wflStageMgr = new Template_Wfl_Stages();

            LPWeb.Model.Template_Wfl_Stages stageModel = new Model.Template_Wfl_Stages();

            this.iCalculationMethod = tempModel.CalculationMethod;
            if (this.iStageID != 0)
            {
                stageModel = wflStageMgr.GetModel(this.iStageID);
                if (stageModel.CalculationMethod.ToString() != "" && stageModel.CalculationMethod.ToString() != "0")
                {
                    iCalculationMethod = int.Parse(stageModel.CalculationMethod.ToString());
                }
            }

            LPWeb.Model.Template_Wfl_Tasks reModel = new Model.Template_Wfl_Tasks();
            reModel.TemplTaskId = 0;
            reModel.WflStageId  = 0;
            reModel.Type        = 1;
            if (this.iTaskID != 0)
            {
                reModel = this.taskTmpMgr.GetModel(this.iTaskID);
                //reModel.TemplTaskId = this.iTaskID;
            }
            else
            {
                reModel.Enabled = true;
            }
            reModel.TemplTaskId = Convert.ToInt32(this.hdnTaskID.Value);
            reModel.Name        = this.tbxTaskName.Text.Trim();
            reModel.Description = this.tbxDescription.Text.Trim();
            if (chkEnable.Checked)
            {
                reModel.Enabled = true;
            }
            else
            {
                reModel.Enabled = false;
            }

            if (chkExternalViewing.Checked)
            {
                reModel.ExternalViewing = true;
            }
            else
            {
                reModel.ExternalViewing = false;
            }

            if (this.ddlStage.SelectedIndex >= 0)
            {
                reModel.WflStageId = Convert.ToInt32(this.ddlStage.SelectedValue);
            }
            else
            {
                reModel.WflStageId = 0;
            }
            if (this.ddlOwner.SelectedIndex >= 0)
            {
                reModel.OwnerRoleId = Convert.ToInt32(this.ddlOwner.SelectedValue);
            }
            else
            {
                reModel.OwnerRoleId = 0;
            }
            int iDays = 0;

            if (this.ddlPrerequisiteTask.SelectedIndex > 0)
            {
                reModel.DaysDueFromCoe     = null;
                reModel.DaysFromCreation   = null;
                reModel.PrerequisiteTaskId = Convert.ToInt32(this.ddlPrerequisiteTask.SelectedValue);
                if (this.tbxDueDaysByTask.Text.Trim() != "" && Int32.TryParse(this.tbxDueDaysByTask.Text, out iDays))
                {
                    reModel.DaysDueAfterPrerequisite = iDays;
                }
                else
                {
                    reModel.DaysDueAfterPrerequisite = 0;
                }
            }
            else
            {
                reModel.PrerequisiteTaskId       = 0;
                reModel.DaysDueAfterPrerequisite = null;
                if (this.iCalculationMethod == 1)
                {
                    if (this.tbxDueDaysByDate.Text.Trim() != "" && Int32.TryParse(this.tbxDueDaysByDate.Text, out iDays))
                    {
                        reModel.DaysDueFromCoe   = iDays;
                        reModel.DaysFromCreation = null;
                    }
                    else
                    {
                        reModel.DaysDueFromCoe = null;
                    }

                    if (this.tbxDaysDueAfterCreationDate.Text.Trim() != "" && Int32.TryParse(this.tbxDaysDueAfterCreationDate.Text, out iDays) && reModel.DaysDueFromCoe == null)
                    {
                        reModel.DaysFromCreation = iDays;
                    }
                    else
                    {
                        reModel.DaysFromCreation = null;
                    }
                }
                if (this.iCalculationMethod == 2)
                {
                    if (this.tbxDaysDueAfterCreationDate.Text.Trim() != "" && Int32.TryParse(this.tbxDaysDueAfterCreationDate.Text, out iDays))
                    {
                        reModel.DaysFromCreation = iDays;
                        reModel.DaysDueFromCoe   = null;
                    }
                    else
                    {
                        reModel.DaysFromCreation = null;
                    }
                    if (this.tbxDueDaysByDate.Text.Trim() != "" && Int32.TryParse(this.tbxDueDaysByDate.Text, out iDays) && reModel.DaysFromCreation == null)
                    {
                        reModel.DaysDueFromCoe = iDays;
                    }
                    else
                    {
                        reModel.DaysDueFromCoe = null;
                    }
                }
            }
            //if (this.ddlCompletionEmail.SelectedIndex >= 0)
            //{
            //    reModel.CompletionEmailId = Convert.ToInt32(this.ddlCompletionEmail.SelectedValue);
            //}
            //else
            //{
            //    reModel.CompletionEmailId = null;
            //}
            if (this.ddlOverdueEmail.SelectedIndex >= 0)
            {
                reModel.OverdueEmailId = Convert.ToInt32(this.ddlOverdueEmail.SelectedValue);
            }
            else
            {
                reModel.OverdueEmailId = null;
            }
            if (this.ddlWarningEmail.SelectedIndex >= 0)
            {
                reModel.WarningEmailId = Convert.ToInt32(this.ddlWarningEmail.SelectedValue);
            }
            else
            {
                reModel.WarningEmailId = null;
            }

            return(reModel);
        }
        private void LoadTaskData()
        {
            this.tbxTemplateName.Text = "";

            this.tbxTaskName.Text                  = "";
            this.tbxDescription.Text               = "";
            this.ddlOwner.SelectedIndex            = -1;
            this.tbxDueDaysByDate.Text             = "";
            this.tbxDueDaysByTask.Text             = "";
            this.tbxDaysDueAfterCreationDate.Text  = "";
            this.ddlPrerequisiteTask.SelectedIndex = -1;
            this.ddlWarningEmail.SelectedIndex     = -1;
            //this.ddlCompletionEmail.SelectedIndex = -1;
            this.ddlOverdueEmail.SelectedIndex = -1;
            this.ddlStage.SelectedIndex        = -1;

            LPWeb.Model.Template_Wfl_Tasks model = null;
            try
            {
                Template_Workflow             templateMgr = new Template_Workflow();
                LPWeb.Model.Template_Workflow tempModel   = new Model.Template_Workflow();
                tempModel = templateMgr.GetModel(this.iTemplateID);

                Template_Wfl_Stages             wflStageMgr = new Template_Wfl_Stages();
                LPWeb.Model.Template_Wfl_Stages stageModel  = new Model.Template_Wfl_Stages();

                this.iCalculationMethod = tempModel.CalculationMethod;
                if (this.iStageID != 0)
                {
                    stageModel = wflStageMgr.GetModel(this.iStageID);
                    if (stageModel.CalculationMethod.ToString() != "" && stageModel.CalculationMethod.ToString() != "0")
                    {
                        iCalculationMethod = int.Parse(stageModel.CalculationMethod.ToString());
                    }
                }

                this.tbxTemplateName.Text = tempModel.Name;


                model = this.taskTmpMgr.GetModel(this.iTaskID);
                if (this.iTaskID == 0 || model == null)
                {
                    if (this.iTemplateID != 0)
                    {
                        if (this.iStageID != 0)
                        {
                            this.ddlStage.SelectedValue = this.iStageID.ToString();
                        }
                    }
                    this.chkEnable.Checked = true;
                    return;
                }
                //Get Template Name by taskid
                this.ddlStage.SelectedValue            = model.WflStageId.ToString();
                this.tbxTaskName.Text                  = model.Name;
                this.tbxDescription.Text               = model.Description;
                this.ddlOwner.SelectedValue            = model.OwnerRoleId.ToString();
                this.tbxDueDaysByDate.Text             = model.DaysDueFromCoe.ToString();
                this.tbxDueDaysByTask.Text             = model.DaysDueAfterPrerequisite.ToString();
                this.tbxDaysDueAfterCreationDate.Text  = model.DaysFromCreation.ToString();
                this.ddlPrerequisiteTask.SelectedValue = model.PrerequisiteTaskId.ToString();
                if (this.ddlPrerequisiteTask.SelectedIndex > 0)
                {
                    this.ddlStage.Enabled = false;
                }
                if (model.Enabled)
                {
                    this.chkEnable.Checked = true;
                }
                else
                {
                    this.chkEnable.Checked = false;
                }

                if (model.ExternalViewing)
                {
                    this.chkExternalViewing.Checked = true;
                }
                else
                {
                    this.chkExternalViewing.Checked = false;
                }

                //
                if (iCalculationMethod == 1)
                {
                    this.tbxDueDaysByDate.Enabled = true;
                    if (model.DaysFromCreation.ToString() == "" || model.DaysFromCreation.ToString() == "0")
                    {
                        this.tbxDaysDueAfterCreationDate.Enabled = false;
                    }
                    //this.tbxDaysDueAfterCreationDate.Text = "";
                }
                else if (iCalculationMethod == 2)
                {
                    if (model.DaysDueFromCoe.ToString() == "" || model.DaysDueFromCoe.ToString() == "0")
                    {
                        this.tbxDueDaysByDate.Enabled = false;
                    }
                    //this.tbxDueDaysByDate.Text = "";
                    this.tbxDaysDueAfterCreationDate.Enabled = true;
                }

                this.ddlWarningEmail.SelectedValue = model.WarningEmailId.ToString();
                //this.ddlCompletionEmail.SelectedValue = model.CompletionEmailId.ToString();
                this.ddlOverdueEmail.SelectedValue = model.OverdueEmailId.ToString();

                //Set prerequisitetask status base on taskid
                DataTable dtTask = this.taskTmpMgr.GetList(" PrerequisiteTaskId=" + this.iTaskID.ToString()).Tables[0];
                if (dtTask.Rows.Count > 0)
                {
                    this.ddlPrerequisiteTask.SelectedIndex    = -1;
                    this.tbxDueDaysByTask.Text                = "";
                    this.tbxDueDaysByTask.ReadOnly            = true;
                    this.tbxDaysDueAfterCreationDate.Text     = "";
                    this.tbxDaysDueAfterCreationDate.ReadOnly = true;
                    this.ddlPrerequisiteTask.Enabled          = false;
                    this.ddlStage.Enabled      = false;
                    this.hdnIsDependTask.Value = "true";
                }
                //Check Referenced
                LoanTasks loanTaskMgr = new LoanTasks();
                if (loanTaskMgr.GetLoanTaskList(" AND a.TemplTaskId=" + this.iTaskID.ToString()).Rows.Count > 0)
                {
                    this.hdnIsReferenced.Value = "true";
                }
                this.hdnTaskID.Value = this.iTaskID.ToString();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#6
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int iStageID = Convert.ToInt32(this.ddlStage.SelectedItem.Value);

        #region Update Loan Stage of Point File

        DataTable SelectedStageInfo   = this.LoanManager.GetLoanStage(" and LoanStageId=" + iStageID);
        string    sStageCompletedDate = SelectedStageInfo.Rows[0]["Completed"].ToString();
        if (sStageCompletedDate != string.Empty)
        {
            bool bIsSuccess = true;

            // invoke PointManager.UpdateLoanStage()

            if (bIsSuccess == false)
            {
                PageCommon.AlertMsg(this, "Failed to update status date in Point.");
                return;
            }
        }

        #endregion

        LoginUser CurrentUser    = new LoginUser();
        int       iCurrentUserID = CurrentUser.iUserID;

        string sTaskName = this.txtTaskName.Text.Trim();

        int    iOwnerID = Convert.ToInt32(this.ddlOwner.SelectedItem.Value);
        string sDueDate = this.txtDueDate.Text.Trim();

        int iPrerequisiteID = Convert.ToInt32(this.ddlPrerequisite.SelectedItem.Value);
        //Get task template Calculation Method
        int iCalculationMethod = 0;
        if (this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString() != "" && this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString() != "0")
        {
            LPWeb.BLL.Template_Wfl_Tasks   taskTempMgr   = new Template_Wfl_Tasks();
            LPWeb.Model.Template_Wfl_Tasks taskTempModel = taskTempMgr.GetModel(int.Parse(this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString()));

            if (taskTempModel != null)
            {
                LPWeb.BLL.Template_Wfl_Stages   stageWflMgr = new Template_Wfl_Stages();
                LPWeb.Model.Template_Wfl_Stages stageModel  = stageWflMgr.GetModel(taskTempModel.WflStageId);
                if (stageModel != null)
                {
                    LPWeb.BLL.Template_Workflow   templateMgr   = new Template_Workflow();
                    LPWeb.Model.Template_Workflow templateModel = templateMgr.GetModel(stageModel.WflTemplId);
                    if (templateModel != null)
                    {
                        iCalculationMethod = templateModel.CalculationMethod;
                    }

                    if (stageModel.CalculationMethod != null && stageModel.CalculationMethod.Value != 0)
                    {
                        iCalculationMethod = stageModel.CalculationMethod.Value;
                    }
                }
            }
        }
        int iDaysToEstClose = 0;
        if (this.txtDaysToEst.Text != string.Empty)
        {
            if (iCalculationMethod == 2 && this.txtDaysAfterCreation.Text != string.Empty)
            {
                iDaysToEstClose        = 0;
                this.txtDaysToEst.Text = "";
            }
            else
            {
                iDaysToEstClose = Convert.ToInt32(this.txtDaysToEst.Text);
            }
        }
        int iDaysAfterCreation = 0;
        if (this.txtDaysAfterCreation.Text != string.Empty)
        {
            if (iCalculationMethod == 1 && this.txtDaysToEst.Text != string.Empty)
            {
                iDaysAfterCreation             = -1;
                this.txtDaysAfterCreation.Text = "";
            }
            else
            {
                iDaysAfterCreation = Convert.ToInt32(this.txtDaysAfterCreation.Text);
            }
        }

        int iDaysDueAfterPre = 0;
        if (this.txtDaysDueAfter.Text != string.Empty)
        {
            iDaysDueAfterPre = Convert.ToInt32(this.txtDaysDueAfter.Text);
        }

        //int iDaysDueAfterPrevStage = 0;
        //if (this.txtDaysDueAfterPrevStage.Text != string.Empty)
        //{
        //    iDaysDueAfterPrevStage = Convert.ToInt32(this.txtDaysDueAfterPrevStage.Text.Trim());
        //}


        int iCompletionEmailID = Convert.ToInt32(this.ddlCompletionEmail.SelectedItem.Value);
        int iWarningEmailID    = Convert.ToInt32(this.ddlWarningEmail.SelectedItem.Value);
        int iOverdueEmailID    = Convert.ToInt32(this.ddlOverdueEmail.SelectedItem.Value);

        // 原Loan Stage ID
        int iOldStageID = Convert.ToInt32(this.LoanTaskInfo.Rows[0]["LoanStageId"]);

        #region 检查任务名称重复
        if (string.IsNullOrEmpty(sTaskName) || sTaskName.Trim() == string.Empty)
        {
            PageCommon.AlertMsg(this, "The task name cannot be blank.");
            return;
        }
        bool bIsExist = this.LoanTaskManager.IsLoanTaskExists_Update(this.iLoanID, this.iTaskID, sTaskName);
        if (bIsExist == true)
        {
            PageCommon.AlertMsg(this, "The task name is already taken.");
            return;
        }
        LPWeb.Model.LoanTasks taskModel = new LPWeb.Model.LoanTasks();
        taskModel.LoanTaskId  = iTaskID;
        taskModel.Name        = sTaskName.Trim();
        taskModel.LoanStageId = iStageID;
        if (iStageID == iOldStageID || iOldStageID <= 0)
        {
            taskModel.OldLoanStageId = 0;
        }
        else
        {
            taskModel.OldLoanStageId = iOldStageID;
        }

        taskModel.Owner        = iOwnerID;
        taskModel.ModifiedBy   = iCurrentUserID;
        taskModel.LastModified = DateTime.Now;
        taskModel.FileId       = iLoanID;

        if (string.IsNullOrEmpty(sDueDate))
        {
            taskModel.Due = DateTime.MinValue;
        }
        else
        {
            taskModel.Due = DateTime.Parse(sDueDate);
        }

        taskModel.DaysDueFromEstClose      = (short)iDaysToEstClose;
        taskModel.DaysFromCreation         = (short)iDaysAfterCreation;
        taskModel.PrerequisiteTaskId       = iPrerequisiteID;
        taskModel.DaysDueAfterPrerequisite = (short)iDaysDueAfterPre;

        taskModel.CompletionEmailId = iCompletionEmailID;
        taskModel.WarningEmailId    = iWarningEmailID;
        taskModel.OverdueEmailId    = iOverdueEmailID;

        taskModel.ExternalViewing = chbExternalViewing.Checked;

        //taskModel.DaysDueAfterPrevStage = (short)iDaysDueAfterPrevStage;

        #endregion

        // update
        //bool bIsSuccess1 = this.LoanTaskManager.UpdateLoanTask(this.iTaskID, sTaskName, sDueDate, iCurrentUserID, iOwnerID, iStageID, iPrerequisiteID, iDaysToEstClose, iDaysDueAfterPre, iWarningEmailID, iOverdueEmailID, iCompletionEmailID, iOldStageID);
        // we need to invoke Workflow Manager UpdateTask in order to set up everything correctly!
        //bool bIsSuccess1 = LPWeb.BLL.WorkflowManager.UpdateTask(this.iTaskID, sTaskName, sDueDate, iCurrentUserID, iOwnerID, iStageID, iPrerequisiteID, iDaysToEstClose, iDaysDueAfterPre, iWarningEmailID, iOverdueEmailID, iCompletionEmailID, iOldStageID);
        bool bIsSuccess1 = LPWeb.BLL.WorkflowManager.UpdateTask(taskModel, this.txtDaysToEst.Text.Trim(), this.txtDaysAfterCreation.Text.Trim(), this.txtDaysDueAfter.Text.Trim(), this.txtDaysDueAfterPrevStage.Text.Trim());
        if (bIsSuccess1 == true)
        {
            SaveCompletetionEmails(iTaskID);
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Success", "$('#divContainer').hide();alert('Saved successfully.');window.parent.RefreshPage();", true);
        }
        else
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed", "$('#divContainer').hide();alert('Failed to save the record.');window.parent.RefreshPage();", true);
        }
    }
示例#7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string sErrorJs = "window.parent.CloseDialog_EditTask();";

        #region 检查必要参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "LoanID", QueryStringType.ID);
        if (bIsValid == false)
        {
            PageCommon.RegisterJsMsg(this, "Missing required query string.", sErrorJs);
            return;
        }

        this.iLoanID = Convert.ToInt32(this.Request.QueryString["LoanID"]);

        bIsValid = PageCommon.ValidateQueryString(this, "TaskID", QueryStringType.ID);
        if (bIsValid == false)
        {
            PageCommon.RegisterJsMsg(this, "Missing required query string.", sErrorJs);
            return;
        }

        this.iTaskID = Convert.ToInt32(this.Request.QueryString["TaskID"]);

        #endregion

        // server now
        this.hdnNow.Value = DateTime.Now.ToString("MM/dd/yyyy");

        // task icon
        this.imgTaskIcon.ImageUrl = "../images/task/" + WorkflowManager.GetTaskIcon(this.iTaskID);

        #region 加载Loan Task信息

        this.LoanTaskInfo = this.LoanTaskManager.GetLoanTaskInfo(this.iTaskID);
        if (this.LoanTaskInfo.Rows.Count == 0)
        {
            PageCommon.RegisterJsMsg(this, "Invalid required query string.", sErrorJs);
            return;
        }

        #endregion

        #region 检查是否是Prerequisite(is a father?)

        bool bIsPrerequisite = this.LoanTaskManager.IsPrerequisite(this.iTaskID);
        this.hndIsPrerequisite.Value = bIsPrerequisite.ToString();

        #endregion

        #region 获取Borrower和Property信息

        #region Property

        DataTable LoanInfo = this.LoanManager.GetLoanInfo(this.iLoanID);
        if (LoanInfo.Rows.Count == 0)
        {
            PageCommon.RegisterJsMsg(this, "Invalid required query string.", sErrorJs);
            return;
        }
        string sPropertyAddress = LoanInfo.Rows[0]["PropertyAddr"].ToString();
        string sPropertyCity    = LoanInfo.Rows[0]["PropertyCity"].ToString();
        string sPropertyState   = LoanInfo.Rows[0]["PropertyState"].ToString();
        string sPropertyZip     = LoanInfo.Rows[0]["PropertyZip"].ToString();

        string sProperty = sPropertyAddress + ", " + sPropertyCity + ", " + sPropertyState + " " + sPropertyZip;

        // 存储Loan.EstCloseDate
        if (LoanInfo.Rows[0]["EstCloseDate"] != DBNull.Value)
        {
            this.hdnEstCloseDate.Value = Convert.ToDateTime(LoanInfo.Rows[0]["EstCloseDate"]).ToString("MM/dd/yyyy");
        }

        #endregion

        #region Borrower

        DataTable BorrowerInfo = this.LoanManager.GetBorrowerInfo(this.iLoanID);
        if (BorrowerInfo.Rows.Count == 0)
        {
            PageCommon.RegisterJsMsg(this, "There is no Borrower in this loan.", sErrorJs);
            return;
        }
        string sFirstName  = BorrowerInfo.Rows[0]["FirstName"].ToString();
        string sMiddleName = BorrowerInfo.Rows[0]["MiddleName"].ToString();
        string sLastName   = BorrowerInfo.Rows[0]["LastName"].ToString();

        string sBorrower = sLastName + ",  " + sFirstName;
        if (sMiddleName != string.Empty)
        {
            sBorrower += " " + sMiddleName;
        }

        this.lbProperty.Text = sProperty;
        this.lbBorrower.Text = sBorrower;

        #endregion

        #endregion

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

            DataTable LoanStages = this.LoanManager.GetLoanStages(this.iLoanID);

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

            this.ddlStage2.DataSource = LoanStages;
            this.ddlStage2.DataBind();

            #endregion

            #region 加载Owner

            DataTable OwnerList = this.LoanTaskManager.GetLoanTaskOwers(this.iLoanID);

            DataRow EmptyOwnerRow = OwnerList.NewRow();
            EmptyOwnerRow["UserID"]   = 0;
            EmptyOwnerRow["FullName"] = "-- select a task owner--";
            OwnerList.Rows.InsertAt(EmptyOwnerRow, 0);

            this.ddlOwner.DataSource = OwnerList;
            this.ddlOwner.DataBind();

            #endregion

            #region 加载Prerequisite

            // 先绑定Stage
            this.ddlStage.SelectedValue = this.LoanTaskInfo.Rows[0]["LoanStageId"].ToString();

            string sSelectedStageID = string.Empty;
            if (this.Request.QueryString["Stage"] == null)
            {
                sSelectedStageID = this.ddlStage.SelectedItem.Value;
            }
            else
            {
                sSelectedStageID = this.Request.QueryString["Stage"].ToString();
            }

            DataTable PrerequisiteList    = this.LoanTaskManager.GetPrerequisiteList(" and FileID=" + this.iLoanID + " and LoanStageId = " + sSelectedStageID + " and PrerequisiteTaskId is null and LoanTaskId !=" + iTaskID);
            DataRow   NonePrerequisiteRow = PrerequisiteList.NewRow();
            NonePrerequisiteRow["LoanTaskId"] = 0;
            NonePrerequisiteRow["Name"]       = "None";
            PrerequisiteList.Rows.InsertAt(NonePrerequisiteRow, 0);

            this.ddlPrerequisite.DataSource = PrerequisiteList;
            this.ddlPrerequisite.DataBind();

            this.ddlPrerequisite2.DataSource = PrerequisiteList;
            this.ddlPrerequisite2.DataBind();

            #endregion

            #region 加载email template

            Template_Email EmailTempManager = new Template_Email();
            EmailTemplates = EmailTempManager.GetEmailTemplate(" and Enabled = 1");

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "None";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

            this.ddlCompletionEmail.DataSource = EmailTemplates;
            this.ddlCompletionEmail.DataBind();

            this.ddlWarningEmail.DataSource = EmailTemplates;
            this.ddlWarningEmail.DataBind();

            this.ddlOverdueEmail.DataSource = EmailTemplates;
            this.ddlOverdueEmail.DataBind();


            this.ddlEmailTemplate.DataSource = EmailTemplates;
            this.ddlEmailTemplate.DataBind();

            #endregion

            #region 绑定对应模板列表

            LPWeb.BLL.LoanTask_CompletionEmails bllTaskMail = new LoanTask_CompletionEmails();

            gridCompletetionEmails.DataSource = bllTaskMail.GetList("LoanTaskid=" + iTaskID);
            gridCompletetionEmails.DataBind();

            #endregion

            #region Bind Data

            this.txtTaskName.Text = this.LoanTaskInfo.Rows[0]["Name"].ToString();


            #region Owner

            string sOwnerID = this.LoanTaskInfo.Rows[0]["Owner"].ToString();
            if (sOwnerID == string.Empty)
            {
                this.ddlOwner.SelectedIndex = 0;
            }
            else
            {
                this.ddlOwner.SelectedValue = sOwnerID;
            }

            #endregion

            #region ExternalViewing

            if (this.LoanTaskInfo.Rows[0]["ExternalViewing"] != null && this.LoanTaskInfo.Rows[0]["ExternalViewing"].ToString() != "")
            {
                bool ExternalViewing = Convert.ToBoolean(this.LoanTaskInfo.Rows[0]["ExternalViewing"]);

                this.chbExternalViewing.Checked = ExternalViewing;
            }

            #endregion


            #region Due Date

            string sDueDate = this.LoanTaskInfo.Rows[0]["Due"].ToString();
            if (sDueDate != string.Empty)
            {
                this.txtDueDate.Text = Convert.ToDateTime(this.LoanTaskInfo.Rows[0]["Due"]).ToString("MM/dd/yyyy");
            }

            #endregion

            //#region Completed Date

            string sCompletedDate = this.LoanTaskInfo.Rows[0]["Completed"].ToString();
            if (sCompletedDate != string.Empty)
            {
                this.hdnCompleted.Value = Convert.ToDateTime(this.LoanTaskInfo.Rows[0]["Completed"]).ToString("MM/dd/yyyy");
            }

            //#endregion

            this.txtDaysToEst.Text         = this.LoanTaskInfo.Rows[0]["DaysDueFromEstClose"] == DBNull.Value ? string.Empty : this.LoanTaskInfo.Rows[0]["DaysDueFromEstClose"].ToString();
            this.txtDaysAfterCreation.Text = this.LoanTaskInfo.Rows[0]["DaysFromCreation"] == DBNull.Value ? string.Empty : this.LoanTaskInfo.Rows[0]["DaysFromCreation"].ToString();

            this.txtDaysDueAfterPrevStage.Text = this.LoanTaskInfo.Rows[0]["DaysDueAfterPrevStage"] == DBNull.Value ? string.Empty : this.LoanTaskInfo.Rows[0]["DaysDueAfterPrevStage"].ToString();


            //Get task template Calculation Method
            if (this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString() != "" && this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString() != "0")
            {
                LPWeb.BLL.Template_Wfl_Tasks   taskTempMgr   = new Template_Wfl_Tasks();
                LPWeb.Model.Template_Wfl_Tasks taskTempModel = taskTempMgr.GetModel(int.Parse(this.LoanTaskInfo.Rows[0]["TemplTaskId"].ToString()));
                int iCalculationMethod = 0;
                if (taskTempModel != null)
                {
                    LPWeb.BLL.Template_Wfl_Stages   stageWflMgr = new Template_Wfl_Stages();
                    LPWeb.Model.Template_Wfl_Stages stageModel  = stageWflMgr.GetModel(taskTempModel.WflStageId);
                    if (stageModel != null)
                    {
                        LPWeb.BLL.Template_Workflow   templateMgr   = new Template_Workflow();
                        LPWeb.Model.Template_Workflow templateModel = templateMgr.GetModel(stageModel.WflTemplId);
                        if (templateModel != null)
                        {
                            iCalculationMethod = templateModel.CalculationMethod;
                        }

                        if (stageModel.CalculationMethod != null && stageModel.CalculationMethod.Value != 0)
                        {
                            iCalculationMethod = stageModel.CalculationMethod.Value;
                        }
                    }
                }

                if (iCalculationMethod == 1 && this.txtDaysAfterCreation.Text == "")
                {
                    this.txtDaysToEst.Enabled         = true;
                    this.txtDaysAfterCreation.Enabled = false;
                }
                else if (iCalculationMethod == 2 && this.txtDaysToEst.Text == "")
                {
                    this.txtDaysToEst.Enabled         = false;
                    this.txtDaysAfterCreation.Enabled = true;
                }
            }
            #region Prerequisite Task Id

            string sPrerequisiteTaskId = this.LoanTaskInfo.Rows[0]["PrerequisiteTaskId"] == DBNull.Value ? string.Empty : this.LoanTaskInfo.Rows[0]["PrerequisiteTaskId"].ToString();
            if (sPrerequisiteTaskId == string.Empty)
            {
                this.ddlPrerequisite.SelectedIndex = 0;
            }
            else
            {
                this.ddlPrerequisite.SelectedValue = sPrerequisiteTaskId;
            }

            #endregion

            this.txtDaysDueAfter.Text = LoanTaskInfo.Rows[0]["DaysDueAfterPrerequisite"] == DBNull.Value ? string.Empty : this.LoanTaskInfo.Rows[0]["DaysDueAfterPrerequisite"].ToString();

            #region Completion Email

            string sCompletionEmailID = this.LoanTaskInfo.Rows[0]["CompletionEmailId"].ToString();
            if (sCompletionEmailID == string.Empty)
            {
                this.ddlCompletionEmail.SelectedIndex = 0;
            }
            else
            {
                this.ddlCompletionEmail.SelectedValue = sCompletionEmailID;
            }

            #endregion

            #region Warning Email

            string sWarningEmailId = this.LoanTaskInfo.Rows[0]["WarningEmailId"].ToString();
            if (sWarningEmailId == string.Empty)
            {
                this.ddlWarningEmail.SelectedIndex = 0;
            }
            else
            {
                this.ddlWarningEmail.SelectedValue = sWarningEmailId;
            }

            #endregion

            #region Overdue Email

            string sOverdueEmailId = this.LoanTaskInfo.Rows[0]["OverdueEmailId"].ToString();
            if (sOverdueEmailId == string.Empty)
            {
                this.ddlOverdueEmail.SelectedIndex = 0;
            }
            else
            {
                this.ddlOverdueEmail.SelectedValue = sOverdueEmailId;
            }

            #endregion

            #endregion
        }
    }