public virtual bool Edit(ref ValidationErrors errors, WMS_LineModel model)
        {
            try
            {
                WMS_Line entity = m_Rep.GetById(model.Id);
                if (entity == null)
                {
                    errors.Add(Resource.Disable);
                    return(false);
                }
                entity.Id       = model.Id;
                entity.HeaderId = model.HeaderId;
                entity.LineName = model.LineName;



                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);
            }
        }
        public virtual bool Create(ref ValidationErrors errors, WMS_LineModel model)
        {
            try
            {
                WMS_Line entity = m_Rep.GetById(model.Id);
                if (entity != null)
                {
                    errors.Add(Resource.PrimaryRepeat);
                    return(false);
                }
                entity          = new WMS_Line();
                entity.Id       = model.Id;
                entity.HeaderId = model.HeaderId;
                entity.LineName = model.LineName;


                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 Edit(long id)
        {
            WMS_LineModel entity = m_BLL.GetById(id);

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

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

            var excelFile = new ExcelQueryFactory(fileName);

            //对应列头
            excelFile.AddMapping <WMS_LineModel>(x => x.HeaderId, "HeaderId");
            excelFile.AddMapping <WMS_LineModel>(x => x.LineName, "LineName");

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

            //检查数据正确性
            foreach (var row in excelContent)
            {
                var errorMessage = new StringBuilder();
                var entity       = new WMS_LineModel();
                entity.Id       = row.Id;
                entity.HeaderId = row.HeaderId;
                entity.LineName = row.LineName;

                //=============================================================================
                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);
        }
        public virtual WMS_LineModel GetById(object id)
        {
            if (IsExists(id))
            {
                WMS_Line      entity = m_Rep.GetById(id);
                WMS_LineModel model  = new WMS_LineModel();
                model.Id       = entity.Id;
                model.HeaderId = entity.HeaderId;
                model.LineName = entity.LineName;

                return(model);
            }
            else
            {
                return(null);
            }
        }
 public JsonResult Edit(WMS_LineModel model)
 {
     if (model != null && ModelState.IsValid)
     {
         if (m_BLL.Edit(ref errors, model))
         {
             LogHandler.WriteServiceLog(GetUserTrueName(), "Id" + model.Id + ",HeaderId" + model.HeaderId, "成功", "修改", "WMS_Line");
             return(Json(JsonHandler.CreateMessage(1, Resource.EditSucceed)));
         }
         else
         {
             string ErrorCol = errors.Error;
             LogHandler.WriteServiceLog(GetUserTrueName(), "Id" + model.Id + ",HeaderId" + model.HeaderId + "," + ErrorCol, "失败", "修改", "WMS_Line");
             return(Json(JsonHandler.CreateMessage(0, Resource.EditFail + ErrorCol)));
         }
     }
     else
     {
         return(Json(JsonHandler.CreateMessage(0, Resource.EditFail)));
     }
 }
        public ActionResult Details(long id)
        {
            WMS_LineModel entity = m_BLL.GetById(id);

            return(View(entity));
        }