Пример #1
0
        //lista todos os ingressos
        public List<Ticket> FindAll()
        {
            try
            {
                OpenConnection();
                Cmd = new SqlCommand("select * from Ticket order by PkAttraction");
                Dr = Cmd.ExecuteReader();
                List<Ticket> list = new List<Ticket>();
                while (Dr.Read())
                {
                    Ticket t = new Ticket();
                    t.PkAttraction = Convert.ToInt32(Dr["PkAttraction"]);
                    t.PkTicket = Convert.ToInt32(Dr["PkTicket"]);

                    list.Add(t);
                }
                return list;
            }
            catch
            {
                throw;
            }
            finally
            {
                CloseConnection();
            }
        }
Пример #2
0
 //atualiza quantidade de ingressos para o evento
 public void Update(Ticket a)
 {
     try
     {
         OpenConnection();
         Cmd = new SqlCommand("update Ticket set QuantityTicket = @v2 where PkAttraction = @v1", Con);
         Cmd.Parameters.AddWithValue("@v2", a.QuantityTicket);
         Cmd.Parameters.AddWithValue("@v1", a.PkAttraction);
         Cmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         throw new Exception("Erro ao atualizar quantidade de ingressos. " + ex.Message);
     }
     finally
     {
         CloseConnection();
     }
 }