using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CY.BLL; using CY.Infrastructure.Common; using CY.Model; namespace CY.WebForm.Pages.business { //吴辉 //合并客户 public partial class CorporateClientsMerger : BasePage { OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = null; //初始化 public CorporateClientsMerger() { bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL(); } //页面加载 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindData(); } } //绑定数据 public void BindData() { try { string Kids = Request["Keyid"].ToString2().Trim('|'); string[] keyids = Kids.Split('|'); Guid[] NewKeyids = new Guid[2]; if (keyids.Length == 2) { NewKeyids[0] = keyids[0].ToGuid2(); NewKeyids[1] = keyids[1].ToGuid2(); OA_CorporateClients m_OA_CorporateClients_one = bll_OA_CorporateClientsBLL.GetModel(NewKeyids[0]); OA_CustomerCommunications m_OA_CustomerCommunications_one = bll_OA_CorporateClientsBLL.GetModel_CustomerCommunications(NewKeyids[0]); OA_CorporateClients m_OA_CorporateClients_two = bll_OA_CorporateClientsBLL.GetModel(NewKeyids[1]); OA_CustomerCommunications m_OA_CustomerCommunications_two = bll_OA_CorporateClientsBLL.GetModel_CustomerCommunications(NewKeyids[1]); if (m_OA_CorporateClients_one == null) { JavaScript.MessageBox("所选择客户中存在错误数据", this, true, false); return; } if (m_OA_CorporateClients_two == null) { JavaScript.MessageBox("所选择客户中存在错误数据", this, true, false); return; } if (m_OA_CorporateClients_one.FirmId != CurrentUser.MemberId || m_OA_CorporateClients_two.FirmId != CurrentUser.MemberId) { JavaScript.MessageBox("错误数据", this, true, false); return; } if (m_OA_CorporateClients_one.MemberId != m_OA_CorporateClients_one.Keyid && m_OA_CorporateClients_two.MemberId != m_OA_CorporateClients_two.Keyid) { JavaScript.MessageBox("两个线上客户不能合并", this, true, false); return; } if (m_OA_CorporateClients_two.MemberId != m_OA_CorporateClients_two.Keyid) { this.CustomNameOne.InnerText = m_OA_CorporateClients_two.CompanyName; this.spanLegalRepresentativeOne.InnerText = m_OA_CustomerCommunications_two.LegalRepresentative; this.spanPhoneNumOne.InnerText = string.IsNullOrEmpty(m_OA_CustomerCommunications_two.CompanyPhone) ? m_OA_CustomerCommunications_two.Mobile : m_OA_CustomerCommunications_two.CompanyPhone; this.divAddressOne.InnerText = m_OA_CustomerCommunications_two.Province + m_OA_CustomerCommunications_two.City + m_OA_CustomerCommunications_two.County + m_OA_CustomerCommunications_two.DetailedAddress; this.CustomNameTwo.InnerText = m_OA_CorporateClients_one.CompanyName; this.spanLegalRepresentativeTwo.InnerText = m_OA_CustomerCommunications_one.LegalRepresentative; this.spanPhoneNumTwo.InnerText = string.IsNullOrEmpty(m_OA_CustomerCommunications_one.CompanyPhone) ? m_OA_CustomerCommunications_one.Mobile : m_OA_CustomerCommunications_one.CompanyPhone; this.divAddressTwo.InnerText = m_OA_CustomerCommunications_one.Province + m_OA_CustomerCommunications_one.City + m_OA_CustomerCommunications_one.County + m_OA_CustomerCommunications_one.DetailedAddress; this.CustomChangeOne.Checked = true; this.CustomChangeOne.Disabled = true; this.CustomChangeTwo.Disabled = true; } else { this.CustomNameOne.InnerText = m_OA_CorporateClients_one.CompanyName; this.spanLegalRepresentativeOne.InnerText = m_OA_CustomerCommunications_one.LegalRepresentative; this.spanPhoneNumOne.InnerText = string.IsNullOrEmpty(m_OA_CustomerCommunications_one.CompanyPhone) ? m_OA_CustomerCommunications_one.Mobile : m_OA_CustomerCommunications_one.CompanyPhone; this.divAddressOne.InnerText = m_OA_CustomerCommunications_one.Province + m_OA_CustomerCommunications_one.City + m_OA_CustomerCommunications_one.County + m_OA_CustomerCommunications_one.DetailedAddress; this.CustomNameTwo.InnerText = m_OA_CorporateClients_two.CompanyName; this.spanLegalRepresentativeTwo.InnerText = m_OA_CustomerCommunications_two.LegalRepresentative; this.spanPhoneNumTwo.InnerText = string.IsNullOrEmpty(m_OA_CustomerCommunications_two.CompanyPhone) ? m_OA_CustomerCommunications_two.Mobile : m_OA_CustomerCommunications_two.CompanyPhone; this.divAddressTwo.InnerText = m_OA_CustomerCommunications_two.Province + m_OA_CustomerCommunications_two.City + m_OA_CustomerCommunications_two.County + m_OA_CustomerCommunications_two.DetailedAddress; if (m_OA_CorporateClients_one.MemberId != m_OA_CorporateClients_one.Keyid) { this.CustomChangeOne.Checked = true; this.CustomChangeOne.Disabled = true; this.CustomChangeTwo.Disabled = true; } } } else { JavaScript.MessageBox("数据错误",this,true,false); } } catch (Exception ex) { PAGEHandleException(ex); JavaScript.MessageBox("合并失败",this,true,false); } } //合并客户 protected void btn_Submit_form(object sender, EventArgs e) { try { string nowChange = Request["CustomChange"]; Guid DefaultId = Guid.Empty; Guid DelId = Guid.Empty; Guid InquiryId = Guid.Empty; string Kids = Request["Keyid"].ToString2().Trim('|'); string[] keyids = Kids.Split('|'); Guid[] NewKeyids = new Guid[2]; if (keyids.Length == 2) { NewKeyids[0] = keyids[0].ToGuid2(); NewKeyids[1] = keyids[1].ToGuid2(); OA_CorporateClients m_OA_CorporateClients_one = bll_OA_CorporateClientsBLL.GetModel(NewKeyids[0]); OA_CorporateClients m_OA_CorporateClients_two = bll_OA_CorporateClientsBLL.GetModel(NewKeyids[1]); if (m_OA_CorporateClients_one == null) { JavaScript.MessageBox("所选择客户中存在错误数据", this, true, false); return; } if (m_OA_CorporateClients_two == null) { JavaScript.MessageBox("所选择客户中存在错误数据", this, true, false); return; } if (m_OA_CorporateClients_one.FirmId != CurrentUser.MemberId || m_OA_CorporateClients_two.FirmId != CurrentUser.MemberId) { JavaScript.MessageBox("错误数据", this, true, false); return; } if (m_OA_CorporateClients_one.MemberId != m_OA_CorporateClients_one.Keyid && m_OA_CorporateClients_two.MemberId != m_OA_CorporateClients_two.Keyid) { JavaScript.MessageBox("两个线上客户不能合并", this, true, false); return; } if (m_OA_CorporateClients_two.MemberId != m_OA_CorporateClients_two.Keyid) { DefaultId = m_OA_CorporateClients_two.Keyid; DelId = m_OA_CorporateClients_one.Keyid; InquiryId= m_OA_CorporateClients_two.InquiryId; } else { if (nowChange == "two") { DefaultId = m_OA_CorporateClients_two.Keyid; DelId = m_OA_CorporateClients_one.Keyid; InquiryId = m_OA_CorporateClients_two.InquiryId; } else { DefaultId = m_OA_CorporateClients_one.Keyid; DelId = m_OA_CorporateClients_two.Keyid; InquiryId = m_OA_CorporateClients_one.InquiryId; } } if (bll_OA_CorporateClientsBLL.MergerCustom(DefaultId, DelId, InquiryId)) JavaScript.MessageBox("合并成功",this,true,true); else JavaScript.MessageBox("合并失败", this, true, false); } else { JavaScript.MessageBox("数据错误", this, true, false); } } catch (Exception ex) { PAGEHandleException(ex); JavaScript.MessageBox("合并失败",this,true,false); } } } }