private void frmSearchPrescriptions_Activated(object sender, EventArgs e) { //get the values string fname = txtPatientFName.Text.Trim(); string lname = txtPatientLName.Text.Trim(); string patientID = txtPatientID.Text.Trim(); //Fill patient datagrid PharmacyDataTier bPharm = new PharmacyDataTier(); DataSet ds1 = new DataSet(); ds1 = bPharm.GetPatient(fname, lname, patientID); dgvPatients.DataSource = ds1.Tables[0]; }
private void frmPatientPrescription_Load(object sender, EventArgs e) { try { //fills the state combo box cboState.DataSource = StateManager.getStates(); cboState.DisplayMember = "abbreviation"; cboState.ValueMember = "abbreviation"; //gets the patient ID from the previous form myPatientID = frmSearchPrescriptions.myID; //fills the boxes with current patient information PharmacyDataTier aPharm = new PharmacyDataTier(); DataSet ds = new DataSet(); ds = aPharm.GetPatient("", "", myPatientID); if (ds.Tables[0].Rows.Count > 0) { txtPatientID.Text = ds.Tables[0].Rows[0]["Patient ID"].ToString().Trim(); txtFName.Text = ds.Tables[0].Rows[0]["First Name"].ToString().Trim(); txtMInit.Text = ds.Tables[0].Rows[0]["Middle Initial"].ToString().Trim(); txtLName.Text = ds.Tables[0].Rows[0]["Last Name"].ToString().Trim(); dtpDOB.Value = DateTime.Parse(ds.Tables[0].Rows[0]["Date of Birth"].ToString().Trim()); cboGender.Text = ds.Tables[0].Rows[0]["Gender"].ToString().Trim(); txtStreet1.Text = ds.Tables[0].Rows[0]["Street 1"].ToString().Trim(); txtStreet2.Text = ds.Tables[0].Rows[0]["Street 2"].ToString().Trim(); txtCity.Text = ds.Tables[0].Rows[0]["City"].ToString().Trim(); cboState.SelectedValue = ds.Tables[0].Rows[0]["State"].ToString().Trim(); txtZip.Text = ds.Tables[0].Rows[0]["zip"].ToString().Trim(); txtHomePhone.Text = ds.Tables[0].Rows[0]["Home Phone"].ToString().Trim(); txtWorkPhone.Text = ds.Tables[0].Rows[0]["Work Phone"].ToString().Trim(); txtCellPhone.Text = ds.Tables[0].Rows[0]["Cell Phone"].ToString().Trim(); txtEmail.Text = ds.Tables[0].Rows[0]["Email"].ToString().Trim(); } //fills the datagrid UpdatePrescriptionDGV(); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { var confirmResult = MessageBox.Show("This will also delete all prescriptions and refills attached to this patient. Are you sure you want to delete this patient?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (confirmResult == DialogResult.Yes) { try { DataGridViewRow row = dgvPatients.SelectedRows[0]; string patientID; patientID = row.Cells[0].Value.ToString(); //Send it throug the datatier PharmacyDataTier bPharm = new PharmacyDataTier(); DataSet ds1 = new DataSet(); ds1 = bPharm.DeletePatient(patientID); MessageBox.Show("Patient deleted successfully", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information); try { //get the values string fname = txtPatientFName.Text.Trim(); string lname = txtPatientLName.Text.Trim(); string patientID2 = txtPatientID.Text.Trim(); //Fill patient datagrid PharmacyDataTier cPharm = new PharmacyDataTier(); DataSet ds2 = new DataSet(); ds1 = bPharm.GetPatient(fname, lname, patientID2); dgvPatients.DataSource = ds1.Tables[0]; } catch (Exception ex) { MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { string myException = ex.ToString(); MessageBox.Show(myException, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { } }