14 changed files with 678 additions and 229 deletions
@ -0,0 +1,76 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace AMESCoreStudio.Web.Code |
||||
|
{ |
||||
|
|
||||
|
public class Entire |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 10進位與16進位互轉 Types = DecToHex/HexToDec
|
||||
|
/// </summary>
|
||||
|
/// <param name="InputTXT"></param>
|
||||
|
/// <param name="Types">10-16:DecToHex 16-10:HexToDec</param>
|
||||
|
/// <returns></returns>
|
||||
|
public string DecHex(string InputTXT, string Types) |
||||
|
{ |
||||
|
// 10 to 16
|
||||
|
if (Types == "DecToHex") |
||||
|
{ |
||||
|
|
||||
|
// To hold our converted unsigned integer32 value
|
||||
|
uint uiDecimal = 0; |
||||
|
try |
||||
|
{ |
||||
|
// Convert text string to unsigned integer
|
||||
|
uiDecimal = checked((uint)System.Convert.ToUInt32(InputTXT)); |
||||
|
} |
||||
|
|
||||
|
catch (System.OverflowException exception) |
||||
|
{ |
||||
|
// Show overflow message and return
|
||||
|
return "Overflow" + exception.ToString(); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// Format unsigned integer value to hex and show in another textbox
|
||||
|
return String.Format("{0:x2}", uiDecimal); |
||||
|
} |
||||
|
|
||||
|
// 16 to 10
|
||||
|
else if (Types == "HexToDec") |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
// To hold our converted unsigned integer32 value
|
||||
|
uint uiHex = 0; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
// Convert hex string to unsigned integer
|
||||
|
uiHex = System.Convert.ToUInt32(InputTXT, 16); |
||||
|
} |
||||
|
|
||||
|
catch (System.OverflowException exception) |
||||
|
{ |
||||
|
// Show overflow message and return
|
||||
|
return "Overflow " + exception.ToString(); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
// Format it and show as a string
|
||||
|
return uiHex.ToString(); |
||||
|
|
||||
|
|
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return "input Type ERROR"; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,139 @@ |
|||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
using AMESCoreStudio.WebApi.DTO.AMES; |
||||
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class MatPropertyController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 料號属性代碼基本檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="context"></param>
|
||||
|
public MatPropertyController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 料號属性代碼基本檔資料
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<MatProperty>>> GetMatProperty() |
||||
|
{ |
||||
|
IQueryable<MatProperty> q = _context.MatPropertys; |
||||
|
q = q.OrderBy(p => p.MatPropertyNo); |
||||
|
var MatProperty = await q.ToListAsync(); |
||||
|
return MatProperty; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 料號属性代碼基本檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="id">MatPropertyID</param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ActionResult<IEnumerable<MatProperty>>> GetMatProperty(string id) |
||||
|
{ |
||||
|
IQueryable<MatProperty> q = _context.MatPropertys; |
||||
|
var MatProperty = await q.Where(p => p.MatPropertyNo == id).ToListAsync(); |
||||
|
|
||||
|
//if (result.Data.Count() == 0)
|
||||
|
//{
|
||||
|
// return NotFound();
|
||||
|
//}
|
||||
|
|
||||
|
return MatProperty; |
||||
|
} |
||||
|
|
||||
|
///// <summary>
|
||||
|
///// 工單鎖定資料 to 工單號碼
|
||||
|
///// </summary>
|
||||
|
///// <param name="id">工單號碼</param>
|
||||
|
///// <returns></returns>
|
||||
|
//[HttpGet("ByWipNO/{id}")]
|
||||
|
//public async Task<ResultModel<MatProperty>> GetMatPropertyByWipNO(string id)
|
||||
|
//{
|
||||
|
// IQueryable<MatProperty> q = _context.MatPropertys;
|
||||
|
|
||||
|
// ResultModel<MatProperty> result = new ResultModel<MatProperty>();
|
||||
|
// result.Data = await q.Where(p => p.WipNO == id).ToListAsync();
|
||||
|
|
||||
|
// //if (result.Data.Count() == 0)
|
||||
|
// //{
|
||||
|
// // return NotFound();
|
||||
|
// //}
|
||||
|
|
||||
|
// return result;
|
||||
|
//}
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 新增料號属性代碼基本檔
|
||||
|
/// </summary>
|
||||
|
/// <param name="MatProperty"></param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
public async Task<ResultModel<MatProperty>> PostMatProperty([FromBody] MatProperty MatProperty) |
||||
|
{ |
||||
|
ResultModel<MatProperty> result = new ResultModel<MatProperty>(); |
||||
|
|
||||
|
_context.MatPropertys.Add(MatProperty); |
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新料號属性代碼基本檔
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPut] |
||||
|
public async Task<ResultModel<MatProperty>> PutMatProperty([FromBody] MatProperty MatProperty) |
||||
|
{ |
||||
|
ResultModel<MatProperty> result = new ResultModel<MatProperty>(); |
||||
|
_context.Attach(MatProperty); |
||||
|
//MatProperty.LockStatus = "1";
|
||||
|
//MatProperty.UnLockUserID = 0;
|
||||
|
//MatProperty.UnLockDate = DateTime.Now;
|
||||
|
// 指定更新某個欄位
|
||||
|
//_context.Entry(MatProperty).Property(p => p.UnLockReason).IsModified = true;
|
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
} |
||||
|
catch (Exception ex) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = ex.Message; |
||||
|
} |
||||
|
return result; |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,67 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using System.Runtime.Serialization; |
||||
|
#nullable disable |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Models.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 料號属性代碼基本檔
|
||||
|
/// </summary>
|
||||
|
[Keyless] |
||||
|
[Table("MAT_PROPERTY", Schema = "JHAMES")] |
||||
|
[Index(nameof(MatPropertyNo), Name = "MAT_PROPERTY_AK2", IsUnique = true)] |
||||
|
public partial class MatProperty |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 料號属性代碼
|
||||
|
/// </summary>
|
||||
|
[Column("MAT_PROPERTY_NO")] |
||||
|
[StringLength(2)] |
||||
|
[DataMember] |
||||
|
[Display(Name = "料號属性代碼")] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
public string MatPropertyNo { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 料號属性描述
|
||||
|
/// </summary>
|
||||
|
[Column("MAT_PROPERTY_DESC")] |
||||
|
[StringLength(80)] |
||||
|
[DataMember] |
||||
|
[Display(Name = "料號属性描述")] |
||||
|
public string MatPropertyDesc { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 料號属性類型
|
||||
|
/// </summary>
|
||||
|
[Column("MAT_PROPERTY_TYPE")] |
||||
|
[StringLength(2)] |
||||
|
[DataMember] |
||||
|
[Display(Name = "料號属性類型")] |
||||
|
public string MatPropertyType { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 附加屬性類型
|
||||
|
/// </summary>
|
||||
|
[Column("AFF_PRO_TYPE")] |
||||
|
[StringLength(2)] |
||||
|
[DataMember] |
||||
|
[Display(Name = "附加屬性類型")] |
||||
|
public string AffProType { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 附加屬性描述
|
||||
|
/// </summary>
|
||||
|
[Column("AFF_PRO_DESC")] |
||||
|
[StringLength(50)] |
||||
|
[DataMember] |
||||
|
[Display(Name = "附加屬性描述")] |
||||
|
public string AffProDesc { get; set; } |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
Loading…
Reference in new issue