public virtual Spl_WarehouseWarrantOUTModel GetById(object id) { if (IsExists(id)) { Spl_WarehouseWarrantOUT entity = m_Rep.GetById(id); Spl_WarehouseWarrantOUTModel model = new Spl_WarehouseWarrantOUTModel(); model.Id = entity.Id; model.OutTime = entity.OutTime; 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 virtual bool Edit(ref ValidationErrors errors, Spl_WarehouseWarrantOUTModel model) { try { Spl_WarehouseWarrantOUT entity = m_Rep.GetById(model.Id); if (entity == null) { errors.Add(Resource.Disable); return(false); } entity.Id = model.Id; entity.OutTime = model.OutTime; 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); } }
/// <summary> /// 审核 /// </summary> /// <param name="errors">持久的错误信息</param> /// <param name="id">主键</param> /// <param name="checkFlag">1审核0反审核</param> /// <param name="checker">审核人</param> /// <returns>是否成功</returns> public bool Check(ref ValidationErrors errors, string id, int checkFlag, string checker) { try { Spl_WarehouseWarrantOUT entity = m_Rep.GetById(id); if (entity.State == 1) { errors.Add("单据已经审核"); return(false); } if (entity.Confirmation == false) { errors.Add("单据未经确认不能审核"); return(false); } if (entity == null) { errors.Add(Resource.Disable); return(false); } entity.State = checkFlag; entity.Checker = checker; entity.CheckTime = DateTime.Now; if (m_Rep.Edit(entity)) { //更新库存表 m_Rep.UpdateWareStockPileOut(entity.Id); return(true); } else { errors.Add(Resource.CheckFail); return(false); } } catch (Exception ex) { errors.Add(ex.Message); ExceptionHander.WriteException(ex); return(false); } }
/// <summary> /// 保存数据 /// </summary> public virtual void SaveImportData(IEnumerable <Spl_WarehouseWarrantOUTModel> list) { try { using (DBContainer db = new DBContainer()) { foreach (var model in list) { Spl_WarehouseWarrantOUT entity = new Spl_WarehouseWarrantOUT(); entity.Id = ResultHelper.NewId; entity.OutTime = model.OutTime; 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 = ResultHelper.NowTime; 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; db.Spl_WarehouseWarrantOUT.Add(entity); } db.SaveChanges(); } } catch (Exception ex) { throw; } }