private void InitControl() { #region 加载Primary Contact Contacts ContactsManager = new Contacts(); _bContactBranches = new ContactBranches(); int iContactBranchID = 0; int result = 0; if (Int32.TryParse(sContactBranchID, out result)) { iContactBranchID = result; } LPWeb.Model.ContactBranches mContactBranches = _bContactBranches.GetModel(iContactBranchID); int iContactCompanyId = 0; if (mContactBranches != null && mContactBranches.ContactCompanyId != null) //bug #201 { iContactCompanyId = (int)mContactBranches.ContactCompanyId; } DataTable ContactsList = ContactsManager.GetEnableCompanyContactInfo(iContactCompanyId, iContactBranchID); if (ContactsList == null) { ContactsList = ContactsManager.GetEnableContactInfo(); } DataRow NewContactsRow = ContactsList.NewRow(); NewContactsRow["ContactId"] = DBNull.Value; NewContactsRow["Contact"] = "—select—"; ContactsList.Rows.InsertAt(NewContactsRow, 0); ContactsList.AcceptChanges(); this.ddlContact.DataSource = ContactsList; this.ddlContact.DataBind(); #endregion #region 加载Company ContactCompanies ContactCompaniesManager = new ContactCompanies(); DataSet ContactCompaniesList = ContactCompaniesManager.GetList("(Enabled='true')"); //if (ContactCompaniesList != null && ContactCompaniesList.Tables[0].Rows.Count > 0) //{ DataRow NewContactCompaniesRow = ContactCompaniesList.Tables[0].NewRow(); NewContactCompaniesRow["ContactCompanyId"] = DBNull.Value; NewContactCompaniesRow["Name"] = "All Companies"; ContactCompaniesList.Tables[0].Rows.InsertAt(NewContactCompaniesRow, 0); ContactCompaniesList.Tables[0].AcceptChanges(); this.ddlCompany.DataSource = ContactCompaniesList.Tables[0]; this.ddlCompany.DataBind(); //} #endregion #region 加载States LPWeb.Layouts.LPWeb.Common.USStates.Init(this.ddlStates); #endregion }
private void BindBranchInfo() { _bContactBranches = new ContactBranches(); LPWeb.Model.ContactBranches mContactBranches = _bContactBranches.GetModel(Convert.ToInt32(sContactBranchID)); this.ddlCompany.SelectedValue = Convert.ToString(mContactBranches.ContactCompanyId); this.tbBranch.Text = mContactBranches.Name; this.tbAddress.Text = mContactBranches.Address; this.tbCity.Text = mContactBranches.City; this.tbFax.Text = mContactBranches.Fax; this.tbPhone.Text = mContactBranches.Phone; this.tbZip.Text = mContactBranches.Zip; this.ddlContact.SelectedValue = Convert.ToString(mContactBranches.PrimaryContact); this.ddlStates.SelectedValue = mContactBranches.State; this.chkEnable.Checked = mContactBranches.Enabled; }
protected void ddlBranch_onSelectedIndexChanged(object sender, EventArgs e) { if (ddlBranch.SelectedIndex == 0) { return; } int branchId = Convert.ToInt32(ddlBranch.SelectedValue.Trim()); LPWeb.Model.ContactBranches model = new LPWeb.Model.ContactBranches(); LPWeb.BLL.ContactBranches cBranch = new ContactBranches(); model = cBranch.GetModel(branchId); ddlState.SelectedValue = model.State.Trim(); txbZip.Text = model.Zip.Trim(); txbAddress.Text = model.Address.Trim(); txbCity.Text = model.City.Trim(); txbFax.Text = model.Fax.Trim(); txbBPhone.Text = model.Phone.Trim(); }
private void BindContactBranch(int ContactBranchId) { try { BindContactBranch(); ContactBranches branch = new ContactBranches(); LPWeb.Model.ContactBranches model = new LPWeb.Model.ContactBranches(); model = branch.GetModel(ContactBranchId); if (model == null) { return; } ddlBranch.SelectedValue = ContactBranchId.ToString(); BindContactCompany(model.ContactCompanyId.Value); ddlCompany.SelectedValue = model.ContactCompanyId.ToString(); } catch { } }
private void BindLables() { if (iContactID == 0) { return; } int iContactBranchID = 0; int iCompanyID = 0; string raw_data = ""; string processed_data = " "; try { Contacts bllContact = new Contacts(); LPWeb.Model.Contacts mContact = new LPWeb.Model.Contacts(); mContact = bllContact.GetModel(iContactID); lbName.Text = mContact.LastName + ", " + mContact.FirstName; lbEnabled.Text = mContact.Enabled?"Yes":"No"; if (mContact.CellPhone != null) { raw_data = mContact.CellPhone.Trim(); raw_data = System.Text.RegularExpressions.Regex.Replace(raw_data, @"[-() ]", String.Empty); if (raw_data.Length > 10) { raw_data = raw_data.Substring(0, 10); } if (raw_data.Length == 10) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 4); } else if (raw_data.Length == 9) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 3); } else if (raw_data.Length == 8) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 2); } else if (raw_data.Length == 7) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 1); } else if (raw_data.Length == 6) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-"; } else if (raw_data.Length == 5) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 2) + " -"; } else if (raw_data.Length == 4) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 1) + " -"; } else if (raw_data.Length == 3) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + " -"; } else if (raw_data.Length == 2) { processed_data = "(" + raw_data.Substring(0, 2) + " ) " + " -"; } else if (raw_data.Length == 1) { processed_data = "(" + raw_data.Substring(0, 1) + " ) " + " -"; } else { processed_data = "( ) - "; } } else { processed_data = "( ) - "; } lbCellPhone.Text = processed_data; if (mContact.BusinessPhone != null) { raw_data = mContact.BusinessPhone.Trim(); raw_data = System.Text.RegularExpressions.Regex.Replace(raw_data, @"[-() ]", String.Empty); if (raw_data.Length > 10) { raw_data = raw_data.Substring(0, 10); } if (raw_data.Length == 10) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 4); } else if (raw_data.Length == 9) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 3); } else if (raw_data.Length == 8) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 2); } else if (raw_data.Length == 7) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 1); } else if (raw_data.Length == 6) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-"; } else if (raw_data.Length == 5) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 2) + " -"; } else if (raw_data.Length == 4) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 1) + " -"; } else if (raw_data.Length == 3) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + " -"; } else if (raw_data.Length == 2) { processed_data = "(" + raw_data.Substring(0, 2) + " ) " + " -"; } else if (raw_data.Length == 1) { processed_data = "(" + raw_data.Substring(0, 1) + " ) " + " -"; } else { processed_data = "( ) - "; } } else { processed_data = "( ) - "; } lbBussinessPhone.Text = processed_data; raw_data = mContact.Fax; if (mContact.Fax != null) { raw_data = mContact.Fax.Trim(); raw_data = System.Text.RegularExpressions.Regex.Replace(raw_data, @"[-() ]", String.Empty); if (raw_data.Length > 10) { raw_data = raw_data.Substring(0, 10); } if (raw_data.Length == 10) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 4); } else if (raw_data.Length == 9) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 3); } else if (raw_data.Length == 8) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 2); } else if (raw_data.Length == 7) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 1); } else if (raw_data.Length == 6) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-"; } else if (raw_data.Length == 5) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 2) + " -"; } else if (raw_data.Length == 4) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 1) + " -"; } else if (raw_data.Length == 3) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + " -"; } else if (raw_data.Length == 2) { processed_data = "(" + raw_data.Substring(0, 2) + " ) " + " -"; } else if (raw_data.Length == 1) { processed_data = "(" + raw_data.Substring(0, 1) + " ) " + " -"; } else { processed_data = "( ) - "; } } else { processed_data = "( ) - "; } lbFax.Text = processed_data; lbEmail.Text = mContact.Email; if (mContact.ContactCompanyId.HasValue) { iCompanyID = mContact.ContactCompanyId.Value; } if (mContact.ContactBranchId.HasValue) { iContactBranchID = mContact.ContactBranchId.Value; } } catch (Exception ex) { } try { ContactBranches bllCB = new ContactBranches(); LPWeb.Model.ContactBranches mCB = new LPWeb.Model.ContactBranches(); mCB = bllCB.GetModel(iContactBranchID); lbBranch.Text = mCB.Name; if (mCB.Phone != null) { raw_data = mCB.Phone.Trim(); raw_data = System.Text.RegularExpressions.Regex.Replace(raw_data, @"[-() ]", String.Empty); if (raw_data.Length > 10) { raw_data = raw_data.Substring(0, 10); } if (raw_data.Length == 10) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 4); } else if (raw_data.Length == 9) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 3); } else if (raw_data.Length == 8) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 2); } else if (raw_data.Length == 7) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 1); } else if (raw_data.Length == 6) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-"; } else if (raw_data.Length == 5) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 2) + " -"; } else if (raw_data.Length == 4) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 1) + " -"; } else if (raw_data.Length == 3) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + " -"; } else if (raw_data.Length == 2) { processed_data = "(" + raw_data.Substring(0, 2) + " ) " + " -"; } else if (raw_data.Length == 1) { processed_data = "(" + raw_data.Substring(0, 1) + " ) " + " -"; } else { processed_data = "( ) - "; } } else { processed_data = "( ) - "; } lbPhone.Text = processed_data; if (mCB.Fax != null) { raw_data = mCB.Fax.Trim(); raw_data = System.Text.RegularExpressions.Regex.Replace(raw_data, @"[-() ]", String.Empty); if (raw_data.Length > 10) { raw_data = raw_data.Substring(0, 10); } if (raw_data.Length == 10) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 4); } else if (raw_data.Length == 9) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 3); } else if (raw_data.Length == 8) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 2); } else if (raw_data.Length == 7) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-" + raw_data.Substring(6, 1); } else if (raw_data.Length == 6) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 3) + "-"; } else if (raw_data.Length == 5) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 2) + " -"; } else if (raw_data.Length == 4) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + raw_data.Substring(3, 1) + " -"; } else if (raw_data.Length == 3) { processed_data = "(" + raw_data.Substring(0, 3) + ") " + " -"; } else if (raw_data.Length == 2) { processed_data = "(" + raw_data.Substring(0, 2) + " ) " + " -"; } else if (raw_data.Length == 1) { processed_data = "(" + raw_data.Substring(0, 1) + " ) " + " -"; } else { processed_data = "( ) - "; } } else { processed_data = "( ) - "; } lbFax1.Text = processed_data; lbAddress.Text = mCB.Address; lbCity.Text = mCB.City + " " + mCB.State + " " + mCB.Zip; if (mCB.ContactCompanyId.HasValue && iCompanyID == 0) { iCompanyID = mCB.ContactCompanyId.Value; } } catch (Exception ex) { } int iServiceTypeID = 0; try { ContactCompanies bllCC = new ContactCompanies(); LPWeb.Model.ContactCompanies mCC = new LPWeb.Model.ContactCompanies(); mCC = bllCC.GetModel(iCompanyID); //lbServiceType.Text = mCC.ServiceTypes; lbCompany.Text = mCC.Name; iServiceTypeID = mCC.ServiceTypeId; } catch { } try { ServiceTypes blST = new ServiceTypes(); LPWeb.Model.ServiceTypes mST = new LPWeb.Model.ServiceTypes(); mST = blST.GetModel(iServiceTypeID); lbServiceType.Text = mST.Name; } catch { } #region Referral Amount/Referral Funded/Wind Ratio string sSql = "select dbo.lpfn_GetTotalReferral(" + this.iContactID + ", " + this.CurrUser.iUserID + ") as TotalReferral, " + "dbo.lpfn_GetTotalReferralFunded(" + this.iContactID + ", " + this.CurrUser.iUserID + ") as TotalReferralFunded, " + "dbo.lpfn_GetTotalReferral_FileIDs(" + this.iContactID + ", " + this.CurrUser.iUserID + ") as TotalReferralFileIDs, " + "isnull(dbo.lpfn_GetTotalReferralFunded(" + this.iContactID + ", " + this.CurrUser.iUserID + "),0)/dbo.lpfn_GetTotalReferral(" + this.iContactID + ", " + this.CurrUser.iUserID + ") as WinRatio"; DataTable ReferralAmountInfo = LPWeb.DAL.DbHelperSQL.ExecuteDataTable(sSql); if (ReferralAmountInfo.Rows.Count > 0) { if (ReferralAmountInfo.Rows[0]["TotalReferral"] == DBNull.Value) { this.aTotalReferral.InnerText = string.Empty; this.aTotalReferral.HRef = string.Empty; } else { this.aTotalReferral.InnerText = Convert.ToDecimal(ReferralAmountInfo.Rows[0]["TotalReferral"]).ToString("c0"); this.aTotalReferral.HRef = "javascript:window.parent.SetTab('PartnerContactDetailReferralstab.aspx',3);"; } if (ReferralAmountInfo.Rows[0]["TotalReferralFunded"] == DBNull.Value) { this.lbTotalReferralFunded.Text = string.Empty; } else { this.lbTotalReferralFunded.Text = Convert.ToDecimal(ReferralAmountInfo.Rows[0]["TotalReferralFunded"]).ToString("c0"); } if (ReferralAmountInfo.Rows[0]["WinRatio"] == DBNull.Value) { this.lbWinRatio.Text = string.Empty; } else { this.lbWinRatio.Text = Convert.ToDecimal(ReferralAmountInfo.Rows[0]["WinRatio"]).ToString("p0"); } } #endregion }
/// <summary> /// Fill contact model /// </summary> /// <returns></returns> public LPWeb.Model.Contacts FillModel() { LPWeb.Model.Contacts model = new LPWeb.Model.Contacts(); model.ContactId = this.ContactId; if (this.ddlBranch.SelectedIndex > 0) { model.ContactBranchId = int.Parse(this.ddlBranch.SelectedValue); LPWeb.BLL.ContactBranches contactBranch = new ContactBranches(); LPWeb.Model.ContactBranches branchModel = contactBranch.GetModel(model.ContactBranchId.Value); if (branchModel != null) { model.ContactCompanyId = branchModel.ContactCompanyId; } } model.FirstName = this.txtFirstName.Text.Trim(); model.LastName = this.txtLastName.Text.Trim(); model.Enabled = this.chkEnabled.Checked; model.ContactEnable = this.chkEnabled.Enabled; model.MailingAddr = this.txtAddress.Text.Trim(); model.MailingCity = this.txtCity.Text.Trim(); if (this.ddlStates.SelectedIndex >= 1) { model.MailingState = this.ddlStates.SelectedValue; } model.MailingZip = this.txtZip.Text.Trim(); model.CellPhone = this.txtCellPhone.Text.Trim().Replace("(", "").Replace(")", "").Replace("-", ""); string CellPhone = model.CellPhone; if ((CellPhone != null) && (CellPhone != string.Empty)) { CellPhone = System.Text.RegularExpressions.Regex.Replace(CellPhone, @"[-() ]", String.Empty); if ((CellPhone.Length != 10) && (CellPhone.Length > 0)) { PageCommon.WriteJsEnd(this, "Cell phone number must be 10 digits.", PageCommon.Js_RefreshSelf); return(null); } } model.BusinessPhone = this.txtBizPhone.Text.Trim().Replace("(", "").Replace(")", "").Replace("-", ""); string BusinessPhone = model.BusinessPhone; if ((BusinessPhone != null) && (BusinessPhone != string.Empty)) { BusinessPhone = System.Text.RegularExpressions.Regex.Replace(BusinessPhone, @"[-() ]", String.Empty); if ((BusinessPhone.Length != 10) && (BusinessPhone.Length > 0)) { PageCommon.WriteJsEnd(this, "Business phone number must be 10 digits.", PageCommon.Js_RefreshSelf); return(null); } } model.Email = this.txtEmail.Text.Trim(); model.Fax = this.txtFax.Text.Trim().Replace("(", "").Replace(")", "").Replace("-", ""); string Fax = model.Fax; if ((Fax != null) && (Fax != string.Empty)) { Fax = System.Text.RegularExpressions.Regex.Replace(Fax, @"[-() ]", String.Empty); if ((Fax.Length != 10) && (Fax.Length > 0)) { PageCommon.WriteJsEnd(this, "Fax number must be 10 digits.", PageCommon.Js_RefreshSelf); return(null); } } if (this.FileUpload1.PostedFile.ContentLength > 0) { byte[] ImageData = new byte[this.FileUpload1.PostedFile.ContentLength]; this.FileUpload1.PostedFile.InputStream.Read(ImageData, 0, this.FileUpload1.PostedFile.ContentLength); model.Picture = ImageData; } string sMySignature = this.txtSignature.Text.Trim(); model.Signature = sMySignature; return(model); }