Example #1
0
        public void Paybill(Customers Cus, int?orderId)
        {
            Console.Clear();
            Order_BL OBL   = new Order_BL();
            Order    order = new Order();
            int      total = 0;

            try
            {
                order = OBL.GetOrderDetailsByOrderId(orderId);
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex);
                Console.ReadKey();
                UserMenu(Cus);
            }
            Console.WriteLine("+-------------------------------------------------------------------------------+");
            Console.WriteLine("|                                HÓA ĐƠN THANH TOÁN                             |");
            Console.WriteLine("|                                                                               |");
            Console.WriteLine("|                      Ngày {0,-2} tháng {1,-2} năm {2, -5}                               |", DateTime.Now.ToString("dd"), DateTime.Now.ToString("MM"), DateTime.Now.ToString("yyyy"));
            Console.WriteLine("+-------------------------------------------------------------------------------+");
            Console.WriteLine("|Tên khách hàng : {0,-35}                           |", order.Customer.Cus_Name);
            Console.WriteLine("|Địa chỉ : {0,-55}              |", order.Customer.Cus_Address);
            Console.WriteLine("+----------------------------------+----------------+----------+----------------+");
            Console.WriteLine("|{0,-34}|{1,-16}|{2,-10}|{3,-16}|", "Tên sản phẩm", "Đơn giá", "Số lượng", "Thành tiền");
            Console.WriteLine("+----------------------------------+----------------+----------+----------------+");
            foreach (var i in order.ItemsList)
            {
                total += i.Item_Price * i.Quantity;
                string format = string.Format($"|{i.Item_Name,-34}|{FormatMoney(i.Item_Price),-16}|{i.Quantity,-10}|{FormatMoney(i.Item_Price * i.Quantity),-16}|");
                Console.WriteLine(format);
                Console.WriteLine("+----------------------------------+----------------+----------+----------------+");
            }
            Console.WriteLine("|    Tổng tiền ( Đã bao gồm thuế VAT )                         |{0,-16}|", FormatMoney(total));
            Console.WriteLine("+-------------------------------------------------------------------------------+");
            Console.WriteLine("|        Người mua hàng                                                         |");
            Console.WriteLine("|            {0,-7}                                                            |    ", Cus.User_Name);
            Console.WriteLine("|       {0,-20}                                                    |", order.Customer.Cus_Name);
            Console.WriteLine("+-------------------------------------------------------------------------------+");
            Console.WriteLine("Nhấn phím bất kỳ để quay lại trang chính!");
            Console.ReadKey();
            UserMenu(Cus);
        }
Example #2
0
        public void UserPurchased(Customers Cus)
        {
            Console.Clear();
            while (true)
            {
                List <Order> ListOrder;
                try
                {
                    Order_BL OBL = new Order_BL();
                    ListOrder = OBL.GetOrderByCustomerId(Cus.Cus_ID);
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    break;
                }
                if (ListOrder.Count <= 0)
                {
                    Console.WriteLine("Danh sách trống !\n");
                    Console.Write("Nhấn phím bất kỳ để quay lại trang chính!");
                    Console.ReadKey();
                    UserMenu(Cus);
                }
                Console.WriteLine("==========================================================================================================");
                Console.WriteLine("                                             Danh sách sản phẩm đã mua");
                Console.WriteLine("==========================================================================================================\n");
                Console.WriteLine("+----------------+--------------------+------------------------------------------+------------------------+");
                Console.WriteLine("| {0,-15}|    {1,-16}|          {2,-21}           |   {3,-21}|", "Mã đơn hàng", "Ngày đặt hàng", "Địa chỉ giao hàng", "Trạng thái thanh toán");
                Console.WriteLine("+----------------+--------------------+------------------------------------------+------------------------+");
                foreach (Order order in ListOrder)
                {
                    Console.WriteLine("|      {0,-7}   |     {1,-15}| {2,-41}|  {3,-22}|", order.Order_ID, order.Order_Date.ToString("dd/MM/yyyy"), order.Address_Shipping, order.Status);
                    Console.WriteLine("+----------------+--------------------+------------------------------------------+------------------------+");
                }
                int Count = ListOrder.Count;
                while (true)
                {
                    string[] choice = { "Xem chi tiết đơn hàng", "Quay lại" };
                    int      number = Product.SubMenu(null, choice);
                    switch (number)
                    {
                    case 1:
                        int orderid;
                        while (true)
                        {
                            Console.Write("Nhập mã đơn hàng: ");
                            bool isINT = Int32.TryParse(Console.ReadLine(), out orderid);
                            if (!isINT)
                            {
                                Console.WriteLine("Giá trị nhập vào phải là số!");
                                continue;
                            }
                            else if (orderid > 0 && orderid <= Count)
                            {
                                break;
                            }
                            else
                            {
                                Console.WriteLine("Mã đơn hàng không hợp lệ");
                                continue;
                            }
                        }
                        Order_BL OBL   = new Order_BL();
                        Order    order = new Order();
                        try
                        {
                            order = OBL.GetOrderDetailsByOrderId(orderid);
                        }
                        catch (System.Exception ex)
                        {
                            Console.WriteLine(ex);
                            Console.ReadKey();
                            UserMenu(Cus);
                        }
                        if (order.Status == "Không thành công")
                        {
                            Console.WriteLine("Do đơn hàng này chưa đặt hàng thành công nên không có hóa đơn !");
                            Console.WriteLine("Nhấn phím bất kỳ để trở lại!");
                            Console.ReadKey();
                            continue;
                        }
                        else
                        {
                            Paybill(Cus, orderid);
                        }
                        break;

                    case 2:
                        UserMenu(Cus);
                        break;
                    }
                }
            }
        }