/// <summary> /// Tab danh sach san pham /// </summary> void LoadDataTabDSSP() { lstSanPham = SanPhamBUS.LayDanhSachSanPham(); lstNhaPP = NhaPhanPhoiBUS.LayDanhSachNhaPhanPhoi(); lstAnhMinhHoa = AnhMinhHoaSPBUS.LayDanhSachAnhMinhHoa(); //var kq = from sp in lstSanPham // select new // { // sp.MASP, // sp.TENSP, // sp.SL_TON, // sp.GIABAN, // sp.DVT, // sp.LOAISANPHAM.TENLOAI, // sp.NHAPHANPHOI.TENNPP // }; var kq = from sp in lstSanPham join npp in lstNhaPP on sp.MANPP equals npp.MANPP select new { sp.MASP, sp.TENSP, sp.SL_TON, sp.GIABAN, sp.DVT, sp.LOAISANPHAM.TENLOAI, npp.TENNPP }; this.dgvDSSanPham.DataSource = kq.ToList(); this.dgvDSSanPham.AutoGenerateColumns = false; }
void LoadDataDSNPP() { lstNPP = NhaPhanPhoiBUS.LayDanhSachNhaPhanPhoi().Where(p => p.TRANGTHAI == true).ToList(); this.dgvDSNhaPhanPhoi.AutoGenerateColumns = false; this.dgvDSNhaPhanPhoi.DataSource = lstNPP; this.txtMaNPP.Text = AutoMaNPP(); }
string AutoMaNPP() { string manpp = string.Empty; var lstnpp = NhaPhanPhoiBUS.LayDanhSachNhaPhanPhoi(); if (lstnpp.Count == 0) { manpp = "NPP1"; return(manpp); } else { manpp = lstnpp[lstnpp.Count - 1].MANPP.ToString(); int somanpp = Convert.ToInt32(manpp.Remove(0, 3)) + 1; manpp = "NPP" + somanpp; for (int i = 0; i < lstnpp.Count(); i++) { if (manpp == lstnpp[i].MANPP) { somanpp = Convert.ToInt32(manpp.Remove(0, 3)) + 1; manpp = "NPP" + somanpp; } } return(manpp); } }
void AutoCompleteMaNPP() { lstNhaPP = NhaPhanPhoiBUS.LayDanhSachNhaPhanPhoi(); AutoCompleteStringCollection collection = new AutoCompleteStringCollection(); foreach (NHAPHANPHOI item in lstNhaPP) { collection.Add(item.MANPP); } this.txtNhaPhanPhoi.AutoCompleteCustomSource = collection; this.txtNhaPhanPhoi.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.txtNhaPhanPhoi.AutoCompleteSource = AutoCompleteSource.CustomSource; }
void LoadComboBoxData() { this.cbDSLoaiSP.DataSource = LoaiSanPhamBUS.LayDanhSachLoaiSanPham(); this.cbDSLoaiSP.DisplayMember = "TENLOAI"; this.cbDSLoaiSP.ValueMember = "MALOAI"; this.cbDSNPP.DataSource = NhaPhanPhoiBUS.LayDanhSachNhaPhanPhoi(); this.cbDSNPP.DisplayMember = "TENNPP"; this.cbDSNPP.ValueMember = "MANPP"; this.cbQLTimKiemLoaiSP.DataSource = LoaiSanPhamBUS.LayDanhSachLoaiSanPham(); this.cbQLTimKiemLoaiSP.DisplayMember = "TENLOAI"; this.cbQLTimKiemLoaiSP.ValueMember = "MALOAI"; this.cbQLTimKiemNPP.DataSource = NhaPhanPhoiBUS.LayDanhSachNhaPhanPhoi(); this.cbQLTimKiemNPP.DisplayMember = "TENNPP"; this.cbQLTimKiemNPP.ValueMember = "MANPP"; }
/// <summary> /// Tab Quan ly san pham /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void LoadDataTabQLSP() { lstSanPham = SanPhamBUS.LayDanhSachSanPham(); lstNhaPP = NhaPhanPhoiBUS.LayDanhSachNhaPhanPhoi(); lstLoaiSp = LoaiSanPhamBUS.LayDanhSachLoaiSanPham(); lstAnhMinhHoa = AnhMinhHoaSPBUS.LayDanhSachAnhMinhHoa(); //var kq = from sp in lstSanPham // //join anhMH in lstAnhMinhHoa // //on sp.MASP equals anhMH.MASP // select new // { // sp.MASP, // sp.TENSP, // sp.SL_TON, // sp.GIABAN, // sp.DVT, // sp.LOAISANPHAM.TENLOAI, // sp.NHAPHANPHOI.TENNPP, // //anhMH.TENANHMINHHOA // }; var kq = from sp in lstSanPham join npp in lstNhaPP on sp.MANPP equals npp.MANPP join lsp in lstLoaiSp on sp.MALOAI equals lsp.MALOAI select new { sp.MASP, sp.TENSP, sp.SL_TON, sp.GIABAN, sp.DVT, lsp.TENLOAI, npp.TENNPP }; this.dgvDSSanPham.AutoGenerateColumns = false; this.dgvQLSanPham.DataSource = kq.ToList(); this.dgvQLSanPham.AutoSize = true; this.dgvQLSanPham.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; }