示例#1
0
        /// <summary>
        /// Gets a specific booking based by booking ID
        /// </summary>
        /// <param name="bookingID"></param>
        /// <returns></returns>
        public Booking GetBooking(int bookingID)
        {
            Booking b;

            try
            {
                dataAccessLayer.CreateParameters(1);
                dataAccessLayer.AddParameters(0, "BookingID", bookingID);
                DataSet ds = dataAccessLayer.ExecuteDataSet("spGetBookingDetails", CommandType.StoredProcedure);

                b = new Booking
                {
                    bookingID  = bookingID,
                    customerID = ds.Tables[0].Rows[0]["Customer_ID"].ToString().Trim(),
                    date       = DateTime.Parse(ds.Tables[0].Rows[0]["BookedDate"].ToString()),
                    show       = new Show
                    {
                        ID    = int.Parse(ds.Tables[0].Rows[0]["ShowID"].ToString()),
                        title = ds.Tables[0].Rows[0]["Title"].ToString(),
                        hall  = new Hall
                        {
                            hallNum = int.Parse(ds.Tables[0].Rows[0]["Hall"].ToString().Trim()),
                            theater = new Theater
                            {
                                name    = ds.Tables[0].Rows[0]["Theater"].ToString(),
                                address = ds.Tables[0].Rows[0]["Address"].ToString()
                            }
                        },
                        imgUrl    = ds.Tables[0].Rows[0]["ImgUrl"].ToString(),
                        basePrice = decimal.Parse(ds.Tables[0].Rows[0]["BasePrice"].ToString())
                    },
                    totalPrice = decimal.Parse(ds.Tables[0].Rows[0]["TotalPrice"].ToString())
                };
                b.seats = new List <Seat>();
                foreach (DataRow row in ds.Tables[1].Rows)
                {
                    b.seats.Add(new Seat(int.Parse(row["SeatNumber"].ToString()),
                                         int.Parse(row["RowNumber"].ToString())));
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }


            return(b);
        }
示例#2
0
        public Theater getTheater(string theaterName)
        {
            Theater theater;

            try
            {
                dataAccessLayer.CreateParameters(1);
                dataAccessLayer.AddParameters(0, "Theater", theaterName);
                DataSet ds = dataAccessLayer.ExecuteDataSet("spGetTheater", CommandType.StoredProcedure);

                theater = new Theater
                {
                    name    = ds.Tables[0].Rows[0]["Theater"].ToString(),
                    address = ds.Tables[0].Rows[0]["Address"].ToString(),
                    active  = ds.Tables[0].Rows[0]["Active"].ToString() == "1"
                };
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }


            return(theater);
        }
示例#3
0
        /// <summary>
        /// Gets a customer from the database
        /// </summary>
        /// <param name="customerID"></param>
        /// <returns></returns>
        public Customer GetCustomer(string customerID)
        {
            Customer customer;

            try
            {
                dataAccessLayer.CreateParameters(1);
                dataAccessLayer.AddParameters(0, "CustomerID", customerID);
                DataSet ds = dataAccessLayer.ExecuteDataSet("spGetCustomer", CommandType.StoredProcedure);


                customer = new Customer
                {
                    ID      = customerID,
                    name    = ds.Tables[0].Rows[0]["CustomerName"].ToString(),
                    email   = ds.Tables[0].Rows[0]["Mail"].ToString().Trim(),
                    phone   = ds.Tables[0].Rows[0]["Phone"]?.ToString(),
                    Address = ds.Tables[0].Rows[0]["Address"]?.ToString(),
                    Gender  = ds.Tables[0].Rows[0]["Gender"]?.ToString(),
                    Age     = int.Parse(ds.Tables[0].Rows[0]["Age"]?.ToString().Trim())
                };
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }


            return(customer);
        }
示例#4
0
        public Show getShow(int id)
        {
            try
            {
                dataAccessLayer.CreateParameters(1);
                dataAccessLayer.AddParameters(0, "ShowID", id);
                DataSet ds = dataAccessLayer.ExecuteDataSet("spGetShow", CommandType.StoredProcedure);

                Show show = new Show
                {
                    ID     = int.Parse(ds.Tables[0].Rows[0]["ID"].ToString()),
                    title  = ds.Tables[0].Rows[0]["Title"].ToString(),
                    imgUrl = ds.Tables[0].Rows[0]["ImgUrl"].ToString(),
                    hall   = new Hall
                    {
                        hallNum = int.Parse(ds.Tables[0].Rows[0]["Hall_ID"].ToString()),
                        theater = new Theater
                        {
                            address = ds.Tables[0].Rows[0]["Address"].ToString(),
                            name    = ds.Tables[0].Rows[0]["Theater"].ToString()
                        },
                        rows  = int.Parse(ds.Tables[2].Rows[0]["RowCount"].ToString()),
                        seats = int.Parse(ds.Tables[2].Rows[0]["SeatCount"].ToString())
                    },
                    basePrice   = decimal.Parse(ds.Tables[0].Rows[0]["BasePrice"].ToString()),
                    description = ds.Tables[0].Rows[0]["Description"].ToString()
                };

                show.dates = new List <DateTime>();
                foreach (DataRow dr in ds.Tables[1].Rows)
                {
                    show.dates.Add(DateTime.Parse(dr["ShowDate"].ToString()));
                }

                return(show);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }
        }
示例#5
0
        public string GetAllPersons()
        {
            string value;

            try
            {
                DataSet dataSet = _dataAccessLayer.ExecuteDataSet("getAll", CommandType.StoredProcedure);
                var     data    = dataSet.Tables[0].Rows[0];
                value = data["lastName"].ToString();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                return(null);
            }

            return(value);
        }