Exemple #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if (comboBox1 != null && comboBox2 != null)
            {
                using (var context = new AanwezigheidslijstContext())
                {
                    var tijd = new Tijdsregistraties();

                    tijd.DateTime = dateTimePicker1.Value;

                    var checkbox   = comboBox1.SelectedItem as Opleidingsinformatie;
                    var nietOplDag = context.Opleidingsinformatie.SingleOrDefault(a => a.Opleiding == checkbox.Opleiding);
                    tijd.Opleidingsinformatie = nietOplDag;

                    var checkbox2 = comboBox2.SelectedItem as Deelnemers;
                    var deelOpl   = context.Deelnemers.SingleOrDefault(a => a.Id == checkbox2.Id);
                    tijd.Deelnemers = deelOpl;

                    context.Tijdsregistraties.Add(tijd);
                    context.SaveChanges();
                    MessageBox.Show("Tijd geregistreerd");
                }
                this.Close();
            }
            else
            {
                MessageBox.Show("Gelieve de gegevens correct in te vullen");
            }
        }
Exemple #2
0
        private void ListBoxTijd_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listBoxTijd.SelectedIndex > -1)
            {
                Tijdsregistraties tijdr = listBoxTijd.SelectedItem as Tijdsregistraties;
                Deelnemers        deeln = tijdr.Deelnemers as Deelnemers;
                var tijdPerDeeln        = from t in TijdLijst
                                          join opl in OplLijst on t.OpleidingsInformatie.Id equals opl.Id
                                          where t.Deelnemers.Id == deeln.Id
                                          select t;

                textBoxTijdNaamDeeln.Text = deeln.Naam;

                int tijdIndex = tijdPerDeeln.Select((item, index) => new { item, index }).Single(p => p.item.Id == tijdr.Id).index;

                if (tijdIndex % 2 == 0)
                {
                    textBoxTijdBadgeStatus.Text = "Badge In";
                    textBoxTijdStip.Text        = "";
                    checkBoxTijdVoorm.Checked   = false;
                    checkBoxTijdNam.Checked     = false;
                }
                else
                {
                    textBoxTijdBadgeStatus.Text = "Badge Out";
                    TimeSpan tijdAanwezig = tijdPerDeeln.ElementAt(tijdIndex).DateTime - tijdPerDeeln.ElementAt(tijdIndex - 1).DateTime;
                    textBoxTijdStip.Text = tijdAanwezig.ToString();

                    if (tijdAanwezig > new TimeSpan(8, 0, 0))
                    {
                        checkBoxTijdVoorm.Checked = true;
                        checkBoxTijdNam.Checked   = true;
                    }
                    else if (tijdAanwezig > new TimeSpan(3, 0, 0) && tijdPerDeeln.ElementAt(tijdIndex).DateTime.Hour < 14)
                    {
                        checkBoxTijdVoorm.Checked = true;
                        checkBoxTijdNam.Checked   = false;
                    }
                    else if (tijdAanwezig > new TimeSpan(3, 0, 0) && tijdPerDeeln.ElementAt(tijdIndex).DateTime.Hour > 14)
                    {
                        checkBoxTijdVoorm.Checked = false;
                        checkBoxTijdNam.Checked   = true;
                    }
                    else
                    {
                        checkBoxTijdVoorm.Checked = false;
                        checkBoxTijdNam.Checked   = false;
                    }
                }
            }
            else
            {
                textBoxTijdStip.Text        = "";
                textBoxTijdBadgeStatus.Text = "";
                checkBoxTijdNam.Checked     = false;
                checkBoxTijdVoorm.Checked   = false;
            }
        }
Exemple #3
0
 private void Button3_Click(object sender, EventArgs e)
 {
     using (var ctx = new AanwezigheidslijstContext())
     {
         var b = listBox1.SelectedItem as Tijdsregistraties;
         Tijdsregistraties tijd = ctx.Tijdsregistraties.FirstOrDefault(a => a.Id == b.Id);
         ctx.Tijdsregistraties.Remove(tijd);
         MessageBox.Show("Tijdsregistratie verwijdert");
         ctx.SaveChanges();
     }
 }