Ejemplo n.º 1
0
        private static void MenuOrder()/*Hóa đơn */
        {
            string menuTitle = "Quản lý hóa đơn";

            string[] menuItem =
            {
                "Thanh toán",
                "Hiển thị hóa đơn",
                "Thêm hóa đơn",
                "Tạo Combo",
                "Trợ giúp",
                "Đăng xuất"
            };

            bool isChoice = false;

            while (!isChoice)
            {
                int choice = Menu(menuTitle, menuItem);
                switch (choice)
                {
                /*THANH TOÁN HÓA ĐƠN */
                case 1:

                    int dem = 0;



                    while (true && dem < 4)
                    {
                        Console.Clear();
                        Console.WriteLine("+-----------------------+");
                        Console.WriteLine("\tThanh Toán");
                        Console.WriteLine("+-----------------------+");
                        Console.WriteLine(emp.Full_Name + " thân mến !Bạn đang ở chức năng thanh toán hóa đơn");
                        Console.WriteLine("Lưu ý Trạng thái hóa đơn: ");
                        sub.PrintColorMessage(ConsoleColor.Green, "1- ĐÃ THANH TOÁN");
                        sub.PrintColorMessage(ConsoleColor.Magenta, "2- CHỜ THANH TOÁN");
                        sub.PrintColorMessage(ConsoleColor.Red, "0- CHƯA THANH TOÁN");
                        // billbl.GetBillbyStatus();

                        if (billbl.GetBillbyStatus() != null)
                        {
                            sub.PrintColorMessage(ConsoleColor.Blue, "Bạn không nên nhập sai quá 3 lần ! Chức năng thanh toán sẽ tự động thoát ra ");
                            //Input ID Card need Pay

                            Console.Write("Vui lòng nhập mã Thẻ: ");

                            string ID = Console.ReadLine();
                            Console.Write("Vui Lòng nhập Trạng thái bill cần thanh toán: ");

                            string statusid = Console.ReadLine();
                            if (sub.IsANumber(ID) != true)
                            {
                                dem++;

                                continue;
                            }
                            Console.Clear();
                            Console.WriteLine(emp.Full_Name + " thân mến !Bạn đang ở chức năng thanh toán hóa đơn");
                            int id = Convert.ToInt32(ID);

                            if (sub.IsANumber(statusid) != true)
                            {
                                dem++;

                                continue;
                            }
                            int status = Convert.ToInt32(statusid);
                            if (status != 1 && status < 4)
                            {
                                billbl.Payment(id, status, string.Concat(emp.Full_Name, "[", emp.IdUser, "]"));
                            }
                            else
                            {
                                Console.WriteLine("Trạng thái nhập 1- ĐÃ THANH TOÁN !");
                                Console.WriteLine("Xin Mời nhập lại: 0- CHƯA THANH TOÁN, 2- CHỜ THANH TOÁN");
                            }
                        }
                        var keyy = Console.ReadKey();

                        if (keyy.Key == ConsoleKey.Escape)
                        {
                            Console.Clear();
                            break;
                        }
                    }

                    break;

                case 2:    /*HIỂN THỊ HÓA ĐƠN */
                    Console.Clear();
                    //SHOW BILL LIST
                    while (true)
                    {
                        Console.WriteLine("+-----------------------+");
                        Console.WriteLine("    Hiển thị hóa đơn");
                        Console.WriteLine("+-----------------------+");

                        Console.WriteLine(emp.Full_Name + "Bạn đang trong Ở Hiển thị hóa đơn");
                        Console.WriteLine("Nhấn F để tìm kiếm và hiển thị hóa đơn theo ngày");
                        var kei = Console.ReadKey();
                        Console.Clear();
                        switch (kei.Key)
                        {
                        case ConsoleKey.F:
                            while (true)
                            {
                                Console.Write("Bạn cần nhập ngày theo định dạng: ");
                                sub.PrintColorMessage(ConsoleColor.Magenta, "dd/m/yyyy (VD:18/2/2000)");
                                Console.Write("Bạn muốn hiển thị Từ ngày: ");
                                string datein = "'" + Console.ReadLine() + "'";
                                Console.Write("Đến ngày: ");
                                string dateout = "'" + Console.ReadLine() + "'";
                                Console.Clear();
                                reportbl.GetBillbyDate(datein, dateout);

                                var kj = Console.ReadKey();
                                if (kj.Key == ConsoleKey.Delete)
                                {
                                    Console.Write("Nhập mã hóa đơn cần xóa: ");
                                    int id = Convert.ToInt32(Console.ReadLine());
                                    reportbl.GetBillbyIdBill(id);
                                    Console.WriteLine("Bạn có chắc chắn muốn xóa hóa đơn này?? (Y/N)");
                                    string choice1 = Console.ReadLine();
                                    if (choice1 == "Y")
                                    {
                                        billinfo.DeleteBillInfoByIdBill(id);
                                        tablebl.UpdateTable1(id);
                                    }

                                    break;
                                }
                                if (kj.Key == ConsoleKey.Escape)
                                {
                                    Console.Clear();
                                    break;
                                }
                            }
                            break;

                        case ConsoleKey.Delete:
                            while (true)
                            {
                                if (billinfo.DeleteBillInfo())
                                {
                                    Console.WriteLine("Xóa thành công !");
                                }
                                if (billbl.DeleteBill())
                                {
                                    Console.WriteLine("Xóa hóa đơn thành công !");
                                }
                                var kj = Console.ReadKey();
                                if (kj.Key == ConsoleKey.Escape)
                                {
                                    Console.Clear();
                                    break;
                                }
                            }
                            break;

                        default:
                            break;
                        }
                        if (kei.Key == ConsoleKey.Escape)
                        {
                            Console.Clear();
                            break;
                        }
                    }
                    break;

                case 3:    /*TẠO HÓA ĐƠN */
                    Console.Clear();
                    int tableid = 0;
                    int dm      = 0;
                    Console.WriteLine("Bạn không nên nhập sai quá 3 lần");
                    while (true && dm < 3)
                    {
                        Console.Clear();
                        Console.WriteLine("+-----------------------+");
                        Console.WriteLine("\tThêm hóa đơn");
                        Console.WriteLine("+-----------------------+");
                        Console.WriteLine(emp.Full_Name + " thân mến !Bạn đang ở chức năng thêm hóa đơn");
                        tablebl.GetInfo();    // Hiển thị thông tin các thẻ
                        Console.Write("*Mã thẻ: ");
                        string iD = Console.ReadLine();
                        if (sub.IsANumber(iD) != true)
                        {
                            dm++;
                            continue;
                        }

                        tableid = Convert.ToInt32(iD);
                        if (tablebl.CheckExistCard(tableid) != true)
                        {
                            dm++;
                            continue;
                        }
                        billbl.CreatBill(tableid);
                        menubl.GetMenuListByTableID(tableid, 0);
                        ConsoleKeyInfo key = Console.ReadKey();
                        if (key.Key == ConsoleKey.Escape)
                        {
                            Console.WriteLine("Đang Thoát...");
                            Console.Clear();
                            break;
                        }
                    }

                    break;

                case 4:    //Tạo Combo//


                    break;

                case 5:    //Mở File trợ giúp//
                    Console.Clear();

                    try
                    {
                        var p = new Process();

                        p.StartInfo = new ProcessStartInfo("file:///F:/HelpAPP/helpemp.htm")
                        {
                            UseShellExecute = true
                        };
                        p.Start();

                        //  Process.Start(@"F:\Menu các món trong quán cà phê.docx");
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }

                    break;

                case 6:
                    Console.Clear();
                    isChoice = true;
                    break;



                default:
                    Console.Clear();
                    sub.PrintColorMessage(ConsoleColor.Red, "Error, Input from 1 to " + menuItem.Length);

                    break;
                }
            }
        }