Ejemplo n.º 1
0
        private void BindDDL()
        {
            Company_Loan_Programs _bCompany_Loan_Programs = new Company_Loan_Programs();
            DataSet ds = _bCompany_Loan_Programs.GetList("1>0");

            ddlProgram.DataValueField = "LoanProgramID";
            ddlProgram.DataTextField  = "LoanProgram";
            ddlProgram.DataSource     = ds.Tables[0];
            ddlProgram.DataBind();
        }
Ejemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 检查必要参数

        bool bIsValid = PageCommon.ValidateQueryString(this, "LoanID", QueryStringType.ID);
        if (bIsValid == false)
        {
            PageCommon.WriteJsEnd(this, "Missing required query string.", "");
        }
        this.iLoanID = Convert.ToInt32(this.Request.QueryString["LoanID"]);

        #endregion

        #region 加载Loan Info

        string    sSql3    = "select l.*, pf.FolderId, pf.Name as FileName from Loans l inner join PointFiles pf on l.FileId=pf.FileId where l.FileId=" + this.iLoanID;
        DataTable LoanInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql3);
        if ((LoanInfo == null) || (LoanInfo.Rows.Count == 0))
        {
            PageCommon.WriteJsEnd(this, string.Format("No Loan Info found for LoanID {0}.", iLoanID), "");
        }

        int    FolderId = 0;
        string FileName = string.Empty;
        FolderId = LoanInfo.Rows[0]["FolderId"] == DBNull.Value ? 0 : (int)LoanInfo.Rows[0]["FolderId"];
        FileName = LoanInfo.Rows[0]["FileName"] == DBNull.Value ? string.Empty : (string)LoanInfo.Rows[0]["FileName"];
        if (FolderId < 1 || string.IsNullOrEmpty(FileName))
        {
            lnkImport.Visible = false;
        }

        #endregion

        #region 权限验证
        //try
        //{
        //    if (this.CurrUser.userRole.Prospect.ToString().IndexOf('B') == -1)
        //    {
        //        this.btnModify.Disabled = true;
        //    }
        //    if (this.CurrUser.userRole.Prospect.ToString().IndexOf('K') == -1)
        //    {
        //        this.btnSendEmail.Disabled = true;
        //    }
        //    if (this.CurrUser.userRole.Prospect.ToString().IndexOf('F') == -1)
        //    {
        //        this.btnDispose.Disabled = true;
        //    }
        //    if (this.CurrUser.userRole.Prospect.ToString().IndexOf('C') == -1)
        //    {
        //        btnDelete.Enabled = false;
        //    }
        //    if (this.CurrUser.userRole.Prospect.ToString().IndexOf('G') == -1)
        //    {
        //        btnSyncNow.Enabled = false;
        //    }
        //}
        //catch (Exception exception)
        //{
        //    LPLog.LogMessage(exception.Message);
        //}


        if (this.CurrUser.userRole.ExportClients == true)
        {
            this.btnvCardExport.Enabled = true;
        }
        else
        {
            this.btnvCardExport.Enabled = false;
        }

        #endregion

        this.GetPostBackEventReference(this.lnkExport);

        if (this.IsPostBack == false)
        {
            #region 加载Lead Source列表

            Company_Lead_Sources LeadSourceManager = new Company_Lead_Sources();
            DataTable            LeadSourceList    = LeadSourceManager.GetList("1=1 order by LeadSource").Tables[0];

            DataRow NewLeadSourceRow = LeadSourceList.NewRow();
            NewLeadSourceRow["LeadSourceID"] = DBNull.Value;
            NewLeadSourceRow["LeadSource"]   = "-- select --";

            LeadSourceList.Rows.InsertAt(NewLeadSourceRow, 0);

            this.ddlLeadSource.DataSource = LeadSourceList;
            this.ddlLeadSource.DataBind();

            #endregion

            #region 加载Program列表

            Company_Loan_Programs ProgramMgr  = new Company_Loan_Programs();
            DataTable             ProgramList = ProgramMgr.GetList("1=1 order by LoanProgram").Tables[0];

            DataRow NewProgramRow = ProgramList.NewRow();
            NewProgramRow["LoanProgramID"] = DBNull.Value;
            NewProgramRow["LoanProgram"]   = "-- select --";

            ProgramList.Rows.InsertAt(NewProgramRow, 0);

            this.ddlProgram.DataSource = ProgramList;
            this.ddlProgram.DataBind();

            #endregion

            #region 加载Borrower Info

            DataTable BorrowerInfo = this.GetBorrowerInfo(this.iLoanID);

            #region 绑定Borrower信息
            if (BorrowerInfo.Rows.Count > 0)
            {
                string sFirstName    = BorrowerInfo.Rows[0]["FirstName"].ToString();
                string sLastName     = BorrowerInfo.Rows[0]["LastName"].ToString();
                string sBorrowerName = sLastName + ", " + sFirstName;
                this.hProspectName.InnerText = sBorrowerName;
                this.txtFirstName.Text       = sFirstName;
                this.txtLastName.Text        = sLastName;

                this.txtEmail.Text     = BorrowerInfo.Rows[0]["Email"].ToString();
                this.txtCellPhone.Text = BorrowerInfo.Rows[0]["CellPhone"].ToString();
                this.txtHomePhone.Text = BorrowerInfo.Rows[0]["HomePhone"].ToString();
                this.txtWorkPhone.Text = BorrowerInfo.Rows[0]["BusinessPhone"].ToString();
                this.txtBirthday.Text  = BorrowerInfo.Rows[0]["DOB"].ToString() == "" ? "" : Convert.ToDateTime(BorrowerInfo.Rows[0]["DOB"]).ToString("MM/dd/yyyy");

                this.lbFirstName.Text = BorrowerInfo.Rows[0]["FirstName"].ToString();
                this.lbLastName.Text  = BorrowerInfo.Rows[0]["LastName"].ToString();
                this.lbEmail.Text     = BorrowerInfo.Rows[0]["Email"].ToString();
                this.lbCellPhone.Text = BorrowerInfo.Rows[0]["CellPhone"].ToString();
                this.lbHomePhone.Text = BorrowerInfo.Rows[0]["HomePhone"].ToString();
                this.lbWorkPhone.Text = BorrowerInfo.Rows[0]["BusinessPhone"].ToString();
                this.lbBirthday.Text  = BorrowerInfo.Rows[0]["DOB"].ToString() == "" ? "" : Convert.ToDateTime(BorrowerInfo.Rows[0]["DOB"]).ToString("MM/dd/yyyy");
            }
            #endregion

            if (BorrowerInfo.Rows.Count > 0)
            {
                string sContactID = BorrowerInfo.Rows[0]["ContactId"].ToString();


                #region 加载Prospect Info

                string    sSqlx0       = "select * from Prospect where ContactId=" + sContactID;
                DataTable ProspectInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSqlx0);

                #region 绑定Prospect信息

                if (ProspectInfo.Rows.Count > 0)
                {
                    // Lead Source
                    if (ProspectInfo.Rows[0]["LeadSource"] != DBNull.Value)
                    {
                        this.ddlLeadSource.SelectedValue = ProspectInfo.Rows[0]["LeadSource"].ToString();

                        this.lbLeadSource.Text = ProspectInfo.Rows[0]["LeadSource"].ToString();
                    }

                    // Referral Source (Prospect.Referral)
                    if (ProspectInfo.Rows[0]["Referral"] != DBNull.Value)
                    {
                        int      iReferralID    = Convert.ToInt32(ProspectInfo.Rows[0]["Referral"]);
                        Contacts ContactManager = new Contacts();
                        this.txtReferralSource.Text = ContactManager.GetContactName(iReferralID);
                        this.hdnReferralID.Value    = iReferralID.ToString();

                        this.lbReferralSource.Text = ContactManager.GetContactName(iReferralID);
                    }
                }

                #endregion

                #endregion
            }
            #endregion

            #region 绑定Lead信息

            if (LoanInfo.Rows[0]["Purpose"] != DBNull.Value)
            {
                this.ddlPurpose.SelectedValue = LoanInfo.Rows[0]["Purpose"].ToString();

                this.lbPurpose.Text = LoanInfo.Rows[0]["Purpose"].ToString();
            }

            if (LoanInfo.Rows[0]["LoanType"] != DBNull.Value)
            {
                this.ddlType.SelectedValue = LoanInfo.Rows[0]["LoanType"].ToString();

                this.lbType.Text = LoanInfo.Rows[0]["LoanType"].ToString();
            }

            if (LoanInfo.Rows[0]["Program"] != DBNull.Value)
            {
                this.ddlProgram.SelectedValue = LoanInfo.Rows[0]["Program"].ToString();

                this.lbProgram.Text = LoanInfo.Rows[0]["Program"].ToString();
            }

            this.txtAmount.Text = LoanInfo.Rows[0]["LoanAmount"].ToString() == "" ? "" : Convert.ToDecimal(LoanInfo.Rows[0]["LoanAmount"]).ToString("n0");
            this.txtRate.Text   = LoanInfo.Rows[0]["Rate"].ToString() == "" ? "" : Convert.ToDecimal(LoanInfo.Rows[0]["Rate"]).ToString("n3");

            this.lbAmount.Text = LoanInfo.Rows[0]["LoanAmount"].ToString() == "" ? "" : Convert.ToDecimal(LoanInfo.Rows[0]["LoanAmount"]).ToString("n0");
            this.lbRate.Text   = LoanInfo.Rows[0]["Rate"].ToString() == "" ? "" : Convert.ToDecimal(LoanInfo.Rows[0]["Rate"]).ToString("n3") + "%";

            #endregion
        }

        #region Codes for Stage Progress Bar

        DataTable StageProgressData = this.GetStageProgressData(this.iLoanID);
        this.rptStageProgressItems.DataSource = StageProgressData;
        this.rptStageProgressItems.DataBind();

        #endregion

        #region 获取当前Point Folder的BranchID

        string    sSqlx        = "select b.BranchId,b.name from PointFiles as a inner join PointFolders as b on a.FolderId = b.FolderId where a.FileId=" + this.iLoanID;
        DataTable BranchIDInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSqlx);
        if (BranchIDInfo.Rows.Count > 0 && BranchIDInfo.Rows[0]["BranchId"].ToString() != "" && BranchIDInfo.Rows[0]["BranchId"].ToString() != "0")
        {
            this.hdnBranchID.Value = BranchIDInfo.Rows[0]["BranchId"].ToString();
        }
        else
        {
            sSqlx = "select BranchID from Loans where FileId=" + this.iLoanID;
            DataTable dtLoan = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSqlx);
            if (dtLoan.Rows.Count > 0 && dtLoan.Rows[0]["BranchID"].ToString() != "" && dtLoan.Rows[0]["BranchID"].ToString() != "0")
            {
                this.hdnBranchID.Value = dtLoan.Rows[0]["BranchID"].ToString();
            }
            else
            {
                sSqlx = "SELECT TOP 1 BranchID FROM Groups WHERE GroupId IN(SELECT GroupID FROM GroupUsers WHERE UserID IN(SELECT UserId FROM LoanTeam WHERE FileId = " + this.iLoanID + " AND RoleId =(SELECT RoleId FROM Roles WHERE [Name]='Loan Officer')))";
                DataTable dtGroup = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSqlx);
                if (dtGroup.Rows.Count > 0 && dtGroup.Rows[0]["BranchID"].ToString() != "" && dtGroup.Rows[0]["BranchID"].ToString() != "0")
                {
                    this.hdnBranchID.Value = dtGroup.Rows[0]["BranchID"].ToString();
                }
            }
        }

        #endregion

        #region 加载Point File Info

        string    sSql7         = "Select top 1 * from dbo.lpvw_GetPointFileInfo where FileId=" + this.iLoanID;
        DataTable PointFileInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql7);

        string sHasPointFile = "False";
        if (PointFileInfo.Rows.Count > 0)
        {
            string sPointFilePath = PointFileInfo.Rows[0]["Path"].ToString();
            string sFolderID      = PointFileInfo.Rows[0]["FolderId"].ToString();

            if (sPointFilePath != string.Empty || sFolderID != string.Empty)
            {
                sHasPointFile = "True";
            }
        }

        this.hdnHasPointFile.Value = sHasPointFile;

        #endregion

        #region Context Menu

        if (LoanInfo.Rows.Count > 0)
        {
            string sProspectLoanStatus = LoanInfo.Rows[0]["ProspectLoanStatus"].ToString();

            //加载 ArchiveLeadStatus

            ArchiveLeadStatus ArchiveLeadStatusMgr  = new ArchiveLeadStatus();
            DataSet           ArchiveLeadStatusList = ArchiveLeadStatusMgr.GetList("isnull([Enabled],0)=1 order by LeadStatusName");

            #region Build Sub Menu Item

            StringBuilder sbSubMenuItems = new StringBuilder();
            if (ArchiveLeadStatusList.Tables[0].Rows.Count > 0)
            {
                sbSubMenuItems.AppendLine("<ul>");
                foreach (DataRow dr in ArchiveLeadStatusList.Tables[0].Rows)
                {
                    string sLeadStatusName1 = dr["LeadStatusName"].ToString();
                    string sLeadStatusName2 = dr["LeadStatusName"].ToString().Replace("'", "\\'");
                    sbSubMenuItems.AppendLine("<li><a href=\"\" onclick=\"ChangeStatus('" + sLeadStatusName2 + "'); return false;\">" + sLeadStatusName1 + "</a></li>");
                }
                sbSubMenuItems.AppendLine("</ul>");
            }

            #endregion

            StringBuilder sbMenuItems = new StringBuilder();
            if (sProspectLoanStatus.ToLower() == "active")
            {
                sbMenuItems.AppendLine("<li><a href=\"\" onclick=\"return false;\">Archive</a>" + sbSubMenuItems + "</li>");
                sbMenuItems.AppendLine("<li><a href=\"\" onclick=\"ChangeStatus('Convert'); return false;\">Convert to Loan</a></li>");
            }

            this.ltrChangeStatusMenuItems.Text = sbMenuItems.ToString();
        }

        #endregion

        #region Actions

        LoanTasks LoanTasksMgr = new LoanTasks();

        DataTable LastTaskInfo = LoanTasksMgr.GetLoanTaskList(1, " and FileId=" + this.iLoanID + " and Completed is not null", " order by Completed desc");
        DataTable NextTaskInfo = LoanTasksMgr.GetLoanTaskList(1, " and FileId=" + this.iLoanID + " and Completed is null", " order by LoanTaskId asc");

        if (LastTaskInfo.Rows.Count == 0 && NextTaskInfo.Rows.Count == 0)
        {
            this.divActions.Visible = false;
        }
        else
        {
            if (LastTaskInfo.Rows.Count == 0)
            {
                this.trLastAction.Visible = false;
            }
            else
            {
                this.ltrLastTaskName.Text = LastTaskInfo.Rows[0]["Name"].ToString();
                this.ltrLastDueDate.Text  = LastTaskInfo.Rows[0]["Due"] == DBNull.Value ? string.Empty : Convert.ToDateTime(LastTaskInfo.Rows[0]["Due"].ToString()).ToLongDateString();
                this.ltrLastDueTime.Text  = LastTaskInfo.Rows[0]["DueTime"] == DBNull.Value ? string.Empty : TimeSpan.Parse(LastTaskInfo.Rows[0]["DueTime"].ToString()).ToString();
            }


            if (NextTaskInfo.Rows.Count == 0)
            {
                this.trNextAction.Visible = false;
            }
            else
            {
                this.ltrNextTaskName.Text = NextTaskInfo.Rows[0]["Name"].ToString();
                this.ltrNextDueDate.Text  = NextTaskInfo.Rows[0]["Due"] == DBNull.Value ? string.Empty : Convert.ToDateTime(NextTaskInfo.Rows[0]["Due"].ToString()).ToLongDateString();
                this.ltrNextDueTime.Text  = NextTaskInfo.Rows[0]["DueTime"] == DBNull.Value ? string.Empty : TimeSpan.Parse(NextTaskInfo.Rows[0]["DueTime"].ToString()).ToString();

                // hidden fields
                this.hdnNextTaskID.Value        = NextTaskInfo.Rows[0]["LoanTaskId"].ToString();
                this.hdnNextTaskOwnerID.Value   = NextTaskInfo.Rows[0]["Owner"].ToString();
                this.hdnLoginUserID.Value       = this.CurrUser.iUserID.ToString();
                this.hdnCompleteOtherTask.Value = this.CurrUser.userRole.MarkOtherTaskCompl == true ? "True" : "False";
                this.hdnLoanStatus.Value        = LoanInfo.Rows[0]["Status"].ToString();
            }
        }

        #endregion
    }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 校验页面参数

        #region LoanId

        if (this.Request.QueryString["FileID"] != null)     // edit lead
        {
            #region 校验LoanId

            string sLoanId = this.Request.QueryString["FileID"];
            bool   bValid  = PageCommon.IsID(sLoanId);
            if (bValid == false)
            {
                PageCommon.WriteJsEnd(this, "Invalid loan id.", "window.location.href='LeadCreate.aspx'");
                return;
            }

            #endregion

            #region LoanId -> 加载CurrentLoanInfo

            // 加载Prospect Loan Info
            this.CurrentLoanInfo = this.GetProspectLoanInfo(sLoanId);
            if (this.CurrentLoanInfo.Rows.Count == 0)
            {
                PageCommon.WriteJsEnd(this, "Invalid loan id.", "window.location.href='LeadCreate.aspx'");
                return;
            }

            // LoanId
            this.iLoanId = Convert.ToInt32(sLoanId);

            #endregion

            // 加载Borrower/Co-Boorwer Info
            this.InitBorrowerCoBorrowerInfo(this.iLoanId);

            this.sActionMode = "Edit_HasLoanId_NoContactId";     // 纯edit
        }
        else
        {
            PageCommon.WriteJsEnd(this, "Invalid query string arrange.", "window.location.href='LeadCreate.aspx'");
            return;
        }

        #endregion

        #endregion

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

            Company_Loan_Programs ProgramMgr  = new Company_Loan_Programs();
            DataTable             ProgramList = ProgramMgr.GetList("1=1 order by LoanProgram").Tables[0];

            this.ddlProgram.Items.Add(new ListItem("-- select --", ""));
            this.ddlProgramNewLoan.Items.Add(new ListItem("-- select --", ""));

            foreach (DataRow ProgramRow in ProgramList.Rows)
            {
                string sLoanProgram = ProgramRow["LoanProgram"].ToString();
                this.ddlProgram.Items.Add(sLoanProgram);
                this.ddlProgramNewLoan.Items.Add(sLoanProgram);
            }

            #endregion

            #region 加载Start Date→Year

            this.ddlStartYear.Items.Add(new ListItem("year", ""));
            this.ddlStartYearNewLoan.Items.Add(new ListItem("year", ""));

            DateTime saveNow = DateTime.Now;

            int iBeginYear = saveNow.Year;
            for (int i = 0; i < 41; i++)
            {
                int iNextYear = iBeginYear - i;
                this.ddlStartYear.Items.Add(iNextYear.ToString());
                this.ddlStartYearNewLoan.Items.Add(iNextYear.ToString());
            }

            #endregion

            #region Loan Info

            this.BindingData_LoanInfo(this.CurrentLoanInfo);

            #endregion
        }
    }