示例#1
0
        private void btnXoaSP_Click(object sender, EventArgs e)
        {
            KhoHang           khoHang           = cbKhoHang.SelectedItem as KhoHang;
            HienThiSanPhamBLL hienThiSanPhamBLL = new HienThiSanPhamBLL();
            int k = 0;

            foreach (SanPham Sp in hienThiSanPhamBLL.HienThiDanhSachSanPhamTheoKho(khoHang.MaKhoHang))
            {
                k++;
                if (Sp.MaSanPham.Trim() == texMaSP.Text.Trim())
                {
                    texMaSP.Text  = Sp.MaSanPham;
                    texTenSP.Text = Sp.TenSanPham;
                    break;
                }
                if (k == hienThiSanPhamBLL.HienThiDanhSachSanPhamTheoKho(khoHang.MaKhoHang).Count&& Sp.MaSanPham.Trim() != texMaSP.Text.Trim())
                {
                    int h = 0;
                    foreach (SanPham Sp1 in hienThiSanPhamBLL.HienThiDanhSachSanPham())
                    {
                        h++;
                        if (Sp1.MaSanPham.Trim() == texMaSP.Text.Trim())
                        {
                            MessageBox.Show("Sản Phẩm Chưa Tồn Tại Trong Kho Hàng Nhưng Đã Tồn Tại Mã Trong Hệ Thông Bạn Cần Chọn Mã Sản Phẩm Khác");
                            return;
                        }
                        else if (h == hienThiSanPhamBLL.HienThiDanhSachSanPham().Count&& Sp1.MaSanPham.Trim() != texMaSP.Text.Trim())
                        {
                            MessageBox.Show("Sản Phẩm Chưa Tồn Tại Trong Kho Mã Sản Phẩm Hợp Lệ");
                            break;
                        }
                    }
                }
            }
            //if(texMaSP.Text== null)
            //{
            //    MessageBox.Show("Ban can Cap Nhap Ma San Pham Truoc Khi Xoa");
            //    return;
            //}
            //if(texMaHoaDon.Text == null)
            //{
            //    MessageBox.Show("Ban can Nhap Ma Hoa Don Truoc Khi Xoa");
            //    return;
            //}
            //if(cbKhoHang.SelectedItem == null)
            //{
            //    MessageBox.Show("Ban Can Chon Kho Hang Truoc Khi Xoa");
            //    return;

            //}
            //KhoHang khoHang = cbKhoHang.SelectedItem as KhoHang;
            //HienThiCT_PhieuNhapBLL hienThiCT_PhieuNhapBLL = new HienThiCT_PhieuNhapBLL();
            //hienThiCT_PhieuNhapBLL.XoaCt_PhieuNhap(texMaHoaDon.Text, texMaSP.Text, khoHang,int.Parse(texSoLuong.Text));
            //HienThiDanhSachSanPhamHD(hienThiCT_PhieuNhapBLL.HienThiDanhSachSPTheoMaPhieu(texMaHoaDon.Text));
        }
 private void cbKhoHang_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cbKhoHang.SelectedIndex != -1)
     {
         HienThiNhanVienBLL hienThiNhanVienBLL = new HienThiNhanVienBLL();
         KhoHang            khoHang            = cbKhoHang.SelectedItem as KhoHang;
         CbNhanViens.Items.Clear();
         foreach (NhanVien NhanVien in hienThiNhanVienBLL.HienThiNhanVienTheoKho(khoHang.MaKhoHang))
         {
             CbNhanViens.Items.Add(NhanVien);
         }
         HienThiSanPhamBLL hienThiSanPhamBLL = new HienThiSanPhamBLL();
         foreach (SanPham sa in hienThiSanPhamBLL.HienThiDanhSachSanPhamTheoKho(khoHang.MaKhoHang))
         {
             cbNhanVien.Items.Add(sa);
         }
     }
     HienThiDanhSachSanPham();
 }
示例#3
0
文件: UCSanPham.cs 项目: NamAnhh/demo
        private void tvPhanLoaiSanPham_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node != null)
            {
                if (e.Node.Level == 0)
                {
                    e.Node.ExpandAll();
                }
            }
            HienThiSanPhamBLL hienThiSanPhamBLL = new HienThiSanPhamBLL();
            List <SanPham>    DanhSachSanPham   = new List <SanPham>();

            if (e.Node.Level == 1)
            {
                if (tvPhanLoaiSanPham.Nodes[0].Nodes[0] == e.Node)
                {
                    HienThiDanhSachSanPham();
                }
            }
            for (int i = 0; i < tvPhanLoaiSanPham.Nodes[1].Nodes.Count; i++)
            {
                if (e.Node.Level == 1)
                {
                    if (tvPhanLoaiSanPham.Nodes[1].Nodes[i] == e.Node)
                    {
                        KhoHang khoHang = e.Node.Tag as KhoHang;
                        DanhSachSanPham = hienThiSanPhamBLL.HienThiDanhSachSanPhamTheoKho(khoHang.MaKhoHang);
                        HienThiDanhSachSanPham(DanhSachSanPham);
                        break;
                    }
                }
            }

            for (int i = 0; i < tvPhanLoaiSanPham.Nodes[2].Nodes.Count; i++)
            {
                if (e.Node.Level == 1)
                {
                    if (tvPhanLoaiSanPham.Nodes[2].Nodes[i] == e.Node)
                    {
                        LoaiSanPham loaiSanPham = e.Node.Tag as LoaiSanPham;
                        DanhSachSanPham = hienThiSanPhamBLL.HienThiDanhSachSanPhamTheoLoaiSP(loaiSanPham.MaLoaiSanPham);
                        HienThiDanhSachSanPham(DanhSachSanPham);
                        break;
                    }
                }
            }

            for (int i = 0; i < tvPhanLoaiSanPham.Nodes[3].Nodes.Count; i++)
            {
                if (e.Node.Level == 1)
                {
                    if (tvPhanLoaiSanPham.Nodes[3].Nodes[i] == e.Node)
                    {
                        NhaCungCap nhaCungCap = e.Node.Tag as NhaCungCap;
                        DanhSachSanPham = hienThiSanPhamBLL.HienThiDanhSachSanPhamTheoNCC(nhaCungCap.MaNhaCungCap);
                        HienThiDanhSachSanPham(DanhSachSanPham);
                        break;
                    }
                }
            }

            for (int i = 0; i < tvPhanLoaiSanPham.Nodes[4].Nodes.Count; i++)
            {
                if (e.Node.Level == 1)
                {
                    if (tvPhanLoaiSanPham.Nodes[4].Nodes[i] == e.Node)
                    {
                        NhaSanXuat nhaSanXuat = e.Node.Tag as NhaSanXuat;
                        DanhSachSanPham = hienThiSanPhamBLL.HienThiDanhSachSanPhamTheoNSX(nhaSanXuat.MaNhaSanXuat);
                        HienThiDanhSachSanPham(DanhSachSanPham);
                        break;
                    }
                }
            }

            //for (int i = 0; i < tvPhanLoaiSanPham.Nodes[5].Nodes.Count; i++)
            //{
            //    if (e.Node.Level == 1)
            //    {

            //        if (tvPhanLoaiSanPham.Nodes[5].Nodes[i] == e.Node)
            //        {
            //            SanPham soluong = e.Node.Tag as SanPham;
            //            DanhSachSanPham = hienThiSanPhamBLL.HienThiDanhSachSanPhamTheSoLuong(soluong.SoLuong);
            //            HienThiDanhSachSanPham(DanhSachSanPham);
            //            break;
            //        }
            //    }
            //}

            /*
             * if (e.Node.Level == 2)
             * {
             *  KhoHang khoHang = e.Node.Tag as KhoHang;
             *  HienThiDanhSachNhanVienTheoKhoHang(khoHang);
             *  KKhoHang = khoHang;
             * }
             * else
             * {
             *  KKhoHang = null;
             *  return;
             * }
             */
        }