protected void Button1_Click(object sender, EventArgs e)
        {
            MedicalHistory mh     = new MedicalHistory(IDBox.Text, DropDownList1.SelectedValue.ToString(), descBox.Text);
            PatientDAO     dao    = new PatientDAO();
            string         result = dao.addMedicalHistory(mh);

            resultLabel.Text = result;
        }
Exemplo n.º 2
0
        public string addMedicalHistory(MedicalHistory mh)
        {
            string        result        = "Added successfully!";
            SqlConnection sqlconnection = new SqlConnection(connectstring);
            string        query         = "Insert into MedicalHistory values('@PID','@Type','@Desc');";

            try
            {
                query = query.Replace("@PID", mh.getPID())
                        .Replace("@Type", mh.getType())
                        .Replace("@Desc", mh.getDesc());
                sqlconnection.Open();
                SqlCommand sqlcommand = new SqlCommand(query, sqlconnection);
                sqlcommand.ExecuteNonQuery();
            }catch (Exception c)
            {
                result = c.Message;
            }
            finally
            {
                sqlconnection.Close();
            }
            return(result);
        }