1 changed files with 65 additions and 0 deletions
@ -0,0 +1,65 @@ |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using System.Net.Http; |
|||
using System.Net.Http.Headers; |
|||
using AMESCoreStudio.CommonTools.Result; |
|||
using Microsoft.EntityFrameworkCore; |
|||
using System.Data.Common; |
|||
using System.Data; |
|||
using System.Dynamic; |
|||
|
|||
namespace AMESCoreStudio.WebApi.Controllers.QASRV |
|||
{ |
|||
[Route("api/[controller]")]
|
|||
[ApiController] |
|||
public class CheckSfisKayPartController : ControllerBase |
|||
{ |
|||
/// <summary>
|
|||
/// 查詢SFIS 有效序號 KeyParts
|
|||
/// </summary>
|
|||
/// <param name="id">KeyParts序號</param>
|
|||
/// <returns></returns>
|
|||
[Route("GetSfisKeyParts/{id}")] |
|||
[HttpGet] |
|||
public async Task<ResultModel<dynamic>> GetSFISKeyParts(string id) |
|||
{ |
|||
ResultModel<dynamic> result = new ResultModel<dynamic>(); |
|||
ESUNContext _esun_context = new ESUNContext(); |
|||
DbConnection esun_conn = _esun_context.Database.GetDbConnection(); |
|||
try |
|||
{ |
|||
if (esun_conn.State != System.Data.ConnectionState.Open) |
|||
{ |
|||
await esun_conn.OpenAsync(); |
|||
} |
|||
result.Msg = "N"; |
|||
|
|||
string strsql = $@" SELECT * FROM SFIS.dbo.ZPDKeyPart
|
|||
WHERE IsActive = 1 AND PartBarcode = '{id.ToUpper().Trim()}'";
|
|||
|
|||
using (var esun_cmd = esun_conn.CreateCommand()) |
|||
{ |
|||
esun_cmd.CommandText = strsql; |
|||
using (var esun_reader = await esun_cmd.ExecuteReaderAsync()) |
|||
{ |
|||
if (esun_reader.HasRows) |
|||
{ |
|||
result.Msg = "Y"; |
|||
} |
|||
} |
|||
|
|||
} |
|||
result.Success = true; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
result.Msg = ex.Message; |
|||
result.Success = false; |
|||
} |
|||
return result; |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue