Ejemplo n.º 1
0
 public HistoricalChild(InformationOfDay i, Child c, Dictionary <string, string> d)
 {
     InitializeComponent();
     infoChild = i;
     child     = c;
     language  = d;
 }
        public override void Load()
        {
            try
            {
                if (File.Exists("listInformationOfDay.txt"))
                {
                    List <InformationOfDay> list  = new List <InformationOfDay>();
                    StreamReader            file  = File.OpenText("listInformationOfDay.txt");
                    string[]         data         = new string[14];
                    string[]         date         = new string[3];
                    string[]         timeSleepMor = new string[4];
                    string[]         timeSleepAft = new string[4];
                    string           line;
                    InformationOfDay info;

                    do
                    {
                        line = file.ReadLine();
                        if (line != null && line.Length > 1)
                        {
                            data         = line.Split('|');
                            date         = data[2].Split(',');
                            timeSleepMor = data[9].Split(',');
                            timeSleepMor = data[11].Split(',');

                            info = new InformationOfDay(Convert.ToInt32(data[0]),
                                                        Convert.ToInt32(data[3]), Convert.ToInt32(data[4]),
                                                        Convert.ToInt32(data[5]), data[12], data[13],
                                                        Convert.ToInt32(data[6]),
                                                        Convert.ToInt32(data[7]),
                                                        Convert.ToInt32(data[8]),
                                                        Convert.ToInt32(data[10]));
                            info.AddTimeSleepMor(Convert.ToInt32(timeSleepMor[0]),
                                                 Convert.ToInt32(timeSleepMor[1]),
                                                 Convert.ToInt32(timeSleepMor[2]),
                                                 Convert.ToInt32(timeSleepMor[3]));
                            info.AddTimeSleepAft(Convert.ToInt32(timeSleepAft[0]),
                                                 Convert.ToInt32(timeSleepAft[1]),
                                                 Convert.ToInt32(timeSleepAft[2]),
                                                 Convert.ToInt32(timeSleepAft[3]));
                            info.AddDaySave(Convert.ToInt32(date[0]),
                                            Convert.ToInt32(date[1]), Convert.ToInt32(date[2]));

                            info.SetMeal(data[1]);
                            list.Add(info);
                        }
                    } while (line != null);
                    file.Close();
                    listInfo = list;
                }
                else
                {
                    listInfo = new List <InformationOfDay>();
                }
            }
            catch (IOException e)
            {
                Console.WriteLine("Eror: " + e.Message);
            }
        }
 public void SetInformation(InformationOfDay d)
 {
     listInformationAllDays.Add(d);
     listInformationAllDays.Sort(CompareInformationByYear);
     listInformationAllDays.Sort(CompareInformationByMonth);
     f.SetList(listInformationAllDays);
     f.Save();
 }
 public int CompareInformationByMonth(InformationOfDay i1, InformationOfDay i2)
 {
     if (i2.GetDay().month == i1.GetDay().month)
     {
         return(CompareInformationByDay(i1, i2));
     }
     else
     {
         return(i2.GetDay().month - i1.GetDay().month);
     }
 }
 //Returns InformationOfChild of a certain date
 public InformationOfDay GetInformationOfAChildFromDate(Day d, int cod)
 {
     foreach (InformationOfDay i in GetInformationOfAChild(cod))
     {
         if ((i.GetDay().day == d.day) && (i.GetDay().month == d.month) &&
             (i.GetDay().year == d.year))
         {
             InformationOfDay info = i;
             return(info);
         }
     }
     return(null);
 }
        //Set the information of a child of a certain day, if that
        //information already exists, replace it with the new information
        public void SetEditInformation(InformationOfDay i)
        {
            bool found = false;

            for (int j = 0; j < listInformationAllDays.Count && !found; j++)
            {
                if ((i.GetCod() == listInformationAllDays[j].GetCod()) &&
                    (listInformationAllDays[j].GetDay().Equals(i.GetDay())))
                {
                    listInformationAllDays.Remove(listInformationAllDays[j]);
                    SetInformation(i);
                    found = true;
                }
            }
        }
Ejemplo n.º 7
0
        private void ShowChild_Load(object sender, EventArgs e)
        {
            this.Text = "BLIST - " + language["ShowC"];
            Day birth = listChildren.GetChildOfList(index).GetBirthday();
            Day today = new Day();

            lbAge.Text               = language["Age"];
            lbName.Text              = language["Name"];
            lbSurnames.Text          = language["Sur"];
            lbSex.Text               = language["Sex"];
            lbCod.Text               = language["Cod"];
            lbObservations.Text      = language["Obs"];
            lbAllergies.Text         = language["Aller"];
            lbMessageForSchool.Text  = language["MesS"];
            lbMessgeForHome.Text     = language["MesH"];
            lbInfoBeak.Text          = language["IEBr"];
            lbInfLunch.Text          = language["IELu"];
            lbInfSnack.Text          = language["IESn"];
            btDiet.Text              = language["Diet"];
            cbEatBreakAll.Text       = language["All"];
            cbEatBreakHalf.Text      = language["Half"];
            cbEatBreakLittle.Text    = language["Little"];
            cbEatLunchAll.Text       = language["All"];
            cbEatLunchHalf.Text      = language["Half"];
            cbEatLunchLittle.Text    = language["Little"];
            cbEatSnackAll.Text       = language["All"];
            cbEatSnackHalf.Text      = language["Half"];
            cbEatSnackLittle.Text    = language["Little"];
            lbDepositions.Text       = language["Depo"];
            lbDepositionsMor.Text    = language["Morn"];
            lbDepositionsAft.Text    = language["Aft"];
            lbSleepMor.Text          = language["Morn"];
            lbSleepAft.Text          = language["Aft"];
            lbSleep.Text             = language["Sleep"];
            cbDepositionsMorYes.Text = language["Y"];
            cbDepositionsAftYes.Text = language["Y"];
            cbSleepMorGood.Text      = language["Good"];
            cbSleepMorBad.Text       = language["Bad"];
            cbSleepAftGood.Text      = language["Good"];
            cbSleepAftBad.Text       = language["Bad"];
            lbSinceMor.Text          = language["Since"];
            lbSinceAft.Text          = language["Since"];
            lbUntilMor.Text          = language["Until"];
            lbUntilAft.Text          = language["Until"];
            btPrintA.Text            = language["PrintAll"];

            today.day   = time.Day;
            today.month = time.Month;
            today.year  = time.Year;

            foreach (InformationOfDay j in list.GetInformationOfAChild(index + 1))
            {
                cbDaysInformation.Items.Add(j.GetDayForShow());
            }

            tbBirthday.Text     = birth.day + "/" + birth.month + "/" + birth.year;
            tbName.Text         = listChildren.GetChildOfList(index).GetName();
            tbSurnames.Text     = listChildren.GetChildOfList(index).GetSurname();
            tbSex.Text          = listChildren.GetChildOfList(index).GetSex().ToString();
            tbCod.Text          = listChildren.GetChildOfList(index).GetCod().ToString();
            tbObservations.Text =
                listChildren.GetChildOfList(index).GetObservations();
            tbAllergies.Text =
                listChildren.GetChildOfList(index).GetAllergies();
            tbAge.Text     = listChildren.GetChildOfList(index).GetAge().ToString();
            lbTypeAge.Text = listChildren.GetChildOfList(index).GetTypeAge();

            tbFoodBreakfast.Text = meal.GetBreakfast();
            tbFoodLunch.Text     = meal.GetLunch();
            tbFoodSnack.Text     = meal.GetSnack();

            dtpSinceSleepMor.Format       = DateTimePickerFormat.Custom;
            dtpSinceSleepMor.CustomFormat = "HH : mm";
            dtpUntilSleepMor.Format       = DateTimePickerFormat.Custom;
            dtpUntilSleepMor.CustomFormat = "HH : mm";
            dtpSinceSleepAft.Format       = DateTimePickerFormat.Custom;
            dtpSinceSleepAft.CustomFormat = "HH : mm";
            dtpUntilSleepAft.Format       = DateTimePickerFormat.Custom;
            dtpUntilSleepAft.CustomFormat = "HH : mm";
            cbDaysInformation.Text        = time.Day + "/" + time.Month + "/" + time.Year;

            InformationOfDay information = list.GetInformationOfAChildFromDate(
                today, listChildren.GetChildOfList(index).GetCod());

            if (information != null)
            {
                if (information.GetEatAmoutB() == 1)
                {
                    cbEatBreakAll.CheckState = CheckState.Checked;
                }
                else if (information.GetEatAmoutB() == 2)
                {
                    cbEatBreakHalf.CheckState = CheckState.Checked;
                }
                else if (information.GetEatAmoutB() == 3)
                {
                    cbEatBreakLittle.CheckState = CheckState.Checked;
                }

                if (information.GetEatAmoutL() == 1)
                {
                    cbEatLunchAll.CheckState = CheckState.Checked;
                }
                else if (information.GetEatAmoutL() == 2)
                {
                    cbEatLunchHalf.CheckState = CheckState.Checked;
                }
                else if (information.GetEatAmoutL() == 3)
                {
                    cbEatLunchLittle.CheckState = CheckState.Checked;
                }

                if (information.GetEatAmoutS() == 1)
                {
                    cbEatSnackAll.CheckState = CheckState.Checked;
                }
                else if (information.GetEatAmoutS() == 2)
                {
                    cbEatSnackHalf.CheckState = CheckState.Checked;
                }
                else if (information.GetEatAmoutS() == 3)
                {
                    cbEatSnackLittle.CheckState = CheckState.Checked;
                }

                switch (information.GetDepositionsMor())
                {
                case 1:
                    cbDepositionsMorYes.CheckState = CheckState.Checked;
                    break;

                case 2:
                    cbDepositionsMorNo.CheckState = CheckState.Checked;
                    break;

                default:
                    break;
                }

                switch (information.GetDepositionsAft())
                {
                case 1: cbDepositionsAftYes.CheckState = CheckState.Checked;
                    break;

                case 2: cbDepositionsAftNo.CheckState = CheckState.Checked;
                    break;

                default:
                    break;
                }

                switch (information.GetSleepMor())
                {
                case 1:
                    cbSleepMorGood.CheckState = CheckState.Checked;
                    break;

                case 2:
                    cbSleepMorBad.CheckState = CheckState.Checked;
                    break;

                default:
                    break;
                }

                switch (information.GetSleepAft())
                {
                case 1:
                    cbSleepAftGood.CheckState = CheckState.Checked;
                    break;

                case 2:
                    cbSleepAftBad.CheckState = CheckState.Checked;
                    break;

                default:
                    break;
                }


                tbMessageForHome.Text   = information.GetMessageForHome();
                tbMessageForSchool.Text = information.GetMessageForSchool();
            }
        }
Ejemplo n.º 8
0
        private void btOk_Click(object sender, EventArgs e)
        {
            Day today = new Day();

            today.day   = time.Day;
            today.month = time.Month;
            today.year  = time.Year;

            int eatB = cbEatBreakAll.Checked ? 1 : cbEatBreakHalf.Checked ? 2
                : cbEatBreakLittle.Checked ? 3 : 0;
            int eatL = cbEatLunchAll.Checked ? 1 : cbEatLunchHalf.Checked ? 2
                : cbEatLunchLittle.Checked ? 3 : 0;
            int eatS = cbEatSnackAll.Checked ? 1 : cbEatSnackHalf.Checked ? 2
                : cbEatSnackLittle.Checked ? 3 : 0;
            int deposMor = cbDepositionsMorYes.Checked ? 1 : cbDepositionsMorNo.Checked ? 2 : 0;
            int deposAft = cbDepositionsAftYes.Checked ? 1 : cbDepositionsAftNo.Checked ? 2 : 0;
            int sleepMor = cbSleepMorGood.Checked ? 1 : cbSleepMorBad.Checked ? 2 : 0;
            int sleepAft = cbSleepAftGood.Checked ? 1 : cbSleepAftBad.Checked ? 2 : 0;

            InformationOfDay information = new InformationOfDay(
                Convert.ToInt32(tbCod.Text), eatB, eatL, eatS,
                tbMessageForHome.Text, tbMessageForSchool.Text,
                deposMor, deposAft, sleepMor, sleepMor);
            TimeSleep timMor1 = new TimeSleep();
            TimeSleep timMor2 = new TimeSleep();
            TimeSleep timAft1 = new TimeSleep();
            TimeSleep timAft2 = new TimeSleep();
            Day       t;

            timMor1.hour = dtpSinceSleepMor.Checked ?
                           dtpSinceSleepMor.Value.Hour : 0;
            timMor1.minute = dtpSinceSleepMor.Checked ?
                             dtpSinceSleepMor.Value.Minute : 0;
            timMor2.hour = dtpUntilSleepMor.Checked ?
                           dtpUntilSleepMor.Value.Hour : 0;
            timMor2.minute = dtpUntilSleepMor.Checked ?
                             dtpUntilSleepMor.Value.Minute : 0;
            information.AddTimeSleepMor(timMor1.hour,
                                        timMor1.minute, timMor2.hour, timMor2.minute);

            timAft1.hour = dtpSinceSleepAft.Checked ?
                           dtpSinceSleepAft.Value.Hour : 0;
            timAft1.minute = dtpSinceSleepAft.Checked ?
                             dtpSinceSleepAft.Value.Minute : 0;
            timAft2.hour = dtpUntilSleepAft.Checked ?
                           dtpSinceSleepAft.Value.Hour : 0;
            timAft2.minute = dtpUntilSleepAft.Checked ?
                             dtpSinceSleepAft.Value.Minute : 0;
            information.AddTimeSleepAft(timAft1.hour,
                                        timAft1.minute, timAft2.hour, timAft2.minute);

            t.day   = time.Day;
            t.month = time.Month;
            t.year  = time.Year;
            information.SetDay(t);
            information.SetMeal(meal.GetBreakfast() + "?"
                                + meal.GetLunch() + "?" + meal.GetSnack());

            InformationOfDay info = list.GetInformationOfAChildFromDate(
                today, listChildren.GetChildOfList(index).GetCod());

            if (info == null)
            {
                list.SetInformation(information);
            }

            else
            {
                list.SetEditInformation(information);
            }

            this.Close();
        }
 public int CompareInformationByYear(InformationOfDay i1, InformationOfDay i2)
 {
     return(i2.GetDay().year - i1.GetDay().year);
 }
 public int CompareInformationByDay(InformationOfDay i1, InformationOfDay i2)
 {
     return(i2.GetDay().day - i1.GetDay().day);
 }
 public int CompareInformation(InformationOfDay i1, InformationOfDay i2)
 {
     return(i1.GetCod() - i2.GetCod());
 }