Ejemplo n.º 1
0
        public Entity SaveEntityByOperator(Entity entity)
        {
            string strCrateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string msg          = "";

            try
            {
                this._Dal.BeginTransaction();

                UniqueDal unique = new UniqueDal(this._Dal.SqlTransaction);
                entity.Add(new SimpleProperty("Log", typeof(string)), "{\"Date\":\"" + strCrateDate + "\",\"People\":\"" + entity.GetValue("Operator").ToString() + "\"}");

                int affectedRows;
                /* 新增 */
                if (entity.GetValue("Unique").TryInt32() == 0)
                {
                    RfidCardBll cardStateBll = new RfidCardBll(this._Dal.SqlTransaction);
                    object      cardNumber   = entity.GetValue("CardNumber");
                    bool        hasUseRecord = CheckForSaveEntityInsert(cardNumber, cardStateBll);

                    int newUnique = unique.GetValueByName(this._Dal.Table);
                    entity.SetValue("Unique", newUnique);
                    entity.Add(new SimpleProperty("BarrierID", typeof(int)), null);
                    entity.Add(new SimpleProperty("ArriveDate", typeof(DateTime)), strCrateDate);
                    entity.Add(new SimpleProperty("State", typeof(int)), StateEnum.Default);
                    entity.Add(new SimpleProperty("Version", typeof(int)), 1);

                    affectedRows = this._Dal.InsertEntity(entity);
                    if (hasUseRecord)
                    {
                        affectedRows = cardStateBll.UpdateState(cardNumber.ToString(), (int)CardType.Green, (int)CardState.Door, newUnique, (int)CardComeFrom.Factry);
                    }
                    else
                    {
                        affectedRows = cardStateBll.Insert(cardNumber.ToString(), (int)CardType.Green, (int)CardState.Door, newUnique, (int)CardComeFrom.Factry);
                    }

                    msg = "发卡成功";
                }
                // 修改
                else
                {
                    CheckForSaveEntityUpdate(entity.GetValue("Unique"));

                    affectedRows = this._Dal.UpdateEntityByUniqueWithOperator(entity);

                    msg = "修改成功";
                }

                this._Dal.CommitTransaction();

                return(Helper.GetEntity(true, msg, entity.GetValue("Unique").ToString()));
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Ejemplo n.º 2
0
        public Entity DeleteEntityByUniqueWithOperator(int intUnique, int intWoodID, int operatorID, string greenCardNumber, string redCardNumber, string bangCid)
        {
            try
            {
                this._Dal.BeginTransaction();

                ExecuteForDeleteEntity(intWoodID);

                int affectedRows = this._Dal.DeleteEntityByUniqueWithOperator(intUnique, intWoodID, operatorID); // 删除车辆还未离厂的记录
                if (affectedRows > 0)
                {
                    RfidCardBll cardStateBll = new RfidCardBll(this._Dal.SqlTransaction);
                    int         affRows      = cardStateBll.UpdateState(greenCardNumber, (int)CardType.Green, (int)CardState.Balance);
                    affRows = cardStateBll.UpdateState(redCardNumber, (int)CardType.Red, (int)CardState.Sample);
                }

                this._Dal.CommitTransaction();

                Entity operateResult;
                if (affectedRows > 0)
                {
                    operateResult = Helper.GetEntity(true, "删除记录成功");
                    SyncDeleteEmptyVolumeData(intWoodID);

                    SimpleProperty BangCID = new SimpleProperty("BangCID", typeof(string));
                    SimpleProperty BangID  = new SimpleProperty("BangID", typeof(string));
                    Entity         entity  = new Entity(new PropertyCollection()
                    {
                        BangCID, BangID
                    });
                    entity.SetValue(BangCID, bangCid);
                    entity.SetValue(BangID, "");
                    SyncVolumeDataForERP(entity, "DEL");
                }
                else
                {
                    operateResult = Helper.GetEntity(false, "删除失败,可能该车辆已经驶出厂区大门,不能再删除");
                }

                return(operateResult);
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
        public Entity DeleteEntityByUniqueWithOperator(int intUnique, int intWoodID, int operatorID, string redCardNumber)
        {
            try
            {
                this._Dal.BeginTransaction();

                ExecuteForDeleteEntity(intWoodID);

                int affectedRows = this._Dal.DeleteEntityByUniqueWithOperator(intUnique, intWoodID, operatorID); // 删除还未地磅回皮的记录
                if (affectedRows > 0)
                {
                    string strFileName  = "WoodID";
                    object objFileValue = intWoodID;
                    string connect      = "=";
                    string table        = "Factory";

                    /* 判断当前记录在料厂处的取样记录是否已删除完 */
                    EntityCollection hasRecord = this._Dal.SelectRecordComeFromDataOfNextStepOperate(strFileName, objFileValue, connect, table);
                    if (hasRecord.Count == 0)
                    {
                        /* 料厂处的取样记录已删除完,则需要变更该红卡的状态 */
                        RfidCardBll cardStateBll = new RfidCardBll(this._Dal.SqlTransaction);
                        int         affRows      = cardStateBll.UpdateState(redCardNumber, (int)CardType.Red, (int)CardState.Balance);
                    }
                }

                this._Dal.CommitTransaction();

                Entity operateResult;
                if (affectedRows > 0)
                {
                    operateResult = Helper.GetEntity(true, "删除记录成功");
                }
                else
                {
                    operateResult = Helper.GetEntity(false, "删除失败,可能该车辆已经到地磅并回皮完毕,不能再删除");
                }

                return(operateResult);
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
        public Entity SaveEntityByOperator(Entity entity, string greenCardNumber)
        {
            string strCrateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string msg          = "";

            try
            {
                this._Dal.BeginTransaction();

                CheckForSaveEntityInsert(entity.GetValue("WoodID"));

                UniqueDal unique = new UniqueDal(this._Dal.SqlTransaction);

                // 新增
                entity.SetValue("Unique", unique.GetValueByName(this._Dal.Table));
                entity.Add(new SimpleProperty("RecoverTime", typeof(DateTime)), strCrateDate);
                entity.Add(new SimpleProperty("State", typeof(int)), StateEnum.Default);
                entity.Add(new SimpleProperty("Version", typeof(int)), 1);
                entity.Add(new SimpleProperty("Log", typeof(string)), "{\"Date\":\"" + strCrateDate + "\",\"People\":\"" + entity.GetValue("Operator").ToString() + "\"}");

                int         affectedRows;
                RfidCardBll cardStateBll = new RfidCardBll(this._Dal.SqlTransaction);
                affectedRows = this._Dal.InsertEntity(entity);
                affectedRows = cardStateBll.UpdateState(greenCardNumber, (int)CardType.Green, (int)CardState.UnUse);

                this._Dal.CommitTransaction();

                msg = "回收成功";

                return(Helper.GetEntity(true, msg, entity.GetValue("Unique").ToString()));
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Ejemplo n.º 8
0
        public Entity DeleteEntityByUniqueWithOperator(int intUnique, int intWoodID, int operatorID, string greenCardNumber, string redCardNumber)
        {
            try
            {
                this._Dal.BeginTransaction();

                ExecuteForDeleteEntity(intWoodID);

                int affectedRows = this._Dal.DeleteEntityByUniqueWithOperator(intUnique, intWoodID, operatorID); // 删除还未被料厂取样的记录
                if (affectedRows > 0)
                {
                    RfidCardBll cardStateBll = new RfidCardBll(this._Dal.SqlTransaction);
                    int         affRows      = cardStateBll.UpdateState(greenCardNumber, (int)CardType.Green, (int)CardState.Door);
                    affRows = cardStateBll.UpdateState(redCardNumber, (int)CardType.Red, (int)CardState.UnUse);
                }

                this._Dal.CommitTransaction();

                Entity operateResult;
                if (affectedRows > 0)
                {
                    operateResult = Helper.GetEntity(true, "删除记录成功");
                    SyncDeleteFullVolumeData(intWoodID);
                }
                else
                {
                    operateResult = Helper.GetEntity(false, "删除失败,可能该车辆已经到达料厂卸货并取样完毕,不能再删除");
                }

                return(operateResult);
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Ejemplo n.º 9
0
        public Entity DeleteEntityByUniqueWithOperator(int intUnique, int operatorID, string cardNumber)
        {
            try
            {
                this._Dal.BeginTransaction();

                ExecuteForDeleteEntity(intUnique);

                int affectedRows = this._Dal.DeleteEntityByUniqueWithOperator(intUnique, operatorID); // 删除还未首磅的记录
                if (affectedRows > 0)
                {
                    RfidCardBll cardStateBll = new RfidCardBll(this._Dal.SqlTransaction);
                    int         affRows      = cardStateBll.UpdateState(cardNumber, (int)CardType.Green, (int)CardState.UnUse);
                }

                this._Dal.CommitTransaction();

                Entity operateResult;
                if (affectedRows > 0)
                {
                    operateResult = Helper.GetEntity(true, "删除成功");
                }
                else
                {
                    operateResult = Helper.GetEntity(false, "删除失败,可能该车辆已经到达地磅并首磅完毕,不能再删除");
                }

                return(operateResult);
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
0
        public Entity SaveEntityByOperator(Entity entity)
        {
            string strCrateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string msg          = "";

            try
            {
                CheckForSaveEntityInsert(entity.GetValue("BarrierID"));

                object greenCardNumber = entity.GetValue("CardNumber");
                /* 这里获取数据,为了在验收电子卡的同时,模拟新发一张工厂入门电子卡记录 */
                SimpleProperty property     = new SimpleProperty("CardNumber", typeof(string));
                Entity         entityOfWood = new Entity(new PropertyCollection()
                {
                    property
                });
                entityOfWood.SetValue(property, greenCardNumber);
                entityOfWood.Add(new SimpleProperty("BarrierID", typeof(int)), entity.GetValue("BarrierID"));
                entityOfWood.Add(new SimpleProperty("ArriveDate", typeof(DateTime)), strCrateDate);
                entityOfWood.Add(new SimpleProperty("Operator", typeof(int)), entity.GetValue("Operator"));
                entityOfWood.Add(new SimpleProperty("State", typeof(int)), StateEnum.Default);
                entityOfWood.Add(new SimpleProperty("Version", typeof(int)), 1);
                entityOfWood.Add(new SimpleProperty("Log", typeof(string)), "{\"Date\":\"" + strCrateDate + "\",\"People\":\"" + entity.GetValue("Operator").ToString() + "\"}");

                this._Dal.BeginTransaction();

                UniqueDal unique = new UniqueDal(this._Dal.SqlTransaction);

                RfidCardBll cardStateBll = new RfidCardBll(this._Dal.SqlTransaction);

                int newUnique = unique.GetValueByName("Wood");  // 注意这里,获取木材表的唯一字段
                if (newUnique <= 0)
                {
                    throw new Exception("验收失败,网络原因,请重试");
                }
                entityOfWood.Add(new SimpleProperty("Unique", typeof(int)), newUnique);

                /* 新增 */
                newUnique = unique.GetValueByName(this._Dal.Table);
                if (newUnique <= 0)
                {
                    throw new Exception("验收失败,网络原因,请重试");
                }
                entity.SetValue("Unique", newUnique);

                entity.Add(new SimpleProperty("CheckDate", typeof(DateTime)), strCrateDate);
                entity.Add(new SimpleProperty("State", typeof(int)), StateEnum.Default);
                entity.Add(new SimpleProperty("Version", typeof(int)), 1);
                entity.Add(new SimpleProperty("Log", typeof(string)), "{\"Date\":\"" + strCrateDate + "\"}");

                int affectedRows;
                affectedRows = this._Dal.InsertEntity(entity);  // 添加记录到电子卡验收Check
                if (affectedRows > 0)
                {
                    affectedRows = this._Dal.InsertBaseDataByOperator(entityOfWood);                    // 添加记录到木材表Wood
                }
                else
                {
                    throw new Exception("验收失败,网络原因,请重试");
                }
                if (affectedRows > 0)
                {
                    affectedRows = cardStateBll.UpdateState(greenCardNumber.ToString(), (int)CardType.Green, (int)CardState.Door, entityOfWood.GetValue("Unique").ToInt32());
                }
                else
                {
                    throw new Exception("验收失败,网络原因,请重试");
                }
                if (affectedRows > 0)
                {
                    msg = "验收成功";
                }
                else
                {
                    throw new Exception("验收失败,网络原因,请重试");
                }

                this._Dal.CommitTransaction();

                return(Helper.GetEntity(true, msg, entity.GetValue("Unique").ToString()));
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Ejemplo n.º 12
0
        public Entity SaveEntityByOperator(Entity entity, string greenCardNumber)
        {
            string strCrateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string msg          = "";
            string CtrlType     = "NEW";

            try
            {
                if (entity.GetValue("FullVolume") != null && entity.GetValue("FullVolume").ToString().Trim() == "")
                {
                    entity.SetValue("FullVolume", null);
                }
                entity.Add(new SimpleProperty("Log", typeof(string)), "{\"Date\":\"" + strCrateDate + "\",\"People\":\"" + entity.GetValue("Operator").ToString() + "\"}");

                this._Dal.BeginTransaction();

                UniqueDal unique = new UniqueDal(this._Dal.SqlTransaction);

                int affectedRows;
                /* 新增 */
                if (entity.GetValue("Unique").TryInt32() == 0)
                {
                    object      woodID       = entity.GetValue("WoodID");
                    object      cardNumber   = entity.GetValue("CardNumber");
                    RfidCardBll cardStateBll = new RfidCardBll(this._Dal.SqlTransaction);
                    bool        hasUseRecord = CheckForSaveEntityInsert(woodID, cardNumber, cardStateBll);

                    entity.SetValue("Unique", unique.GetValueByName(this._Dal.Table));
                    entity.Add(new SimpleProperty("WeighTime", typeof(DateTime)), strCrateDate);
                    entity.Add(new SimpleProperty("Printed", typeof(bool)), 0);
                    entity.Add(new SimpleProperty("State", typeof(int)), StateEnum.Default);
                    entity.Add(new SimpleProperty("Version", typeof(int)), 1);

                    affectedRows = this._Dal.InsertEntity(entity);
                    affectedRows = cardStateBll.UpdateState(greenCardNumber, (int)CardType.Green, (int)CardState.Balance);
                    if (hasUseRecord)
                    {
                        affectedRows = cardStateBll.UpdateState(cardNumber.ToString(), (int)CardType.Red, (int)CardState.Balance, woodID.ToInt32());
                    }
                    else
                    {
                        affectedRows = cardStateBll.Insert(cardNumber.ToString(), (int)CardType.Red, (int)CardState.Balance, woodID.ToInt32(), (int)CardComeFrom.Weighbridge);
                    }

                    msg = "添加记录成功#" + strCrateDate;
                }
                /* 修改 */
                else
                {
                    CheckForSaveEntityUpdate(entity.GetValue("WoodID"));

                    affectedRows = this._Dal.UpdateEntityByUniqueWithOperator(entity);

                    msg = "修改记录成功";

                    CtrlType = "EDIT";
                }

                this._Dal.CommitTransaction();

                SyncFullVolumeData(entity, CtrlType);

                return(Helper.GetEntity(true, msg, entity.GetValue("Unique").ToString()));
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Ejemplo n.º 13
0
        public Entity SaveEntityByOperator(Entity entity, string redCardNumber)
        {
            string strCrateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            string msg = "";

            try
            {
                string weightime = entity.GetValue("WeighTime").TryString();
                string Key       = entity.GetValue("Key").TryString();

                this._Dal.BeginTransaction();

                UniqueDal unique = new UniqueDal(this._Dal.SqlTransaction);
                entity.Add(new SimpleProperty("Log", typeof(string)), "{\"Date\":\"" + strCrateDate + "\",\"People\":\"" + entity.GetValue("Operator").ToString() + "\"}");

                int affectedRows;
                // 新增
                if (entity.GetValue("Unique").TryInt32() == 0)
                {
                    CheckForSaveEntityInsert(entity.GetValue("WoodID"), entity.GetValue("Operator"));
                    if (this._Dal.IsExistsFactoryKey(weightime, Key) > 0)
                    {
                        throw new ValueDuplicatedException("添加失败,密码出现重复。");
                    }
                    entity.SetValue("Unique", unique.GetValueByName(this._Dal.Table));
                    entity.Add(new SimpleProperty("SampleTime", typeof(DateTime)), strCrateDate);
                    entity.Add(new SimpleProperty("State", typeof(int)), StateEnum.Default);
                    entity.Add(new SimpleProperty("Version", typeof(int)), 1);

                    RfidCardBll cardStateBll = new RfidCardBll(this._Dal.SqlTransaction);
                    affectedRows = this._Dal.InsertEntity(entity);
                    affectedRows = cardStateBll.UpdateState(redCardNumber, (int)CardType.Red, (int)CardState.Sample);

                    msg = "添加记录成功";
                }
                // 修改
                else
                {
                    //CheckForSaveEntityUpdate(entity.GetValue("WoodID"));

                    string OldKey = entity.GetValue("OldKey").TryString();
                    if (Key != OldKey)
                    {
                        if (this._Dal.IsExistsFactoryKey(weightime, Key) > 0)
                        {
                            throw new ValueDuplicatedException("修改失败,密码出现重复。");
                        }
                    }
                    affectedRows = this._Dal.UpdateEntityByUniqueWithOperator(entity);

                    msg = "修改记录成功";
                }

                this._Dal.CommitTransaction();

                return(Helper.GetEntity(true, msg, entity.GetValue("Unique").ToString()));
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Ejemplo n.º 14
0
        public Entity SaveEntityByOperator(Entity entity, string greenCardNumber, string redCardNumber)
        {
            string strCrateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string msg          = "";

            try
            {
                if (entity.GetValue("EmptyVolume") != null && entity.GetValue("EmptyVolume").ToString().Trim() == "")
                {
                    entity.SetValue("EmptyVolume", null);
                }
                if (entity.GetValue("HandVolume") != null && entity.GetValue("HandVolume").ToString().Trim() == "")
                {
                    entity.SetValue("HandVolume", null);
                }
                if (entity.GetValue("RebateVolume") != null && entity.GetValue("RebateVolume").ToString().Trim() == "")
                {
                    entity.SetValue("RebateVolume", null);
                }
                entity.Add(new SimpleProperty("Log", typeof(string)), "{\"Date\":\"" + strCrateDate + "\",\"People\":\"" + entity.GetValue("Operator").ToString() + "\"}");

                this._Dal.BeginTransaction();

                UniqueDal unique = new UniqueDal(this._Dal.SqlTransaction);
                int       affectedRows;
                /* 新增 */
                if (entity.GetValue("Unique").TryInt32() == 0)
                {
                    CheckForSaveEntityInsert(entity.GetValue("WoodID"));

                    entity.SetValue("Unique", unique.GetValueByName(this._Dal.Table));
                    //entity.Add(new SimpleProperty("BackWeighTime", typeof(DateTime)), strCrateDate);
                    entity.SetValue("BackWeighTime", strCrateDate);
                    entity.Add(new SimpleProperty("State", typeof(int)), StateEnum.Default);
                    entity.Add(new SimpleProperty("Version", typeof(int)), 1);

                    RfidCardBll cardStateBll = new RfidCardBll(this._Dal.SqlTransaction);
                    affectedRows = this._Dal.InsertEntity(entity);
                    affectedRows = cardStateBll.UpdateState(redCardNumber, (int)CardType.Red, (int)CardState.UnUse);
                    affectedRows = cardStateBll.UpdateState(greenCardNumber, (int)CardType.Green, (int)CardState.EmptyBalance);

                    msg = "添加记录成功";
                }
                /* 修改 */
                else
                {
                    CheckForSaveEntityUpdate(entity.GetValue("WoodID"));

                    affectedRows = this._Dal.UpdateEntityByUniqueWithOperator(entity);

                    msg = "修改记录成功";
                }

                this._Dal.CommitTransaction();

                if (affectedRows > 0)
                {
                    SyncEmptyVolumeData(entity);
                    SyncVolumeDataForERP(entity, "ADDOREDIT");
                }

                return(Helper.GetEntity(true, msg, entity.GetValue("Unique").ToString()));
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }