private void button1_Click(object sender, RoutedEventArgs e) { try { MySqlConnection con = DBConnect.connectToDb(); string q1 = "delete from appointment where pat_contact_no='" + contact_no + "' and appointment_date='" + textField + "';"; MySqlCommand MyCommand5 = new MySqlCommand(q1, con); MySqlDataReader MyReader5; MyReader5 = MyCommand5.ExecuteReader(); MessageBox.Show("Appointment Rejected"); MyReader5.Close(); delete_request(); //Remove that patient because appointment is rejected show_all(); /// Refreshing Request Table /// con.Close(); } catch (Exception ee) { MessageBox.Show(ee.Message.ToString()); } }
private void btnReleasePatient_Click(object sender, RoutedEventArgs e) { try { string Query = "insert into release_patient values('" + txtPatientName.Text + "','" + txtPatientAge.Text + "','" + txtContactNo.Text + "','" + txtPatientAddress.Text + "','" + txtDisease.Text + "','" + txtDocName.Text + "','" + txtDateOfAdmit.Text + "','" + txtDateOfRelease.Text + "','" + txtDays.Text + "','" + txtMedicineCost.Text + "','" + txtTestCost.Text + "', '" + txtBedCost.Text + "', '" + txtTotalCost.Text + "');"; MySqlCommand MyCommand = new MySqlCommand(Query, conn); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); MyReader.Close(); MessageBox.Show("Patient Released!"); string Query1 = "update admitted_patient set checked_status='" + "Released" + "' where patient_contact_no='" + txtContactNo.Text + "';"; MySqlCommand MyCommand1 = new MySqlCommand(Query1, conn); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); MyReader1.Close(); //These 3 block codes are responsible for free-ing the bed. string Query2 = "update bed set pat_contact_no='" + "" + "', bed_status='" + "Free" + "' where pat_contact_no='" + txtContactNo.Text + "';"; MySqlCommand MyCommand2 = new MySqlCommand(Query2, conn); MySqlDataReader MyReader2; MyReader2 = MyCommand2.ExecuteReader(); MyReader2.Close(); //SELECT ward.ward_name,bed.pat_contact_no, bed.bed_no,bed.bed_type ,bed.bed_cost, bed.bed_status FROM ward,bed WHERE ward.ward_id = bed.ward_id string Query3 = "DROP TABLE ward_bed;"; MySqlCommand MyCommand3 = new MySqlCommand(Query3, conn); MySqlDataReader MyReader3; MyReader3 = MyCommand3.ExecuteReader(); MyReader3.Close(); string Query4 = "CREATE TABLE ward_bed AS SELECT ward.ward_name,bed.pat_contact_no, bed.bed_no,bed.bed_type ,bed.bed_cost, bed.bed_status FROM ward,bed WHERE ward.ward_id = bed.ward_id;"; MySqlCommand MyCommand4 = new MySqlCommand(Query4, conn); MySqlDataReader MyReader4; MyReader4 = MyCommand4.ExecuteReader(); MyReader4.Close(); string Query5 = "DROP TABLE user.allocate_patient_bed;"; MySqlCommand MyCommand5 = new MySqlCommand(Query5, conn); MySqlDataReader MyReader5; MyReader5 = MyCommand5.ExecuteReader(); MyReader5.Close(); string Query6 = "CREATE TABLE allocate_patient_bed AS SELECT admitted_patient.patient_name,admitted_patient.patient_age,admitted_patient.patient_contact_no,ward_bed.ward_name,ward_bed.bed_no,ward_bed.bed_type,ward_bed.bed_cost,ward_bed.bed_status FROM admitted_patient,ward_bed WHERE admitted_patient.patient_contact_no=ward_bed.pat_contact_no AND admitted_patient.ward_name=ward_bed.ward_name;"; MySqlCommand MyCommand6 = new MySqlCommand(Query6, conn); MySqlDataReader MyReader6; MyReader6 = MyCommand6.ExecuteReader(); MyReader6.Close(); txtContactNo.Text = ""; txtPatientAge.Text = ""; txtPatientAddress.Text = ""; txtDateOfRelease.Text = ""; txtPatientName.Text = ""; txtDisease.Text = ""; txtDocName.Text = ""; txtDateOfAdmit.Text = ""; txtMedicineCost.Text = ""; txtBedCost.Text = ""; txtTestCost.Text = ""; txtTotalCost.Text = ""; txtDays.Text = ""; btnReleasePatient.IsEnabled = false; /*string Query5 = "select quantity,days from user.admitted_medicine where product_name='" + comboboxMedicineName.SelectedItem + "';"; * MySqlCommand MyCommand5 = new MySqlCommand(Query5, conn); * MySqlDataReader MyReader5; * MyReader5 = MyCommand5.ExecuteReader(); * while (MyReader5.Read()) * { * string medquantyty = MyReader5.GetString(0); * x = Int32.Parse(medquantyty); * string c = this.quantity.Text; * y = Int32.Parse(c); * * x = x - y; * } * MyReader5.Close(); * * string Query6 = "update user.supplier set quantity='" + x.ToString() + "' where product_name='" + comboboxMedicineName.SelectedItem + "' ;"; * MySqlCommand MyCommand6 = new MySqlCommand(Query6, conn); * MySqlDataReader MyReader6; * MyReader6 = MyCommand6.ExecuteReader(); * MyReader6.Close();*/ } catch (Exception ex) { MessageBox.Show(ex.Message); } }