username@email.com
2024-12-18 21a248a0cf76b6f05fcaac6f90975ef15ab607a1
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
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 CY.BLL.OA;
using System.Collections;
using System.Data;
 
namespace CY.WebForm.Pages.procurement
{
    public partial class SuppliersEdit : BasePage
    {
 
        Sys_DictionaryBLL _Sys_DictionaryBLL = null;
        OA_Suppliers supplier = null;
        OA_SuppliersBLL _OA_SuppliersBLL = null;
        OA_BrandBLL _OA_BrandBLL = null;
        OA_SuppliersOtherQualificationBLL _OA_SuppliersOtherQualificationBLL = null;
        public string[] Fileds;
 
        public SuppliersEdit()
        {
            _OA_SuppliersOtherQualificationBLL = new OA_SuppliersOtherQualificationBLL();
            _OA_BrandBLL = new OA_BrandBLL();
            _Sys_DictionaryBLL = new Sys_DictionaryBLL();
            supplier = new OA_Suppliers();
            _OA_SuppliersBLL = new OA_SuppliersBLL();
 
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                InitialSelData();
                if (Request["Keyid"].ToInt32() > 0)
                    InitialSuplier();
            }
 
        }
 
        //初始化下拉列表中的值   
        protected void InitialSelData()
        {
            this.txtOrderNum.Value = _OA_BrandBLL.GetMaxOrderNum(CurrentUser.MemberId, "OA_Suppliers");
            selCooperativeStateId.DataSource = _Sys_DictionaryBLL.GetDataByType("供应商合作状态");
            selCooperativeStateId.DataBind();
            selSuppliersLevelId.DataSource = _Sys_DictionaryBLL.GetDataByType("供应商级别");
            selSuppliersLevelId.DataBind();
            selSuppliersTypeId.DataSource = _Sys_DictionaryBLL.GetDataByType("供应商类别 ").OrderBy(x=>x.LastUpdateTime);
            selSuppliersTypeId.DataBind();
        }
 
        /// <summary>
        /// 如果是修改/则加载要修改的数据
        /// </summary>
        protected void InitialSuplier()
        {
            supplier = _OA_SuppliersBLL.getSingleSupplier(Request["Keyid"].ToString2());
            this.selCooperativeStateId.Value = supplier.CooperativeStateId.ToString2();
            this.selSuppliersLevelId.Value = supplier.SuppliersLevelId.ToString2();
            this.selSuppliersTypeId.Value = supplier.SuppliersTypeId.ToString2();
            this.txtBusinessLicenseNum.Value = supplier.BusinessLicenseNum;
            this.txtBusinessManagers.Value = supplier.BusinessManagers;
            this.txtBusinessScope.Value = supplier.BusinessScope;
            this.txtCompanyPhone.Value = supplier.CompanyPhone;
            this.txtDetailedAddress.Value = supplier.DetailedAddress;
            this.txtFax.Value = supplier.Fax;
            this.txtFinancialOfficers.Value = supplier.FinancialOfficers;
            this.txtLegalMobile.Value = supplier.LegalMobile;
            this.txtLegalQQ.Value = supplier.LegalQQ;
            this.txtLegalRepresentative.Value = supplier.LegalRepresentative;
            this.txtManagersMobile.Value = supplier.ManagersMobile;
            this.txtManagersQQ.Value = supplier.ManagersQQ;
            this.txtName.Value = supplier.Name;
            this.txtOfficersMobile.Value = supplier.OfficersMobile;
            this.txtOfficersQQ.Value = supplier.OfficersQQ;
            this.txtBank.Value = supplier.Bank;
            this.txtHuming.Value = supplier.Huming;
            this.txtAccountID.Value = supplier.AccountID;
            this.txtPostcode.Value = supplier.Postcode;
            this.txtQQ.Value = supplier.QQ;
            this.txtRegisterCapital.Value = supplier.RegisterCapital.ToString2();
            this.txtWebSite.Value = supplier.WebSite;
            this.txtOrderNum.Value = (this.supplier.OrderNum ?? 0).ToString();
            if (!string.IsNullOrEmpty(supplier.OrganizationCodeFileId))
            {
                this.div_Organization.Visible = true;
                this.OrganizationCodeFileImg.Src = supplier.OrganizationCodeFileId;
                this.aOrganizationCodeFileImg.HRef = supplier.OrganizationCodeFileId;
            }
            if (!string.IsNullOrEmpty(supplier.BusinessLicenseFileId))
            {
                this.div_Business.Visible = true;
                this.BusinessLicenseFilePic.Src = supplier.BusinessLicenseFileId;
                this.aBusinessLicenseFilePic.HRef = supplier.BusinessLicenseFileId;
            }
            if (!string.IsNullOrEmpty(supplier.TaxRegistrationFileId))
            {
                this.div_Tax.Visible = true;
                this.TaxRegistrationFileImg.Src = supplier.TaxRegistrationFileId;
                this.aTaxRegistrationFileImg.HRef = supplier.TaxRegistrationFileId;
            }
 
            DataTable ds = _OA_SuppliersOtherQualificationBLL.selectOtherQuBySuppliersId(supplier.Keyid.ToString2());
            if (ds != null && ds.Rows.Count > 0)
            {
                Fileds = new string[ds.Rows.Count];
                for (int i = 0; i < ds.Rows.Count; i++)
                {
                    Fileds[i] = ds.Rows[i]["FileId"].ToString2();
                }
 
            }
 
        }
 
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
 
            if (Request["Keyid"].ToInt32() > 0)
            {
                supplier = _OA_SuppliersBLL.getSingleSupplier(Request["Keyid"].ToString2());
            }
 
 
            //营业执照上传
            CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult0 = CY.WebForm.cs.UploadCS.Upload("BusinessLicenseFileId", supplier.BusinessLicenseFileId);
            supplier.BusinessLicenseFileId = supplier.BusinessLicenseFileId ?? "";
            if (_UpFileResult0.returnerror.Count == 0)
            {
                if (_UpFileResult0.returnfilename.Count > 0)
                    supplier.BusinessLicenseFileId = _UpFileResult0.returnfilename[0].ToString2();
            }
            else
            {
                JavaScript.MessageBox(string.Join("<br/>", (string[])_UpFileResult0.returnerror.ToArray(typeof(string))), this);
                return;
            }
 
            //组织机构代码上传
            CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult1 = CY.WebForm.cs.UploadCS.Upload("OrganizationCodeFileId", supplier.OrganizationCodeFileId);
            supplier.OrganizationCodeFileId = supplier.OrganizationCodeFileId ?? "";
            if (_UpFileResult1.returnerror.Count == 0)
            {
                if (_UpFileResult1.returnfilename.Count > 0)
                    supplier.OrganizationCodeFileId = _UpFileResult1.returnfilename[0].ToString2();
            }
            else
            {
                JavaScript.MessageBox(string.Join("<br/>", (string[])_UpFileResult1.returnerror.ToArray(typeof(string))), this);
                return;
            }
 
 
            ///税务登记证上传
            CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult2 = CY.WebForm.cs.UploadCS.Upload("TaxRegistrationFileId", supplier.TaxRegistrationFileId);
            supplier.TaxRegistrationFileId = supplier.TaxRegistrationFileId ?? "";
            if (_UpFileResult2.returnerror.Count == 0)
            {
                if (_UpFileResult2.returnfilename.Count > 0)
                    supplier.TaxRegistrationFileId = _UpFileResult2.returnfilename[0].ToString2();
            }
            else
            {
                JavaScript.MessageBox(string.Join("<br/>", (string[])_UpFileResult2.returnerror.ToArray(typeof(string))), this);
                return;
            }
 
            #region
            //其它资质文件
            OA_SuppliersOtherQualification model = new OA_SuppliersOtherQualification();
            CY.WebForm.cs.UploadCS.UpFileResult _UpFileResult3 = CY.WebForm.cs.UploadCS.Upload("ProductPics", model.FileId);
 
            if (_UpFileResult3.returnerror.Count == 0)
            {
                ArrayList NameList = new ArrayList();
                for (int i = 0; i < _UpFileResult3.returnfilename.Count; i++)
                {
                    OA_SuppliersOtherQualification model1 = new OA_SuppliersOtherQualification();
                    model1.FileId = _UpFileResult3.returnfilename[i].ToString();
                    model1.SuppliersId = Request["Keyid"].ToInt32();
                    NameList.Add(model1);
                }
                string[] aaa = (Request.Form["OldProductPics"]??"").Split(',');
                for (int i = 0; i < aaa.Length; i++)
                {
                    if (!string.IsNullOrEmpty(aaa[i].ToString2()))
                    {
                        OA_SuppliersOtherQualification newmodel = new OA_SuppliersOtherQualification();
                        newmodel.FileId = aaa[i].ToString2();
                        newmodel.SuppliersId = Request["Keyid"].ToInt32();
                        NameList.Add(newmodel);
                    }
                }
                _OA_SuppliersOtherQualificationBLL.DeleteAllModel(supplier.Keyid.ToString());
                _OA_SuppliersOtherQualificationBLL.InsertModelList(NameList, supplier.Keyid.ToString());
            }
 
            #endregion
 
            supplier.CooperativeStateId = this.selCooperativeStateId.Value.ToInt32();
            supplier.SuppliersLevelId = this.selSuppliersLevelId.Value.ToInt32();
            supplier.SuppliersTypeId = this.selSuppliersTypeId.Value.ToInt32();
            supplier.BusinessLicenseNum = this.txtBusinessLicenseNum.Value;
            supplier.BusinessManagers = this.txtBusinessManagers.Value;
            supplier.BusinessScope = this.txtBusinessScope.Value;
            supplier.CompanyPhone = this.txtCompanyPhone.Value;
            supplier.DetailedAddress = this.txtDetailedAddress.Value;
            supplier.Fax = this.txtFax.Value;
            supplier.FinancialOfficers = this.txtFinancialOfficers.Value;
            supplier.LegalMobile = this.txtLegalMobile.Value;
            supplier.LegalQQ = this.txtLegalQQ.Value;
            supplier.LegalRepresentative = this.txtLegalRepresentative.Value;
            supplier.ManagersMobile = this.txtManagersMobile.Value;
            supplier.ManagersQQ = this.txtManagersQQ.Value;
            supplier.Name = this.txtName.Value;
            supplier.OfficersMobile = this.txtOfficersMobile.Value;
            supplier.OfficersQQ = this.txtOfficersQQ.Value;
            if (!string.IsNullOrEmpty(this.txtHuming.Value))
            {
                supplier.Huming = this.txtHuming.Value;
            }
            else
            {
                supplier.Huming = this.txtName.Value;
            }
           
            supplier.Bank = this.txtBank.Value;
            supplier.AccountID = this.txtAccountID.Value;
            supplier.Postcode = this.txtPostcode.Value;
            supplier.QQ = this.txtQQ.Value;
            supplier.RegisterCapital = (string.IsNullOrEmpty(this.txtRegisterCapital.Value) ? "0" : this.txtRegisterCapital.Value).ToInt32();
            supplier.Remark = "";
            supplier.WebSite = this.txtWebSite.Value;
            supplier.OrderNum = this.txtOrderNum.Value.ToInt32();
            if ((Request["Keyid"].ToInt32() > 0))
            {
                if (_OA_SuppliersBLL.UpdateModel(supplier))
                {
                    JavaScript.MessageBox("更新成功", this, true, true);
                }
                else
                    JavaScript.MessageBox("更新失败", this);
            }
            else
            {
                supplier.FirmId = CurrentUser.MemberId;
                supplier.Operator = CurrentUser.ShortName;
                supplier.LastUpdateTime = System.DateTime.Now;
                if (_OA_SuppliersBLL.InsertModel(supplier))
                {
                    if (!string.IsNullOrEmpty(Request["flasss"]))
                    {
                        JavaScript.MessageBoxCloseAndRefreshparent("新增成功", this);
                    }
                    else
                    {
                        JavaScript.MessageBox("新增成功", this, true, true);
                    }
                    
                }
                else
                    JavaScript.MessageBox("添加失败", this);
            }
        }
    }
}