//write the studentdata

        public void Student_records()
        {
            File.Delete(path);
            foreach (Student item in smi)
            {
                ImmunizationModel mn = checking(item.age);
                try
                {
                    if (!(mn.Equals(null)))
                    {
                        if (!File.Exists(path))
                        {
                            // Create a file to write to.
                            using (StreamWriter sw = File.CreateText(path))
                            {
                                sw.Write(item.id + ",");
                                sw.Write(item.firstName + ",");
                                sw.Write(item.lastName + ",");
                                sw.Write(item.age + ",");
                                sw.Write(item.email + ",");
                                sw.Write(item.date_of_birth + ",");

                                sw.WriteLine("Required vaccination:::: " + mn.vaccination);
                            }
                        }
                        else
                        {
                            using (StreamWriter sw = File.AppendText(path))
                            {
                                sw.Write(item.id + ",");
                                sw.Write(item.firstName + ",");
                                sw.Write(item.lastName + ",");
                                sw.Write(item.age + ",");
                                sw.Write(item.email + ",");
                                sw.Write(item.date_of_birth + ",");

                                sw.WriteLine("Required vaccination:::: " + mn.vaccination);
                            }
                        }
                    }
                }
                catch (NullReferenceException e)
                {
                    Console.WriteLine(e);
                }
            }
            ImmunizationReminder imr = new ImmunizationReminder();
            AnnualReminder       anr = new AnnualReminder();
        }
Esempio n. 2
0
 public void read_I_Details()
 {
     foreach (var imd in imuneDetails)
     {
         string[] I_details = imd.Split(",");
         im             = new ImmunizationModel();
         im.age         = Convert.ToInt32(I_details[0]);
         im.vaccination = I_details[1];
         L_IM.Add(im);
     }
     foreach (var stu in stu_Details)
     {
         string[] s_details = stu.Split(",");
         Student  st        = (Student)Factory.Get("STUDENT");
         st.age           = Convert.ToInt32(s_details[3]);
         st.date_of_birth = Convert.ToDateTime(s_details[6]);
         st.firstName     = s_details[1];
         st.lastName      = s_details[2];
         st.email         = s_details[4];
         std.Add(st);
     }
 }