public int Update(SubXRayReport subXRayReport) { UpdateCommand.Parameters["@ID"].Value = subXRayReport.ID; UpdateCommand.Parameters["@PatientID"].Value = subXRayReport.PatientID; UpdateCommand.Parameters["@PatientName"].Value = subXRayReport.PatientName; UpdateCommand.Parameters["@DOB"].Value = subXRayReport.DOB; UpdateCommand.Parameters["@Sex"].Value = subXRayReport.Sex; UpdateCommand.Parameters["@ImagePath"].Value = subXRayReport.ImagePath; UpdateCommand.Parameters["@SubXRayReportDate"].Value = subXRayReport.SubXRayReportDate; UpdateCommand.Parameters["@Report"].Value = subXRayReport.Report; UpdateCommand.Parameters["@ConsultantRadiologist"].Value = subXRayReport.ConsultantRadiologist; UpdateCommand.Parameters["@Status"].Value = subXRayReport.Status; int returnValue = -1; try { UpdateCommand.Connection.Open(); returnValue = UpdateCommand.ExecuteNonQuery(); } catch (SqlException ex) { Logger.Write(ex); } finally { UpdateCommand.Connection.Close(); } return(returnValue); }
public int Insert(SubXRayReport subXRayReport) { InsertCommand.Parameters["@PatientID"].Value = subXRayReport.PatientID; InsertCommand.Parameters["@PatientName"].Value = subXRayReport.PatientName; InsertCommand.Parameters["@DOB"].Value = subXRayReport.DOB; InsertCommand.Parameters["@Sex"].Value = subXRayReport.Sex; InsertCommand.Parameters["@ImagePath"].Value = subXRayReport.ImagePath; InsertCommand.Parameters["@SubXRayReportDate"].Value = subXRayReport.SubXRayReportDate; InsertCommand.Parameters["@Report"].Value = subXRayReport.Report; InsertCommand.Parameters["@ConsultantRadiologist"].Value = subXRayReport.ConsultantRadiologist; InsertCommand.Parameters["@Status"].Value = subXRayReport.Status; int returnValue = -1; try { InsertCommand.Connection.Open(); returnValue = (int)InsertCommand.ExecuteScalar(); } catch (SqlException ex) { Logger.Write(ex); } finally { InsertCommand.Connection.Close(); } return(returnValue); }
private SubXRayReport DataTableToEntity(DataTable dt) { SubXRayReport subXRayReport = new SubXRayReport(); if (Null.IsNotNull(dt) == true && dt.Rows.Count > 0) { if (Null.IsNotNull(dt.Rows[0])) { DataRow dr = dt.Rows[0]; if (Null.IsNotNull(dr["ID"])) { subXRayReport.ID = Convert.ToInt32(dr["ID"]); } else { subXRayReport.ID = 0; } if (Null.IsNotNull(dr["PatientID"])) { subXRayReport.PatientID = Convert.ToInt32(dr["PatientID"]); } else { subXRayReport.PatientID = 0; } if (Null.IsNotNull(dr["PatientName"])) { subXRayReport.PatientName = Convert.ToString(dr["PatientName"]); } else { subXRayReport.PatientName = string.Empty; } if (Null.IsNotNull(dr["DOB"])) { subXRayReport.DOB = Convert.ToDateTime(dr["DOB"]); } else { subXRayReport.DOB = DateTime.Now; } if (Null.IsNotNull(dr["Sex"])) { subXRayReport.Sex = Convert.ToString(dr["Sex"]); } else { subXRayReport.Sex = string.Empty; } if (Null.IsNotNull(dr["ImagePath"])) { subXRayReport.ImagePath = Convert.ToString(dr["ImagePath"]); } else { subXRayReport.ImagePath = string.Empty; } if (Null.IsNotNull(dr["SubXRayReportDate"])) { subXRayReport.SubXRayReportDate = Convert.ToDateTime(dr["SubXRayReportDate"]); } else { subXRayReport.SubXRayReportDate = DateTime.Now; } if (Null.IsNotNull(dr["Report"])) { subXRayReport.Report = Convert.ToString(dr["Report"]); } else { subXRayReport.Report = string.Empty; } if (Null.IsNotNull(dr["ConsultantRadiologist"])) { subXRayReport.ConsultantRadiologist = Convert.ToString(dr["ConsultantRadiologist"]); } else { subXRayReport.ConsultantRadiologist = string.Empty; } if (Null.IsNotNull(dr["Status"])) { subXRayReport.Status = Convert.ToString(dr["Status"]); } else { subXRayReport.Status = string.Empty; } } } return(subXRayReport); }