private void btnDelete_Click(object sender, EventArgs e)
        {
            PersonRepo p1 = new PersonRepo();

            p1.PersonID = Convert.ToInt32(this.txtPID.Text);

            DoctorRepo dr = new DoctorRepo();

            if (this.txtDoctorId.Text != "" && this.txtDoctorId.Text != null)
            {
                dr.DoctorID = Convert.ToInt32(this.txtDoctorId.Text);
            }

            EmployeeRepo er = new EmployeeRepo();

            er.EmpID = Convert.ToInt32(this.txtEmpId.Text);

            try
            {
                if (this.cmbDesignation.Text == "Doctor")
                {
                    // IF DOCTOR -> Delete from all table that contains doctor's reference first
                    CancelledAppointmentsRepo.RemoveParticularDoctorsAppointments(dr.DoctorID);
                    AppointmentRepo.RemoveParticularDoctorsAppointments(dr.DoctorID);
                    PatientDiseaseRepo.DeleteInfoBasedOnDoctor(dr.DoctorID);
                    LoginVerification.DeleteLoginInfo(er.EmpID);
                    // Afterwards delete from doctor table
                    dr.DeleteDoctor(dr.DoctorID);
                }

                int empdelete     = er.DeleteEmployee(er.EmpID);
                int persondeleted = p1.DeletePerson(p1.PersonID);

                this.PopulatePersonTable();
                MessageBox.Show("Successfully deleted!");
                this.ClearAll();
            }
            catch (Exception exc)
            {
                MessageBox.Show("error!" + exc);
            }
        }
Example #2
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.dgvDoctor.SelectedRows.Count != 1)
            {
                MessageBox.Show("Please Select A Row First");
                return;
            }
            if (MessageBox.Show("Are You Sure?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }
            string name     = this.dgvDoctor.CurrentRow.Cells["name"].Value.ToString();
            bool   decision = doctorRepo.DeleteDoctor(name);

            if (decision)
            {
                MessageBox.Show("Delete Confirmed");
                this.PopulatedGridView();
            }
            else
            {
                MessageBox.Show("Invalid Id");
            }
        }