private void btnNewHosp_Click(object sender, EventArgs e) { if (dbQuery.checkHosp(Convert.ToInt64(txtCnp.Text))) { MessageBox.Show("Patient currently hospitalized\nCannot create new hospitalization", "Warning"); return; } NewHospForm newHosp = new NewHospForm(patientDetail, docID); this.Hide(); newHosp.ShowDialog(); this.Show(); }
private void btnAdd_Click(object sender, EventArgs e) { if (txtFirstName.Text == String.Empty) { MessageBox.Show("First name cannot be empty", "Warning"); return; } if (txtLastName.Text == String.Empty) { MessageBox.Show("Last name cannot be empty", "Warning"); return; } if (ctxtSex.Text == String.Empty) { MessageBox.Show("Please select a gender", "Warning"); return; } if (dtpBirth.Text == String.Empty) { MessageBox.Show("Please enter birth date", "Warning"); return; } if (MessageBox.Show("Are you sure all information is correct?", "Warning", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { dbQuery.addPatient(Convert.ToInt64(txtCnp.Text), txtFirstName.Text, txtLastName.Text, dtpBirth.Value.ToString("yyyy-MM-dd"), ctxtSex.Text, txtAPP.Text, txtAPF.Text, txtAHC.Text); MessageBox.Show("Patient succesfully added to the database", "Success"); if (MessageBox.Show("Would you like to hospitalize patient now?", "New hospitalization", MessageBoxButtons.YesNo) == DialogResult.Yes) { List <String> details = new List <string>(); details.Add(txtCnp.Text); details.Add(txtFirstName.Text + " " + txtLastName.Text); details.Add(dtpBirth.Value.ToString("dd-MM-yyyy")); details.Add(ctxtSex.Text); NewHospForm hospPatient = new NewHospForm(details, MainMenu.currentUser.id); hospPatient.ShowDialog(); } this.Close(); } catch (Exception ex) { MessageBox.Show("Patient could not be added\nError:\n\n" + ex.ToString(), "Failure"); } } }