Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region 检查页面参数

        // CloseDialogCodes
        bool bIsValid = PageCommon.ValidateQueryString(this, "CloseDialogCodes", QueryStringType.String);
        if (bIsValid == false)
        {
            PageCommon.WriteJsEnd(this, "Missing required query string.", "window.parent.location.href=window.parent.location.href");
        }
        this.sCloseDialogCodes = this.Request.QueryString["CloseDialogCodes"].ToString() + ";";

        // RefreshCodes
        bIsValid = PageCommon.ValidateQueryString(this, "RefreshCodes", QueryStringType.String);
        if (bIsValid == false)
        {
            PageCommon.WriteJsEnd(this, "Missing required query string.", "window.parent.location.href=window.parent.location.href");
        }
        this.sRefreshCodes = this.Request.QueryString["RefreshCodes"].ToString() + ";";
        if (PageCommon.ValidateQueryString(this, "RefreshCodes", QueryStringType.String))
        {
            this.sRefreshTabCodes = this.Request.QueryString["RefreshTab"].ToString().Trim() == "" ? "" : (this.Request.QueryString["RefreshTab"].ToString().Trim() + ";");
        }

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

        #endregion

        //权限验证
        if (_curLoginUser.userRole.Prospect.ToString().IndexOf('H') == -1) // UpdatePoint
        {
            btnUpdatePoint.Enabled = false;
        }

        #region 加载Contact信息

        Contacts  ContactManager = new Contacts();
        DataTable ContactInfo    = null;
        try
        {
            ContactInfo = ContactManager.GetContactInfo(this.iProspectID);
        }
        catch (Exception ex)
        {
            string sExMsg = string.Format("Exception happened when get contact info (ContactID={0}): {1}", this.iProspectID, ex.Message);
            LPLog.LogMessage(LogType.Logerror, ex.Message);
            PageCommon.WriteJsEnd(this, "Exception happened when get contact info.", this.sCloseDialogCodes);
        }

        if (ContactInfo.Rows.Count == 0)
        {
            PageCommon.WriteJsEnd(this, "Invalid contact id.", this.sCloseDialogCodes);
        }

        #endregion

        #region 加载Prospect信息

        Prospect  ProspectManager = new Prospect();
        DataTable ProspectInfo    = null;
        try
        {
            ProspectInfo = ProspectManager.GetProspectInfo(this.iProspectID);
        }
        catch (Exception ex)
        {
            string sExMsg = string.Format("Exception happened when get prospect info (ContactID={0}): {1}", this.iProspectID, ex.Message);
            LPLog.LogMessage(LogType.Logerror, ex.Message);
            PageCommon.WriteJsEnd(this, "Exception happened when get prospect info.", this.sCloseDialogCodes);
        }

        if (ProspectInfo.Rows.Count == 0)
        {
            PageCommon.WriteJsEnd(this, "Invalid prospect id.", this.sCloseDialogCodes);
        }



        #region 加载Create By

        Users  UserManager = new Users();
        string sCreatedBy  = ProspectInfo.Rows[0]["CreatedBy"].ToString();
        int    iCreatedBy  = 0; //Convert.ToInt32(sCreatedBy);

        if (sCreatedBy != string.Empty)
        {
            iCreatedBy = Convert.ToInt32(sCreatedBy);
            DataTable CreatedByInfo = UserManager.GetUserInfo(iCreatedBy);
            if (CreatedByInfo.Rows.Count == 0)
            {
                this.lbCreatedBy.Text = string.Empty;
            }
            else
            {
                this.lbCreatedBy.Text = CreatedByInfo.Rows[0]["LastName"].ToString() + ", " + CreatedByInfo.Rows[0]["FirstName"].ToString();
            }
        }
        else
        {
            this.lbCreatedBy.Text = string.Empty;
        }

        #endregion

        #region 加载Create By

        string sModifiedBy = ProspectInfo.Rows[0]["ModifiedBy"].ToString();

        if (sModifiedBy != string.Empty)
        {
            DataTable ModifiedByInfo = UserManager.GetUserInfo(Convert.ToInt32(sModifiedBy));
            if (ModifiedByInfo.Rows.Count == 0)
            {
                this.lbModifiedBy.Text = string.Empty;
            }
            else
            {
                this.lbModifiedBy.Text = ModifiedByInfo.Rows[0]["LastName"].ToString() + ", " + ModifiedByInfo.Rows[0]["FirstName"].ToString();
            }
        }
        else
        {
            this.lbModifiedBy.Text = string.Empty;
        }

        #endregion

        #endregion

        // Old Status
        this.hdnOldStatus.Value = ProspectInfo.Rows[0]["Status"].ToString();

        if (this.IsPostBack == false)
        {
            USStates.Init(ddlState);
            #region 加载Loan Officer列表

            DataTable LoanOfficerList = this.GetLoanOfficerList(iCreatedBy);
            this.ddlLoanOfficer.DataSource = LoanOfficerList;
            this.ddlLoanOfficer.DataBind();

            #endregion

            #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 绑定Prospect数据

            // Loan Officer
            this.ddlLoanOfficer.SelectedValue = ProspectInfo.Rows[0]["LoanOfficer"].ToString();

            hfLoanOfficer.Value          = ProspectInfo.Rows[0]["LoanOfficer"].ToString();
            this.txtRefCode.Text         = ProspectInfo.Rows[0]["ReferenceCode"].ToString();
            this.ddlStatus.SelectedValue = ProspectInfo.Rows[0]["Status"].ToString();
            ListItem item = this.ddlCreditRanking.Items.FindByValue(string.Format("{0}", ProspectInfo.Rows[0]["CreditRanking"]));
            if (null != item)
            {
                this.ddlCreditRanking.ClearSelection();
                item.Selected = true;
            }
            item = this.ddlPreferredContact.Items.FindByValue(string.Format("{0}", ProspectInfo.Rows[0]["PreferredContact"]));
            if (null != item)
            {
                this.ddlPreferredContact.ClearSelection();
                item.Selected = true;
            }
            this.ddlLeadSource.SelectedValue = ProspectInfo.Rows[0]["LeadSource"].ToString();

            this.lbCreatedOn.Text = ProspectInfo.Rows[0]["Created"].ToString();

            this.lbModifiedOn.Text = ProspectInfo.Rows[0]["Modifed"].ToString();

            //Get referral contact name
            int iReferralId = 0;
            if (ProspectInfo.Rows[0]["Referral"].ToString() != "" && int.TryParse(ProspectInfo.Rows[0]["Referral"].ToString(), out iReferralId))
            {
                this.txbReferral.Text    = ContactManager.GetContactName(iReferralId);
                this.hdnReferralID.Value = iReferralId.ToString();
            }

            #endregion

            #region 绑定Contact数据

            this.txtFirstName.Text      = ContactInfo.Rows[0]["FirstName"].ToString();
            this.txtMiddleName.Text     = ContactInfo.Rows[0]["MiddleName"].ToString();
            this.txtLastName.Text       = ContactInfo.Rows[0]["LastName"].ToString();
            this.ddlTitle.SelectedValue = ContactInfo.Rows[0]["Title"].ToString();
            this.txtGenerationCode.Text = ContactInfo.Rows[0]["GenerationCode"].ToString();
            this.txtSSN.Text            = ContactInfo.Rows[0]["SSN"].ToString();
            this.txtHomePhone.Text      = ContactInfo.Rows[0]["HomePhone"].ToString();
            this.txtCellPhone.Text      = ContactInfo.Rows[0]["CellPhone"].ToString();
            this.txtBizPhone.Text       = ContactInfo.Rows[0]["BusinessPhone"].ToString();
            this.txtFax.Text            = ContactInfo.Rows[0]["Fax"].ToString();
            this.txtAddress.Text        = ContactInfo.Rows[0]["MailingAddr"].ToString();
            this.txtCity.Text           = ContactInfo.Rows[0]["MailingCity"].ToString();
            this.ddlState.SelectedValue = ContactInfo.Rows[0]["MailingState"].ToString();
            this.txtZip.Text            = ContactInfo.Rows[0]["MailingZip"].ToString();
            this.txtEmail.Text          = ContactInfo.Rows[0]["Email"].ToString();
            if (ContactInfo.Rows[0]["DOB"] == DBNull.Value)
            {
                this.txtDOB.Text = string.Empty;
            }
            else
            {
                this.txtDOB.Text = Convert.ToDateTime(ContactInfo.Rows[0]["DOB"]).ToShortDateString();
            }
            this.txtExperianScore.Text  = ContactInfo.Rows[0]["Experian"].ToString();
            this.txtTransUnitScore.Text = ContactInfo.Rows[0]["TransUnion"].ToString();
            this.txtEquifaxScore.Text   = ContactInfo.Rows[0]["Equifax"].ToString();



            #endregion
        }
    }