Example #1
0
 public void AddPro(SanPham pro)
 {
     Dssp.Add(pro);
 }
Example #2
0
        private static void Func1()
        {
            SanPham Product  = new SanPham("cf01", "ca phe so 1", 75, 5);
            SanPham Product1 = new SanPham("cf02", "ca phe so 2", 65, 15);
            SanPham Product2 = new SanPham("ip01", "Iphone 8", 100, 20);
            SanPham Product3 = new SanPham("ip02", "Iphone 7", 150, 6);
            SanPham Product4 = new SanPham("xd01", "Xe dap strongman xanh", 70, 4);
            SanPham Product5 = new SanPham("xd02", "Xe martin", 70, 3);
            var     flagFC1  = false;

            ProList.AddRange(new SanPham[] { Product, Product1, Product2, Product3, Product4, Product5 });
            Console.WriteLine("Danh sách các sản phẩm đang kinh doanh tại cửa hàng:");
            for (int i = 0; i < ProList.Count; i++)
            {
                Console.WriteLine("Mã sp: " + ProList[i].Masp);
                Console.WriteLine("Tên sp: " + ProList[i].Tensp);
                Console.WriteLine("Giá sp: " + ProList[i].Giasp);
                Console.WriteLine("Số lượng còn trong kho: " + ProList[i].Soluong);
                Console.WriteLine("");
            }
            do
            {
                Console.WriteLine("Vui lòng chọn mã sản phẩm bạn muốn mua: ");
                var chosenProId = ValidationCustom <string> .CheckValid();

                Console.WriteLine("Nhập số lượng: ");
                var QuantityPro = ValidationCustom <int> .CheckValid();

                Console.WriteLine("Nhập thông tin KH:");
                KhachHang cus = new KhachHang();
                Console.WriteLine("Tên khách hàng: ");
                cus.HoTen = ValidationCustom <string> .CheckValid();

                Console.WriteLine("Mã khách hàng:");
                cus.MaKh = ValidationCustom <string> .CheckValid();

                Console.WriteLine("Nhập thông tin HĐ:");
                HoaDon bll = new HoaDon();
                Console.WriteLine("Tên hóa đơn: ");
                bll.TenHd = ValidationCustom <string> .CheckValid();

                Console.WriteLine("Ngày lập hóa đơn: ");
                bll.NgayLapHd = ValidationCustom <DateTime> .CheckValid();

                foreach (var product in ProList)
                {
                    if (product.Masp == chosenProId)
                    {
                        bll.AddPro(product);
                    }
                }
                Console.WriteLine("ahjhj");
                BillList.Add(bll);
                cus.AddBill(bll);
                CustomerList.Add(cus);
                Console.WriteLine("Mua tiếp?(y/n)");
                var result = Console.ReadLine();
                if (result == "k")
                {
                    flagFC1 = true;
                }
            } while (!flagFC1);
        }