Esempio 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);

                CheckForSaveEntityInsert(entity.GetValue("BangID"), entity.GetValue("GsmID"), entity.GetValue("WoodID"));

                entity.SetValue("Unique", unique.GetValueByName(this._Dal.Table));
                entity.Add(new SimpleProperty("JoinTime", 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)), "{\"JoinDate\":\"" + strCrateDate + "\",\"JoinPeople\":\"" + entity.GetValue("Operator").ToString() + "\"}");

                this._Dal.InsertEntity(entity);
                int aft = this._Dal.UpdateJoin(entity.GetValue("BangID"), (object)1);

                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));
            }
        }
Esempio n. 2
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));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 批量对接
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public string BatchJoinData(Entity entity)
        {
            string strRes  = string.Empty;
            string BangIDs = entity.GetValue("BangIDs").TryString();
            string WoodIDs = entity.GetValue("WoodIDs").TryString();
            int    AreaID  = entity.GetValue("AreaID").TryInt32();
            int    Account = entity.GetValue("Account").TryInt32();
            int    intRes  = 0;

            try
            {
                this._Dal.BeginTransaction();
                if (BangIDs != "")
                {
                    string[] BangID = BangIDs.Split(new char[] { ',' });
                    string[] WoodID = WoodIDs.Split(new char[] { ',' });
                    for (int i = 0; i < BangID.Length; i++)
                    {
                        string strCrateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

                        UniqueDal unique = new UniqueDal(this._Dal.SqlTransaction);
                        CheckForSaveEntityInsert(BangID[i], 0, WoodID[i]);
                        SimpleProperty propertyOfConnector = new SimpleProperty("BangID", typeof(string));
                        Entity         entity1             = new Entity(new PropertyCollection()
                        {
                            propertyOfConnector
                        });
                        entity1.SetValue("BangID", BangID[i]);
                        entity1.Add(new SimpleProperty("GsmID", typeof(int)), 0);
                        entity1.Add(new SimpleProperty("WoodID", typeof(int)), WoodID[i].TryInt32());
                        entity1.Add(new SimpleProperty("Unique", typeof(int)), unique.GetValueByName(this._Dal.Table));
                        entity1.Add(new SimpleProperty("JoinTime", typeof(DateTime)), strCrateDate);
                        entity1.Add(new SimpleProperty("State", typeof(int)), StateEnum.Default);
                        entity1.Add(new SimpleProperty("Version", typeof(int)), 1);
                        entity1.Add(new SimpleProperty("Operator", typeof(int)), Account);
                        entity1.Add(new SimpleProperty("IsGsm", typeof(int)), 1);
                        entity1.Add(new SimpleProperty("IsAdd", typeof(int)), 0);
                        entity1.Add(new SimpleProperty("AreaID", typeof(int)), AreaID);
                        entity1.Add(new SimpleProperty("Log", typeof(string)), "{\"JoinDate\":\"" + strCrateDate + "\",\"JoinPeople\":\"" + Account + "\"}");

                        this._Dal.InsertEntity(entity1);
                        intRes += this._Dal.UpdateJoin(BangID[i], (object)1);
                    }
                }

                this._Dal.CommitTransaction();

                strRes = intRes > 0 ? "SUCCESS" : "FAIL";
            }
            catch (System.Exception ex)
            {
                strRes = "EXCEPTION";
                this._Dal.RollbackTransaction();
            }
            return(strRes);
        }
Esempio n. 4
0
        /// <summary>
        /// 装箱操作
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Entity SaveBoxEntity(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);

                // 新增
                if (entity.GetValue("Unique").TryInt32() == 0)
                {
                    CheckForSaveBoxEntityInsert(entity.GetValue("WoodID"));
                    Entity entityBox = new Entity(new PropertyCollection()
                    {
                    });
                    entityBox.Add(new SimpleProperty("Unique", typeof(int)), unique.GetValueByName("WoodPackBox"));
                    entityBox.Add(new SimpleProperty("WoodID", typeof(int)), entity.GetValue("WoodID").TryInt32());
                    entityBox.Add(new SimpleProperty("Box", typeof(int)), entity.GetValue("Box").TryInt32());
                    entityBox.Add(new SimpleProperty("PackTime", typeof(DateTime)), strCrateDate);
                    entityBox.Add(new SimpleProperty("Operator", typeof(int)), entity.GetValue("Operator").TryInt32());
                    entityBox.Add(new SimpleProperty("State", typeof(int)), StateEnum.Default);
                    entityBox.Add(new SimpleProperty("Version", typeof(int)), 1);
                    entityBox.Add(new SimpleProperty("Log", typeof(string)), "{\"Date\":\"" + strCrateDate + "\",\"People\":\"" + entity.GetValue("Operator").ToString() + "\"}");
                    this._Dal.InsertBoxEntity(entityBox);

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

                //    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));
            }
        }
Esempio n. 5
0
        public Entity SaveEntityByOperator(Entity entity)
        {
            string msg = "";

            try
            {
                this._Dal.BeginTransaction();

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

                // 新增
                if (entity.GetValue("Unique").TryInt32() == 0)
                {
                    CheckForSaveEntityInsert(entity.GetValue("StationName"));

                    entity.SetValue("Unique", unique.GetValueByName(this._Dal.Table));
                    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\":\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\",\"People\":\"" + entity.GetValue("Operator").ToString() + "\"}");

                    this._Dal.InsertEntity(entity);

                    msg = "添加成功";
                }
                // 修改
                else
                {
                    CheckForSaveEntityUpdate(entity);

                    this._Dal.UpdateEntityByUnique(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));
            }
        }
Esempio n. 6
0
        public Entity SaveEntities(object[] entities)
        {
            try
            {
                this._Dal.BeginTransaction();

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

                this.ExecuteForSaveEntities(this._Dal.SqlTransaction, entities, unique);

                this._Dal.CommitTransaction();

                return(Helper.GetEntity(true, "保存记录成功!"));
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 保存相片
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Entity SavePhoto(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("Unique", typeof(int)), unique.GetValueByName("WoodCarPhoto"));
                entity.Add(new SimpleProperty("PhotoTime", 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 rows = this._Dal.SavePhoto(entity);

                this._Dal.CommitTransaction();

                if (rows > 0)
                {
                    msg = "照片发送成功";
                }
                else
                {
                    msg = "照片发送失败,可能是网络慢的原因,请再发送一次";
                }

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

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 保存和修改价格体系
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public Entity SaveWoodPriceEntity(Entity entity)
        {
            try
            {
                this._Dal.BeginTransaction();

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

                // 新增
                if (entity.GetValue("Unique").TryInt32() == 0)
                {
                    entity = this.SaveWoodPriceEntityInsert(this._Dal.SqlTransaction, entity);

                    entity.SetValue("Unique", unique.GetValueByName(this._Dal.Table));
                    entity.Add(new SimpleProperty("State", typeof(int)), 0);
                    entity.Add(new SimpleProperty("Version", typeof(int)), 1);
                    entity.Add(new SimpleProperty("Log", typeof(string)), "{\"Date\":\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\"}");

                    this._Dal.InsertEntity(entity);
                }
                // 修改
                else
                {
                    entity = this.SaveWoodPriceEntityUpdate(this._Dal.SqlTransaction, entity);

                    this._Dal.UpdateWoodPrice(entity);
                }

                this._Dal.CommitTransaction();

                return(Helper.GetEntity(true, "保存记录成功!", entity.GetValue("Unique").ToString()));
            }
            catch (Exception exception)
            {
                this._Dal.RollbackTransaction();

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Esempio n. 9
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));
            }
        }
Esempio n. 10
0
        public override void ExecuteForSaveEntities(SqlTransaction transaction, object[] entities, UniqueDal unique)
        {
            // 删除
            this._Dal.UpdateEntitiesByAccount(Helper.Deserialize(entities[0].ToString()).GetValue("AccountID").ToInt32());

            // 新增
            for (int i = 1; i < entities.Length; i++)
            {
                Entity entity = Helper.Deserialize(entities[i].ToString());

                entity.SetValue("Unique", unique.GetValueByName(this._Dal.Table));
                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\":\"" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\",\"People\":\"" + entity.GetValue("Operator").ToString() + "\"}");

                this._Dal.InsertEntity(entity);
            }
        }
Esempio n. 11
0
        public Entity SaveEntityByOperator(Entity entity)
        {
            string strCrateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string msg          = "";

            try
            {
                //entity.SetValue("RebateWater", entity.GetValue("Water")); // 目前没有水份打折,所以折后水份等于原始水份

                /* 对于空值的字段,重新赋值,防止字符串转换为浮点数出错 */
                if (entity.GetValue("Bad").ToString() == "")
                {
                    entity.SetValue("Bad", null);
                }
                if (entity.GetValue("Greater").ToString() == "")
                {
                    entity.SetValue("Greater", null);
                }
                if (entity.GetValue("Less").ToString() == "")
                {
                    entity.SetValue("Less", null);
                }
                //自动计算折后数据
                CalculateRebate(entity);

                this._Dal.BeginTransaction();

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

                /* 新增 */
                if (entity.GetValue("Unique").TryInt32() == 0)
                {
                    CheckForSaveEntityInsert(entity.GetValue("WoodID"));

                    entity.SetValue("Unique", unique.GetValueByName(this._Dal.Table));
                    entity.Add(new SimpleProperty("CheckTime", 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() + "\"}");

                    this._Dal.InsertEntity(entity);

                    msg = "添加记录成功";
                }
                /* 修改 */
                else
                {
                    msg = "不允许在这里修改,需要在化验报告审核页面才能修改";

                    return(Helper.GetEntity(false, msg, entity.GetValue("Unique").ToString()));
                }

                this._Dal.CommitTransaction();

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

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

            try
            {
                if (entity.GetValue("FullVolume") != null && entity.GetValue("FullVolume").ToString().Trim() == "")
                {
                    entity.SetValue("FullVolume", null);
                }
                if (entity.GetValue("WoodID") == null || entity.GetValue("WoodID").TryInt32() == 0)
                {
                    entity.SetValue("WoodID", this._Dal.getWoodID());
                }
                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, woodID;
                /* 新增 */
                if (entity.GetValue("Unique").TryInt32() == 0)
                {
                    //首磅
                    woodID = entity.GetValue("WoodID").TryInt32();
                    entity.SetValue("Unique", unique.GetValueByName(this._Dal.Table));
                    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);

                    msg = "添加记录成功";
                }
                /* 修改 */
                else
                {
                    affectedRows = this._Dal.UpdateEntityByUniqueWithOperator(entity);
                    msg          = "修改记录成功";
                }
                //回皮===================================================================
                Entity emptyEntity = new Entity(new PropertyCollection()
                {
                });
                emptyEntity.Add(new SimpleProperty("BackWeighTime", typeof(DateTime)), entity.GetValue("BackWeighTime").TryString() == "" ? null : entity.GetValue("BackWeighTime").TryString());
                emptyEntity.Add(new SimpleProperty("LFUnique", typeof(int)), entity.GetValue("LFUniqueEmpty").TryInt32());
                emptyEntity.Add(new SimpleProperty("LFDate", typeof(DateTime)), entity.GetValue("LFDateEmpty").TryString() == "" ? null : entity.GetValue("LFDateEmpty").TryString());
                emptyEntity.Add(new SimpleProperty("State", typeof(int)), StateEnum.Default);
                emptyEntity.Add(new SimpleProperty("Version", typeof(int)), 1);
                emptyEntity.Add(new SimpleProperty("EmptyVolume", typeof(decimal)), entity.GetValue("EmptyVolume").TryDecimal());
                emptyEntity.Add(new SimpleProperty("HandVolume", typeof(decimal)), entity.GetValue("HandVolume").TryDecimal());
                emptyEntity.Add(new SimpleProperty("RebateVolume", typeof(decimal)), entity.GetValue("RebateVolume").TryDecimal());
                emptyEntity.Add(new SimpleProperty("Operator", typeof(int)), entity.GetValue("Operator").TryInt32());
                emptyEntity.Add(new SimpleProperty("Log", typeof(string)), "{\"Date\":\"" + strCrateDate + "\",\"People\":\"" + entity.GetValue("Operator").ToString() + "\"}");
                /* 新增 */
                if (entity.GetValue("UniqueEmpty").TryInt32() == 0)
                {
                    woodID = entity.GetValue("WoodID").TryInt32();
                    emptyEntity.Add(new SimpleProperty("WoodID", typeof(int)), woodID);
                    emptyEntity.Add(new SimpleProperty("Unique", typeof(int)), unique.GetValueByName("EmptyPound"));
                    affectedRows = this._Dal.InsertEmptyPoundEntity(emptyEntity);
                }
                else
                {
                    emptyEntity.Add(new SimpleProperty("UniqueEmpty", typeof(int)), entity.GetValue("UniqueEmpty").TryInt32());
                    affectedRows = this._Dal.UpdateEmptyPoundEntity(emptyEntity);
                }

                this._Dal.CommitTransaction();

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

                return(Helper.GetEntity(false, exception.Message));
            }
        }
Esempio n. 13
0
 public virtual void ExecuteForSaveEntities(SqlTransaction transaction, object[] entities, UniqueDal unique)
 {
 }
Esempio n. 14
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));
            }
        }
Esempio n. 15
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));
            }
        }
Esempio n. 16
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));
            }
        }
Esempio n. 17
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));
            }
        }