Exemple #1
0
        public doctorEdit(doctor nd)
        {
            InitializeComponent();
            d = nd;
            familyNameTextBox.Text = d.family_name;
            nameTextBox.Text       = d.name;
            fatherNameTextBox.Text = d.father_name;
            //posTextBox.Text = d.doctor_position.position;
            List <string> specs = new List <string>();

            foreach (var item in db.doctor_specialization)
            {
                specs.Add(item.specialization);
            }
            spec1ComboBox.BindingContext = new BindingContext();
            spec1ComboBox.DataSource     = specs;
            spec2ComboBox.BindingContext = new BindingContext();
            spec2ComboBox.DataSource     = specs;
            spec1ComboBox.Enabled        = false;
            spec2ComboBox.Enabled        = false;
            List <string> docPos = new List <string>();

            for (int i = 0; i < db.doctor_position.ToList().Count; i++)
            {
                docPos.Add(db.doctor_position.ToList()[i].position);
            }
            posComboBox.DataSource   = docPos;
            posComboBox.SelectedItem = d.doctor_position.position;
            //qualifTextBox.Text = Convert.ToString(d.qualification);
            qualifNumericUpDown.Enabled = notNullCheckBox.Checked;
            //spec2ComboBox.Enabled = notNullSpecCheckBox.Checked;
            if (nd.qualification != null)
            {
                notNullCheckBox.Checked     = true;
                qualifNumericUpDown.Enabled = true;
                qualifNumericUpDown.Value   = Convert.ToDecimal(nd.qualification);
            }
            else
            {
                notNullCheckBox.Checked     = false;
                qualifNumericUpDown.Enabled = false;
            }
            List <doctor_to_specialization> dspecs = db.doctor_to_specialization.Where(p => p.docID == d.id).ToList();

            spec1ComboBox.SelectedItem = dspecs[0].doctor_specialization.specialization;
            if (dspecs.Count == 2)
            {
                spec2ComboBox.SelectedItem = dspecs[1].doctor_specialization.specialization;
            }
            en = (d == null) || (dspecs.Count != 2);
        }
Exemple #2
0
 private void resultAddBtn_Click(object sender, EventArgs e)
 {
     using (resultEdit frm = new resultEdit())
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             //patient p = db.patients.Where(p1 => (p1.family_name == frm.patientFamilyNameTextBox.Text) && (p1.name == frm.patientNameTextBox.Text) && (p1.father_name == frm.patientFatherNameTextBox.Text)).FirstOrDefault();
             string locPatient       = frm.patientComboBox.SelectedItem.ToString();
             char   sp               = ' ';
             int    pos              = locPatient.IndexOf(sp);
             string locPatientFamily = locPatient.Substring(0, pos);
             string locPatientName   = locPatient.Substring(pos + 1);
             locPatient     = locPatientName;
             pos            = locPatient.IndexOf(sp);
             locPatientName = locPatient.Substring(0, pos);
             string  locPatientFather = locPatient.Substring(pos + 1);
             patient p = db.patients.Where(p1 => (p1.family_name == locPatientFamily) && (p1.name == locPatientName) && (p1.father_name == locPatientFather)).FirstOrDefault();
             //doctor d = db.doctors.Where(d1 => (d1.family_name == frm.doctorFamilyNameTextBox.Text) && (d1.name == frm.doctorNameTextBox.Text) && (d1.father_name == frm.doctorFatherNameTextBox.Text)).FirstOrDefault();
             string locDoctor = frm.doctorComboBox.SelectedItem.ToString();
             pos = locDoctor.IndexOf(sp);
             string locDoctorFamily = locDoctor.Substring(0, pos);
             string locDoctorName   = locDoctor.Substring(pos + 1);
             locDoctor     = locDoctorName;
             pos           = locDoctor.IndexOf(sp);
             locDoctorName = locDoctor.Substring(0, pos);
             string locDoctorFather = locDoctor.Substring(pos + 1);
             doctor d    = db.doctors.Where(d1 => (d1.family_name == locDoctorFamily) && (d1.name == locDoctorName) && (d1.father_name == locDoctorFather)).FirstOrDefault();
             string diag = frm.diagnosisTextBox.Text;
             diag = diagnosisCutSpacesAndUnprintChars(diag);
             if (dbm.AddResult(p.id, d.id, diag, frm.outpatientCheckBox.Checked, Convert.ToInt32(frm.countDaysTextBox.Text), frm.clinicalAccountCheckBox.Checked, frm.startDateTimePicker.Value, frm.predictedDateTimePicker.Value, frm.factDateTimePicker.Value, frm.notNullCheckBox.Checked) == null)
             {
                 MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
             //resultDataGridView.DataSource = db.results.ToList();
             //resultDataGridView.DataSource = dbm.GetExtResults();
             reloadData();
             resultDataGridView.DataSource = db.ExtResults.ToList();
         }
     }
 }
Exemple #3
0
        private void resultDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(resultDataGridView.CurrentRow.Cells[0].Value);

            //14.15
            if (e.ColumnIndex == 14)
            {
                //Edit
                result locr = db.results.Find(id);
                using (resultEdit frm = new resultEdit(locr))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        //patient p = db.patients.Where(p1 => (p1.family_name == frm.patientFamilyNameTextBox.Text) && (p1.name == frm.patientNameTextBox.Text) && (p1.father_name == frm.patientFatherNameTextBox.Text)).FirstOrDefault();
                        string locPatient       = frm.patientComboBox.SelectedItem.ToString();
                        char   sp               = ' ';
                        int    pos              = locPatient.IndexOf(sp);
                        string locPatientFamily = locPatient.Substring(0, pos);
                        string locPatientName   = locPatient.Substring(pos + 1);
                        locPatient     = locPatientName;
                        pos            = locPatient.IndexOf(sp);
                        locPatientName = locPatient.Substring(0, pos);
                        string  locPatientFather = locPatient.Substring(pos + 1);
                        patient p = db.patients.Where(p1 => (p1.family_name == locPatientFamily) && (p1.name == locPatientName) && (p1.father_name == locPatientFather)).FirstOrDefault();
                        //doctor d = db.doctors.Where(d1 => (d1.family_name == frm.doctorFamilyNameTextBox.Text) && (d1.name == frm.doctorNameTextBox.Text) && (d1.father_name == frm.doctorFatherNameTextBox.Text)).FirstOrDefault();
                        string locDoctor = frm.doctorComboBox.SelectedItem.ToString();
                        pos = locDoctor.IndexOf(sp);
                        string locDoctorFamily = locDoctor.Substring(0, pos);
                        string locDoctorName   = locDoctor.Substring(pos + 1);
                        locDoctor     = locDoctorName;
                        pos           = locDoctor.IndexOf(sp);
                        locDoctorName = locDoctor.Substring(0, pos);
                        string locDoctorFather = locDoctor.Substring(pos + 1);
                        doctor d    = db.doctors.Where(d1 => (d1.family_name == locDoctorFamily) && (d1.name == locDoctorName) && (d1.father_name == locDoctorFather)).FirstOrDefault();
                        string diag = frm.diagnosisTextBox.Text;
                        diag = diagnosisCutSpacesAndUnprintChars(diag);
                        if (dbm.EditResult(id, p.id, d.id, diag, frm.outpatientCheckBox.Checked, Convert.ToInt32(frm.countDaysTextBox.Text), frm.clinicalAccountCheckBox.Checked, frm.startDateTimePicker.Value, frm.predictedDateTimePicker.Value, frm.factDateTimePicker.Value, frm.notNullCheckBox.Checked))
                        {
                            MessageBox.Show("OK", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        //resultDataGridView.DataSource = db.results.ToList();
                        //resultDataGridView.DataSource = dbm.GetExtResults();
                        reloadData();
                        resultDataGridView.DataSource = db.ExtResults.ToList();
                    }
                }
            }
            if (e.ColumnIndex == 15)
            {
                //Delete
                if (dbm.DeleteResult(id))
                {
                    MessageBox.Show("OK", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                //resultDataGridView.DataSource = db.results.ToList();
                //resultDataGridView.DataSource = dbm.GetExtResults();
                reloadData();
                resultDataGridView.DataSource = db.ExtResults.ToList();
            }
        }
Exemple #4
0
        private void doctorsDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            int id = Convert.ToInt32(doctorsDataGridView.CurrentRow.Cells[0].Value);

            //7.8
            if (e.ColumnIndex == 7)
            {
                doctor locd = db.doctors.Find(id);
                //Edit
                using (doctorEdit frm = new doctorEdit(locd))
                {
                    if (frm.ShowDialog() == DialogResult.OK)
                    {
                        string familyName = frm.familyNameTextBox.Text;
                        string name       = frm.nameTextBox.Text;
                        string fatherName = frm.fatherNameTextBox.Text;
                        familyName = cutSpacesAndUnprintChars(familyName);
                        name       = cutSpacesAndUnprintChars(name);
                        fatherName = cutSpacesAndUnprintChars(fatherName);
                        if (dbm.EditDoctor(id, familyName, name, fatherName, db.doctor_position.Where(p => p.position.Equals(frm.posComboBox.SelectedItem.ToString())).First().id, frm.qualifNumericUpDown.Value, frm.notNullCheckBox.Checked))
                        {
                            string spec2    = frm.spec2ComboBox.SelectedItem.ToString();
                            bool   nullSpec = frm.notNullSpecCheckBox.Checked;
                            int    id2      = db.doctor_specialization.Where(p => p.specialization.Equals(spec2)).FirstOrDefault().id;
                            int    did      = db.doctors.Where(p => (p.family_name.ToLower().Equals(familyName.ToLower())) && (p.name.ToLower().Equals(name.ToLower())) && (p.father_name.ToLower().Equals(fatherName.ToLower()))).FirstOrDefault().id;
                            if (nullSpec)
                            {
                                if (dbm.AddDoctorNewSpecialization(did, id2))
                                {
                                    MessageBox.Show("OK", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                                else
                                {
                                    MessageBox.Show("Error with Specializations", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                            else
                            {
                                MessageBox.Show("OK", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        //doctorsDataGridView.DataSource = db.doctors.ToList();
                        //doctorsDataGridView.DataSource = dbm.GetExtDoctors();
                        reloadData();
                        doctorsDataGridView.DataSource = db.ExtDoctors.ToList();
                    }
                }
            }
            if (e.ColumnIndex == 8)
            {
                //Delete
                if (dbm.DeleteDoctor(id))
                {
                    MessageBox.Show("OK", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Error", "Info", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                //doctorsDataGridView.DataSource = db.doctors.ToList();
                //doctorsDataGridView.DataSource = dbm.GetExtDoctors();
                reloadData();
                doctorsDataGridView.DataSource = db.ExtDoctors.ToList();
            }
        }