Esempio n. 1
0
        /// <summary>
        /// 添加前的验证
        /// </summary>
        /// <param name="cardNumber">绿卡号</param>
        /// <param name="cardStateBll">电子卡使用状态业务逻辑对象</param>
        /// <returns>该绿卡是否已存在使用状态记录</returns>
        public bool CheckForSaveEntityInsert(object cardNumber, RfidCardBll cardStateBll)
        {
            /* 当前绿卡是否正在被使用,还未被回收 */
            Entity cardStateEntity = cardStateBll.GetCardStateEntity(cardNumber.ToString(), (int)CardType.Green);

            if (cardStateEntity.GetValue("CardNumber") == null)
            {
                return(false);                                                // 还未使用过
            }
            if (cardStateEntity.GetValue("CardState").ToInt32() != (int)CardState.UnUse)
            {
                throw new ValueDuplicatedException(string.Format("警报,该绿卡正在被使用中。当前状态:{0}", cardStateEntity.GetValue("StateText")));
            }

            return(true);
        }
Esempio n. 2
0
        public Entity GetEntityByFieldWithOperator(string cardNumber)
        {
            RfidCardBll cardStateBll = new RfidCardBll();
            /* 当前绿卡是否入厂已登记,等待首磅 */
            Entity cardStateEntity = cardStateBll.GetCardStateEntity(cardNumber, (int)CardType.Green);

            if (cardStateEntity.GetValue("CardNumber") == null)
            {
                return(Helper.GetEntity(false, "警报,该绿卡还未在厂门口登记。当前状态:新卡,还未被使用"));
            }

            if (cardStateEntity.GetValue("CardState").ToInt32() != (int)CardState.Door)
            {
                return(Helper.GetEntity(false, string.Format("警报,该绿卡还未在厂门口登记。当前状态:{0}", cardStateEntity.GetValue("StateText"))));
            }

            Entity entity = this._Dal.GetEntityByFieldWithOperator(cardStateEntity.GetValue("RecordId").ToInt32());

            entity.Add(new SimpleProperty("Success", typeof(bool)), true);

            return(entity);
        }
Esempio n. 3
0
        /// <summary>
        /// 添加前的验证
        /// </summary>
        /// <param name="woodID">关联的木材编号 (来自于Wood表)</param>
        /// <param name="cardNumber">红卡号</param>
        /// <param name="cardStateBll">电子卡使用状态业务逻辑对象</param>
        /// <returns>该红卡是否已存在使用状态记录</returns>
        bool CheckForSaveEntityInsert(object woodID, object cardNumber, RfidCardBll cardStateBll)
        {
            string strFileName  = "Unique";
            object objFileValue = woodID;
            string connect      = "=";
            string table        = "Wood";

            /*  判断当前绿卡号关联的记录是否已被删除 */
            EntityCollection recordOfWaitCheck = this._Dal.SelectRecordComeFromDataOfNextStepOperate(strFileName, objFileValue, connect, table);

            if (recordOfWaitCheck.Count == 0)
            {
                throw new ValueDuplicatedException("添加失败,该绿卡在厂门口的登记记录已经被删除");
            }

            /* 判断当前红卡是否正在被使用,还未被回收 */
            Entity cardStateEntity = cardStateBll.GetCardStateEntity(cardNumber.ToString(), (int)CardType.Red);

            if (cardStateEntity.GetValue("CardNumber") == null)
            {
                return(false);                                                // 还未使用过
            }
            if (cardStateEntity.GetValue("CardState").ToInt32() != (int)CardState.UnUse)
            {
                throw new ValueDuplicatedException(string.Format("警报,该红卡正在被使用中。当前状态:{0}", cardStateEntity.GetValue("StateText")));
            }

            /* 判断当前绿卡关联的记录是否已添加过 */
            strFileName = "WoodID";
            table       = "FullPound";
            EntityCollection hasRecord = this._Dal.SelectRecordComeFromDataOfNextStepOperate(strFileName, objFileValue, connect, table);

            if (hasRecord.Count != 0)
            {
                throw new ValueDuplicatedException("添加失败,这张绿卡的记录之前已经被添加过,不允许再次添加");
            }

            return(true);
        }
Esempio n. 4
0
        public Entity GetEntityByFieldWithOperator(string cardNumber)
        {
            RfidCardBll cardStateBll = new RfidCardBll();
            /* 当前红卡是否首磅已登记,但还未回皮,等待取样 */
            Entity cardStateEntity = cardStateBll.GetCardStateEntity(cardNumber, (int)CardType.Red);

            if (cardStateEntity.GetValue("CardNumber") == null)
            {
                return(Helper.GetEntity(false, "警报,该红卡还未进行首磅登记。当前状态:新卡,还未被使用"));
            }

            int cardState = cardStateEntity.GetValue("CardState").ToInt32();

            if (cardState != (int)CardState.Balance && cardState != (int)CardState.Sample)
            {
                return(Helper.GetEntity(false, string.Format("警报,该红卡还未进行首磅登记。当前状态:{0}", cardStateEntity.GetValue("StateText"))));
            }

            Entity entity = this._Dal.GetEntityByFieldWithOperator(cardStateEntity.GetValue("RecordId").ToInt32());

            entity.Add(new SimpleProperty("Success", typeof(bool)), true);

            return(entity);
        }