Exemple #1
0
        /// <summary>
        /// Creates a customer in the database
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public int CreateCustomer(Customer customer)
        {
            int affectedRows;

            dataAccessLayer.BeginTransaction();
            try
            {
                dataAccessLayer.CreateParameters(7);
                dataAccessLayer.AddParameters(0, "ID", customer.ID);
                dataAccessLayer.AddParameters(1, "CustomerName", customer.name);
                dataAccessLayer.AddParameters(2, "Email", customer.email);
                dataAccessLayer.AddParameters(3, "Phone", customer.phone);
                dataAccessLayer.AddParameters(4, "Address", customer.Address);
                dataAccessLayer.AddParameters(5, "Gender", customer.Gender);
                dataAccessLayer.AddParameters(6, "Age", customer.Age);

                affectedRows = dataAccessLayer.ExecuteQuery("spCreateCustomer", CommandType.StoredProcedure);

                dataAccessLayer.CommitTransaction();
            }
            catch (Exception e)
            {
                dataAccessLayer.RollbackTransaction();
                Console.WriteLine(e);
                return(-1);
            }

            return(affectedRows);
        }
Exemple #2
0
        public int createShow(Show show)
        {
            try
            {
                dataAccessLayer.BeginTransaction();

                dataAccessLayer.CreateParameters(6);
                dataAccessLayer.AddParameters(0, "Title", show.title);
                dataAccessLayer.AddParameters(1, "ImgUrl", show.imgUrl);
                dataAccessLayer.AddParameters(2, "Hall_ID", show.hall.hallNum);


                List <string> date_strings = new List <string>();
                show.dates.ForEach(d => date_strings.Add(d.ToString("yyyy-MM-dd hh:mm:ss")));
                string dates = string.Join(",", date_strings);

                dataAccessLayer.AddParameters(3, "Dates", dates);
                dataAccessLayer.AddParameters(4, "basePrice", show.basePrice);
                dataAccessLayer.AddParameters(5, "description", show.description);
                int affectedRows = dataAccessLayer.ExecuteQuery("spCreateShow", CommandType.StoredProcedure);


                dataAccessLayer.CommitTransaction();

                return(affectedRows);
            }
            catch (Exception e)
            {
                dataAccessLayer.RollbackTransaction();
                Console.WriteLine(e);
                return(-1);
            }
        }
Exemple #3
0
        public int createTheater(Theater theater)
        {
            try
            {
                dataAccessLayer.BeginTransaction();

                dataAccessLayer.CreateParameters(3);
                dataAccessLayer.AddParameters(0, "Theater", theater.name);
                dataAccessLayer.AddParameters(1, "Address", theater.address);
                dataAccessLayer.AddParameters(2, "Active", theater.active);
                int affectedRows = dataAccessLayer.ExecuteQuery("spCreateTheater", CommandType.StoredProcedure);


                dataAccessLayer.CommitTransaction();
                return(affectedRows);
            }
            catch (Exception e)
            {
                dataAccessLayer.RollbackTransaction();
                Console.WriteLine(e);
                return(-1);
            }
        }
Exemple #4
0
        /// <summary>
        /// Delete a specific booking
        /// </summary>
        /// <param name="bookingID"></param>
        /// <returns></returns>
        public int DeleteBooking(int bookingID)
        {
            try
            {
                dataAccessLayer.BeginTransaction();

                dataAccessLayer.CreateParameters(1);
                dataAccessLayer.AddParameters(0, "BookingID", bookingID);
                int affectedRows = dataAccessLayer.ExecuteQuery("spDeleteBooking", CommandType.StoredProcedure);

                dataAccessLayer.CommitTransaction();
                return(affectedRows);
            }
            catch (Exception e)
            {
                dataAccessLayer.RollbackTransaction();
                Console.WriteLine(e);
                return(-1);
            }
        }
Exemple #5
0
        public int createHall(Hall hall)
        {
            try
            {
                dataAccessLayer.BeginTransaction();

                dataAccessLayer.CreateParameters(4);
                dataAccessLayer.AddParameters(0, "HallNum", hall.hallNum);
                dataAccessLayer.AddParameters(1, "Theater", hall.theater.name);
                dataAccessLayer.AddParameters(2, "SeatCount", hall.seats);
                dataAccessLayer.AddParameters(3, "RowCount", hall.rows);
                int affectedRows = dataAccessLayer.ExecuteQuery("spCreateHall", CommandType.StoredProcedure);


                dataAccessLayer.CommitTransaction();
                return(affectedRows);
            }
            catch (Exception e)
            {
                dataAccessLayer.RollbackTransaction();
                Console.WriteLine(e);
                return(-1);
            }
        }