//Edit a child private void btOK_Click(object sender, EventArgs e) { Day birthday = new Day(); DateTime now = DateTime.Today; string allergies = ""; bool addCo = false; bool goodDate = false; bool failDate = false; string[] b = tbBirthday.Text.Split('/'); birthday.day = Convert.ToInt32(b[0]); birthday.month = Convert.ToInt32(b[1]); birthday.year = Convert.ToInt32(b[2]); //Convert the event of the checkBox into a string //so that it can be stored in the file 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 { if (clbVegFrt.CheckedItems.Count > 0) { 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 (dtpAge.Checked) { 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; } else { failDate = true; } } if (failDate) { WarningInvalidDate w = new WarningInvalidDate(language["InvDate"]); w.Show(); } else { ModifyChild child = new ModifyChild(editList); child.SetModifiedChild(child.SetEditChild( tbName.Text.ToUpper(), tbSurnames.Text.ToUpper(), tbObservation.Text, allergies, Convert.ToChar(tbSex.Text.ToUpper()), birthday, Convert.ToInt32(tbCod.Text)), index); this.Close(); } } }
//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(); } } }