示例#1
0
        private void ButtonVerlofUpd_Click(object sender, EventArgs e)
        {
            VerlofTab_validatie();

            if (comboBoxOpleiding.SelectedIndex < 1)
            {
                errorProviderOplInfoTab.SetError(buttonVerlofUpd, "Selecteer of creeër eerst een opleiding om deelnemer aan toe tevoegen.");
            }
            else if (IsValidVerlof && textBoxVerlofId.Text != "")
            {
                int dagId = int.Parse(textBoxVerlofId.Text);
                using (var ctx = new DataContext())
                {
                    NietOpleidingsDagen updDag = ctx.NietOpleidingsDagen.SingleOrDefault(x => x.Id == dagId);
                    if (dateTimePickerVerlof.Value.Date != updDag.Datum)
                    {
                        errorProviderOplInfoTab.SetError(dateTimePickerVerlof, "Om datum te veranderen voeg een nieuwe verlofdag toe en verwijder de oude indien nodig.");
                    }
                    else
                    {
                        updDag.Voormiddag = checkBoxVerlofVoormiddag.Checked;
                        updDag.Namiddag   = checkBoxVerlofNamiddag.Checked;
                        ctx.SaveChanges();

                        VerlofLijst = ctx.NietOpleidingsDagen.Include(x => x.OpleidingsInformatie).ToList();
                    }
                }
                ClearAll();
                LaadAlleListbox();
            }
            else if (textBoxVerlofId.Text == "")
            {
                errorProviderOplInfoTab.SetError(buttonVerlofUpd, "U probeert een nieuwe datum toe te voegen.");
            }
        }
示例#2
0
        private void ButtonVerlofAdd_Click(object sender, EventArgs e)
        {
            VerlofTab_validatie();

            //is deze datum al toegevoegd? ja -> update ipv toevoegen
            var verlofLijst = (from v in VerlofLijst
                               where v.OpleidingsInformatie.Id == Opleiding.Id
                               select v);

            verlofLijst = verlofLijst.OrderBy(v => v.Datum.Date);
            foreach (NietOpleidingsDagen item in verlofLijst)
            {
                if (item.Datum == dateTimePickerVerlof.Value.Date)
                {
                    errorProviderOplInfoTab.SetError(dateTimePickerVerlof, "Deze dag is al toegevoegd. Probeer update.");
                    IsValidVerlof = false;
                }
            }

            if (comboBoxOpleiding.SelectedIndex < 1)
            {
                errorProviderOplInfoTab.SetError(buttonVerlofAdd, "Selecteer of creeër eerst een opleiding om deelnemer aan toe tevoegen.");
            }
            else if (IsValidVerlof && textBoxVerlofId.Text == "")
            {
                using (var ctx = new DataContext())
                {
                    Opleiding = ctx.OpleidingsInformatie.SingleOrDefault(x => x.Id == Opleiding.Id);
                    NietOpleidingsDagen nieuweVerlofDag = new NietOpleidingsDagen
                    {
                        Datum                = dateTimePickerVerlof.Value.Date,
                        Voormiddag           = checkBoxVerlofVoormiddag.Checked,
                        Namiddag             = checkBoxVerlofNamiddag.Checked,
                        OpleidingsInformatie = Opleiding
                    };
                    ctx.NietOpleidingsDagen.Add(nieuweVerlofDag);
                    ctx.SaveChanges();

                    VerlofLijst = ctx.NietOpleidingsDagen.Include(x => x.OpleidingsInformatie).ToList();
                }
                textBoxVerlofId.Text = VerlofLijst.Last().Id.ToString();

                ClearAll();
                LaadAlleListbox();
            }
            else if (textBoxVerlofId.Text != "")
            {
                errorProviderOplInfoTab.SetError(buttonVerlofAdd, "U probeert te updaten.");
            }
        }
示例#3
0
        private void ListBoxFeestdag_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBoxFeestdag.SelectedIndex > 0)
            {
                NietOpleidingsDagen verlofDag = listBoxFeestdag.SelectedItem as NietOpleidingsDagen;
                textBoxVerlofId.Text             = verlofDag.Id.ToString();
                dateTimePickerVerlof.Value       = verlofDag.Datum.Date;
                checkBoxVerlofVoormiddag.Checked = verlofDag.Voormiddag;
                checkBoxVerlofNamiddag.Checked   = verlofDag.Namiddag;
            }
            else
            {
                errorProviderOplInfoTab.SetError(buttonVerlofAdd, string.Empty);

                textBoxVerlofId.Text             = "";
                dateTimePickerVerlof.Value       = DateTime.Today;
                checkBoxVerlofVoormiddag.Checked = true;
                checkBoxVerlofNamiddag.Checked   = true;
            }
        }