private void frmQuanLySach_Load(object sender, EventArgs e) { cmbTenTG.DataSource = TacGiaBUS.GetList(); cmbTenTG.DisplayMember = "TenTG"; cmbTenTG.ValueMember = "MaTG"; comboBox4.DataSource = NhaXuatBanBUS.GetList(); comboBox4.DisplayMember = "TenNXB"; comboBox4.ValueMember = "MaNXB"; cmbLoaiSach.DataSource = TheLoaiBUS.GetList(); cmbLoaiSach.DisplayMember = "TenTheLoai"; cmbLoaiSach.ValueMember = "MaLoai"; cmbNgonNgu.DataSource = NgonNguBUS.GetList(); cmbNgonNgu.DisplayMember = "TenNgonNgu"; cmbNgonNgu.ValueMember = "MaNgonNgu"; tbxTenSach.Text = ""; textBox2.Text = ""; cmbNgonNgu.Text = ""; cmbLoaiSach.Text = ""; cmbTenTG.Text = ""; comboBox4.Text = ""; }
void LoadData() { List <NhaXuatBan> nhaXuatBan = new List <NhaXuatBan>(); NhaXuatBanBUS busNhaXuatBan = new NhaXuatBanBUS(); nhaXuatBan = busNhaXuatBan.GetList(); dataGrid.Items.Clear(); id = 1; foreach (NhaXuatBan i in nhaXuatBan) { ThongTinNhaXuatBan thongTinNhaXuatBan = new ThongTinNhaXuatBan(); thongTinNhaXuatBan.MaNhaXuatBan = i.MaNXB; thongTinNhaXuatBan.TenNhaXuatBan = i.TenNXB; thongTinNhaXuatBan.DiaChi = i.DiaChiNXB; thongTinNhaXuatBan.SoDienThoai = i.SoDienThoai; dataGrid.IsReadOnly = true; dataGrid.Items.Add(thongTinNhaXuatBan); if (id < int.Parse(i.MaNXB)) { id = int.Parse(i.MaNXB); } } }
private void btnThem_Click(object sender, EventArgs e) { if (KiemTra() == "") { NhaXuatBanDTO NXB = new NhaXuatBanDTO(); NXB.MaNXB = txtMaNXB.Text; NXB.TenNXB = txtTenNXB.Text; NXB.DiaChi = txtDiaChi.Text; NXB.DienThoai = txtDienThoai.Text; if (NhaXuatBanBUS.ThemNXB(NXB) == true) { txtMaNXB.Text = NhaXuatBanBUS.GetIDNXB(); txtTenNXB.ResetText(); txtDiaChi.ResetText(); txtDienThoai.ResetText(); LoadData(); } else { MessageBox.Show("Thêm thất bại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(string.Format("{0}", KiemTra()), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public Form1() { InitializeComponent(); dauSach = new DauSachBUS(); tacGia = new TacGiaBUS(); theLoai = new TheLoaiBUS(); nhaXuatBan = new NhaXuatBanBUS(); }
private void frmPhieuNhapSach_Load(object sender, EventArgs e) { cboNXB.DataSource = NhaXuatBanBUS.DanhSachNXB(); cboNXB.DisplayMember = "TenNXB"; cboNXB.ValueMember = "MaNXB"; dgvDanhSach.AllowUserToAddRows = false; dtkNgayNhap.Value = DateTime.Now; dgvDanhSach.Rows.Clear(); }
private void frmBaoCaoSach_Load(object sender, EventArgs e) { NhaXuatBanBUS nxbBUS = new NhaXuatBanBUS(); bdsNXB.DataSource = nxbBUS.LayDanhSach(); TheLoaiBUS tlBUS = new TheLoaiBUS(); bdsTheLoai.DataSource = tlBUS.LayDanhSach(); }
private void btnCapNhat_Click(object sender, EventArgs e) { NhaXuatBanDTO NXB = new NhaXuatBanDTO(); NXB.MaNXB = ((NhaXuatBanDTO)cmbNXB.SelectedItem).MaNXB; NXB.TenNXB = txtNXB.Text; NhaXuatBanBUS.Modify(NXB); QuanLyNXB_Load(sender, e); }
private void btnRefresh_Click(object sender, EventArgs e) { txtMaNXB.Text = NhaXuatBanBUS.GetIDNXB(); txtTenNXB.ResetText(); txtDiaChi.ResetText(); txtDienThoai.ResetText(); btnThem.Enabled = true; btnXoa.Enabled = false; btnSua.Enabled = false; LoadData(); }
private void btnXoa_Click(object sender, EventArgs e) { if (NhaXuatBanBUS.XoaNXB(dgvDanhSach.CurrentRow.Cells[0].Value.ToString()) == true) { txtMaNXB.Text = NhaXuatBanBUS.GetIDNXB(); txtTenNXB.ResetText(); txtDiaChi.ResetText(); txtDienThoai.ResetText(); LoadData(); } else { MessageBox.Show("Không thể xóa vì còn tồn tại sách thuộc nhà xuất bản đó.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnThem_Click(object sender, EventArgs e) { if (txtThemTenNXB.Text.Length == 0) { MessageBox.Show("Bạn Chưa Nhập Tên Nhà Xuất Bản!", "Cảnh báo!"); } else { NhaXuatBanDTO NXB = new NhaXuatBanDTO(); NXB.TenNXB = txtThemTenNXB.Text; NhaXuatBanBUS.Insert(NXB); MessageBox.Show("Thêm thành công!", "Thông báo!"); this.Close(); } }
private void frmThemSach_Load(object sender, EventArgs e) { cboTheLoai.DataSource = TheLoaiBUS.DanhSachTheLoai(); cboTheLoai.DisplayMember = "TenTL"; cboTheLoai.ValueMember = "MaTL"; cboTacGia.DataSource = TacGiaBUS.DanhSachTacGia(); cboTacGia.DisplayMember = "TenTG"; cboTacGia.ValueMember = "MaTG"; cboNXB.DataSource = NhaXuatBanBUS.DanhSachNXB(); cboNXB.DisplayMember = "TenNXB"; cboNXB.ValueMember = "MaNXB"; txtMaSach.Text = SachBUS.GetIDSach(); }
private void btnSua_Click(object sender, EventArgs e) { NhaXuatBanDTO NXB = new NhaXuatBanDTO(); NXB.MaNXB = txtMaNXB.Text; NXB.TenNXB = txtTenNXB.Text; NXB.DiaChi = txtDiaChi.Text; NXB.DienThoai = txtDienThoai.Text; if (NhaXuatBanBUS.SuaNXB(NXB) == true) { LoadData(); } else { MessageBox.Show("Cập nhật thất bại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btXoa_Click(object sender, RoutedEventArgs e) { NhaXuatBanBUS bus = new NhaXuatBanBUS(); try { bus.Delete(tbMaNhaXuatBan.Text); MessageBox.Show("Xóa thành công !"); } catch (Exception) { MessageBox.Show("Xóa thất bại !"); } LoadData(); }
public frmSuaSach(SachDTO S) { InitializeComponent(); cboTheLoai.DataSource = TheLoaiBUS.DanhSachTheLoai(); cboTheLoai.DisplayMember = "TenTL"; cboTheLoai.ValueMember = "MaTL"; cboTacGia.DataSource = TacGiaBUS.DanhSachTacGia(); cboTacGia.DisplayMember = "TenTG"; cboTacGia.ValueMember = "MaTG"; cboNXB.DataSource = NhaXuatBanBUS.DanhSachNXB(); cboNXB.DisplayMember = "TenNXB"; cboNXB.ValueMember = "MaNXB"; txtMaSach.Text = S.MaSach; txtTenSach.Text = S.TenSach; cboTheLoai.SelectedValue = S.MaTL; cboTacGia.SelectedValue = S.MaTG; cboNXB.SelectedValue = S.MaNXB; }
private void btThem_Click(object sender, RoutedEventArgs e) { NhaXuatBan nhaXuatBan = new NhaXuatBan() { MaNXB = (++id).ToString(), TenNXB = tbTenTacGia.Text, DiaChiNXB = tbDiaChi.Text, SoDienThoai = tbSoDienThoai.Text }; NhaXuatBanBUS bus = new NhaXuatBanBUS(); try { bus.Insert(nhaXuatBan); MessageBox.Show("Thêm thành công !"); } catch (Exception) { MessageBox.Show("Thêm thất bại !"); } LoadData(); }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { List <Sach> _sach = new List <Sach>(); SachBUS _busSach = new SachBUS(); dataGrid.Items.Clear(); _sach = _busSach.GetList(); List <TacGia> _tacGia = new List <TacGia>(); TacGiaBUS _busTacGia = new TacGiaBUS(); _tacGia = _busTacGia.GetList(); List <NhaXuatBan> _nhaXuatBan = new List <NhaXuatBan>(); NhaXuatBanBUS _busNhaXuatBan = new NhaXuatBanBUS(); _nhaXuatBan = _busNhaXuatBan.GetList(); List <TheLoai> _theLoai = new List <TheLoai>(); TheLoaiBUS _busTheLoai = new TheLoaiBUS(); _theLoai = _busTheLoai.GetList(); foreach (Sach i in _sach) { ThongTinSach _thongTinSach = new ThongTinSach(); _thongTinSach.MaSach = i.MaSach; _thongTinSach.TenSach = i.TenSach; _thongTinSach.TheLoai = LayTenTheLoai(_theLoai, i.TheLoai); _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia); _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan); _thongTinSach.NamXuatBan = i.NamXuatBan; _thongTinSach.GiaBan = i.GiaBan.ToString(); _thongTinSach.SoLuong = i.SoLuong; dataGrid.Items.Add(_thongTinSach); } }
private void btSua_Click(object sender, RoutedEventArgs e) { NhaXuatBan nhaXuatBan = new NhaXuatBan() { MaNXB = tbMaNhaXuatBan.Text, TenNXB = tbTenTacGia.Text, DiaChiNXB = tbDiaChi.Text, SoDienThoai = tbSoDienThoai.Text }; NhaXuatBanBUS bus = new NhaXuatBanBUS(); try { bus.Update(nhaXuatBan); MessageBox.Show("Sửa thành công !"); } catch (Exception) { MessageBox.Show("Sửa thất bại !"); } LoadData(); }
private void btnXem_Click(object sender, EventArgs e) { SachBUS sBUS = new SachBUS(); DataTable dt = new DataTable(); if (radTatCa.Checked) { frmReport f = new frmReport(); f.TopLevel = false; AddControlsToPanel(f); dt = sBUS.LayDanhSach(); f.rpvReport.LocalReport.ReportEmbeddedResource = "QuanLyCuaHangSach.rptDSSach.rdlc"; f.rpvReport.LocalReport.DataSources.Add(new ReportDataSource("dsSach", dt)); f.rpvReport.RefreshReport(); } if (radTheoTheLoai.Checked) { frmReport f = new frmReport(); f.TopLevel = false; AddControlsToPanel(f); dt = sBUS.LayDSSachTheoTheLoai((int)cboTheLoai.SelectedValue); f.rpvReport.LocalReport.ReportEmbeddedResource = "QuanLyCuaHangSach.rptDSSachTheoTheLoai.rdlc"; f.rpvReport.LocalReport.DataSources.Add(new ReportDataSource("dsSach", dt)); f.rpvReport.LocalReport.SetParameters(new ReportParameter("paTheLoai", cboTheLoai.Text, false)); f.rpvReport.RefreshReport(); } if (radTheoNXB.Checked) { frmReport f = new frmReport(); f.TopLevel = false; AddControlsToPanel(f); dt = sBUS.LayDSSachTheoNXB((int)cboNXB.SelectedValue); f.rpvReport.LocalReport.ReportEmbeddedResource = "QuanLyCuaHangSach.rptDSSachTheoNXB.rdlc"; f.rpvReport.LocalReport.DataSources.Add(new ReportDataSource("dsSach", dt)); f.rpvReport.LocalReport.SetParameters(new ReportParameter("paNXB", cboNXB.Text, false)); f.rpvReport.RefreshReport(); } if (radNhomTheLoai.Checked) { frmReport f = new frmReport(); f.TopLevel = false; AddControlsToPanel(f); TheLoaiBUS tlBUS = new TheLoaiBUS(); DataTable dtTL = tlBUS.LayDanhSach(); f.rpvReport.LocalReport.ReportEmbeddedResource = "QuanLyCuaHangSach.rptDSSachTheLoaiGroup.rdlc"; f.rpvReport.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing); f.rpvReport.LocalReport.DataSources.Add(new ReportDataSource("dsSach", dtTL)); f.rpvReport.RefreshReport(); } if (radNhomNXB.Checked) { frmReport f = new frmReport(); f.TopLevel = false; AddControlsToPanel(f); NhaXuatBanBUS nxbBUS = new NhaXuatBanBUS(); DataTable dtNXB = nxbBUS.LayDanhSach(); f.rpvReport.LocalReport.ReportEmbeddedResource = "QuanLyCuaHangSach.rptDSSachNXBGroup.rdlc"; f.rpvReport.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(LocalReport_SubreportProcessing); f.rpvReport.LocalReport.DataSources.Add(new ReportDataSource("dsSach", dtNXB)); f.rpvReport.RefreshReport(); } }
private void frmCapNhatSach_Load(object sender, EventArgs e) { try { cmbTenTG.DataSource = TacGiaBUS.GetList(); cmbTenTG.DisplayMember = "TenTG"; cmbTenTG.ValueMember = "MaTG"; cmbNhaXuatBan.DataSource = NhaXuatBanBUS.GetList(); cmbNhaXuatBan.DisplayMember = "TenNXB"; cmbNhaXuatBan.ValueMember = "MaNXB"; cmbLoaiSach.DataSource = TheLoaiBUS.GetList(); cmbLoaiSach.DisplayMember = "TenTheLoai"; cmbLoaiSach.ValueMember = "MaLoai"; cmbNgonNgu.DataSource = NgonNguBUS.GetList(); cmbNgonNgu.DisplayMember = "TenNgonNgu"; cmbNgonNgu.ValueMember = "MaNgonNgu"; int maSach = TimKiemSach.MaSach; SachBUS sachBUS = new SachBUS(); SachDTO sachDTO = null; sachDTO = sachBUS.Search_MaSach(maSach); tbxTenSach.Text = sachDTO.TenSach; txtSoTrang.Text = sachDTO.SoTrang.ToString(); TacGiaBUS tacgiaBUS = new TacGiaBUS(); TacGiaDTO tacgiaDTO = null; tacgiaDTO = tacgiaBUS.LayTenTacGia(sachDTO.MaTacGia); cmbTenTG.Text = tacgiaDTO.TenTG; NhaXuatBanBUS nxbBUS = new NhaXuatBanBUS(); NhaXuatBanDTO nxbDTO = null; nxbDTO = nxbBUS.LayTenNhaXuatBan(sachDTO.MaNXB); cmbNhaXuatBan.Text = nxbDTO.TenNXB; NgonNguBUS nnBUS = new NgonNguBUS(); NgonNguDTO nnDTO = null; nnDTO = nnBUS.LayTenNgonNgu(sachDTO.MaNgonNgu); cmbNgonNgu.Text = nnDTO.TenNgonNgu; TheLoaiBUS tlBUS = new TheLoaiBUS(); TheLoaiDTO tlDTO = null; tlDTO = tlBUS.LayTenTheLoai(sachDTO.MaTheLoai); cmbLoaiSach.Text = tlDTO.TenTheLoai; if (sachDTO.TrangThai == 0) { cmbTinhTrang.Text = "Chưa mượn"; } else { cmbTinhTrang.Text = "Đã mượn"; } } catch (System.Exception ex) { MessageBox.Show(ex.Message); } }
void Custom() { dgvDanhSach.AutoGenerateColumns = false; dgvDanhSach.Columns.Clear(); dgvDanhSach.AllowUserToAddRows = false; DataGridViewTextBoxColumn dgvCol = new DataGridViewTextBoxColumn(); dgvCol.HeaderText = "Mã sách"; dgvCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells; dgvCol.DataPropertyName = "MaSach"; dgvCol.ReadOnly = true; dgvDanhSach.Columns.Add(dgvCol); dgvCol = new DataGridViewTextBoxColumn(); dgvCol.HeaderText = "Tên sách"; dgvCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; dgvCol.DataPropertyName = "TenSach"; dgvCol.ReadOnly = true; dgvCol.Width = 400; dgvDanhSach.Columns.Add(dgvCol); DataGridViewComboBoxColumn dgvCo = new DataGridViewComboBoxColumn(); dgvCo.HeaderText = "Thể loại"; dgvCo.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvCo.DataSource = TheLoaiBUS.DanhSachTheLoai(); dgvCo.DisplayMember = "TenTL"; dgvCo.ValueMember = "MaTL"; dgvCo.DataPropertyName = "MaTL"; dgvCo.ReadOnly = true; dgvCo.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; dgvDanhSach.Columns.Add(dgvCo); dgvCo = new DataGridViewComboBoxColumn(); dgvCo.HeaderText = "Nhà xuất bản"; dgvCo.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvCo.DataSource = NhaXuatBanBUS.DanhSachNXB(); dgvCo.DisplayMember = "TenNXB"; dgvCo.ValueMember = "MaNXB"; dgvCo.DataPropertyName = "MaNXB"; dgvCo.ReadOnly = true; dgvCo.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; dgvDanhSach.Columns.Add(dgvCo); dgvCo = new DataGridViewComboBoxColumn(); dgvCo.HeaderText = "Tác giả"; dgvCo.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvCo.DataSource = TacGiaBUS.DanhSachTacGia(); dgvCo.DisplayMember = "TenTG"; dgvCo.ValueMember = "MaTG"; dgvCo.DataPropertyName = "MaTG"; dgvCo.ReadOnly = true; dgvCo.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing; dgvDanhSach.Columns.Add(dgvCo); dgvCol = new DataGridViewTextBoxColumn(); dgvCol.HeaderText = "Số lượng tồn"; dgvCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.None; dgvCol.DataPropertyName = "SoLuongTon"; dgvCol.ReadOnly = true; dgvCol.Width = 110; dgvDanhSach.Columns.Add(dgvCol); dgvCol = new DataGridViewTextBoxColumn(); dgvCol.HeaderText = "Giá bán (VNĐ)"; dgvCol.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dgvCol.DataPropertyName = "GiaBan"; dgvCol.ReadOnly = true; dgvCol.DefaultCellStyle.Format = "0,00"; dgvDanhSach.Columns.Add(dgvCol); }
private void QuanLyNXB_Load(object sender, EventArgs e) { cmbNXB.DataSource = NhaXuatBanBUS.GetList(); cmbNXB.ValueMember = "MaNXB"; cmbNXB.DisplayMember = "TenNXB"; }
private void btTim_Click(object sender, RoutedEventArgs e) { List <Sach> _sach = new List <Sach>(); SachBUS _busSach = new SachBUS(); dataGrid.Items.Clear(); _sach = _busSach.GetList(); string _maTheLoai = ""; foreach (TheLoai i in _theLoai) { if (i.TenTheLoai == cbbTheLoai.Text) { _maTheLoai = i.MaTheLoai; break; } } List <TacGia> _tacGia = new List <TacGia>(); TacGiaBUS _busTacGia = new TacGiaBUS(); _tacGia = _busTacGia.GetList(); List <NhaXuatBan> _nhaXuatBan = new List <NhaXuatBan>(); NhaXuatBanBUS _busNhaXuatBan = new NhaXuatBanBUS(); _nhaXuatBan = _busNhaXuatBan.GetList(); int stt = 1; if (tbTenSach.Text == "") { foreach (Sach i in _sach) { if (i.TheLoai == _maTheLoai) { ThongTinSach _thongTinSach = new ThongTinSach(); _thongTinSach.Stt = stt++; _thongTinSach.TenSach = i.TenSach; _thongTinSach.TheLoai = cbbTheLoai.Text; _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia); _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan); _thongTinSach.NamXuatBan = i.NamXuatBan; _thongTinSach.GiaBan = i.GiaBan.ToString(); _thongTinSach.SoLuong = i.SoLuong; dataGrid.Items.Add(_thongTinSach); } } } else if (tbTenSach.Text != "" && cbbTheLoai.Text != "") { foreach (Sach i in _sach) { if (String.Compare(i.TenSach, tbTenSach.Text, true) == 0 && i.TheLoai == _maTheLoai) { ThongTinSach _thongTinSach = new ThongTinSach(); _thongTinSach.Stt = stt++; _thongTinSach.TenSach = i.TenSach; _thongTinSach.TheLoai = cbbTheLoai.Text; _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia); _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan); _thongTinSach.NamXuatBan = i.NamXuatBan; _thongTinSach.GiaBan = i.GiaBan.ToString(); _thongTinSach.SoLuong = i.SoLuong; dataGrid.Items.Add(_thongTinSach); } } } else if (tbTenSach.Text != "") { foreach (Sach i in _sach) { if (String.Compare(i.TenSach, tbTenSach.Text, true) == 0) { ThongTinSach _thongTinSach = new ThongTinSach(); _thongTinSach.Stt = stt++; _thongTinSach.TenSach = i.TenSach; _thongTinSach.TheLoai = LayTenTheLoai(_theLoai, i.TheLoai); _thongTinSach.TacGia = LayTenTacGia(_tacGia, i.TacGia); _thongTinSach.NhaXuatBan = LayTenNhaXuatBan(_nhaXuatBan, i.NhaXuatBan); _thongTinSach.NamXuatBan = i.NamXuatBan; _thongTinSach.GiaBan = i.GiaBan.ToString(); _thongTinSach.SoLuong = i.SoLuong; dataGrid.Items.Add(_thongTinSach); } } } }
private void frmNhaXuatBan_Load(object sender, EventArgs e) { txtMaNXB.Text = NhaXuatBanBUS.GetIDNXB(); LoadData(); }
void LoadData() { dgvDanhSach.DataSource = NhaXuatBanBUS.DanhSachNXB(); Custom(); dgvDanhSach.ClearSelection(); }
private void frmTimKiemTheoNXB_Load(object sender, EventArgs e) { cboNXB.DataSource = NhaXuatBanBUS.DanhSachNXB(); cboNXB.DisplayMember = "TenNXB"; cboNXB.ValueMember = "MaNXB"; }