Exemplo n.º 1
0
        //删除
        public override bool Delete(ref ValidationErrors errors, object id)
        {
            try
            {
                Spl_WarehouseWarrant entity = new Spl_WarehouseWarrant();
                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);
            }
        }
        public virtual Spl_WarehouseWarrantModel GetById(object id)
        {
            if (IsExists(id))
            {
                Spl_WarehouseWarrant      entity = m_Rep.GetById(id);
                Spl_WarehouseWarrantModel model  = new Spl_WarehouseWarrantModel();
                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.InOutCategoryId = entity.InOutCategoryId;
                model.WarehouseId     = entity.WarehouseId;
                model.ContractNumber  = entity.ContractNumber;

                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 保存数据
        /// </summary>
        public virtual void SaveImportData(IEnumerable <Spl_WarehouseWarrantModel> list)
        {
            try
            {
                using (DBContainer db = new DBContainer())
                {
                    foreach (var model in list)
                    {
                        Spl_WarehouseWarrant entity = new Spl_WarehouseWarrant();
                        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.InOutCategoryId = model.InOutCategoryId;
                        entity.WarehouseId     = model.WarehouseId;

                        db.Spl_WarehouseWarrant.Add(entity);
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 4
0
        ///修改
        ///
        public override bool Edit(ref ValidationErrors errors, Spl_WarehouseWarrantModel model)
        {
            try
            {
                Spl_WarehouseWarrant 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.InOutCategoryId = model.InOutCategoryId;
                entity.WarehouseId     = model.WarehouseId;
                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);
            }
        }
Exemplo n.º 5
0
        public virtual async Task <Tuple <ValidationErrors, bool> > CreateAsync(Spl_WarehouseWarrantModel model)
        {
            ValidationErrors errors = new ValidationErrors();

            try
            {
                Spl_WarehouseWarrant entity = await m_Rep.GetByIdAsync(model.Id);

                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
                entity                 = new Spl_WarehouseWarrant();
                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.InOutCategoryId = model.InOutCategoryId;
                entity.WarehouseId     = model.WarehouseId;


                if (await m_Rep.CreateAsync(entity))
                {
                    return(new Tuple <ValidationErrors, bool>(errors, true));
                }
                else
                {
                    errors.Add(Resource.InsertFail);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(new Tuple <ValidationErrors, bool>(errors, false));
            }
        }
        public virtual bool Create(ref ValidationErrors errors, Spl_WarehouseWarrantModel model)
        {
            try
            {
                Spl_WarehouseWarrant entity = m_Rep.GetById(model.Id);
                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(false);
                }
                entity                 = new Spl_WarehouseWarrant();
                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.InOutCategoryId = model.InOutCategoryId;
                entity.WarehouseId     = model.WarehouseId;
                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);
            }
        }
Exemplo n.º 7
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_WarehouseWarrant 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.UpdateWareStockPileIn(entity.Id);
                    return(true);
                }
                else
                {
                    errors.Add(Resource.CheckFail);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(false);
            }
        }