public ActionResult Print(string id) { ViewBag.ComName = siteConfig.webcompany; Spl_WarehouseWarrantModel entity = m_BLL.GetById(id); return(View(entity)); }
public virtual Spl_WarehouseWarrantModel GetById(object id) { if (IsExists(id)) { Spl_WarehouseWarrant entity = m_Rep.GetById(id); Spl_WarehouseWarrantModel model = new Spl_WarehouseWarrantModel(); model.Id = entity.Id; model.InTime = entity.InTime; model.Handler = entity.Handler; model.Remark = entity.Remark; model.PriceTotal = entity.PriceTotal; model.State = entity.State; model.Checker = entity.Checker; model.CheckTime = entity.CheckTime; model.CreateTime = entity.CreateTime; model.CreatePerson = entity.CreatePerson; model.ModifyTime = entity.ModifyTime; model.ModifyPerson = entity.ModifyPerson; model.Confirmation = entity.Confirmation; model.InOutCategoryId = entity.InOutCategoryId; model.WarehouseId = entity.WarehouseId; model.ContractNumber = entity.ContractNumber; return(model); } else { return(null); } }
public ActionResult Edit(string id) { Spl_WarehouseWarrantModel entity = m_BLL.GetById(id); ViewBag.Warehouse = new SelectList(WarehouseBLL.GetList(ref setNoPagerAscById, "", GetUserId()), "Id", "Name", entity.WarehouseId); ViewBag.InOutCategory = new SelectList(InOutCategoryBLL.GetList(ref setNoPagerAscById, "入库"), "Id", "Name", entity.InOutCategoryId); return(View(entity)); }
public JsonResult Edit(Spl_WarehouseWarrantModel model, string inserted) { var detailsList = JsonHandler.DeserializeJsonToList <Spl_WarehouseWarrantDetailsModel>(inserted); if (detailsList != null && detailsList.Count != 0) { //计算总价 model.PriceTotal = detailsList.Sum(a => a.Quantity * a.Price); model.ModifyTime = DateTime.Now; if (model != null && ModelState.IsValid) { if (m_BLL.Edit(ref errors, model)) { var detailsResultList = new List <Spl_WarehouseWarrantDetailsModel>(); //新加 foreach (var r in detailsList) { //过滤无效数据 if (string.IsNullOrEmpty(r.WareDetailsId)) { continue; } Spl_WarehouseWarrantDetailsModel entity = new Spl_WarehouseWarrantDetailsModel(); entity.Id = r.Id; entity.WareDetailsId = r.WareDetailsId; entity.WarehouseId = model.WarehouseId; entity.WarehouseWarrantId = model.Id; entity.Quantity = r.Quantity; entity.Price = r.Price; entity.TotalPrice = r.Quantity * r.Price; entity.Defined = string.IsNullOrWhiteSpace(r.Defined) ? "" : r.Defined; entity.CreateTime = ResultHelper.NowTime; detailsResultList.Add(entity); } try { m_BLL.SaveEditData(detailsResultList, model.Id); LogHandler.WriteServiceLog(GetUserId(), "保存成功", "成功", "保存", "Spl_WarehouseWarrant"); return(Json(JsonHandler.CreateMessage(1, Resource.InsertSucceed))); } catch (Exception ex) { LogHandler.WriteServiceLog(GetUserId(), ex.Message, "失败", "保存", "Spl_WarehouseWarrant"); return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ex.Message))); } } else { string ErrorCol = errors.Error; LogHandler.WriteServiceLog(GetUserId(), "Id" + model.Id + ",InTime" + model.InTime + "," + ErrorCol, "失败", "创建", "Spl_WarehouseWarrant"); return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ErrorCol))); } } } return(Json(JsonHandler.CreateMessage(0, Resource.InsertFail + ":没有明细"))); }
///修改 /// public override bool Edit(ref ValidationErrors errors, Spl_WarehouseWarrantModel model) { try { Spl_WarehouseWarrant entity = m_Rep.GetById(model.Id); if (entity.Confirmation == true) { errors.Add("单据已确认不能被修改"); return(false); }//修改于2018年2月5日 if (entity == null) { errors.Add(Resource.Disable); return(false); } entity.Id = model.Id; entity.InTime = model.InTime; entity.Handler = model.Handler; entity.Remark = model.Remark; entity.PriceTotal = model.PriceTotal; entity.State = model.State; entity.Checker = model.Checker; entity.CheckTime = model.CheckTime; entity.CreateTime = model.CreateTime; entity.CreatePerson = model.CreatePerson; entity.ModifyTime = model.ModifyTime; entity.ModifyPerson = model.ModifyPerson; entity.Confirmation = model.Confirmation; entity.InOutCategoryId = model.InOutCategoryId; entity.WarehouseId = model.WarehouseId; entity.ContractNumber = model.ContractNumber; 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 async Task <Tuple <ValidationErrors, bool> > CreateAsync(Spl_WarehouseWarrantModel model) { ValidationErrors errors = new ValidationErrors(); try { Spl_WarehouseWarrant entity = await m_Rep.GetByIdAsync(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(new Tuple <ValidationErrors, bool>(errors, false)); } entity = new Spl_WarehouseWarrant(); entity.Id = model.Id; entity.InTime = model.InTime; entity.Handler = model.Handler; entity.Remark = model.Remark; entity.PriceTotal = model.PriceTotal; entity.State = model.State; entity.Checker = model.Checker; entity.CheckTime = model.CheckTime; entity.CreateTime = model.CreateTime; entity.CreatePerson = model.CreatePerson; entity.ModifyTime = model.ModifyTime; entity.ModifyPerson = model.ModifyPerson; entity.Confirmation = model.Confirmation; entity.InOutCategoryId = model.InOutCategoryId; entity.WarehouseId = model.WarehouseId; if (await m_Rep.CreateAsync(entity)) { return(new Tuple <ValidationErrors, bool>(errors, true)); } else { errors.Add(Resource.InsertFail); return(new Tuple <ValidationErrors, bool>(errors, false)); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(new Tuple <ValidationErrors, bool>(errors, false)); } }
public ActionResult Create() { ViewBag.Warehouse = new SelectList(WarehouseBLL.GetList(ref setNoPagerAscById, "", GetUserId()), "Id", "Name"); ViewBag.InOutCategory = new SelectList(InOutCategoryBLL.GetList(ref setNoPagerAscById, "入库"), "Id", "Name"); AccountModel accountModel = GetAccount(); Spl_WarehouseWarrantModel model = new Spl_WarehouseWarrantModel() { Id = "RKD" + DateTime.Now.ToString("yyyyMMddHHmmssff"), Handler = accountModel.TrueName, HandlerName = accountModel.TrueName, }; ViewBag.Checker = new SelectList(WarehouseBLL.GetList(ref setNoPagerAscById, "", GetUserId()).GroupBy(p => new { p.Id, p.ContactPerson }).Select(g => new { Id = g.Key.Id, ContactPerson = g.Key.ContactPerson }), "Id", "ContactPerson"); return(View(model)); }
public virtual bool Create(ref ValidationErrors errors, Spl_WarehouseWarrantModel model) { try { Spl_WarehouseWarrant entity = m_Rep.GetById(model.Id); if (entity != null) { errors.Add(Resource.PrimaryRepeat); return(false); } entity = new Spl_WarehouseWarrant(); entity.Id = model.Id; entity.InTime = model.InTime; entity.Handler = model.Handler; entity.Remark = model.Remark; entity.PriceTotal = model.PriceTotal; entity.State = model.State; entity.Checker = model.Checker; entity.CheckTime = model.CheckTime; entity.CreateTime = model.CreateTime; entity.CreatePerson = model.CreatePerson; entity.ModifyTime = model.ModifyTime; entity.ModifyPerson = model.ModifyPerson; entity.Confirmation = model.Confirmation; entity.InOutCategoryId = model.InOutCategoryId; entity.WarehouseId = model.WarehouseId; entity.ContractNumber = model.ContractNumber; 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); } }
/// <summary> /// 校验Excel数据,这个方法一般用于重写校验逻辑 /// </summary> public virtual bool CheckImportData(string fileName, List <Spl_WarehouseWarrantModel> list, ref ValidationErrors errors) { var targetFile = new FileInfo(fileName); if (!targetFile.Exists) { errors.Add("导入的数据文件不存在"); return(false); } var excelFile = new ExcelQueryFactory(fileName); //对应列头 excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.InTime, "入库时间"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.Handler, "经手人"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.Remark, "说明"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.PriceTotal, "总价"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.State, "1 正常 2 审核中 3 审核完成 0作废"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.Checker, "审查人"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.CheckTime, "审查时间"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.CreateTime, "创建时间"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.CreatePerson, "制单人"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.ModifyTime, "修改时间"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.ModifyPerson, "修改人"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.Confirmation, "单据确认"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.InOutCategoryId, "出入库类别"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.WarehouseId, "所属仓库"); excelFile.AddMapping <Spl_WarehouseWarrantModel>(x => x.ContractNumber, "合同编号"); //SheetName var excelContent = excelFile.Worksheet <Spl_WarehouseWarrantModel>(0); int rowIndex = 1; //检查数据正确性 foreach (var row in excelContent) { var errorMessage = new StringBuilder(); var entity = new Spl_WarehouseWarrantModel(); entity.Id = row.Id; entity.InTime = row.InTime; entity.Handler = row.Handler; entity.Remark = row.Remark; entity.PriceTotal = row.PriceTotal; entity.State = row.State; entity.Checker = row.Checker; entity.CheckTime = row.CheckTime; entity.CreateTime = row.CreateTime; entity.CreatePerson = row.CreatePerson; entity.ModifyTime = row.ModifyTime; entity.ModifyPerson = row.ModifyPerson; entity.Confirmation = row.Confirmation; entity.InOutCategoryId = row.InOutCategoryId; entity.WarehouseId = row.WarehouseId; entity.ContractNumber = row.ContractNumber; //============================================================================= 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 ActionResult Details(string id) { Spl_WarehouseWarrantModel entity = m_BLL.GetById(id); return(View(entity)); }