Exemple #1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            MarikinaOpticalEntities dbContext = new MarikinaOpticalEntities();
            var patientLens   = "";
            var isOpticalLens = false;
            var isContactLens = false;

            if (String.IsNullOrWhiteSpace(txtSerialNo.Text))
            {
                MessageBox.Show("Please input Rx - Serial No.!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (IsOpticalSerialNoExisting() || IsContactSerialNoExisting())
            {
                MessageBox.Show("Serial No. is already used!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (cbOpticalLens.Checked == true || cbContactLens.Checked == true)
            {
                if (cbOpticalLens.Checked == true)
                {
                    if (String.IsNullOrWhiteSpace(cmbOLRS.Text) && String.IsNullOrWhiteSpace(cmbOLRC.Text) && String.IsNullOrWhiteSpace(cmbOLRA.Text) &&
                        String.IsNullOrWhiteSpace(cmbOLRPD.Text) && String.IsNullOrWhiteSpace(cmbOLRADD.Text) && String.IsNullOrWhiteSpace(cmbOLRPRISM.Text) &&
                        String.IsNullOrWhiteSpace(cmbOLRBASE.Text) && String.IsNullOrWhiteSpace(cmbOLROH.Text) && String.IsNullOrWhiteSpace(cmbOLLS.Text) &&
                        String.IsNullOrWhiteSpace(cmbOLLC.Text) && String.IsNullOrWhiteSpace(cmbOLLA.Text) && String.IsNullOrWhiteSpace(cmbOLLPD.Text) &&
                        String.IsNullOrWhiteSpace(cmbOLLADD.Text) && String.IsNullOrWhiteSpace(cmbOLLPRISM.Text) && String.IsNullOrWhiteSpace(cmbOLLBASE.Text) &&
                        String.IsNullOrWhiteSpace(cmbOLLOH.Text))
                    {
                        MessageBox.Show("Please select a valid value in the box!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    isOpticalLens = true;
                }

                if (cbContactLens.Checked == true)
                {
                    if (String.IsNullOrWhiteSpace(cmbCLRS.Text) && String.IsNullOrWhiteSpace(cmbCLRC.Text) && String.IsNullOrWhiteSpace(cmbCLRA.Text) &&
                        String.IsNullOrWhiteSpace(cmbCLRBC.Text) && String.IsNullOrWhiteSpace(cmbCLRDptr.Text) && String.IsNullOrWhiteSpace(cmbCLLS.Text) &&
                        String.IsNullOrWhiteSpace(cmbCLLC.Text) && String.IsNullOrWhiteSpace(cmbCLLA.Text) && String.IsNullOrWhiteSpace(cmbCLLBC.Text) &&
                        String.IsNullOrWhiteSpace(cmbCLLDptr.Text))
                    {
                        MessageBox.Show("Please select a valid value in the box!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    isContactLens = true;
                }

                DialogResult result = MessageBox.Show("Do you want to 'Submit' this Rx to" + txtSerialNo.Text + " - " + txtName.Text + "?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    if (isOpticalLens == true)
                    {
                        patientLens = " Optical Lens ";
                        dbContext.InsertOpticalLensDoctors(txtSerialNo.Text, txtOpthometrist.Text, txtOptician.Text);

                        dbContext.InsertOpticalLensRemarks(txtSerialNo.Text, txtRemarks.Text);

                        dbContext.InsertOpticalLens(txtSerialNo.Text, cmbOLRS.Text, cmbOLRC.Text, cmbOLRA.Text, cmbOLRPD.Text,
                                                    cmbOLRADD.Text, cmbOLRPRISM.Text, cmbOLRBASE.Text, cmbOLROH.Text, cmbOLLS.Text,
                                                    cmbOLLC.Text, cmbOLLA.Text, cmbOLLPD.Text, cmbOLLADD.Text, cmbOLLPRISM.Text, cmbOLLBASE.Text,
                                                    cmbOLLOH.Text, DateTime.Now);

                        dbContext.InsertPatientsOpticalLens(txtSerialNo.Text, Convert.ToInt32(lblPatientId.Text));
                    }

                    if (isContactLens == true)
                    {
                        patientLens = " Contact Lens ";
                        dbContext.InsertContactLensDoctors(txtSerialNo.Text, txtOpthometrist.Text, txtOptician.Text);

                        dbContext.InsertContactLensRemarks(txtSerialNo.Text, txtRemarks.Text);

                        dbContext.InsertContactLens(txtSerialNo.Text, cmbCLRS.Text, cmbCLRC.Text, cmbCLRA.Text,
                                                    cmbCLRBC.Text, cmbCLRDptr.Text, cmbCLLS.Text, cmbCLLC.Text,
                                                    cmbCLLA.Text, cmbCLLBC.Text, cmbCLLDptr.Text, DateTime.Now);

                        dbContext.InsertPatientsContactLens(txtSerialNo.Text, Convert.ToInt32(lblPatientId.Text));
                    }

                    if (cbOpticalLens.Checked == true && cbContactLens.Checked == true)
                    {
                        patientLens = " Optical and Contact Lens ";
                    }

                    MessageBox.Show("Patient Rx" + patientLens + "has been saved successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Clear();
                }
            }
            else
            {
                MessageBox.Show("Please select lens for Patient!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }