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 btnAddress_Click(object sender, RoutedEventArgs e) { try { con.Open(); string sql3 = "update staff set address='" + staffAddress.Text + "' where staff_id='" + textBox1.Text + "';"; MySqlCommand MyCommand3 = new MySqlCommand(sql3, con); MySqlDataReader MyReader3; MyReader3 = MyCommand3.ExecuteReader(); MyReader3.Close(); MessageBox.Show("Address Updated Succesfully"); staffAddress.Text = ""; con.Close(); } catch (Exception eee) { MessageBox.Show(eee.Message.ToString()); } }
private void radiobtnVIP_Checked(object sender, RoutedEventArgs e) { comboboxChooseBed.Items.Clear(); comboboxChooseWard.Items.Clear(); try { string Query = "select distinct ward_name from ward_bed where bed_type='" + "VIP" + "';"; MySqlCommand MyCommand3 = new MySqlCommand(Query, conn); MySqlDataReader MyReader3; MyReader3 = MyCommand3.ExecuteReader(); while (MyReader3.Read()) { name = MyReader3.GetString(0); comboboxChooseWard.Items.Add(name); } MyReader3.Close(); } catch { } this.comboboxChooseWard.IsEnabled = true; }
private void save_Click(object sender, EventArgs e) { Double t = Convert.ToDouble(this.tel.Text); Double t2 = Convert.ToDouble(254000000000 + t); String newtel = "+" + t2.ToString(); if (checkBox1.Checked == true) { //ADD NEW CUSTOMER string MyConnection2 = "datasource=localhost;port=3306;username=root"; //This is my insert query in which i am taking input from the user through windows forms string Query = "insert into drawgift.customer(name,passport,address,idno,tel) values('" + this.name.Text + "','" + this.pass.Text + "','" + this.area.Text + "','" + this.idno.Text + "','" + newtel + "');"; //This is MySqlConnection here i have created the object and pass my connection string. MySqlConnection MyConn2 = new MySqlConnection(MyConnection2); //This is command class which will handle the query and connection object. MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2); MySqlDataReader MyReader2; MyConn2.Open(); MyReader2 = MyCommand2.ExecuteReader(); // Here our query will be executed and data saved into the database. while (MyReader2.Read()) { } MyReader2.Close(); MyConn2.Close(); } if (pass.Text != "N/A") { //UPDATE CUSTOMER DETAILS string MyConnection7 = "datasource=localhost;port=3306;username=root"; //This is my insert query in which i am taking input from the user through windows forms string Query = "UPDATE drawgift.customer set passport='" + pass.Text + "'WHERE idno='" + idno.Text + "'|| tel='" + tel.Text + "' "; //This is MySqlConnection here i have created the object and pass my connection string. MySqlConnection MyConn7 = new MySqlConnection(MyConnection7); //This is command class which will handle the query and connection object. MySqlCommand MyCommand7 = new MySqlCommand(Query, MyConn7); MySqlDataReader MyReader7; MyConn7.Open(); MyReader7 = MyCommand7.ExecuteReader(); // Here our query will be executed and data saved into the database. while (MyReader7.Read()) { } MyReader7.Close(); MyConn7.Close(); } //GENERATE TOKEN string MyConnection4 = "datasource=localhost;port=3306;username=root"; //This is my insert query in which i am taking input from the user through windows forms //This is MySqlConnection here i have created the object and pass my connection string. MySqlConnection MyConn4 = new MySqlConnection(MyConnection4); //This is command class which will handle the query and connection object. MyConn4.Open(); //get account no string q2 = "select COUNT(id) as idc from drawgift.entries ;"; MySqlCommand com4 = new MySqlCommand(q2, MyConn4); MySqlDataReader r2; r2 = com4.ExecuteReader(); r2.Read(); int ab = Convert.ToInt32(r2["idc"]) + 1; String raf = ("GALLERIA-" + ab).ToString(); r2.Close(); //ITERATE TRHOUGH ARRAY for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) { object a = dataGridView1.Rows[i].Cells["Total"].Value; int aNumber = 0; int setlimit = 1000; if (a != null) { aNumber = Convert.ToInt32(a.ToString()); } int vouch = (aNumber / setlimit); dataGridView1.Rows[i].Cells["vouchers"].Value = vouch; //ASSIGN VALUABLES object va = dataGridView1.Rows[i].Cells["vouchers"].Value; String v = va.ToString(); object sh = dataGridView1.Rows[i].Cells["Shop"].Value; // String s = sh.ToString(); //String tot = a.ToString(); //SEARCH FOR SHOPNAME string shopconnection = "datasource=localhost;port=3306;username=root"; //This is my insert query in which i am taking input from the user through windows forms string shopquery = "SELECT cname FROM drawgift.shop WHERE name='" + sh + "'"; //This is MySqlConnection here i have created the object and pass my connection string. MySqlConnection shopconn = new MySqlConnection(shopconnection); //This is command class which will handle the query and connection object. MySqlCommand shopcommand = new MySqlCommand(shopquery, shopconn); MySqlDataReader shopreader; shopconn.Open(); shopreader = shopcommand.ExecuteReader(); // Here our query will be executed and data saved into the database. shopreader.Read(); String shopname = shopreader["cname"].ToString(); shopreader.Close(); shopconn.Close(); //RUN INSERT SCRIPT try { //ADD NEW RAFFLE ENTRY string MyConnection3 = "datasource=localhost;port=3306;username=root"; //This is my insert query in which i am taking input from the user through windows forms string Query = "insert into drawgift.entries(customername,passport,tel,address,raffleno,idno,shop,amount,points,dateadded)values('" + this.name.Text + "','" + this.pass.Text + "','" + newtel + "','" + this.area.Text + "','" + raf + "','" + this.idno.Text + "','" + shopname + "','" + a + "','" + vouch + "','" + this.datea.Text + "');"; //This is MySqlConnection here i have created the object and pass my connection string. MySqlConnection MyConn3 = new MySqlConnection(MyConnection3); //This is command class which will handle the query and connection object. MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn3); MySqlDataReader MyReader3; MyConn3.Open(); MyReader3 = MyCommand2.ExecuteReader(); // Here our query will be executed and data saved into the database. while (MyReader3.Read()) { // Find your Account Sid and Auth Token at twilio.com/user/account /* string AccountSid = "AC76b83713f0c7385af9352e3dfb902288"; * string AuthToken = "6e48fb10b5b82dd13f2eb663d6a3c210"; * var twilio = new TwilioRestClient(AccountSid, AuthToken); * * twilio.SendMessage("+17083283330","+254728944815","This is the ship that made the Kessel Run in fourteen parsecs?" * );*/ // Specify your login credentials string username = "******"; string apiKey = "93f87c6f181904289e830c9fabda74e70cfcaef5d804e9811d9f097dee44989e"; // Specify the numbers that you want to send to in a comma-separated list // Please ensure you include the country code (+254 for Kenya in this case) string recipients = this.tel.Text; // And of course we want our recipients to know what we really do string message = "I'm a lumberjack and its ok, I sleep all night and I work all day"; // Create a new instance of our awesome gateway class AfricasTalkingGateway gateway = new AfricasTalkingGateway(username, apiKey); // Any gateway errors will be captured by our custom Exception class below, // so wrap the call in a try-catch block try { // Thats it, hit send and we'll take care of the rest gateway.sendMessage(recipients, message); dynamic results = gateway.sendMessage(recipients, message); foreach (dynamic result in results) { Console.Write((string)result["number"] + ","); Console.Write((string)result["status"] + ","); // status is either "Success" or "error message" Console.Write((string)result["messageId"] + ","); Console.WriteLine((string)result["cost"]); } } catch (AfricasTalkingGatewayException e1) { Console.WriteLine("Encountered an error: " + e1.Message); } } MyReader3.Close(); MyConn3.Close(); //RESET EVERYTHING } catch (Exception ex) { MessageBox.Show(ex.Message); } } MessageBox.Show("ENTRIES SAVED"); tel.Enabled = true; tel.Text = "0"; idno.Enabled = true; idno.Text = ""; name.Enabled = false; name.Text = ""; pass.Enabled = false; pass.Text = ""; area.Enabled = false; area.Text = ""; checkBox1.Checked = false; dataGridView1.Rows.Clear(); }
private void save_Click(object sender, EventArgs e) { Double t = Convert.ToDouble(this.tel.Text); Double t2 = Convert.ToDouble(254000000000 + t); String newtel = "+" + t2.ToString(); if (checkBox1.Checked == true) { //ADD NEW CUSTOMER string MyConnection2 = "datasource=techcube.co.ke;port=3306;username=techcube_galleria;password=Pandora.2017"; //This is my insert query in which i am taking input from the user through windows forms string Query = "insert into techcube_galleria.customer(name,passport,address,idno,tel,gender) values('" + this.name.Text + "','" + this.pass.Text + "','" + this.area.Text + "','" + this.idno.Text + "','" + newtel + "','" + this.gender.Text + "');"; //This is MySqlConnection here i have created the object and pass my connection string. MySqlConnection MyConn2 = new MySqlConnection(MyConnection2); //This is command class which will handle the query and connection object. MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2); MySqlDataReader MyReader2; MyConn2.Open(); MyReader2 = MyCommand2.ExecuteReader(); // Here our query will be executed and data saved into the database. while (MyReader2.Read()) { } MyReader2.Close(); MyConn2.Close(); } if (pass.Text != "N/A") { //UPDATE CUSTOMER DETAILS string MyConnection7 = "datasource=techcube.co.ke;port=3306;username=techcube_galleria;password=Pandora.2017"; //This is my insert query in which i am taking input from the user through windows forms string Query = "UPDATE techcube_galleria.customer set passport='" + pass.Text + "'WHERE idno='" + idno.Text + "'|| tel='" + tel.Text + "' "; //This is MySqlConnection here i have created the object and pass my connection string. MySqlConnection MyConn7 = new MySqlConnection(MyConnection7); //This is command class which will handle the query and connection object. MySqlCommand MyCommand7 = new MySqlCommand(Query, MyConn7); MySqlDataReader MyReader7; MyConn7.Open(); MyReader7 = MyCommand7.ExecuteReader(); // Here our query will be executed and data saved into the database. while (MyReader7.Read()) { } MyReader7.Close(); MyConn7.Close(); } //GENERATE TOKEN string MyConnection4 = "datasource=techcube.co.ke;port=3306;username=techcube_galleria;password=root"; //This is my insert query in which i am taking input from the user through windows forms //This is MySqlConnection here i have created the object and pass my connection string. MySqlConnection MyConn4 = new MySqlConnection(MyConnection4); //This is command class which will handle the query and connection object. MyConn4.Open(); //get account no string q2 = "select COUNT(id) as idc from techcube_galleria.entries where promo='VALENTINES2017' ;"; MySqlCommand com4 = new MySqlCommand(q2, MyConn4); MySqlDataReader r2; r2 = com4.ExecuteReader(); r2.Read(); int ab = Convert.ToInt32(r2["idc"]) + 1; String raf = ("GALLERIA-VALS-" + ab).ToString(); r2.Close(); //ITERATE TRHOUGH ARRAY for (int i = 0; i < dataGridView1.Rows.Count - 1; i++) { object a = dataGridView1.Rows[i].Cells["Total"].Value; int aNumber = 0; int setlimit = 1000; if (a != null) { aNumber = Convert.ToInt32(a.ToString()); } int vouch = (aNumber / setlimit); dataGridView1.Rows[i].Cells["vouchers"].Value = vouch; //ASSIGN VALUABLES object va = dataGridView1.Rows[i].Cells["vouchers"].Value; String v = va.ToString(); object sh = dataGridView1.Rows[i].Cells["Shop"].Value; // String s = sh.ToString(); //String tot = a.ToString(); //SEARCH FOR SHOPNAME string shopconnection = "datasource=techcube.co.ke;port=3306;username=techcube_galleria;password=Pandora.2017"; //This is my insert query in which i am taking input from the user through windows forms string shopquery = "SELECT cname FROM techcube_galleria.shop WHERE name='" + sh + "'"; //This is MySqlConnection here i have created the object and pass my connection string. MySqlConnection shopconn = new MySqlConnection(shopconnection); //This is command class which will handle the query and connection object. MySqlCommand shopcommand = new MySqlCommand(shopquery, shopconn); MySqlDataReader shopreader; shopconn.Open(); shopreader = shopcommand.ExecuteReader(); // Here our query will be executed and data saved into the database. shopreader.Read(); String shopname = shopreader["cname"].ToString(); shopreader.Close(); shopconn.Close(); //VALIDATE TEL NO if (checkBox1.Checked == false) { string phone = this.tel.Text; //RUN INSERT SCRIPT try { //ADD NEW RAFFLE ENTRY string MyConnection3 = "datasource=techcube.co.ke;port=3306;username=techcube_galleria;password=Pandora.2017"; //This is my insert query in which i am taking input from the user through windows forms string Query = "insert into techcube_galleria.entries(customername,passport,tel,address,raffleno,idno,shop,amount,points,dateadded,promo)values('" + this.name.Text + "','" + this.pass.Text + "','" + phone + "','" + this.area.Text + "','" + raf + "','" + this.idno.Text + "','" + shopname + "','" + a + "','" + vouch + "','" + this.datea.Text + "','" + "VALENTINES2017');"; //This is MySqlConnection here i have created the object and pass my connection string. MySqlConnection MyConn3 = new MySqlConnection(MyConnection3); //This is command class which will handle the query and connection object. MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn3); MySqlDataReader MyReader3; MyConn3.Open(); MyReader3 = MyCommand2.ExecuteReader(); // Here our query will be executed and data saved into the database. while (MyReader3.Read()) { } MyReader3.Close(); MyConn3.Close(); //RESET EVERYTHING } catch (Exception ex) { MessageBox.Show(ex.Message); } //END INSERT } else if (checkBox1.Checked == true) { //RUN INSERT SCRIPT try { //ADD NEW RAFFLE ENTRY string MyConnection3 = "datasource=techcube.co.ke;port=3306;username=techcube_galleria;password=Pandora.2017"; //This is my insert query in which i am taking input from the user through windows forms string Query = "insert into techcube_galleria.entries(customername,passport,tel,address,raffleno,idno,shop,amount,points,dateadded)values('" + this.name.Text + "','" + this.pass.Text + "','" + newtel + "','" + this.area.Text + "','" + raf + "','" + this.idno.Text + "','" + shopname + "','" + a + "','" + vouch + "','" + this.datea.Text + "');"; //This is MySqlConnection here i have created the object and pass my connection string. MySqlConnection MyConn3 = new MySqlConnection(MyConnection3); //This is command class which will handle the query and connection object. MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn3); MySqlDataReader MyReader3; MyConn3.Open(); MyReader3 = MyCommand2.ExecuteReader(); // Here our query will be executed and data saved into the database. while (MyReader3.Read()) { } MyReader3.Close(); MyConn3.Close(); //RESET EVERYTHING } catch (Exception ex) { MessageBox.Show(ex.Message); } //END INSERT } } MessageBox.Show("ENTRIES SAVED"); tel.Enabled = true; tel.Text = "0"; idno.Enabled = true; idno.Text = ""; name.Enabled = false; name.Text = ""; pass.Enabled = false; pass.Text = ""; area.Enabled = false; area.Text = ""; checkBox1.Checked = false; dataGridView1.Rows.Clear(); }
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); } }
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() + "';"; } 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.ToString() + "' and time_of_admission='" + checkpatientDate.Text.ToString() + "';"; } conn.Open(); MySqlCommand MyCommand1 = new MySqlCommand(Query1, conn); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); MyReader1.Close(); //conn.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(); //conn.Open(); 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(); //conn.Close(); MessageBox.Show("Patient checked Succesfully . . ."); this.checkpatientAge.Text = ""; this.checkpatientContactNo.Text = ""; this.checkpatientDate.Text = ""; this.comboboxDiseaseType.Text = ""; this.checkpatientName.Text = ""; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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); } }