/// <summary> /// 修改条例 /// </summary> /// <param name="entity"></param> /// <param name="fileInfo"></param> /// <returns></returns> public bool UpdatePlanRegulation(ServPlanRegulationModel entity, List <ServFileInfoModel> fileInfo) { try { bool result = servPlanRegulationDAL.UpdatePlanRegulation(entity, fileInfo); return(result); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取预案条例信息 /// </summary> /// <param name="regId"></param> /// <returns></returns> public PlanRegulationModel GetPlanRegulations(int regId) { try { //获取预案条例信息 ServPlanRegulationModel entity = servPlanRegulationDAL.GetEntity(regId); //获取关联文件 List <ServRegulationFileModel> RegulationFile = servRegulationFileDAL.GetRegulationFile(regId); //获取文件信息 List <ServFileInfoModel> FileInfoList = new List <ServFileInfoModel>(); for (var i = 0; i < RegulationFile.Count; i++) { ServFileInfoModel fileInfo = servFileInfoDAL.GetEntity(RegulationFile[i].file_id); FileInfoList.Add(fileInfo); } //获取文件信息 PlanRegulationModel model = new PlanRegulationModel(); model.id = entity.id; model.keyword = entity.keyword; model.person_id = entity.person_id; model.reg_level = entity.reg_level; model.reg_name = entity.reg_name; model.reg_type = entity.reg_type; var a = baseEventTypeDAL.GetEntity(entity.reg_type); model.reg_typeName = a == null ? "未知" : a.event_name; model.reg_levelName = Enum.GetName(typeof(EnumClass.PlanRegulation), entity.reg_level); model.create_time = entity.create_time; model.update_time = entity.update_time; model.FileInfoList = FileInfoList; return(model); } catch (Exception ex) { throw ex; } }
/// <summary> /// 修改预案条例信息 /// </summary> /// <param name="ServPlanRegulationModel"></param> /// <returns></returns> public bool UpdateDevicePlan(ServPlanRegulationModel ServPlanRegulationModel) { bool result = servPlanRegulationDAL.UpdateEntity(ServPlanRegulationModel.id, ServPlanRegulationModel); return(result); }
/// <summary> /// 新增预案条例信息 2016.12.02 乔会会 /// </summary> /// <param name="configModel"></param> /// <returns></returns> public int AddDevicePlan(ServPlanRegulationModel configModel) { int id = servPlanRegulationDAL.AddEntity(configModel); return(id); }
/// <summary> /// 更新一条数据 /// </summary> /// <param name="model"></param> public int UpdatePlanRegulationById(ServPlanRegulationModel model) { int result = mapContext.Update("UpdatePlanRegulationById", model); return(result); }
/// <summary> /// 修改预案条例 /// </summary> /// <param name="entity"></param> /// <param name="fileInfo"></param> /// <returns></returns> public bool UpdatePlanRegulation(ServPlanRegulationModel entity, List <ServFileInfoModel> fileInfo) { mapContext.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);//创建事务 try { bool result = false; //向预案条例信息表中添加信息 int regId = (int)mapContext.Update("UpdatePlanRegulationById", entity); if (regId > 0) { List <ServRegulationFileModel> servRegulationFileInfo = mapContext.QueryForList <ServRegulationFileModel>("GetRegulationFileByRegId", entity.id).ToList(); for (var i = 0; i < servRegulationFileInfo.Count(); i++) { int fileId = (int)mapContext.Delete("DeleteFileInfoById", servRegulationFileInfo[i].file_id); if (fileId > -1) { result = true; } else { mapContext.RollBackTransaction(); result = false; break; } } if (result == true) { int Id = (int)mapContext.Delete("DeletePlanRegulationFileById", entity.id); if (Id > -1) { //向文件表中添加数据 for (var i = 0; i < fileInfo.Count(); i++) { int fileId = (int)mapContext.Insert("InsertFileInfo", fileInfo[i]); if (fileId > 0) { //向关联表中添加信息 ServRegulationFileModel RegulationFile = new ServRegulationFileModel(); RegulationFile.reg_id = entity.id; RegulationFile.file_id = fileId; int relationId = (int)mapContext.Insert("InsertRegulationFile", RegulationFile); if (relationId > 0) { result = true; } else { result = false; break; } } else { result = false; } } } else { mapContext.RollBackTransaction(); result = false; } } } else { mapContext.RollBackTransaction(); result = false; } if (result == true) { mapContext.CommitTransaction();//提交事务 return(result); } else { mapContext.RollBackTransaction();//事务回滚 return(result); } } catch (Exception ex) { mapContext.RollBackTransaction(); throw ex; } finally { //mapContext.CommitTransaction(); } }
/// <summary> /// 添加预案条例 /// </summary> /// <param name="entity"></param> /// <param name="fileInfo"></param> /// <returns></returns> public bool AddPlanRegulation(ServPlanRegulationModel entity, List <ServFileInfoModel> fileInfo) { mapContext.BeginTransaction(System.Data.IsolationLevel.ReadUncommitted);//创建事务 try { bool result = false; //向预案条例信息表中添加信息 int regId = (int)mapContext.Insert("InsertPlanRegulation", entity); if (regId > 0) { //向文件表中添加数据 for (var i = 0; i < fileInfo.Count(); i++) { int fileId = (int)mapContext.Insert("InsertFileInfo", fileInfo[i]); if (fileId > 0) { //向关联表中添加信息 ServRegulationFileModel RegulationFile = new ServRegulationFileModel(); RegulationFile.reg_id = regId; RegulationFile.file_id = fileId; int relationId = (int)mapContext.Insert("InsertRegulationFile", RegulationFile); if (relationId > 0) { result = true; } else { result = false; } } else { result = false; } } } else { mapContext.RollBackTransaction(); result = false; } if (result == true) { mapContext.CommitTransaction();//提交事务 return(result); } else { mapContext.RollBackTransaction();//事务回滚 return(result); } } catch (Exception ex) { mapContext.RollBackTransaction(); throw ex; } finally { //mapContext.CommitTransaction(); } }
/// <summary> /// 增加一条数据 /// </summary> /// <param name="entity"></param> public int AddEntity(ServPlanRegulationModel entity) { int id = (int)mapContext.Insert("InsertPlanRegulation", entity); return(id); }
public bool UpdateEntity(int id, ServPlanRegulationModel newentity) { throw new NotImplementedException(); }