Exemple #1
0
        private void btnTimKiem_Click_1(object sender, EventArgs e)
        {
            List <SanPham>    DanhSachSanPham   = new List <SanPham>();
            HienThiSanPhamBLL hienThiSanPhamBLL = new HienThiSanPhamBLL();

            if (radioMa.Checked)
            {
                DanhSachSanPham = hienThiSanPhamBLL.HienThiDanhSachSanPhamTheoMaSP(texTimKiem.Text);
                HienThiDanhSachSanPham(DanhSachSanPham);
            }
            else if (radioTen.Checked)
            {
                DanhSachSanPham = hienThiSanPhamBLL.HienThiDanhSachSanPhamTheoTenSP(texTimKiem.Text);
                HienThiDanhSachSanPham(DanhSachSanPham);
            }
            else if (radioCMT.Checked)
            {
                int SoLuong = int.Parse(texTimKiem.Text);
                DanhSachSanPham = hienThiSanPhamBLL.HienThiDanhSachSanPhamTheoSoLuong(SoLuong);
                HienThiDanhSachSanPham(DanhSachSanPham);
            }
            else
            {
                MessageBox.Show("Ban cần nhập Lựa Chọn Trước Khi Tìm Kiếm");
            }
        }
        private void CapNhapLaiKhoHang()
        {
            if (cbKhoHang.SelectedIndex == -1)
            {
                MessageBox.Show("Bạn Cần Chọn Kho Hàng Cần Cập Nhập");
                return;
            }
            KhoHang        khoHang    = cbKhoHang.SelectedItem as KhoHang;
            List <SanPham> DanhSach   = new List <SanPham>();
            NhaCungCap     nhacungcap = cbNhaCungCap.SelectedItem as NhaCungCap;

            foreach (CT_PhieuNhap ct in DanhSachSanPhamTheoHoaDơn)
            {
                MessageBox.Show(ct.SanPham);
                SanPham sanPham = new SanPham()
                {
                    MaSanPham   = ct.SanPham,
                    TenSanPham  = ct.TenSanPham,
                    SoLuong     = ct.SoLuong,
                    KhoHang     = khoHang.MaKhoHang,
                    LoaiSanPham = "LSP0000",
                    NhaCungCap  = nhacungcap.MaNhaCungCap,
                    DonGia      = 0,
                    NhaSanXuat  = "NSX0000"
                };
                DanhSach.Add(sanPham);
            }

            HienThiSanPhamBLL hienThiSanPhamBLL = new HienThiSanPhamBLL();

            foreach (SanPham sp1 in DanhSach)
            {
                List <SanPham> ketQua = hienThiSanPhamBLL.HienThiDanhSachSanPhamTheoMaSP(sp1.MaSanPham);
                if (ketQua.Count == 0)
                {
                    hienThiSanPhamBLL.ThemMoiSanPham(sp1);
                }
                else if (ketQua[0].KhoHang == khoHang.MaKhoHang)
                {
                    int SoLuongSP = ketQua[0].SoLuong + sp1.SoLuong;
                    hienThiSanPhamBLL.ChinhSuaSoLuongSanPham(sp1.MaSanPham, SoLuongSP);
                }
            }
        }