Exemplo n.º 1
0
        private List <Eveniment> getAllEvenimente(string user)
        {
            var dbCon = DBConnection.Instance();

            dbCon.DatabaseName = "mybd";
            if (dbCon.IsConnect())
            {
                List <Eveniment> evenimenteleObtinute = new List <Eveniment>();
                dbCon.Connection.Open();
                string query  = $"SELECT * FROM mydb.evenimentele_useri WHERE loginNume = '{user}';";
                var    cmd    = new MySqlCommand(query, dbCon.Connection);
                var    reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    int      idEveniment        = reader.GetInt16(0);
                    string   numeEveniment      = reader.GetString(1);
                    string   tipEveniment       = reader.GetString(2);
                    string   descriereEveniment = reader.GetString(3);
                    DateTime inceputEveniment   = reader.GetDateTime(4);
                    DateTime sfarsitEveniment   = reader.GetDateTime(5);

                    Eveniment ev = new Eveniment(idEveniment, numeEveniment, descriereEveniment,
                                                 tipEveniment, inceputEveniment, sfarsitEveniment);
                    evenimenteleObtinute.Add(ev);
                }
                dbCon.Close();
                return(evenimenteleObtinute);
            }
            else
            {
                dbCon.Close();
                return(null);
            }
        }
Exemplo n.º 2
0
 public object ToggleEveniment(Eveniment ev)
 {
     if (ev.tip == "unic")
     {
         ev.tip = "terminat";
     }
     else if (ev.tip == "terminat")
     {
         ev.tip = "unic";
     }
     return(ev);
 }