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;
|
OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = 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();
|
bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
|
|
}
|
|
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());
|
|
var sss = _OA_SuppliersBLL.getSupplierByFirmId(CurrentUser.MemberId, this.txtName.Value.Trim()).ToList();
|
if (sss.Count > 0)
|
{
|
if(sss.Count(x => x.Keyid != supplier.Keyid) > 0)
|
{
|
JavaScript.MessageBox("已有同名供应商!", this);
|
return;
|
}
|
}
|
}
|
else
|
{
|
var sss = _OA_SuppliersBLL.getSupplierByFirmId(CurrentUser.MemberId, this.txtName.Value.Trim()).ToList();
|
if (sss.Count > 0)
|
{
|
JavaScript.MessageBox("已有同名供应商!", this);
|
return;
|
}
|
var suptypeid = this.selSuppliersTypeId.Value.ToInt32();
|
var sys_Dictionary = _Sys_DictionaryBLL.GetDataByType("供应商类别 ").Where(x=>x.Keyid == suptypeid).FirstOrDefault();
|
if (sys_Dictionary!=null && sys_Dictionary.Name == "外协加工")
|
{
|
Pagination pa = new Pagination();
|
pa.PageSize = 500;
|
pa.PageIndex = 1;
|
//查询是否有同名的外协
|
var ss = bll_OA_CorporateClientsBLL.SelectModelPage(pa, CurrentUser.MemberId, "").Where(x=>x.OutVendorName == this.txtName.Value.Trim()).ToList();
|
if (ss.Count == 0)
|
{
|
//新增外协厂商
|
OA_CorporateClients m_OA_CorporateClients = new OA_CorporateClients();
|
OA_CustomerCommunications m_OA_CustomerCommunications = new OA_CustomerCommunications();
|
EC_AcceptWayByCustomers m_EC_AcceptWayByCustomers = new EC_AcceptWayByCustomers();
|
EC_MemberBasic m_EC_MemberBasic = new EC_MemberBasic();
|
Guid NewGuid = Guid.NewGuid();
|
#region 初始合作客户基础信息
|
m_OA_CorporateClients.CompanyName = CurrentUser.Name;
|
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.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.OrderCount = 0;
|
m_OA_CorporateClients.OrderMoney = 0;
|
|
m_OA_CorporateClients.Prepayments = 0;
|
m_OA_CorporateClients.IsOutsourcing = true;
|
m_OA_CorporateClients.OutVendorName = this.txtName.Value.Trim();
|
m_OA_CorporateClients.IsPriority = false;
|
m_OA_CorporateClients.CumulativePrepayments = 0;
|
m_OA_CorporateClients.LastUpdateTime = DateTime.Now;
|
m_OA_CorporateClients.Operator = CurrentUser.ShortName;
|
m_OA_CorporateClients.Remark = "";
|
m_OA_CorporateClients.OutRate = 1;
|
m_OA_CorporateClients.LoginPwd = "";
|
|
#endregion
|
|
#region 初始合作客户通讯信息
|
m_OA_CustomerCommunications.Province = CurrentUser.Province;
|
m_OA_CustomerCommunications.City = CurrentUser.City;
|
m_OA_CustomerCommunications.County = CurrentUser.County;
|
m_OA_CustomerCommunications.DetailedAddress = CurrentMemberExtend.DetailedAddress;
|
m_OA_CustomerCommunications.CompanyPhone = CurrentMemberExtend.PhoneNum;
|
m_OA_CustomerCommunications.Postcode = CurrentMemberExtend.Postcode;
|
m_OA_CustomerCommunications.Mobile = CurrentMemberExtend.MobileNum;
|
m_OA_CustomerCommunications.Fax = CurrentMemberExtend.Fax;
|
m_OA_CustomerCommunications.Email = CurrentMemberExtend.Email;
|
m_OA_CustomerCommunications.QQ = CurrentMemberExtend.QQ;
|
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 = "";
|
|
#endregion
|
|
m_OA_CorporateClients.Keyid = NewGuid;
|
m_OA_CorporateClients.CreateTime = DateTime.Now;
|
m_OA_CorporateClients.MemberId = CurrentUser.MemberId;
|
m_OA_CorporateClients.FirmId = NewGuid;
|
m_OA_CorporateClients.InquiryId = AdminAccount.MemberId;
|
m_OA_CorporateClients.CustomerId = bll_OA_CorporateClientsBLL.GetLastIdByFirmId(m_OA_CorporateClients.FirmId) + 1;
|
|
m_OA_CustomerCommunications.Keyid = NewGuid;
|
m_EC_AcceptWayByCustomers.TargetId = NewGuid;
|
m_OA_CorporateClients.Paytime = 0;
|
m_OA_CorporateClients.Paydays = 0;
|
m_OA_CorporateClients.Biddingcompany = 0;
|
m_OA_CorporateClients.Contracttype = 0;
|
m_OA_CorporateClients.Contractmoney = 0;
|
m_OA_CorporateClients.Jigoudaima = "";
|
m_OA_CorporateClients.Piaoju = 0;
|
m_OA_CorporateClients.Kaipiaoziliao = "";
|
m_OA_CorporateClients.Expiretype = 0;
|
m_OA_CorporateClients.Shifouwanjie = 2;
|
m_OA_CorporateClients.Note = "";
|
bool result = bll_OA_CorporateClientsBLL.InsertModel(m_OA_CorporateClients, m_OA_CustomerCommunications, m_EC_AcceptWayByCustomers);//添加信息
|
if (!result)
|
{
|
JavaScript.MessageBox("添加失败", this);
|
return;
|
}
|
|
|
}
|
}
|
}
|
|
|
//营业执照上传
|
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.Trim();
|
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);
|
}
|
}
|
}
|
}
|