コード例 #1
0
        private void open_family_file() //opens the file of family members and adds them to the combo box in appoinments tab and the Listbox in family tab
        {
            using (var myFile = new System.IO.StreamReader(@"C:\Users\Fate\Desktop\Programs\Visual Studio\DoctorHelper\DoctorHelper\bin\Debug\family.txt"))
            {
                string line = myFile.ReadLine();

                while (line != null)
                {
                    fam      = new Family();
                    fam.name = line;
                    line     = myFile.ReadLine();

                    while (line != null && line.Contains("=") != false)
                    {
                        meds = seperate_meds(line);
                        fam.meds.Add(meds);
                        fam.display_meds = fam.display_meds + meds.name + ", ";
                        line             = myFile.ReadLine();
                    }

                    while (line != null && line.Contains("+") != false)
                    {
                        doc      = new Doctors();
                        doc.name = line.Remove(0, 1);
                        fam.doctors.Add(doc);
                        fam.display_doctors = fam.display_doctors + doc.name + ", ";
                        line = myFile.ReadLine();
                    }

                    members.Add(fam);
                    Family_ListBox.Items.Add(fam);
                }
                myFile.Close();
            }
        }
コード例 #2
0
        private Medications seperate_meds(string line) //seperates the string of medicine into objects when being read in from a file
        {
            Medications medicine = new Medications();

            line = line.Remove(0, 1);
            string[] split_meds = line.Split(' ');

            medicine.name        = split_meds[0];
            medicine.dosage      = split_meds[1];
            medicine.refill_date = split_meds[2];

            return(medicine);
        }
コード例 #3
0
        public void Add_Family_Click(object sender, RoutedEventArgs e) //all the logic for adding a family member
        {
            fam = new Family();

            if (fam_name.Text == "") //if no name is given, return
            {
                MessageBox.Show("No name given.");
                return;
            }

            fam.name = fam_name.Text;

            if (selected_doctors.Items.Count != 0) //loops through selected_doctors and adds them to the family member's list of doctors
            {
                for (int i = 0; i < selected_doctors.Items.Count; i++)
                {
                    doc = new Doctors();
                    doc = selected_doctors.Items[i] as Doctors;
                    fam.doctors.Add(doc);
                    fam.display_doctors += doc.name + ", ";
                }
            }

            if (Meds.Items.Count != 0) //if the family member has medications, they are added to the family member's list of medications
            {
                for (int i = 0; i < Meds.Items.Count; i++)
                {
                    meds = new Medications();
                    meds = Meds.Items[i] as Medications;
                    fam.meds.Add(meds);
                    fam.display_meds += meds.name + ", ";
                }
            }

            Family_ListBox.Items.Add(fam);
            members.Add(fam);
            Meds.Items.Clear();
            selected_doctors.Items.Clear();
            fam_name.Text = "";
            save_family_to_file();
            add_family.Content = "Add Family Member";
        }
コード例 #4
0
        private void Meds_Click(object sender, RoutedEventArgs e) //adds medications to the display list
        {
            string      med     = med_name.Text;
            string      dosage  = dosage_textbox.Text;
            string      date    = null;
            Medications new_med = new Medications();

            if (date_selected.SelectedDate.HasValue)
            {
                date = date_selected.SelectedDate.Value.ToString("MM/dd/yyyy");
            }
            else
            {
                date = "__/__/____";
            }

            if (dosage_textbox.Text == "")
            {
                new_med.dosage = "~";
            }
            else
            {
                new_med.dosage = dosage;
            }

            if (med.Contains(" "))
            {
                med.Replace(" ", "_");
            }
            new_med.name        = med;
            new_med.refill_date = date;

            new_meds_list.Add(new_med);
            Meds.Items.Add(new_med);

            med_name.Text              = "";
            dosage_textbox.Text        = "";
            date_selected.SelectedDate = null;
        }
コード例 #5
0
 private void remove_meds_Click(object sender, RoutedEventArgs e) //removes the selected medication from the medications box for adding family members
 {
     meds = (Medications)Meds.SelectedItem;
     Meds.Items.Remove(meds);
     remove_meds.Visibility = Visibility.Collapsed;
 }