Beispiel #1
0
        public PriceSeatOfRoomType GetPriceSeatOfRoomType(MySqlDataReader reader)
        {
            string rtName = reader.GetString("rt_name");
            string stType = reader.GetString("st_type");
            double price  = reader.GetDouble("price");

            PriceSeatOfRoomType priceSeatOfRoomType = new PriceSeatOfRoomType(rtName, stType, price);

            return(priceSeatOfRoomType);
        }
        private PriceSeatOfRoomType GetPriceSeatOfRoomTypeExecQuery(string query)
        {
            if (connection.State == System.Data.ConnectionState.Closed)
            {
                connection.Open();
            }

            MySqlCommand        command             = new MySqlCommand(query, connection);
            PriceSeatOfRoomType priceSeatOfRoomType = null;

            using (reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    priceSeatOfRoomType = priceSeatOfRoomTypeDAL.GetPriceSeatOfRoomType(reader);
                }
            }

            connection.Close();

            return(priceSeatOfRoomType);
        }
        public void GetPriceSeatsOfRoomTypeByRTNameTest1()
        {
            string rtName = "3D";
            List <PriceSeatOfRoomType> priceSeatsOfRoomType = priceSeatOfRoomTypeDAL.GetPriceSeatsOfRoomTypeByRTName(rtName);

            query = $"select * from PriceSeatsOfRoomTypes where rt_name = '" + rtName + "' order by rand() limit 1;";
            PriceSeatOfRoomType priceSeatOfRoomTypeRand = GetPriceSeatOfRoomTypeExecQuery(query);

            query = $"select * from PriceSeatsOfRoomTypes where rt_name = '" + rtName + "' order by st_type asc limit 1;";
            PriceSeatOfRoomType priceSeatOfRoomTypeTop = GetPriceSeatOfRoomTypeExecQuery(query);

            query = $"select * from PriceSeatsOfRoomTypes where rt_name = '" + rtName + "' order by st_type desc limit 1;";
            PriceSeatOfRoomType priceSeatOfRoomTypeBottom = GetPriceSeatOfRoomTypeExecQuery(query);

            Assert.NotNull(priceSeatsOfRoomType);
            Assert.NotNull(priceSeatOfRoomTypeRand);
            Assert.NotNull(priceSeatOfRoomTypeTop);
            Assert.NotNull(priceSeatOfRoomTypeBottom);

            Assert.Contains(priceSeatOfRoomTypeRand, priceSeatsOfRoomType);

            Assert.True(priceSeatsOfRoomType.IndexOf(priceSeatOfRoomTypeTop) == 0);
            Assert.True(priceSeatsOfRoomType.IndexOf(priceSeatOfRoomTypeBottom) == (priceSeatsOfRoomType.Count - 1));
        }
        public double PrintTicket(ScheduleDetail sched, Schedule sche, Room room, Movie movie, PriceSeatOfRoomType psort, User user, Cinema cine, string seat)
        {
            string a    = "";
            string b    = "";
            int    inde = (cine.CineAddress.Length) / 2;

            for (int j = inde; j > 0; j--)
            {
                if (cine.CineAddress[j - 1] == ',')
                {
                    a = cine.CineAddress.Substring(0, j);
                    b = cine.CineAddress.Substring(j + 1, cine.CineAddress.Length - inde);
                    break;
                }
            }
            string price = pricevalid(psort.Price);

            string[] left = { cine.CineName,                                 a,                                        b, cine.CinePhone,
                              DateTime.Now.ToString("dd/MM/yyyy") + "     " + sched.SchedTimeStart?.ToString("HH:mm") +
                              " - " + sched.SchedTimeEnd?.ToString("HH:mm"), movie.MovieName,
                              psort.STType + " Ghế" + " Rạp",                price + " " + seat + " " + room.RoomName,
                              "Gồm" + " Seat" + " Cinema",                   "5% VAT",                                 DateTime.Now.ToString("HH:mm dd/MM/yyyy") + "      " + user.Username };
            string[] right = { cine.CineName,                                 a,                                              b,            movie.MovieName, "Time: " + sched.SchedTimeStart?.ToString("HH:mm") +
                               " - " + sched.SchedTimeEnd?.ToString("HH:mm"), "Date: " + DateTime.Now.ToString("dd/MM/yyyy"),
                               "Hall: " + room.RoomName,                      "Seat: " + seat,                                psort.STType, "Price: " + price, DateTime.Now.ToString("HH:mm dd/MM/yyyy") };
            int      length  = 0;
            int      length1 = 0;
            int      length2 = 0;

            if ((left[2]).Length > left[5].Length)
            {
                length  = (left[2] + left[2]).Length;
                length1 = left[2].Length;
                length2 = left[2].Length;
            }
            else if (true)
            {
                length  = (left[5] + left[5]).Length;
                length1 = left[5].Length;
                length2 = left[5].Length;
            }

            for (int i = 0; i < length + 7; i++)
            {
                Console.Write("_");
            }
            Console.WriteLine();
            for (int i = 0; i < left.Length; i++)
            {
                string lefti;
                if (i > 5 && i < 9)
                {
                    string[] arr = left[i].Split(" ");
                    Console.Write("| " + arr[0]);
                    for (int l = 0; l < 12 - arr[0].ToString().Length; l++)
                    {
                        Console.Write(" ");
                    }
                    Console.Write(arr[1]);
                    for (int j = 0; j < 7 - arr[1].ToString().Length; j++)
                    {
                        Console.Write(" ");
                    }
                    Console.Write(arr[2]);
                    for (int o = 0; o < length1 - 12 - 7 - arr[2].Length; o++)
                    {
                        Console.Write(" ");
                    }
                }
                else
                {
                    lefti = "| " + left[i];
                    Console.Write(lefti);
                    for (int j = 0; j < length1 - lefti.Length + 2; j++)
                    {
                        Console.Write(" ");
                    }
                }


                string righti = " | " + right[i];
                Console.Write(righti);
                for (int k = 0; k < length2 - righti.Length + 3; k++)
                {
                    Console.Write(" ");
                }
                Console.WriteLine(" |");
            }
            for (int i = 0; i < length + 7; i++)
            {
                Console.Write("_");
            }
            Console.WriteLine();
            return(psort.Price);
        }