Exemplo n.º 1
0
        private Sector CreateSectorFromReader(SqlDataReader reader)
        {
            Spoor s = spoorrepo.GetSpoor(Convert.ToInt16(reader["spoorid"]));

            try
            {
                Tram t = tramrepo.GetTram(Convert.ToInt16(reader["tramid"]));

                return(new Sector(Convert.ToInt32(reader["id"]),
                                  t,
                                  s,
                                  Convert.ToBoolean(reader["blokkade"]),
                                  Convert.ToBoolean(reader["beschikbaarheid"]),
                                  Convert.ToInt16(reader["rownumber"])
                                  ));
            }
            catch
            {
                return(new Sector(Convert.ToInt32(reader["id"]),
                                  s,
                                  Convert.ToBoolean(reader["blokkade"]),
                                  Convert.ToBoolean(reader["beschikbaarheid"]),
                                  Convert.ToInt16(reader["rownumber"])
                                  ));
            }
        }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Tram   tram1  = lbGroteDienst.SelectedItem as Tram;
            Tram   tram2  = lbKleineDienst.SelectedItem as Tram;
            string status = comboBox1.Text;
            int    i      = 0;

            switch (status)
            {
            case "Defect":
                i = 1;
                break;

            case "Dienst":
                i = 3;
                break;

            case "Remise":
                i = 4;
                break;
            }
            if (i != 0)
            {
                if (tram2 != null && i != 0)
                {
                    tramRepo.Update(tram2.id, i);
                }
            }
            if (tram1 != null && i != 0)
            {
                tramRepo.Update(tram1.id, i);
            }
        }
Exemplo n.º 3
0
        private void btnInvoerTramNr_Click(object sender, EventArgs e)
        {
            Tram   inrijdtram   = cbTram.SelectedItem as Tram;
            Spoor  inrijdspoor  = cbSpoor.SelectedItem as Spoor;
            Sector inrijdsector = cbSector.SelectedItem as Sector;


            if (inrijdsector != null && inrijdspoor != null && inrijdtram != null)
            {
                if (sectorRepo.CheckTram(inrijdtram) == false)
                {
                    sectorRepo.TramInrijden(inrijdtram, inrijdspoor, inrijdsector);
                    UpdateForm();
                    Simulatie();
                }
                else
                {
                    MessageBox.Show("deze tram moet eerst uitgereden worden");
                }
            }
            else
            {
                MessageBox.Show("Vul alle gegevens in");
            }
        }
Exemplo n.º 4
0
        public bool CheckTram(Tram tram)
        {
            List <Sector> returnSectoren = new List <Sector>();

            using (SqlConnection connection = Database.Connection)
            {
                string query = "select * from sector where tramid = @tramid";
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    command.Parameters.AddWithValue("tramid", tram.id);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            returnSectoren.Add(CreateSectorFromReader(reader));
                        }
                    }
                }
            }
            if (returnSectoren.Count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
 public Activiteit(DateTime beginDatum, DateTime eindDatum, int activiteitiD, Medewerker m, Tram t)
 {
     this.medewerker   = m;
     this.Tram         = t;
     this.BeginDatum   = beginDatum;
     this.EindDatum    = eindDatum;
     this.ActiviteitiD = activiteitiD;
 }
Exemplo n.º 6
0
 public Sector(int id, Tram tram, Spoor spoor, bool blokkade, bool beschikbaar, int rownumber)
 {
     this.rowNumber   = rownumber;
     this.id          = id;
     this.tram        = tram;
     this.spoor       = spoor;
     this.Blokkade    = blokkade;
     this.Beschikbaar = beschikbaar;
 }
Exemplo n.º 7
0
        public void GetTram()
        {
            Tram t = tramrepo.GetTramWithRFID(tbRFID.Text);

            if (t != null)
            {
                lbTramnr.Text = t.id.ToString();
            }
            this.VrijindrijdSpoor = spoorRepo.ZoekinrijdSpoor();
            this.VrijeSectoren    = sectorRepo.ZoekVrijSector(VrijindrijdSpoor[0]);
            lbSector.Text         = VrijeSectoren[0].id.ToString();
            lbNaarSpoor.Text      = VrijindrijdSpoor[0].id.ToString();
        }
Exemplo n.º 8
0
        private void btnTramUitrijden_Click(object sender, EventArgs e)
        {
            Tram uitrijdtram = cbTram.SelectedItem as Tram;

            if (uitrijdtram != null)
            {
                sectorRepo.TramUitrijden(sectorRepo.GetSector(cbTram.SelectedItem as Tram));
                UpdateForm();
                Simulatie();
            }
            else
            {
                MessageBox.Show("selecteer een tram");
            }
        }
Exemplo n.º 9
0
        private Activiteit CreateActiviteitFromReader(SqlDataReader reader)
        {
            MedewerkerRepository m          = new MedewerkerRepository(new SqlMedewerkerContext());
            Medewerker           medewerker = m.GetGebruiker(Convert.ToInt32(reader["medewerkerid"]));
            TramRepository       t          = new TramRepository(new SqlTramContext());
            Tram tram = t.GetTram(Convert.ToInt32(reader["tramid"]));

            return(new Activiteit(
                       Convert.ToInt32(reader["id"]),
                       Convert.ToDateTime(reader["begintijd"]),
                       Convert.ToDateTime(reader["eindtijd"]),
                       Convert.ToInt32(reader["activiteitid"]),
                       medewerker,
                       tram
                       ));
        }
Exemplo n.º 10
0
        public void TramInrijden(Tram tram, Spoor spoor, Sector sector)
        {
            using (SqlConnection connection = Database.Connection)
            {
                string query = "UPDATE sector SET spoorid= @spoorid,tramid =@tramid  WHERE id = @sectorid";

                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    command.Parameters.AddWithValue("sectorid", sector.id);
                    command.Parameters.AddWithValue("spoorid", spoor.id);
                    command.Parameters.AddWithValue("tramid", tram.id);


                    Convert.ToInt32(command.ExecuteNonQuery());
                }
            }
        }
Exemplo n.º 11
0
        public Tram GetTram(int id)
        {
            Tram ReturnTram = new Tram();

            using (SqlConnection connection = Database.Connection)
            {
                string query = "Select * FROM tram Where id = @id";
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    command.Parameters.AddWithValue("id", id);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ReturnTram = (CreateTramFromReader(reader));
                        }
                    }
                }
            }
            return(ReturnTram);
        }
Exemplo n.º 12
0
        public Sector GetSector(Tram tram)
        {
            Sector ReturnSector = new Sector();

            using (SqlConnection connection = Database.Connection)
            {
                string query = "Select * FROM Sector Where tramid = @id";
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    command.Parameters.AddWithValue("id", tram.id);
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            ReturnSector = (CreateSectorFromReader(reader));
                        }
                    }
                }
            }
            return(ReturnSector);
        }
Exemplo n.º 13
0
 public Tram Insert(Tram tram)
 {
     return(tramContext.Insert(tram));
 }
Exemplo n.º 14
0
 public Tram Insert(Tram tram)
 {
     throw new NotImplementedException();
 }