using Procurement.Enums;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;
using Procurement.EntityFrameworkCore.SqlRepositories;
using Procurement.ViewModel;
using Procurement.Helpers;
using System.Data.SqlClient;
using System.Data;
namespace Procurement.Controllers
{
[Produces("application/json")]
[Route("api/[controller]")]
public class PurOrdMasterController : AbpController
{
private readonly ISqlRepository _repository;
public PurOrdMasterController(ISqlRepository sqlRepository)
{
_repository = sqlRepository;
}
///
/// 采购单选择列表
///
///
///
[Route("purordselectlist")]
[HttpGet]
public async Task GetPurOrd(string domain, string type = "", string supplier = "")
{
ResultCode code = ResultCode.Success, subCode = ResultCode.Success;
string subMsg = "";
dynamic items = null;
try
{
SqlParameter[] parameters = {
new SqlParameter { ParameterName = "@Domain", Value = domain,SqlDbType=SqlDbType.VarChar},
new SqlParameter { ParameterName = "@Type", Value = type,SqlDbType=SqlDbType.VarChar},
new SqlParameter { ParameterName = "@Supplier", Value = supplier,SqlDbType=SqlDbType.VarChar},
};
items = await _repository.GetSingleListByProcAsync("pr_WMS_GetPurOrdList", parameters);
}
catch (Exception ex)
{
subMsg = ex.Message;
code = ResultCode.Fail;
subCode = ResultCode.Fail;
}
ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg);
return Ok(result);
}
[Route("purorddetails")]
[HttpGet]
public async Task GetPurOrdDetails(string domain, string purord, string type, string shipnbr = "")
{
ResultCode code = ResultCode.Success, subCode = ResultCode.Success;
string subMsg = "";
dynamic items = null;
try
{
SqlParameter[] parameters = {
new SqlParameter { ParameterName = "@Domain", Value = domain,SqlDbType=SqlDbType.VarChar},
new SqlParameter { ParameterName = "@PurOrd", Value = purord,SqlDbType=SqlDbType.VarChar},
new SqlParameter { ParameterName = "@Type", Value = type,SqlDbType=SqlDbType.VarChar},
new SqlParameter { ParameterName = "@ShipNbr", Value = shipnbr,SqlDbType=SqlDbType.VarChar},
};
items = await _repository.GetListByProcAsync("pr_WMS_GetPurOrdDetails", parameters);
}
catch (Exception ex)
{
subMsg = ex.Message;
code = ResultCode.Fail;
subCode = ResultCode.Fail;
}
ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg);
return Ok(result);
}
[Route("purordnbrdetails")]
[HttpGet]
public async Task GetPurOrdNbrDetails(string domain, string purord, string nbr)
{
ResultCode code = ResultCode.Success, subCode = ResultCode.Success;
string subMsg = "";
dynamic items = null;
try
{
SqlParameter[] parameters = {
new SqlParameter { ParameterName = "@Domain", Value = domain,SqlDbType=SqlDbType.VarChar},
new SqlParameter { ParameterName = "@PurOrd", Value = purord,SqlDbType=SqlDbType.VarChar},
new SqlParameter { ParameterName = "@Nbr", Value = nbr,SqlDbType=SqlDbType.VarChar}
};
items = await _repository.GetListByProcAsync("pr_WMS_GetVMIPurOrdNbrDetails", parameters);
}
catch (Exception ex)
{
subMsg = ex.Message;
code = ResultCode.Fail;
subCode = ResultCode.Fail;
}
ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg);
return Ok(result);
}
}
}