Ejemplo n.º 1
0
        //insert new child in list and save this
        public void SetListWithNewChild(Child c, ListOfChildren list)
        {
            List <Child> children = list.GetList();

            children.Add(c);
            list.SetList(children);
            list.SaveListOfChildren();
        }
Ejemplo n.º 2
0
        private void Form3_Load(object sender, EventArgs e)
        {
            SelectLenguage sl = new SelectLenguage();

            if (sl.ShowDialog() == DialogResult.OK)
            {
                language = sl.language;
            }
            else
            {
                this.Close();
            }

            if (listChildren.GetList() != null)
            {
                listChildren.SetNumDiferentChildren(listChildren.GetList(),
                                                    ref totChild, ref totWom, ref totMen);

                foreach (string i in listChildren.ListForShow())
                {
                    clbChildren.Items.Add(i);
                }

                btRefresh.Text       = language["Refr"];
                btAdd.Text           = language["AddC"];
                btNormalDiet.Text    = language["Diet"];
                btAllergiesDiet.Text = language["DietA"];
                btDelete.Text        = language["DelC"];
                btEdit.Text          = language["EditC"];
                btShow.Text          = language["ShowC"];
                lbTotalChildren.Text = language["TotC"];
                lbTotalFemale.Text   = language["TotW"];
                lbTotalMens.Text     = language["TotM"];

                tbTotalChildren.Text = totChild.ToString();
                tbTotalFemale.Text   = totWom.ToString();
                tbTotalMens.Text     = totMen.ToString();
            }
        }
Ejemplo n.º 3
0
        public RemoveChild(int index, ListOfChildren list)
        {
            list.listChildren.RemoveAt(index);
            List <Child> children = list.GetList();

            foreach (Child i in children)
            {
                if (i.GetCod() > index + 1)
                {
                    i.SetCod(i.GetCod() - 1);
                }
            }

            list.SaveListOfChildren();
        }
Ejemplo n.º 4
0
        //Add a new child
        private void btOK_Click(object sender, EventArgs e)
        {
            string allergies = "";
            bool   addCo     = false;

            //Convert the event of the checkBox into a string
            //so that it can be stored in the file
            for (int i = 0; i < clbVegFrt.Items.Count; i++)
            {
                if (clbVegFrt.GetItemChecked(i))
                {
                    if (addCo)
                    {
                        allergies += ",";
                        addCo      = false;
                    }
                    allergies += clbVegFrt.Items[i].ToString();
                    addCo      = true;
                }
            }
            if ((tbName.Text == "") | (tbSurnames.Text == "")
                | (tbSex.Text == ""))
            {
                WarningDataWhite w = new WarningDataWhite(language["WFilesWhite"]);
                w.Show();
            }
            if (tbSex.Text.ToLower().ToString() != "f" &&
                tbSex.Text.ToLower().ToString() != "m")
            {
                WarningInvalidSex w = new WarningInvalidSex(language["WInvSex"]);
                w.Show();
            }
            else
            {
                Day      birthday = new Day();
                DateTime now      = DateTime.Today;
                bool     goodDate = false;

                if (dtpAge.Value.Year == now.Date.Year)
                {
                    if (dtpAge.Value.Month == now.Date.Month)
                    {
                        if (dtpAge.Value.Day < now.Date.Day)
                        {
                            goodDate = true;
                        }
                    }
                    else if (dtpAge.Value.Month < now.Date.Month)
                    {
                        goodDate = true;
                    }
                }
                else if (dtpAge.Value.Year < now.Date.Year)
                {
                    goodDate = true;
                }

                if (goodDate)
                {
                    birthday.day   = dtpAge.Value.Day;
                    birthday.month = dtpAge.Value.Month;
                    birthday.year  = dtpAge.Value.Year;
                    AddChild newChild = new AddChild();
                    newChild.SetListWithNewChild(newChild.SetNewChild(
                                                     tbName.Text.ToUpper(), tbSurnames.Text.ToUpper(),
                                                     tbObservation.Text, allergies,
                                                     Convert.ToChar(tbSex.Text.ToUpper()), birthday,
                                                     saveList.GetList().Count + 1), saveList);

                    this.Close();
                }
                else
                {
                    WarningInvalidDate w = new WarningInvalidDate(language["WInvDate"]);
                    w.Show();
                }
            }
        }
Ejemplo n.º 5
0
 public ModifyChild(ListOfChildren l)
 {
     listChildren = l.GetList();
     list         = l;
 }