Example #1
0
        public void Sua()
        {
            Console.Clear();
            Console.WriteLine("SUA THONG TIN SAN PHAM");
            List <SanPham> list = spDLL.GetAllSanPham();
            string         masanpham;

            Console.Write("Nhap ma san pham can sua:");
            masanpham = Console.ReadLine();
            int i = 0;

            for (i = 0; i < list.Count; ++i)
            {
                if (list[i].Masp == masanpham)
                {
                    break;
                }
            }

            if (i < list.Count)
            {
                SanPham sp = new SanPham(list[i]);
                Console.Write("Nhap ten moi:");
                string ten = Console.ReadLine();
                if (!string.IsNullOrEmpty(ten))
                {
                    sp.Tensp = ten;
                }
                Console.Write("Gia moi:");
                int gia = int.Parse(Console.ReadLine());
                if (gia > 0)
                {
                    sp.Giaban = gia;
                }
                spDLL.SuaSanPham(sp);
            }
            else
            {
                Console.WriteLine("Khong ton tai ma san pham nay");
            }
        }
Example #2
0
        public void Sua()
        {
            Hien();
            Console.WriteLine("SUA THONG TIN SAN PHAM");
            List<Sanpham> list = spBLL.GetAllSanPham();
            string masanpham;
            Console.Write("Nhap ma san pham can sua:");
            masanpham = Console.ReadLine();
            int i = 0;
            for (i = 0; i < list.Count; ++i)
                if (list[i].Masp == masanpham) break;

            if (i < list.Count)
            {
                Sanpham sp = new Sanpham(list[i]);
                Console.Write("Nhap ma san pham moi:");
                string ma = Console.ReadLine();
                if (!string.IsNullOrEmpty(ma)) sp.Masp = ma;
                Console.Write("Nhap ma loai san pham moi :");
                string loai = Console.ReadLine();
                if (!string.IsNullOrEmpty(loai)) sp.Maloai = loai;
                Console.Write("Nhap ten san pham moi:");
                string ten = Console.ReadLine();
                if (!string.IsNullOrEmpty(ten)) sp.Tensp = ten;
                Console.Write("Gia so luong san pham moi:");
                int sl = int.Parse(Console.ReadLine());
                if (sl > 0) sp.Soluong = sl;
                Console.Write("Nhap gia ban san pham moi:");
                int giamoi = int.Parse(Console.ReadLine());
                if (giamoi > 0) sp.Giaban = giamoi;
                Console.Write("Nhap nha san xuat moi:");
                string nsx = Console.ReadLine();
                if (!string.IsNullOrEmpty(nsx)) sp.Nhasx = nsx;
                spBLL.SuaSanPham(sp,masanpham);
            }
            else
            {
                Console.WriteLine("Khong ton tai ma san pham nay");
            }
        }