public ActionResult Edit(string id)
        {
            Spl_WareDetailsModel entity = m_BLL.GetById(id);

            ViewBag.WareCategory = new SelectList(WareCategoryBLL.GetList(ref setNoPagerAscById, ""), "Id", "Name", entity.WareCategoryId);
            return(View(entity));
        }
示例#2
0
        public virtual async Task <Spl_WareDetailsModel> GetByIdAsync(object id)
        {
            if (IsExists(id))
            {
                Spl_WareDetails entity = await m_Rep.GetByIdAsync(id);

                Spl_WareDetailsModel model = new Spl_WareDetailsModel();
                model.Id             = entity.Id;
                model.Name           = entity.Name;
                model.Code           = entity.Code;
                model.BarCode        = entity.BarCode;
                model.WareCategoryId = entity.WareCategoryId;
                model.Unit           = entity.Unit;
                model.Lable          = entity.Lable;
                model.BuyPrice       = entity.BuyPrice;
                model.SalePrice      = entity.SalePrice;
                model.RetailPrice    = entity.RetailPrice;
                model.Remark         = entity.Remark;
                model.Vender         = entity.Vender;
                model.Brand          = entity.Brand;
                model.Color          = entity.Color;
                model.Material       = entity.Material;
                model.Size           = entity.Size;
                model.Weight         = entity.Weight;
                model.ComeFrom       = entity.ComeFrom;
                model.UpperLimit     = entity.UpperLimit;
                model.LowerLimit     = entity.LowerLimit;
                model.PrimeCost      = entity.PrimeCost;
                model.Price1         = entity.Price1;
                model.Price2         = entity.Price2;
                model.Price3         = entity.Price3;
                model.Price4         = entity.Price4;
                model.Price5         = entity.Price5;
                model.Photo1         = entity.Photo1;
                model.Photo2         = entity.Photo2;
                model.Photo3         = entity.Photo3;
                model.Photo4         = entity.Photo4;
                model.Photo5         = entity.Photo5;
                model.Enable         = entity.Enable;
                model.CreateTime     = entity.CreateTime;

                return(model);
            }
            else
            {
                return(null);
            }
        }
 public JsonResult Edit(Spl_WareDetailsModel model)
 {
     if (model != null && ModelState.IsValid)
     {
         if (m_BLL.Edit(ref errors, model))
         {
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name, "成功", "修改", "Spl_WareDetails");
             return(Json(JsonHandler.CreateMessage(1, Resource.EditSucceed)));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name + "," + ErrorCol, "失败", "修改", "Spl_WareDetails");
             return(Json(JsonHandler.CreateMessage(0, Resource.EditFail + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Resource.EditFail)));
     }
 }
 public JsonResult Create(Spl_WareDetailsModel 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 + ",Name" + model.Name, "成功", "创建", "Spl_WareDetails");
             return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed)));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",Name" + model.Name + "," + ErrorCol, "失败", "创建", "Spl_WareDetails");
             return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail)));
     }
 }
示例#5
0
        /// <summary>
        /// 校验Excel数据,这个方法一般用于重写校验逻辑
        /// </summary>
        public virtual bool CheckImportData(string fileName, List <Spl_WareDetailsModel> list, ref ValidationErrors errors)
        {
            var targetFile = new FileInfo(fileName);

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

            var excelFile = new ExcelQueryFactory(fileName);

            //对应列头
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Name, "Name");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Code, "Code");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.BarCode, "BarCode");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.WareCategoryId, "WareCategoryId");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Unit, "Unit");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Lable, "Lable");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.BuyPrice, "BuyPrice");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.SalePrice, "SalePrice");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.RetailPrice, "RetailPrice");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Remark, "Remark");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Vender, "Vender");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Brand, "Brand");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Color, "Color");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Material, "Material");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Size, "Size");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Weight, "Weight");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.ComeFrom, "ComeFrom");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.UpperLimit, "UpperLimit");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.LowerLimit, "LowerLimit");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.PrimeCost, "PrimeCost");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Price1, "Price1");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Price2, "Price2");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Price3, "Price3");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Price4, "Price4");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Price5, "Price5");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Photo1, "Photo1");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Photo2, "Photo2");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Photo3, "Photo3");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Photo4, "Photo4");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Photo5, "Photo5");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Enable, "Enable");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.CreateTime, "CreateTime");

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

            //检查数据正确性
            foreach (var row in excelContent)
            {
                var errorMessage = new StringBuilder();
                var entity       = new Spl_WareDetailsModel();
                entity.Id             = row.Id;
                entity.Name           = row.Name;
                entity.Code           = row.Code;
                entity.BarCode        = row.BarCode;
                entity.WareCategoryId = row.WareCategoryId;
                entity.Unit           = row.Unit;
                entity.Lable          = row.Lable;
                entity.BuyPrice       = row.BuyPrice;
                entity.SalePrice      = row.SalePrice;
                entity.RetailPrice    = row.RetailPrice;
                entity.Remark         = row.Remark;
                entity.Vender         = row.Vender;
                entity.Brand          = row.Brand;
                entity.Color          = row.Color;
                entity.Material       = row.Material;
                entity.Size           = row.Size;
                entity.Weight         = row.Weight;
                entity.ComeFrom       = row.ComeFrom;
                entity.UpperLimit     = row.UpperLimit;
                entity.LowerLimit     = row.LowerLimit;
                entity.PrimeCost      = row.PrimeCost;
                entity.Price1         = row.Price1;
                entity.Price2         = row.Price2;
                entity.Price3         = row.Price3;
                entity.Price4         = row.Price4;
                entity.Price5         = row.Price5;
                entity.Photo1         = row.Photo1;
                entity.Photo2         = row.Photo2;
                entity.Photo3         = row.Photo3;
                entity.Photo4         = row.Photo4;
                entity.Photo5         = row.Photo5;
                entity.Enable         = row.Enable;
                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);
        }
示例#6
0
        public virtual async Task <Tuple <ValidationErrors, bool> > EditAsync(Spl_WareDetailsModel model)
        {
            ValidationErrors errors = new ValidationErrors();

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

                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
                entity.Id             = model.Id;
                entity.Name           = model.Name;
                entity.Code           = model.Code;
                entity.BarCode        = model.BarCode;
                entity.WareCategoryId = model.WareCategoryId;
                entity.Unit           = model.Unit;
                entity.Lable          = model.Lable;
                entity.BuyPrice       = model.BuyPrice;
                entity.SalePrice      = model.SalePrice;
                entity.RetailPrice    = model.RetailPrice;
                entity.Remark         = model.Remark;
                entity.Vender         = model.Vender;
                entity.Brand          = model.Brand;
                entity.Color          = model.Color;
                entity.Material       = model.Material;
                entity.Size           = model.Size;
                entity.Weight         = model.Weight;
                entity.ComeFrom       = model.ComeFrom;
                entity.UpperLimit     = model.UpperLimit;
                entity.LowerLimit     = model.LowerLimit;
                entity.PrimeCost      = model.PrimeCost;
                entity.Price1         = model.Price1;
                entity.Price2         = model.Price2;
                entity.Price3         = model.Price3;
                entity.Price4         = model.Price4;
                entity.Price5         = model.Price5;
                entity.Photo1         = model.Photo1;
                entity.Photo2         = model.Photo2;
                entity.Photo3         = model.Photo3;
                entity.Photo4         = model.Photo4;
                entity.Photo5         = model.Photo5;
                entity.Enable         = model.Enable;
                entity.CreateTime     = model.CreateTime;


                if (await m_Rep.EditAsync(entity))
                {
                    return(new Tuple <ValidationErrors, bool>(errors, true));
                }
                else
                {
                    errors.Add(Resource.NoDataChange);
                    return(new Tuple <ValidationErrors, bool>(errors, false));
                }
            }
            catch (Exception ex)
            {
                errors.Add(ex.Message);
                ExceptionHander.WriteException(ex);
                return(new Tuple <ValidationErrors, bool>(errors, false));
            }
        }
示例#7
0
        public virtual bool Create(ref ValidationErrors errors, Spl_WareDetailsModel model)
        {
            try
            {
                Spl_WareDetails entity = m_Rep.GetById(model.Id);
                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(false);
                }
                entity                = new Spl_WareDetails();
                entity.Id             = model.Id;
                entity.Name           = model.Name;
                entity.Code           = model.Code;
                entity.BarCode        = model.BarCode;
                entity.WareCategoryId = model.WareCategoryId;
                entity.Unit           = model.Unit;
                entity.Lable          = model.Lable;
                entity.BuyPrice       = model.BuyPrice;
                entity.SalePrice      = model.SalePrice;
                entity.RetailPrice    = model.RetailPrice;
                entity.Remark         = model.Remark;
                entity.Vender         = model.Vender;
                entity.Brand          = model.Brand;
                entity.Color          = model.Color;
                entity.Material       = model.Material;
                entity.Size           = model.Size;
                entity.Weight         = model.Weight;
                entity.ComeFrom       = model.ComeFrom;
                entity.UpperLimit     = model.UpperLimit;
                entity.LowerLimit     = model.LowerLimit;
                entity.PrimeCost      = model.PrimeCost;
                entity.Price1         = model.Price1;
                entity.Price2         = model.Price2;
                entity.Price3         = model.Price3;
                entity.Price4         = model.Price4;
                entity.Price5         = model.Price5;
                entity.Photo1         = model.Photo1;
                entity.Photo2         = model.Photo2;
                entity.Photo3         = model.Photo3;
                entity.Photo4         = model.Photo4;
                entity.Photo5         = model.Photo5;
                entity.Enable         = model.Enable;
                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);
            }
        }
        public ActionResult Details(string id)
        {
            Spl_WareDetailsModel entity = m_BLL.GetById(id);

            return(View(entity));
        }
示例#9
0
        /// <summary>
        /// 校验Excel数据,这个方法一般用于重写校验逻辑
        /// </summary>
        public virtual bool CheckImportData(string fileName, List <Spl_WareDetailsModel> list, ref ValidationErrors errors)
        {
            var targetFile = new FileInfo(fileName);

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

            var excelFile = new ExcelQueryFactory(fileName);

            //对应列头
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Name, "名称");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Code, "编码");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.BarCode, "条码");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.WareCategoryId, "存货分类");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Unit, "计量单位");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Lable, "存货标签");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.BuyPrice, "参考进价");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.SalePrice, "参考售价");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.RetailPrice, "零售价");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Remark, "备注");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Vender, "其他信息-厂家");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Brand, "品牌");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Color, "颜色");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Material, "材质");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Size, "尺码");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Weight, "重量");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.ComeFrom, "产地");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.UpperLimit, "最高库存");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.LowerLimit, "最低库存");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.PrimeCost, "参考成本");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Price1, "一级价格");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Price2, "二级价格");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Price3, "三级价格");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Price4, "四级价格");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Price5, "五级价格");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Photo1, "照片1");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Photo2, "照片2");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Photo3, "照片3");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Photo4, "照片4");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Photo5, "照片5");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Enable, "状态");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.CreateTime, "CreateTime");

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

            //检查数据正确性
            foreach (var row in excelContent)
            {
                var errorMessage = new StringBuilder();
                var entity       = new Spl_WareDetailsModel();
                entity.Id             = row.Id;
                entity.Name           = row.Name;
                entity.Code           = row.Code;
                entity.BarCode        = row.BarCode;
                entity.WareCategoryId = row.WareCategoryId;
                entity.Unit           = row.Unit;
                entity.Lable          = row.Lable;
                entity.BuyPrice       = row.BuyPrice;
                entity.SalePrice      = row.SalePrice;
                entity.RetailPrice    = row.RetailPrice;
                entity.Remark         = row.Remark;
                entity.Vender         = row.Vender;
                entity.Brand          = row.Brand;
                entity.Color          = row.Color;
                entity.Material       = row.Material;
                entity.Size           = row.Size;
                entity.Weight         = row.Weight;
                entity.ComeFrom       = row.ComeFrom;
                entity.UpperLimit     = row.UpperLimit;
                entity.LowerLimit     = row.LowerLimit;
                entity.PrimeCost      = row.PrimeCost;
                entity.Price1         = row.Price1;
                entity.Price2         = row.Price2;
                entity.Price3         = row.Price3;
                entity.Price4         = row.Price4;
                entity.Price5         = row.Price5;
                entity.Photo1         = row.Photo1;
                entity.Photo2         = row.Photo2;
                entity.Photo3         = row.Photo3;
                entity.Photo4         = row.Photo4;
                entity.Photo5         = row.Photo5;
                entity.Enable         = row.Enable;
                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);
        }
        /// <summary>
        /// 校验Excel数据,这个方法一般用于重写校验逻辑
        /// </summary>
        public bool CheckImportData(string fileName, List <Spl_WareDetailsModel> list, ref ValidationErrors errors, string wareCategoryId)
        {
            var targetFile = new FileInfo(fileName);

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

            var excelFile = new ExcelQueryFactory(fileName);

            //对应列头
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Code, "编码");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Name, "名称");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Brand, "品牌");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Size, "型号");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Unit, "单位");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.SalePrice, "单价");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Vender, "厂家");
            excelFile.AddMapping <Spl_WareDetailsModel>(x => x.Material, "技术参数");


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

            //检查数据正确性
            foreach (var row in excelContent)
            {
                if (row.Name != "" && row.Code != "")
                {
                    var errorMessage = new StringBuilder();
                    var entity       = new Spl_WareDetailsModel();
                    entity.Id             = ResultHelper.NewId;
                    entity.Name           = row.Name; //名称
                    entity.Code           = row.Code; //编码
                    entity.BarCode        = row.Code;
                    entity.WareCategoryId = wareCategoryId;
                    entity.Unit           = row.Unit;      //单位
                    entity.SalePrice      = row.SalePrice; //单价
                    entity.Brand          = row.Brand;     //品牌
                    entity.Vender         = row.Vender;    //厂家
                    entity.Size           = row.Size;      //型号
                    entity.Material       = row.Material;  //型号
                    entity.Enable         = true;
                    entity.CreateTime     = ResultHelper.NowTime;

                    //=============================================================================
                    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);
        }