Exemplo n.º 1
0
        // wyswietl wydarzenia dla danego konta
        private void showUserEvents(int id)
        {
            AccountManagement am = new AccountManagement();

            EventList.BeginUpdate();

            EventList.Items.Clear(); // wyczysc liste

            // wstaw do niej wszystkie wydarzenia uzytkownika
            foreach (EventRegistration er in am.GetEventRegistrationList(id))
            {
                EventItem eventItem = availableEvents[er.eventId];
                EventList.Items.Add(er.eventRegistrationId + " - " +
                                    eventItem.name + " - " + er.foodType + " - " + er.type + " - " + er.confirmation);
            }

            EventList.EndUpdate();
        }
Exemplo n.º 2
0
        // pobiera słownik, w którym kluczem jest id eventu, a wartością są informacje o tym evencie
        public Dictionary <int, EventItem> GetEventMap()
        {
            Dictionary <int, EventItem> dict = new Dictionary <int, EventItem>();

            DbUtil db = new DbUtil();

            string connStr = db.getConnStr();

            MySqlConnection conn = null;

            try
            {
                conn = new MySqlConnection(connStr);
                conn.Open();

                string       query = "SELECT id, name, agenda, date FROM events";
                MySqlCommand cmd   = new MySqlCommand(query, conn);

                MySqlDataReader reader = cmd.ExecuteReader();

                // sprawdzanie każdej znalezionej krotki
                while (reader.Read())
                {
                    EventItem ev = new EventItem();

                    ev.id     = reader.GetInt32(0);
                    ev.name   = reader.GetString(1);
                    ev.agenda = reader.GetString(2);
                    ev.date   = reader.GetDateTime(3);

                    dict.Add(ev.id, ev);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                conn.Close();
            }

            return(dict);
        }