11 changed files with 701 additions and 10 deletions
@ -0,0 +1,89 @@ |
|||||
|
@model AMESCoreStudio.WebApi.Models.AMES.InspectionResultReject |
||||
|
|
||||
|
|
||||
|
@{ ViewData["Title"] = "SPC004J"; |
||||
|
Layout = "~/Views/Shared/_FormLayout.cshtml"; } |
||||
|
|
||||
|
|
||||
|
<style> |
||||
|
.control-label { |
||||
|
justify-content: flex-end !important; |
||||
|
} |
||||
|
</style> |
||||
|
|
||||
|
<div class="row"> |
||||
|
<div class="col-sm-12"> |
||||
|
<form enctype="multipart/form-data" onsubmit="return tt();" method="post" asp-action="SPC004JSave"> |
||||
|
<div asp-validation-summary="ModelOnly" class="text-danger"></div> |
||||
|
<input type="hidden" id="InspectionID" asp-for="InspectionID" value="@ViewBag.InspectionID" /> |
||||
|
<input type="hidden" id="InspectionItemID" asp-for="InspectionItemID" value="@ViewBag.InspectionItemID" /> |
||||
|
<input type="hidden" asp-for="CreateUserID" value="@ViewBag.UserID" /> |
||||
|
<input type="hidden" asp-for="CreateDate" value="@System.DateTime.Now" /> |
||||
|
<input type="hidden" asp-for="InspectionRejectID" value="0" /> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="BarcodeNo" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="BarcodeNo" class="form-control col-sm-1" value="@ViewBag.BarcodeNo" readonly="readonly" /> |
||||
|
<span asp-validation-for="BarcodeNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="WipNo" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="WipNo" class="form-control col-sm-1" value="@ViewBag.WipNo" readonly="readonly" /> |
||||
|
<span asp-validation-for="WipNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="ItemNo" class="control-label col-sm-3"></label> |
||||
|
<input asp-for="ItemNo" class="form-control col-sm-1" value="@ViewBag.ItemNo" readonly="readonly" /> |
||||
|
<span asp-validation-for="ItemNo" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
|
||||
|
|
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="RejectAddress" class="control-label col-sm-3"></label> |
||||
|
<textarea cols="50" rows="3" asp-for="RejectAddress" class="layui-textarea"></textarea> |
||||
|
<span asp-validation-for="RejectAddress" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<div class="form-group form-inline my-sm-1"> |
||||
|
<label asp-for="RejectReason" class="control-label col-sm-3"></label> |
||||
|
<textarea cols="50" rows="3" asp-for="RejectReason" class="layui-textarea"></textarea> |
||||
|
<span asp-validation-for="RejectReason" class="text-danger offset-sm-3 my-sm-1"></span> |
||||
|
</div> |
||||
|
<span style="color: firebrick;word-break: break-all;" class="text-danger offset-sm-3">@Html.ValidationMessage("error")</span> |
||||
|
<div class="form-group"> |
||||
|
<input type="submit" value="退回" class="btn btn-primary offset-sm-3" /> |
||||
|
</div> |
||||
|
|
||||
|
</form> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
@section Scripts { |
||||
|
@{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); |
||||
|
await Html.RenderPartialAsync("_FileinputScriptsPartial"); } |
||||
|
|
||||
|
<script type="text/javascript"> |
||||
|
function tt() { |
||||
|
var data2 = $("#RejectReason").val(); |
||||
|
var data3 = $("#RejectReason").val(); |
||||
|
if (data2.trim() == "" || data3.trim() == "") { |
||||
|
alert('請填寫退回原因及通知人Mail Address!!!!'); |
||||
|
return false; |
||||
|
} |
||||
|
else { |
||||
|
return true; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
$(document).ready(function () { |
||||
|
var error = '@Html.ValidationMessage("error")'; |
||||
|
if ($(error).text() != '') { |
||||
|
parent.hg.msg(error); |
||||
|
} |
||||
|
}); |
||||
|
</script> |
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,202 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.WebApi; |
||||
|
using AMESCoreStudio.WebApi.Models.AMES; |
||||
|
using AMESCoreStudio.WebApi.DTO.AMES; |
||||
|
using AMESCoreStudio.CommonTools.Result; |
||||
|
|
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Controllers.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 巡檢類別資料维护
|
||||
|
/// </summary>
|
||||
|
[Route("api/[controller]")]
|
||||
|
[ApiController] |
||||
|
public class InspectionResultRejectsController : ControllerBase |
||||
|
{ |
||||
|
private readonly AMESContext _context; |
||||
|
|
||||
|
/// <summary>
|
||||
|
///
|
||||
|
/// </summary>
|
||||
|
/// <param name="context"></param>
|
||||
|
public InspectionResultRejectsController(AMESContext context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 获取全部巡檢類別資料
|
||||
|
/// </summary>
|
||||
|
/// <returns></returns>
|
||||
|
// GET: api/InspectionResultRejects
|
||||
|
[HttpGet] |
||||
|
public async Task<ActionResult<IEnumerable<InspectionResultReject>>> GetInspectionResultRejects() |
||||
|
{ |
||||
|
IQueryable<InspectionResultReject> q = _context.InspectionResultRejects; |
||||
|
q = q.OrderBy(p => p.InspectionID); |
||||
|
q = q.OrderBy(p => p.InspectionItemID); |
||||
|
|
||||
|
var InspectionResultRejects = await q.ToListAsync(); |
||||
|
|
||||
|
return InspectionResultRejects; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 用ID获取该巡檢類別資料
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// GET: api/InspectionResultRejects/5
|
||||
|
[HttpGet("{id}")] |
||||
|
public async Task<ActionResult<IEnumerable<InspectionResultReject>>> GetInspectionResultRejects(int id) |
||||
|
{ |
||||
|
|
||||
|
IQueryable<InspectionResultReject> q = _context.InspectionResultRejects; |
||||
|
q = q.Where(p => p.InspectionRejectID.Equals(id)); |
||||
|
q = q.OrderBy(p => p.InspectionItemID); |
||||
|
var InspectionResultReject = await q.ToListAsync(); |
||||
|
|
||||
|
if (InspectionResultReject == null) |
||||
|
{ |
||||
|
return NotFound(); |
||||
|
} |
||||
|
|
||||
|
return InspectionResultReject; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 用ID获取该巡檢類別資料
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <param name="Iid"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// GET: api/InspectionResultRejects/5
|
||||
|
[HttpGet("Query/{id}/{Iid}")] |
||||
|
public async Task<ActionResult<IEnumerable<InspectionResultReject>>> GetInspectionResultRejectByQuery(int id, int Iid) |
||||
|
{ |
||||
|
|
||||
|
IQueryable<InspectionResultReject> q = _context.InspectionResultRejects; |
||||
|
q = q.Where(p => p.InspectionID.Equals(id)); |
||||
|
q = q.Where(p => p.InspectionItemID.Equals(Iid)); |
||||
|
var InspectionResultReject = await q.ToListAsync(); |
||||
|
|
||||
|
if (InspectionResultReject == null) |
||||
|
{ |
||||
|
return InspectionResultReject; |
||||
|
} |
||||
|
|
||||
|
return InspectionResultReject; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 更新巡檢類別資料
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <param name="InspectionResultReject"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// PUT: api/InspectionResultRejects/5
|
||||
|
// To protect from overposting attacks, enable the specific properties you want to bind to, for
|
||||
|
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
|
||||
|
[HttpPut("{id}")] |
||||
|
public async Task<ResultModel<InspectionResultReject>> PutInspectionResultReject(int id, [FromBody] InspectionResultReject InspectionResultReject) |
||||
|
{ |
||||
|
ResultModel<InspectionResultReject> result = new ResultModel<InspectionResultReject>(); |
||||
|
if (id != InspectionResultReject.InspectionID) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = "序號錯誤"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
_context.Entry(InspectionResultReject).State = EntityState.Modified; |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = e.Message; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 新增巡檢類別資料
|
||||
|
/// </summary>
|
||||
|
/// <param name="InspectionResultReject"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// POST: api/InspectionResultRejects
|
||||
|
// To protect from overposting attacks, enable the specific properties you want to bind to, for
|
||||
|
// more details, see https://go.microsoft.com/fwlink/?linkid=2123754.
|
||||
|
[HttpPost] |
||||
|
public async Task<ResultModel<InspectionResultReject>> PostInspectionResultRejects(InspectionResultReject InspectionResultReject) |
||||
|
{ |
||||
|
ResultModel<InspectionResultReject> result = new ResultModel<InspectionResultReject>(); |
||||
|
Helper helper = new Helper(_context); |
||||
|
var InspectionResultRejectID = helper.GetIDKey("INSPECTION_REJECT_ID").Result; |
||||
|
InspectionResultReject.InspectionRejectID = InspectionResultRejectID; |
||||
|
_context.InspectionResultRejects.Add(InspectionResultReject); |
||||
|
try |
||||
|
{ |
||||
|
await _context.SaveChangesAsync(); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = e.Message; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
return result; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 删除巡檢類別資料
|
||||
|
/// </summary>
|
||||
|
/// <param name="id"></param>
|
||||
|
/// <returns></returns>
|
||||
|
// DELETE: api/InspectionResultRejects/5
|
||||
|
[HttpDelete("{id}")] |
||||
|
public async Task<ResultModel<InspectionResultReject>> DeleteInspectionResultRejects(int id) |
||||
|
{ |
||||
|
ResultModel<InspectionResultReject> result = new ResultModel<InspectionResultReject>(); |
||||
|
var inspectionType = await _context.InspectionResultRejects.Where(m => m.InspectionID == id).FirstOrDefaultAsync(); |
||||
|
if (inspectionType == null) |
||||
|
{ |
||||
|
result.Success = false; |
||||
|
result.Msg = "序號不存在"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
_context.InspectionResultRejects.Remove(inspectionType); |
||||
|
await _context.SaveChangesAsync(); |
||||
|
|
||||
|
result.Success = true; |
||||
|
result.Msg = "OK"; |
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
private bool InspectionResultRejectsExists(int id) |
||||
|
{ |
||||
|
return _context.InspectionResultRejects.Any(e => e.InspectionID == id); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
@ -0,0 +1,103 @@ |
|||||
|
using System; |
||||
|
using System.ComponentModel.DataAnnotations; |
||||
|
using System.ComponentModel.DataAnnotations.Schema; |
||||
|
using System.Runtime.Serialization; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using AMESCoreStudio.WebApi.Models.BAS; |
||||
|
using AMESCoreStudio.WebApi.Models.SYS; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace AMESCoreStudio.WebApi.Models.AMES |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 巡檢結果回覆明細資料檔
|
||||
|
/// </summary>
|
||||
|
[Keyless] |
||||
|
[Table("INSPECTION_RESULT_REJECT", Schema = "JHAMES")] |
||||
|
public partial class InspectionResultReject |
||||
|
{ |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 巡檢結果退回ID
|
||||
|
/// </summary>
|
||||
|
[Column("INSPECTION_REJECT_ID")] |
||||
|
[Key] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
public int InspectionRejectID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 巡檢結果ID
|
||||
|
/// </summary>
|
||||
|
[Column("INSPECTION_ID")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
public int InspectionID { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 巡檢項目ID
|
||||
|
/// </summary>
|
||||
|
[Column("INSPECTION_ITEMID")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
public int InspectionItemID { get; set; } |
||||
|
|
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 退回原因
|
||||
|
/// </summary>
|
||||
|
[Column("REJECT_REASON")] |
||||
|
[StringLength(200)] |
||||
|
[Display(Name = "退回原因")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
public string RejectReason { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 退回通知人
|
||||
|
/// </summary>
|
||||
|
[Column("REJECT_ADDRESS")] |
||||
|
[Display(Name = "退回通知人")] |
||||
|
[DataMember] |
||||
|
[Required(ErrorMessage = "{0},不能空白")] |
||||
|
public string RejectAddress { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 創建者ID
|
||||
|
/// </summary>
|
||||
|
[Column("CREATE_USERID")] |
||||
|
[DataMember] |
||||
|
public int CreateUserID { get; set; } = 0; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// 創建日期
|
||||
|
/// </summary>
|
||||
|
[Column("CREATE_DATE")] |
||||
|
[DataMember] |
||||
|
public DateTime CreateDate { get; set; } = System.DateTime.Now; |
||||
|
/// <summary>
|
||||
|
/// 工單號碼
|
||||
|
/// </summary>
|
||||
|
///
|
||||
|
[Display(Name = "工單號碼")] |
||||
|
[NotMapped] |
||||
|
[DataMember] |
||||
|
public string WipNo { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 料號
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "料號")] |
||||
|
[NotMapped] |
||||
|
[DataMember] |
||||
|
public string ItemNo { get; set; } |
||||
|
/// <summary>
|
||||
|
/// 檢驗編號
|
||||
|
/// </summary>
|
||||
|
[Display(Name = "檢驗編號")] |
||||
|
[NotMapped] |
||||
|
[DataMember] |
||||
|
public string BarcodeNo { get; set; } |
||||
|
|
||||
|
} |
||||
|
} |
Loading…
Reference in new issue