public virtual Spl_WarehouseAllocationModel GetById(object id)
        {
            if (IsExists(id))
            {
                Spl_WarehouseAllocation      entity = m_Rep.GetById(id);
                Spl_WarehouseAllocationModel model  = new Spl_WarehouseAllocationModel();
                model.Id              = entity.Id;
                model.InTime          = entity.InTime;
                model.Handler         = entity.Handler;
                model.Remark          = entity.Remark;
                model.PriceTotal      = entity.PriceTotal;
                model.State           = entity.State;
                model.Checker         = entity.Checker;
                model.CheckTime       = entity.CheckTime;
                model.CreateTime      = entity.CreateTime;
                model.CreatePerson    = entity.CreatePerson;
                model.ModifyTime      = entity.ModifyTime;
                model.ModifyPerson    = entity.ModifyPerson;
                model.Confirmation    = entity.Confirmation;
                model.FromWarehouseId = entity.FromWarehouseId;
                model.ToWarehouseId   = entity.ToWarehouseId;
                model.ContractNumber  = entity.ContractNumber;

                return(model);
            }
            else
            {
                return(null);
            }
        }
Example #2
0
        //删除
        public override bool Delete(ref ValidationErrors errors, object id)
        {
            try
            {
                Spl_WarehouseAllocation entity = new Spl_WarehouseAllocation();
                if (entity.State == 1)
                {
                    errors.Add("单据已审核不能被删除");
                    return(false);
                }

                if (m_Rep.Delete(id) == 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
Example #3
0
        ///修改
        ///
        public override bool Edit(ref ValidationErrors errors, Spl_WarehouseAllocationModel model)
        {
            try
            {
                Spl_WarehouseAllocation entity = m_Rep.GetById(model.Id);
                if (entity.Confirmation == true)
                {
                    errors.Add("单据已确认不能被修改");
                    return(false);
                }//修改于2018年2月5日
                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(false);
                }
                entity.Id              = model.Id;
                entity.InTime          = model.InTime;
                entity.Handler         = model.Handler;
                entity.Remark          = model.Remark;
                entity.PriceTotal      = model.PriceTotal;
                entity.State           = model.State;
                entity.Checker         = model.Checker;
                entity.CheckTime       = model.CheckTime;
                entity.CreateTime      = model.CreateTime;
                entity.CreatePerson    = model.CreatePerson;
                entity.ModifyTime      = model.ModifyTime;
                entity.ModifyPerson    = model.ModifyPerson;
                entity.Confirmation    = model.Confirmation;
                entity.ToWarehouseId   = model.ToWarehouseId;
                entity.FromWarehouseId = model.FromWarehouseId;
                entity.ContractNumber  = model.ContractNumber;

                if (m_Rep.Edit(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Resource.NoDataChange);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
        public virtual bool Create(ref ValidationErrors errors, Spl_WarehouseAllocationModel model)
        {
            try
            {
                Spl_WarehouseAllocation entity = m_Rep.GetById(model.Id);
                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(false);
                }
                entity                 = new Spl_WarehouseAllocation();
                entity.Id              = model.Id;
                entity.InTime          = model.InTime;
                entity.Handler         = model.Handler;
                entity.Remark          = model.Remark;
                entity.PriceTotal      = model.PriceTotal;
                entity.State           = model.State;
                entity.Checker         = model.Checker;
                entity.CheckTime       = model.CheckTime;
                entity.CreateTime      = model.CreateTime;
                entity.CreatePerson    = model.CreatePerson;
                entity.ModifyTime      = model.ModifyTime;
                entity.ModifyPerson    = model.ModifyPerson;
                entity.Confirmation    = model.Confirmation;
                entity.FromWarehouseId = model.FromWarehouseId;
                entity.ToWarehouseId   = model.ToWarehouseId;
                entity.ContractNumber  = model.ContractNumber;


                if (m_Rep.Create(entity))
                {
                    return(true);
                }
                else
                {
                    errors.Add(Resource.InsertFail);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
Example #5
0
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="errors">持久的错误信息</param>
        /// <param name="id">主键</param>
        /// <param name="checkFlag">1审核0反审核</param>
        /// <param name="checker">审核人</param>
        /// <returns>是否成功</returns>
        public bool Check(ref ValidationErrors errors, string id, int checkFlag, string checker)
        {
            try
            {
                Spl_WarehouseAllocation entity = m_Rep.GetById(id);
                if (entity.State == 1)
                {
                    errors.Add("单据已经审核");
                    return(false);
                }
                if (entity.Confirmation == false)
                {
                    errors.Add("单据未经确认不能审核");
                    return(false);
                }
                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(false);
                }
                entity.State     = checkFlag;
                entity.Checker   = checker;
                entity.CheckTime = DateTime.Now;

                if (m_Rep.Edit(entity))
                {
                    //更新库存表
                    m_Rep.UpdateWareStockPileAllocation(entity.Id);
                    return(true);
                }
                else
                {
                    errors.Add(Resource.CheckFail);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }
        /// <summary>
        /// 保存数据
        /// </summary>
        public virtual void SaveImportData(IEnumerable <Spl_WarehouseAllocationModel> list)
        {
            try
            {
                using (DBContainer db = new DBContainer())
                {
                    foreach (var model in list)
                    {
                        Spl_WarehouseAllocation entity = new Spl_WarehouseAllocation();
                        entity.Id              = ResultHelper.NewId;
                        entity.InTime          = model.InTime;
                        entity.Handler         = model.Handler;
                        entity.Remark          = model.Remark;
                        entity.PriceTotal      = model.PriceTotal;
                        entity.State           = model.State;
                        entity.Checker         = model.Checker;
                        entity.CheckTime       = model.CheckTime;
                        entity.CreateTime      = ResultHelper.NowTime;
                        entity.CreatePerson    = model.CreatePerson;
                        entity.ModifyTime      = model.ModifyTime;
                        entity.ModifyPerson    = model.ModifyPerson;
                        entity.Confirmation    = model.Confirmation;
                        entity.FromWarehouseId = model.FromWarehouseId;
                        entity.ToWarehouseId   = model.ToWarehouseId;
                        entity.ContractNumber  = model.ContractNumber;

                        db.Spl_WarehouseAllocation.Add(entity);
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }