public List<Disease> GetAllDiseases()
        {
            List<Disease> diseaseList = new List<Disease>();
            string query = "SELECT * FROM tbl_disease";
            ASqlCommand = new SqlCommand(query, ASqlConnection);
            ASqlConnection.Open();
            ASqlDataReader = ASqlCommand.ExecuteReader();
            Disease aDisease;

            while (ASqlDataReader.Read())
            {
                aDisease = new Disease();
                aDisease.Id = (int)ASqlDataReader["id"];
                aDisease.Name = ASqlDataReader["name"].ToString();
                aDisease.Description = ASqlDataReader["description"].ToString();
                aDisease.TreatmentProcedure = ASqlDataReader["treatment_procedure"].ToString();
                aDisease.PreferredDrug = ASqlDataReader["preferred_drug"].ToString();

                diseaseList.Add(aDisease);
            }

            ASqlDataReader.Close();
            ASqlCommand.Dispose();
            ASqlConnection.Close();
            return diseaseList;
        }
 public int Save(Disease aDisease)
 {
     string query = "INSERT INTO tbl_disease VALUES ('" + aDisease.Name + "','" + aDisease.Description + "','" +
                    aDisease.TreatmentProcedure + "','" + aDisease.PreferredDrug + "')";
     ASqlConnection.Open();
     ASqlCommand = new SqlCommand(query, ASqlConnection);
     int rowAffected = ASqlCommand.ExecuteNonQuery();
     ASqlConnection.Close();
     return rowAffected;
 }
 public int Save(Disease aDisease)
 {
     if (aDiseaseDbGateway.Find(aDisease.Name) == null)
     {
         return aDiseaseDbGateway.Save(aDisease);
     }
     else
     {
         return 0;
     }
 }
 protected void saveButton_Click(object sender, EventArgs e)
 {
     Disease aDisease = new Disease();
     aDisease.Name = nameTextBox.Text;
     aDisease.Description = descriptionTextBox.Text;
     aDisease.TreatmentProcedure = treatementProcedureTextBox.Text;
     aDisease.PreferredDrug = preferredDrugTextBox.Text;
     int rowAffected = aDiseaseManager.Save(aDisease);
     if (rowAffected > 0)
     {
         msgLabel.Text = "Disease Saved...";
     }
     else
     {
         msgLabel.Text = "Error in saving or duplicate name of disease...";
     }
 }
 public Disease Find(string name)
 {
     string query = "SELECT * FROM tbl_disease WHERE name= '" + name + "' ";
     ASqlConnection.Open();
     ASqlCommand = new SqlCommand(query, ASqlConnection);
     ASqlDataReader = ASqlCommand.ExecuteReader();
     if (ASqlDataReader.HasRows)
     {
         ASqlDataReader.Read();
         Disease aDisease = new Disease();
         aDisease.Id = (int)ASqlDataReader["id"];
         aDisease.Name = ASqlDataReader["name"].ToString();
         ASqlDataReader.Close();
         ASqlConnection.Close();
         return aDisease;
     }
     else
     {
         ASqlDataReader.Close();
         ASqlConnection.Close();
         return null;
     }
 }