private void button_Click(object sender, RoutedEventArgs e) { try { string Query = "insert into hopedatabase.patient_data (`patient_name`, `patient_age`, `patient_contact_no`, `patient_address`, `time_of_admission`, `patient_sex`, `patient_occupation`) values('" + patient_name.Text + "','" + patient_age.Text + "','" + patient_contact_no2.Text + "','" + patient_address.Text + "','" + datepicker.Text + "','" + comboboxPatient_sex.SelectedItem.ToString() + "','" + patient_occupation.Text + "');"; MySqlCommand MyCommand = new MySqlCommand(Query, connn); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); MyReader.Close(); MessageBox.Show("Patient Registered"); string Query1 = "insert into hopedatabase.patient_data ( `patient_blood_group` ) values('" + comboboxBloodGroup.SelectedItem.ToString() + "');"; MySqlCommand MyCommand1 = new MySqlCommand(Query1, connn); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); MyReader1.Close(); patient_name.Text = ""; patient_address.Text = ""; patient_age.Text = ""; patient_contact_no2.Text = ""; referred_by.Text = ""; datepicker.Text = ""; patient_occupation.Text = ""; comboboxBloodGroup.Items.Clear(); comboboxPatient_sex.Items.Clear(); load_blood_group(); load(); patient_name.IsEnabled = false; patient_address.IsEnabled = false; patient_age.IsEnabled = false; referred_by.IsEnabled = false; comboboxBloodGroup.IsEnabled = false; } catch { } //catch (Exception ex) //{ // MessageBox.Show(ex.Message); //} }
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 btnAddMedicine_Click(object sender, RoutedEventArgs e) { if (txtMedicineName.Text.Equals("") || comboDiseaseType.Text.Equals("") || comboDiseaseName.Text.Equals("") || txtCompanyName.Text.Equals("") || txtContactNo.Text.Equals("") || txtDate.Text.Equals("") || txtQuantity.Text.Equals("") || txtBuyingPrice.Text.Equals("") || txtSellingPrice.Text.Equals("")) { MessageBox.Show("Please Fill All the fields"); } else { try { string Query = "insert into supplier values('" + txtCompanyName.Text + "','" + txtContactNo.Text + "','" + txtMedicineName.Text + "','" + "Medicine" + "','" + txtDate.Text + "','" + txtQuantity.Text + "','" + txtBuyingPrice.Text + "','" + txtSellingPrice.Text + "');"; MySqlCommand MyCommand = new MySqlCommand(Query, conn); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); MyReader.Close(); string Query1 = "insert into medicine_name values('" + txtMedicineName.Text + "','" + comboDiseaseType.SelectedItem + "','" + comboDiseaseName.SelectedItem + "');"; MySqlCommand MyCommand1 = new MySqlCommand(Query1, conn); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); MyReader1.Close(); MessageBox.Show("Medicine added"); txtMedicineName.Text = ""; txtCompanyName.Text = ""; txtContactNo.Text = ""; txtDate.Text = ""; txtQuantity.Text = ""; txtBuyingPrice.Text = ""; txtSellingPrice.Text = ""; btnAddMedicine.IsEnabled = false; comboDiseaseType.Items.Clear(); load_combo_disease_typee(); txtCompanyName.IsEnabled = false; txtContactNo.IsEnabled = false; txtDate.IsEnabled = false; txtQuantity.IsEnabled = false; txtBuyingPrice.IsEnabled = false; txtSellingPrice.IsEnabled = false; comboDiseaseType.IsEnabled = false; comboDiseaseName.IsEnabled = false; } catch (Exception exp) { MessageBox.Show(exp.Message); } } }
private void btnPass_Click(object sender, RoutedEventArgs e) { try { con.Open(); string sql1 = "update staff set staff_password='******' where staff_id='" + textBox1.Text + "';"; MySqlCommand MyCommand1 = new MySqlCommand(sql1, con); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); MyReader1.Close(); MessageBox.Show("Password Updated Succesfully"); staffPass.Text = ""; con.Close(); } catch (Exception eee) { MessageBox.Show(eee.Message.ToString()); } }
private void BCl(object sender, RoutedEventArgs e) { int count = Mylist.Count / 3; int counter = 0; string MyConnection2 = "datasource=localhost;port=3306;username=root;password=;database=gpcenter;"; double x = 0, y = 0, z = 0; MySqlConnection MyConn2 = new MySqlConnection(MyConnection2); int User_id = 1; int movement_id = 1; string code = "GP1.3gam3a_pre"; codenum++; string co = code + Convert.ToString(codenum); string q = "INSERT INTO `video` (`Id`, `Code`, `GroupId`, `MovementId`) VALUES (NULL, '" + co + "','" + User_id + "','" + movement_id + "');"; MySqlCommand MyCommand1 = new MySqlCommand(q, MyConn2); MySqlDataReader MyReader1; MyConn2.Open(); //int id = (int)MyCommand1.ExecuteScalar(); MyReader1 = MyCommand1.ExecuteReader(); while (MyReader1.Read()) { //string rid = MyReader1["Id"].ToString(); } MyConn2.Close(); MyConn2.Open(); string q2 = "SELECT Id FROM `video` WHERE Id=LAST_INSERT_ID()"; MySqlCommand MyCommand12 = new MySqlCommand(q2, MyConn2); MySqlDataReader MyReader12; MyReader12 = MyCommand12.ExecuteReader(); while (MyReader12.Read()) { } //int id = rid; int rid = (int)MyReader12["Id"]; int id = rid; MyConn2.Close(); int jointid = 1; for (int j = 0; j < count; j++) { if (counter <= Mylist.Count) { for (int i = 0; i < 3; i++) { if (i == 0) { x = Mylist[counter]; counter++; } if (i == 1) { y = Mylist[counter]; counter++; } if (i == 2) { z = Mylist[counter]; counter++; } } } string Query = "INSERT INTO `videopoint`( `VideoId`, `JointId`, `x`, `y`, `z`) VALUES ('" + id + "','" + jointid + "','" + x + "','" + y + "','" + z + "');"; MySqlCommand MyCommand2 = new MySqlCommand(Query, MyConn2); MySqlDataReader MyReader2; MyConn2.Open(); MyReader2 = MyCommand2.ExecuteReader(); //MessageBox.Show("Save Data"); while (MyReader2.Read()) { } MyConn2.Close(); jointid++; if (jointid == 7) { jointid = 1; } } Mylist.Clear(); string qtest = "INSERT INTO `checkvideo` (`Id`, `VideoId`, `Value`, `CoachCheck`) VALUES (NULL, '" + id + "', NULL , '0');"; MySqlCommand MyCommand3test = new MySqlCommand(qtest, MyConn2); MySqlDataReader MyReader3; MyConn2.Open(); //int id = (int)MyCommand1.ExecuteScalar(); MyReader3 = MyCommand3test.ExecuteReader(); while (MyReader3.Read()) { //string rid = MyReader1["Id"].ToString(); } MyConn2.Close(); //sw.Close(); //filenum++; }
private void txtContactNo_TextChanged(object sender, TextChangedEventArgs e) { try { //conn.Open(); string Query = "select product_name,quantity,days from user.admitted_medicine where patient_contact_no='" + txtContactNo.Text + "'"; MySqlCommand MyCommand = new MySqlCommand(Query, conn); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { product_name = MyReader.GetString(0); quantity = MyReader.GetString(1); days = MyReader.GetString(2); //conn.Open(); string Query1 = "select selling_price from user.supplier where product_name='" + product_name + "'"; MySqlCommand MyCommand1 = new MySqlCommand(Query1, conn2); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); while (MyReader1.Read()) { per_quantity_price = MyReader1.GetString(0); } quantity_int = Int32.Parse(quantity); days_int = Int32.Parse(days); per_quantity_price_int = Int32.Parse(per_quantity_price); total_medicine_cost_int += quantity_int * days_int * per_quantity_price_int; } conn.Close(); MessageBox.Show("Product Name: " + product_name + "\n" + "Days: " + days + "\n" + "Quantity: " + quantity); /*conn.Open(); * string Query1 = "select selling_price from user.supplier where product_name='" + product_name + "'"; * MySqlCommand MyCommand1 = new MySqlCommand(Query1, conn); * MySqlDataReader MyReader1; * MyReader1 = MyCommand1.ExecuteReader(); * while (MyReader1.Read()) * { * per_quantity_price = MyReader1.GetString(0); * } * conn.Close();*/ MessageBox.Show("Selling price: " + per_quantity_price); /* quantity_int = Int32.Parse(quantity); * days_int = Int32.Parse(days); * per_quantity_price_int = Int32.Parse(per_quantity_price); * * total_medicine_cost_int = quantity_int * days_int * per_quantity_price_int;*/ total_medicine_cost = total_medicine_cost_int.ToString(); txtMedicineCost.Text = total_medicine_cost; //conn.Open(); /*string Query = "select product_name,quantity,days from user.admitted_medicine where patient_contact_no='" + txtContactNo.Text + "'"; * MySqlCommand MyCommand = new MySqlCommand(Query, conn); * MySqlDataReader MyReader; * MyReader = MyCommand.ExecuteReader(); * while (MyReader.Read()) * { * product_name = MyReader.GetString(0); * quantity = MyReader.GetString(1); * days = MyReader.GetString(2); * } * conn.Close(); * * // MessageBox.Show("Product Name: " + product_name + "\n" + "Days: " + days + "\n" + "Quantity: " + quantity); * * conn.Open(); * string Query1 = "select selling_price from user.supplier where product_name='" + product_name + "'"; * MySqlCommand MyCommand1 = new MySqlCommand(Query1, conn); * MySqlDataReader MyReader1; * MyReader1 = MyCommand1.ExecuteReader(); * while (MyReader1.Read()) * { * per_quantity_price = MyReader1.GetString(0); * } * conn.Close(); * * //MessageBox.Show("Selling price: " + per_quantity_price); * * quantity_int = Int32.Parse(quantity); * days_int = Int32.Parse(days); * per_quantity_price_int = Int32.Parse(per_quantity_price); * * total_medicine_cost_int = quantity_int * days_int * per_quantity_price_int; * total_medicine_cost = total_medicine_cost_int.ToString(); * * txtMedicineCost.Text = total_medicine_cost;*/ } catch (Exception ex) { MessageBox.Show(ex.Message); } }
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 button1_Click_1(object sender, EventArgs e) { string conexao = "Server=localhost;Database=Scholendar;Uid=root"; var connection = new MySqlConnection(conexao); //var command = connection.CreateCommand(); MySqlCommand query = new MySqlCommand("select count(*) from Admin where Utilizador = '" + textBoxUtilizador.Text + "' and Pass = '******'", connection); connection.Open(); DataTable dataTable = new DataTable(); MySqlDataAdapter da = new MySqlDataAdapter(query); MySqlDataAdapter adapter = new MySqlDataAdapter(); da.Fill(dataTable); connection.Close(); //QUERY'S MySqlCommand queryAl = new MySqlCommand("select * from Aluno where Utilizador = '" + textBoxUtilizador.Text + "' and Pass = '******'", connection); MySqlCommand queryAd = new MySqlCommand("select * from Admin where Utilizador = '" + textBoxUtilizador.Text + "' and Pass = '******'", connection); MySqlCommand queryProf = new MySqlCommand("select * from Professor where Utilizador = '" + textBoxUtilizador.Text + "' and Pass = '******'", connection); MySqlCommand queryEE = new MySqlCommand("select * from EE where Utilizador = '" + textBoxUtilizador.Text + "' and Pass = '******'", connection); connection.Open(); //DATATABLES DataTable dataTable1 = new DataTable(); DataTable dataTable2 = new DataTable(); DataTable dataTable3 = new DataTable(); DataTable dataTable4 = new DataTable(); //ADAPATERS MySqlDataAdapter daAl = new MySqlDataAdapter(queryAl); MySqlDataAdapter daAd = new MySqlDataAdapter(queryAd); MySqlDataAdapter daProf = new MySqlDataAdapter(queryProf); MySqlDataAdapter daEE = new MySqlDataAdapter(queryEE); daAl.Fill(dataTable1); daAd.Fill(dataTable2); daProf.Fill(dataTable3); daEE.Fill(dataTable4); connection.Close(); foreach (DataRow list in dataTable1.Rows) // Aluno { if (Convert.ToInt32(list.ItemArray[0]) > 0) { textBoxVar.Text = "1"; } else { } } foreach (DataRow list2 in dataTable2.Rows) // Admin { if (Convert.ToInt32(list2.ItemArray[0]) > 0) { textBoxVar.Text = "2"; } else { } } foreach (DataRow list3 in dataTable3.Rows) //Professor { if (Convert.ToInt32(list3.ItemArray[0]) > 0) { textBoxVar.Text = "3"; } else { } } foreach (DataRow list4 in dataTable4.Rows) //EE { if (Convert.ToInt32(list4.ItemArray[0]) > 0) { textBoxVar.Text = "4"; } else { } } string Utilizador = textBoxUtilizador.Text; if (textBoxVar.Text == "1") // Aluno { connection.Open(); string queryAlHex = "select * from Aluno where Utilizador = '" + Utilizador + "' "; MySqlCommand MyCommand = new MySqlCommand(queryAlHex, connection); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { textBoxID_Aluno.Text = MyReader["ID_Aluno"].ToString(); } connection.Close(); connection.Open(); string query1 = "select * from Aluno where ID_aluno = '" + textBoxID_Aluno.Text + "' ;"; MySqlCommand MyCommand1 = new MySqlCommand(query1, connection); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); while (MyReader1.Read()) { textBoxVarPass.Text = MyReader1["var"].ToString(); } connection.Close(); try { string ID_Aluno = textBoxID_Aluno.Text; connection.Open(); string sql = "Update VAR set var = ('" + ID_Aluno + "') where ID_Var = 1;"; adapter.InsertCommand = new MySqlCommand(sql, connection); adapter.InsertCommand.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { connection.Close(); } connection.Open(); string sql1 = "Update VAR set var = '1' where ID_Var = 2;"; adapter.InsertCommand = new MySqlCommand(sql1, connection); adapter.InsertCommand.ExecuteNonQuery(); connection.Close(); if (textBoxVarPass.Text == "1") { this.Hide(); MudarPass newform = new MudarPass(); newform.Show(); } else if (textBoxVarPass.Text == "0") { this.Hide(); Aluno Form = new Aluno(); Form.Show(); } } else if (textBoxVar.Text == "2") // Admin { connection.Open(); string queryAlHex = "select * from Admin where Utilizador = '" + Utilizador + "' "; MySqlCommand MyCommand = new MySqlCommand(queryAlHex, connection); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { textBoxID_Admin.Text = MyReader["ID_Admin"].ToString(); } connection.Close(); connection.Open(); string query1 = "select * from Admin where ID_Admin = '" + textBoxID_Admin.Text + "' ;"; MySqlCommand MyCommand1 = new MySqlCommand(query1, connection); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); while (MyReader1.Read()) { textBoxVarPass.Text = MyReader1["var"].ToString(); } connection.Close(); try { string ID_Admin = textBoxID_Admin.Text; connection.Open(); string sql = "Update VAR set var = ('" + ID_Admin + "') where ID_Var = 1;"; adapter.InsertCommand = new MySqlCommand(sql, connection); adapter.InsertCommand.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { connection.Close(); } connection.Open(); string sql1 = "Update VAR set var = '2' where ID_Var = 2;"; adapter.InsertCommand = new MySqlCommand(sql1, connection); adapter.InsertCommand.ExecuteNonQuery(); connection.Close(); if (textBoxVarPass.Text == "1") { this.Hide(); MudarPass newform = new MudarPass(); newform.Show(); } else if (textBoxVarPass.Text == "0") { this.Hide(); Admin Form = new Admin(); Form.Show(); } } else if (textBoxVar.Text == "3") // Professor { connection.Open(); string queryAlHex = "select * from Professor where Utilizador = '" + Utilizador + "' "; MySqlCommand MyCommand = new MySqlCommand(queryAlHex, connection); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { textBoxIDProf.Text = MyReader["ID_Professor"].ToString(); } connection.Close(); connection.Open(); string query1 = "select * from Professor where ID_Professor = '" + textBoxIDProf.Text + "' ;"; MySqlCommand MyCommand1 = new MySqlCommand(query1, connection); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); while (MyReader1.Read()) { textBoxVarPass.Text = MyReader1["var"].ToString(); } connection.Close(); try { string ID_Prof = textBoxIDProf.Text; connection.Open(); string sql = "Update VAR set var = ('" + ID_Prof + "') where ID_Var = 1;"; adapter.InsertCommand = new MySqlCommand(sql, connection); adapter.InsertCommand.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { connection.Close(); } connection.Open(); string sql1 = "Update VAR set var = '3' where ID_Var = 2;"; adapter.InsertCommand = new MySqlCommand(sql1, connection); adapter.InsertCommand.ExecuteNonQuery(); connection.Close(); if (textBoxVarPass.Text == "1") { this.Hide(); MudarPass newform = new MudarPass(); newform.Show(); } else if (textBoxVarPass.Text == "0") { this.Hide(); Professor Form = new Professor(); Form.Show(); } } if (textBoxVar.Text == "4") // EE { connection.Open(); string ID_EE = textBoxID_EE.Text; string queryAlHex = "select * from EE where Utilizador = '" + Utilizador + "' "; MySqlCommand MyCommand = new MySqlCommand(queryAlHex, connection); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { textBoxID_EE.Text = MyReader["ID_EE"].ToString(); } connection.Close(); connection.Open(); string query1 = "select * from EE where ID_EE = '" + ID_EE + "' ;"; MySqlCommand MyCommand1 = new MySqlCommand(query1, connection); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); while (MyReader1.Read()) { textBoxVarPass.Text = MyReader1["var"].ToString(); } connection.Close(); try { connection.Open(); string sql = "Update VAR set var = ('" + ID_EE + "') where ID_Var = 1;"; adapter.InsertCommand = new MySqlCommand(sql, connection); adapter.InsertCommand.ExecuteNonQuery(); connection.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { connection.Close(); } connection.Open(); string sql1 = "Update VAR set var = '4' where ID_Var = 2;"; adapter.InsertCommand = new MySqlCommand(sql1, connection); adapter.InsertCommand.ExecuteNonQuery(); connection.Close(); if (textBoxVarPass.Text == "1") { this.Hide(); MudarPass newform = new MudarPass(); newform.Show(); } else if (textBoxVarPass.Text == "0") { this.Hide(); EE Form = new EE(); Form.Show(); } } else if (textBoxPass.Text == "" || textBoxUtilizador.Text == "") { MessageBox.Show("Insira o utilizador e a Password"); } else if (textBoxVar.Text == "") { MessageBox.Show("Utilizador Incorreto"); } }
unsafe private void button2_Click_1(object sender, EventArgs e) { UInt32 uiLength, uiRead, uiResult, uiWritten; byte[] ReadBuffer = new byte[0x40]; byte[] WriteBuffer = new byte[] { 0x2, 0x2, 0x1, 0x1 }; //Command {STX, LEN, CMD, DATA1, DATA2.....} byte[] sResponse = null; sResponse = new byte[21]; EasyPOD.VID = 0xe6a; EasyPOD.PID = 0x317; Index = 1; uiLength = 64; fixed(MW_EasyPOD *pPOD = &EasyPOD) { dwResult = PODfuncs.ConnectPOD(pPOD, Index); if ((dwResult != 0)) { MessageBox.Show("Ligue o leitor de cartões"); } else { EasyPOD.ReadTimeOut = 200; EasyPOD.WriteTimeOut = 200; dwResult = PODfuncs.WriteData(pPOD, WriteBuffer, 4, &uiWritten); //Send a request command to reader uiResult = PODfuncs.ReadData(pPOD, ReadBuffer, uiLength, &uiRead); //Read the response data from reader textBoxHex.Text = BitConverter.ToString(ReadBuffer, 4, (Int32)uiRead).Replace("-", " "); //HEX textBoxDe.Text = BitConverter.ToInt32(ReadBuffer, 4).ToString(); //DEC //textBox1.PasswordChar = '*'; string conexao = "Server=localhost;Database=Scholendar;Uid=root"; var connection = new MySqlConnection(conexao); var command = connection.CreateCommand(); MySqlDataAdapter adapter = new MySqlDataAdapter(); //QUERY'S MySqlCommand queryAl = new MySqlCommand("select * from Aluno where Hex = '" + textBoxHex.Text + "' or De = '" + textBoxDe.Text + "'", connection); MySqlCommand queryAd = new MySqlCommand("select * from Admin where Hex = '" + textBoxHex.Text + "' or De = '" + textBoxDe.Text + "'", connection); MySqlCommand queryProf = new MySqlCommand("select * from Professor where Hex = '" + textBoxHex.Text + "' or De = '" + textBoxDe.Text + "'", connection); connection.Open(); //DATATABLES DataTable dataTable1 = new DataTable(); DataTable dataTable2 = new DataTable(); DataTable dataTable3 = new DataTable(); //ADAPATERS MySqlDataAdapter daAl = new MySqlDataAdapter(queryAl); MySqlDataAdapter daAd = new MySqlDataAdapter(queryAd); MySqlDataAdapter daProf = new MySqlDataAdapter(queryProf); daAl.Fill(dataTable1); daAd.Fill(dataTable2); daProf.Fill(dataTable3); connection.Close(); foreach (DataRow list in dataTable1.Rows) // Aluno { if (Convert.ToInt32(list.ItemArray[0]) > 0) { textBoxVar.Text = "1"; } else { MessageBox.Show("Teste"); } } foreach (DataRow list in dataTable2.Rows) // Admin { if (Convert.ToInt32(list.ItemArray[0]) > 0) { textBoxVar.Text = "2"; } else { MessageBox.Show("Teste"); } } foreach (DataRow list3 in dataTable3.Rows) //Professor { if (Convert.ToInt32(list3.ItemArray[0]) > 0) { textBoxVar.Text = "3"; } else { MessageBox.Show("Teste"); } } if (textBoxVar.Text == "1")//ALUNO { connection.Open(); string Hex = textBoxHex.Text; string query = "select * from Aluno where Hex = '" + Hex + "' "; MySqlCommand MyCommand = new MySqlCommand(query, connection); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { textBoxID_Aluno.Text = MyReader["ID_Aluno"].ToString(); } connection.Close(); try { string ID_Aluno = textBoxID_Aluno.Text; connection.Open(); string sql = "Update VAR set var = ('" + ID_Aluno + "') where ID_Var = 1;"; adapter.InsertCommand = new MySqlCommand(sql, connection); adapter.InsertCommand.ExecuteNonQuery(); connection.Close(); connection.Open(); string query1 = "select * from Aluno where ID_Aluno = '" + ID_Aluno + "' ;"; MySqlCommand MyCommand1 = new MySqlCommand(query1, connection); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); while (MyReader1.Read()) { textBoxVarPass.Text = MyReader1["var"].ToString(); } connection.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { connection.Close(); } try { connection.Open(); string sql = "Update VAR set var = '1' where ID_Var = 2;"; adapter.InsertCommand = new MySqlCommand(sql, connection); adapter.InsertCommand.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { connection.Close(); } if (textBoxVarPass.Text == "1") { this.Hide(); MudarPass newform1 = new MudarPass(); newform1.Show(); form.textBoxUtilizador.Text = "Aluno"; } else { this.Hide(); Aluno newform = new Aluno(); newform.Show(); } } else if (textBoxVar.Text == "2")//ADMIN { connection.Open(); string Hex = textBoxHex.Text; string query = "select * from Admin where Hex = '" + Hex + "' "; MySqlCommand MyCommand = new MySqlCommand(query, connection); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { textBoxID_Admin.Text = MyReader["ID_Admin"].ToString(); } connection.Close(); try { string ID_Admin = textBoxID_Admin.Text; connection.Open(); string sql = "Update VAR set var = ('" + ID_Admin + "') where ID_Var = 1;"; adapter.InsertCommand = new MySqlCommand(sql, connection); adapter.InsertCommand.ExecuteNonQuery(); connection.Close(); connection.Open(); string query1 = "select * from Admin where ID_Admin = '" + ID_Admin + "' ;"; MySqlCommand MyCommand1 = new MySqlCommand(query1, connection); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); while (MyReader1.Read()) { textBoxVarPass.Text = MyReader1["var"].ToString(); } connection.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { connection.Close(); } try { connection.Open(); string sql = "Update VAR set var = '2' where ID_Var = 2;"; adapter.InsertCommand = new MySqlCommand(sql, connection); adapter.InsertCommand.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { connection.Close(); } if (textBoxVarPass.Text == "1") { this.Hide(); MudarPass newform = new MudarPass(); newform.Show(); form.textBoxUtilizador.Text = "Administrador"; } else if (textBoxVarPass.Text == "0") { this.Hide(); Admin Form = new Admin(); Form.Show(); } } else if (textBoxVar.Text == "3")//PROFESSOR { connection.Open(); string Hex = textBoxHex.Text; string query = "select * from Professor where Hex = '" + Hex + "' "; MySqlCommand MyCommand = new MySqlCommand(query, connection); MySqlDataReader MyReader; MyReader = MyCommand.ExecuteReader(); while (MyReader.Read()) { textBoxIDProf.Text = MyReader["ID_Professor"].ToString(); } connection.Close(); string ID_Prof = textBoxIDProf.Text; try { connection.Open(); string sql = "Update VAR set var = ('" + ID_Prof + "') where ID_Var = 1;"; adapter.InsertCommand = new MySqlCommand(sql, connection); adapter.InsertCommand.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { connection.Close(); } connection.Open(); string query1 = "select * from Professor where ID_Professor = '" + ID_Prof + "' ;"; MySqlCommand MyCommand1 = new MySqlCommand(query1, connection); MySqlDataReader MyReader1; MyReader1 = MyCommand1.ExecuteReader(); while (MyReader1.Read()) { textBoxVarPass.Text = MyReader1["var"].ToString(); } connection.Close(); try { connection.Open(); string sql = "Update VAR set var = '3' where ID_Var = 2;"; adapter.InsertCommand = new MySqlCommand(sql, connection); adapter.InsertCommand.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { connection.Close(); } if (textBoxVarPass.Text == "1") { this.Hide(); MudarPass newform = new MudarPass(); newform.Show(); form.textBoxUtilizador.Text = "Professor"; } else if (textBoxVarPass.Text == "0") { this.Hide(); Professor Form = new Professor(); Form.Show(); } } else if (textBoxDe.Text == "0") { } else { MessageBox.Show("Cartão não registado"); } } dwResult = PODfuncs.ClearPODBuffer(pPOD); dwResult = PODfuncs.DisconnectPOD(pPOD); } }
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); } }