From 8b7aa694e3a12676ca3ad73b7abe73549f702527 Mon Sep 17 00:00:00 2001 From: ray Date: Tue, 11 Jan 2022 01:52:12 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=96=B0=E5=A2=9EFQC001~003?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/FQCController.cs | 80 +++++++++++++ AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs | 39 +++++- AMESCoreStudio.Web/Views/FQC/FQC001.cshtml | 91 ++++++++++++++ AMESCoreStudio.Web/Views/FQC/FQC001C.cshtml | 66 +++++++++++ AMESCoreStudio.Web/Views/FQC/FQC001U.cshtml | 67 +++++++++++ AMESCoreStudio.Web/Views/FQC/FQC002.cshtml | 91 ++++++++++++++ AMESCoreStudio.Web/Views/FQC/FQC002C.cshtml | 66 +++++++++++ AMESCoreStudio.Web/Views/FQC/FQC002U.cshtml | 67 +++++++++++ AMESCoreStudio.Web/Views/FQC/FQC003.cshtml | 96 +++++++++++++++ AMESCoreStudio.Web/Views/FQC/FQC003C.cshtml | 75 ++++++++++++ AMESCoreStudio.Web/Views/FQC/FQC003U.cshtml | 67 +++++++++++ .../Controllers/AMES/QcGroupController.cs | 111 +++++++++++------- AMESCoreStudio.WebApi/Models/AMES/QcGroup.cs | 6 +- 13 files changed, 874 insertions(+), 48 deletions(-) create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC001.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC001C.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC001U.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC002.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC002C.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC002U.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC003.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC003C.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC003U.cshtml diff --git a/AMESCoreStudio.Web/Controllers/FQCController.cs b/AMESCoreStudio.Web/Controllers/FQCController.cs index 7bb3fc09..9fbd3a06 100644 --- a/AMESCoreStudio.Web/Controllers/FQCController.cs +++ b/AMESCoreStudio.Web/Controllers/FQCController.cs @@ -37,7 +37,78 @@ namespace AMESCoreStudio.Web.Controllers #region FQC001 檢驗類別維護 + public IActionResult FQC001() + { + return View(); + } + + //新增頁面 + public IActionResult FQC001C() + { + return View(); + } + + //修改页面 + [HttpGet] + public async Task FQC001UAsync(int id) + { + var result = await _fqcApi.GetQcGroup(id); + return View(result); + } + + public async Task FQC001DAsync(int id) + { + var result = await _fqcApi.DeleteQcGroup(id); + return Json(new Result() { success = result.Success, msg = result.Msg }); + } + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task FQC001Async(QcGroup model) + { + if (ModelState.IsValid) + { + IResultModel result; + if (model.GroupID == 0) + { + result = await _fqcApi.PostQcGroup(JsonConvert.SerializeObject(model)); + } + else + { + result = await _fqcApi.PutQcGroup(JsonConvert.SerializeObject(model)); + } + + if (result.Success) + { + var _msg = model.GroupID == 0 ? "新增成功!" : "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + + ModelState.AddModelError("error", result.Msg); + } + } + if (model.GroupID == 0) + { + return View("FQC01C", model); + } + return View("FQC001U", model); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task FQC001QueryAsync(int page = 1, int limit = 10) + { + var result = await _fqcApi.GetQcGroupQuery(page, limit); + + if (result.Data.Count() != 0) + { + return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + } + + return Json(new Table() { count = 0, data = null }); + } #endregion #region FQC002 檢驗項目維護 @@ -45,7 +116,16 @@ namespace AMESCoreStudio.Web.Controllers #endregion #region FQC003 檢驗結果維護 + public IActionResult FQC003() + { + return View(); + } + //新增頁面 + public IActionResult FQC003C() + { + return View(); + } #endregion #region FQC004 抽驗標準維護 diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs index 366d8138..56a15c6c 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs @@ -10,10 +10,45 @@ using AMESCoreStudio.WebApi.DTO.AMES; namespace AMESCoreStudio.Web { [JsonReturn] - public interface IFQC:IHttpApi + public interface IFQC : IHttpApi { #region FQC001 檢驗類別維護 - + /// + /// 新增檢驗類別維護 + /// + /// + [WebApiClient.Attributes.HttpPost("api/QcGroup")] + ITask> PostQcGroup([FromBody, RawJsonContent] string model); + + /// + /// 更新檢驗類別維護 + /// + /// + [WebApiClient.Attributes.HttpPut("api/QcGroup")] + ITask> PutQcGroup([FromBody, RawJsonContent] string model); + + /// + /// 刪除檢驗類別維護 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/QcGroup/{id}")] + ITask> DeleteQcGroup(int id); + + /// + /// 查詢檢驗類別維護 + /// + /// 頁數 + /// + /// + [WebApiClient.Attributes.HttpGet("api/QcGroup/QcGroupQuery")] + ITask> GetQcGroupQuery(int page = 1, int limit = 10); + + /// + /// 查詢檢驗類別維護 ID + /// + /// + [WebApiClient.Attributes.HttpGet("api/QcGroup/{id}")] + ITask GetQcGroup(int id); #endregion #region FQC002 檢驗項目維護 diff --git a/AMESCoreStudio.Web/Views/FQC/FQC001.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC001.cshtml new file mode 100644 index 00000000..45bbea42 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC001.cshtml @@ -0,0 +1,91 @@ +@{ + ViewData["Title"] = "檢驗類別維護"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/FQC/FQC001C.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC001C.cshtml new file mode 100644 index 00000000..f2f8c20d --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC001C.cshtml @@ -0,0 +1,66 @@ +@model AMESCoreStudio.WebApi.Models.AMES.QcGroup + + +@{ ViewData["Title"] = "FQC001C"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+
+ +
+
+ +
+ + +
+ +
+
+ +
+
+ +
+ +
+
+
+ @Html.ValidationMessage("error") +
+
+ +
+
+
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC001U.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC001U.cshtml new file mode 100644 index 00000000..fb27ec80 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC001U.cshtml @@ -0,0 +1,67 @@ +@model AMESCoreStudio.WebApi.Models.AMES.QcGroup + + +@{ ViewData["Title"] = "FQC001U"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+
+ + +
+
+ +
+ + +
+ +
+
+ +
+
+ +
+ +
+
+
+ @Html.ValidationMessage("error") +
+
+ +
+
+
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC002.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC002.cshtml new file mode 100644 index 00000000..3a128979 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC002.cshtml @@ -0,0 +1,91 @@ +@{ + ViewData["Title"] = "檢驗項目維護"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/FQC/FQC002C.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC002C.cshtml new file mode 100644 index 00000000..f2f8c20d --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC002C.cshtml @@ -0,0 +1,66 @@ +@model AMESCoreStudio.WebApi.Models.AMES.QcGroup + + +@{ ViewData["Title"] = "FQC001C"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+
+ +
+
+ +
+ + +
+ +
+
+ +
+
+ +
+ +
+
+
+ @Html.ValidationMessage("error") +
+
+ +
+
+
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC002U.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC002U.cshtml new file mode 100644 index 00000000..fb27ec80 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC002U.cshtml @@ -0,0 +1,67 @@ +@model AMESCoreStudio.WebApi.Models.AMES.QcGroup + + +@{ ViewData["Title"] = "FQC001U"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+
+ + +
+
+ +
+ + +
+ +
+
+ +
+
+ +
+ +
+
+
+ @Html.ValidationMessage("error") +
+
+ +
+
+
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC003.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC003.cshtml new file mode 100644 index 00000000..40ef6112 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC003.cshtml @@ -0,0 +1,96 @@ +@{ + ViewData["Title"] = "檢驗結果維護"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/FQC/FQC003C.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC003C.cshtml new file mode 100644 index 00000000..908d14ce --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC003C.cshtml @@ -0,0 +1,75 @@ +@model AMESCoreStudio.WebApi.Models.AMES.FqcResult + + +@{ ViewData["Title"] = "FQC003C"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+
+ +
+
+ +
+ + +
+ +
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+ + +
+
+ + @Html.ValidationMessage("error") +
+
+ +
+
+
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC003U.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC003U.cshtml new file mode 100644 index 00000000..fb27ec80 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC003U.cshtml @@ -0,0 +1,67 @@ +@model AMESCoreStudio.WebApi.Models.AMES.QcGroup + + +@{ ViewData["Title"] = "FQC001U"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+
+ + +
+
+ +
+ + +
+ +
+
+ +
+
+ +
+ +
+
+
+ @Html.ValidationMessage("error") +
+
+ +
+
+
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/QcGroupController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/QcGroupController.cs index 8df02f58..34dbbec6 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/QcGroupController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/QcGroupController.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using AMESCoreStudio.WebApi; using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.CommonTools.Result; namespace AMESCoreStudio.WebApi.Controllers.AMES { @@ -33,7 +34,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES // GET: api/QcGroup/5 [HttpGet("{id}")] - public async Task> GetQcGroup(decimal id) + public async Task> GetQcGroup(int id) { var qcGroup = await _context.QcGroups.FindAsync(id); @@ -45,78 +46,102 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return qcGroup; } - // PUT: api/QcGroup/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 PutQcGroup(decimal id, QcGroup qcGroup) + [HttpGet("QcGroupQuery")] + public async Task> GetQcGroupQuery(int page = 1, int limit = 10) { - if (id != qcGroup.GroupID) + IQueryable q = _context.QcGroups; + ResultModel result = new ResultModel(); + + // 紀錄筆數 + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) { - return BadRequest(); + q = q.Skip((page - 1) * limit).Take(limit); } + result.Data = await q.ToListAsync(); + return result; + } + + /// + /// 更新檢驗類別維護 + /// + /// + /// + [HttpPut] + public async Task> PutQcGroup(QcGroup qcGroup) + { + ResultModel result = new ResultModel(); _context.Entry(qcGroup).State = EntityState.Modified; + qcGroup.UpdateDate = DateTime.Now; + qcGroup.UpdateUserID = 0; try { await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; } - catch (DbUpdateConcurrencyException) + catch (Exception ex) { - if (!QcGroupExists(id)) - { - return NotFound(); - } - else - { - throw; - } + result.Success = false; + result.Msg = ex.Message; } - - return NoContent(); + return result; } - // POST: api/QcGroup - // 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> PostQcGroup(QcGroup qcGroup) + public async Task> PostQcGroup(QcGroup qcGroup) { + ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + qcGroup.GroupID = helper.GetIDKey("GROUP_ID").Result; _context.QcGroups.Add(qcGroup); try { await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; } - catch (DbUpdateException) + catch (Exception ex) { - if (QcGroupExists(qcGroup.GroupID)) - { - return Conflict(); - } - else - { - throw; - } + result.Success = false; + result.Msg = ex.Message; } - - return CreatedAtAction("GetQcGroup", new { id = qcGroup.GroupID }, qcGroup); + return result; } - // DELETE: api/QcGroup/5 + /// + /// 刪除檢驗類別維護 + /// + /// GroupID + /// [HttpDelete("{id}")] - public async Task> DeleteQcGroup(decimal id) + public async Task> DeleteQcGroup(int id) { + ResultModel result = new ResultModel(); var qcGroup = await _context.QcGroups.FindAsync(id); - if (qcGroup == null) + + try { - return NotFound(); + _context.QcGroups.Remove(qcGroup); + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; } - - _context.QcGroups.Remove(qcGroup); - await _context.SaveChangesAsync(); - - return qcGroup; + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.Message; + } + return result; } private bool QcGroupExists(decimal id) diff --git a/AMESCoreStudio.WebApi/Models/AMES/QcGroup.cs b/AMESCoreStudio.WebApi/Models/AMES/QcGroup.cs index 6e371c25..261a254b 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/QcGroup.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/QcGroup.cs @@ -56,20 +56,20 @@ namespace AMESCoreStudio.WebApi.Models.AMES [Required] [Column("CREATE_DATE")] [DataMember] - public DateTime CreateDate { get; set; } = System.DateTime.Now; + public DateTime CreateDate { get; set; } = DateTime.Now; /// /// 更新UserID /// [Column("UPDATE_USERID")] [DataMember] - public int UpdateUserID { get; set; } + public int UpdateUserID { get; set; } = 0; /// /// 更新日期 /// [Column("UPDATE_DATE")] [DataMember] - public DateTime? UpdateDate { get; set; } + public DateTime? UpdateDate { get; set; }=DateTime.Now; } }