NbrMasterController.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using Procurement.Enums;
  2. using Microsoft.AspNetCore.Mvc;
  3. using System;
  4. using System.Threading.Tasks;
  5. using Volo.Abp.AspNetCore.Mvc;
  6. using Procurement.EntityFrameworkCore.SqlRepositories;
  7. using Procurement.ViewModel;
  8. using Procurement.Helpers;
  9. using System.Data;
  10. using System.Data.SqlClient;
  11. namespace Procurement.Controllers
  12. {
  13. [Produces("application/json")]
  14. [Route("api/[controller]")]
  15. public class NbrMasterController : AbpController
  16. {
  17. private readonly ISqlRepository _repository;
  18. public NbrMasterController(ISqlRepository sqlRepository)
  19. {
  20. _repository = sqlRepository;
  21. }
  22. /// <summary>
  23. /// µ¥ºÅÑ¡ÔñÁбí
  24. /// </summary>
  25. /// <param name="domain"></param>
  26. /// <returns></returns>
  27. [Route("nbrselectlist")]
  28. [HttpGet]
  29. public async Task<IActionResult> Get(string domain, string type, string nbrtype, string userno)
  30. {
  31. ResultCode code = ResultCode.Success, subCode = ResultCode.Success;
  32. string subMsg = "";
  33. dynamic items = null;
  34. try
  35. {
  36. SqlParameter[] parameters = {
  37. new SqlParameter { ParameterName = "@Domain", Value = domain,SqlDbType=SqlDbType.VarChar},
  38. new SqlParameter { ParameterName = "@NbrType", Value = nbrtype,SqlDbType=SqlDbType.VarChar},
  39. new SqlParameter { ParameterName = "@Type", Value = type,SqlDbType=SqlDbType.VarChar},
  40. new SqlParameter { ParameterName = "@UserNo", Value = userno,SqlDbType=SqlDbType.VarChar}
  41. };
  42. items = await _repository.GetSingleListByProcAsync("pr_WMS_GetNbrList", parameters);
  43. }
  44. catch (Exception ex)
  45. {
  46. subMsg = ex.Message;
  47. code = ResultCode.Fail;
  48. subCode = ResultCode.Fail;
  49. }
  50. ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg);
  51. return Ok(result);
  52. }
  53. [Route("nbrdetails")]
  54. [HttpGet]
  55. public async Task<IActionResult> GetNbrDetails(string domain, string nbr, string type)
  56. {
  57. ResultCode code = ResultCode.Success, subCode = ResultCode.Success;
  58. string subMsg = "";
  59. dynamic items = null;
  60. try
  61. {
  62. SqlParameter[] parameters = {
  63. new SqlParameter { ParameterName = "@Domain", Value = domain,SqlDbType=SqlDbType.VarChar},
  64. new SqlParameter { ParameterName = "@Nbr", Value = nbr,SqlDbType=SqlDbType.VarChar},
  65. new SqlParameter { ParameterName = "@Type", Value = type,SqlDbType=SqlDbType.VarChar}
  66. };
  67. items = await _repository.GetListByProcAsync("pr_WMS_GetNbrDetails", parameters);
  68. }
  69. catch (Exception ex)
  70. {
  71. subMsg = ex.Message;
  72. code = ResultCode.Fail;
  73. subCode = ResultCode.Fail;
  74. }
  75. ResultViewModel result = ResultHelper.CreateResult(code, items, subCode, subMsg);
  76. return Ok(result);
  77. }
  78. }
  79. }