コード例 #1
0
        /// <summary>
        /// 保存数据
        /// </summary>
        public virtual void SaveImportData(IEnumerable <Spl_WarehouseAllocationDetailsModel> list)
        {
            try
            {
                using (DBContainer db = new DBContainer())
                {
                    foreach (var model in list)
                    {
                        Spl_WarehouseAllocationDetails entity = new Spl_WarehouseAllocationDetails();
                        entity.Id                    = ResultHelper.NewId;
                        entity.WareDetailsId         = model.WareDetailsId;
                        entity.WarehouseId           = model.WarehouseId;
                        entity.WarehouseAllocationId = model.WarehouseAllocationId;
                        entity.Quantity              = model.Quantity;
                        entity.Price                 = model.Price;
                        entity.TotalPrice            = model.TotalPrice;
                        entity.Defined               = model.Defined;
                        entity.CreateTime            = ResultHelper.NowTime;

                        db.Spl_WarehouseAllocationDetails.Add(entity);
                    }
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #2
0
        public void SaveEditData(IEnumerable <Spl_WarehouseAllocationDetailsModel> personList, string WarehouseAllocationId)
        {
            try
            {
                using (DBContainer db = new DBContainer())
                {
                    int count = db.Database.ExecuteSqlCommand("delete Spl_WarehouseAllocationDetails where WarehouseAllocationId=@WarehouseAllocationId", new SqlParameter("@WarehouseAllocationId", WarehouseAllocationId));
                    foreach (var model in personList)
                    {
                        Spl_WarehouseAllocationDetails entity = new Spl_WarehouseAllocationDetails();
                        entity.Id                    = model.Id;
                        entity.WareDetailsId         = model.WareDetailsId;
                        entity.WarehouseId           = model.WarehouseId;
                        entity.WarehouseAllocationId = model.WarehouseAllocationId;
                        entity.Quantity              = model.Quantity;
                        entity.Price                 = model.Price;
                        entity.TotalPrice            = model.TotalPrice;
                        entity.Defined               = model.Defined;
                        entity.CreateTime            = model.CreateTime;
                        entity.Id                    = ResultHelper.NewId;
                        db.Spl_WarehouseAllocationDetails.Add(entity);
                    }

                    db.SaveChanges();
                }
            }
            catch
            {
                throw;
            }
        }
コード例 #3
0
        public virtual bool Create(ref ValidationErrors errors, Spl_WarehouseAllocationDetailsModel model)
        {
            try
            {
                Spl_WarehouseAllocationDetails entity = m_Rep.GetById(model.Id);
                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(false);
                }
                entity                       = new Spl_WarehouseAllocationDetails();
                entity.Id                    = model.Id;
                entity.WareDetailsId         = model.WareDetailsId;
                entity.WarehouseId           = model.WarehouseId;
                entity.WarehouseAllocationId = model.WarehouseAllocationId;
                entity.Quantity              = model.Quantity;
                entity.Price                 = model.Price;
                entity.TotalPrice            = model.TotalPrice;
                entity.Defined               = model.Defined;
                entity.CreateTime            = model.CreateTime;


                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);
            }
        }
コード例 #4
0
 /// <summary>
 /// 保存数据
 /// </summary>
 public void SaveData(IEnumerable <Spl_WarehouseAllocationDetailsModel> personList)
 {
     try
     {
         using (DBContainer db = new DBContainer())
         {
             foreach (var model in personList)
             {
                 Spl_WarehouseAllocationDetails entity = new Spl_WarehouseAllocationDetails();
                 entity.Id                    = model.Id;
                 entity.WareDetailsId         = model.WareDetailsId;
                 entity.WarehouseId           = model.WarehouseId;
                 entity.WarehouseAllocationId = model.WarehouseAllocationId;
                 entity.Quantity              = model.Quantity;
                 entity.Price                 = model.Price;
                 entity.TotalPrice            = model.TotalPrice;
                 entity.Defined               = model.Defined;
                 entity.CreateTime            = model.CreateTime;
                 //新增
                 if (string.IsNullOrEmpty(model.Id))
                 {
                     entity.Id = ResultHelper.NewId;
                     db.Spl_WarehouseAllocationDetails.Add(entity);
                 }
                 else
                 {
                     //修改
                     db.Set <Spl_WarehouseAllocationDetails>().Attach(entity);
                     db.Entry <Spl_WarehouseAllocationDetails>(entity).State = EntityState.Modified;
                 }
             }
             db.SaveChanges();
         }
     }
     catch
     {
         throw;
     }
 }
コード例 #5
0
        public virtual Spl_WarehouseAllocationDetailsModel GetById(object id)
        {
            if (IsExists(id))
            {
                Spl_WarehouseAllocationDetails      entity = m_Rep.GetById(id);
                Spl_WarehouseAllocationDetailsModel model  = new Spl_WarehouseAllocationDetailsModel();
                model.Id                    = entity.Id;
                model.WareDetailsId         = entity.WareDetailsId;
                model.WarehouseId           = entity.WarehouseId;
                model.WarehouseAllocationId = entity.WarehouseAllocationId;
                model.Quantity              = entity.Quantity;
                model.Price                 = entity.Price;
                model.TotalPrice            = entity.TotalPrice;
                model.Defined               = entity.Defined;
                model.CreateTime            = entity.CreateTime;

                return(model);
            }
            else
            {
                return(null);
            }
        }