Beispiel #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            switch (toolStripComboBox1.SelectedIndex)
            {
            case 0:
                MessageBox.Show("No table selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case 1:
                using (addEditAddress frm = new addEditAddress(null, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        AddressBindingSource.DataSource = db.Addresses.ToList();
                    }
                }
                break;

            case 2:
                using (addEditDisease frm = new addEditDisease(null, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        diseaseBindingSource.DataSource = db.Diseases.ToList();
                    }
                }
                break;

            case 3:
                using (addEditPatient frm = new addEditPatient(null, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        PatientBindingSource.DataSource = db.Patients.ToList();
                        AddressBindingSource.DataSource = db.Addresses.ToList();
                    }
                }
                break;

            case 4:
                using (addEditDoctor frm = new addEditDoctor(null, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        DoctorBindingSource.DataSource  = db.Doctors.ToList();
                        AddressBindingSource.DataSource = db.Addresses.ToList();
                    }
                }
                break;

            case 5:
                using (addEditPrescription frm = new addEditPrescription(null, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        PrescriptionBindingSource.DataSource = db.Prescriptions.ToList();
                    }
                }
                break;

            case 6:
                using (addEditAppointment frm = new addEditAppointment(null, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        AppointmentBindingSource.DataSource = db.Appointments.ToList();
                    }
                }
                break;

            case 7:
                using (addEditPDR frm = new addEditPDR(null, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        PdrBindingSource.DataSource          = db.PatientDiseaseRelations.ToList();
                        AppointmentBindingSource.DataSource  = db.Appointments.ToList();
                        PrescriptionBindingSource.DataSource = db.Prescriptions.ToList();
                    }
                }
                break;

            default:
                MessageBox.Show("Cant Add on View Table", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;
            }
            dataGridView.Refresh();
            Program.detachAll();
        }
Beispiel #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            switch (toolStripComboBox1.SelectedIndex)
            {
            case 0:
                MessageBox.Show("No table selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;

            case 1:
                if (AddressBindingSource.Current == null)
                {
                    MessageBox.Show("No Address selected for editing", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                using (addEditAddress frm = new addEditAddress(AddressBindingSource.Current as Address, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        AddressBindingSource.DataSource = db.Addresses.ToList();
                    }
                }
                break;

            case 2:
                if (diseaseBindingSource.Current == null)
                {
                    MessageBox.Show("No Disease selected for editing", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                using (addEditDisease frm = new addEditDisease(diseaseBindingSource.Current as Disease, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        diseaseBindingSource.DataSource = db.Diseases.ToList();
                    }
                }
                break;

            case 3:
                if (PatientBindingSource.Current == null)
                {
                    MessageBox.Show("No Patient selected for editing", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                using (addEditPatient frm = new addEditPatient(PatientBindingSource.Current as Patient, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        PatientBindingSource.DataSource = db.Patients.ToList();
                        AddressBindingSource.DataSource = db.Addresses.ToList();
                    }
                }
                break;

            case 4:
                if (DoctorBindingSource.Current == null)
                {
                    MessageBox.Show("No Doctor selected for editing", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                using (addEditDoctor frm = new addEditDoctor(DoctorBindingSource.Current as Doctor, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        DoctorBindingSource.DataSource  = db.Doctors.ToList();
                        AddressBindingSource.DataSource = db.Addresses.ToList();
                    }
                }
                break;

            case 5:
                if (PrescriptionBindingSource.Current == null)
                {
                    MessageBox.Show("No Prescription selected for editing", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                using (addEditPrescription frm = new addEditPrescription(PrescriptionBindingSource.Current as Prescription, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        PrescriptionBindingSource.DataSource = db.Prescriptions.ToList();
                    }
                }
                break;

            case 6:
                if (AppointmentBindingSource.Current == null)
                {
                    MessageBox.Show("No Appointment selected for editing", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                using (addEditAppointment frm = new addEditAppointment(AppointmentBindingSource.Current as Appointment, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        AppointmentBindingSource.DataSource = db.Appointments.ToList();
                    }
                }
                break;

            case 7:
                if (PdrBindingSource.Current == null)
                {
                    MessageBox.Show("No PDR selected for editing", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                using (addEditPDR frm = new addEditPDR(PdrBindingSource.Current as PatientDiseaseRelation, this))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        PdrBindingSource.DataSource          = db.PatientDiseaseRelations.ToList();
                        AppointmentBindingSource.DataSource  = db.Appointments.ToList();
                        PrescriptionBindingSource.DataSource = db.Prescriptions.ToList();
                    }
                }
                break;

            default:
                MessageBox.Show("Cant Edit on View Table", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                break;
            }
            dataGridView.Refresh();
            Program.detachAll();
        }