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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
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.Model;
using CY.Infrastructure.Query;
using CY.Infrastructure.Common;
 
namespace CY.WebForm.Pages.soft
{
    //吴辉
    //软件客户列表
    public partial class ClientList : BasePage
    {
        Soft_ClientBLL bll_Soft_ClientBLL = null;
        OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = null;
        public string Province = ""; //接收值 Request["selectProvince"].ToString2();
        public string City = "";//接收值 Request["selectCity"].ToString2();
        public string County = "";//接收值 Request["selectCounty"].ToString2();
 
        //初始化
        public ClientList()
        {
            bll_Soft_ClientBLL = new Soft_ClientBLL();
            bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            UCPager1.AspNetPager.PageChanged += AspNetPager1_PageChanged;
            Province = Request["selectProvince"].ToString2();
            City = Request["selectCity"].ToString2();
            County = Request["selectCounty"].ToString2();
            if (!IsPostBack)
            {
                BindList();
            }
            if (Request["delete"] != null)
            {
                Soft_Client model = bll_Soft_ClientBLL.GetModelByKeyid(Request["delete"].ToInt32());
                if (model != null && model.Keyid != null)
                {
                    bll_Soft_ClientBLL.DeleteModel(model);
                    JavaScript.MessageBox("删除成功", this, "window.location='/Pages/Soft/ClientList.aspx';");
                }
                else
                    JavaScript.MessageBox("删除失败", this, "window.location='/Pages/Soft/ClientList.aspx';");
            }
            else if (Request["deleteKeyIds"] != null)
            {
                List<int> deleteKeyIdList = new List<int>();
                string deleteKeyIds = Request["deleteKeyIds"].ToString().Trim(',');
                string[] keyIdArry = deleteKeyIds.Split(',');
                foreach (string keyId in keyIdArry)
                {
                    Soft_Client model = bll_Soft_ClientBLL.GetModelByKeyid(keyId.ToInt32());
                    if (model.Keyid != null && model != null)
                        bll_Soft_ClientBLL.DeleteModel(model);
                    else
                    {
                        JavaScript.MessageBox("删除失败", this, "window.location='/Pages/Soft/ClientList.aspx';");
                        return;
                    }
                }
                JavaScript.MessageBox("删除成功", this, "window.location='/Pages/Soft/ClientList.aspx';");
            }
            else if (Request["importid"] != null)
            {
                Soft_Client m_Soft_Client = bll_Soft_ClientBLL.GetModelByKeyid(Request["importid"].ToInt32());
                if (m_Soft_Client != null && m_Soft_Client.Keyid != null)
                {
                    bool isExit = bll_OA_CorporateClientsBLL.isExistCompanyName(m_Soft_Client.ClientName.ToString2(), CurrentUser.MemberId, Guid.NewGuid());
 
                    if (!isExit)
                    {
                        OA_CorporateClients m_OA_CorporateClients = new OA_CorporateClients();
                        OA_CustomerCommunications m_OA_CustomerCommunications = new OA_CustomerCommunications();
                        EC_AcceptWayByCustomers m_EC_AcceptWayByCustomers = new EC_AcceptWayByCustomers();
 
                        #region 初始合作客户基础信息
 
                        m_OA_CorporateClients.CompanyName = m_Soft_Client.ClientName.ToString2();
                        m_OA_CorporateClients.CustomerIndustriesId = 0;
                        m_OA_CorporateClients.CustomerTypeId = 0;
                        m_OA_CorporateClients.SourcesInfoId = 0;
                        m_OA_CorporateClients.DegreeImportanId = 0;
                        m_OA_CorporateClients.AccountManagerId = 0;
                        m_OA_CorporateClients.BusinessManagerId = 0;
 
                        m_OA_CorporateClients.CreditId = 0;
                        m_OA_CorporateClients.LoginPhone = "";
                        m_OA_CorporateClients.LoginPwd = "";
                        m_OA_CorporateClients.CorporateWebsite = "";
                        m_OA_CorporateClients.BusinessAnalysisId = 0;
                        m_OA_CorporateClients.IsLoginCorporateWeb = false;
                        m_OA_CorporateClients.Credit = 0;
                        m_OA_CorporateClients.Bank = "";
                        m_OA_CorporateClients.TaxID = "";
                        m_OA_CorporateClients.AccountID = "";
                        m_OA_CorporateClients.OutVendorName = CurrentUser.Name;
                        m_OA_CorporateClients.LastUpdateTime = DateTime.Now;
                        m_OA_CorporateClients.Operator = CurrentUser.ShortName;
                        m_OA_CorporateClients.Remark = "来源于软件用户导入";
                        m_OA_CorporateClients.OutRate = 1;
 
                        #endregion
 
                        #region 初始合作客户通讯信息
 
                        m_OA_CustomerCommunications.Province = m_Soft_Client.ClientProvince;
                        m_OA_CustomerCommunications.City = m_Soft_Client.ClientCity;
                        m_OA_CustomerCommunications.County = m_Soft_Client.ClientCountry;
                        m_OA_CustomerCommunications.DetailedAddress = m_Soft_Client.ClientAddress;
                        m_OA_CustomerCommunications.CompanyPhone = m_Soft_Client.ClientPhone;
                        m_OA_CustomerCommunications.Postcode = m_Soft_Client.ClientPostcode;
                        m_OA_CustomerCommunications.Mobile = m_Soft_Client.ClientMobile;
                        m_OA_CustomerCommunications.Fax = "";
                        m_OA_CustomerCommunications.Email = m_Soft_Client.ClientEmail;
                        m_OA_CustomerCommunications.QQ = m_Soft_Client.ClientQQ;
                        m_OA_CustomerCommunications.LegalRepresentative = "";
                        m_OA_CustomerCommunications.LegalMobile = "";
                        m_OA_CustomerCommunications.LegalQQ = "";
                        m_OA_CustomerCommunications.BusinessManagers = "";
                        m_OA_CustomerCommunications.ManagersMobile = "";
                        m_OA_CustomerCommunications.ManagersQQ = "";
                        m_OA_CustomerCommunications.FinancialOfficers = "";
                        m_OA_CustomerCommunications.OfficersMobile = "";
                        m_OA_CustomerCommunications.OfficersQQ = "";
                        m_OA_CustomerCommunications.Remark = "来源于软件用户导入";
                        m_OA_CustomerCommunications.LastUpdateTime = DateTime.Now;
                        m_OA_CustomerCommunications.Operator = CurrentUser.ShortName;
 
                        #endregion
 
                        #region 初始合作客户收货地址
 
                        m_EC_AcceptWayByCustomers.AcceptTypeId = 0;
                        m_EC_AcceptWayByCustomers.InvoiceDemand = "";
                        m_EC_AcceptWayByCustomers.Remark = "";
                        m_EC_AcceptWayByCustomers.LastUpdateTime = DateTime.Now;
                        m_EC_AcceptWayByCustomers.Operator = CurrentUser.ShortName;
 
                        m_EC_AcceptWayByCustomers.City = "";
                        m_EC_AcceptWayByCustomers.Accepter = "";
                        m_EC_AcceptWayByCustomers.AccepterPhone = "";
                        m_EC_AcceptWayByCustomers.AppointCourierCompany = "";
                        m_EC_AcceptWayByCustomers.AccepterAddress = "";
                        m_EC_AcceptWayByCustomers.AccepterPhoneNum = "";
                        m_EC_AcceptWayByCustomers.AcceptContacts = "";
                        m_EC_AcceptWayByCustomers.FetchAddress = "";
                        m_EC_AcceptWayByCustomers.FetchPhoneNum = "";
                        m_EC_AcceptWayByCustomers.FetchContacts = "";
                        m_EC_AcceptWayByCustomers.AppointCourierCompany = "";
 
                        #endregion
 
                        #region 新增操作
 
                        m_OA_CorporateClients.OrderCount = 0;
                        m_OA_CorporateClients.OrderMoney = 0;
                        m_OA_CorporateClients.Prepayments = 0;
                        m_OA_CorporateClients.IsOutsourcing = false;
                        m_OA_CorporateClients.IsPriority = false;
                        m_OA_CorporateClients.CumulativePrepayments = 0;
 
                        m_OA_CorporateClients.Keyid = Guid.NewGuid();
                        m_OA_CorporateClients.CreateTime = DateTime.Now;
                        m_OA_CorporateClients.CustomerId = bll_OA_CorporateClientsBLL.GetLastIdByFirmId(CurrentUser.MemberId) + 1;
                        m_OA_CorporateClients.FirmId = CurrentUser.MemberId;
                        m_OA_CorporateClients.InquiryId = CurrentUser.InquiryId;
                        m_OA_CorporateClients.MemberId = m_OA_CorporateClients.Keyid;
                        m_OA_CustomerCommunications.Keyid = m_OA_CorporateClients.Keyid;
                        m_EC_AcceptWayByCustomers.TargetId = m_OA_CorporateClients.Keyid;
 
                        #endregion
 
                        bool result = bll_OA_CorporateClientsBLL.InsertModel(m_OA_CorporateClients, m_OA_CustomerCommunications, m_EC_AcceptWayByCustomers);//添加信息
                        if (result)
                        {
                            Province = CurrentUser.Province;
                            City = CurrentUser.City;
                            County = CurrentUser.County;
                            JavaScript.MessageBox("导入成功", this, "window.location='/Pages/Soft/ClientList.aspx';");
                        }
                        else
                            JavaScript.MessageBox("导入失败", this, "window.location='/Pages/Soft/ClientList.aspx';");
                    }
                    else
                    {
                        JavaScript.MessageBox("导入失败,已存在此名称的的客户", this, "window.location='/Pages/Soft/ClientList.aspx';");
                    }
                }
            }
        }
 
        //绑定数据
        private void BindList()
        {
            Pagination pa = new Pagination();
            pa.PageSize = UCPager1.AspNetPager.PageSize;
            pa.PageIndex = UCPager1.AspNetPager.CurrentPageIndex;
            this.RepClientList.DataSource = bll_Soft_ClientBLL.SelectModelPage(pa, this.txtClientName.Value, null, "", "", "", Request["selectProvince"].ToString2(), Request["selectCity"].ToString2(), Request["selectCounty"].ToString2(), "", "", null, null, null, Guid.Empty, null, null, null, null, null, null, "");
            this.RepClientList.DataBind();
            UCPager1.AspNetPager.RecordCount = pa.RecordCount;
        }
 
        //分页事件
        protected void AspNetPager1_PageChanged(object src, EventArgs e)
        {
            BindList();
        }
 
        //查询事件
        protected void btn_Search_Click(object src, EventArgs e)
        {
            BindList();
        }
    }
}