/// <summary> /// Registers the patient. /// </summary> /// <param name="patient">The patient.</param> /// <returns></returns> public bool RegisterPatient(Patient patient) { return Global.DBProcess.RegisterPatient(patient); }
/// <summary> /// Registers the patient. /// </summary> /// <param name="patient">The patient.</param> /// <returns>登记结果</returns> public bool RegisterPatient(Patient patient) { string sql = string.Format(@"select patientName from patientRecord where patientId='{0}'", patient.PatientId); var temp = SqlHelper.ExecuteScalar(Global.ConnStr, CommandType.Text, sql); var paras = new SqlParameter[] { this.GetSqlParameter("@patientId",patient.PatientId), this.GetSqlParameter("@patientSN",patient.PatientSN), this.GetSqlParameter("@patientName",patient.PatientName), this.GetSqlParameter("@patientPhoneNo",patient.PatientPhoneNo), this.GetSqlParameter("@patientAddress",patient.PatientAddr), this.GetSqlParameter("@remark",patient.Remark), this.GetSqlParameter("@sex",patient.Sex), this.GetSqlParameter("@time",DateTime.Now.ToString()), this.GetSqlParameter("@positive",patient.IsPositive), this.GetSqlParameter("@age",patient.Age), this.GetSqlParameter("@endoscope",patient.Endoscope) }; try { // 插入 if (temp == null) { sql = @"insert into patientRecord (patientSn,patientName,patientPhoneNo,patientAddress,remark,endoscope,sex,time,positive,age) values(@patientSN,@patientName,@patientPhoneNo,@patientAddress,@remark,@endoscope,@sex,@time,@positive,@age)"; int result = SqlHelper.ExecuteNonQuery(Global.ConnStr, CommandType.Text, sql, paras); if (result > 0) { return true; } } else { sql = @"update patientRecord set patientName=@patientName,patientPhoneNo=@patientPhoneNo,patientAddress=@patientAddress,remark=@remark,endoscope=@endoscope,sex=@sex,time=@time,positive=@positive,age=@age where patientId=@patientId"; int result = SqlHelper.ExecuteNonQuery(Global.ConnStr, CommandType.Text, sql, paras); if (result > 0) { return true; } } } catch (Exception ex) { Global.Log("注册病人信息失败", ex); throw new Exception("注册病人信息失败"); } return false; }
/// <summary> /// Loads the patients. /// </summary> /// <returns>病人列表</returns> public List<Patient> LoadPatients() { var sql = "select * from patientRecord where examined is null"; List<Patient> patients = null; using (var reader = SqlHelper.ExecuteReader(Global.ConnStr, CommandType.Text, sql)) { if (!reader.HasRows) { return new List<Patient>(); } patients = new List<Patient>(); try { while (reader.Read()) { var patient = new Patient(); patient.PatientId = reader.SafeRead<int>("patientId").ToString(); patient.PatientSN = reader.SafeRead<string>("patientSn"); patient.PatientSex = reader.SafeRead<string>("sex"); patient.PatientName = reader.SafeRead<string>("patientName"); patient.PatientPhoneNo = reader.SafeRead<string>("patientPhoneNo"); patient.PatientAddr = reader.SafeRead<string>("patientAddress"); patient.Remark = reader.SafeRead<string>("remark"); patient.Endoscope = reader.SafeRead<string>("endoscope"); patient.Age = reader.SafeRead<string>("age"); patient.Sex = reader.SafeRead<string>("sex"); patient.IsPositive = reader.SafeRead<bool>("positive"); patients.Add(patient); } } catch (Exception ex) { Global.Log("加载病人信息失败", ex); throw new Exception("加载病人信息失败", ex); } } return patients; }
/// <summary> /// Registers the patient. /// </summary> /// <param name="patient">The patient.</param> /// <returns></returns> public bool RegisterPatient(Patient patient) { return dataObject.RegisterPatient(patient); }