private void ConfirmBtn_Click(object sender, EventArgs e) { SqlCommand checker = new SqlCommand("select *from ScheduleTable where Date = '" + Month.Text + "/" + Day.Text + "/" + Year.Text + "' and Time ='" + Hour.Text + ":" + Minute.Text + "'", connection); connection.Open(); SqlDataReader reader = checker.ExecuteReader(); if (reader.HasRows) { MessageBox.Show("Schedule slot is already occupied"); Month.SelectedItem = null; Day.SelectedItem = null; Year.SelectedItem = null; Hour.SelectedItem = null; Minute.SelectedItem = null; ConfirmBtn.Enabled = false; } else { connection.Close(); cmd = new SqlCommand("insert into ScheduleTable values('" + PatientName.Text + "','" + Month.Text + "/" + Day.Text + "/" + Year.Text + "','" + Hour.Text + ":" + Minute.Text + "','pending')", connection); connection.Open(); cmd.ExecuteNonQuery(); connection.Close(); MessageBox.Show("Schedule Added Successfully"); PatientName.Clear(); Month.SelectedItem = null; Day.SelectedItem = null; Year.SelectedItem = null; Hour.SelectedItem = null; Minute.SelectedItem = null; ConfirmBtn.Enabled = false; } }
private void ClearBtn_Click(object sender, EventArgs e) { PatientName.Clear(); Month.SelectedItem = null; Day.SelectedItem = null; Year.SelectedItem = null; Hour.SelectedItem = null; Minute.SelectedItem = null; ConfirmBtn.Enabled = false; }