username@email.com
2025-01-20 dc7b6c75f98b6924b7e091ee7ac6551470652d78
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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
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.Sys;
using System.Text;
using CY.BLL.OA;
 
namespace CY.WebForm.Pages.business
{
    //吴辉
    //新增/修改合作客户资料
    public partial class AddCorporateClients : BasePage
    {
        OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = null;
        Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;//字典业务逻辑操作类对象
        EC_MemberBasicBLL bll_EC_MemberBasicBLL = null;
        OA_IntentionCustomerBLL bll_OA_IntentionCustomerBLL = null;
        OA_StaffBLL bll_OA_StaffBLL = null;
        public string Province = ""; //接收值 Request["selectProvince"].ToString2();
        public string City = "";//接收值 Request["selectCity"].ToString2();
        public string County = "";//接收值 Request["selectCounty"].ToString2();
        public string Targetid = ""; //收货方式目标值
        public string Shifouwanjie = "";  //完结状态
        public string CorporateClientsid = "";
        public string strNewKeyid = "";
        /// <summary>
        /// 在新建时,保存或者是处理附件时先要生成这个Guid
        /// </summary>
        public Guid NewKeyid{ get; set; }
      
        //初始化
        public AddCorporateClients()
        {
            bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
            bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
            bll_EC_MemberBasicBLL = new EC_MemberBasicBLL();
            bll_OA_IntentionCustomerBLL = new OA_IntentionCustomerBLL();
            bll_OA_StaffBLL = new OA_StaffBLL();
        }
 
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
 
                GetKeyID();
                this.saveKey.Value = NewKeyid.ToString();
          
                Targetid = Request["Keyid"].ToString2();
                CorporateClientsid = Targetid;
                switch (Request["datatype"].ToString2())
                {
                    case "check":
                        if (Request["companyName"] != null && Request["datatype"].ToString2() == "check")
                            Response.Write(BindCompanyList(Request["companyName"].ToString2().Trim()));
                        break;
                    default:
                        if (!IsPostBack)
                        {
                            Province = CurrentUser.Province;
                            City = CurrentUser.City;
                            County = CurrentUser.County;
                            BindData();
                        }
                        return;
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                Response.Clear();
                Response.Write("-1");
            }
            Response.End();
          
        }
 
        //提交事件
        protected void btn_Submit_Config(object sender, EventArgs e)
        {
            OA_CorporateClients m_OA_CorporateClients = new OA_CorporateClients();
            OA_CustomerCommunications m_OA_CustomerCommunications = new OA_CustomerCommunications();
            EC_AcceptWayByCustomers m_EC_AcceptWayByCustomers = new EC_AcceptWayByCustomers();
            if ( this.selSourcesInfoId.Value.ToString() == "452" && string.IsNullOrWhiteSpace(this.txtJigoudaima.Value.ToString()))
            {
                JavaScript.MessageBox("客户来源为政府采购,请填写机构代码", this);
                return;
            }
 
            if (string.IsNullOrEmpty(Request["selectProvince"].ToString2()) || string.IsNullOrEmpty(Request["selectCity"].ToString2()) || string.IsNullOrEmpty(Request["selectCounty"].ToString2()))
            {
                JavaScript.MessageBox("请选择所在区域", this);
                return;
            }
            try
            {
                //var files = Request.Files;
                //for (int iFile = 0; iFile < files.Count; iFile++)
                //{
                //    ///'检查文件扩展名字
                //    HttpPostedFile postedFile = files[iFile];
                //    string fileName, fileExtension;
                //    fileName = System.IO.Path.GetFileName(postedFile.FileName);
                //    if (fileName != "")
                //    {
                //        fileExtension = System.IO.Path.GetExtension(fileName);
                //        //strMsg.Append("上传的文件类型:" + postedFile.ContentType.ToString() + "<br>");
                //        //strMsg.Append("客户端文件地址:" + postedFile.FileName + "<br>");
                //        //strMsg.Append("上传文件的文件名:" + fileName + "<br>");
                //        //strMsg.Append("上传文件的扩展名:" + fileExtension + "<br><hr>");
                //        ///'可根据扩展名字的不同保存到不同的文件夹
                //        ///注意:可能要修改你的文件夹的匿名写入权限。
                //        postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("images/") + fileName);
                //    }
                //}
                    Guid Keyid = Request["Keyid"].ToGuid2();
                bool isExit = bll_OA_CorporateClientsBLL.isExistCompanyName(this.txtCompanyName.Value.ToString2(), CurrentUser.MemberId, Keyid);
                if (!isExit)
                {
                    bool resultxs = bll_OA_IntentionCustomerBLL.isExistCompanyName(this.txtCompanyName.Value.ToString2(), CurrentUser.MemberId, 0);
                    if (resultxs)
                    {
                        JavaScript.MessageBox("此客户已存在于意向客户中,请勿重复添加", this);
                    }
                    else
                    {
 
                        if (Request["Keyid"] != null)
                        {
                            m_OA_CorporateClients = bll_OA_CorporateClientsBLL.GetModel(Request["Keyid"].ToGuid2());
                            m_OA_CustomerCommunications = bll_OA_CorporateClientsBLL.GetModel_CustomerCommunications(Request["Keyid"].ToGuid2());
                            m_EC_AcceptWayByCustomers = bll_OA_CorporateClientsBLL.GetModel_AcceptWayByCustomers(Request["Keyid"].ToGuid2());
                            if (m_EC_AcceptWayByCustomers == null)
                            {
                                m_EC_AcceptWayByCustomers = new EC_AcceptWayByCustomers();
                            }
                        }
 
                        #region 初始合作客户基础信息
                        m_OA_CorporateClients.CompanyName = this.txtCompanyName.Value.ToString2(); 
                        m_OA_CorporateClients.CustomerIndustriesId = this.selCustomerIndustriesId.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.CustomerTypeId = this.selCustomerTypeId.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.SourcesInfoId = this.selSourcesInfoId.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.DegreeImportanId = this.selDegreeImportanId.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.AccountManagerId = this.selAccountManagerId.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.BusinessManagerId = this.selBusinessManagerId.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.Shifouwanjie = 2;
 
                        //add by zyyao
                        m_OA_CorporateClients.Paytime = this.selPaytime.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.Paydays = this.txtPaydays.Value.ToInt32() ?? 0;
 
                        m_OA_CorporateClients.Biddingcompany = this.selBiddingcompany.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.Contracttype = this.selContracttype.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.Contractmoney = this.txtContractmoney.Value.ToDecimal2() ?? 0;
                        m_OA_CorporateClients.ExpireTime = this.txtExpireTime.Value.ToDateTime2() ?? null;
                        m_OA_CorporateClients.Expiretype = this.selExpiretype.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.Jigoudaima = this.txtJigoudaima.Value.ToString();
                        m_OA_CorporateClients.Piaoju = this.selPiaoju.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.Kaipiaoziliao = this.txtKaipiaoziliao.Value.ToString();
                        m_OA_CorporateClients.Shifouwanjie = 2;
                        m_OA_CorporateClients.Note = this.txtNote.Value.ToString();
 
                        m_OA_CorporateClients.CreditId = this.selCreditId.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.LoginPhone = this.txtLoginPhone.Value.ToString2();
                        m_OA_CorporateClients.LoginPwd = this.txtPassWord.Value.ToString2();
                        m_OA_CorporateClients.CorporateWebsite = this.txtCorporateWebsite.Value.ToString2();
                        m_OA_CorporateClients.BusinessAnalysisId = this.selBusinessAnalysisId.Value.ToInt32() ?? 0;
                        m_OA_CorporateClients.IsLoginCorporateWeb = this.selIsLoginCorporateWeb.Value.ToBoolean2();
                        m_OA_CorporateClients.Credit = this.txtCredit.Value.ToDecimal2() ?? 0;
                        m_OA_CorporateClients.Bank = this.txtBank.Value.ToString2();
                        m_OA_CorporateClients.TaxID = this.txtTaxID.Value.ToString2();
                        m_OA_CorporateClients.AccountID = this.txtAccountID.Value.ToString2();
                        m_OA_CorporateClients.OutVendorName = CurrentUser.Name;
                        m_OA_CorporateClients.LastUpdateTime = DateTime.Now;
                        m_OA_CorporateClients.Operator = CurrentUser.ShortName;
                        m_OA_CorporateClients.Remark = this.txtRemark.InnerText.ToString2();
                        m_OA_CorporateClients.OutRate =1;
                        #endregion
 
                        #region 初始合作客户通讯信息
                        m_OA_CustomerCommunications.Province = Request["selectProvince"].ToString2();
                        m_OA_CustomerCommunications.City = Request["selectCity"].ToString2();
                        m_OA_CustomerCommunications.County = Request["selectCounty"].ToString2();
                        m_OA_CustomerCommunications.DetailedAddress = this.txtDetailedAddress.Value.ToString2();
                        m_OA_CustomerCommunications.CompanyPhone = this.txtCompanyPhone.Value.ToString2();
                        m_OA_CustomerCommunications.Postcode = this.txtPostcode.Value.ToString2();
                        m_OA_CustomerCommunications.Mobile = this.txtMobile.Value.ToString2();
                        m_OA_CustomerCommunications.Fax = this.txtFax.Value.ToString2();
                        m_OA_CustomerCommunications.Email = this.txtEmail.Value.ToString2();
                        m_OA_CustomerCommunications.QQ = this.txtQQ.Value.ToString2();
                        m_OA_CustomerCommunications.LegalRepresentative = this.txtLegalRepresentative.Value.ToString2();
                        m_OA_CustomerCommunications.LegalMobile = this.txtLegalMobile.Value.ToString2();
                        m_OA_CustomerCommunications.LegalQQ = this.txtLegalQQ.Value.ToString2();
                        m_OA_CustomerCommunications.BusinessManagers = this.txtBusinessManagers.Value.ToString2();
                        m_OA_CustomerCommunications.ManagersMobile = this.txtManagersMobile.Value.ToString2();
                        m_OA_CustomerCommunications.ManagersQQ = this.txtManagersQQ.Value.ToString2();
                        m_OA_CustomerCommunications.FinancialOfficers = this.txtFinancialOfficers.Value.ToString2();
                        m_OA_CustomerCommunications.OfficersMobile = this.txtOfficersMobile.Value.ToString2();
                        m_OA_CustomerCommunications.OfficersQQ = this.txtOfficersQQ.Value.ToString2();
                        m_OA_CustomerCommunications.Remark = "";
                        m_OA_CustomerCommunications.LastUpdateTime = DateTime.Now;
                        m_OA_CustomerCommunications.Operator = CurrentUser.ShortName;
                        #endregion
 
                        #region 初始合作客户收货地址
                        m_EC_AcceptWayByCustomers.AcceptTypeId = Request["AcceptTypeId"].ToInt32();
                        m_EC_AcceptWayByCustomers.InvoiceDemand = Request["InvoiceId"].ToString2();
                        m_EC_AcceptWayByCustomers.Remark = Request["Remark"].ToString2();
                        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 = Request["AccepterAddress_HomeDelivery"].ToString2() ?? Request["selectProvince"].ToString2() + Request["selectCity"].ToString2() + Request["selectCounty"].ToString2() + this.txtDetailedAddress.Value.ToString2();
                        m_EC_AcceptWayByCustomers.AccepterPhoneNum = "";
                        m_EC_AcceptWayByCustomers.AcceptContacts = "";
                        m_EC_AcceptWayByCustomers.FetchAddress = "";
                        m_EC_AcceptWayByCustomers.FetchPhoneNum = "";
                        m_EC_AcceptWayByCustomers.FetchContacts = "";
                        m_EC_AcceptWayByCustomers.AppointCourierCompany = "";
 
                        string ReceiptType = bll_Sys_DictionaryBLL.GetModelByKeyid(Request["AcceptTypeId"].ToInt32());
                        switch (ReceiptType)
                        {
                            case "自提":
                                break;
                            case "代发货运":
                                m_EC_AcceptWayByCustomers.City = Request["City_OnBehalfOfCargo"].ToString2();
                                m_EC_AcceptWayByCustomers.Accepter = Request["Accepter_OnBehalfOfCargo"].ToString2();
                                m_EC_AcceptWayByCustomers.AccepterPhone = Request["AccepterPhone_OnBehalfOfCargo"].ToString2();
                                break;
                            case "送货上门":
                                m_EC_AcceptWayByCustomers.City = Request["City_HomeDelivery"].ToString2();
                                m_EC_AcceptWayByCustomers.Accepter = Request["Accepter_HomeDelivery"].ToString2();
                                m_EC_AcceptWayByCustomers.AccepterPhone = Request["AccepterPhone_HomeDelivery"].ToString2();
                                break;
                            case "指定货运公司":
                                m_EC_AcceptWayByCustomers.City = Request["City_OfficialFreightForwarder"].ToString2();
                                m_EC_AcceptWayByCustomers.Accepter = Request["Accepter_OfficialFreightForwarder"].ToString2();
                                m_EC_AcceptWayByCustomers.AccepterPhone = Request["AccepterPhone_OfficialFreightForwarder"].ToString2();
                                m_EC_AcceptWayByCustomers.AppointCourierCompany = Request["AppointCourierCompany"].ToString2();
                                m_EC_AcceptWayByCustomers.AccepterAddress = Request["AccepterAddress"].ToString2();
                                m_EC_AcceptWayByCustomers.AccepterPhoneNum = Request["AccepterPhoneNum"].ToString2();
                                m_EC_AcceptWayByCustomers.AcceptContacts = Request["AcceptContacts"].ToString2();
                                m_EC_AcceptWayByCustomers.FetchAddress = Request["FetchAddress"].ToString2();
                                m_EC_AcceptWayByCustomers.FetchPhoneNum = Request["FetchPhoneNum"].ToString2();
                                m_EC_AcceptWayByCustomers.FetchContacts = Request["FetchContacts"].ToString2();
                                m_EC_AcceptWayByCustomers.AppointCourierCompany = Request["AppointCourierCompany"].ToString2();
                                break;
                            default:
                                break;
                        }
                        #endregion
 
                        #region 添加或编辑
 
                        if (Request["Keyid"] != null)
                        {
                            bool result = bll_OA_CorporateClientsBLL.UpdateModel(m_OA_CorporateClients, m_OA_CustomerCommunications, m_EC_AcceptWayByCustomers);//更新信息
                            if (result)
                                JavaScript.MessageBox("更新成功", this, true, true);
                            else
                                JavaScript.MessageBox("更新失败", this);
                            
                        }
                        else
                        {
                            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 = new Guid( this.saveKey.Value);// Guid.NewGuid();//GetKeyID();
                            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;
                            if (this.txtHideMemberType.Value == "网站会员")
                            {
                                m_OA_CorporateClients.MemberId = this.txtHideMemberId.Value.ToGuid2();
                            }
                            else
                            {
                                m_OA_CorporateClients.MemberId = m_OA_CorporateClients.Keyid;
                            }
                            m_OA_CustomerCommunications.Keyid = m_OA_CorporateClients.Keyid;
                            m_EC_AcceptWayByCustomers.TargetId = m_OA_CorporateClients.Keyid;
 
                            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;
                                if (Request["src"] == "order")
                                {
                                    JavaScript.MessageBox("添加成功", this, "top.document.getElementById('frmright').contentWindow.ReBindClients();top.Dialog.close();");
                                }
                                else
                                {
                                    JavaScript.MessageBox("添加成功", this, false, true);
                                    BindData();
                                }
                            }
                            else
                                JavaScript.MessageBox("添加失败", this);
                        }
                        #endregion
                    }
                }
                else
                {
                    JavaScript.MessageBox("此客户已存在,请勿重复添加", this);
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
 
 
        //完结事件
        protected void btn_Submit_Wanjie(object sender, EventArgs e)
        {
            OA_CorporateClients m_OA_CorporateClients = new OA_CorporateClients();
           
 
            try
            {
                Guid Keyid = Request["Keyid"].ToGuid2();
 
 
 
 
                if (Request["Keyid"] != null)
                {
                    m_OA_CorporateClients = bll_OA_CorporateClientsBLL.GetModel(Request["Keyid"].ToGuid2());
                    
                }
                else
                {
                    JavaScript.MessageBox("请先保存客户", this);
                }
 
                m_OA_CorporateClients.Shifouwanjie = 1;
 
                m_OA_CorporateClients.LastUpdateTime = DateTime.Now;
 
 
 
 
                        #region 添加或编辑
 
                         
                            bool result = bll_OA_CorporateClientsBLL.UpdateModel(m_OA_CorporateClients);//更新信息
                            if (result)
                                JavaScript.MessageBox("完结成功", this, true, true);
                            else
                                JavaScript.MessageBox("完结失败", this);
                    
                        #endregion
                
                 
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
 
 
 
        //完结事件
        protected void btn_Submit_chongxinkaitong(object sender, EventArgs e)
        {
            OA_CorporateClients m_OA_CorporateClients = new OA_CorporateClients();
 
 
            try
            {
                Guid Keyid = Request["Keyid"].ToGuid2();
 
 
 
 
                if (Request["Keyid"] != null)
                {
                    m_OA_CorporateClients = bll_OA_CorporateClientsBLL.GetModel(Request["Keyid"].ToGuid2());
 
                }
                else
                {
                    JavaScript.MessageBox("请先保存客户", this);
                }
 
                m_OA_CorporateClients.Shifouwanjie = 2;
 
                m_OA_CorporateClients.LastUpdateTime = DateTime.Now;
 
 
 
 
                #region 添加或编辑
 
 
                bool result = bll_OA_CorporateClientsBLL.UpdateModel(m_OA_CorporateClients);//更新信息
                if (result)
                    JavaScript.MessageBox("完结成功", this, true, true);
                else
                    JavaScript.MessageBox("完结失败", this);
 
                #endregion
 
 
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
        ////完结事件
        //protected void btn_Submit_Visit(object sender, EventArgs e)
        //{
        //    OA_CorporateClientsVisit m_OA_CorporateClientsVisit = new OA_CorporateClientsVisit();
 
 
        //    try
        //    {
        //        Guid Keyid = Request["Keyid"].ToGuid2();
 
 
 
 
        //        if (Request["Keyid"] != null)
        //        {
 
 
        //        }
        //        else
        //        {
        //            JavaScript.MessageBox("请先保存客户", this);
        //        }
 
        //        if (this.txtVisitTime.Value == "")
        //        {
        //            JavaScript.MessageBox("请选择日期", this);
 
        //        }
        //        if (this.txtVisitTime.Value == "")
        //        {
        //            JavaScript.MessageBox("请填写维护记录", this);
 
        //        }
 
        //        m_OA_CorporateClientsVisit.Keyid = Guid.NewGuid();
 
 
        //        m_OA_CorporateClientsVisit.CorporateClientsid = Keyid;
 
        //        m_OA_CorporateClientsVisit.VisitTime = this.txtVisitTime.Value.ToDateTime2();
 
        //        m_OA_CorporateClientsVisit.Remark = this.txtvisitRemark.Value.ToString2();
        //        m_OA_CorporateClientsVisit.Creater = CurrentUser.TrueMemberId;
        //        m_OA_CorporateClientsVisit.CreateTime = DateTime.Now;
        //        m_OA_CorporateClientsVisit.Updater = CurrentUser.TrueMemberId;
        //        m_OA_CorporateClientsVisit.LastUpdateTime = DateTime.Now;
 
 
        //        #region 添加或编辑
 
 
        //        bool result = bll_OA_CorporateClientsBLL.InsertModelVisit(m_OA_CorporateClientsVisit);//更新信息
 
        //        if (result)
        //        {
        //            //this.RepClientList.DataSource = bll_OA_CorporateClientsBLL.SelectVisitListByCorId(Keyid);
        //            //this.RepClientList.DataBind();
        //            this.txtVisitTime.Value = "";
        //            this.txtvisitRemark.Value = "";
        //            JavaScript.MessageBox("维护保存成功", this, false, false);
        //        }
 
        //        else
        //            JavaScript.MessageBox("维护保存失败", this);
 
        //        Province = CurrentUser.Province;
        //        City = CurrentUser.City;
        //        County = CurrentUser.County;
        //        BindData();
        //        #endregion
 
 
        //    }
        //    catch (Exception ex)
        //    {
        //        PAGEHandleException(ex);
        //        JavaScript.MessageBox("操作失败", this);
        //    }
        //}
 
        //绑定数据
        protected void BindData()
        {
            #region 初始字典表数据
 
            this.selSourcesInfoId.DataSource = bll_Sys_DictionaryBLL.GetDataByType("客户来源");
            this.selSourcesInfoId.DataValueField = "Keyid";
            this.selSourcesInfoId.DataTextField = "Name";
            this.selSourcesInfoId.DataBind();
            this.selSourcesInfoId.Value = "452";
 
            this.selCustomerIndustriesId.DataSource = bll_Sys_DictionaryBLL.GetDataByType("客户所属行业");
            this.selCustomerIndustriesId.DataValueField = "Keyid";
            this.selCustomerIndustriesId.DataTextField = "Name";
            this.selCustomerIndustriesId.DataBind();
 
            this.selCustomerIndustriesId.Value = "454";
 
            this.selCustomerTypeId.DataSource = bll_Sys_DictionaryBLL.GetDataByType("客户类型");
            this.selCustomerTypeId.DataValueField = "Keyid";
            this.selCustomerTypeId.DataTextField = "Name";
            this.selCustomerTypeId.DataBind();
 
            this.selBusinessManagerId.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, true, false);
            this.selBusinessManagerId.DataTextField = "Name";
            this.selBusinessManagerId.DataValueField = "Keyid";
            this.selBusinessManagerId.DataBind();
            this.selBusinessManagerId.Items.Insert(0, new ListItem("请选择", ""));
 
            this.selBusinessManagerId.Value = CurrentUser.StaffId.Value.ToString();
 
            this.selAccountManagerId.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, false, true);
            this.selAccountManagerId.DataTextField = "Name";
            this.selAccountManagerId.DataValueField = "Keyid";
            this.selAccountManagerId.DataBind();
            this.selAccountManagerId.Items.Insert(0, new ListItem("请选择", ""));
 
            this.selAccountManagerId.Value = CurrentUser.StaffId.Value.ToString();
 
            this.selCreditId.DataSource = bll_Sys_DictionaryBLL.GetDataByType("客户信誉");
            this.selCreditId.DataValueField = "Keyid";
            this.selCreditId.DataTextField = "Name";
            this.selCreditId.DataBind();
            this.selCreditId.Value = "76";
 
            this.selDegreeImportanId.DataSource = bll_Sys_DictionaryBLL.GetDataByType("客户重要程度");
            this.selDegreeImportanId.DataValueField = "Keyid";
            this.selDegreeImportanId.DataTextField = "Name";
            this.selDegreeImportanId.DataBind();
 
            this.selBusinessAnalysisId.DataSource = bll_Sys_DictionaryBLL.GetDataByType("客户业务分析量");
            this.selBusinessAnalysisId.DataValueField = "Keyid";
            this.selBusinessAnalysisId.DataTextField = "Name";
            this.selBusinessAnalysisId.DataBind();
            this.selBusinessAnalysisId.Value = "83";
 
            //add by zyyao
            this.selPaytime.DataSource = bll_Sys_DictionaryBLL.GetDataByType("付款时间");
            this.selPaytime.DataValueField = "MeanValue";
            this.selPaytime.DataTextField = "Name";
            this.selPaytime.DataBind();
 
            this.selBiddingcompany.DataSource = bll_OA_CorporateClientsBLL.SelectBiddingcompanyByFirmId(CurrentUser.MemberId);
            this.selBiddingcompany.DataValueField = "Keyid1";
            this.selBiddingcompany.DataTextField = "CompanyName";
            this.selBiddingcompany.DataBind();
 
            this.selContracttype.DataSource = bll_Sys_DictionaryBLL.GetDataByType("合同金额");
            this.selContracttype.DataValueField = "MeanValue";
            this.selContracttype.DataTextField = "Name";
            this.selContracttype.DataBind();
 
            this.selExpiretype.DataSource = bll_Sys_DictionaryBLL.GetDataByType("到期时间");
            this.selExpiretype.DataValueField = "MeanValue";
            this.selExpiretype.DataTextField = "Name";
            this.selExpiretype.DataBind();
 
            this.selPiaoju.DataSource = bll_Sys_DictionaryBLL.GetDataByType("票据");
            this.selPiaoju.DataValueField = "MeanValue";
            this.selPiaoju.DataTextField = "Name";
            this.selPiaoju.DataBind();
 
            this.selShifouwanjie.DataSource = bll_Sys_DictionaryBLL.GetDataByType("客户完结状态").OrderByDescending(x=>x.MeanValue);
            this.selShifouwanjie.DataValueField = "MeanValue";
            this.selShifouwanjie.DataTextField = "Name";
            this.selShifouwanjie.DataBind();
            
            #endregion
 
            if (Request["Keyid"] != null)
            {
                OA_CorporateClients m_OA_CorporateClients = bll_OA_CorporateClientsBLL.GetModel(Request["Keyid"].ToGuid2());
                OA_CustomerCommunications m_OA_CustomerCommunications = bll_OA_CorporateClientsBLL.GetModel_CustomerCommunications(Request["Keyid"].ToGuid2());
                EC_AcceptWayByCustomers m_EC_AcceptWayByCustomers = bll_OA_CorporateClientsBLL.GetModel_AcceptWayByCustomers(Request["Keyid"].ToGuid2());
 
                #region 页面初始合作客户基础信息
 
                this.selSourcesInfoId.Value = m_OA_CorporateClients.SourcesInfoId.ToString2();
                this.selCustomerIndustriesId.Value = m_OA_CorporateClients.CustomerIndustriesId.ToString2();
                this.selCustomerTypeId.Value = m_OA_CorporateClients.CustomerTypeId.ToString2();
                this.selBusinessManagerId.Value = m_OA_CorporateClients.BusinessManagerId.ToString2()=="0"?"": m_OA_CorporateClients.BusinessManagerId.ToString2();
                this.selAccountManagerId.Value = m_OA_CorporateClients.AccountManagerId.ToString2() == "0" ? "" : m_OA_CorporateClients.AccountManagerId.ToString2();
                this.selDegreeImportanId.Value = m_OA_CorporateClients.DegreeImportanId.ToString2();
                this.selBusinessAnalysisId.Value = m_OA_CorporateClients.BusinessAnalysisId.ToString2();
                this.selIsLoginCorporateWeb.Value = m_OA_CorporateClients.IsLoginCorporateWeb.ToString2();
 
                //add by zyyao
                this.selPaytime.Value = m_OA_CorporateClients.Paytime.ToString2();
                this.txtPaydays.Value = m_OA_CorporateClients.Paydays.ToString2();
                this.selBiddingcompany.Value = m_OA_CorporateClients.Biddingcompany.ToString2();
                this.selContracttype.Value = m_OA_CorporateClients.Contracttype.ToString2();
                this.txtContractmoney.Value = m_OA_CorporateClients.Contractmoney.ToDecimal2Yen();
                this.txtExpireTime.Value = m_OA_CorporateClients.ExpireTime==null?"": m_OA_CorporateClients.ExpireTime.Value.ToString("yyyy-MM-dd");
                this.selExpiretype.Value = m_OA_CorporateClients.Expiretype.ToString2();
                this.txtJigoudaima.Value = m_OA_CorporateClients.Jigoudaima.ToString2();
                this.selPiaoju.Value = m_OA_CorporateClients.Piaoju.ToString2();
                this.txtKaipiaoziliao.Value = m_OA_CorporateClients.Kaipiaoziliao.ToString2();
                this.selShifouwanjie.Value = m_OA_CorporateClients.Shifouwanjie.ToString2();
                Shifouwanjie = m_OA_CorporateClients.Shifouwanjie.ToString2();
                this.txtNote.Value = m_OA_CorporateClients.Note.ToString2();
                this.selCreditId.Value = m_OA_CorporateClients.CreditId.ToString2();
                this.txtCompanyName.Value = m_OA_CorporateClients.CompanyName.ToString2();
                this.txtCorporateWebsite.Value = m_OA_CorporateClients.CorporateWebsite.ToString2();
                this.txtCredit.Value = m_OA_CorporateClients.Credit.ToString2().ToDecimal2Yen();
                this.txtLoginPhone.Value = m_OA_CorporateClients.LoginPhone.ToString2();
                this.txtBank.Value = m_OA_CorporateClients.Bank.ToString2();
                this.txtTaxID.Value = m_OA_CorporateClients.TaxID.ToString2();
                this.txtAccountID.Value = m_OA_CorporateClients.AccountID.ToString2();
                this.txtRemark.InnerText = m_OA_CorporateClients.Remark.ToString2();
                this.txtPassWord.Value = m_OA_CorporateClients.LoginPwd.ToString2();
                #endregion
 
                #region 页面初始合作客户通讯信息
 
                this.txtDetailedAddress.Value = m_OA_CustomerCommunications.DetailedAddress.ToString2();
                this.txtCompanyPhone.Value = m_OA_CustomerCommunications.CompanyPhone.ToString2();
                this.txtPostcode.Value = m_OA_CustomerCommunications.Postcode.ToString2();
                this.txtMobile.Value = m_OA_CustomerCommunications.Mobile.ToString2();
                this.txtFax.Value = m_OA_CustomerCommunications.Fax.ToString2();
                this.txtEmail.Value = m_OA_CustomerCommunications.Email.ToString2();
                this.txtQQ.Value = m_OA_CustomerCommunications.QQ.ToString2();
                this.txtLegalRepresentative.Value = m_OA_CustomerCommunications.LegalRepresentative.ToString2();
                this.txtLegalMobile.Value = m_OA_CustomerCommunications.LegalMobile.ToString2();
                this.txtLegalQQ.Value = m_OA_CustomerCommunications.LegalQQ.ToString2();
                this.txtBusinessManagers.Value = m_OA_CustomerCommunications.BusinessManagers.ToString2();
                this.txtManagersMobile.Value = m_OA_CustomerCommunications.ManagersMobile.ToString2();
                this.txtManagersQQ.Value = m_OA_CustomerCommunications.ManagersQQ.ToString2();
                this.txtFinancialOfficers.Value = m_OA_CustomerCommunications.FinancialOfficers.ToString2();
                this.txtOfficersMobile.Value = m_OA_CustomerCommunications.OfficersMobile.ToString2();
                this.txtOfficersQQ.Value = m_OA_CustomerCommunications.OfficersQQ.ToString2();
 
                Province = m_OA_CustomerCommunications.Province.ToString2();
                City = m_OA_CustomerCommunications.City.ToString2();
                County = m_OA_CustomerCommunications.County.ToString2();
 
                #endregion
 
 
                //this.RepClientList.DataSource = bll_OA_CorporateClientsBLL.SelectVisitListByCorId(Request["Keyid"].ToGuid2());
                //this.RepClientList.DataBind();
 
                this.Repeater1.DataSource = bll_OA_CorporateClientsBLL.SelectPrintListByCorId(Request["Keyid"].ToGuid2());
                this.Repeater1.DataBind();
                
            }
            else
            {
 
                #region 页面初始合作客户基础信息
 
                this.selIsLoginCorporateWeb.Value = "";
                this.txtCompanyName.Value = "";
                this.txtCorporateWebsite.Value = "";
                this.txtCredit.Value = "0";
                this.txtLoginPhone.Value = "";
                this.txtBank.Value = "";
                this.txtTaxID.Value = "";
                this.txtAccountID.Value = "";
                this.txtRemark.InnerText = "";
                this.txtPassWord.Value = "";
 
                #endregion
 
                #region 页面初始合作客户通讯信息
 
                this.txtDetailedAddress.Value = "";
                this.txtCompanyPhone.Value = "";
                this.txtPostcode.Value = "";
                this.txtMobile.Value = "";
                this.txtFax.Value = "";
                this.txtEmail.Value = "";
                this.txtQQ.Value = "";
                this.txtLegalRepresentative.Value = "";
                this.txtLegalMobile.Value = "";
                this.txtLegalQQ.Value = "";
                this.txtBusinessManagers.Value = "";
                this.txtManagersMobile.Value = "";
                this.txtManagersQQ.Value = "";
                this.txtFinancialOfficers.Value = "";
                this.txtOfficersMobile.Value = "";
                this.txtOfficersQQ.Value = "";
                Shifouwanjie = "3";
 
                #endregion
 
                //this.RepClientList.DataSource = null;
                //this.RepClientList.DataBind();
            }
        }
 
        //绑定关联会员列表以及意向客户列表
        protected string BindCompanyList(string companyname)
        {
            Guid Keyid = Request["Keyid"].ToGuid2();
 
            bool isExit = bll_OA_CorporateClientsBLL.isExistCompanyName(companyname, CurrentUser.MemberId, Keyid);
            if (isExit)
                return "0";
 
            if (Request["xs"].ToString2() == "blur")
            {
                bool resultxs = bll_OA_IntentionCustomerBLL.isExistCompanyName(Request["companyname"].ToString2(), CurrentUser.MemberId, 0);
                if (resultxs)
                    return "1";
                else
                    return "2";
            }
            else
            {
 
                List<OA_IntentionCustomer> m_OA_IntentionCustomerList = bll_OA_IntentionCustomerBLL.SelectListByName(companyname, CurrentUser.MemberId) as List<OA_IntentionCustomer>;
 
                string[] modelArry = new string[m_OA_IntentionCustomerList.Count];
                int i = 0;
 
                foreach (var item in m_OA_IntentionCustomerList)
                {
                    string result = "";
                    StringBuilder sb_html = new StringBuilder();
 
                    sb_html.AppendFormat("CustormType:'{0}',", "意向客户");
                    sb_html.AppendFormat("CustormKeyId:'{0}',", item.Keyid);
                    sb_html.AppendFormat("CustormName:'{0}',", item.CompanyName);
                    sb_html.AppendFormat("CustormAddress:'{0}',", item.DetailedAddress);
                    sb_html.AppendFormat("CustormPhone:'{0}',", item.PhoneNum);
                    sb_html.AppendFormat("CustormMobile:'{0}',", item.MobileNum);
                    sb_html.AppendFormat("CustormFax:'{0}',", "");
                    sb_html.AppendFormat("CustormQQ:'{0}',", item.QQ);
                    sb_html.AppendFormat("CustormEmail:'{0}',", item.Email);
                    sb_html.AppendFormat("CustormPostCode:'{0}',", item.Postcode);
                    sb_html.AppendFormat("CustormWeb:'{0}'", "");
 
                    result = "{" + sb_html.ToString() + "}";
                    modelArry[i] = result;
                    i++;
                }
                return ("[" + string.Join(",", modelArry) + "]");
            }
        }
        /// <summary>
        /// 获取Guid
        /// </summary>
        /// <returns></returns>
        public Guid GetKeyID()
        {
            if (NewKeyid != null && NewKeyid != new Guid("00000000-0000-0000-0000-000000000000"))
            {
                strNewKeyid = NewKeyid.ToString();
                return NewKeyid;
            }
 
            if (Request["Keyid"] != null)
            {
                NewKeyid = Request["Keyid"].ToGuid2();
                //  this.SaveNewKeyID.Value = NewKeyid.ToString();
                strNewKeyid = NewKeyid.ToString();
                return NewKeyid;
            }
           
 
            if (this.saveKey.Value == "")
            {
                NewKeyid = Guid.NewGuid();
                this.saveKey.Value = NewKeyid.ToString();
                return NewKeyid;
            }
            else
            {
                NewKeyid = new Guid(this.saveKey.Value);
                return NewKeyid;
            }
 
        }
 
        //CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult1 = CY.WebForm.cs.UploadCS.Upload(
 
        //提交事件
        protected void btn_SubmitClientsBiddingcompany_Config(object sender, EventArgs e)
        {
            OA_CorporateClients m_OA_CorporateClients = new OA_CorporateClients();
           
 
            try
            {
                if (string.IsNullOrWhiteSpace(this.txtBiddingcompany.Value))
                {
                    JavaScript.MessageBox("请填写中标单位", this);
                     
                }
 
                string Biddingcompany = this.txtBiddingcompany.Value.Trim();
               
 
                       OA_CorporateClients  oA_CorporateClients = bll_OA_CorporateClientsBLL.SelectBiddingcompanyByFirmId(CurrentUser.MemberId).Where(x=>x.CompanyName== Biddingcompany).FirstOrDefault();
                if (oA_CorporateClients==null)
                {
                    m_OA_CorporateClients.FirmId = CurrentUser.MemberId;
                    m_OA_CorporateClients.CompanyName = Biddingcompany;
                    m_OA_CorporateClients.CreateTime = DateTime.Now;
 
                            bool result = bll_OA_CorporateClientsBLL.InsertModelBiddingcompany(m_OA_CorporateClients);//添加信息
                    if (result)
                    {
 
                        JavaScript.MessageBox("添加成功", this);
                        this.selBiddingcompany.DataSource = bll_OA_CorporateClientsBLL.SelectBiddingcompanyByFirmId(CurrentUser.MemberId);
                        this.selBiddingcompany.DataValueField = "Keyid1";
                        this.selBiddingcompany.DataTextField = "CompanyName";
                        this.selBiddingcompany.DataBind();
                        
                    }
                    else
                    {
                        JavaScript.MessageBox("添加失败", this);
                       
                    }
                      
 
 
                }
                else
                {
                    JavaScript.MessageBox("此中标单位已存在,请勿重复添加", this);
                }
                Province = CurrentUser.Province;
                City = CurrentUser.City;
                County = CurrentUser.County;
                BindData();
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
            }
        }
    }
}