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);
|
}
|
}
|
}
|
}
|