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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
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;
using CY.BLL.OA;
 
namespace CY.WebForm.Pages.business
{
    //吴辉
    //商业信函
    public partial class SendAllLetters : BasePage
    {
        OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = null;
        OA_IntentionCustomerBLL bll_OA_IntentionCustomerBLL = null;
        EC_ExSingleTemBLL bll_EC_ExSingleTemBLL = null;
        public int PrintWidth = 0;
        public int PrintHeight = 0;
        public string PrintType = "";
 
        //初始化
        public SendAllLetters()
        {
            bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
            bll_OA_IntentionCustomerBLL = new OA_IntentionCustomerBLL();
            bll_EC_ExSingleTemBLL = new EC_ExSingleTemBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!string.IsNullOrEmpty(Request["s"].ToString2()))
                {
                    switch (Request["s"].ToString2())
                    {
                        case "corporate": //合作客户
                            DataBindCorporate(Request["i"].ToString2());
                            break;
                        case "intention": //意向客户
                            DataBindIntention(Request["i"].ToString2());
                            break;
                        default:
                            break;
                    }
                }
            }
        }
 
        /// <summary>
        /// 绑定合作客户
        /// </summary>
        /// <param name="Keyid"></param>
        public void DataBindCorporate(string Keyid)
        {
            Keyid = Keyid.Trim(',');
            List<OA_CorporateClients> m_OA_CorporateClientsList = bll_OA_CorporateClientsBLL.SelectListListByCustomId(Keyid, CurrentUser.MemberId) as List<OA_CorporateClients>;
            OA_CustomerAccessRecord m_OA_CustomerAccessRecord = new OA_CustomerAccessRecord();
            m_OA_CustomerAccessRecord.AccessContent = "";
            m_OA_CustomerAccessRecord.AccesserId = CurrentUser.StaffId ?? 0;
            m_OA_CustomerAccessRecord.AccessTypeId = 5;
            m_OA_CustomerAccessRecord.CreateTime = DateTime.Now;
            m_OA_CustomerAccessRecord.CustomerId = "";
            m_OA_CustomerAccessRecord.CutomerType = true;
            m_OA_CustomerAccessRecord.EndTime = DateTime.Now;
            m_OA_CustomerAccessRecord.LastUpdateTime = DateTime.Now;
            m_OA_CustomerAccessRecord.Operator = CurrentUser.ShortName;
            m_OA_CustomerAccessRecord.Receiver = "";
            m_OA_CustomerAccessRecord.Remark = CurrentUser.MemberId.ToString2();
            m_OA_CustomerAccessRecord.StartTime = DateTime.Now;
            m_OA_CustomerAccessRecord.StuffId = CurrentUser.StaffId ?? 0;
            m_OA_CustomerAccessRecord.TurnoverIntention = "";
            OA_CustomerAccessRecordBLL bll_OA_CustomerAccessRecordBLL = new OA_CustomerAccessRecordBLL();
            bll_OA_CustomerAccessRecordBLL.InsertModelList(Keyid.ToString2().Trim(',').Split(','), m_OA_CustomerAccessRecord);
            EC_ExSingleTem m_EC_ExSingleTem = bll_EC_ExSingleTemBLL.GetModelByType(Request["p"].ToString2());
            string Printhtml = "";
 
            switch (Request["p"].ToString2())
            {
                case "普通信件":
                    PrintWidth = 2100;
                    PrintHeight = 2970;
                    PrintType = "A4";
                    break;
                case "邮政EMS":
                    PrintWidth = 2080;
                    PrintHeight = 1270;
                    PrintType = "";
                    break;
                case "顺丰快递":
                    PrintWidth = 2310;
                    PrintHeight = 1360;
                    PrintType = "";
                    break;
                case "圆通快递":
                    PrintWidth = 2310;
                    PrintHeight = 1360;
                    PrintType = "";
                    break;
                default:
                    break;
            }
            int i = 0;
            string color = "Red";
            foreach (var item in m_OA_CorporateClientsList)
            {
                OA_CustomerCommunications m_OA_CustomerCommunications = bll_OA_CorporateClientsBLL.GetModel_CustomerCommunications(item.Keyid);
 
                if (Request["p"].ToString2() == "普通信件")
                {
                    if (i % 2 == 0)
                    {
                        Printhtml = Printhtml + "<div style='float:left;width: 760px;border:0px solid #ccc; float: left; display:block;  height: 156px;'>";
                    }
                    Printhtml = Printhtml + "<div style='float:left;width: 375px; float: " + (i % 2 == 0 ? "left" : "right") + "; display:block; height: 130px;'><table width='100%'><tr style=' height:40px;'><td align='left' style=' vertical-align:top;'>" + (string.IsNullOrEmpty(item.Postcode) ? "" : "(" + item.Postcode + ")") + item.Province + item.City.Replace("其他", "") + item.County.Replace("其他", "") + item.DetailedAddress + "</td></tr><tr><td align='left' height='23px'>" + item.CompanyName + "</td></tr><tr><td align='left' height='23px'>" + (string.IsNullOrEmpty(m_OA_CustomerCommunications.LegalRepresentative) ? "" : (m_OA_CustomerCommunications.LegalRepresentative) + "(收)") + (string.IsNullOrEmpty(m_OA_CustomerCommunications.CompanyPhone) ? m_OA_CustomerCommunications.Mobile : m_OA_CustomerCommunications.CompanyPhone) + "</td></tr><tr><td align='right' height='35px;' style='padding-right: 30px;'>印刷品</td></tr></table></div>";
                    if (i % 2 != 0)
                    {
                        Printhtml = Printhtml + "</div>";
                    }
                    i++;
                }
                else
                {
                    if (m_EC_ExSingleTem != null)
                    {
                        //background-image:url('" + m_EC_ExSingleTem.EST_Background + "')
                        Printhtml = Printhtml + "<div class=\"EST_DIV\" style=\"position: relative;float:left; border: 0px solid Red; width: " + m_EC_ExSingleTem.EST_Width + "px; float: left; display:block;height: " + (m_EC_ExSingleTem.EST_Height + 1) + "px;\">" + m_EC_ExSingleTem.EST_Html
                            .Replace("contentEditable", "x")
                            .Replace("background-color: red;", "")
                            .Replace("发-公司名称", CurrentUser.Name)
                            .Replace("发-姓名", Request["d"])
                            .Replace("发-区域", CurrentUser.Province + CurrentUser.City.Replace("其他", "") + CurrentUser.County.Replace("其他", ""))
                            .Replace("发-地址", CurrentMemberExtend.DetailedAddress)
                            .Replace("发-邮编", CurrentMemberExtend.Postcode)
                            .Replace("发-电话手机", string.IsNullOrEmpty(CurrentMemberExtend.PhoneNum) ? CurrentMemberExtend.MobileNum : CurrentMemberExtend.PhoneNum)
                            .Replace("发-电话", CurrentMemberExtend.PhoneNum)
                            .Replace("发-手机", CurrentMemberExtend.MobileNum)
                            .Replace("发-省", CurrentUser.Province)
                            .Replace("发-市", CurrentUser.City.Replace("其他", ""))
                            .Replace("发-区", CurrentUser.County.Replace("其他", ""))
                            .Replace("收-客户名称", item.CompanyName)
                            .Replace("收-姓名", string.IsNullOrEmpty(m_OA_CustomerCommunications.BusinessManagers) ? m_OA_CustomerCommunications.LegalRepresentative : m_OA_CustomerCommunications.BusinessManagers)
                            .Replace("收-区域", m_OA_CustomerCommunications.Province + m_OA_CustomerCommunications.City + m_OA_CustomerCommunications.County.Replace("其他", ""))
                            .Replace("收-地址", item.DetailedAddress)
                            .Replace("收-邮编", m_OA_CustomerCommunications.Postcode)
                            .Replace("收-电话手机", string.IsNullOrEmpty(m_OA_CustomerCommunications.CompanyPhone) ? m_OA_CustomerCommunications.Mobile : m_OA_CustomerCommunications.CompanyPhone)
                            .Replace("收-电话", m_OA_CustomerCommunications.CompanyPhone)
                            .Replace("收-手机", m_OA_CustomerCommunications.Mobile)
                            .Replace("收-省", m_OA_CustomerCommunications.Province)
                            .Replace("收-市", m_OA_CustomerCommunications.City.Replace("其他", ""))
                            .Replace("收-区", m_OA_CustomerCommunications.County.Replace("其他", ""))
                            .Replace("内件品名", Request["h"])
                            .Replace("寄件时间", DateTime.Now.ToString("yyyy年MM月dd").Replace("年", "&nbsp;&nbsp;&nbsp;").Replace("月", "&nbsp;&nbsp;&nbsp;")) + "</div>";
                    }
                }
            }
            this.divPrintHtml.InnerHtml = Printhtml;
        }
 
        /// <summary>
        /// 绑定意向客户
        /// </summary>
        /// <param name="Keyid"></param>
        public void DataBindIntention(string Keyid)
        {
            Keyid = Keyid.Trim(',');
 
            List<OA_IntentionCustomer> m_OA_IntentionCustomerList = bll_OA_IntentionCustomerBLL.SelectListListByCustomId(Keyid, CurrentUser.MemberId) as List<OA_IntentionCustomer>;
 
            OA_CustomerAccessRecord m_OA_CustomerAccessRecord = new OA_CustomerAccessRecord();
            m_OA_CustomerAccessRecord.AccessContent = "";
            m_OA_CustomerAccessRecord.AccesserId = CurrentUser.StaffId ?? 0;
            m_OA_CustomerAccessRecord.AccessTypeId = 5;
            m_OA_CustomerAccessRecord.CreateTime = DateTime.Now;
            m_OA_CustomerAccessRecord.CustomerId = "";
            m_OA_CustomerAccessRecord.CutomerType = false;
            m_OA_CustomerAccessRecord.EndTime = DateTime.Now;
            m_OA_CustomerAccessRecord.LastUpdateTime = DateTime.Now;
            m_OA_CustomerAccessRecord.Operator = CurrentUser.ShortName;
            m_OA_CustomerAccessRecord.Receiver = "";
            m_OA_CustomerAccessRecord.Remark = CurrentUser.MemberId.ToString2();
            m_OA_CustomerAccessRecord.StartTime = DateTime.Now;
            m_OA_CustomerAccessRecord.StuffId = CurrentUser.StaffId ?? 0;
            m_OA_CustomerAccessRecord.TurnoverIntention = "";
            OA_CustomerAccessRecordBLL bll_OA_CustomerAccessRecordBLL = new OA_CustomerAccessRecordBLL();
            bll_OA_CustomerAccessRecordBLL.InsertModelList(Keyid.ToString2().Trim(',').Split(','), m_OA_CustomerAccessRecord);
 
            EC_ExSingleTem m_EC_ExSingleTem = bll_EC_ExSingleTemBLL.GetModelByType(Request["p"].ToString2());
            string Printhtml = "";
            switch (Request["p"].ToString2())
            {
                case "普通信件":
                    PrintWidth = 2100;
                    PrintHeight = 2970;
                    PrintType = "A4";
                    break;
                case "邮政EMS":
                    PrintWidth = 2080;
                    PrintHeight = 1270;
                    PrintType = "";
                    break;
                case "顺丰快递":
                    PrintWidth = 2310;
                    PrintHeight = 1360;
                    PrintType = "";
                    break;
                case "圆通快递":
                    PrintWidth = 2310;
                    PrintHeight = 1360;
                    PrintType = "";
                    break;
                default:
                    break;
            }
            int i = 0;
            foreach (var item in m_OA_IntentionCustomerList)
            {
                if (Request["p"].ToString2() == "普通信件")
                {
                    if (i % 2 == 0)
                    {
                        Printhtml = Printhtml + "<div style='float:left;width: 760px;border:0px solid #ccc; float: left; display:block;  height: 156px;'>";
                    }
                    Printhtml = Printhtml + "<div style='float:left;width: 375px; float: " + (i % 2 == 0 ? "left" : "right") + "; display:block; height: 130px;'><table width='100%'><tr style=' height:40px;'><td align='left' style=' vertical-align:top;'>" + (string.IsNullOrEmpty(item.Postcode) ? "" : "(" + item.Postcode + ")") + item.Province + item.City.Replace("其他", "") + item.County.Replace("其他", "") + item.DetailedAddress + "</td></tr><tr><td align='left' height='23px'>" + item.CompanyName + "</td></tr><tr><td align='left' height='23px'>" + (string.IsNullOrEmpty(item.CompanyOfficers) ? "" : (item.CompanyOfficers) + "(收)") + (string.IsNullOrEmpty(item.PhoneNum) ? item.MobileNum : item.PhoneNum) + "</td></tr><tr><td align='right' height='35px;' style='padding-right: 30px;'>印刷品</td></tr></table></div>";
                    if (i % 2 != 0)
                    {
                        Printhtml = Printhtml + "</div>";
                    }
                    i++;
                }
                else
                {
                    if (m_EC_ExSingleTem != null)
                    {
                        Printhtml = Printhtml + "<div class=\"EST_DIV\" style=\"position: relative;float:left; border: 0px solid #000; width: " + m_EC_ExSingleTem.EST_Width + "px; float: left; display:block;height: " + (m_EC_ExSingleTem.EST_Height + 1) + "px;\">" + m_EC_ExSingleTem.EST_Html
                            .Replace("contentEditable", "x")
                            .Replace("background-color: red;", "")
                            .Replace("发-公司名称", CurrentUser.Name)
                            .Replace("发-姓名", Request["d"])
                            .Replace("发-区域", CurrentUser.Province + CurrentUser.City.Replace("其他", "") + CurrentUser.County.Replace("其他", ""))
                            .Replace("发-地址", CurrentMemberExtend.DetailedAddress)
                            .Replace("发-邮编", CurrentMemberExtend.Postcode)
                            .Replace("发-电话手机", string.IsNullOrEmpty(CurrentMemberExtend.PhoneNum) ? CurrentMemberExtend.MobileNum : CurrentMemberExtend.PhoneNum)
                            .Replace("发-电话", CurrentMemberExtend.PhoneNum)
                            .Replace("发-手机", CurrentMemberExtend.MobileNum)
                            .Replace("发-省", CurrentUser.Province)
                            .Replace("发-市", CurrentUser.City.Replace("其他", ""))
                            .Replace("发-区", CurrentUser.County.Replace("其他", ""))
                            .Replace("收-客户名称", item.CompanyName)
                            .Replace("收-姓名", string.IsNullOrEmpty(item.BusinessManagers) ? item.CompanyOfficers : item.BusinessManagers)
                            .Replace("收-区域", item.Province + item.City.Replace("其他", "") + item.County.Replace("其他", ""))
                            .Replace("收-地址", item.DetailedAddress)
                            .Replace("收-邮编", item.Postcode)
                            .Replace("收-电话手机", string.IsNullOrEmpty(item.PhoneNum) ? item.MobileNum : item.PhoneNum)
                            .Replace("收-电话", item.PhoneNum)
                            .Replace("收-手机", item.MobileNum)
                            .Replace("收-省", item.Province)
                            .Replace("收-市", item.City.Replace("其他", ""))
                            .Replace("收-区", item.County.Replace("其他", ""))
                            .Replace("内件品名", Request["h"])
                            .Replace("寄件时间", DateTime.Now.ToString("yyyy年MM月dd").Replace("年", "&nbsp;&nbsp;&nbsp;").Replace("月", "&nbsp;&nbsp;&nbsp;")) + "</div>";
                    }
                }
            }
            this.divPrintHtml.InnerHtml = Printhtml;
        }
    }
}