2026-06-17 16:02:24 +06:00
|
|
|
|
using Ease.NetCore.DataAccess;
|
2026-06-16 17:22:46 +06:00
|
|
|
|
using Ease.NetCore.DataAccess.SQL;
|
|
|
|
|
|
using Microsoft.Data.SqlClient;
|
|
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
|
using OnlineSalesAutoCrop.CoreAPI.Models.Global;
|
|
|
|
|
|
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
|
|
|
|
|
|
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
|
|
|
|
|
|
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
|
|
|
|
|
|
using System;
|
2026-06-23 17:34:45 +06:00
|
|
|
|
using System.Collections.Generic;
|
2026-06-16 17:22:46 +06:00
|
|
|
|
using System.Data;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace OnlineSalesAutoCrop.CoreAPI.Services.Services.Integrations;
|
|
|
|
|
|
|
|
|
|
|
|
public class IntegrationService : IIntegrationService
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly AppSettings _settings;
|
|
|
|
|
|
|
|
|
|
|
|
public IntegrationService(IOptions<AppSettings> options)
|
|
|
|
|
|
{
|
|
|
|
|
|
_settings = options.Value;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
|
2026-06-16 17:22:46 +06:00
|
|
|
|
public async Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
CustomerByCompanyCodeResponse response = new();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
await GetCustomerByCompanyCodeAsync(tc, request);
|
|
|
|
|
|
tc.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ie)
|
|
|
|
|
|
{
|
|
|
|
|
|
tc?.HandleError();
|
|
|
|
|
|
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ie);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
public async Task<IntegrationCustomerResponse> UpsertCustomerAsync(IntegrationCustomerRequest request)
|
2026-06-16 17:22:46 +06:00
|
|
|
|
{
|
2026-06-23 17:34:45 +06:00
|
|
|
|
IntegrationCustomerResponse response = new();
|
2026-06-16 17:22:46 +06:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2026-06-16 18:15:04 +06:00
|
|
|
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode,true);
|
2026-06-16 17:22:46 +06:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
var customer = await GetCustomerByCompanyCodeAsync(tc, new CustomerByCompanyCodeRequest() { CompanyCode = request.CompanyCode, CustomerNumber = request.CustomerNumber });
|
|
|
|
|
|
|
|
|
|
|
|
if( customer != null && customer.CustomerId>0)
|
|
|
|
|
|
{
|
|
|
|
|
|
//Update Here
|
2026-06-18 18:19:43 +06:00
|
|
|
|
UpdateCustomer(tc, request);
|
2026-06-16 17:51:28 +06:00
|
|
|
|
response.IsUpdated = true;
|
2026-06-16 17:22:46 +06:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
//Insert Here
|
2026-06-16 17:51:28 +06:00
|
|
|
|
|
2026-06-17 13:51:19 +06:00
|
|
|
|
CreateCustomer(tc, request);
|
2026-06-16 17:51:28 +06:00
|
|
|
|
response.IsUpdated = false;
|
2026-06-16 17:22:46 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-17 13:51:19 +06:00
|
|
|
|
response.CustomerNumber = request.CustomerNumber;
|
|
|
|
|
|
response.CompanyCode = request.CompanyCode;
|
2026-06-16 17:22:46 +06:00
|
|
|
|
tc.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ie)
|
|
|
|
|
|
{
|
|
|
|
|
|
tc?.HandleError();
|
|
|
|
|
|
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ie);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
public async Task<IntegrationEmployeeResponse> GetEmployeeBySalesOrgAsync(EmployeeIntegrationByComapanyRequest request)
|
2026-06-16 17:22:46 +06:00
|
|
|
|
{
|
2026-06-23 17:34:45 +06:00
|
|
|
|
IntegrationEmployeeResponse response = new();
|
2026-06-16 17:22:46 +06:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2026-06-18 18:19:43 +06:00
|
|
|
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
|
|
|
|
|
try
|
2026-06-16 17:22:46 +06:00
|
|
|
|
{
|
2026-06-18 18:19:43 +06:00
|
|
|
|
await GetEmployeeBySalesOrgAsync(tc, request);
|
|
|
|
|
|
tc.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ie)
|
|
|
|
|
|
{
|
|
|
|
|
|
tc?.HandleError();
|
2026-06-16 17:22:46 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
throw DBCustomError.GenerateCustomError(ie);
|
2026-06-16 17:22:46 +06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-06-18 18:19:43 +06:00
|
|
|
|
catch (Exception ex)
|
2026-06-16 17:22:46 +06:00
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
2026-06-18 18:19:43 +06:00
|
|
|
|
|
2026-06-16 17:22:46 +06:00
|
|
|
|
return response;
|
|
|
|
|
|
}
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
public async Task<EmployeeIntegrationReqResponse> UpsertEmployeeAsync(IntegrationEmployeeRequest request)
|
2026-06-16 19:17:16 +06:00
|
|
|
|
{
|
2026-06-18 18:19:43 +06:00
|
|
|
|
EmployeeIntegrationReqResponse response = new EmployeeIntegrationReqResponse();
|
2026-06-16 19:17:16 +06:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2026-06-18 18:19:43 +06:00
|
|
|
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
2026-06-16 19:17:16 +06:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2026-06-23 17:34:45 +06:00
|
|
|
|
IntegrationEmployeeResponse employee = await GetEmployeeBySalesOrgAsync(tc,
|
2026-06-18 18:19:43 +06:00
|
|
|
|
new EmployeeIntegrationByComapanyRequest() { EmployeeVendorCode = request.EmployeeVendorCode, CompanyCode = request.CompanyCode });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (employee != null && employee.EmployeeId > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateEmployee(tc, request);
|
|
|
|
|
|
response.IsUpdated = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
InsertEmployee(tc, request);
|
2026-06-21 10:43:59 +06:00
|
|
|
|
response.IsUpdated = false;
|
2026-06-18 18:19:43 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
response.EmployeeVendorCode = request.EmployeeVendorCode;
|
|
|
|
|
|
response.CompanyCode = request.CompanyCode;
|
2026-06-16 19:17:16 +06:00
|
|
|
|
tc.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ie)
|
|
|
|
|
|
{
|
|
|
|
|
|
tc?.HandleError();
|
|
|
|
|
|
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ie);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
public async Task<MaterialIntegrationReqResponse> UpsertMaterialAsync(IntegrationMaterialRequest request)
|
2026-06-16 19:17:16 +06:00
|
|
|
|
{
|
2026-06-18 18:19:43 +06:00
|
|
|
|
MaterialIntegrationReqResponse response = new MaterialIntegrationReqResponse();
|
2026-06-16 19:17:16 +06:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2026-06-18 18:19:43 +06:00
|
|
|
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
2026-06-16 19:17:16 +06:00
|
|
|
|
try
|
|
|
|
|
|
{
|
2026-06-23 17:34:45 +06:00
|
|
|
|
IntegrationMaterialResponse meterial = await GetMaterialByCodeAsync(tc,
|
2026-06-18 18:19:43 +06:00
|
|
|
|
new GetMaterialByCodeRequest() { MaterialCode = request.MaterialCode });
|
|
|
|
|
|
|
|
|
|
|
|
if (meterial != null && meterial.MeterialId > 0)
|
2026-06-16 19:17:16 +06:00
|
|
|
|
{
|
2026-06-18 18:19:43 +06:00
|
|
|
|
UpdateMaterial(tc, request);
|
2026-06-17 13:51:19 +06:00
|
|
|
|
response.IsUpdated = true;
|
2026-06-16 19:17:16 +06:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2026-06-18 18:19:43 +06:00
|
|
|
|
CreateMaterial(tc, request);
|
|
|
|
|
|
response.IsUpdated = false;
|
2026-06-16 19:17:16 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
response.MaterialCode = request.MaterialCode;
|
|
|
|
|
|
tc.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ie)
|
|
|
|
|
|
{
|
|
|
|
|
|
tc?.HandleError();
|
|
|
|
|
|
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ie);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
public async Task<IntegrationMaterialResponse> GetMaterialByCodeAsync(GetMaterialByCodeRequest request)
|
2026-06-18 18:19:43 +06:00
|
|
|
|
{
|
2026-06-23 17:34:45 +06:00
|
|
|
|
IntegrationMaterialResponse response = new();
|
2026-06-18 18:19:43 +06:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
response= await GetMaterialByCodeAsync(tc, request);
|
2026-06-16 19:17:16 +06:00
|
|
|
|
tc.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ie)
|
|
|
|
|
|
{
|
|
|
|
|
|
tc?.HandleError();
|
|
|
|
|
|
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ie);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-25 12:41:18 +06:00
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
public async Task<MaterialIntegrationPriceReqResponse> UpsertMaterialPriceAsync(IntegrationMaterialPriceRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
MaterialIntegrationPriceReqResponse response = new MaterialIntegrationPriceReqResponse();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
IntegrationMaterialPriceResponse meterialPrice = await GetMaterialPriceByCodeAndConditionTypeAsync(tc,
|
2026-06-25 19:08:21 +06:00
|
|
|
|
new GetMaterialPriceByCodeRequest() { MaterialCode = request.MaterialCode, ConditionType = request.ConditionType,
|
|
|
|
|
|
SalesOrg=request.SalesOrg, CustomerNumber = request.CustomerNumber,CustomerGroupCode = request.CustomerGroupCode });
|
2026-06-23 17:34:45 +06:00
|
|
|
|
|
|
|
|
|
|
if (meterialPrice != null && !string.IsNullOrWhiteSpace(meterialPrice.MaterialCode))
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateMaterialPrice(tc, request);
|
|
|
|
|
|
response.IsUpdated = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
CreateMaterialPrice(tc, request);
|
|
|
|
|
|
response.IsUpdated = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
response.MaterialCode = request.MaterialCode;
|
|
|
|
|
|
response.ConditionType = request.ConditionType;
|
|
|
|
|
|
tc.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ie)
|
|
|
|
|
|
{
|
|
|
|
|
|
tc?.HandleError();
|
|
|
|
|
|
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ie);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<IntegrationMaterialPriceResponse> GetMaterialPriceByCodeAsync(GetMaterialPriceByCodeRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntegrationMaterialPriceResponse response = new();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
response = await GetMaterialPriceByCodeAndConditionTypeAsync(tc, request);
|
|
|
|
|
|
tc.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ie)
|
|
|
|
|
|
{
|
|
|
|
|
|
tc?.HandleError();
|
|
|
|
|
|
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ie);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
|
2026-06-25 12:41:18 +06:00
|
|
|
|
public async Task<MaterialFreeGoodsByReqResponse> UpsertMaterialFreeGoodsAsync(IntegrationMaterialFreeGoodsRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
MaterialFreeGoodsByReqResponse response = new MaterialFreeGoodsByReqResponse();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
IntegrationMaterialFreeGoodsResponse meterialFreeGoods = await GetMaterialFreeGoodsByFilterAsync(tc,
|
|
|
|
|
|
new GetMaterialFreeGoodsByFilterRequest() { SalesOrg = request.SalesOrg, DistributionChannel = request.DistributionChannel,
|
2026-06-25 19:08:21 +06:00
|
|
|
|
CustomerPriceGroup = request.CustomerPriceGroup,MaterialCode = request.MaterialCode, CustomerNumber = request.CustomerNumber });
|
2026-06-25 12:41:18 +06:00
|
|
|
|
|
|
|
|
|
|
if (meterialFreeGoods != null && !string.IsNullOrWhiteSpace(meterialFreeGoods.MaterialCode))
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdateMaterialFreeGoods(tc, request);
|
|
|
|
|
|
response.IsUpdated = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
CreateMaterialFreeGoods(tc, request);
|
|
|
|
|
|
response.IsUpdated = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
response.SalesOrg = request.SalesOrg;
|
|
|
|
|
|
response.DistributionChannel = request.DistributionChannel;
|
|
|
|
|
|
response.CustomerPriceGroup = request.CustomerPriceGroup;
|
|
|
|
|
|
response.MaterialCode = request.MaterialCode;
|
|
|
|
|
|
tc.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ie)
|
|
|
|
|
|
{
|
|
|
|
|
|
tc?.HandleError();
|
|
|
|
|
|
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ie);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<IntegrationMaterialFreeGoodsResponse> GetMaterialFreeGoodseByFilterAsync(GetMaterialFreeGoodsByFilterRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntegrationMaterialFreeGoodsResponse response = new();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
response = await GetMaterialFreeGoodsByFilterAsync(tc, request);
|
|
|
|
|
|
tc.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ie)
|
|
|
|
|
|
{
|
|
|
|
|
|
tc?.HandleError();
|
|
|
|
|
|
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ie);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-06-28 19:02:40 +06:00
|
|
|
|
public async Task<IntegrationPaymentTermReqResponse> UpsertPaymentTermsAsync(IntegrationPaymentTermRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntegrationPaymentTermReqResponse response = new IntegrationPaymentTermReqResponse();
|
|
|
|
|
|
|
|
|
|
|
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
IntegrationPaymentTermResponse paymentTerms = await GetPaymentTermByFilterAsync(tc,
|
|
|
|
|
|
new GetIntegrationPaymentTermRequest()
|
|
|
|
|
|
{
|
|
|
|
|
|
CreditCode = request.CreditCode,
|
|
|
|
|
|
SalesOrg = request.SalesOrg
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (paymentTerms != null && !string.IsNullOrWhiteSpace(paymentTerms.CreditCode))
|
|
|
|
|
|
{
|
|
|
|
|
|
UpdatePaymentTerm(tc, request);
|
|
|
|
|
|
response.IsUpdated = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
CreatePaymentTerm(tc, request);
|
|
|
|
|
|
response.IsUpdated = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
response.SalesOrg = request.SalesOrg;
|
|
|
|
|
|
response.CreditCode = request.CreditCode;
|
|
|
|
|
|
tc.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ie)
|
|
|
|
|
|
{
|
|
|
|
|
|
tc?.HandleError();
|
|
|
|
|
|
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ie);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<IntegrationPaymentTermResponse> GetPaymentTermsByFilterAsync(GetIntegrationPaymentTermRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntegrationPaymentTermResponse response = new();
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
response = await GetPaymentTermByFilterAsync(tc, request);
|
|
|
|
|
|
tc.End();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ie)
|
|
|
|
|
|
{
|
|
|
|
|
|
tc?.HandleError();
|
|
|
|
|
|
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ie);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
#region Customer Private Functions
|
|
|
|
|
|
|
|
|
|
|
|
private async Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(TransactionContext tc, CustomerByCompanyCodeRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
CustomerByCompanyCodeResponse response = new CustomerByCompanyCodeResponse();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@CompanyCode", pType: SqlDbType.NVarChar, pValue: request.CompanyCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@CustomerNumber", pType: SqlDbType.NVarChar, pValue: request.CustomerNumber)
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetCustomerByCompanyCode", parameterValues: p))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dr.Read())
|
|
|
|
|
|
{
|
|
|
|
|
|
response = new CustomerByCompanyCodeResponse()
|
|
|
|
|
|
{
|
|
|
|
|
|
CustomerId = dr.GetInt32(0),
|
|
|
|
|
|
CustomerNumber = dr.GetString(1),
|
|
|
|
|
|
CustomerName = dr.GetString(2),
|
|
|
|
|
|
AccountGroup = dr.GetString(3),
|
|
|
|
|
|
AccountGroupDescription = dr.GetString(4),
|
|
|
|
|
|
CompanyCode = dr.GetString(5),
|
|
|
|
|
|
CompanyCodeDescription = dr.GetString(6),
|
|
|
|
|
|
SalesOrganization = dr.GetString(7),
|
|
|
|
|
|
SalesOrganizationDescription = dr.GetString(8),
|
|
|
|
|
|
DistributionChannel = dr.GetString(9),
|
|
|
|
|
|
DistributionChannelDescription = dr.GetString(10),
|
|
|
|
|
|
Division = dr.GetString(11),
|
|
|
|
|
|
DivisionDescription = dr.GetString(12),
|
|
|
|
|
|
MobileNumber = dr.GetString(13),
|
|
|
|
|
|
EmailAddress = dr.GetString(14),
|
|
|
|
|
|
BusinessTaxNumber = dr.GetString(15),
|
|
|
|
|
|
CreditLimit = dr.GetDecimal(16),
|
|
|
|
|
|
SalesGroup = dr.GetString(17),
|
|
|
|
|
|
SalesGroupDescription = dr.GetString(18),
|
|
|
|
|
|
CustomerGroup = dr.GetString(19),
|
|
|
|
|
|
CustomerGroupDescription = dr.GetString(20),
|
|
|
|
|
|
CustomerPriceGroup = dr.GetString(21),
|
|
|
|
|
|
CustomerPriceGroupDescription = dr.GetString(22),
|
|
|
|
|
|
StatusCode = dr.GetString(23),
|
|
|
|
|
|
StatusDescription = dr.GetString(24),
|
|
|
|
|
|
PaymentTerms = dr.GetString(25),
|
|
|
|
|
|
PaymentTermsDescription = dr.GetString(26),
|
|
|
|
|
|
SearchTerm = dr.GetString(27),
|
|
|
|
|
|
AreaRegion = dr.GetString(28),
|
|
|
|
|
|
AreaRegionDescription = dr.GetString(29),
|
|
|
|
|
|
SalesUnitAreaAV = dr.GetString(30),
|
|
|
|
|
|
SalesUnitAreaAVDescription = dr.GetString(31),
|
|
|
|
|
|
Territory = dr.GetString(32),
|
|
|
|
|
|
TerritoryName = dr.GetString(33),
|
|
|
|
|
|
Plant = dr.GetString(34),
|
|
|
|
|
|
PlantName = dr.GetString(35)
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
dr.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
private bool CreateCustomer(TransactionContext tc, IntegrationCustomerRequest request)
|
2026-06-18 18:19:43 +06:00
|
|
|
|
{
|
|
|
|
|
|
bool returnValue = false;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.NVarChar, request.CustomerNumber),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerName", SqlDbType.NVarChar, request.CustomerName),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@AccountGroup", SqlDbType.NVarChar, request.AccountGroup),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@AccountGroupDescription", SqlDbType.NVarChar, request.AccountGroupDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CompanyCode", SqlDbType.NVarChar, request.CompanyCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CompanyCodeDescription", SqlDbType.NVarChar, request.CompanyCodeDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrganization", SqlDbType.NVarChar, request.SalesOrganization),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrganizationDescription", SqlDbType.NVarChar, request.SalesOrganizationDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.NVarChar, request.DistributionChannel),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@DistributionChannelDescription", SqlDbType.NVarChar, request.DistributionChannelDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@Division", SqlDbType.NVarChar, request.Division),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@DivisionDescription", SqlDbType.NVarChar, request.DivisionDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MobileNumber", SqlDbType.NVarChar, request.MobileNumber),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@EmailAddress", SqlDbType.NVarChar, request.EmailAddress),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@BusinessTaxNumber", SqlDbType.NVarChar, request.BusinessTaxNumber),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CreditLimit", SqlDbType.Decimal, request.CreditLimit),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesGroup", SqlDbType.NVarChar, request.SalesGroup),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesGroupDescription", SqlDbType.NVarChar, request.SalesGroupDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerGroup", SqlDbType.NVarChar, request.CustomerGroup),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerGroupDescription", SqlDbType.NVarChar, request.CustomerGroupDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerPriceGroup", SqlDbType.NVarChar, request.CustomerPriceGroup),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerPriceGroupDescription", SqlDbType.NVarChar, request.CustomerPriceGroupDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@StatusCode", SqlDbType.NChar, request.StatusCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@StatusDescription", SqlDbType.NVarChar, request.StatusDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@PaymentTerms", SqlDbType.NVarChar, request.PaymentTerms),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@PaymentTermsDescription", SqlDbType.NVarChar, request.PaymentTermsDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SearchTerm", SqlDbType.NVarChar, request.SearchTerm),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@AreaRegion", SqlDbType.NVarChar, request.AreaRegion),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@AreaRegionDescription", SqlDbType.NVarChar, request.AreaRegionDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesUnitAreaAV", SqlDbType.NVarChar, request.SalesUnitAreaAV),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesUnitAreaAVDescription", SqlDbType.NVarChar, request.SalesUnitAreaAVDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@Territory", SqlDbType.NVarChar, request.Territory),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@TerritoryName", SqlDbType.NVarChar, request.TerritoryName),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@Plant", SqlDbType.NVarChar, request.Plant),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@PlantName", SqlDbType.NVarChar, request.PlantName)
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.CreateCustomer", parameterValues: p);
|
|
|
|
|
|
|
|
|
|
|
|
returnValue = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
private bool UpdateCustomer(TransactionContext tc, IntegrationCustomerRequest request)
|
2026-06-18 18:19:43 +06:00
|
|
|
|
{
|
|
|
|
|
|
bool returnValue = false;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.NVarChar, request.CustomerNumber),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerName", SqlDbType.NVarChar, request.CustomerName),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@AccountGroup", SqlDbType.NVarChar, request.AccountGroup),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@AccountGroupDescription", SqlDbType.NVarChar, request.AccountGroupDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CompanyCode", SqlDbType.NVarChar, request.CompanyCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CompanyCodeDescription", SqlDbType.NVarChar, request.CompanyCodeDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrganization", SqlDbType.NVarChar, request.SalesOrganization),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrganizationDescription", SqlDbType.NVarChar, request.SalesOrganizationDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.NVarChar, request.DistributionChannel),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@DistributionChannelDescription", SqlDbType.NVarChar, request.DistributionChannelDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@Division", SqlDbType.NVarChar, request.Division),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@DivisionDescription", SqlDbType.NVarChar, request.DivisionDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MobileNumber", SqlDbType.NVarChar, request.MobileNumber),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@EmailAddress", SqlDbType.NVarChar, request.EmailAddress),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@BusinessTaxNumber", SqlDbType.NVarChar, request.BusinessTaxNumber),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CreditLimit", SqlDbType.Decimal, request.CreditLimit),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesGroup", SqlDbType.NVarChar, request.SalesGroup),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesGroupDescription", SqlDbType.NVarChar, request.SalesGroupDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerGroup", SqlDbType.NVarChar, request.CustomerGroup),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerGroupDescription", SqlDbType.NVarChar, request.CustomerGroupDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerPriceGroup", SqlDbType.NVarChar, request.CustomerPriceGroup),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerPriceGroupDescription", SqlDbType.NVarChar, request.CustomerPriceGroupDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@StatusCode", SqlDbType.NChar, request.StatusCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@StatusDescription", SqlDbType.NVarChar, request.StatusDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@PaymentTerms", SqlDbType.NVarChar, request.PaymentTerms),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@PaymentTermsDescription", SqlDbType.NVarChar, request.PaymentTermsDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SearchTerm", SqlDbType.NVarChar, request.SearchTerm),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@AreaRegion", SqlDbType.NVarChar, request.AreaRegion),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@AreaRegionDescription", SqlDbType.NVarChar, request.AreaRegionDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesUnitAreaAV", SqlDbType.NVarChar, request.SalesUnitAreaAV),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesUnitAreaAVDescription", SqlDbType.NVarChar, request.SalesUnitAreaAVDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@Territory", SqlDbType.NVarChar, request.Territory),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@TerritoryName", SqlDbType.NVarChar, request.TerritoryName),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@Plant", SqlDbType.NVarChar, request.Plant),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@PlantName", SqlDbType.NVarChar, request.PlantName)
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.UpdateCustomer", parameterValues: p);
|
|
|
|
|
|
|
|
|
|
|
|
returnValue = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Employee Private Functions
|
|
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
private async Task<IntegrationEmployeeResponse> GetEmployeeBySalesOrgAsync(TransactionContext tc, EmployeeIntegrationByComapanyRequest request)
|
2026-06-16 19:17:16 +06:00
|
|
|
|
{
|
2026-06-23 17:34:45 +06:00
|
|
|
|
IntegrationEmployeeResponse response = new IntegrationEmployeeResponse();
|
2026-06-18 18:19:43 +06:00
|
|
|
|
|
2026-06-16 19:17:16 +06:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorCode", pType: SqlDbType.NVarChar, pValue: request.EmployeeVendorCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@CompanyCode", pType: SqlDbType.NVarChar, pValue: request.CompanyCode)
|
2026-06-16 19:17:16 +06:00
|
|
|
|
];
|
|
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetEmployeeByVendorCode", parameterValues: p))
|
2026-06-16 19:17:16 +06:00
|
|
|
|
{
|
|
|
|
|
|
if (dr.Read())
|
|
|
|
|
|
{
|
2026-06-23 17:34:45 +06:00
|
|
|
|
response = new IntegrationEmployeeResponse()
|
2026-06-16 19:17:16 +06:00
|
|
|
|
{
|
2026-06-18 18:19:43 +06:00
|
|
|
|
EmployeeId = dr.GetInt32(0),
|
2026-06-16 19:17:16 +06:00
|
|
|
|
EmployeeVendorCode = dr.GetString(1),
|
|
|
|
|
|
EmployeeVendorName = dr.GetString(2),
|
2026-06-18 18:19:43 +06:00
|
|
|
|
Designation = dr.GetString(3),
|
2026-06-16 19:17:16 +06:00
|
|
|
|
DesignationDescription = dr.GetString(4),
|
|
|
|
|
|
MobileNo = dr.GetString(5),
|
2026-06-18 18:19:43 +06:00
|
|
|
|
Mail = dr.GetString(6),
|
|
|
|
|
|
CompanyCode = dr.GetString(7),
|
|
|
|
|
|
CompanyName = dr.GetString(8),
|
|
|
|
|
|
SalesOrg = dr.GetString(9),
|
|
|
|
|
|
SalesOrgDescription = dr.GetString(10),
|
|
|
|
|
|
DistChannel = dr.GetString(11),
|
|
|
|
|
|
DistChannelDescription = dr.GetString(12),
|
|
|
|
|
|
Division = dr.GetString(13),
|
|
|
|
|
|
DivisionDescription = dr.GetString(14),
|
|
|
|
|
|
RegionAreaCode = dr.GetString(15),
|
|
|
|
|
|
RegionAreaDescription = dr.GetString(16),
|
|
|
|
|
|
AreaAVSalesUnitCode = dr.GetString(17),
|
|
|
|
|
|
AreaAVSalesUnitDescription = dr.GetString(18),
|
|
|
|
|
|
Territory = dr.GetString(19),
|
|
|
|
|
|
TerritoryDescription = dr.GetString(20),
|
|
|
|
|
|
Plant = dr.GetString(21),
|
|
|
|
|
|
PlantDescription = dr.GetString(22),
|
|
|
|
|
|
Status = dr.GetString(23),
|
|
|
|
|
|
StatusDescription = dr.GetString(24)
|
2026-06-16 19:17:16 +06:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
dr.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ex);
|
|
|
|
|
|
}
|
2026-06-18 18:19:43 +06:00
|
|
|
|
|
2026-06-16 19:17:16 +06:00
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
private bool InsertEmployee(TransactionContext tc, IntegrationEmployeeRequest request)
|
2026-06-16 18:15:04 +06:00
|
|
|
|
{
|
|
|
|
|
|
bool returnValue = false;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorCode", pType: SqlDbType.NVarChar, pValue: request.EmployeeVendorCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorName", pType: SqlDbType.NVarChar, pValue: request.EmployeeVendorName),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@Designation", pType: SqlDbType.NVarChar, pValue: request.Designation),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@DesignationDescription", pType: SqlDbType.NVarChar, pValue: request.DesignationDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@MobileNo", pType: SqlDbType.NVarChar, pValue: request.MobileNo),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@Mail", pType: SqlDbType.NVarChar, pValue: request.Mail),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@CompanyCode", pType: SqlDbType.NVarChar, pValue: request.CompanyCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@CompanyName", pType: SqlDbType.NVarChar, pValue: request.CompanyName),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@SalesOrg", pType: SqlDbType.NVarChar, pValue: request.SalesOrg),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@SalesOrgDescription", pType: SqlDbType.NVarChar, pValue: request.SalesOrgDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@DistChannel", pType: SqlDbType.NVarChar, pValue: request.DistChannel),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@DistChannelDescription", pType: SqlDbType.NVarChar, pValue: request.DistChannelDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@Division", pType: SqlDbType.NVarChar, pValue: request.Division),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@DivisionDescription", pType: SqlDbType.NVarChar, pValue: request.DivisionDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@RegionAreaCode", pType: SqlDbType.NVarChar, pValue: request.RegionAreaCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@RegionAreaDescription", pType: SqlDbType.NVarChar, pValue: request.RegionAreaDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@AreaAVSalesUnitCode", pType: SqlDbType.NVarChar, pValue: request.AreaAVSalesUnitCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@AreaAVSalesUnitDescription", pType: SqlDbType.NVarChar, pValue: request.AreaAVSalesUnitDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@Territory", pType: SqlDbType.NVarChar, pValue: request.Territory),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@TerritoryDescription", pType: SqlDbType.NVarChar, pValue: request.TerritoryDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@Plant", pType: SqlDbType.NVarChar, pValue: request.Plant),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@PlantDescription", pType: SqlDbType.NVarChar, pValue: request.PlantDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@Status", pType: SqlDbType.NChar, pValue: request.Status),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@StatusDescription", pType: SqlDbType.NVarChar, pValue: request.StatusDescription)
|
|
|
|
|
|
];
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.InsertEmployee", parameterValues: p);
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
returnValue = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
private bool UpdateEmployee(TransactionContext tc, IntegrationEmployeeRequest request)
|
2026-06-18 18:19:43 +06:00
|
|
|
|
{
|
|
|
|
|
|
bool returnValue = false;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorCode", pType: SqlDbType.NVarChar, pValue: request.EmployeeVendorCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@CompanyCode", pType: SqlDbType.NVarChar, pValue: request.CompanyCode),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@EmployeeVendorName", pType: SqlDbType.NVarChar, pValue: request.EmployeeVendorName),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@Designation", pType: SqlDbType.NVarChar, pValue: request.Designation),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@DesignationDescription", pType: SqlDbType.NVarChar, pValue: request.DesignationDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@MobileNo", pType: SqlDbType.NVarChar, pValue: request.MobileNo),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@Mail", pType: SqlDbType.NVarChar, pValue: request.Mail),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@CompanyName", pType: SqlDbType.NVarChar, pValue: request.CompanyName),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@SalesOrg", pType: SqlDbType.NVarChar, pValue: request.SalesOrg),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@SalesOrgDescription", pType: SqlDbType.NVarChar, pValue: request.SalesOrgDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@DistChannel", pType: SqlDbType.NVarChar, pValue: request.DistChannel),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@DistChannelDescription", pType: SqlDbType.NVarChar, pValue: request.DistChannelDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@Division", pType: SqlDbType.NVarChar, pValue: request.Division),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@DivisionDescription", pType: SqlDbType.NVarChar, pValue: request.DivisionDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@RegionAreaCode", pType: SqlDbType.NVarChar, pValue: request.RegionAreaCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@RegionAreaDescription", pType: SqlDbType.NVarChar, pValue: request.RegionAreaDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@AreaAVSalesUnitCode", pType: SqlDbType.NVarChar, pValue: request.AreaAVSalesUnitCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@AreaAVSalesUnitDescription", pType: SqlDbType.NVarChar, pValue: request.AreaAVSalesUnitDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@Territory", pType: SqlDbType.NVarChar, pValue: request.Territory),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@TerritoryDescription", pType: SqlDbType.NVarChar, pValue: request.TerritoryDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@Plant", pType: SqlDbType.NVarChar, pValue: request.Plant),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@PlantDescription", pType: SqlDbType.NVarChar, pValue: request.PlantDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@Status", pType: SqlDbType.NChar, pValue: request.Status),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@StatusDescription", pType: SqlDbType.NVarChar, pValue: request.StatusDescription)
|
2026-06-16 18:15:04 +06:00
|
|
|
|
];
|
|
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.UpdateEmployee", parameterValues: p);
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
|
|
|
|
|
returnValue = true;
|
|
|
|
|
|
}
|
2026-06-18 18:19:43 +06:00
|
|
|
|
catch (Exception)
|
2026-06-16 18:15:04 +06:00
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Meterial Private Functions
|
|
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
private async Task<IntegrationMaterialResponse> GetMaterialByCodeAsync(TransactionContext tc, GetMaterialByCodeRequest request)
|
2026-06-18 18:19:43 +06:00
|
|
|
|
{
|
2026-06-23 17:34:45 +06:00
|
|
|
|
IntegrationMaterialResponse response = new IntegrationMaterialResponse();
|
2026-06-18 18:19:43 +06:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam(pName: "@MaterialCode", pType: SqlDbType.NVarChar, pValue: request.MaterialCode)
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetMaterialByMaterialCode", parameterValues: p))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dr.Read())
|
|
|
|
|
|
{
|
2026-06-23 17:34:45 +06:00
|
|
|
|
response = new IntegrationMaterialResponse()
|
2026-06-18 18:19:43 +06:00
|
|
|
|
{
|
|
|
|
|
|
MeterialId = dr.GetInt32(0),
|
|
|
|
|
|
MaterialType = dr.GetString(1),
|
|
|
|
|
|
MaterialTypeDescription = dr.GetString(2),
|
|
|
|
|
|
MaterialCode = dr.GetString(3),
|
|
|
|
|
|
MaterialDescription = dr.GetString(4),
|
|
|
|
|
|
MaterialGroupCode = dr.GetString(5),
|
|
|
|
|
|
MaterialGroupDescription = dr.GetString(6),
|
|
|
|
|
|
BaseUnitOfMeasure = dr.GetString(7),
|
|
|
|
|
|
SalesUnitOfMeasure = dr.GetString(8),
|
|
|
|
|
|
UnitConversionWithBaseUoM = dr.GetDecimal(9),
|
|
|
|
|
|
PlantCode = dr.GetString(10),
|
|
|
|
|
|
PlantDescription = dr.GetString(11),
|
|
|
|
|
|
StorageLocationCode = dr.GetString(12),
|
|
|
|
|
|
StorageLocationDescription = dr.GetString(13),
|
|
|
|
|
|
SalesOrganization = dr.GetString(14),
|
|
|
|
|
|
SalesOrganizationDescription = dr.GetString(15),
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
dr.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
private bool CreateMaterial(TransactionContext tc, IntegrationMaterialRequest request)
|
2026-06-16 18:15:04 +06:00
|
|
|
|
{
|
|
|
|
|
|
bool returnValue = false;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialType", SqlDbType.NVarChar, request.MaterialType),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialTypeDescription", SqlDbType.NVarChar, request.MaterialTypeDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialDescription", SqlDbType.NVarChar, request.MaterialDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialGroupCode", SqlDbType.NVarChar, request.MaterialGroupCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialGroupDescription", SqlDbType.NVarChar, request.MaterialGroupDescription),
|
|
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@BaseUnitOfMeasure", SqlDbType.NVarChar, request.BaseUnitOfMeasure),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesUnitOfMeasure", SqlDbType.NVarChar, request.SalesUnitOfMeasure),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@UnitConversionWithBaseUoM", SqlDbType.Decimal, request.UnitConversionWithBaseUoM),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@PlantCode", SqlDbType.NVarChar, request.PlantCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@PlantDescription", SqlDbType.NVarChar, request.PlantDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@StorageLocationCode", SqlDbType.NVarChar, request.StorageLocationCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@StorageLocationDescription", SqlDbType.NVarChar, request.StorageLocationDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrganization", SqlDbType.NVarChar, request.SalesOrganization),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrganizationDescription", SqlDbType.NVarChar, request.SalesOrganizationDescription)
|
|
|
|
|
|
];
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.CreateMaterial", parameterValues: p);
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
returnValue = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
return returnValue;
|
|
|
|
|
|
}
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-23 17:34:45 +06:00
|
|
|
|
private bool UpdateMaterial(TransactionContext tc, IntegrationMaterialRequest request)
|
2026-06-18 18:19:43 +06:00
|
|
|
|
{
|
|
|
|
|
|
bool returnValue = false;
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialType", SqlDbType.NVarChar, request.MaterialType),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialTypeDescription", SqlDbType.NVarChar, request.MaterialTypeDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialDescription", SqlDbType.NVarChar, request.MaterialDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialGroupCode", SqlDbType.NVarChar, request.MaterialGroupCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialGroupDescription", SqlDbType.NVarChar, request.MaterialGroupDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@BaseUnitOfMeasure", SqlDbType.NVarChar, request.BaseUnitOfMeasure),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesUnitOfMeasure", SqlDbType.NVarChar, request.SalesUnitOfMeasure),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@UnitConversionWithBaseUoM", SqlDbType.Decimal, request.UnitConversionWithBaseUoM),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@PlantCode", SqlDbType.NVarChar, request.PlantCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@PlantDescription", SqlDbType.NVarChar, request.PlantDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@StorageLocationCode", SqlDbType.NVarChar, request.StorageLocationCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@StorageLocationDescription", SqlDbType.NVarChar, request.StorageLocationDescription),
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrganization", SqlDbType.NVarChar, request.SalesOrganization),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrganizationDescription", SqlDbType.NVarChar, request.SalesOrganizationDescription)
|
2026-06-16 18:15:04 +06:00
|
|
|
|
];
|
|
|
|
|
|
|
2026-06-18 18:19:43 +06:00
|
|
|
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.UpdateMaterial", parameterValues: p);
|
2026-06-16 18:15:04 +06:00
|
|
|
|
|
|
|
|
|
|
returnValue = true;
|
|
|
|
|
|
}
|
2026-06-18 18:19:43 +06:00
|
|
|
|
catch (Exception)
|
2026-06-16 18:15:04 +06:00
|
|
|
|
{
|
2026-06-18 18:19:43 +06:00
|
|
|
|
throw;
|
2026-06-16 18:15:04 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
|
|
}
|
2026-06-18 18:19:43 +06:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
2026-06-23 17:34:45 +06:00
|
|
|
|
|
|
|
|
|
|
#region Material Price Private Functions
|
|
|
|
|
|
|
|
|
|
|
|
private async Task<IntegrationMaterialPriceResponse> GetMaterialPriceByCodeAndConditionTypeAsync(
|
|
|
|
|
|
TransactionContext tc, GetMaterialPriceByCodeRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntegrationMaterialPriceResponse response = new IntegrationMaterialPriceResponse();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
2026-06-25 19:08:21 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrg", SqlDbType.NVarChar, request.SalesOrg),
|
2026-06-23 17:34:45 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode),
|
2026-06-25 19:08:21 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@ConditionType", SqlDbType.NVarChar, request.ConditionType),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.NVarChar, string.IsNullOrWhiteSpace(request.CustomerNumber)? null : request.CustomerNumber ),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerGroup", SqlDbType.NVarChar, string.IsNullOrWhiteSpace(request.CustomerGroupCode)? null : request.CustomerGroupCode )
|
2026-06-23 17:34:45 +06:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetMaterialPriceByMaterialCodeAndConditionType", parameterValues: p))
|
|
|
|
|
|
{
|
2026-06-25 19:08:21 +06:00
|
|
|
|
if (dr.Read())
|
2026-06-23 17:34:45 +06:00
|
|
|
|
{
|
|
|
|
|
|
response=new IntegrationMaterialPriceResponse()
|
|
|
|
|
|
{
|
|
|
|
|
|
MaterialPriceId = dr.GetInt32(0),
|
|
|
|
|
|
SalesOrg = dr.GetString(1),
|
|
|
|
|
|
DistributionChannel = dr.GetString(2),
|
2026-06-25 19:08:21 +06:00
|
|
|
|
CustomerNumber = dr.IsDBNull(3) ? null : dr.GetString(3),
|
2026-06-23 17:34:45 +06:00
|
|
|
|
CustomerGroupCode = dr.IsDBNull(4) ? null : dr.GetString(4),
|
|
|
|
|
|
MaterialCode = dr.GetString(5),
|
|
|
|
|
|
ConditionType = dr.GetString(6),
|
|
|
|
|
|
CalculationType = dr.GetString(7),
|
|
|
|
|
|
PricingUnit = dr.GetString(8),
|
|
|
|
|
|
UnitOfMeasure = dr.GetString(9),
|
|
|
|
|
|
ValidFrom = dr.GetDateTime(10),
|
|
|
|
|
|
ValidTo = dr.GetDateTime(11),
|
|
|
|
|
|
Status = dr.IsDBNull(12) ? null : dr.GetString(12),
|
|
|
|
|
|
ConditionValue = dr.GetDecimal(13)
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
dr.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-25 19:08:21 +06:00
|
|
|
|
private bool CreateMaterialPrice(TransactionContext tc, IntegrationMaterialPriceRequest request)
|
2026-06-23 17:34:45 +06:00
|
|
|
|
{
|
2026-06-25 19:08:21 +06:00
|
|
|
|
bool response = false;
|
2026-06-23 17:34:45 +06:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrg", SqlDbType.NVarChar, request.SalesOrg),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.NVarChar, request.DistributionChannel),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.NVarChar, request.CustomerNumber),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerGroupCode", SqlDbType.NVarChar, request.CustomerGroupCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ConditionType", SqlDbType.NVarChar, request.ConditionType),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CalculationType", SqlDbType.NVarChar, request.CalculationType),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@PricingUnit", SqlDbType.NVarChar, request.PricingUnit),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@UnitOfMeasure", SqlDbType.NVarChar, request.UnitOfMeasure),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ValidFrom", SqlDbType.DateTime, request.ValidFrom),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ValidTo", SqlDbType.DateTime, request.ValidTo),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@Status", SqlDbType.NVarChar, request.Status),
|
2026-06-25 19:08:21 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@ConditionValue", SqlDbType.Decimal, request.ConditionValue)
|
2026-06-23 17:34:45 +06:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.InsertIntegrationMaterialPrice", parameterValues: p);
|
|
|
|
|
|
|
2026-06-25 19:08:21 +06:00
|
|
|
|
response = true;
|
2026-06-23 17:34:45 +06:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-25 19:08:21 +06:00
|
|
|
|
return response;
|
2026-06-23 17:34:45 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool UpdateMaterialPrice(TransactionContext tc, IntegrationMaterialPriceRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool returnValue = false;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrg", SqlDbType.NVarChar, request.SalesOrg),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.NVarChar, request.DistributionChannel),
|
2026-06-25 19:08:21 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.NVarChar, string.IsNullOrWhiteSpace(request.CustomerNumber) ? null : request.CustomerNumber),
|
2026-06-23 17:34:45 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerGroupCode", SqlDbType.NVarChar, request.CustomerGroupCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ConditionType", SqlDbType.NVarChar, request.ConditionType),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CalculationType", SqlDbType.NVarChar, request.CalculationType),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@PricingUnit", SqlDbType.NVarChar, request.PricingUnit),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@UnitOfMeasure", SqlDbType.NVarChar, request.UnitOfMeasure),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ValidFrom", SqlDbType.DateTime, request.ValidFrom),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ValidTo", SqlDbType.DateTime, request.ValidTo),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@Status", SqlDbType.NVarChar, request.Status),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ConditionValue", SqlDbType.Decimal, request.ConditionValue)
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.UpdateIntegrationMaterialPrice", parameterValues: p);
|
|
|
|
|
|
|
|
|
|
|
|
returnValue = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
2026-06-25 12:41:18 +06:00
|
|
|
|
|
|
|
|
|
|
#region Material Free Goods Private Functions
|
|
|
|
|
|
|
|
|
|
|
|
private async Task<IntegrationMaterialFreeGoodsResponse> GetMaterialFreeGoodsByFilterAsync(
|
|
|
|
|
|
TransactionContext tc, GetMaterialFreeGoodsByFilterRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntegrationMaterialFreeGoodsResponse response = new IntegrationMaterialFreeGoodsResponse();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
2026-06-25 19:08:21 +06:00
|
|
|
|
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrg", SqlDbType.NVarChar, request.SalesOrg),
|
2026-06-25 12:41:18 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.NVarChar, request.DistributionChannel),
|
2026-06-25 19:08:21 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.NVarChar, request.CustomerNumber),
|
2026-06-25 12:41:18 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerPriceGroup", SqlDbType.NVarChar, request.CustomerPriceGroup),
|
2026-06-25 19:08:21 +06:00
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode)
|
2026-06-25 12:41:18 +06:00
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetAllMaterialFreeGoodsForUpdate", parameterValues: p))
|
|
|
|
|
|
{
|
|
|
|
|
|
while (dr.Read())
|
|
|
|
|
|
{
|
|
|
|
|
|
response= new IntegrationMaterialFreeGoodsResponse()
|
|
|
|
|
|
{
|
|
|
|
|
|
FreeGoodsId = dr.GetInt32(0),
|
|
|
|
|
|
SalesOrg = dr.GetString(1),
|
|
|
|
|
|
DistributionChannel = dr.GetString(2),
|
|
|
|
|
|
CustomerNumber = dr.IsDBNull(3) ? null : dr.GetString(3),
|
|
|
|
|
|
CustomerPriceGroup = dr.GetString(4),
|
|
|
|
|
|
MaterialCode = dr.GetString(5),
|
|
|
|
|
|
MinOrderQuantity = dr.GetDecimal(6),
|
|
|
|
|
|
ForQuantity = dr.GetDecimal(7),
|
|
|
|
|
|
UnitOfMeasure = dr.GetString(8),
|
|
|
|
|
|
FreeQuantity = dr.GetDecimal(9),
|
|
|
|
|
|
FocUnitOfMeasure = dr.GetString(10),
|
|
|
|
|
|
ValidFrom = dr.GetDateTime(11),
|
|
|
|
|
|
ValidTo = dr.GetDateTime(12),
|
|
|
|
|
|
Status = dr.IsDBNull(13) ? null : dr.GetString(13)
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
dr.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-25 19:08:21 +06:00
|
|
|
|
private bool CreateMaterialFreeGoods(TransactionContext tc, IntegrationMaterialFreeGoodsRequest request)
|
2026-06-25 12:41:18 +06:00
|
|
|
|
{
|
2026-06-25 19:08:21 +06:00
|
|
|
|
bool response = false;
|
2026-06-25 12:41:18 +06:00
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrg", SqlDbType.NVarChar, request.SalesOrg),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.NVarChar, request.DistributionChannel),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.NVarChar, (object?)request.CustomerNumber ?? DBNull.Value),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerPriceGroup", SqlDbType.NVarChar, request.CustomerPriceGroup),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MinOrderQuantity", SqlDbType.Decimal, request.MinOrderQuantity),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ForQuantity", SqlDbType.Decimal, request.ForQuantity),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@UnitOfMeasure", SqlDbType.NVarChar, request.UnitOfMeasure),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@FreeQuantity", SqlDbType.Decimal, request.FreeQuantity),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@FocUnitOfMeasure", SqlDbType.NVarChar, request.FocUnitOfMeasure),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ValidFrom", SqlDbType.Date, request.ValidFrom),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ValidTo", SqlDbType.Date, request.ValidTo),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@Status", SqlDbType.NVarChar, (object?)request.Status ?? DBNull.Value),
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.InsertIntegrationMaterialFreeGoods", parameterValues: p);
|
|
|
|
|
|
|
2026-06-25 19:08:21 +06:00
|
|
|
|
response = true;
|
2026-06-25 12:41:18 +06:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-25 19:08:21 +06:00
|
|
|
|
return response;
|
2026-06-25 12:41:18 +06:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool UpdateMaterialFreeGoods(TransactionContext tc, IntegrationMaterialFreeGoodsRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool returnValue = false;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrg", SqlDbType.NVarChar, request.SalesOrg),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@DistributionChannel", SqlDbType.NVarChar, request.DistributionChannel),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerNumber", SqlDbType.NVarChar, string.IsNullOrWhiteSpace(request.CustomerNumber)? null : request.CustomerNumber ),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CustomerPriceGroup", SqlDbType.NVarChar, request.CustomerPriceGroup),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MaterialCode", SqlDbType.NVarChar, request.MaterialCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@MinOrderQuantity", SqlDbType.Decimal, request.MinOrderQuantity),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ForQuantity", SqlDbType.Decimal, request.ForQuantity),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@UnitOfMeasure", SqlDbType.NVarChar, request.UnitOfMeasure),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@FreeQuantity", SqlDbType.Decimal, request.FreeQuantity),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@FocUnitOfMeasure", SqlDbType.NVarChar, request.FocUnitOfMeasure),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ValidFrom", SqlDbType.Date, request.ValidFrom),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ValidTo", SqlDbType.Date, request.ValidTo),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@Status", SqlDbType.NVarChar, (object?)request.Status ?? DBNull.Value)
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.UpdateIntegrationMaterialFreeGoods", parameterValues: p);
|
|
|
|
|
|
|
|
|
|
|
|
returnValue = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-28 19:02:40 +06:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Credit Code Private Functions
|
|
|
|
|
|
|
|
|
|
|
|
private async Task<IntegrationPaymentTermResponse> GetPaymentTermByFilterAsync(TransactionContext tc,
|
|
|
|
|
|
GetIntegrationPaymentTermRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
IntegrationPaymentTermResponse response = new IntegrationPaymentTermResponse();
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CreditCode", SqlDbType.NVarChar, request.CreditCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrg", SqlDbType.NVarChar, request.SalesOrg)
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetPaymentTermByFilter", parameterValues: p))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (dr.Read())
|
|
|
|
|
|
{
|
|
|
|
|
|
response=new IntegrationPaymentTermResponse()
|
|
|
|
|
|
{
|
|
|
|
|
|
CreditCodeId = dr.GetInt32(0),
|
|
|
|
|
|
CreditCode = dr.GetString(1),
|
|
|
|
|
|
Description = dr.GetString(2),
|
|
|
|
|
|
ValidFrom = dr.GetDateTime(3),
|
|
|
|
|
|
ValidTo = dr.GetDateTime(4),
|
|
|
|
|
|
SalesOrg = dr.GetString(5)
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
dr.Close();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw DBCustomError.GenerateCustomError(ex);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool CreatePaymentTerm(TransactionContext tc, IntegrationPaymentTermRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool response = false;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CreditCode", SqlDbType.NVarChar, request.CreditCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@Description", SqlDbType.NVarChar, request.Description),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ValidFrom", SqlDbType.DateTime, request.ValidFrom),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ValidTo", SqlDbType.DateTime, request.ValidTo),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrg", SqlDbType.NVarChar, request.SalesOrg)
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.InsertIntegrationPaymentTerm", parameterValues: p);
|
|
|
|
|
|
|
|
|
|
|
|
response = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return response;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private bool UpdatePaymentTerm(TransactionContext tc, IntegrationPaymentTermRequest request)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool returnValue = false;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
SqlParameter[] p =
|
|
|
|
|
|
[
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@CreditCode", SqlDbType.NVarChar, request.CreditCode),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@Description", SqlDbType.NVarChar, request.Description),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ValidFrom", SqlDbType.DateTime, request.ValidFrom),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@ValidTo", SqlDbType.DateTime, request.ValidTo),
|
|
|
|
|
|
SqlHelperExtension.CreateInParam("@SalesOrg", SqlDbType.NVarChar, request.SalesOrg)
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
_ = tc.ExecuteNonQuerySp(spName: "dbo.UpdateIntegrationPaymentTerms", parameterValues: p);
|
|
|
|
|
|
|
|
|
|
|
|
returnValue = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception)
|
|
|
|
|
|
{
|
|
|
|
|
|
throw;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-06-25 12:41:18 +06:00
|
|
|
|
#endregion
|
2026-06-16 17:22:46 +06:00
|
|
|
|
}
|