|  |  |  | 
|---|
|  |  |  | using System.Linq; | 
|---|
|  |  |  | using System.Text; | 
|---|
|  |  |  | using System.Threading.Tasks; | 
|---|
|  |  |  | using WIDESEA_BasicRepository; | 
|---|
|  |  |  | using WIDESEA_Core; | 
|---|
|  |  |  | using WIDESEA_Core.BaseServices; | 
|---|
|  |  |  | using WIDESEA_DTO.Basic; | 
|---|
|  |  |  | using WIDESEA_IBasicRepository; | 
|---|
|  |  |  | using WIDESEA_IBasicService; | 
|---|
|  |  |  | using WIDESEA_Model.Models; | 
|---|
|  |  |  | 
|---|
|  |  |  | public SupplierInfoService(ISupplierInfoRepository BaseDal) : base(BaseDal) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public ISupplierInfoRepository Repository => BaseDal; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public WebResponseContent ReceiveSupplier(SupplierDTO model) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | try | 
|---|
|  |  |  | { | 
|---|
|  |  |  | if (model.OperateType == "0") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_SupplierInfo supplierInfo = new Dt_SupplierInfo() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Status = 1, | 
|---|
|  |  |  | SupplierCode = model.Code, | 
|---|
|  |  |  | ContactAddress = model.ContactAddress, | 
|---|
|  |  |  | ContactNumber = model.ContactNumber, | 
|---|
|  |  |  | Contacts = model.Contacts, | 
|---|
|  |  |  | Description = model.Description, | 
|---|
|  |  |  | Email = model.Email, | 
|---|
|  |  |  | InvOrgId = model.InvOrgId, | 
|---|
|  |  |  | SupplierName = model.Name, | 
|---|
|  |  |  | SupplierShortName = model.ShortName | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BaseDal.AddData(supplierInfo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (model.OperateType == "1") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_SupplierInfo supplierInfo = BaseDal.QueryFirst(x => x.SupplierCode == model.Code); | 
|---|
|  |  |  | if (supplierInfo == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_SupplierInfo supplierInfoAddNew = new Dt_SupplierInfo() | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Status = 1, | 
|---|
|  |  |  | SupplierCode = model.Code, | 
|---|
|  |  |  | ContactAddress = model.ContactAddress, | 
|---|
|  |  |  | ContactNumber = model.ContactNumber, | 
|---|
|  |  |  | Contacts = model.Contacts, | 
|---|
|  |  |  | Description = model.Description, | 
|---|
|  |  |  | Email = model.Email, | 
|---|
|  |  |  | InvOrgId = model.InvOrgId, | 
|---|
|  |  |  | SupplierName = model.Name, | 
|---|
|  |  |  | SupplierShortName = model.ShortName | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | BaseDal.AddData(supplierInfoAddNew); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | supplierInfo.Status = 1; | 
|---|
|  |  |  | supplierInfo.SupplierCode = model.Code; | 
|---|
|  |  |  | supplierInfo.SupplierName = model.Name; | 
|---|
|  |  |  | supplierInfo.SupplierShortName = model.ShortName; | 
|---|
|  |  |  | BaseDal.UpdateData(supplierInfo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else if (model.OperateType == "2") | 
|---|
|  |  |  | { | 
|---|
|  |  |  | Dt_SupplierInfo supplierInfo = BaseDal.QueryFirst(x => x.SupplierCode == model.Code); | 
|---|
|  |  |  | if (supplierInfo == null) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error($"æªæ¾å°è¯¥ä¾åºåä¿¡æ¯"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | BaseDal.DeleteData(supplierInfo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return WebResponseContent.Instance.OK(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | catch (Exception ex) | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return WebResponseContent.Instance.Error(ex.Message); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|