Exemple #1
0
        public void UpdateNrLocuri(int idSpectacol, int nrLocuriVandute)
        {
            IDbConnection connection = DButils.getConnection(props);

            using (var comm = connection.CreateCommand())
            {
                comm.CommandText = "update Spectacole set NrLocuri=NrLocuri-@locVandute,NrLocuriVandute=NrLocuriVandute+@locVandute where IdSpectacol=@idSpec";
                var paramNrLocV = comm.CreateParameter();
                paramNrLocV.ParameterName = "@locVandute";
                paramNrLocV.Value         = nrLocuriVandute;
                comm.Parameters.Add(paramNrLocV);

                var paramIdSpec = comm.CreateParameter();
                paramIdSpec.ParameterName = "@idSpec";
                paramIdSpec.Value         = idSpectacol;
                comm.Parameters.Add(paramIdSpec);

                try
                {
                    comm.ExecuteNonQuery();
                    Console.WriteLine("update realizat");
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Exemple #2
0
        public ICollection <Spectacol> GetAll()
        {
            IDbConnection     connection = DButils.getConnection(props);
            IList <Spectacol> spectacole = new List <Spectacol>();

            using (var command = connection.CreateCommand())
            {
                command.CommandText = "select a.IdArtist,a.Nume,s.IdSpectacol,s.DataSpectacol,s.OraSpectacol,s.LocSpectacol,s.NrLocuri,s.NrLocuriVandute from Spectacole s JOIN Artisti a on s.IdArtist = a.IdArtist";

                using (var dataReader = command.ExecuteReader())
                {
                    while (dataReader.Read())
                    {
                        int    idArtist        = dataReader.GetInt32(0);
                        string numeArtist      = dataReader.GetString(1);
                        int    idSpec          = dataReader.GetInt32(2);
                        string dataSpec        = dataReader.GetString(3);
                        string oraSpec         = dataReader.GetString(4);
                        string locSpec         = dataReader.GetString(5);
                        int    nrLocuri        = dataReader.GetInt32(6);
                        int    nrLocuriVandute = dataReader.GetInt32(7);

                        Spectacol spec = new Spectacol(idSpec, new Artist(idArtist, numeArtist), dataSpec, oraSpec, locSpec, nrLocuri, nrLocuriVandute);
                        spectacole.Add(spec);
                    }
                }
            }

            return(spectacole);
        }
Exemple #3
0
        public void Add(Bilet entity)
        {
            var connection = DButils.getConnection(props);

            using (var comm = connection.CreateCommand())
            {
                comm.CommandText = "insert into Bilete(IdClient,IdSpectacol,NrLocuri) values(@idClient,@idSpectacol,@nrLocuri)";
                var idC = comm.CreateParameter();
                idC.ParameterName = "@idClient";
                idC.Value         = entity.Client.IdClient;
                comm.Parameters.Add(idC);

                var idS = comm.CreateParameter();
                idS.ParameterName = "@idSpectacol";
                idS.Value         = entity.Spectacol.IdSpectacol;
                comm.Parameters.Add(idS);

                var nrL = comm.CreateParameter();
                nrL.ParameterName = "@nrLocuri";
                nrL.Value         = entity.NrLocuriCumparate;
                comm.Parameters.Add(nrL);

                try
                {
                    comm.ExecuteNonQuery();
                    Console.WriteLine("Adaugare bilet efectuata!");
                }
                catch (Exception e)
                {
                    Console.WriteLine("Eroare bilet " + e.Message);
                }
            }
        }
Exemple #4
0
        public Boolean exists(String userName, String pass)
        {
            IDbConnection connection = DButils.getConnection(props);

            using (var command = connection.CreateCommand())
            {
                command.CommandText = "select Count(*) as Existance from Useri where UserName = @user and Password = @pass";
                IDbDataParameter param = command.CreateParameter();
                param.ParameterName = "@user";
                param.Value         = userName;
                command.Parameters.Add(param);

                IDbDataParameter password = command.CreateParameter();
                password.ParameterName = "@pass";
                password.Value         = pass;
                command.Parameters.Add(password);

                using (var dataReader = command.ExecuteReader())
                {
                    if (dataReader.Read())
                    {
                        int existance = dataReader.GetInt16(0);
                        if (existance != 0)
                        {
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Exemple #5
0
        public void Add(Client entity)
        {
            var connection = DButils.getConnection(props);

            using (var comm = connection.CreateCommand())
            {
                comm.CommandText = "insert into Clienti(IdClient,Nume) values(@idClient,@nume)";
                var idClient = comm.CreateParameter();
                idClient.ParameterName = "@idClient";
                idClient.Value         = entity.IdClient;
                comm.Parameters.Add(idClient);

                var numeC = comm.CreateParameter();
                numeC.ParameterName = "@nume";
                numeC.Value         = entity.Nume;
                comm.Parameters.Add(numeC);

                try
                {
                    comm.ExecuteNonQuery();
                    Console.WriteLine("Adaugare efectuata!");
                }
                catch (Exception e)
                {
                    Console.WriteLine("Eroare adaugare " + e.Message);
                }
            }
        }