private void BindContactBranch() { try { ddlBranch.Items.Clear(); ContactBranches branch = new ContactBranches(); string strWhere = " Enabled=1 "; if (ddlCompany.SelectedValue != "0") { strWhere += string.Format(" AND ContactCompanyID={0} ", ddlCompany.SelectedValue.Trim()); } DataSet ds = branch.GetList(0, strWhere, " [Name] asc"); if (ds == null) { return; } ddlBranch.DataValueField = "ContactBranchID"; ddlBranch.DataTextField = "Name"; ddlBranch.Items.Add(new ListItem("--select--", "0")); ddlBranch.SelectedIndex = 0; foreach (DataRow dr in ds.Tables[0].Rows) { ddlBranch.Items.Add(new ListItem(dr["Name"].ToString(), dr["ContactBranchID"].ToString())); } } catch { } }
/// <summary> /// Save /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { _bContactBranches = new ContactBranches(); //check if there is a duplicate branch name in the CompanyBranches if (_bContactBranches.IsExist_EditBase(Convert.ToInt32(sContactBranchID), tbBranch.Text.Trim())) { PageCommon.WriteJsEnd(this, "duplication of this branch name.", PageCommon.Js_RefreshSelf); return; } //Load LPWeb.Model.ContactBranches _mContactBranches = new LPWeb.Model.ContactBranches(); _mContactBranches.ContactBranchId = Convert.ToInt32(sContactBranchID); if (ddlCompany.SelectedValue.ToString() != "") { _mContactBranches.ContactCompanyId = Convert.ToInt32(ddlCompany.SelectedValue); } _mContactBranches.Name = tbBranch.Text.Trim(); _mContactBranches.Phone = tbPhone.Text.Trim(); string Phone = _mContactBranches.Phone; if ((Phone != null) && (Phone != string.Empty)) { Phone = System.Text.RegularExpressions.Regex.Replace(Phone, @"[-() ]", String.Empty); if ((Phone.Length != 10) && (Phone.Length > 0)) { PageCommon.WriteJsEnd(this, "Phone number must be 10 digits.", PageCommon.Js_RefreshSelf); return; } } _mContactBranches.State = ddlStates.SelectedValue.ToString(); _mContactBranches.Zip = tbZip.Text.Trim(); _mContactBranches.Fax = tbFax.Text.Trim(); string Fax = _mContactBranches.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; } } _mContactBranches.Enabled = chkEnable.Checked; _mContactBranches.Address = tbAddress.Text.Trim(); _mContactBranches.City = tbCity.Text.Trim(); if (ddlContact.SelectedValue.ToString() != "") { _mContactBranches.PrimaryContact = Convert.ToInt32(ddlContact.SelectedValue); } //Save _bContactBranches.Update(_mContactBranches); PageCommon.WriteJsEnd(this, "Updated partner branch successfully.", "window.parent.location.href='PartnerBranchList.aspx';"); }
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 }
protected void Page_Load(object sender, EventArgs e) { // json示例 // {"ContactBranchId":{0},"Name":"{1}","Address":"{2}","City":"{3}","State":"{4}","Zip":"{5}"} #region 接收参数 string respTempl = "^0^\"ContactBranchId\":{0},\"Name\":\"{1}\",\"Address\":\"{2}\",\"City\":\"{3}\",\"State\":\"{4}\",\"Zip\":\"{5}\"^1^"; // DelContactID bool bIsValid = PageCommon.ValidateQueryString(this, "ContactBranchId", QueryStringType.ID); if (bIsValid == false) { this.Response.Write(string.Format("{\"ContactBranchId\":{0},\"Name\":\"{1}\",\"Address\":\"{2}\",\"City\":\"{3}\",\"State\":\"{4}\",\"Zip\":\"{5}\"}", 0)); return; } string sContactBranchId = this.Request.QueryString["ContactBranchId"].ToString(); int iContactBranchId = Convert.ToInt32(sContactBranchId); #endregion #region Branch ContactBranches contactBranch = new ContactBranches(); try { DataSet dsCBranch = contactBranch.GetList(" ContactBranchId = " + iContactBranchId.ToString()); if (dsCBranch != null && dsCBranch.Tables.Count > 0 && dsCBranch.Tables[0].Rows.Count > 0) { DataRow dr = dsCBranch.Tables[0].Rows[0]; string rspStr = string.Format(respTempl , dr["ContactBranchId"] != DBNull.Value ? dr["ContactBranchId"].ToString() : "0" , dr["Name"] != DBNull.Value ? dr["Name"].ToString() : "" , dr["Address"] != DBNull.Value ? dr["Address"].ToString() : "" , dr["City"] != DBNull.Value ? dr["City"].ToString() : "" , dr["State"] != DBNull.Value ? dr["State"].ToString() : "" , dr["Zip"] != DBNull.Value ? dr["Zip"].ToString() : "" ); this.Response.Write(respStrReplace(rspStr)); return; } this.Response.Write(string.Format(respTempl, 0)); return; } catch { this.Response.Write(string.Format(respTempl, 0)); return; } #endregion }
protected void lnkDeleteBranch_Click(object sender, EventArgs e) { string sSelBranchID = this.hdnSelectedBranchID.Value; int iSelBranchID = Convert.ToInt32(sSelBranchID); ContactBranches ContactBranchManager = new ContactBranches(); ContactBranchManager.RomoveBranch(iSelBranchID); PageCommon.WriteJsEnd(this, "Deleted partner branch successfully.", PageCommon.Js_RefreshSelf); }
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; }
/// <summary> /// Bind Page default values /// </summary> private void BindPageDefaultValues() { try { //Bind Alphabet foreach (string alphabet in alphabets.Split(',')) { ddlAlphabets.Items.Add(new ListItem(alphabet, alphabet)); } //Bind State LPWeb.Layouts.LPWeb.Common.USStates.Init(this.ddlStates); //Bind Branch ContactBranches contactBranch = new ContactBranches(); DataSet dsCBranch = contactBranch.GetList(" Enabled='true' Order by Name asc"); DataRow drNew = dsCBranch.Tables[0].NewRow(); drNew["ContactBranchId"] = 0; drNew["Name"] = "-- Select Branch --"; dsCBranch.Tables[0].Rows.InsertAt(drNew, 0); this.ddlBranch.DataSource = dsCBranch.Tables[0]; this.ddlBranch.DataValueField = "ContactBranchId"; this.ddlBranch.DataTextField = "Name"; this.ddlBranch.DataBind(); //this.ddlBranch.SelectedValue = CurrUser. // autocomplete address this.ddlBranchAddress.DataSource = dsCBranch.Tables[0]; this.ddlBranchAddress.DataBind(); List <string> s = new List <string>(); if (this.ContactId == 0) { this.btnDelete.Disabled = true; } else { this.btnDelete.Disabled = false; } } catch (Exception ex) { throw ex; } }
private void BindBranches() { try { LPWeb.BLL.ContactBranches bllBranch = new ContactBranches(); ddlBranchs.DataSource = bllBranch.GetList(" Enabled=1 order by Name"); ddlBranchs.DataBind(); var item = new ListItem("All Branches", "0") { Selected = true }; ddlBranchs.Items.Insert(0, item); } catch { } }
/// <summary> /// Assign Contact /// </summary> private void AssignContactUser() { _bContactBranches = new ContactBranches(); string sSelUserIDs = this.Request.QueryString["AssignUserIDs"] != null ? this.Request.QueryString["AssignUserIDs"].ToString() : ""; var selctedStr = this.Request.QueryString["SelContactIDs"] != null ? this.Request.QueryString["SelContactIDs"].ToString() : ""; if (sSelUserIDs != "" && selctedStr != "") { foreach (string ContactID in selctedStr.Split(',')) { foreach (string sUserID in sSelUserIDs.Split(',')) { _bContactBranches.AssignUser2Contact(Convert.ToInt32(sUserID), Convert.ToInt32(ContactID)); } } } }
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 { } }
/// <summary> /// Assign Contact /// </summary> private void AssignContactUser() { string sSelUserIDs = string.Empty; string selctedStr = string.Empty; if (!string.IsNullOrEmpty(this.Request.QueryString["AssignUserIDs"])) { sSelUserIDs = this.Request.QueryString["AssignUserIDs"]; } else { return; } if (!string.IsNullOrEmpty(this.Request.QueryString["SelContactIDs"])) { selctedStr = this.Request.QueryString["SelContactIDs"]; } else { return; } if (sSelUserIDs != "" && selctedStr != "") { ContactBranches _bContactBranches = new ContactBranches(); foreach (string ContactID in selctedStr.Split(',')) { foreach (string sUserID in sSelUserIDs.Split(',')) { try { _bContactBranches.AssignUser2Contact(Convert.ToInt32(sUserID), Convert.ToInt32(ContactID)); } 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); }