private void submitBed_Click(object sender, RoutedEventArgs e) { try { p.textboxWard.Text = this.comboboxChooseWard.SelectedItem.ToString(); p.textboxBed.Text = this.comboboxChooseBed.SelectedItem.ToString(); p.textboxBedType.Text = this.check(); string Query = "update bed set pat_contact_no='" + contact + "',bed_status='" + "Occupied" + "' where bed_no='" + comboboxChooseBed.SelectedItem.ToString() + "';"; MySqlCommand MyCommand4 = new MySqlCommand(Query, conn); MySqlDataReader MyReader4; MyReader4 = MyCommand4.ExecuteReader(); while (MyReader4.Read()) { name = MyReader4.GetString(0); comboboxChooseBed.Items.Add(name); } MyReader4.Close(); this.Close(); } catch (Exception e1) { MessageBox.Show(e1.Message.ToString()); } }
private void button_Click(object sender, RoutedEventArgs e) { try { string Query = "insert into admitted_patient values('" + patient_name.Text + "','" + patient_age.Text + "','" + patient_contact_no.Text + "','" + comboboxBloodGroup.SelectedItem.ToString() + "','" + patient_address.Text + "','" + comboboxDisease.SelectedItem.ToString() + "','" + comboboxDoctorName.SelectedItem.ToString() + "','" + docId + "','" + textboxDoctorDept.Text + "','" + time_of_admission.Text + "','" + this.textboxWard.Text + "', '" + "Admitted" + "');"; MySqlCommand MyCommand = new MySqlCommand(Query, conn); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); MyReader.Close(); string Query1 = "DROP TABLE ward_bed;"; MySqlCommand MyCommand1 = new MySqlCommand(Query1, conn); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); MyReader1.Close(); string Query2 = "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 MyCommand2 = new MySqlCommand(Query2, conn); MySqlDataReader MyReader2; MyReader2 = MyCommand2.ExecuteReader(); MyReader2.Close(); string Query3 = "DROP TABLE allocate_patient_bed;"; MySqlCommand MyCommand3 = new MySqlCommand(Query3, conn); MySqlDataReader MyReader3; MyReader3 = MyCommand3.ExecuteReader(); MyReader3.Close(); string Query4 = "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 MyCommand4 = new MySqlCommand(Query4, conn); MySqlDataReader MyReader4; MyReader4 = MyCommand4.ExecuteReader(); MyReader4.Close(); MessageBox.Show("Patient Addmitted!"); patient_name.Text = ""; patient_address.Text = ""; patient_age.Text = ""; patient_contact_no.Text = ""; comboboxBloodGroup.Items.Clear(); comboboxDoctorName.Items.Clear(); comboboxDisease.Items.Clear(); textboxBed.Text = ""; textboxBedType.Text = ""; textboxWard.Text = ""; textboxDoctorDept.Text = ""; load_blood_group(); load_disease(); load_doctor_name(); patient_name.IsEnabled = false; patient_address.IsEnabled = false; patient_age.IsEnabled = false; patient_contact_no.IsEnabled = false; comboboxBloodGroup.IsEnabled = false; comboboxDoctorName.IsEnabled = false; comboboxDisease.IsEnabled = false; textboxBed.IsEnabled = false; textboxBedType.IsEnabled = false; textboxWard.IsEnabled = false; textboxDoctorDept.IsEnabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void comboboxChooseWard_SelectionChanged(object sender, SelectionChangedEventArgs e) { comboboxChooseBed.Items.Clear(); try { string text = comboboxChooseWard.SelectedItem.ToString(); string Query = "select bed_no from ward_bed where ward_name='" + text + "' and bed_status='" + "Free" + "' and bed_type='" + check().ToString() + "';"; MySqlCommand MyCommand4 = new MySqlCommand(Query, conn); MySqlDataReader MyReader4; MyReader4 = MyCommand4.ExecuteReader(); while (MyReader4.Read()) { name = MyReader4.GetString(0); comboboxChooseBed.Items.Add(name); } MyReader4.Close(); } catch { } this.comboboxChooseBed.IsEnabled = true; radiobtnNormal.IsEnabled = false; radiobtnVIP.IsEnabled = false; }
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); } }