Ejemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            //prompt
            var confirmResult = MessageBox.Show("Are you sure you want to update this prescription?", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (confirmResult == DialogResult.Yes)
            {
                try
                {
                    string physicianID = cboPhysicianID.SelectedValue.ToString();
                    try
                    {
                        epv.SetError(cboPhysicianID, "");
                        epv.SetError(cboDrug, "");
                        epv.SetError(txtRefill, "");
                        string NDCPackageCode = cboDrug.SelectedValue.ToString();
                        string totalRefills   = txtRefill.Text.Trim();
                        if (int.Parse(totalRefills) > 0)
                        {
                            DateTime time = dtpPrescribed.Value;

                            //Send it throug the datatier
                            PharmacyDataTier bPharm = new PharmacyDataTier();
                            DataSet          ds1    = new DataSet();
                            ds1 = bPharm.UpdatePrescription(myPrescriptionID, NDCPackageCode, myPatientID, physicianID, totalRefills, time);
                            MessageBox.Show("prescription sucesfully updated", "Completed", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            epv.SetError(txtRefill, "Cannot insert a lower than 0 fulfillments");
                            MessageBox.Show("Cannot insert a lower than 1 fulfillments", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    catch (Exception ex)
                    {
                        string myException = ex.ToString();
                        if (myException.Contains("Cannot insert a lower Total Refills than refills have been completed"))
                        {
                            epv.SetError(txtRefill, "Cannot insert a lower Total fulfillments than fulfillments have been completed");
                            MessageBox.Show("Cannot insert a lower Total fulfillments than fulfillments have been completed", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        else
                        {
                            epv.SetError(cboDrug, "Must select a drug in the list.");
                            MessageBox.Show("Must select a drug in the list.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }
                catch (Exception)
                {
                    epv.SetError(cboPhysicianID, "Must select a physician in the list.");
                    MessageBox.Show("Must select a physician in the list.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
            }
        }