private void appointment_Click(object sender, EventArgs e) { appointment pat = new appointment(); this.Hide(); pat.Show(); }
private void button1_Click(object sender, EventArgs e) { appointment appt = new appointment(); this.Hide(); appt.Show(); }
private void button2_Click(object sender, EventArgs e) { try { string sql = "INSERT INTO appointment (name,phone,gender,visit_date) values (@name,@phone,@gender,@visit_date)"; using (SqlConnection sqlcon = new SqlConnection("Data Source=.;Initial Catalog=sem2;User ID=sa;Password=sap")) { sqlcon.Open(); using (SqlCommand cmd = new SqlCommand(sql, sqlcon)) { cmd.Parameters.AddWithValue("@name", name.Text.Trim()); cmd.Parameters.AddWithValue("@phone", phone.Text.Trim()); cmd.Parameters.AddWithValue("@visit_date", visit_date.Value); string gender_value = ""; bool isChecked = radioButton1.Checked; if (isChecked) { gender_value = radioButton1.Text; } else { gender_value = radioButton2.Text; } cmd.Parameters.AddWithValue("@gender", gender_value); cmd.ExecuteNonQuery(); MessageBox.Show("You have successfully added the patient appointment to the database"); appointment appt = new appointment(); this.Hide(); appt.Show(); } } } catch (SqlException ex) { string msg = "Insert Error:"; msg += ex.Message; } }