From 2eb186c97b879aab53e9c189c3892590bf24d48b Mon Sep 17 00:00:00 2001 From: ray Date: Wed, 15 Dec 2021 01:42:55 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=8A=A0=E5=85=A5=E8=87=AA=E8=A8=82?= =?UTF-8?q?=E9=A9=97=E8=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AMESCoreStudio.Web/Views/PCS/PCS004C.cshtml | 57 ++++++++++--------- .../Attribute/BarCodeAttribute.cs | 39 +++++++++++++ .../Models/AMES/WipBarcode.cs | 2 + 3 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 AMESCoreStudio.WebApi/Attribute/BarCodeAttribute.cs diff --git a/AMESCoreStudio.Web/Views/PCS/PCS004C.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS004C.cshtml index c4900ce8..476ea4b2 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS004C.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS004C.cshtml @@ -69,45 +69,46 @@ + -
-
- -
- -
- -
- -
+
+
+ +
+ +
+ +
+
+
-
-
- -
- -
- -
- -
+
+
+ +
+ +
+ +
+
+
-
-
- -
- -
+
+
+ +
+
-
+ +
@@ -175,7 +176,7 @@ layui.use(['form'], function () { var form = layui.form; }); - + $(document).ready(function () { diff --git a/AMESCoreStudio.WebApi/Attribute/BarCodeAttribute.cs b/AMESCoreStudio.WebApi/Attribute/BarCodeAttribute.cs new file mode 100644 index 00000000..4bfb4271 --- /dev/null +++ b/AMESCoreStudio.WebApi/Attribute/BarCodeAttribute.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.ComponentModel.DataAnnotations; +using AMESCoreStudio.WebApi.Models.AMES; + +namespace AMESCoreStudio.WebApi.Attribute +{ + public class BarCodeAttribute : ValidationAttribute + { + + + + protected override ValidationResult IsValid(object value, ValidationContext validationContext) + { + var WipBarcode = (WipBarcode)validationContext.ObjectInstance; + var aa = WipBarcode.StartNO; + var bb = WipBarcode.EndNO; + //string[] strBaseError = m_BaseText.Where(x => strValue.Contains(x)).ToArray(); + //string[] strCustomError = m_Text.Where(x => strValue.Contains(x)).ToArray(); + + //if (strBaseError.Count() == 0 && strCustomError.Count() == 0) + //{ + // return ValidationResult.Success; + //} + //else + //{ + // List temp = new List(); + // temp.AddRange(m_BaseText.ToList()); + // temp.AddRange(m_Text.ToList()); + // string errorMsg = $"禁止輸入 [{string.Join(", ", temp.ToArray())}] !!"; + // return new ValidationResult(errorMsg); + //} + return ValidationResult.Success; + } + + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/WipBarcode.cs b/AMESCoreStudio.WebApi/Models/AMES/WipBarcode.cs index 58419621..9e258c5b 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/WipBarcode.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/WipBarcode.cs @@ -2,6 +2,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Runtime.Serialization; +using AMESCoreStudio.WebApi.Attribute; namespace AMESCoreStudio.WebApi.Models.AMES { @@ -39,6 +40,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [DataMember] [Required(ErrorMessage = "{0},不能空白")] [Display(Name = "結束條碼")] + [BarCode] public string EndNO { get; set; } ///