Пример #1
0
    private int Save_LoanDetail()
    {
        ReassignProspect();

        #region gdc crm33
        int    iContactCoBoId = string.IsNullOrEmpty(hdnCoBorrowerID.Value) ? 0 : Convert.ToInt32(hdnCoBorrowerID.Value);
        string CBname         = txtCBFirstname.Text + txtCBMiddlename.Text + txtCBLastname.Text;

        if ((CBname != hdnCoBorrowerName.Value.Trim() || iContactCoBoId == 0) && !string.IsNullOrEmpty(CBname))
        {
            LPWeb.Model.Contacts contactRecCoBo = new LPWeb.Model.Contacts();
            Contacts             contactsbll    = new Contacts();//gdc crm33
            contactRecCoBo.ContactId  = 0;
            contactRecCoBo.FirstName  = txtCBFirstname.Text.Trim();
            contactRecCoBo.MiddleName = txtCBMiddlename.Text.Trim();
            contactRecCoBo.LastName   = txtCBLastname.Text.Trim();

            iContactCoBoId = contactsbll.AddClient(contactRecCoBo);//gdc crm33

            #region CoBo to loanContacts  gdc crm33
            LPWeb.BLL.LoanContacts loanContactsBll = new LoanContacts();


            LPWeb.BLL.ContactRoles contactRolesbll = new ContactRoles();
            int contactRoleID   = 0;
            var contactRoleList = contactRolesbll.GetModelList(" Name = 'CoBorrower' ");
            if (contactRoleList != null && contactRoleList.Count > 0 && contactRoleList.FirstOrDefault() != null)
            {
                contactRoleID = contactRoleList.FirstOrDefault().ContactRoleId;
            }

            if (contactRoleID != 0)
            {
                LPWeb.Model.LoanContacts loanContactModel = new LPWeb.Model.LoanContacts();
                loanContactModel.FileId        = iFileID;
                loanContactModel.ContactRoleId = contactRoleID;
                loanContactModel.ContactId     = iContactCoBoId;

                loanContactsBll.Add(loanContactModel);
            }

            #endregion
        }
        #endregion

        LPWeb.Model.LoanDetails model = new LPWeb.Model.LoanDetails();
        model.FileId = iFileID;
        if (ddlBorrower.Items.Count < 1)
        {
            model.BoID = 0;
        }
        else
        {
            model.BoID = int.Parse(ddlBorrower.SelectedValue);
        }
        //if (ddlCoBorrower.Items.Count < 1)
        //{
        //    model.CoBoID = 0;
        //}
        //else
        //{
        //    model.CoBoID = int.Parse(ddlCoBorrower.SelectedValue);
        //}

        if (iContactCoBoId != 0)
        {
            model.CoBoID = iContactCoBoId;
        }


        model.Created    = DateTime.Now;
        model.CreatedBy  = loginUser.iUserID;
        model.Modifed    = DateTime.Now;
        model.ModifiedBy = loginUser.iUserID;
        if (txbAmount.Text.Trim().Length < 1)
        {
            model.LoanAmount = 0;
        }
        else
        {
            model.LoanAmount = decimal.Parse(txbAmount.Text.Trim());
        }

        if (txbEstimatedDate.Text.Trim().Length > 5)
        {
            model.EstCloseDate = DateTime.Parse(txbEstimatedDate.Text.Trim());
        }
        else
        {
            model.EstCloseDate = DateTime.Parse("1900-1-1");
        }
        if (ddlRanking.SelectedIndex >= 0)
        {
            model.Ranking = ddlRanking.SelectedValue;
        }
        model.UserId = CurrUser.iUserID;
        if (ddlLoanOfficer.Items.Count < 1)
        {
            model.LoanOfficerId = 0;
        }
        else
        {
            model.LoanOfficerId = int.Parse(ddlLoanOfficer.SelectedValue);
        }
        if (txbInterestRate.Text.Trim().Length < 1)
        {
            model.Rate = 0;
        }
        else
        {
            model.Rate = decimal.Parse(txbInterestRate.Text.Trim());
        }

        if (ddlLoanProgram.SelectedIndex == 0)
        {
            model.Program = "";
        }
        else
        {
            model.Program = ddlLoanProgram.SelectedItem.Text;
        }
        if (ddlPurpose.SelectedIndex == 0)
        {
            model.Purpose = "";
        }
        else
        {
            model.Purpose = ddlPurpose.SelectedItem.Text.Trim();
        }

        model.Lien          = ddlLienPosition.SelectedItem.Value.Trim();
        model.PropertyAddr  = txbPropertyAddress.Text.Trim();
        model.PropertyCity  = txbCity.Text.Trim();
        model.PropertyState = ddlState.SelectedValue;
        model.PropertyZip   = txbZip.Text.Trim();
        if (ddlPointFolder.Items.Count < 1)
        {
            model.FolderId = 0;
        }
        else
        {
            model.FolderId = int.Parse(ddlPointFolder.SelectedValue);
        }
        model.FileName           = txbPointFileName.Text.Trim();
        model.Status             = "Prospect";
        model.ProspectLoanStatus = "Active";

        model.PropertyType   = txbPropetyType.Text.Trim();
        model.HousingStatus  = txbHousingStatus.Text.Trim();
        model.IncludeEscrows = cbIncludeEscrows.Checked;
        model.InterestOnly   = cbInterestOnly.Checked;
        model.RentAmount     = string.IsNullOrEmpty(txbRentAmount.Text.Trim()) ? 0 : Convert.ToDecimal(txbRentAmount.Text.Trim());
        model.CoborrowerType = txbCoborrowerType.Text.Trim();
        iFileID = loan.LoanDetailSaveFileId(model);


        #region Referral
        LPWeb.Model.Prospect modelProspect = new LPWeb.Model.Prospect();

        LPWeb.BLL.Prospect bllProspect = new Prospect();
        modelProspect = bllProspect.GetModel(iContactID);

        modelProspect.LeadSource = ddlLeadSource.SelectedValue; //gdc CR40

        int referralIDNew = string.IsNullOrEmpty(hdnReferralID.Value.Trim()) ? 0 : Convert.ToInt32(hdnReferralID.Value.Trim());

        if (referralIDNew > 0 && referralIDNew.ToString() != modelProspect.Referral.ToString())
        {
            int referralIDOld = modelProspect.Referral == null ? 0 : Convert.ToInt32(modelProspect.Referral);

            modelProspect.Referral = referralIDNew;

            #region Referral to loanContacts  gdc crm33
            LPWeb.BLL.LoanContacts loanContactsBll = new LoanContacts();

            LPWeb.BLL.ContactRoles contactRolesbll = new ContactRoles();
            int refrralRoleID    = 0;
            var referralRoleList = contactRolesbll.GetModelList(" Name = 'Referral' ");
            if (referralRoleList != null && referralRoleList.Count > 0 && referralRoleList.FirstOrDefault() != null)
            {
                refrralRoleID = referralRoleList.FirstOrDefault().ContactRoleId;
            }

            if (refrralRoleID != 0)
            {
                LPWeb.Model.LoanContacts loanContactModel = new LPWeb.Model.LoanContacts();
                loanContactModel.FileId        = iFileID;
                loanContactModel.ContactRoleId = refrralRoleID;
                loanContactModel.ContactId     = referralIDNew;

                loanContactsBll.Add(loanContactModel);
            }

            #endregion


            #region Del Old loanContacts

            try
            {
                if (referralIDOld > 0)
                {
                    loanContactsBll.Delete(iFileID, refrralRoleID, referralIDOld);
                }
            }
            catch { }

            #endregion
        }

        bllProspect.Update(modelProspect); //gdc CR40

        #endregion

        return(iFileID);
    }
Пример #2
0
    private void FillLabels()
    {
        if (iFileID == 0)
        {
            return;
        }
        LPWeb.Model.Loans model = new LPWeb.Model.Loans();
        model = loan.GetModel(iFileID);
        if (model == null)
        {
            return;
        }
        if (model.LoanAmount.HasValue && model.LoanAmount.Value > 0)
        {
            txbAmount.Text = string.Format("{0:C}", model.LoanAmount.Value.ToString());
        }
        else
        {
            txbAmount.Text = string.Empty;
        }

        if (model.Rate.HasValue && model.Rate.Value > 0)
        {
            txbInterestRate.Text = model.Rate.Value.ToString();
        }
        else
        {
            txbInterestRate.Text = string.Empty;
        }

        if (model.EstCloseDate.HasValue && model.EstCloseDate.Value > DateTime.Parse("1900-1-1"))
        {
            txbEstimatedDate.Text = model.EstCloseDate.Value.ToShortDateString();
        }
        else
        {
            txbEstimatedDate.Text = string.Empty;
        }
        if (model.Program.Length == 0)
        {
            ddlLoanProgram.SelectedIndex = 0;
        }
        else
        {
            if (!ddlLoanProgram.Items.Contains(new ListItem(model.Program, model.Program)))
            {
                ddlLoanProgram.Items.Add(new ListItem(model.Program, model.Program));
            }
            ddlLoanProgram.SelectedValue = model.Program;
        }
        txbPropertyAddress.Text = model.PropertyAddr;
        txbCity.Text            = model.PropertyCity;
        txbZip.Text             = model.PropertyZip;
        if (model.PropertyState.Length > 0)
        {
            ddlState.SelectedValue = model.PropertyState.Trim();
        }
        else
        {
            ddlState.SelectedIndex = 0;
        }
        if (model.Ranking.Length > 0)
        {
            ddlRanking.SelectedValue = model.Ranking.ToLower();
        }
        else
        {
            ddlRanking.SelectedIndex = -1;
        }
        if (model.LienPosition.Length > 0)
        {
            ddlLienPosition.SelectedValue = model.LienPosition.Trim();
        }
        if (model.Purpose.Length > 0)
        {
            ddlPurpose.SelectedValue = model.Purpose.Trim();
        }
        Contacts contact = new Contacts();

        try
        {
            string sBoID = contact.GetBorrowerDetails(iFileID, "Borrower")["ContactID"].ToString();
            ddlBorrower.SelectedValue = sBoID;
        }
        catch
        { }

        try
        {
            var    dr     = contact.GetBorrowerDetails(iFileID, "CoBorrower");
            string sCBoID = dr["ContactID"].ToString();
            //ddlCoBorrower.SelectedValue = sCBoID;
            hdnCoBorrowerID.Value = sCBoID;
            txtCBFirstname.Text   = dr["FirstName"] != DBNull.Value ? dr["FirstName"].ToString() : "";
            txtCBMiddlename.Text  = dr["Middlename"] != DBNull.Value ? dr["Middlename"].ToString() : "";
            txtCBLastname.Text    = dr["Lastname"] != DBNull.Value ? dr["Lastname"].ToString() : "";

            hdnCoBorrowerName.Value = txtCBFirstname.Text + txtCBMiddlename.Text + txtCBLastname.Text;
        }
        catch
        { }

        BindPoint(iFileID);

        if (model.Created.HasValue)
        {
            lbCreatedOn.Text = model.Created.Value.ToShortDateString();
        }
        if (model.CreatedBy.HasValue)
        {
            lbCreatedBy.Text = GetUserName(model.CreatedBy.Value);
        }

        if (model.Modifed.HasValue)
        {
            lbCreatedOn.Text = model.Modifed.Value.ToShortDateString();
        }
        if (model.ModifiedBy.HasValue)
        {
            lbCreatedBy.Text = GetUserName(model.ModifiedBy.Value);
        }

        //add by gdc 20110828

        txbPropetyType.Text      = model.PropertyType;
        txbHousingStatus.Text    = model.HousingStatus;
        cbInterestOnly.Checked   = model.InterestOnly;
        cbIncludeEscrows.Checked = model.IncludeEscrows;

        txbCoborrowerType.Text = model.CoBrwType;
        txbRentAmount.Text     = model.RentAmount == null ? "" : Convert.ToDecimal(model.RentAmount).ToString("n0");


        //gdc crm33
        LPWeb.Model.Prospect modelProspect = new LPWeb.Model.Prospect();

        LPWeb.BLL.Prospect bllProspect = new Prospect();
        modelProspect = bllProspect.GetModel(iContactID);

        if (modelProspect != null & modelProspect.Referral != null)
        {
            hdnReferralID.Value = modelProspect.Referral.ToString();

            string sqlReferralName = string.Format("select dbo.lpfn_GetReferralName({0})", iFileID);

            var obj = LPWeb.DAL.DbHelperSQL.GetSingle(sqlReferralName);
            if (obj != null)
            {
                txtReferral.Text = obj.ToString();
            }
        }

        ddlLeadSource.SelectedValue = modelProspect.LeadSource;
    }