public void BuyTicket(Customer customer)
        {
            bool checkchoice = false;

            while (true)
            {
                Console.Clear();
                Ticket        t          = new Ticket();
                List <Ticket> listticket = new List <Ticket>();
                DisplayMatchDetails(customer);
                string path = Path.GetFullPath("DataCart" + customer.Username + ".txt");
                string choice;
                if (File.Exists(path) == true)
                {
                    listticket = ReadFile(customer);
                }
                t = InputTicketInfo(customer);
                foreach (var item in listticket)
                {
                    if (t.TicketID == item.TicketID)
                    {
                        item.Amount += t.Amount;
                        t            = null;
                        break;
                    }
                }
                if (t != null)
                {
                    listticket.Add(t);
                }
                if (InputTicketOnFile(customer, listticket) == true)
                {
                    Console.Write("Them vao gio hang thanh cong!Ban co muon mua tiep khong?(C/K)");
                    choice      = Console.ReadLine().ToUpper();
                    checkchoice = m.Choose(choice);
                    if (checkchoice == true)
                    {
                        continue;
                    }
                    else
                    {
                        m.MenuTicket(customer);
                        break;
                    }
                }
                else
                {
                    Console.WriteLine("Them vao gio hang khong thanh cong,An phim bat ky de tro ve menu");
                    Console.ReadKey();
                    m.MenuTicket(customer);
                    break;
                }
                // InputTicketOnFile(customer, listticket);
            }
        }
        public void DisplayStatistic(Customer customer)
        {
            bool         checkorder = false;
            string       choice;
            string       status     = "";
            List <Order> ListOrders = new List <Order>();
            OrderBL      Orders     = new OrderBL();

            try
            {
                ListOrders = Orders.GetOrdersByCustomerID(customer.Id);
            }
            catch (System.Exception)
            {
            }
            if (ListOrders.Count != 0)
            {
                var table = new ConsoleTable("Ma Don Hang", "Ngay Mua", "Trang Thai Don Hang");
                foreach (var item in ListOrders)
                {
                    if (item.OrderStatus == 0)
                    {
                        status = "Da Thanh Toan";
                    }
                    table.AddRow(item.OrderID, String.Format("{0:dd/MM/yyyy}", item.OrderDate), status);
                }
                table.Write(Format.Default);
            }
            else
            {
                Console.WriteLine("Ban Chua mua hang!Nhan phim bat ky de tro ve menu chinh");
                Console.ReadKey();
                menu.MenuMain(customer);
            }
            while (checkorder == false)
            {
                Console.Write("Nhap ma dat hang:");
                int OrderID = consoleticket.Input(Console.ReadLine());
                foreach (var item in ListOrders)
                {
                    if (OrderID == item.OrderID)
                    {
                        checkorder = PrintTableTicket(customer, OrderID);
                    }
                }
                if (checkorder == false)
                {
                    Console.Write("Ma hoa don can tra cuu khong dung!Ban co muon nhap lai khong(C/K):");
                    choice = Console.ReadLine().ToUpper();
                    bool checkchoice = menu.Choose(choice);
                    if (checkchoice == true)
                    {
                        checkorder = false;
                        continue;
                    }
                    else
                    {
                        checkorder = true;
                        menu.MenuMain(customer);
                    }
                }
            }
            Console.WriteLine("An phim bat ky de tro ve menu chinh!");
            Console.ReadKey();
            menu.MenuMain(customer);
        }
Ejemplo n.º 3
0
        public void PayTicket(Customer customer)
        {
            double        moneySumTicket = 0;
            string        choice;
            List <Ticket> listCart = new List <Ticket>();

            listCart = ReadFileToListCart(customer);
            foreach (var item in listCart)
            {
                moneySumTicket += (item.TicketPrice * item.Amount);
            }
            Order order = new Order();

            order.listticket  = listCart;
            order.Customer.Id = customer.Id;
            order.OrderDate   = DateTime.Now;
            order.OrderStatus = 0;
            Console.WriteLine("Tong tien:{0} VND", pricevalid(moneySumTicket));
            Console.Write("Nhap so tien thanh toan(VND):");
            double moneypay;

            while (true)
            {
                try
                {
                    moneypay = Convert.ToDouble(Console.ReadLine());
                    if (moneypay <= 0)
                    {
                        Console.Write("So tien thanh toan phai lon hon 0!Moi ban nhap lai: ");
                        continue;
                    }
                    if (moneypay < moneySumTicket)
                    {
                        Console.Write("So tien nhap khong du!Moi ban nhap lai: ");
                        continue;
                    }
                    if (moneypay > 999999999)
                    {
                        Console.Write("So tien qua lon!Moi ban nhap lai: ");
                        continue;
                    }
                }
                catch
                {
                    Console.Write("Ban phai nhap so tien bang so!Moi ban nhap lai so tien can thanh toan(VND): ");
                    continue;
                }
                break;
            }
            Console.Write("Xac nhan thanh toan:(C/K)");
            choice = Console.ReadLine().ToUpper();
            bool checkInsertOrder = false;
            bool checkchoice      = false;

            checkchoice = m.Choose(choice);
            if (checkchoice == true)
            {
                checkInsertOrder = InsertOrder(customer, order);
            }
            else
            {
                m.MenuPay(customer);
            }
            if (checkInsertOrder == true)
            {
                Console.WriteLine("Thanh toan thanh cong!");
                if (moneypay > moneySumTicket)
                {
                    Console.WriteLine("Tien thua tra lai:{0} VND", pricevalid((moneypay - moneySumTicket)));
                }
                Console.WriteLine("Ban co muon in hoa don khong?(C/K): ");
                choice      = Console.ReadLine().ToUpper();
                checkchoice = m.Choose(choice);
                if (checkchoice == true)
                {
                    PrintBill(customer, order.OrderID, moneySumTicket);
                    Console.Write("In hoa don thanh cong!Nhan phim bat ky de tro ve menu chinh!");
                    Console.ReadKey();
                    m.MenuMain(customer);
                }
                else
                {
                    m.MenuMain(customer);
                }
            }
            if (checkInsertOrder == false)
            {
                Console.WriteLine("Thanh toan khong thanh cong!Nhan phim bat ky de quay tro lai Menu chinh");
                Console.ReadKey();
                m.MenuMain(customer);
            }
        }