username@email.com
2025-05-09 66beb245e516809514642c00922f0339bf760518
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
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);
            }
        }
    }
}