You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
409 lines
17 KiB
409 lines
17 KiB
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.ServiceModel;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UFSoft.UBF.Exceptions;
|
|
using UFSoft.UBF.Service;
|
|
using UFSoft.UBF.Util.Context;
|
|
using www.ufida.org.EntityData;
|
|
using CustCreateSupplierBankAccountSV;
|
|
using CustCreateBank;
|
|
using CustCreateAddress;
|
|
using ICS.WCF.Base;
|
|
|
|
namespace UFIDA.U9.CreateSupplier
|
|
{
|
|
public class CustCreateSupplier
|
|
{
|
|
public OperationResult CustCreateSupp(Supplier Supp)
|
|
{
|
|
|
|
OperationResult result = new OperationResult();
|
|
try
|
|
{
|
|
StringBuilder beginstr = new StringBuilder();
|
|
beginstr.AppendLine("-----------------------传入数据验证开始-----------------------------");
|
|
beginstr.AppendLine("创建U9供应商信息");
|
|
beginstr.AppendLine("供应商编码:" + Supp.Code);
|
|
beginstr.AppendLine("供应商名称:" + Supp.Name);
|
|
beginstr.AppendLine("供应商简称:" + Supp.ShortName);
|
|
beginstr.AppendLine("分类:" + Supp.Category);
|
|
beginstr.AppendLine("税号:" + Supp.StateTaxNo);
|
|
beginstr.AppendLine("生效日期:" + Supp.Effective_EffectiveDate);
|
|
beginstr.AppendLine("立账条件:" + Supp.APConfirmTerm);
|
|
beginstr.AppendLine("付款条件:" + Supp.PaymentTerm);
|
|
beginstr.AppendLine("联系人:" + Supp.desc1);
|
|
beginstr.AppendLine("联系电话:" + Supp.desc2);
|
|
beginstr.AppendLine("-----------------------传入数据验证结束-----------------------------");
|
|
Appconfig.WriteLogFile(beginstr.ToString(), "创建U9供应商信息");
|
|
//上下文信息
|
|
object context;
|
|
context = CreateContextObj();
|
|
MessageBase[] outMessages;
|
|
string SuppCode = string.Empty;
|
|
|
|
if (Supp != null)
|
|
{
|
|
UFIDAU9CBOSCMSupplierIBatchCreateSupplierByDTOSVClient client = new UFIDAU9CBOSCMSupplierIBatchCreateSupplierByDTOSVClient();
|
|
UFIDAU9CBOSCMSupplierSupplierDTOData[] suppliers = new UFIDAU9CBOSCMSupplierSupplierDTOData[] { };
|
|
List<UFIDAU9CBOSCMSupplierSupplierDTOData> supplierList = new List<UFIDAU9CBOSCMSupplierSupplierDTOData>();
|
|
|
|
UFIDAU9CBOSCMSupplierSupplierDTOData supplierInfo = new UFIDAU9CBOSCMSupplierSupplierDTOData();
|
|
|
|
if (!string.IsNullOrWhiteSpace(Supp.Category))
|
|
{
|
|
supplierInfo.m_category = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
supplierInfo.m_category.m_code = Supp.Category;
|
|
}
|
|
else
|
|
{
|
|
result.IsSuccess = false;
|
|
result.MESSAGE = "供应商分类不允许为空";
|
|
return result;
|
|
}
|
|
if (string.IsNullOrWhiteSpace(Supp.Code))
|
|
{
|
|
result.IsSuccess = false;
|
|
result.MESSAGE = "供应商编码不允许为空";
|
|
return result;
|
|
}
|
|
if (string.IsNullOrWhiteSpace(Supp.StateTaxNo))
|
|
{
|
|
result.IsSuccess = false;
|
|
result.MESSAGE = "税号不允许为空";
|
|
return result;
|
|
}
|
|
|
|
SuppCode = Supp.Code;
|
|
|
|
supplierInfo.m_code = SuppCode;
|
|
supplierInfo.Name = Supp.Name;
|
|
supplierInfo.m_shortName = Supp.ShortName;
|
|
|
|
supplierInfo.m_isPriceListModify = true;//价目表可改
|
|
supplierInfo.m_isReceiptRuleEditable = true; // 收货原则可改
|
|
supplierInfo.m_isPaymentTermModify = true; // 付款条件可改
|
|
supplierInfo.m_isAPConfirmTermEditable = true; //立账条件可改
|
|
|
|
|
|
string StateTaxNo = "";
|
|
string sqlWH = @"select StateTaxNo from CBO_Supplier where StateTaxNo <>'' and StateTaxNo='"+Supp.StateTaxNo+"' ";
|
|
sqlWH = string.Format(sqlWH);
|
|
DataTable _dtWH = DBhlper.Query(sqlWH, Appconfig.GetU9ConnStr());
|
|
string WHCode = string.Empty;
|
|
if (_dtWH != null && _dtWH.Rows.Count > 0)
|
|
{
|
|
StateTaxNo = _dtWH.Rows[0][0].ToString();
|
|
}
|
|
if (string.IsNullOrWhiteSpace(WHCode))
|
|
supplierInfo.m_stateTaxNo = Supp.StateTaxNo;
|
|
else
|
|
throw new Exception("税号已被使用请重新输入!");
|
|
|
|
|
|
|
|
|
|
//SupplierBankAccount
|
|
|
|
//supplierInfo.m_supplierSiteDTOs
|
|
|
|
UFIDAU9CBOPubControllerCommonArchiveDataDTOData m_org = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
m_org.m_code = ConfigurationManager.AppSettings["orgCode"].ToString();//"01";// Supp.Org;
|
|
supplierInfo.m_org = m_org;
|
|
|
|
supplierInfo.m_receiptRule = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
supplierInfo.m_receiptRule.m_code = "01";// Supp.ReceiptRule;//收货原则
|
|
|
|
|
|
UFIDAU9BasePropertyTypesEffectiveData m_effective = new UFIDAU9BasePropertyTypesEffectiveData();
|
|
//m_effective.m_effectiveDate = new DateTime(2022, 9, 1);
|
|
m_effective.m_effectiveDate = Convert.ToDateTime(Supp.Effective_EffectiveDate);// DateTime.Now.AddDays(-1);
|
|
|
|
m_effective.m_disableDate = new DateTime(9999, 12, 31);
|
|
m_effective.m_isEffective = true;
|
|
|
|
supplierInfo.m_effective = m_effective;
|
|
|
|
|
|
|
|
#region 供应商1
|
|
|
|
|
|
supplierInfo.m_paymentTerm = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
supplierInfo.m_paymentTerm.m_code = Supp.PaymentTerm; ;//付款条件
|
|
|
|
|
|
List<UFIDAU9CBOSCMSupplierSupplierSiteDTOData> supplierSiteList = new List<UFIDAU9CBOSCMSupplierSupplierSiteDTOData>();
|
|
|
|
supplierInfo.m_supplierSiteDTOs = new UFIDAU9CBOSCMSupplierSupplierSiteDTOData[] { };
|
|
UFIDAU9CBOSCMSupplierSupplierSiteDTOData supplierSiteInfo = new UFIDAU9CBOSCMSupplierSupplierSiteDTOData();
|
|
|
|
supplierSiteInfo.m_code = SuppCode;
|
|
supplierSiteInfo.Name = Supp.Name;
|
|
supplierSiteInfo.m_isDefaultBillTo = true;
|
|
supplierSiteInfo.m_isPriceListModify = true;//价目表可改
|
|
supplierSiteInfo.m_isReceiptRuleModify = true; // 收货原则可改
|
|
supplierSiteInfo.m_isPayItemEditable = true; // 付款条件可改
|
|
|
|
#region 201912114
|
|
supplierSiteInfo.m_isShipTo = true;
|
|
supplierSiteInfo.m_isBillTo = true;
|
|
supplierSiteInfo.m_isClaim = true;
|
|
supplierSiteInfo.m_isContrast = true;
|
|
supplierSiteInfo.m_isRemit = true;
|
|
supplierSiteInfo.m_isInquire = true;
|
|
supplierSiteInfo.m_isDefaultShipTo = true;
|
|
supplierSiteInfo.m_isDefaultBillTo = true;
|
|
supplierSiteInfo.m_isDefaultClaim = true;
|
|
supplierSiteInfo.m_isDefaultContrast = true;
|
|
supplierSiteInfo.m_isDefaultRemit = true;
|
|
supplierSiteInfo.m_isDefaultInquire = true;
|
|
|
|
|
|
supplierSiteInfo.m_receiptRule = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
supplierSiteInfo.m_receiptRule.m_code = "01";// Supp.ReceiptRule;//收货原则
|
|
supplierSiteInfo.m_paymentTerm = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
supplierSiteInfo.m_paymentTerm.m_code = "YZ01"; //Supp.Payment; ;//付款条件
|
|
supplierSiteInfo.m_aPConfirmTerm = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
supplierSiteInfo.m_aPConfirmTerm.m_code = Supp.APConfirmTerm; //立账条件
|
|
supplierSiteInfo.m_invoiceVerificationDetail = 0;// Supp.InvoiceVerificationDetai;//核销明细
|
|
supplierSiteInfo.m_invoiceVerificationOrder = 1;
|
|
supplierSiteInfo.m_docVerificationOrder = 1;
|
|
supplierSiteInfo.m_effective = new UFIDAU9BasePropertyTypesEffectiveData();
|
|
supplierSiteInfo.m_effective.m_isEffective = true;
|
|
supplierSiteInfo.m_effective.m_effectiveDate = Convert.ToDateTime(Supp.Effective_EffectiveDate); //DateTime.Now.AddDays(-1);
|
|
supplierSiteInfo.m_effective.m_disableDate = new DateTime(9999, 12, 31);
|
|
//supplierSiteInfo.m_createdOn = DateTime.Now.AddDays(-1);
|
|
|
|
|
|
|
|
//SupplierBankAccount
|
|
supplierSiteInfo.m_defaultBankAccount = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
|
|
|
|
#endregion
|
|
|
|
supplierSiteList.Add(supplierSiteInfo);
|
|
supplierInfo.m_supplierSiteDTOs = supplierSiteList.ToArray();
|
|
#endregion
|
|
|
|
supplierInfo.m_invoiceVerificationDetai = 1;
|
|
supplierInfo.m_invoiceVerificationOrder = 1;
|
|
supplierInfo.m_docVerificationOrder = 1;
|
|
|
|
supplierInfo.m_descFlexField = new UFIDAU9BaseFlexFieldDescFlexFieldDescFlexSegmentsData();
|
|
if (!string.IsNullOrWhiteSpace(Supp.desc1))
|
|
{
|
|
supplierInfo.m_descFlexField.m_privateDescSeg1 = Supp.desc1;
|
|
}
|
|
if (!string.IsNullOrWhiteSpace(Supp.desc2))
|
|
{
|
|
supplierInfo.m_descFlexField.m_privateDescSeg2 = Supp.desc2;
|
|
|
|
}
|
|
//supplierInfo.m_contactObject = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
//supplierInfo.m_contactObject.m_code = SuppCode;
|
|
supplierInfo.m_ourSideSupplyRecRefStd = 1;// Supp.OutSide;
|
|
|
|
supplierInfo.m_paymentTerm = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
supplierInfo.m_paymentTerm.m_code = "YZ01";//Supp.Payment;
|
|
|
|
supplierInfo.m_aPConfirmTerm = new UFIDAU9CBOPubControllerCommonArchiveDataDTOData();
|
|
supplierInfo.m_aPConfirmTerm.m_code = Supp.APConfirmTerm;
|
|
|
|
|
|
supplierList.Add(supplierInfo);
|
|
|
|
suppliers = supplierList.ToArray();
|
|
|
|
UFIDAU9CBOSCMSupplierSupplierData[] returnMsg = client.Do(out outMessages, context, suppliers);
|
|
|
|
result.IsSuccess = true;
|
|
result.MESSAGE = "创建供应商成功";
|
|
result.SuppCode = SuppCode;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
result.IsSuccess = false;
|
|
result.MESSAGE = "传入数据为空";
|
|
return result;
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.MESSAGE = GetExceptionMessage(ex);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 创建上下文
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
private static ThreadContext CreateContextObj()
|
|
{
|
|
// 实例化应用上下文对象
|
|
ThreadContext thContext = new ThreadContext();
|
|
|
|
System.Collections.Generic.Dictionary<object, object> ns = new Dictionary<object, object>();
|
|
ns.Add("OrgID", ConfigurationManager.AppSettings["orgID"].ToString());
|
|
ns.Add("UserID", ConfigurationManager.AppSettings["userID"].ToString());
|
|
ns.Add("UserCode", ConfigurationManager.AppSettings["userCode"].ToString());
|
|
ns.Add("Datetime", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
|
|
|
|
ns.Add("CultureName", ConfigurationManager.AppSettings["cultureName"].ToString());
|
|
ns.Add("EnterpriseID", ConfigurationManager.AppSettings["enterpriseID"].ToString());
|
|
ns.Add("DefaultCultureName", ConfigurationManager.AppSettings["cultureName"].ToString());
|
|
thContext.nameValueHas = ns;
|
|
|
|
return thContext;
|
|
}
|
|
|
|
|
|
#region 提取异常信息
|
|
/// <summary>
|
|
/// 提取异常信息
|
|
/// </summary>
|
|
/// <param name="ex"></param>
|
|
private static string GetExceptionMessage(Exception ex)
|
|
{
|
|
string faultMessage = "未知错误,请查看ERP日志!";
|
|
|
|
System.TimeoutException timeoutEx = ex as System.TimeoutException;
|
|
if (timeoutEx != null)
|
|
{
|
|
faultMessage = "访问服务超时,请修改配置信息!";
|
|
}
|
|
else
|
|
{
|
|
FaultException<ServiceException> faultEx = ex as FaultException<ServiceException>;
|
|
if (faultEx == null)
|
|
{
|
|
faultMessage = ex.Message;
|
|
}
|
|
else
|
|
{
|
|
ServiceException serviceEx = faultEx.Detail;
|
|
if (serviceEx != null && !string.IsNullOrEmpty(serviceEx.Message)
|
|
&& !serviceEx.Message.Equals("fault", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
// 错误信息在faultEx.Message中,请提取,
|
|
// 格式为"Fault:料品不能为空,请录入\n 在....."
|
|
int startIndex = serviceEx.Message.IndexOf(":");
|
|
int endIndex = serviceEx.Message.IndexOf("\n");
|
|
if (endIndex == -1)
|
|
endIndex = serviceEx.Message.Length;
|
|
if (endIndex > 0 && endIndex > startIndex + 1)
|
|
{
|
|
faultMessage = serviceEx.Message.Substring(startIndex + 1, endIndex - startIndex - 1);
|
|
}
|
|
else
|
|
{
|
|
faultMessage = serviceEx.Message;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return faultMessage;
|
|
}
|
|
#endregion
|
|
|
|
public class OperationResult
|
|
{
|
|
public bool IsSuccess { get; set; }
|
|
public string MESSAGE { get; set; }
|
|
public string SuppCode { get; set; }
|
|
|
|
}
|
|
public class Supplier
|
|
{
|
|
public string Code { get; set; }
|
|
public string Name { get; set; }
|
|
public string ShortName { get; set; }
|
|
public string Category { get; set; }//分类
|
|
|
|
|
|
public string Effective_EffectiveDate { get; set; }//生效日期
|
|
public string APConfirmTerm { get; set; }//立账条件
|
|
public string PaymentTerm { get; set; }//付款条件
|
|
|
|
|
|
|
|
public string Org { get; set; }//组织
|
|
|
|
|
|
public string desc1 { get; set; }//
|
|
public string desc2 { get; set; }//
|
|
|
|
public string StateTaxNo { get; set; }
|
|
|
|
}
|
|
|
|
public class CreateSupplierBankAccount
|
|
{
|
|
public string SupperBankCode { get; set; }
|
|
public string SupperBankName { get; set; }
|
|
public Bank BankAccount { get; set; }
|
|
public string SupplierAccountCurrency { get; set; }
|
|
//public string SupperCode { get; set; }
|
|
public bool IsDefault { get; set; }
|
|
|
|
public string BankAccountType { get; set; }
|
|
|
|
|
|
|
|
}
|
|
|
|
public class Bank
|
|
{
|
|
public string BankCode { get; set; }
|
|
public string BankName { get; set; }
|
|
public int BankStatement { get; set; } //Oppsite 日记账反向 1 否 是 否 是 Misc System.Int32
|
|
//Same 日记账同向 0
|
|
public string Country { get; set; } // 国家/地区
|
|
public string BankCategory { get; set; }//银行类别
|
|
|
|
public string UOpenAccount { get; set; }//开户行
|
|
|
|
//public DateTime EffDatetime { get; set; }//
|
|
//public DateTime DisDatetime { get; set; }//
|
|
}
|
|
|
|
public class Contact
|
|
{
|
|
//public string ContactCode { get; set; }
|
|
public string ContactName { get; set; }
|
|
public string ContactFixedPhone { get; set; }
|
|
public string ContactMobilePhone { get; set; }
|
|
public string ContactFax { get; set; }
|
|
public string ContactMail { get; set; }
|
|
public bool isDefault { get; set; }
|
|
public string AddressCode { get; set; }
|
|
|
|
}
|
|
|
|
public class Address
|
|
{
|
|
public string AddressName { get; set; }
|
|
public string AddressCode { get; set; }
|
|
}
|
|
|
|
|
|
}
|
|
}
|