public List<Disease> DiseaseList() { List<Disease> DiseaseList = new List<Disease>(); aGateway.command.CommandText = "SELECT * FROM Disease_tbl"; aGateway.sqlConnection.Open(); SqlDataReader reader = aGateway.command.ExecuteReader(); while (reader.Read()) { Disease newDisease = new Disease(); newDisease.Name = reader[1].ToString(); newDisease.Description = reader[2].ToString(); newDisease.Treatment = reader[3].ToString(); DiseaseList.Add(newDisease); } reader.Close(); aGateway.sqlConnection.Close(); return DiseaseList; }
public int SaveDisease(Disease aDisease) { return aHeadOfficeGateway.SaveDisease(aDisease); }
public int SaveDisease(Disease aDisease) { string query = "insert into Disease_tbl(Name,Description,Treatment) values('" + aDisease.Name + "','" + aDisease.Description + "','" + aDisease.Treatment + "')"; aGateway.sqlConnection.Open(); aGateway.command.CommandText = query; int rowAffected = aGateway.command.ExecuteNonQuery(); aGateway.sqlConnection.Close(); return rowAffected; }
public List<Disease> GetAllDiseases() { aGateway.command.CommandText = "SELECT * FROM Disease_tbl"; aGateway.sqlConnection.Open(); SqlDataReader reader = aGateway.command.ExecuteReader(); List<Disease> diseasesList = new List<Disease>(); if (reader != null) while (reader.Read()) { Disease aDisease=new Disease(); aDisease.ID = Convert.ToInt16(reader["ID"].ToString()); aDisease.Name = reader["Name"].ToString(); diseasesList.Add(aDisease); } reader.Close(); aGateway.sqlConnection.Close(); return diseasesList; }