Beispiel #1
0
 public JsonResult Create(Spl_WareCheckTotalModel model)
 {
     model.CreateTime = ResultHelper.NowTime;
     model.State      = 0;
     model.Creater    = GetUserId();
     model.Checker    = GetUserId();//修改2018年3月13
     if (model != null && ModelState.IsValid)
     {
         if (m_BLL.Create(ref errors, model))
         {
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",WareDetailsId" + model.WareDetailsId, "成功", "创建", "Spl_WareCheckTotal");
             return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed)));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",WareDetailsId" + model.WareDetailsId + "," + ErrorCol, "失败", "创建", "Spl_WareCheckTotal");
             return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail)));
     }
 }
        public virtual Spl_WareCheckTotalModel GetById(object id)
        {
            if (IsExists(id))
            {
                Spl_WareCheckTotal      entity = m_Rep.GetById(id);
                Spl_WareCheckTotalModel model  = new Spl_WareCheckTotalModel();
                model.Id            = entity.Id;
                model.WareDetailsId = entity.WareDetailsId;
                model.WarehouseId   = entity.WarehouseId;
                model.Remark        = entity.Remark;
                model.DiffQuantity  = entity.DiffQuantity;
                model.Quantity      = entity.Quantity;
                model.Price         = entity.Price;
                model.State         = entity.State;
                model.Creater       = entity.Creater;
                model.Checker       = entity.Checker;
                model.CheckTime     = entity.CheckTime;
                model.Confirmation  = entity.Confirmation;
                model.CreateTime    = entity.CreateTime;

                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        public ActionResult Create()
        {
            ViewBag.Warehouse = new SelectList(m_WarehouseBLL.GetList(ref setNoPagerAscById, "", GetUserId()), "Id", "Name");
            ViewBag.Checker   = new SelectList(m_WarehouseBLL.GetList(ref setNoPagerAscById, "", GetUserId()), "Id", "ContactPerson");//x修改2018年3月13
            //AccountModel accountModel = GetAccount();
            Spl_WareCheckTotalModel model = new Spl_WareCheckTotalModel()
            {
                Id    = "CKD" + DateTime.Now.ToString("yyyyMMddHHmmssff"),
                State = 0
                        //Handler = accountModel.Id,
                        //HandlerName = accountModel.TrueName,
            };

            return(View(model));
        }
        public virtual bool Edit(ref ValidationErrors errors, Spl_WareCheckTotalModel model)
        {
            try
            {
                Spl_WareCheckTotal entity = m_Rep.GetById(model.Id);
                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(false);
                }
                entity.Id            = model.Id;
                entity.WareDetailsId = model.WareDetailsId;
                entity.WarehouseId   = model.WarehouseId;
                entity.Remark        = model.Remark;
                entity.DiffQuantity  = model.DiffQuantity;
                entity.Quantity      = model.Quantity;
                entity.Price         = model.Price;
                entity.State         = model.State;
                entity.Creater       = model.Creater;
                entity.Checker       = model.Checker;
                entity.CheckTime     = model.CheckTime;
                entity.Confirmation  = model.Confirmation;
                entity.CreateTime    = model.CreateTime;



                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);
            }
        }
Beispiel #5
0
 public JsonResult Edit(Spl_WareCheckTotalModel model)
 {
     if (model != null && ModelState.IsValid)
     {
         if (m_BLL.Edit(ref errors, model))
         {
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",WareDetailsId" + model.WareDetailsId, "成功", "修改", "Spl_WareCheckTotal");
             return(Json(JsonHandler.CreateMessage(1, Resource.EditSucceed)));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",WareDetailsId" + model.WareDetailsId + "," + ErrorCol, "失败", "修改", "Spl_WareCheckTotal");
             return(Json(JsonHandler.CreateMessage(0, Resource.EditFail + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Resource.EditFail)));
     }
 }
 public override Spl_WareCheckTotalModel GetById(object id)
 {
     if (IsExists(id))
     {
         Spl_WareCheckTotal      entity = m_Rep.GetById(id);
         Spl_WareCheckTotalModel model  = new Spl_WareCheckTotalModel();
         model.Id                  = entity.Id;
         model.WareDetailsId       = entity.WareDetailsId;
         model.WarehouseId         = entity.WarehouseId;
         model.Remark              = entity.Remark;
         model.DiffQuantity        = entity.DiffQuantity;
         model.Quantity            = entity.Quantity;
         model.Price               = entity.Price;
         model.State               = entity.State;
         model.Creater             = entity.Creater;
         model.Checker             = entity.Checker;
         model.CreaterName         = entity.SysUser1.TrueName;
         model.CheckerName         = entity.SysUser.TrueName;
         model.CheckTime           = entity.CheckTime;
         model.Confirmation        = entity.Confirmation;
         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;
         return(model);
     }
     else
     {
         return(null);
     }
 }
        /// <summary>
        /// 校验Excel数据,这个方法一般用于重写校验逻辑
        /// </summary>
        public virtual bool CheckImportData(string fileName, List <Spl_WareCheckTotalModel> list, ref ValidationErrors errors)
        {
            var targetFile = new FileInfo(fileName);

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

            var excelFile = new ExcelQueryFactory(fileName);

            //对应列头
            excelFile.AddMapping <Spl_WareCheckTotalModel>(x => x.WareDetailsId, "货品名称");
            excelFile.AddMapping <Spl_WareCheckTotalModel>(x => x.WarehouseId, "所属仓库");
            excelFile.AddMapping <Spl_WareCheckTotalModel>(x => x.Remark, "盘点说明");
            excelFile.AddMapping <Spl_WareCheckTotalModel>(x => x.DiffQuantity, "实际总数");
            excelFile.AddMapping <Spl_WareCheckTotalModel>(x => x.Quantity, "原有总数");
            excelFile.AddMapping <Spl_WareCheckTotalModel>(x => x.Price, "单价");
            excelFile.AddMapping <Spl_WareCheckTotalModel>(x => x.State, "审核状态");
            excelFile.AddMapping <Spl_WareCheckTotalModel>(x => x.Creater, "创建人");
            excelFile.AddMapping <Spl_WareCheckTotalModel>(x => x.Checker, "审核人");
            excelFile.AddMapping <Spl_WareCheckTotalModel>(x => x.CheckTime, "审核时间");
            excelFile.AddMapping <Spl_WareCheckTotalModel>(x => x.Confirmation, "是否确认");
            excelFile.AddMapping <Spl_WareCheckTotalModel>(x => x.CreateTime, "创建时间");

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

            //检查数据正确性
            foreach (var row in excelContent)
            {
                var errorMessage = new StringBuilder();
                var entity       = new Spl_WareCheckTotalModel();
                entity.Id            = row.Id;
                entity.WareDetailsId = row.WareDetailsId;
                entity.WarehouseId   = row.WarehouseId;
                entity.Remark        = row.Remark;
                entity.DiffQuantity  = row.DiffQuantity;
                entity.Quantity      = row.Quantity;
                entity.Price         = row.Price;
                entity.State         = row.State;
                entity.Creater       = row.Creater;
                entity.Checker       = row.Checker;
                entity.CheckTime     = row.CheckTime;
                entity.Confirmation  = row.Confirmation;
                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);
        }
Beispiel #8
0
        public ActionResult Details(string id)
        {
            Spl_WareCheckTotalModel entity = m_BLL.GetById(id);

            return(View(entity));
        }