private void delete_btn_Click(object sender, EventArgs e) { del_confirm del = new del_confirm(); del.ShowDialog(); selectedItems2 = new ListBox.SelectedObjectCollection(project_list); selectedItems2 = project_list.SelectedItems; int selectedIndex = project_list.SelectedIndex; if (selectedIndex != -1) { if (del.Showconfirmation() == true) { for (int i = selectedItems2.Count - 1; i >= 0; i--) { projIDii = selectedItems2[i].ToString(); } projIDiii = projIDii.Split(','); proID = Convert.ToInt32(projIDiii[0]); //proj.Remove(proj[selectedIndex]); MySqlConnection connection = new MySqlConnection(connec); connection.Open(); string query = "DELETE FROM `internal_communication_4`.`projects` WHERE(`project_id` = " + this.proID + "); "; MySqlCommand idused = new MySqlCommand(query, connection); MySqlDataReader MyReader3; MyReader3 = idused.ExecuteReader(); while (MyReader3.Read()) { } connection.Close(); //delete subject associated connection.Open(); string query7 = "DELETE FROM `internal_communication_4`.`subjects` WHERE(`Project_project_id` = " + this.proID + "); "; MySqlCommand comma = new MySqlCommand(query7, connection); MySqlDataReader MyReader6; MyReader6 = comma.ExecuteReader(); while (MyReader6.Read()) { } connection.Close(); for (int i = selectedItems2.Count - 1; i >= 0; i--) { project_list.Items.Remove(selectedItems2[i]); } projectDA.Save(proj); } else { } } else { MessageBox.Show("You must select a project"); } }
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); } }