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

        bool bValid = PageCommon.ValidateQueryString(this, "EmailTemplateID", QueryStringType.ID);
        if (bValid == false)
        {
            this.Response.End();
        }
        this.iEmailTemplateID = Convert.ToInt32(this.Request.QueryString["EmailTemplateID"]);

        #endregion

        if (this.IsPostBack == false)
        {
            #region 加载Email Template List

            Template_Email Template_EmailMgr = new Template_Email();
            DataTable      EmailTemplateList = Template_EmailMgr.GetEmailTemplate(" and Enabled=1");
            this.ddlEmailTemplate.DataSource = EmailTemplateList;
            this.ddlEmailTemplate.DataBind();

            // default selected
            this.ddlEmailTemplate.SelectedValue = this.iEmailTemplateID.ToString();

            #endregion
        }
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(Request.QueryString["needret"]))
        {
            strNeedReturn = "0";
        }
        else
        {
            strNeedReturn = "1";
        }

        if (this.IsPostBack == false)
        {
            #region 加载email template
            LoanTasks      LoanTaskManager  = new LoanTasks();
            Template_Email EmailTempManager = new Template_Email();
            DataTable      EmailTemplates   = EmailTempManager.GetEmailTemplate(" and Enabled = 1");

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "-- select an email template --";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

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

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

            #endregion
        }
    }
示例#3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验页面参数

        string sCloseDialogCodes = this.GetCloseDialogJs();

        if (this.Request.QueryString["LoanID"] == null &&
            this.Request.QueryString["ProspectID"] == null &&
            this.Request.QueryString["ContactID"] == null &&
            this.Request.QueryString["ProspectAlertID"] == null)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "_InvalidQuery1", "$('#divContainer').hide();alert('Missing required query string.');" + sCloseDialogCodes, true);
            return;
        }

        if (this.Request.QueryString["LoanID"] != null)
        {
            #region LoanID

            bool bIsValid = PageCommon.ValidateQueryString(this, "LoanID", QueryStringType.ID);
            if (bIsValid == false)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "_InvalidQuery2", "$('#divContainer').hide();alert('Missing required query string.');" + sCloseDialogCodes, true);
                return;
            }
            this.iLoanID = Convert.ToInt32(this.Request.QueryString["LoanID"]);

            #endregion
        }
        else if (this.Request.QueryString["ProspectID"] != null)
        {
            #region ProspectID

            bool bIsValid = PageCommon.ValidateQueryString(this, "ProspectID", QueryStringType.ID);
            if (bIsValid == false)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "_InvalidQuery2", "$('#divContainer').hide();alert('Missing required query string.');" + sCloseDialogCodes, true);
                return;
            }
            this.iProspectID = Convert.ToInt32(this.Request.QueryString["ProspectID"]);

            #endregion
        }
        else if (this.Request.QueryString["ContactID"] != null)
        {
            #region ContactID

            bool bIsValid = PageCommon.ValidateQueryString(this, "ContactID", QueryStringType.ID);
            if (bIsValid == false)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "_InvalidQuery2", "$('#divContainer').hide();alert('Missing required query string.');" + sCloseDialogCodes, true);
                return;
            }
            this.iContactID = Convert.ToInt32(this.Request.QueryString["ContactID"]);

            #endregion
        }
        else if (this.Request.QueryString["ProspectAlertID"] != null)
        {
            #region ProspectAlertID

            bool bIsValid = PageCommon.ValidateQueryString(this, "ProspectAlertID", QueryStringType.ID);
            if (bIsValid == false)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "_InvalidQuery2", "$('#divContainer').hide();alert('Missing required query string.');" + sCloseDialogCodes, true);
                return;
            }
            this.iProspectAlertID = Convert.ToInt32(this.Request.QueryString["ProspectAlertID"]);

            #endregion

            #region 获取ProspectID

            ProspectAlerts ProspectAlertManager = new ProspectAlerts();
            DataTable      ProspectAlertInfo    = ProspectAlertManager.GetProspectAlertInfo(this.iProspectAlertID);
            if (ProspectAlertInfo.Rows.Count == 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "_InvalidQuery3", "$('#divContainer').hide();alert('Invalid prospect alert id.');" + sCloseDialogCodes, true);
                return;
            }

            #endregion
        }

        #endregion

        #region EWS

        Company_Web             CompanyWebManager = new Company_Web();
        LPWeb.Model.Company_Web Company_Web_Model = CompanyWebManager.GetModel();

        Users             UserManager = new Users();
        LPWeb.Model.Users UserModel   = UserManager.GetModel(this.CurrUser.iUserID);

        if (Company_Web_Model.SendEmailViaEWS && UserModel.Password == string.Empty)
        {
            this.hdnUseEWS.Value = "True";
        }
        else
        {
            this.hdnUseEWS.Value = "False";
        }

        #endregion

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

            Template_Email EmailTempManager = new Template_Email();
            DataTable      EmailTemplates   = EmailTempManager.GetEmailTemplate(" and Enabled = 1 "); //gdc 20130528 取消 order by [Name] asc 有人在方法里加入了排序

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

            #endregion

            #region 加载To(Dropdown List)

            if (this.Request.QueryString["LoanID"] != null)
            {
                #region LoanID

                string sSql = "select 'User'+convert(varchar, a.UserId) as UserID, c.Name +' - '+ b.LastName +', '+b.FirstName as RoleAndFullName from LoanTeam as a "
                              + "inner join Users as b on a.UserId = b.UserId "
                              + "inner join Roles as c on a.RoleId = c.RoleId "
                              + "where FileId=" + this.iLoanID + " "
                              + "union "
                              + "select 'Contact'+convert(varchar, a.ContactId) as UserID, c.Name +' - '+ b.LastName +', '+ b.FirstName + case when ISNULL(b.MiddleName, '') != '' then ' '+ b.MiddleName else '' end as RoleAndFullName from LoanContacts as a "
                              + "inner join Contacts as b on a.ContactId = b.ContactId "
                              + "inner join ContactRoles as c on a.ContactRoleId = c.ContactRoleId "
                              + "where FileId=" + this.iLoanID + " "
                              + "union "
                              + "select 'User'+convert(varchar, BranchMgrId) as UserID, 'Branch Manager - ' + b.LastName +', '+b.FirstName as RoleAndFullName from BranchManagers as a "
                              + "inner join Users as b on a.BranchMgrId = b.UserId "
                              + "where BranchId = ( "
                              + "select b.BranchId from PointFiles as a "
                              + "inner join PointFolders as b on a.FolderId = b.FolderId "
                              + "where FileId=" + this.iLoanID + ")";

                SqlCommand SqlCmd     = new SqlCommand(sSql);
                DataTable  ToListData = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(SqlCmd);

                this.ddlToList.DataSource = ToListData;
                this.ddlToList.DataBind();

                string sSql2 = "select 'User'+convert(varchar, a.UserId) as UserID, b.LastName +', '+b.FirstName as FullName from LoanTeam as a "
                               + "inner join Users as b on a.UserId = b.UserId "
                               + "inner join Roles as c on a.RoleId = c.RoleId "
                               + "where FileId=" + this.iLoanID + " "
                               + "union "
                               + "select 'Contact'+convert(varchar, a.ContactId) as UserID, b.LastName +', '+ b.FirstName + case when ISNULL(b.MiddleName, '') != '' then ' '+ b.MiddleName else '' end as FullName from LoanContacts as a "
                               + "inner join Contacts as b on a.ContactId = b.ContactId "
                               + "inner join ContactRoles as c on a.ContactRoleId = c.ContactRoleId "
                               + "where FileId=" + this.iLoanID + " "
                               + "union "
                               + "select 'User'+convert(varchar, BranchMgrId) as UserID, b.LastName +', '+b.FirstName as FullName from BranchManagers as a "
                               + "inner join Users as b on a.BranchMgrId = b.UserId "
                               + "where BranchId = ( "
                               + "select b.BranchId from PointFiles as a "
                               + "inner join PointFolders as b on a.FolderId = b.FolderId "
                               + "where FileId=" + this.iLoanID + ")";

                SqlCommand SqlCmd2 = new SqlCommand(sSql2);
                DataTable  ToList_FullName_Data = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(SqlCmd2);

                this.ddlToList_FullName.DataSource = ToList_FullName_Data;
                this.ddlToList_FullName.DataBind();

                string sSql3 = "select 'User'+convert(varchar, a.UserId) as UserID, isnull(b.EmailAddress,'') as Email from LoanTeam as a "
                               + "inner join Users as b on a.UserId = b.UserId "
                               + "inner join Roles as c on a.RoleId = c.RoleId "
                               + "where FileId=" + this.iLoanID + " "
                               + "union "
                               + "select 'Contact'+convert(varchar, a.ContactId) as UserID, isnull(b.Email,'') as Email from LoanContacts as a "
                               + "inner join Contacts as b on a.ContactId = b.ContactId "
                               + "inner join ContactRoles as c on a.ContactRoleId = c.ContactRoleId "
                               + "where FileId=" + this.iLoanID + " "
                               + "union "
                               + "select 'User'+convert(varchar, BranchMgrId) as UserID, isnull(b.EmailAddress,'') as Email from BranchManagers as a "
                               + "inner join Users as b on a.BranchMgrId = b.UserId "
                               + "where BranchId = ( "
                               + "select b.BranchId from PointFiles as a "
                               + "inner join PointFolders as b on a.FolderId = b.FolderId "
                               + "where FileId=" + this.iLoanID + ")";

                SqlCommand SqlCmd3           = new SqlCommand(sSql3);
                DataTable  ToList_Email_Data = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(SqlCmd3);

                this.ddlToList_Email.DataSource = ToList_Email_Data;
                this.ddlToList_Email.DataBind();

                #endregion
            }
            else if (this.Request.QueryString["ContactID"] != null)
            {
                #region ContactID

                string sSql = "select 'Contact'+convert(varchar, a.ContactId) as UserID, a.LastName +', '+ a.FirstName + case when ISNULL(a.MiddleName, '') != '' then ' '+ a.MiddleName else '' end as RoleAndFullName from Contacts as a "
                              + "where ContactId=" + this.iContactID;


                SqlCommand SqlCmd     = new SqlCommand(sSql);
                DataTable  ToListData = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(SqlCmd);

                this.ddlToList.DataSource = ToListData;
                this.ddlToList.DataBind();

                string sSql2 = "select 'Contact'+convert(varchar, a.ContactId) as UserID, a.LastName +', '+ a.FirstName + case when ISNULL(a.MiddleName, '') != '' then ' '+ a.MiddleName else '' end as FullName from Contacts as a "
                               + "where ContactId=" + this.iContactID;

                SqlCommand SqlCmd2 = new SqlCommand(sSql2);
                DataTable  ToList_FullName_Data = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(SqlCmd2);

                this.ddlToList_FullName.DataSource = ToList_FullName_Data;
                this.ddlToList_FullName.DataBind();

                string sSql3 = "select 'Contact'+convert(varchar, a.ContactId) as UserID, isnull(a.Email,'') as Email from Contacts as a "
                               + "where ContactId=" + this.iContactID;

                SqlCommand SqlCmd3           = new SqlCommand(sSql3);
                DataTable  ToList_Email_Data = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(SqlCmd3);

                this.ddlToList_Email.DataSource = ToList_Email_Data;
                this.ddlToList_Email.DataBind();

                #endregion
            }
            else
            {
                #region ProspectID or ProspectAlertID

                string sSql = "select 'User'+convert(varchar, a.Loanofficer) as UserID, c.Name +' - '+ b.LastName +', '+b.FirstName as RoleAndFullName "
                              + "from Prospect as a inner join Users as b on a.Loanofficer = b.UserId "
                              + "inner join Roles as c on b.RoleId = c.RoleId "
                              + "where a.Contactid=" + this.iProspectID + " "
                              + "union "
                              + "select 'Contact'+convert(varchar, a.ContactId) as UserID, d.Name +' - '+ b.LastName +', '+ b.FirstName + case when ISNULL(b.MiddleName, '') != '' then ' '+ b.MiddleName else '' end as RoleAndFullName "
                              + "from Prospect as a inner join Contacts as b on a.Contactid = b.ContactId "
                              + "inner join LoanContacts as c on a.Contactid = c.ContactId "
                              + "inner join ContactRoles as d on c.ContactRoleId = d.ContactRoleId "
                              + "where a.Contactid=" + this.iProspectID + " "
                              + "union "
                              + "select 'User'+convert(varchar, a.UserId) as UserID, d.Name +' - '+ a.LastName +', '+a.FirstName as RoleAndFullName "
                              + "from Users as a "
                              + "inner join GroupUsers as b on a.UserId = b.UserID "
                              + "inner join Groups as c on b.GroupID = c.GroupId "
                              + "inner join Roles as d on a.RoleId = d.RoleId "
                              + "where c.Enabled = 1 and a.UserEnabled=1 "
                              + "and c.BranchId in (select * from lpfn_GetUserBranches_UserList((select Loanofficer from Prospect where Contactid=" + this.iProspectID + ")))";

                SqlCommand SqlCmd     = new SqlCommand(sSql);
                DataTable  ToListData = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(SqlCmd);

                this.ddlToList.DataSource = ToListData;
                this.ddlToList.DataBind();

                string sSql2 = "select 'User'+convert(varchar, a.Loanofficer) as UserID, b.LastName +', '+b.FirstName as FullName "
                               + "from Prospect as a inner join Users as b on a.Loanofficer = b.UserId "
                               + "where a.Contactid=" + this.iProspectID + " "
                               + "union "
                               + "select 'Contact'+convert(varchar, a.ContactId) as UserID, b.LastName +', '+ b.FirstName + case when ISNULL(b.MiddleName, '') != '' then ' '+ b.MiddleName else '' end as FullName "
                               + "from Prospect as a inner join Contacts as b on a.Contactid = b.ContactId "
                               + "where a.Contactid=" + this.iProspectID + " "
                               + "union "
                               + "select 'User'+convert(varchar, a.UserId) as UserID, a.LastName +', '+a.FirstName as FullName "
                               + "from Users as a "
                               + "inner join GroupUsers as b on a.UserId = b.UserID "
                               + "inner join Groups as c on b.GroupID = c.GroupId "
                               + "where c.Enabled = 1 and a.UserEnabled=1 "
                               + "and c.BranchId in (select * from lpfn_GetUserBranches_UserList((select Loanofficer from Prospect where Contactid=" + this.iProspectID + ")))";

                SqlCommand SqlCmd2 = new SqlCommand(sSql2);
                DataTable  ToList_FullName_Data = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(SqlCmd2);

                this.ddlToList_FullName.DataSource = ToList_FullName_Data;
                this.ddlToList_FullName.DataBind();

                string sSql3 = "select 'User'+convert(varchar, a.Loanofficer) as UserID, isnull(b.EmailAddress,'') as Email "
                               + "from Prospect as a inner join Users as b on a.Loanofficer = b.UserId "
                               + "where a.Contactid=" + this.iProspectID + " "
                               + "union "
                               + "select 'Contact'+convert(varchar, a.ContactId) as UserID, isnull(b.Email,'') as Email "
                               + "from Prospect as a inner join Contacts as b on a.Contactid = b.ContactId "
                               + "where a.Contactid=" + this.iProspectID + " "
                               + "union "
                               + "select 'User'+convert(varchar, a.UserId) as UserID, isnull(a.EmailAddress,'') as Email "
                               + "from Users as a "
                               + "inner join GroupUsers as b on a.UserId = b.UserID "
                               + "inner join Groups as c on b.GroupID = c.GroupId "
                               + "where c.Enabled = 1 and a.UserEnabled=1 "
                               + "and c.BranchId in (select * from lpfn_GetUserBranches_UserList((select Loanofficer from Prospect where Contactid=" + this.iProspectID + ")))";

                SqlCommand SqlCmd3           = new SqlCommand(sSql3);
                DataTable  ToList_Email_Data = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(SqlCmd3);

                this.ddlToList_Email.DataSource = ToList_Email_Data;
                this.ddlToList_Email.DataBind();

                #endregion
            }

            #endregion
        }
    }
示例#4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 检查必要参数

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

        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

        #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 加载LoanInfo信息

        DataTable LoanInfo = this.LoanManager.GetLoanInfo(this.iLoanID);
        if (LoanInfo.Rows.Count == 0)
        {
            PageCommon.RegisterJsMsg(this, "Invalid required query string.", sErrorJs);
            return;
        }

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

        #endregion



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

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

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

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

            // 绑定Owner
            this.ddlOwner.SelectedValue = this.CurrUser.iUserID.ToString();

            #endregion

            #region 加载ddlTaskList for TaskNaem

            LeadTaskList LeadTaskListMgr = new LeadTaskList();

            string sOrderBy = string.Empty;
            if (this.CurrUser.SortTaskPickList == "S")
            {
                sOrderBy = "SequenceNumber";
            }
            else
            {
                sOrderBy = "TaskName";
            }

            DataTable LeadTaskList1 = LeadTaskListMgr.GetLeadTaskList(" and Enabled=1", sOrderBy);

            DataRow EmptyTaskRow = LeadTaskList1.NewRow();
            EmptyTaskRow["TaskName"] = "-- select --";
            LeadTaskList1.Rows.InsertAt(EmptyTaskRow, 0);

            this.ddlTaskList.DataSource = LeadTaskList1;
            this.ddlTaskList.DataBind();

            #endregion

            #region 加载Prerequisite

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

            DataTable PrerequisiteList    = this.LoanTaskManager.GetPrerequisiteList(" and FileID=" + this.iLoanID + " and LoanStageId = " + iCurrentLoanStageId + " and PrerequisiteTaskId is null");
            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();
            this.EmailTemplates = EmailTempManager.GetEmailTemplate(" and Enabled = 1");

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

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

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

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

            #endregion

            #region completion email list

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

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

            #endregion

            #region Stage

            //Template_Stages stage = new Template_Stages();
            //var dtStage = stage.GetStageTemplateList(" And [Enabled] = 1 order by  SequenceNumber ");

            LoanStages ls      = new LoanStages();
            var        dtStage = ls.GetLoanStageSetupInfo(iLoanID);

            ddlStage.DataSource = dtStage;
            ddlStage.DataBind();


            #endregion

            #region Bind Data

            ddlStage.SelectedValue = this.LoanTaskInfo.Rows[0]["LoanStageId"].ToString();

            this.radTaskName.Checked = true;
            this.txtTaskName.Text    = this.LoanTaskInfo.Rows[0]["Name"].ToString();
            this.txtDescription.Text = this.LoanTaskInfo.Rows[0]["Desc"].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 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");
            }

            string sDueTime = this.LoanTaskInfo.Rows[0]["DueTime"].ToString();
            if (sDueTime != string.Empty)
            {
                TimeSpan DueTime = TimeSpan.Parse(this.LoanTaskInfo.Rows[0]["DueTime"].ToString());
                this.txtDueTime.Text = DueTime.ToString().Substring(0, 5);

                ddlDueTime_hour.SelectedValue = DueTime.Hours.ToString();
                ddlDueTime_min.SelectedValue  = ((DueTime.Minutes / 5) * 5).ToString();
            }

            #endregion

            //#region Completed Date

            string sCompletedDate = this.LoanTaskInfo.Rows[0]["Completed"].ToString();
            if (sCompletedDate != string.Empty)
            {
                this.chkCompleted.Checked  = true;
                this.txtCompletedDate.Text = Convert.ToDateTime(this.LoanTaskInfo.Rows[0]["Completed"]).ToString("MM/dd/yyyy");
                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();

            #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 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
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验页面参数

        string sJsCloseDialog = "$('#divContainer').hide();window.parent.CloseGlobalDialog();";

        bool bIsValid = PageCommon.ValidateQueryString(this, "TemplateID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "alert('Missing required query string.');" + sJsCloseDialog, true);
            return;
        }
        this.iTemplateID = Convert.ToInt32(this.Request.QueryString["TemplateID"]);


        if (this.Request.QueryString["StageID"] != null)
        {
            bIsValid = PageCommon.ValidateQueryString(this, "StageID", QueryStringType.ID);
            if (bIsValid == false)
            {
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "alert('Missing required query string.');" + sJsCloseDialog, true);
                return;
            }
            this.iStageID = Convert.ToInt32(this.Request.QueryString["StageID"]);
        }

        #endregion

        #region 获取Workflow Template Name

        string    sSql = "select * from dbo.Template_Workflow where WflTemplId=" + this.iTemplateID;
        DataTable WorkflowTemplateInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql);
        if (WorkflowTemplateInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_m1", "alert('Invalid workflow template id.');" + sJsCloseDialog, true);
            return;
        }
        string sWorkflowTemplateName = WorkflowTemplateInfo.Rows[0]["Name"].ToString();
        this.tbxTemplateName.Text = sWorkflowTemplateName;

        #endregion

        if (this.IsPostBack == false)
        {
            #region 获取Workflow Stage List

            string    sSql2     = "select * from Template_Wfl_Stages where WflTemplId=" + this.iTemplateID;
            DataTable StageList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql2);

            DataRow NoneStageRow = StageList.NewRow();
            NoneStageRow["WflStageId"] = 0;
            NoneStageRow["Name"]       = "-- select an stage --";
            StageList.Rows.InsertAt(NoneStageRow, 0);

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

            this.ddlStage.SelectedValue = this.iStageID.ToString();

            #endregion

            #region 获取Default Owner

            string    sSql3    = "select * from Roles where Name<>'Executive' AND Name <>'Branch Manager'";
            DataTable RoleList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql3);

            DataView RoleView = new DataView(RoleList);
            RoleView.Sort            = "Name";
            this.ddlOwner.DataSource = RoleView;
            this.ddlOwner.DataBind();

            #endregion

            #region 获取Prerequisite

            string    sSql4       = "select * from Template_Wfl_Tasks where (PrerequisiteTaskId IS NULL OR PrerequisiteTaskId=0) AND WflStageId=" + this.iStageID;
            DataTable WflTaskList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql4);

            DataRow NoneWflTaskRow = WflTaskList.NewRow();
            NoneWflTaskRow["TemplTaskId"] = 0;
            NoneWflTaskRow["Name"]        = "";
            WflTaskList.Rows.InsertAt(NoneWflTaskRow, 0);

            this.ddlPrerequisiteTask.DataSource = WflTaskList;
            this.ddlPrerequisiteTask.DataBind();

            #endregion

            #region 加载email template

            LoanTasks      LoanTaskManager     = new LoanTasks();
            Template_Email EmailTempManager    = new Template_Email();
            DataTable      EmailTemplates      = EmailTempManager.GetEmailTemplate(" and Enabled = 1");
            DataTable      CmpltEmailTemplates = EmailTemplates.Copy();

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "-- select an Email Template --";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

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

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

            this.CmpltEmailTmpltText.DataSource = new DataView(CmpltEmailTemplates, "", "Name", DataViewRowState.CurrentRows);
            this.CmpltEmailTmpltText.DataBind();

            #endregion
        }
    }
示例#6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 检查必要参数

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

        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"]);

        #endregion

        #region 校验LoanId

        DataTable LoanInfo = this.LoanManager.GetLoanInfo(this.iLoanID);
        if (LoanInfo.Rows.Count == 0)
        {
            PageCommon.RegisterJsMsg(this, "Invalid required query string.", sErrorJs);
            return;
        }

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

        this.iCurrentLoanStageId = WorkflowManager.GetCurrentLoanStageId(this.iLoanID);

        bIsValid = PageCommon.ValidateQueryString(this, "Stage", QueryStringType.ID);
        if (bIsValid == true)
        {
            int    iout   = 0;
            string sStage = this.Request.QueryString["Stage"];
            if (Int32.TryParse(sStage, out iout))
            {
                this.iCurrentLoanStageId = iout;
            }
        }

        #endregion

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

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

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

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

            // 绑定Owner
            this.ddlOwner.SelectedValue = this.CurrUser.iUserID.ToString();

            #endregion

            #region 加载ddlTaskList for TaskNaem

            LeadTaskList LeadTaskListMgr = new LeadTaskList();

            string sOrderBy = string.Empty;
            if (this.CurrUser.SortTaskPickList == "S")
            {
                sOrderBy = "SequenceNumber";
            }
            else
            {
                sOrderBy = "TaskName";
            }

            DataTable LeadTaskList1 = LeadTaskListMgr.GetLeadTaskList(" and Enabled=1", sOrderBy);

            DataRow EmptyTaskRow = LeadTaskList1.NewRow();
            EmptyTaskRow["TaskName"] = "-- select --";
            LeadTaskList1.Rows.InsertAt(EmptyTaskRow, 0);

            this.ddlTaskList.DataSource = LeadTaskList1;
            this.ddlTaskList.DataBind();

            #endregion

            // set default value
            this.txtDueDate.Text = DateTime.Now.ToString("MM/dd/yyyy");
            //this.txtDueTime.Text = DateTime.Now.AddMinutes(15).ToShortTimeString();
            this.ddlDueTime_hour.SelectedValue = DateTime.Now.Hour.ToString("00");
            this.ddlDueTime_min.SelectedValue  = (DateTime.Now.AddMinutes(15).Minute / 5 * 5).ToString();

            #region 加载Prerequisite

            DataTable PrerequisiteList    = this.LoanTaskManager.GetPrerequisiteList(" and FileID=" + this.iLoanID + " and LoanStageId = " + iCurrentLoanStageId + " and PrerequisiteTaskId is null");
            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();
            DataTable      EmailTemplates   = EmailTempManager.GetEmailTemplate(" and Enabled = 1");

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

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

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

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

            #endregion

            #region completion email list

            gridCompletetionEmails.DataSource = null;
            gridCompletetionEmails.DataBind();

            #endregion


            #region Stage

            //Template_Stages stage = new Template_Stages();
            //var dtStage = stage.GetStageTemplateList(" And [Enabled] = 1 order by  SequenceNumber ");

            LoanStages ls      = new LoanStages();
            var        dtStage = ls.GetLoanStageSetupInfo(iLoanID);

            ddlStage.DataSource = dtStage;
            ddlStage.DataBind();

            ddlStage.SelectedValue = this.iCurrentLoanStageId.ToString();
            #endregion
        }
    }
示例#7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验页面参数

        string sJsCloseDialog = "$('#divContainer').hide();window.parent.CloseGlobalDialog();";

        bool bIsValid = PageCommon.ValidateQueryString(this, "TemplateID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "alert('Missing required query string.');" + sJsCloseDialog, true);
            return;
        }
        this.iTemplateID = Convert.ToInt32(this.Request.QueryString["TemplateID"]);


        if (this.Request.QueryString["StageID"] != null)
        {
            bIsValid = PageCommon.ValidateQueryString(this, "StageID", QueryStringType.ID);
            if (bIsValid == false)
            {
                this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "alert('Missing required query string.');" + sJsCloseDialog, true);
                return;
            }
            this.iStageID = Convert.ToInt32(this.Request.QueryString["StageID"]);
        }

        bIsValid = PageCommon.ValidateQueryString(this, "TaskID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "alert('Missing required query string.');" + sJsCloseDialog, true);
            return;
        }
        this.iTaskID = Convert.ToInt32(this.Request.QueryString["TaskID"]);

        #endregion

        #region 获取Workflow Template Name

        string    sSql = "select * from dbo.Template_Workflow where WflTemplId=" + this.iTemplateID;
        DataTable WorkflowTemplateInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql);
        if (WorkflowTemplateInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_m1", "alert('Invalid workflow template id.');" + sJsCloseDialog, true);
            return;
        }
        string sWorkflowTemplateName = WorkflowTemplateInfo.Rows[0]["Name"].ToString();
        this.tbxTemplateName.Text = sWorkflowTemplateName;

        #endregion

        #region 加载Workflow Task信息

        string    sSql4    = "select * from Template_Wfl_Tasks where TemplTaskId=" + this.iTaskID;
        DataTable TaskInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql4);
        if (TaskInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_m2", "alert('Invalid workflow task id.');" + sJsCloseDialog, true);
            return;
        }

        #endregion

        //Check Referenced
        LoanTasks loanTaskMgr = new LoanTasks();
        if (loanTaskMgr.GetLoanTaskList(" AND a.TemplTaskId=" + this.iTaskID.ToString()).Rows.Count > 0)
        {
            this.hdnIsReferenced.Value = "true";
        }

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

        if (this.IsPostBack == false)
        {
            #region 获取Workflow Stage List

            string    sSql2     = "select * from Template_Wfl_Stages where WflTemplId=" + this.iTemplateID;
            DataTable StageList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql2);

            DataRow NoneStageRow = StageList.NewRow();
            NoneStageRow["WflStageId"] = 0;
            NoneStageRow["Name"]       = "-- select an stage --";
            StageList.Rows.InsertAt(NoneStageRow, 0);

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

            this.ddlStage.SelectedValue = this.iStageID.ToString();

            #endregion

            #region 获取Default Owner

            string    sSql3    = "select * from Roles where Name<>'Executive' AND Name <>'Branch Manager'";
            DataTable RoleList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql3);

            DataView RoleView = new DataView(RoleList);
            RoleView.Sort            = "Name";
            this.ddlOwner.DataSource = RoleView;
            this.ddlOwner.DataBind();

            #endregion

            #region 获取Prerequisite

            string    sSql6       = "select * from Template_Wfl_Tasks where (PrerequisiteTaskId IS NULL OR PrerequisiteTaskId=0) AND WflStageId=" + this.iStageID;
            DataTable WflTaskList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql6);

            DataRow NoneWflTaskRow = WflTaskList.NewRow();
            NoneWflTaskRow["TemplTaskId"] = 0;
            NoneWflTaskRow["Name"]        = "";
            WflTaskList.Rows.InsertAt(NoneWflTaskRow, 0);

            this.ddlPrerequisiteTask.DataSource = WflTaskList;
            this.ddlPrerequisiteTask.DataBind();

            #endregion

            #region 加载email template

            LoanTasks      LoanTaskManager  = new LoanTasks();
            Template_Email EmailTempManager = new Template_Email();
            DataTable      EmailTemplates   = EmailTempManager.GetEmailTemplate(" and Enabled = 1");
            this.CmpltEmailTemplates = EmailTemplates.Copy();

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "-- select an Email Template --";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

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

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

            this.CmpltEmailTmpltText.DataSource = new DataView(this.CmpltEmailTemplates, "", "Name", DataViewRowState.CurrentRows);
            this.CmpltEmailTmpltText.DataBind();

            #endregion

            #region 绑定数据

            this.tbxTaskName.Text           = TaskInfo.Rows[0]["Name"].ToString();
            this.chkEnable.Checked          = Convert.ToBoolean(TaskInfo.Rows[0]["Enabled"]);
            this.chkExternalViewing.Checked = TaskInfo.Rows[0]["ExternalViewing"] == DBNull.Value ? false : Convert.ToBoolean(TaskInfo.Rows[0]["ExternalViewing"]);

            this.txtSequence.Text    = TaskInfo.Rows[0]["SequenceNumber"].ToString();
            this.tbxDescription.Text = TaskInfo.Rows[0]["Description"].ToString();


            this.ddlOwner.SelectedValue           = TaskInfo.Rows[0]["OwnerRoleId"].ToString();
            this.tbxDueDaysByDate.Text            = TaskInfo.Rows[0]["DaysDueFromCoe"].ToString();
            this.tbxDaysDueAfterCreationDate.Text = TaskInfo.Rows[0]["DaysFromCreation"].ToString();


            this.txtDaysDueAfterPrevStage.Text = TaskInfo.Rows[0]["DaysDueAfterPrevStage"].ToString();

            this.ddlPrerequisiteTask.SelectedValue = TaskInfo.Rows[0]["PrerequisiteTaskId"].ToString() == string.Empty ? "0" : TaskInfo.Rows[0]["PrerequisiteTaskId"].ToString();

            this.tbxDueDaysByTask.Text = TaskInfo.Rows[0]["DaysDueAfterPrerequisite"].ToString();

            this.ddlWarningEmail.SelectedValue = TaskInfo.Rows[0]["WarningEmailId"].ToString() == string.Empty ? "0" : TaskInfo.Rows[0]["WarningEmailId"].ToString();
            this.ddlOverdueEmail.SelectedValue = TaskInfo.Rows[0]["OverdueEmailId"].ToString() == string.Empty ? "0" : TaskInfo.Rows[0]["OverdueEmailId"].ToString();

            #endregion

            #region 加载Completion Email List

            string    sSql5 = "select ROW_NUMBER() OVER (ORDER BY CompletionEmailId) AS RowIndex, * from Template_Wfl_CompletionEmails as a inner join Template_Email as b on a.TemplEmailId=b.TemplEmailId where TemplTaskid=" + this.iTaskID;
            DataTable CompletionEmailList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql5);

            this.gridCompletionEmailList.DataSource = CompletionEmailList;
            this.gridCompletionEmailList.DataBind();

            #endregion

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

        bool bIsValid = PageCommon.ValidateQueryString(this, "RuleID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "$('#divContainer').hide();alert('Missing required query string.');window.parent.CloseDialog_EditRule();", true);
            return;
        }

        this.iRuleID = Convert.ToInt32(this.Request.QueryString["RuleID"]);

        #endregion

        #region 加载Rule信息
        Template_Rules RuleManager = new Template_Rules();
        DataTable      RuleInfo    = RuleManager.GetRuleInfo(this.iRuleID);
        if (RuleInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Invalid", "$('#divContainer').hide();alert('Invalid required query string.');window.parent.CloseDialog_EditRule();", true);
            return;
        }

        #endregion

        if (this.IsPostBack == false)
        {
            #region 加载email template
            LoanTasks      LoanTaskManager  = new LoanTasks();
            Template_Email EmailTempManager = new Template_Email();
            DataTable      EmailTemplates   = EmailTempManager.GetEmailTemplate(" and Enabled = 1");

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "-- select an email template --";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

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

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

            #endregion

            #region 加载Conditions

            DataTable ConditionListData = RuleManager.GetConditionList(this.iRuleID);

            this.hdnTolerances.Text = "";
            string Tol = "";
            foreach (DataRow dr in ConditionListData.Rows)
            {
                if ((dr["Tolerance"] != DBNull.Value) &&
                    (dr["Tolerance"] != string.Empty))
                {
                    Tol = (string)dr["Tolerance"];
                }
                else
                {
                    Tol = "";
                }

                if (this.hdnTolerances.Text == "")
                {
                    this.hdnTolerances.Text = "[$" + Tol + "$]";
                }
                else
                {
                    this.hdnTolerances.Text += ",[$" + Tol + "$]";
                }
            }

            this.gridConditionList.DataSource = ConditionListData;
            this.gridConditionList.DataBind();

            #endregion

            #region 绑定数据

            this.txtRuleName.Text   = "Copy of " + RuleInfo.Rows[0]["Name"].ToString();
            this.txtDesc.Text       = RuleInfo.Rows[0]["Desc"].ToString();
            this.chkEnabled.Checked = Convert.ToBoolean(RuleInfo.Rows[0]["Enabled"]);
            this.ddlRecomActionTemplate.SelectedValue = RuleInfo.Rows[0]["RecomEmailTemplid"].ToString();
            this.ddlAlertEmailTemplate.SelectedValue  = RuleInfo.Rows[0]["AlertEmailTemplId"].ToString();
            this.chkReqAck.Checked      = Convert.ToBoolean(RuleInfo.Rows[0]["AckReq"]);
            this.txtFormula.Text        = RuleInfo.Rows[0]["AdvFormula"].ToString();
            this.ddlScope.SelectedValue = RuleInfo.Rows[0]["RuleScope"].ToString();

            #region get loan target

            //this.ddlTarget.SelectedValue = RuleInfo.Rows[0]["LoanTarget"].ToString();

            LPWeb.Model.Template_Rules_LoanTarget modelLoanTarget;
            if (!RuleInfo.Rows[0].IsNull("LoanTarget"))
            {
                modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget(Convert.ToInt16(RuleInfo.Rows[0]["LoanTarget"]));
            }
            else
            {
                modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget();
            }

            this.chkTargetActiveLoans.Checked   = modelLoanTarget.ActiveLoans;
            this.chkTargetActiveLeads.Checked   = modelLoanTarget.ActiveLeads;
            this.chkTargetArchivedLoans.Checked = modelLoanTarget.ArchivedLoans;
            this.chkTargetArchivedLeads.Checked = modelLoanTarget.ArchivedLeads;

            #endregion

            #endregion

            // set counter
            this.hdnCounter.Value = ConditionListData.Rows.Count.ToString();
        }
    }
示例#9
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
        }
    }
示例#10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验页面参数

        string sCloseDialogCodes = this.GetCloseDialogJs();

        if (this.Request.QueryString["ContactID"] == null)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "_InvalidQuery1", "$('#divContainer').hide();alert('Missing required query string.');" + sCloseDialogCodes, true);
            return;
        }

        if (this.Request.QueryString["ContactID"] != null)
        {
            #region ContactID

            bool bIsValid = PageCommon.ValidateQueryString(this, "ContactID", QueryStringType.ID);
            if (bIsValid == false)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "_InvalidQuery2", "$('#divContainer').hide();alert('Missing required query string.');" + sCloseDialogCodes, true);
                return;
            }
            this.iContactID = Convert.ToInt32(this.Request.QueryString["ContactID"]);

            #endregion
        }


        #endregion

        #region EWS

        Company_Web             CompanyWebManager = new Company_Web();
        LPWeb.Model.Company_Web Company_Web_Model = CompanyWebManager.GetModel();

        Users             UserManager = new Users();
        LPWeb.Model.Users UserModel   = UserManager.GetModel(this.CurrUser.iUserID);

        if (Company_Web_Model.SendEmailViaEWS && UserModel.Password == string.Empty)
        {
            this.hdnUseEWS.Value = "True";
        }
        else
        {
            this.hdnUseEWS.Value = "False";
        }

        #endregion

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

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

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

            #endregion

            #region 加载To(Dropdown List)

            if (this.Request.QueryString["ContactID"] != null)
            {
                #region ContactID

                string sSql = "select 'Contact'+convert(varchar, ContactId) as UserID, LastName +', '+ FirstName + case when ISNULL(MiddleName, '') != '' then ' '+ MiddleName else '' end as RoleAndFullName from Contacts "
                              + "where ContactId=" + this.iContactID;
                if (CurrUser.bIsCompanyUser)
                {
                    // All Contact
                    sSql += "union select 'Contact'+convert(varchar, a.ContactId) as UserID, a.LastName +', '+ a.FirstName + case when ISNULL(a.MiddleName, '') != '' then ' '+ a.MiddleName else '' end as RoleAndFullName from Contacts as a "
                            + "where a.ContactId<>" + this.iContactID;
                }
                else if (CurrUser.bIsRegionUser)
                {
                    sSql += "union select 'Contact'+convert(varchar, a.ContactId) as UserID, a.LastName +', '+ a.FirstName + case when ISNULL(a.MiddleName, '') != '' then ' '+ a.MiddleName else '' end as RoleAndFullName from Contacts as a "
                            + "where a.ContactBranchId in (SELECT BranchId FROM Branches WHERE RegionID IN (Select RegionID from Regions where GroupID in (select GroupID from GroupUsers  where UserID=" + CurrUser.iUserID + "))) and a.[Enabled]=1 and a.ContactId<>" + this.iContactID;
                }
                else if (CurrUser.bIsDivisionUser)
                {
                    sSql += "union select 'Contact'+convert(varchar, a.ContactId) as UserID, a.LastName +', '+ a.FirstName + case when ISNULL(a.MiddleName, '') != '' then ' '+ a.MiddleName else '' end as RoleAndFullName from Contacts as a "
                            + " where a.ContactBranchId in (SELECT BranchId FROM Branches WHERE DivisionID IN (Select DivisionID from Divisions where GroupID in (select GroupID from GroupUsers  where UserID=" + CurrUser.iUserID + "))) and a.[Enabled]=1 and a.ContactId<>" + this.iContactID;
                }
                else
                {
                    sSql += "union select 'Contact'+convert(varchar, a.ContactId) as UserID, a.LastName +', '+ a.FirstName + case when ISNULL(a.MiddleName, '') != '' then ' '+ a.MiddleName else '' end as RoleAndFullName from Contacts as a "
                            + "where a.ContactBranchId in (Select BranchId from Branches where GroupID in (select GroupID from GroupUsers  where UserID=" + CurrUser.iUserID + ")) and a.[Enabled]=1 and a.ContactId<>" + this.iContactID;
                }

                string     sNewSql    = "select * from (" + sSql + ") as t order by RoleAndFullName";
                SqlCommand SqlCmd     = new SqlCommand(sNewSql);
                DataTable  ToListData = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(SqlCmd);

                this.ddlToList.DataSource = ToListData;
                this.ddlToList.DataBind();
                this.ddlToList.SelectedValue = "Contact" + this.iContactID.ToString();

                string sSql2 = "select 'Contact'+convert(varchar, ContactId) as UserID, LastName +', '+ FirstName + case when ISNULL(MiddleName, '') != '' then ' '+ MiddleName else '' end as FullName from Contacts "
                               + "where ContactId=" + this.iContactID;
                if (CurrUser.bIsCompanyUser)
                {
                    // All Contact
                    sSql2 += "Union select 'Contact'+convert(varchar, a.ContactId) as UserID, a.LastName +', '+ a.FirstName + case when ISNULL(a.MiddleName, '') != '' then ' '+ a.MiddleName else '' end as FullName from Contacts as a "
                             + " where a.ContactId<>" + this.iContactID;
                }
                else if (CurrUser.bIsRegionUser)
                {
                    sSql2 += "Union select 'Contact'+convert(varchar, a.ContactId) as UserID, a.LastName +', '+ a.FirstName + case when ISNULL(a.MiddleName, '') != '' then ' '+ a.MiddleName else '' end as FullName from Contacts as a "
                             + " where a.ContactBranchId in (SELECT BranchId FROM Branches WHERE RegionID IN (Select RegionID from Regions where GroupID in (select GroupID from GroupUsers  where UserID=" + CurrUser.iUserID + "))) and a.[Enabled]=1 and a.ContactId<>" + this.iContactID;
                }
                else if (CurrUser.bIsDivisionUser)
                {
                    sSql2 += "Union select 'Contact'+convert(varchar, a.ContactId) as UserID, a.LastName +', '+ a.FirstName + case when ISNULL(a.MiddleName, '') != '' then ' '+ a.MiddleName else '' end as FullName from Contacts as a "
                             + " where a.ContactBranchId in (SELECT BranchId FROM Branches WHERE DivisionID IN (Select DivisionID from Divisions where GroupID in (select GroupID from GroupUsers  where UserID=" + CurrUser.iUserID + "))) and a.[Enabled]=1 and a.ContactId<>" + this.iContactID;
                }
                else
                {
                    sSql2 += "Union select 'Contact'+convert(varchar, a.ContactId) as UserID, a.LastName +', '+ a.FirstName + case when ISNULL(a.MiddleName, '') != '' then ' '+ a.MiddleName else '' end as FullName from Contacts as a "
                             + " where a.ContactBranchId in (Select BranchId from Branches where GroupID in (select GroupID from GroupUsers  where UserID=" + CurrUser.iUserID + ")) and a.[Enabled]=1 and a.ContactId<>" + this.iContactID;
                }

                SqlCommand SqlCmd2 = new SqlCommand(sSql2);
                DataTable  ToList_FullName_Data = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(SqlCmd2);

                this.ddlToList_FullName.DataSource = ToList_FullName_Data;
                this.ddlToList_FullName.DataBind();

                string sSql3 = "select 'Contact'+convert(varchar, ContactId) as UserID, isnull(Email,'') as Email from Contacts "
                               + "where ContactId=" + this.iContactID;

                if (CurrUser.bIsCompanyUser)
                {
                    // All Contact
                    sSql3 += "Union select 'Contact'+convert(varchar, a.ContactId) as UserID, isnull(a.Email,'') as Email from Contacts as a "
                             + " where a.ContactId<>" + this.iContactID;
                }
                else if (CurrUser.bIsRegionUser)
                {
                    sSql3 += "Union select 'Contact'+convert(varchar, a.ContactId) as UserID, isnull(a.Email,'') as Email from Contacts as a "
                             + " where a.ContactBranchId in (SELECT BranchId FROM Branches WHERE RegionID IN (Select RegionID from Regions where GroupID in (select GroupID from GroupUsers  where UserID=" + CurrUser.iUserID + "))) and a.[Enabled]=1 and a.ContactId<>" + this.iContactID;
                }
                else if (CurrUser.bIsDivisionUser)
                {
                    sSql3 += "Union select 'Contact'+convert(varchar, a.ContactId) as UserID, isnull(a.Email,'') as Email from Contacts as a "
                             + " where a.ContactBranchId in (SELECT BranchId FROM Branches WHERE DivisionID IN (Select DivisionID from Divisions where GroupID in (select GroupID from GroupUsers  where UserID=" + CurrUser.iUserID + "))) and a.[Enabled]=1 and a.ContactId<>" + this.iContactID;
                }
                else
                {
                    sSql3 += "Union select 'Contact'+convert(varchar, a.ContactId) as UserID, isnull(a.Email,'') as Email from Contacts as a "
                             + " where a.ContactBranchId in (Select BranchId from Branches where GroupID in (select GroupID from GroupUsers  where UserID=" + CurrUser.iUserID + ")) and a.[Enabled]=1 and a.ContactId<>" + this.iContactID;
                }

                SqlCommand SqlCmd3           = new SqlCommand(sSql3);
                DataTable  ToList_Email_Data = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(SqlCmd3);

                this.ddlToList_Email.DataSource = ToList_Email_Data;
                this.ddlToList_Email.DataBind();

                #endregion
            }
            #endregion
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验页面参数

        string sErrorJs = "$('#divContainer').hide();alert('Missing required query string.');window.parent.CloseDialog_SendCompletionEmail();";
        bool   bIsValid = PageCommon.ValidateQueryString(this, "LoanID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "_InvalidQuery1", sErrorJs, true);
            return;
        }
        this.iLoanID = Convert.ToInt32(this.Request.QueryString["LoanID"]);

        bIsValid = PageCommon.ValidateQueryString(this, "EmailTemplateID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "_InvalidQuery2", sErrorJs, true);
            return;
        }
        this.iEmailTemplateID = Convert.ToInt32(this.Request.QueryString["EmailTemplateID"]);
        string sTaskID = "";
        sTaskID = this.Request.QueryString["TaskID"];
        if ((sTaskID != null) && (sTaskID != ""))
        {
            this.iTaskID = Convert.ToInt32(sTaskID);
        }

        #endregion

        #region EWS

        Company_Web             CompanyWebManager = new Company_Web();
        LPWeb.Model.Company_Web Company_Web_Model = CompanyWebManager.GetModel();

        Users             UserManager = new Users();
        LPWeb.Model.Users UserModel   = UserManager.GetModel(this.CurrUser.iUserID);

        if (Company_Web_Model.SendEmailViaEWS && UserModel.Password == string.Empty)
        {
            this.hdnUseEWS.Value = "True";
        }
        else
        {
            this.hdnUseEWS.Value = "False";
        }

        #endregion

        #region 旧代码

        //#region 加载email template info

        //Template_Email EmailTempManager = new Template_Email();
        //DataTable EmailTemplateInfo = EmailTempManager.GetEmailTemplateInfo(this.iEmailTemplateID);

        //if (EmailTemplateInfo.Rows.Count == 0)
        //{
        //    this.ClientScript.RegisterStartupScript(this.GetType(), "_InvalidQuery3", "$('#divContainer').hide();alert('The email template does not exist.');window.parent.CloseDialog_SendCompletionEmail();", true);
        //    return;
        //}

        //string sEmailTemplate = EmailTemplateInfo.Rows[0]["Name"].ToString();
        //this.lbEmailTemplate.Text = sEmailTemplate;

        //string sFromUserRoleID = EmailTemplateInfo.Rows[0]["FromUserRoles"].ToString();
        //if (sFromUserRoleID != string.Empty)
        //{
        //    #region 获取Loan Team和Users信息

        //    string sSql = "select * from LoanTeam as a inner join Users as b on a.UserId = b.UserId where a.FileId=" + this.iLoanID + " and a.RoleId=" + sFromUserRoleID;
        //    DataTable SenderInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql);

        //    if (SenderInfo.Rows.Count == 0)
        //    {
        //        this.lbSender.Text = "There is no sender, so can't send email.";
        //        this.lbSender.ForeColor = System.Drawing.Color.Red;
        //    }
        //    else
        //    {
        //        string sFirstName = SenderInfo.Rows[0]["FirstName"].ToString();
        //        string sLastName = SenderInfo.Rows[0]["LastName"].ToString();
        //        string sFullName = sLastName + ", " + sFirstName;
        //        this.lbSender.Text = sFullName;
        //    }

        //    #endregion
        //}
        //else
        //{
        //    string sFromEmailAddress = EmailTemplateInfo.Rows[0]["FromEmailAddress"].ToString();
        //    if (sFromEmailAddress != string.Empty)
        //    {
        //        this.lbSender.Text = sFromEmailAddress;
        //    }
        //    else
        //    {
        //        this.lbSender.Text = "There is no sender.";
        //        this.lbSender.ForeColor = System.Drawing.Color.Red;
        //    }
        //}

        //#endregion

        //if (this.IsPostBack == false)
        //{
        //    #region 加载Recipient列表

        //    #region 获取Email Template的Recipient(s)

        //    Template_Email EmailTemplateManager = new Template_Email();
        //    DataTable RecipientList = EmailTemplateManager.GetRecipientList(this.iEmailTemplateID);

        //    #endregion

        //    #region 获取Loan Team

        //    string sSql = "select * from LoanTeam as a inner join Users as b on a.UserId = b.UserId where a.FileId=" + this.iLoanID;
        //    DataTable LoanTeamList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql);

        //    #endregion

        //    #region 获取Contacts

        //    string sSql2 = "select * from LoanContacts as a inner join Contacts as b on a.ContactId = b.ContactId where a.FileId=" + this.iLoanID;
        //    DataTable ContactList = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql2);

        //    #endregion

        //    DataTable RecipientListData = this.BuildRecipientDataTable();

        //    #region To

        //    DataRow[] ToRecipient = RecipientList.Select("RecipientType='To'");
        //    if (ToRecipient.Length > 0)
        //    {
        //        string sEmailList_To = ToRecipient[0]["EmailAddr"].ToString();
        //        string sContactList_To = ToRecipient[0]["ContactRoles"].ToString();
        //        string sUserRoleList_To = ToRecipient[0]["UserRoles"].ToString();
        //        string sTaskOwner = ToRecipient[0]["TaskOwner"].ToString();

        //        #region Emails

        //        if (sEmailList_To != string.Empty)
        //        {
        //            string[] EmailArray_To = sEmailList_To.Split(';');
        //            foreach (string sEmailTo in EmailArray_To)
        //            {
        //                this.AddNewRecipientRow(RecipientListData, "To", string.Empty, sEmailTo);
        //            }
        //        }

        //        #endregion

        //        #region User IDs

        //        if (sUserRoleList_To != string.Empty)
        //        {
        //            string[] UserRoleArray_To = sUserRoleList_To.Split(';');
        //            foreach (string sUserRoleIDTo in UserRoleArray_To)
        //            {
        //                int iUserRoleIDTo = Convert.ToInt32(sUserRoleIDTo);

        //                DataRow[] LoanTeamRows = LoanTeamList.Select("RoleId=" + iUserRoleIDTo);
        //                foreach (DataRow LoanTeamRow in LoanTeamRows)
        //                {
        //                    string sFullName = LoanTeamRow["LastName"].ToString() + ", " + LoanTeamRow["FirstName"].ToString();
        //                    string sEmailAddress = LoanTeamRow["EmailAddress"].ToString();
        //                    if (sEmailAddress == string.Empty)
        //                    {
        //                        this.AddNewRecipientRow(RecipientListData, "To", sFullName, "There is no emaill address in the user account.");
        //                    }
        //                    else
        //                    {
        //                        this.AddNewRecipientRow(RecipientListData, "To", sFullName, sEmailAddress);
        //                    }
        //                }
        //            }
        //        }

        //        #endregion

        //        #region Contact IDs

        //        if (sContactList_To != string.Empty)
        //        {
        //            string[] ContactArray_To = sContactList_To.Split(';');
        //            foreach (string sContactIDTo in ContactArray_To)
        //            {
        //                int iContactRoleIDTo = Convert.ToInt32(sContactIDTo);

        //                DataRow[] ContactRows = ContactList.Select("ContactRoleId=" + iContactRoleIDTo);
        //                foreach (DataRow ContactRow in ContactRows)
        //                {
        //                    #region Build FullName

        //                    string sFirstName = ContactRow["FirstName"].ToString();
        //                    string sLastName = ContactRow["LastName"].ToString();
        //                    string sMiddleName = ContactRow["MiddleName"].ToString();

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

        //                    #endregion

        //                    string sEmailAddress = ContactRow["Email"].ToString();

        //                    if (sEmailAddress == string.Empty)
        //                    {
        //                        this.AddNewRecipientRow(RecipientListData, "To", sFullName, "There is no emaill address in the contact account.");
        //                    }
        //                    else
        //                    {
        //                        this.AddNewRecipientRow(RecipientListData, "To", sFullName, sEmailAddress);
        //                    }
        //                }
        //            }
        //        }

        //        #endregion

        //        #region TaskOwner

        //        if ((sTaskOwner != string.Empty) && (sTaskOwner != null))
        //        {
        //            if (sTaskOwner == "True")
        //            {
        //                string sSql_LoanTasks = "select Owner from LoanTasks where LoanTaskId=" + this.iTaskID;
        //                DataTable LoanTasks_List = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql_LoanTasks);

        //                string sOwnerId = LoanTasks_List.Rows[0]["Owner"].ToString();

        //                if ((sTaskOwner != string.Empty) && (sTaskOwner != null))
        //                {
        //                    int iOwnerId = Convert.ToInt32(sOwnerId);
        //                    string sSql_Users = "select EmailAddress, LastName, FirstName from Users where UserId=" + iOwnerId;
        //                    DataTable Users_List = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql_Users);
        //                    string Owner_EmailAddress = Users_List.Rows[0]["EmailAddress"].ToString();
        //                    if ((Owner_EmailAddress != string.Empty) && (Owner_EmailAddress != null))
        //                    {
        //                        string sOwnerFullName = Users_List.Rows[0]["LastName"].ToString() + ", " + Users_List.Rows[0]["FirstName"].ToString();
        //                        this.AddNewRecipientRow(RecipientListData, "To", sOwnerFullName, Owner_EmailAddress);
        //                    }
        //                }
        //            }
        //        }

        //        #endregion
        //    }

        //    #endregion

        //    #region CC

        //    DataRow[] CCRecipient = RecipientList.Select("RecipientType='CC'");
        //    if (CCRecipient.Length > 0)
        //    {
        //        string sEmailList_CC = CCRecipient[0]["EmailAddr"].ToString();
        //        string sContactList_CC = CCRecipient[0]["ContactRoles"].ToString();
        //        string sUserRoleList_CC = CCRecipient[0]["UserRoles"].ToString();

        //        #region Emails

        //        if (sEmailList_CC != string.Empty)
        //        {
        //            string[] EmailArray_CC = sEmailList_CC.Split(';');
        //            foreach (string sEmailCC in EmailArray_CC)
        //            {
        //                this.AddNewRecipientRow(RecipientListData, "CC", string.Empty, sEmailCC);
        //            }
        //        }

        //        #endregion

        //        #region User IDs

        //        if (sUserRoleList_CC != string.Empty)
        //        {
        //            string[] UserRoleArray_CC = sUserRoleList_CC.Split(';');
        //            foreach (string sUserRoleIDCC in UserRoleArray_CC)
        //            {
        //                int iUserRoleIDCC = Convert.ToInt32(sUserRoleIDCC);

        //                DataRow[] LoanTeamRows = LoanTeamList.Select("RoleId=" + iUserRoleIDCC);
        //                foreach (DataRow LoanTeamRow in LoanTeamRows)
        //                {
        //                    string sFullName = LoanTeamRow["LastName"].ToString() + ", " + LoanTeamRow["FirstName"].ToString();
        //                    string sEmailAddress = LoanTeamRow["EmailAddress"].ToString();

        //                    if (sEmailAddress == string.Empty)
        //                    {
        //                        this.AddNewRecipientRow(RecipientListData, "CC", sFullName, "There is no emaill address in the user account.");
        //                    }
        //                    else
        //                    {
        //                        this.AddNewRecipientRow(RecipientListData, "CC", sFullName, sEmailAddress);
        //                    }
        //                }
        //            }
        //        }

        //        #endregion

        //        #region Contact IDs

        //        if (sContactList_CC != string.Empty)
        //        {
        //            string[] ContactArray_CC = sContactList_CC.Split(';');
        //            foreach (string sContactIDCC in ContactArray_CC)
        //            {
        //                int iContactRoleIDCC = Convert.ToInt32(sContactIDCC);

        //                DataRow[] ContactRows = ContactList.Select("ContactRoleId=" + iContactRoleIDCC);
        //                foreach (DataRow ContactRow in ContactRows)
        //                {
        //                    #region Build FullName

        //                    string sFirstName = ContactRow["FirstName"].ToString();
        //                    string sLastName = ContactRow["LastName"].ToString();
        //                    string sMiddleName = ContactRow["MiddleName"].ToString();

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

        //                    #endregion

        //                    string sEmailAddress = ContactRow["Email"].ToString();

        //                    if (sEmailAddress == string.Empty)
        //                    {
        //                        this.AddNewRecipientRow(RecipientListData, "CC", sFullName, "There is no emaill address in the contact account.");
        //                    }
        //                    else
        //                    {
        //                        this.AddNewRecipientRow(RecipientListData, "CC", sFullName, sEmailAddress);
        //                    }
        //                }
        //            }
        //        }

        //        #endregion
        //    }

        //    #endregion

        //    this.gridRecipientList.DataSource = RecipientListData;
        //    this.gridRecipientList.DataBind();

        //    #endregion
        //}

        #endregion
        #region 新页面信息绑定 Borrower/Task/EmailTemplate

        #region 加载Borrower Info

        string    sSql5        = "select * from LoanContacts as b1 inner join Contacts as b2 on b1.ContactId = b2.ContactId where b1.FileId=" + this.iLoanID + "  and b1.ContactRoleId=dbo.lpfn_GetBorrowerRoleId() ";
        DataTable BorrowerInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql5);

        #endregion

        #region 绑定Borrower信息
        this.lbBorrower.Text = "";
        if (BorrowerInfo.Rows.Count > 0)
        {
            string sBorrowerLastName   = BorrowerInfo.Rows[0]["LastName"].ToString();
            string sBorrowerFristName  = BorrowerInfo.Rows[0]["FirstName"].ToString();
            string sBorrowerMiddleName = BorrowerInfo.Rows[0]["MiddleName"].ToString();

            StringBuilder sbBorrowerName = new StringBuilder();
            sbBorrowerName.Append(sBorrowerLastName);
            if (sBorrowerFristName != string.Empty)
            {
                sbBorrowerName.Append(", " + sBorrowerFristName);
            }
            if (sBorrowerMiddleName != string.Empty)
            {
                sbBorrowerName.Append(" " + sBorrowerMiddleName);
            }

            this.lbBorrower.Text = sbBorrowerName.ToString();
        }
        #endregion

        #region 加载Task Info

        string    sSql6    = "SELECT [Name] FROM [LoanTasks] WHERE LoanTaskId=" + this.iTaskID;
        DataTable TaskInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql6);

        #endregion

        #region 绑定Task Info信息
        this.lbTask.Text = "";
        if (TaskInfo.Rows.Count > 0)
        {
            string taskName = TaskInfo.Rows[0]["Name"].ToString();

            this.lbTask.Text = taskName;
        }
        #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);
        #endregion

        #region 加载 任务邮件模板 并绑定


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

        var ltceDS = bllLT_com_Emails.GetList("[Enabled]=1 AND LoanTaskid=" + this.iTaskID);

        gridCompletetionEmails.DataSource = ltceDS;//new List<string>(){"t1","t2"};
        gridCompletetionEmails.DataBind();

        #endregion


        #endregion
    }
示例#12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (string.IsNullOrEmpty(Request.QueryString["needret"]))
        {
            strNeedReturn = "0";
        }
        else
        {
            strNeedReturn = "1";
        }

        #region 校验必要参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "RuleID", QueryStringType.ID);
        if (bIsValid == false)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Missing", "$('#divContainer').hide();alert('Missing required query string.');window.parent.CloseDialog_EditRule();", true);
            return;
        }

        this.iRuleID = Convert.ToInt32(this.Request.QueryString["RuleID"]);

        #endregion

        #region 加载Rule信息
        Template_Rules RuleManager = new Template_Rules();
        DataTable      RuleInfo    = RuleManager.GetRuleInfo(this.iRuleID);
        if (RuleInfo.Rows.Count == 0)
        {
            this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Invalid", "$('#divContainer').hide();alert('Invalid required query string.');window.parent.CloseDialog_EditRule();", true);
            return;
        }

        #endregion

        // is referenced by rule group
        this.hdnIsRef.Text = RuleManager.bIsRef(this.iRuleID).ToString();

        if (this.IsPostBack == false)
        {
            #region 加载email template
            LoanTasks      LoanTaskManager  = new LoanTasks();
            Template_Email EmailTempManager = new Template_Email();
            DataTable      EmailTemplates   = EmailTempManager.GetEmailTemplate(" and Enabled = 1");

            DataRow NoneEmailTemplateRow = EmailTemplates.NewRow();
            NoneEmailTemplateRow["TemplEmailId"] = 0;
            NoneEmailTemplateRow["Name"]         = "-- select an email template --";
            EmailTemplates.Rows.InsertAt(NoneEmailTemplateRow, 0);

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

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

            #endregion

            #region 加载Conditions

            DataTable ConditionListData = RuleManager.GetConditionList(this.iRuleID);
            this.gridConditionList.DataSource = ConditionListData;
            this.gridConditionList.DataBind();

            #endregion

            #region 绑定数据

            this.txtRuleName.Text   = RuleInfo.Rows[0]["Name"].ToString();
            this.txtDesc.Text       = RuleInfo.Rows[0]["Desc"].ToString();
            this.chkEnabled.Checked = Convert.ToBoolean(RuleInfo.Rows[0]["Enabled"]);
            this.ddlRecomActionTemplate.SelectedValue = RuleInfo.Rows[0]["RecomEmailTemplid"].ToString();
            this.ddlAlertEmailTemplate.SelectedValue  = RuleInfo.Rows[0]["AlertEmailTemplId"].ToString();
            this.chkReqAck.Checked      = Convert.ToBoolean(RuleInfo.Rows[0]["AckReq"]);
            this.txtFormula.Text        = RuleInfo.Rows[0]["AdvFormula"].ToString();
            this.ddlScope.SelectedValue = RuleInfo.Rows[0]["RuleScope"].ToString();

            #region get loan target

            //this.ddlTarget.SelectedValue = RuleInfo.Rows[0]["LoanTarget"].ToString();

            LPWeb.Model.Template_Rules_LoanTarget modelLoanTarget;
            if (!RuleInfo.Rows[0].IsNull("LoanTarget"))
            {
                modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget(Convert.ToInt16(RuleInfo.Rows[0]["LoanTarget"]));
            }
            else
            {
                modelLoanTarget = new LPWeb.Model.Template_Rules_LoanTarget();
            }

            this.chkTargetActiveLoans.Checked   = modelLoanTarget.ActiveLoans;
            this.chkTargetActiveLeads.Checked   = modelLoanTarget.ActiveLeads;
            this.chkTargetArchivedLoans.Checked = modelLoanTarget.ArchivedLoans;
            this.chkTargetArchivedLeads.Checked = modelLoanTarget.ArchivedLeads;

            #endregion

            #endregion
            if (RuleInfo.Rows[0]["AutoCampaignId"].ToString() != "")
            {
                this.hfSelCampaigns.Value = RuleInfo.Rows[0]["AutoCampaignId"].ToString();
                MarketingCampaigns             _bMarketingCampaigns = new MarketingCampaigns();
                LPWeb.Model.MarketingCampaigns _mMarketingCampaigns = _bMarketingCampaigns.GetModel(Convert.ToInt32(RuleInfo.Rows[0]["AutoCampaignId"]));
                //txtMarketingCampaign.Text = _mMarketingCampaigns.CampaignName;
            }
            // set counter
            this.hdnCounter.Value = ConditionListData.Rows.Count.ToString();
        }
    }
示例#13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string sErrorJs = "window.parent.CloseDialog_AddTask();";

        #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"]);

        #endregion

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

        #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);
            if (LoanStages == null || LoanStages.Rows.Count <= 0)
            {
                this.iCurrentLoanStageId = GetTaskStageID(this.iLoanID);
                if ((this.iCurrentLoanStageId == null) ||
                    (this.iCurrentLoanStageId <= 0))
                {
                    this.ClientScript.RegisterClientScriptBlock(this.GetType(), "_Failed0", "$('#divContainer').hide();alert('The loan does not have any stage to add the task to.');window.parent.RefreshPage();", true);
                    return;
                }
            }
            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

            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");
            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();
            DataTable      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

            gridCompletetionEmails.DataSource = null;
            gridCompletetionEmails.DataBind();
        }
    }