Exemplo n.º 1
0
 void FetchData()
 {
     using (SQLiteConnection connection = new SQLiteConnection(Properties.Settings.Default.connString))
         connection.Open();
         SQLiteCommand cmd = new SQLiteCommand("SELECT ID_Mitarbeiter, FirstName, LastName, ID_Team FROM Mitarbeiter", connection);
         SQLiteCommand cmd_Team = new SQLiteCommand("SELECT * FROM Teams", connection);
         using (SQLiteDataReader reader = cmd.ExecuteReader())
         { 
             while (reader.Read())
             {
                 int ID_Mitarbeiter = reader.GetInt32(0);
                 string Vorname = reader.GetString(1);
                 string Nachname = reader.GetString(2);
                 int ID_Team = reader.GetInt32(3);
                 OC_Mitarbeiter.Add(new Mitarbeiter(ID_Mitarbeiter, Vorname, Nachname, ID_Team));
             }
         }
         using (SQLiteDataReader reader = cmd_Team.ExecuteReader())
         {
             while (reader.Read())
             {
                 int ID_Team = reader.GetInt32(0);
                 string Name = reader.GetString(1);
                 OC_Team.Add(new Team(ID_Team, Name));
             }
         }
     }
Exemplo n.º 2
0
 private void CreateNewRow(object param)
 {
     string Parameter = (string) param;
     if (Parameter == "Mitarbeiter")
     {
         OC_Mitarbeiter.Add(new Mitarbeiter(99999, "?", "?", 1));
     }
     else if (Parameter == "Team")
     {
         OC_Team.Add(new Team(99999, "?"));
     }
     else
     {
         MessageBox.Show("falscher Parameter");
     }
 }
Exemplo n.º 3
0
 private void DeleteEntryVoid(object param)
 {
     string Parameter = (string)param;
     if (Parameter == "Mitarbeiter")
     {
         try
         {
             using (SQLiteConnection connection = new SQLiteConnection(Properties.Settings.Default.connString))
             {
                 connection.Open();
                 SQLiteCommand cmd = new SQLiteCommand("DELETE FROM Mitarbeiter WHERE ID_Mitarbeiter= '" + MySelectedMitarbeiter.ID_Mitarbeiter + "'", connection);
                 cmd.ExecuteNonQuery();
             }
         }
         catch (Exception exception)
         {
             Console.WriteLine(exception);
         }
         OC_Mitarbeiter.Remove(OC_Mitarbeiter.Where(i => i.ID_Mitarbeiter == MySelectedMitarbeiter.ID_Mitarbeiter).Single());
     }
     else if (Parameter == "Team")
     {
         try
         {
             using (SQLiteConnection connection = new SQLiteConnection(Properties.Settings.Default.connString))
             {
                 connection.Open();
                 SQLiteCommand cmd = new SQLiteCommand("DELETE FROM Teams WHERE ID_Team= '" + MySelectedTeam.ID_Team + "'", connection);
                 cmd.ExecuteNonQuery();
             }
         }
         catch (Exception exception)
         {
             Console.WriteLine(exception);
         }
         OC_Team.Remove(OC_Team.Where(i => i.ID_Team == MySelectedTeam.ID_Team).Single());
     }
     else
     {
         MessageBox.Show("falscher Parameter");
     }
 }