Exemplo n.º 1
0
 public override Spl_WareStockPileModel GetById(object id)
 {
     if (IsExists(id))
     {
         Spl_WareStockPile      entity = m_Rep.GetById(id);
         Spl_WareStockPileModel model  = new Spl_WareStockPileModel();
         model.Id                  = entity.Id;
         model.WarehouseId         = entity.WarehouseId;
         model.WareDetailsId       = entity.WareDetailsId;
         model.FirstEnterDate      = entity.FirstEnterDate;
         model.LastLeaveDate       = entity.LastLeaveDate;
         model.WaringQuantity      = entity.WaringQuantity;
         model.Quantity            = entity.Quantity;
         model.Price               = entity.Price;
         model.CreateTime          = entity.CreateTime;
         model.WarehouseName       = entity.Spl_Warehouse.Name;
         model.WareDetailsCode     = entity.Spl_WareDetails.Code;
         model.WareDetailsUnit     = entity.Spl_WareDetails.Unit;
         model.WareDetailsCategory = entity.Spl_WareDetails.Spl_WareCategory.Name;
         model.WareDetailsVender   = entity.Spl_WareDetails.Vender;
         model.WareDetailsBrand    = entity.Spl_WareDetails.Brand;
         model.WareDetailsSize     = entity.Spl_WareDetails.Size;
         model.WareDetailsName     = entity.Spl_WareDetails.Name;
         model.WaringQuantity      = entity.WaringQuantity;
         return(model);
     }
     else
     {
         return(null);
     }
 }
Exemplo n.º 2
0
        public ActionResult Edit(string id)
        {
            Spl_WareStockPileModel entity = m_BLL.GetById(id);

            ViewBag.Warehouse = new SelectList(m_WarehouseBLL.GetList(ref setNoPagerAscById, ""), "Id", "Name", entity.WarehouseId);
            return(View(entity));
        }
        /// <summary>
        /// 校验Excel数据,这个方法一般用于重写校验逻辑
        /// </summary>
        public virtual bool CheckImportData(string fileName, List <Spl_WareStockPileModel> list, ref ValidationErrors errors)
        {
            var targetFile = new FileInfo(fileName);

            if (!targetFile.Exists)
            {
                errors.Add("导入的数据文件不存在");
                return(false);
            }

            var excelFile = new ExcelQueryFactory(fileName);

            //对应列头
            excelFile.AddMapping <Spl_WareStockPileModel>(x => x.WarehouseId, "WarehouseId");
            excelFile.AddMapping <Spl_WareStockPileModel>(x => x.WareDetailsId, "WareDetailsId");
            excelFile.AddMapping <Spl_WareStockPileModel>(x => x.FirstEnterDate, "最后入库时间");
            excelFile.AddMapping <Spl_WareStockPileModel>(x => x.LastLeaveDate, "最后出库时间");
            excelFile.AddMapping <Spl_WareStockPileModel>(x => x.WaringQuantity, "WaringQuantity");
            excelFile.AddMapping <Spl_WareStockPileModel>(x => x.Quantity, "库存量");
            excelFile.AddMapping <Spl_WareStockPileModel>(x => x.Price, "加权价");
            excelFile.AddMapping <Spl_WareStockPileModel>(x => x.CreateTime, "创建时间");

            //SheetName
            var excelContent = excelFile.Worksheet <Spl_WareStockPileModel>(0);
            int rowIndex     = 1;

            //检查数据正确性
            foreach (var row in excelContent)
            {
                var errorMessage = new StringBuilder();
                var entity       = new Spl_WareStockPileModel();
                entity.Id             = row.Id;
                entity.WarehouseId    = row.WarehouseId;
                entity.WareDetailsId  = row.WareDetailsId;
                entity.FirstEnterDate = row.FirstEnterDate;
                entity.LastLeaveDate  = row.LastLeaveDate;
                entity.WaringQuantity = row.WaringQuantity;
                entity.Quantity       = row.Quantity;
                entity.Price          = row.Price;
                entity.CreateTime     = row.CreateTime;

                //=============================================================================
                if (errorMessage.Length > 0)
                {
                    errors.Add(string.Format(
                                   "第 {0} 列发现错误:{1}{2}",
                                   rowIndex,
                                   errorMessage,
                                   "<br/>"));
                }
                list.Add(entity);
                rowIndex += 1;
            }
            if (errors.Count > 0)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 4
0
        public Spl_WareStockPileModel GetQuantity(string warehouseid, string waredetailsid)
        {
            Spl_WareStockPileModel         model     = new Spl_WareStockPileModel();
            IQueryable <Spl_WareStockPile> queryData = checkRepository.GetList(a => a.WarehouseId == warehouseid && a.WareDetailsId == waredetailsid);
            List <Spl_WareStockPileModel>  list      = CreateModelList2(ref queryData);

            if (list.Count == 0)
            {
                return(model);
            }

            return(list[0]);
        }
Exemplo n.º 5
0
 public JsonResult Edit(Spl_WareStockPileModel model)
 {
     if (model != null && ModelState.IsValid)
     {
         if (m_BLL.Edit(ref errors, model))
         {
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",WarehouseId" + model.WarehouseId, "成功", "修改", "Spl_WareStockPile");
             return(Json(JsonHandler.CreateMessage(1, Resource.EditSucceed)));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",WarehouseId" + model.WarehouseId + "," + ErrorCol, "失败", "修改", "Spl_WareStockPile");
             return(Json(JsonHandler.CreateMessage(0, Resource.EditFail + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Resource.EditFail)));
     }
 }
        public virtual bool Create(ref ValidationErrors errors, Spl_WareStockPileModel model)
        {
            try
            {
                Spl_WareStockPile entity = m_Rep.GetById(model.Id);
                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(false);
                }
                entity                = new Spl_WareStockPile();
                entity.Id             = model.Id;
                entity.WarehouseId    = model.WarehouseId;
                entity.WareDetailsId  = model.WareDetailsId;
                entity.FirstEnterDate = model.FirstEnterDate;
                entity.LastLeaveDate  = model.LastLeaveDate;
                entity.WaringQuantity = model.WaringQuantity;
                entity.Quantity       = model.Quantity;
                entity.Price          = model.Price;
                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);
            }
        }
Exemplo n.º 7
0
 public JsonResult Create(Spl_WareStockPileModel model)
 {
     model.Id         = ResultHelper.NewId;
     model.CreateTime = ResultHelper.NowTime;
     if (model != null && ModelState.IsValid)
     {
         if (m_BLL.Create(ref errors, model))
         {
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",WarehouseId" + model.WarehouseId, "成功", "创建", "Spl_WareStockPile");
             return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed)));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",WarehouseId" + model.WarehouseId + "," + ErrorCol, "失败", "创建", "Spl_WareStockPile");
             return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail)));
     }
 }
        public virtual Spl_WareStockPileModel GetById(object id)
        {
            if (IsExists(id))
            {
                Spl_WareStockPile      entity = m_Rep.GetById(id);
                Spl_WareStockPileModel model  = new Spl_WareStockPileModel();
                model.Id             = entity.Id;
                model.WarehouseId    = entity.WarehouseId;
                model.WareDetailsId  = entity.WareDetailsId;
                model.FirstEnterDate = entity.FirstEnterDate;
                model.LastLeaveDate  = entity.LastLeaveDate;
                model.WaringQuantity = entity.WaringQuantity;
                model.Quantity       = entity.Quantity;
                model.Price          = entity.Price;
                model.CreateTime     = entity.CreateTime;

                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 9
0
        public ActionResult Details(string id)
        {
            Spl_WareStockPileModel entity = m_BLL.GetById(id);

            return(View(entity));
        }
Exemplo n.º 10
0
        public JsonResult GetQuantity(string warehouseid, string waredetailsid)
        {
            Spl_WareStockPileModel entity = m_BLL.GetQuantity(warehouseid, waredetailsid);

            return(Json(entity));
        }