/// <summary> /// Adds a new record into the <c>PatientVisitInfo</c> table. /// </summary> /// <param name="value">The <see cref="PatientVisitInfoRow"/> object to be inserted.</param> public virtual void Insert(PatientVisitInfoRow value) { SqlCommand cmd = _db.CreateCommand("dbo._PatientVisitInfo_Insert", true); AddParameter(cmd, "PatientType", value.IsPatientTypeNull ? DBNull.Value : (object)value.PatientType); AddParameter(cmd, "DoctorId", value.IsDoctorIdNull ? DBNull.Value : (object)value.DoctorId); AddParameter(cmd, "BedId", value.IsBedIdNull ? DBNull.Value : (object)value.BedId); AddParameter(cmd, "DateofVisit", value.IsDateofVisitNull ? DBNull.Value : (object)value.DateofVisit); AddParameter(cmd, "DateofDischarge", value.IsDateofDischargeNull ? DBNull.Value : (object)value.DateofDischarge); AddParameter(cmd, "Symptoms", value.Symptoms); AddParameter(cmd, "Disease", value.Disease); AddParameter(cmd, "Treatment", value.Treatment); value.Id = Convert.ToInt32(cmd.ExecuteScalar()); }
/// <summary> /// Updates a record in the <c>PatientVisitInfo</c> table. /// </summary> /// <param name="value">The <see cref="PatientVisitInfoRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(PatientVisitInfoRow value) { SqlCommand cmd = _db.CreateCommand("dbo._PatientVisitInfo_Update", true); AddParameter(cmd, "PatientType", value.IsPatientTypeNull ? DBNull.Value : (object)value.PatientType); AddParameter(cmd, "DoctorId", value.IsDoctorIdNull ? DBNull.Value : (object)value.DoctorId); AddParameter(cmd, "BedId", value.IsBedIdNull ? DBNull.Value : (object)value.BedId); AddParameter(cmd, "DateofVisit", value.IsDateofVisitNull ? DBNull.Value : (object)value.DateofVisit); AddParameter(cmd, "DateofDischarge", value.IsDateofDischargeNull ? DBNull.Value : (object)value.DateofDischarge); AddParameter(cmd, "Symptoms", value.Symptoms); AddParameter(cmd, "Disease", value.Disease); AddParameter(cmd, "Treatment", value.Treatment); AddParameter(cmd, "Id", value.Id); return(0 != cmd.ExecuteNonQuery()); }
/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="PatientVisitInfoRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="PatientVisitInfoRow"/> object.</returns> protected virtual PatientVisitInfoRow MapRow(DataRow row) { PatientVisitInfoRow mappedObject = new PatientVisitInfoRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Id" dataColumn = dataTable.Columns["Id"]; if (!row.IsNull(dataColumn)) { mappedObject.Id = (int)row[dataColumn]; } // Column "PatientType" dataColumn = dataTable.Columns["PatientType"]; if (!row.IsNull(dataColumn)) { mappedObject.PatientType = (int)row[dataColumn]; } // Column "DoctorId" dataColumn = dataTable.Columns["DoctorId"]; if (!row.IsNull(dataColumn)) { mappedObject.DoctorId = (int)row[dataColumn]; } // Column "BedId" dataColumn = dataTable.Columns["BedId"]; if (!row.IsNull(dataColumn)) { mappedObject.BedId = (int)row[dataColumn]; } // Column "DateofVisit" dataColumn = dataTable.Columns["DateofVisit"]; if (!row.IsNull(dataColumn)) { mappedObject.DateofVisit = (System.DateTime)row[dataColumn]; } // Column "DateofDischarge" dataColumn = dataTable.Columns["DateofDischarge"]; if (!row.IsNull(dataColumn)) { mappedObject.DateofDischarge = (System.DateTime)row[dataColumn]; } // Column "Symptoms" dataColumn = dataTable.Columns["Symptoms"]; if (!row.IsNull(dataColumn)) { mappedObject.Symptoms = (string)row[dataColumn]; } // Column "Disease" dataColumn = dataTable.Columns["Disease"]; if (!row.IsNull(dataColumn)) { mappedObject.Disease = (string)row[dataColumn]; } // Column "Treatment" dataColumn = dataTable.Columns["Treatment"]; if (!row.IsNull(dataColumn)) { mappedObject.Treatment = (string)row[dataColumn]; } return(mappedObject); }
/// <summary> /// Reads data from the provided data reader and returns /// an array of mapped objects. /// </summary> /// <param name="reader">The <see cref="System.Data.SqlDataReader"/> object to read data from the table.</param> /// <param name="startIndex">The index of the first record to map.</param> /// <param name="length">The number of records to map.</param> /// <param name="totalRecordCount">A reference parameter that returns the total number /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param> /// <returns>An array of <see cref="PatientVisitInfoRow"/> objects.</returns> protected virtual PatientVisitInfoRow[] MapRecords(SqlDataReader reader, int startIndex, int length, ref int totalRecordCount) { if (0 > startIndex) { throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero."); } if (0 > length) { throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero."); } int idColumnIndex = reader.GetOrdinal("Id"); int patientTypeColumnIndex = reader.GetOrdinal("PatientType"); int doctorIdColumnIndex = reader.GetOrdinal("DoctorId"); int bedIdColumnIndex = reader.GetOrdinal("BedId"); int dateofVisitColumnIndex = reader.GetOrdinal("DateofVisit"); int dateofDischargeColumnIndex = reader.GetOrdinal("DateofDischarge"); int symptomsColumnIndex = reader.GetOrdinal("Symptoms"); int diseaseColumnIndex = reader.GetOrdinal("Disease"); int treatmentColumnIndex = reader.GetOrdinal("Treatment"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { PatientVisitInfoRow record = new PatientVisitInfoRow(); recordList.Add(record); record.Id = Convert.ToInt32(reader.GetValue(idColumnIndex)); if (!reader.IsDBNull(patientTypeColumnIndex)) { record.PatientType = Convert.ToInt32(reader.GetValue(patientTypeColumnIndex)); } if (!reader.IsDBNull(doctorIdColumnIndex)) { record.DoctorId = Convert.ToInt32(reader.GetValue(doctorIdColumnIndex)); } if (!reader.IsDBNull(bedIdColumnIndex)) { record.BedId = Convert.ToInt32(reader.GetValue(bedIdColumnIndex)); } if (!reader.IsDBNull(dateofVisitColumnIndex)) { record.DateofVisit = Convert.ToDateTime(reader.GetValue(dateofVisitColumnIndex)); } if (!reader.IsDBNull(dateofDischargeColumnIndex)) { record.DateofDischarge = Convert.ToDateTime(reader.GetValue(dateofDischargeColumnIndex)); } if (!reader.IsDBNull(symptomsColumnIndex)) { record.Symptoms = Convert.ToString(reader.GetValue(symptomsColumnIndex)); } if (!reader.IsDBNull(diseaseColumnIndex)) { record.Disease = Convert.ToString(reader.GetValue(diseaseColumnIndex)); } if (!reader.IsDBNull(treatmentColumnIndex)) { record.Treatment = Convert.ToString(reader.GetValue(treatmentColumnIndex)); } if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((PatientVisitInfoRow[])(recordList.ToArray(typeof(PatientVisitInfoRow)))); }
/// <summary> /// Deletes the specified object from the <c>PatientVisitInfo</c> table. /// </summary> /// <param name="value">The <see cref="PatientVisitInfoRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(PatientVisitInfoRow value) { return(DeleteByPrimaryKey(value.Id)); }