Beispiel #1
0
        public void saveBilet(Bilet b)
        {
            try
            {
                IDbConnection con = factory.createConnection();
                con.Open();
                using (var com = con.CreateCommand())
                {
                    com.CommandText = "INSERT INTO BILET VALUES (@p1, @p2, @p3)";
                    var param = com.CreateParameter();
                    param.ParameterName = "@p1";
                    param.Value         = b.Customer;
                    com.Parameters.Add(param);

                    var param2 = com.CreateParameter();
                    param2.ParameterName = "@p2";
                    param2.Value         = b.ConcertID;
                    com.Parameters.Add(param2);

                    var param3 = com.CreateParameter();
                    param3.ParameterName = "@p3";
                    param3.Value         = b.Seats;
                    com.Parameters.Add(param3);


                    com.ExecuteNonQuery();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Beispiel #2
0
        public int CheckLoginCredentials(string user, string pass)
        {
            int rez = -1;

            try
            {
                IDbConnection con = utile.createConnection();

                using (IDbCommand cmd = con.CreateCommand())
                {
                    con.Open();
                    cmd.CommandText = "SELECT ID FROM USER WHERE NUME = @p1 and PAROLA = @p2";
                    var par1 = cmd.CreateParameter();
                    par1.Value         = user;
                    par1.ParameterName = "@p1";
                    cmd.Parameters.Add(par1);

                    var par2 = cmd.CreateParameter();
                    par2.Value         = pass;
                    par2.ParameterName = "@p2";
                    cmd.Parameters.Add(par2);

                    int aux = (int)cmd.ExecuteScalar();
                    if (aux > 0)
                    {
                        rez = aux;
                        Console.Write("USER REPO - Utilizator gasit\n");
                    }
                    else
                    {
                        Console.WriteLine("USER REPO - Autentificare nereusita\n");
                    }
                }
            }
            catch (Exception e)
            {
                Console.Write(e.Message);
            }
            return(rez);
        }