コード例 #1
0
        public void ValidateBeforeSaveAdd(InventoryTransactionDTO data)
        {
            //Validate Item Code
            ItemValidator itemValidator = new ItemValidator();

            ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(data.ITEM_CD));

            BusinessException itemNotFound = itemValidator.CheckItemNotExist(data.ITEM_CD);

            if (itemNotFound != null)
            {
                ValidateException.ThrowErrorItem(itemNotFound.Error);
            }
            if (data.TRANS_ID.IsNull)
            {
                if (data.TRANS_CLS.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eTRANS_TYPE.Receiving))
                {
                    ValidateException.ThrowErrorItem(CheckExistReceiveItem(data.ITEM_CD, data.LOT_NO, data.LOC_CD));
                }
                else
                {
                    ValidateException.ThrowErrorItem(CheckNotExistReceiveItem(data.ITEM_CD, data.LOT_NO, data.LOC_CD));
                }


                ////ถ้า Receive ต้อง check ว่า lot นั้นไม่เคยทำ receive มาก่อน
                //if (model.RECEIVE_TYPE.StrongValue.Equals(DataDefine.eTRANS_TYPE_string.Receiving))
                //{
                //    ValidateException.ThrowErrorItem(receivingValidator.CheckExistReceiveItem(dto.ITEM_CD, dto.LOT_NO));
                //}
                //else
                //{
                //    ValidateException.ThrowErrorItem(receivingValidator.CheckNotExistReceiveItem(dto.ITEM_CD, dto.LOT_NO));
                //}
            }


            //Validate Receive Qty
            if (data.QTY.IsNull || data.QTY.StrongValue <= 0)
            {
                ValidateException.ThrowErrorItem(new ErrorItem(data.QTY.Owner, TKPMessages.eValidate.VLM0043.ToString()));
            }
        }
コード例 #2
0
        //public ErrorItem CheckInputLot(NZString itemCode, NZString lotNo) {
        //    ItemBIZ biz = new ItemBIZ();
        //    ItemDTO dto = biz.LoadItem(itemCode);

        //    switch (DataDefine.ConvertValue2Enum<DataDefine.eLOT_CONTROL_CLS>(dto.LOT_CONTROL_CLS.StrongValue)) {
        //        case DataDefine.eLOT_CONTROL_CLS.No:
        //            if (!lotNo.IsNull || lotNo.StrongValue != string.Empty) {
        //                return new ErrorItem(lotNo.Owner, TKPMessages.eValidate.VLM0065.ToString());
        //            }
        //            break;
        //        case DataDefine.eLOT_CONTROL_CLS.Yes:
        //            if (lotNo.IsNull || lotNo.StrongValue.Trim() == String.Empty) {
        //                return new ErrorItem(lotNo.Owner, TKPMessages.eValidate.VLM0050.ToString(), new object[] { itemCode.StrongValue });
        //            }
        //            break;
        //    }

        //    return null;
        //}
        #endregion

        #region Business Validate
        /// <summary>
        /// Validate data before load consumption list.
        /// </summary>
        /// <param name="itemCode"></param>
        /// <param name="orderLocation"></param>
        /// <param name="qty"></param>
        public void ValidateBeforeLoadConsumption(NZString itemCode, NZString orderLocation, NZDecimal qty, NZString ConsumptionCls)
        {
            //== Check ItemCode.
            ItemValidator itemValidator = new ItemValidator();

            ValidateException.ThrowErrorItem(itemValidator.CheckEmptyItemCode(itemCode));

            BusinessException businessException = itemValidator.CheckItemNotExist(itemCode);

            if (businessException != null)
            {
                ValidateException.ThrowErrorItem(businessException.Error);
            }

            //== Check Order Location.
            DealingValidator locationValidator = new DealingValidator();

            if (ConsumptionCls.StrongValue == DataDefine.Convert2ClassCode(DataDefine.eCONSUMPTION_CLS.Manual))
            {
                ValidateException.ThrowErrorItem(locationValidator.CheckEmptyLocationCode(orderLocation));
                ValidateException.ThrowErrorItem(locationValidator.CheckNotExistsLocationCode(orderLocation));
            }
        }