private void Button_Click_5(object sender, RoutedEventArgs e)
        {
            try
            {
                count++;
                if (count > 1)
                {
                    conn.Close();
                    conn.Open();
                }
                else
                {
                    conn.Open();
                }

                string          sql         = "DELETE FROM user.medicine WHERE pat_contact_no='" + checkpatientContactNo.Text + "' AND appointment_date='" + checkpatientDate.Text + "' AND product_name='" + med_name + "' AND quantity='" + quantity + "' AND days='" + days + "' AND time_of_day='" + timeOfDay + "';";
                MySqlCommand    MyCommand68 = new MySqlCommand(sql, conn);
                MySqlDataReader MyReader68;
                MyReader68 = MyCommand68.ExecuteReader();
                MyReader68.Close();
                MessageBox.Show("Medicine Removed!");
                datagridMedicineList.ItemsSource = null;
                datagridMedicineList.Items.Refresh();
                btnRefreshMedList.IsEnabled = true;
                conn.Close();
            }
            catch (Exception except)
            {
                MessageBox.Show(except.Message.ToString());
            }
        }
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (check().Equals("Accepted"))
                {
                    Query1 = "DROP TABLE user.appointment_medicine;";
                    Query2 = "CREATE TABLE user.appointment_medicine AS SELECT appointment.pat_name,appointment.pat_contact_no,appointment.appointment_date,appointment.pat_age,medicine.disease,medicine.product_name,medicine.quantity,medicine.days,medicine.time_of_day FROM appointment,medicine WHERE user.appointment.pat_contact_no=user.medicine.pat_contact_no AND user.appointment.appointment_date=user.medicine.appointment_date;";
                    Query9 = "DROP TABLE user.appointment_test;";
                    Query8 = "CREATE TABLE user.appointment_test AS SELECT appointment.pat_name,appointment.pat_contact_no,appointment.appointment_date,appointment.pat_age,test.test_name FROM appointment,test WHERE user.appointment.pat_contact_no=user.test.pat_contact_no AND user.appointment.appointment_date=user.test.appointment_date;";
                    Query3 = "update user.appointment set appointment_status='" + "Checked" + "' where pat_contact_no='" + checkpatientContactNo.Text.ToString() + "' and appointment_date='" + checkpatientDate.Text.ToString() + "';";
                    i      = 1;
                }

                if (check().Equals("Admitted"))
                {
                    Query1 = "DROP TABLE user.admitted_medicine;";
                    Query2 = "CREATE TABLE user.admitted_medicine AS SELECT admitted_patient.patient_name,admitted_patient.patient_contact_no,admitted_patient.time_of_admission,admitted_patient.patient_age,medicine.disease,medicine.product_name,medicine.quantity,medicine.days,medicine.time_of_day FROM admitted_patient,medicine WHERE user.admitted_patient.patient_contact_no=user.medicine.pat_contact_no AND user.admitted_patient.time_of_admission=user.medicine.appointment_date;";
                    Query9 = "DROP TABLE user.admitted_test;";
                    Query8 = "CREATE TABLE user.admitted_test AS SELECT admitted_patient.patient_name,admitted_patient.patient_contact_no,admitted_patient.time_of_admission,admitted_patient.patient_age,test.test_name FROM admitted_patient,test WHERE user.admitted_patient.patient_contact_no=user.test.pat_contact_no AND user.admitted_patient.time_of_admission=user.test.appointment_date;";
                    Query3 = "update user.admitted_patient set checked_status='" + "Checked" + "' where patient_contact_no='" + checkpatientContactNo.Text + "' and time_of_admission='" + checkpatientDate.Text + "';";
                    i      = 0;
                }

                conn.Open();

                MySqlCommand    MyCommand1 = new MySqlCommand(Query1, conn);
                MySqlDataReader MyReader1;
                MyReader1 = MyCommand1.ExecuteReader();
                MyReader1.Close();

                MySqlCommand    MyCommand2 = new MySqlCommand(Query2, conn);
                MySqlDataReader MyReader2;
                MyReader2 = MyCommand2.ExecuteReader();
                MyReader2.Close();

                MySqlCommand    MyCommand9 = new MySqlCommand(Query9, conn);
                MySqlDataReader MyReader9;
                MyReader9 = MyCommand9.ExecuteReader();
                MyReader9.Close();

                MySqlCommand    MyCommand8 = new MySqlCommand(Query8, conn);
                MySqlDataReader MyReader8;
                MyReader8 = MyCommand8.ExecuteReader();
                MyReader8.Close();

                MySqlCommand    MyCommand3 = new MySqlCommand(Query3, conn);
                MySqlDataReader MyReader3;
                MyReader3 = MyCommand3.ExecuteReader();
                MyReader3.Close();

                if (i == 0)
                {
                    string Query67 = "DROP TABLE user.admitted_medicine_cost;";
                    string Query68 = "CREATE TABLE admitted_medicine_cost AS SELECT admitted_medicine.patient_name,admitted_medicine.patient_contact_no,admitted_medicine.time_of_admission, admitted_medicine.patient_age, admitted_medicine.disease,admitted_medicine.product_name,admitted_medicine.quantity, admitted_medicine.days,admitted_medicine.time_of_day,supplier.selling_price FROM admitted_medicine,supplier WHERE admitted_medicine.product_name = supplier.product_name;";
                    string Query69 = "DROP TABLE admitted_test_cost;";
                    string Query70 = "CREATE TABLE admitted_test_cost AS SELECT admitted_test.patient_name,admitted_test.patient_contact_no,admitted_test.time_of_admission,admitted_test.patient_age,admitted_test.test_name,test_name.test_cost FROM admitted_test,test_name WHERE admitted_test.test_name=test_name.test_Name;";

                    MySqlCommand    MyCommand67 = new MySqlCommand(Query67, conn);
                    MySqlDataReader MyReader67;
                    MyReader67 = MyCommand67.ExecuteReader();
                    MyReader67.Close();

                    MySqlCommand    MyCommand68 = new MySqlCommand(Query68, conn);
                    MySqlDataReader MyReader68;
                    MyReader68 = MyCommand68.ExecuteReader();
                    MyReader68.Close();

                    MySqlCommand    MyCommand69 = new MySqlCommand(Query69, conn);
                    MySqlDataReader MyReader69;
                    MyReader69 = MyCommand69.ExecuteReader();
                    MyReader69.Close();

                    MySqlCommand    MyCommand70 = new MySqlCommand(Query70, conn);
                    MySqlDataReader MyReader70;
                    MyReader70 = MyCommand70.ExecuteReader();
                    MyReader70.Close();
                }

                MessageBox.Show("Patient checked Succesfully . . .");

                this.checkpatientAge.Text       = "";
                this.checkpatientContactNo.Text = "";
                this.checkpatientDate.Text      = "";
                this.comboboxDiseaseType.Text   = "";
                this.checkpatientName.Text      = "";

                datagridMedicineList.ItemsSource = null;
                datagridMedicineList.Items.Refresh();
                datagridTest.ItemsSource = null;
                datagridTest.Items.Refresh();

                this.Visibility = Visibility.Hidden;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }