Пример #1
0
 public PatientEntryForm(string mode,int patientId)
 {
     InitializeComponent();
     if (mode == "Update")
     {
         Patient patient=patientManager.GetPatientById(patientId);
         patientsNameTextBox.Text = patient.Name;
         Doctor doctor=patientManager.GetDoctorByPatientId(patientId);
         GetDoctorsListInComboBox();
         doctorComboBox.Text = doctor.Name;
         List<Disease> patientDiseaseList=new List<Disease>();
         List<Disease> diseaseList = new List<Disease>();
         DiseaseManager diseaseManager=new DiseaseManager();
         patientDiseaseList=diseaseManager.GetDiseasesBypatientId(patientId);
         diseaseList = diseaseManager.GetDiseaseList();
         diseaseCheckedListBox.DataSource = null;
         diseaseCheckedListBox.DataSource = diseaseList;
         diseaseCheckedListBox.ValueMember = "Id";
         diseaseCheckedListBox.DisplayMember = "Name";
         for (int index = 0; index < diseaseList.Count; index++)
         {
             foreach (var patientIndex in patientDiseaseList)
             {
                if(diseaseList[index].Id==patientIndex.Id)
                {
                    diseaseCheckedListBox.SetItemChecked(index,true);
                    break;
                }
             }
         }
         this.mode = mode;
         this.patientId = patientId;
     }
     else
     {
         GetDoctorsListInComboBox();
         GetDiseaseListInDiseaseCheckedListBox();
     }
 }
 private void showDiseasesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (patientsListView.SelectedItems.Count > 0)
     {
         int patientId = int.Parse(patientsListView.SelectedItems[0].Tag.ToString());
         List<Disease> diseaseList = new List<Disease>();
         DiseaseManager diseaseManager = new DiseaseManager();
         diseaseList = diseaseManager.GetDiseasesBypatientId(patientId);
         DiseaseListForm diseaseListForm = new DiseaseListForm(diseaseList);
         diseaseListForm.Show();
     }
     else
     {
         MessageBox.Show("A row must be selected");
     }
 }