//Populates patient details in textboxes private void Dropdown_1_SelectionChangeCommitted(object sender, EventArgs e) { Patient_Database.patientSelectedGenerateLetter(Dropdown_1, Input_1, Input_2, Input_3, Input_4, Input_5, GP_Letter); //Gets all initial consultations of patient DataTable initialConsultations = Consultation_Database.CheckInitialConsultations(Dropdown_1); int consCount = initialConsultations.Rows.Count; //Depending on how many initial consultations will depend on the text displayed if (consCount == 0) { Input_6.Text = "No Initial Consultation"; } else if (consCount == 1) { Input_6.Text = Convert.ToString(initialConsultations.Rows[0]["Display Text"]); } else if (consCount > 1) { Input_6.Text = "More than one Initial Consultation"; } //Enables controls to generate letters Initial_Letter.Enabled = true; Initial_Letter_MHLP.Enabled = true; No_Contact_Letter.Enabled = true; GP_Letter.Enabled = true; }
//No contant letter is based on the initial consultation. If thre is more than 1 initial consultation then //furethr validation is required private void No_Contact_Letter_Click(object sender, EventArgs e) { //Gets all initial Consultations from patient and stores the id and date in a dictionary DataTable initialConsultations = Consultation_Database.CheckInitialConsultations(Dropdown_1); if (initialConsultations.Rows.Count == 0) { MessageBox.Show("There is no initial consultations for This patient. Please add a new initial " + "consultation to generate this letter", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //If only one consultation then generate letter else if (initialConsultations.Rows.Count == 1) { consultationDate = Convert.ToString(initialConsultations.Rows[0]["Date"]); WriteLetter("No Contact.dat"); } //Changing the form to allow user to choose which consultation will be in the letter else if (initialConsultations.Rows.Count > 1) { //Sets trigger so other events know we are choosing the initial consultation ChooseInitialConsultation = true; //Adjusting form height and setting unwanted objects to visible = false this.Height = 190; this.Width = 352; Sort_Lists.Visible = false; label2.Visible = false; label4.Visible = false; label5.Visible = false; Input_1.Visible = false; Input_2.Visible = false; Input_3.Visible = false; //Changes the header label label1.Visible = false; label3.Visible = true; label6.Visible = true; //Centering the dropdown and moving the back button into view Dropdown_1.Visible = false; Dropdown_2.Visible = true; UserLabel.Location = new Point(20, 133); Back.Location = new Point(239, 122); //Making visible the accept consultation button and cancel button Accept_Consultation.Visible = true; Cancel.Visible = true; //Changes the datasource of the dropdown2 Dropdown_2.DataSource = null; Dropdown_2.DataSource = initialConsultations; Dropdown_2.DisplayMember = "Display Text"; Dropdown_2.ValueMember = "Date"; } }