/// <summary> /// 添加记录操作 /// </summary> protected void AddRecord() { HttpContext context = HttpContext.Current; HttpRequest request = context.Request; HttpResponse response = context.Response; DigitalImage digitalImage= new DigitalImage(); string addTime=request.Params["textAddTime"]; string description=request.Params["textDescription"]; string patientId=request.Params["textPatientId"]; string type=request.Params["textType"]; string updateTime=request.Params["textUpdateTime"]; string url=request.Params["textUrl"]; digitalImage.AddTime=DateTime.Now; if(!String.IsNullOrEmpty(description)) digitalImage.Description=description; digitalImage.ImageId=Guid.NewGuid().ToString("N"); if(!String.IsNullOrEmpty(patientId)) digitalImage.PatientId=patientId; if(!String.IsNullOrEmpty(type)) digitalImage.Type=type; digitalImage.UpdateTime=DateTime.Now; if(!String.IsNullOrEmpty(url)) digitalImage.Url=url; ResultModel result = DigitalImageBll.Insert(digitalImage); string jsonString = JsonConvert.SerializeObject(result); response.Write(result); }
/// <summary> /// 修改某条记录 /// </summary> /// <param name="user">要修改记录对应的实体</param> /// <returns>修改结果,包括是否修改成功、记录主键等信息</returns> public static ResultModel Update(DigitalImage digitalImage) { OperationLog log = new OperationLog(); ResultModel result = new ResultModel(); try { log.AddTime = DateTime.Now; log.IsSuccessId = SymbolicConstant.ISSUCCESS_TRUE; log.OperationLogId = System.Guid.NewGuid().ToString("N"); log.OperationContent = SymbolicConstant.OPERATIONCONTENT_UPDATE; log.OperationTable = typeof(DigitalImage).Name; log.OperationTypeCode = SymbolicConstant.OPERATIONTYPE_UPDATE; log.ResultCode = SymbolicConstant.RESULTCODE_UPDATE_SUCCESS; log.ResultMessage=SymbolicConstant.RESULTMESSAGE_UPDATE_SUCCESS; log.UserId = CurrentSession.getUser().UserId; log.ObjectRecordId = digitalImage.ImageId; DigitalImageDal.Update(digitalImage); result.IsSuccess = true; result.ObjectRecordId = digitalImage.ImageId; result.ResultCode = SymbolicConstant.RESULTCODE_UPDATE_SUCCESS; result.ResultMessage = SymbolicConstant.RESULTMESSAGE_UPDATE_SUCCESS; return result; } catch (Exception exception) { log.ResultCode = SymbolicConstant.RESULTCODE_UPDATE_ERROR; log.IsSuccessId = SymbolicConstant.ISSUCCESS_FALSE; log.ResultMessage=exception.Message; result.IsSuccess = false; result.ObjectRecordId =digitalImage.ImageId; result.ResultCode = SymbolicConstant.RESULTCODE_UPDATE_ERROR; result.ResultMessage = exception.Message; return result; } finally { OperationLogBll.Insert(log); } }
/// <summary> /// 修改某条记录 /// </summary> /// <param name="user">要修改记录对应的实体</param> /// <param name="isLog">是否写入日志</param> /// <returns>修改结果,包括是否修改成功、记录主键等信息</returns> public static ResultModel Update(DigitalImage digitalImage, bool isLog) { if (isLog) return Update(digitalImage); ResultModel result = new ResultModel(); try { DigitalImageDal.Update(digitalImage); result.IsSuccess = true; result.ObjectRecordId = digitalImage.ImageId; result.ResultCode = SymbolicConstant.RESULTCODE_UPDATE_SUCCESS; result.ResultMessage = SymbolicConstant.RESULTMESSAGE_UPDATE_SUCCESS; return result; } catch (Exception exception) { result.IsSuccess = false; result.ObjectRecordId =digitalImage.ImageId; result.ResultCode = SymbolicConstant.RESULTCODE_UPDATE_ERROR; result.ResultMessage = exception.Message; return result; } }
/// <summary> /// 添加一条新记录 /// </summary> /// <param name="digitalImage">DigitalImage实体</param> /// <param name="isLog">是否写入日志</param> /// <returns>添加结果,包括是否插入成功、记录主键等信息</returns> public static ResultModel Insert(DigitalImage digitalImage, bool isLog) { if (isLog) return Insert(digitalImage); ResultModel result = new ResultModel(); object id = ""; try { id = DigitalImageDal.Insert(digitalImage); result.IsSuccess = true; result.ObjectRecordId = id.ToString(); result.ResultCode = SymbolicConstant.RESULTCODE_INSERT_SUCCESS; result.ResultMessage = SymbolicConstant.RESULTMESSAGE_INSERT_SUCCESS; return result; } catch (Exception exception) { result.IsSuccess = false; result.ObjectRecordId = id.ToString(); result.ResultCode = SymbolicConstant.RESULTCODE_INSERT_ERROR; result.ResultMessage = exception.Message; return result; } }
/// <summary> /// 根据主键查询指定记录 /// </summary> /// <param name="digitalImageId">主键</param> /// <param name="isLog">是否写入日志</param> /// <returns>查询结果,封装了查询出的实体</returns> public static ResultModel GetDigitalImageById(string digitalImageId, bool isLog) { if (isLog) return GetDigitalImageById(digitalImageId); DigitalImage digitalImage = new DigitalImage(); ResultModel result = new ResultModel(); try { digitalImage= DigitalImageDal.GetModel(digitalImageId); result.Data = digitalImage; result.IsSuccess = true; result.ResultCode = SymbolicConstant.RESULTCODE_GETMODEL_SUCCESS; result.ResultMessage=SymbolicConstant.RESULTMESSAGE_GETMODEL_SUCCESS; return result; } catch (Exception exception) { result.IsSuccess = false; result.ResultCode = SymbolicConstant.RESULTCODE_GETMODEL_ERROR; result.ResultMessage = exception.Message; return result; } }
/// <summary> /// 修改DigitalImage表中的某条记录 /// </summary> /// <param name="user">要修改记录对应的实体</param> public static void Update(DigitalImage digitalImage) { DataAccessUtility.Update<DigitalImage>(digitalImage); }
/// <summary> /// 插入一条新记录 /// </summary> /// <param name="digitalImage">DigitalImage实体</param> /// <returns>插入记录的主键</returns> public static object Insert(DigitalImage digitalImage) { Object id = DataAccessUtility.Insert<DigitalImage>(digitalImage); return id; }
/// <summary> /// 删除DigitalImage表中的某条记录 /// </summary> /// <param name="user">要删除记录的对应的实体</param> public static void Delete(DigitalImage digitalImage) { DataAccessUtility.Delete<DigitalImage>(digitalImage); }