コード例 #1
0
 /// <summary>
 /// 判断订单是否有空项
 /// </summary>
 /// <param name="order">待判断订单</param>
 /// <returns>是否有空项</returns>
 public static bool isNull(InterviewPurchaseOrder order)
 {
     if (order.ISBN == "")
     {
         return(true);
     }
     if (order.OrdererId == 0)
     {
         return(true);
     }
     if (order.BookName == "")
     {
         return(true);
     }
     if (order.Price == 0)
     {
         return(true);
     }
     if (order.CurrencyType == "")
     {
         return(true);
     }
     if (order.PublishingHouseId == 0)
     {
         return(true);
     }
     if (order.DocumentType == "")
     {
         return(true);
     }
     return(false);
 }
コード例 #2
0
        /// <summary>
        /// 判断订单是否规范
        /// </summary>
        /// <param name="order">待判断订单</param>
        /// <param name="errorMsg">错误信息</param>
        /// <returns>是否规范</returns>
        public static bool isNormative(InterviewPurchaseOrder order, ref List <string> errorMsg)
        {
            List <string> errorList = new List <string>();

            if (order.OrdererId <= 0)
            {
                errorList.Add("OrdererId Error");
            }
            Match matchISBN = Regex.Match(order.ISBN, @"^(\d{10})$");

            if (!matchISBN.Success)
            {
                errorList.Add("ISBN Error");
            }
            if (order.Price <= 0)
            {
                errorList.Add("Price Error");
            }
            if (order.PublishingHouseId <= 0)
            {
                errorList.Add("PublishingHouseId Error");
            }
            Match matchDocumentType = Regex.Match(order.DocumentType, @"^(期刊|专著|论文|电子文献|专利)$");

            if (!matchDocumentType.Success)
            {
                errorList.Add("DocumentType Error");
            }
            errorMsg = errorList;
            if (errorList.Count > 0)
            {
                return(false);
            }
            return(true);
        }