private void btnXoa_Click(object sender, EventArgs e) { TheLoai theLoai = new TheLoai(); theLoai.MaTLoai = txtMa.Text; theLoai.TenTLoai = txtTen.Text; theLoai.GhiChu = txtGhiChu.Text; TheLoaiBUS theLoaiBUS = new TheLoaiBUS(); DialogResult dialogResult = MessageBox.Show("Bạn có chắc xoá mã " + txtMa.Text + "?", "Xác nhận xoá", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { if (theLoaiBUS.xoaTheLoai(theLoai)) { MessageBox.Show("Xoá OK !"); loadData(); } else { MessageBox.Show("Xoá lỗi !"); return; } } else { return; } }
private void dgvTL_CellContentClick(object sender, DataGridViewCellEventArgs e) { try { var senderGrid = (DataGridView)sender; if (senderGrid.Columns[e.ColumnIndex] is DataGridViewButtonColumn && e.RowIndex >= 0) { string maTL = txtMaTL.Text; string tenTL = txtTheLoai.Text; TheLoai tl = new TheLoai(maTL, tenTL); bool b = new TheLoaiBUS().DeleteTL(tl); if (b) { MessageBox.Show("Xóa Thành Công"); } Init(); } } catch (SqlException ex) { MessageBox.Show("Xóa thất bại", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void LoadDanhSachTheLoaiSach() { TheLoaiBUS TheLoaiBUS = new TheLoaiBUS(); DataTable dsTheLoai = TheLoaiBUS.LayDanhSachTheLoai(); dtgridviewTheLoaiSach.DataSource = dsTheLoai; }
private void btnXoaTL_Click(object sender, EventArgs e) { try { DialogResult result = MessageBox.Show("Bạn chắc chắn muốn xóa không ??", "Xóa thể loại " + txtTenTheLoai.Text, MessageBoxButtons.YesNo); switch (result) { case DialogResult.No: break; case DialogResult.Yes: TheLoaiBUS TheLoaiBUS = new TheLoaiBUS(); TheLoaiBUS.XoaTheLoai(txtMaTL.Text); MessageBox.Show("Xóa thành công"); LoadDanhSachTheLoaiSach(); break; default: break; } } catch (Exception ex) { MessageBox.Show("Xóa thất bại - Lỗi :" + ex.ToString()); } }
private void buttonThem_Click(object sender, EventArgs e) { if (txtTheLoai.Text.Equals("") == true) { MessageBox.Show("Nhập dữ liệu để thêm thể loại", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } TheLoai theLoai = new TheLoai(txtTheLoai.Text); TheLoaiBUS theLoaiBUS = new TheLoaiBUS(); if (theLoaiBUS.getByTenTheLoai(theLoai.TenTheLoai) == null) { //chua ton tai the loai trong CSDL if (theLoaiBUS.insert(theLoai) == true) { LoadDgvTheLoai(); MessageBox.Show("Thêm thể loại '" + theLoai.TenTheLoai + "' thành công", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("Thêm thể loại '" + theLoai.TenTheLoai + "' thất bại", "Thất bại", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //da ton tai trong CSDL MessageBox.Show("Thể loại '" + theLoai.TenTheLoai + "' đã tồn tại trong CSDL", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void button_Xoa_Click(object sender, EventArgs e) { if (txtTheLoai.Text.Equals("") == true) { MessageBox.Show("Chọn thể loại để xóa", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DialogResult dialogResult = MessageBox.Show("Bạn có chắc chắn muốn xóa thể loại '" + txtTheLoai.Text + "' hay không ?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { TheLoai theLoai = new TheLoai(txtTheLoai.Text); theLoai.MaTheLoai = this.maTheLoai; TheLoaiBUS theLoaiBUS = new TheLoaiBUS(); if (theLoaiBUS.delete(theLoai) == true) { MessageBox.Show("Thể loại '" + theLoai.TenTheLoai + "' đã được xóa", "Thành công", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); LoadDgvTheLoai(); } else { MessageBox.Show("Xóa thất bại", "Thất bại", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
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 = ""; }
private void TheLoai_Load() { cbbTheLoai.DataSource = TheLoaiBUS.GetList(); cbbTheLoai.ValueMember = "MaLoai"; cbbTheLoai.DisplayMember = "TenTheLoai"; cbbTheLoai.SelectedIndex = -1; }
private void btnXoa_Click(object sender, EventArgs e) { string idTheLoai = txtMaTheLoai.Text; string tenTheLoai = txtTenTheLoai.Text; if (idTheLoai != "" && tenTheLoai != "") { if (MessageBox.Show(this, $"Bạn có muốn xóa thể loại { tenTheLoai } không ?", "Xác nhận", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes) { try { TheLoaiBUS.DeleteTheLoai(idTheLoai); MessageBox.Show(this, "Xóa thể loại thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadTheLoai(); } catch { MessageBox.Show(this, "Không thể xóa thể loại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return; } MessageBox.Show(this, "ID thể loại không được để trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); }
private void frmTheLoaiSach_Load(object sender, EventArgs e) { List <TheLoai> list = new TheLoaiBUS().getTL(); dgvTL.DataSource = list; Init(); }
public QuanLySach() { theLoaiBUS = new TheLoaiBUS(); dauSachBUS = new DauSachBUS(); keSachBus = new KeSachBus(); InitializeComponent(); }
/* Sự kiện load form để lấy thể loại cho vào dgv */ private void FAddBookCategory_Load(object sender, EventArgs e) { List <TheLoaiDTO> theLoais = TheLoaiBUS.GetBookCategorys(); dgvBookCate.DataSource = theLoais; dgvBookCate.Columns[0].Visible = false; dgvBookCate.Columns[1].HeaderText = "Thể loại"; }
public Form1() { InitializeComponent(); dauSach = new DauSachBUS(); tacGia = new TacGiaBUS(); theLoai = new TheLoaiBUS(); nhaXuatBan = new NhaXuatBanBUS(); }
private void btnRefresh_Click(object sender, EventArgs e) { txtMaTL.Text = TheLoaiBUS.GetIDTheLoai(); txtTenTL.ResetText(); btnThem.Enabled = true; btnXoa.Enabled = false; btnSua.Enabled = false; LoadData(); }
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) { TheLoaiDTO theLoai = new TheLoaiDTO(); theLoai.MaLoai = ((TheLoaiDTO)cmbLoaiSach.SelectedItem).MaLoai; theLoai.TenTheLoai = txtLoaiSach.Text; TheLoaiBUS.Modify(theLoai); QuanLyLoaiSach_Load(sender, e); }
private void loadComboBoxLoaiSach() { TheLoaiBUS theLoaiBUS = new TheLoaiBUS(); DataTable dt = theLoaiBUS.getAllReturnDataTable(); cbLoaiSach.DisplayMember = "Tên thể loại"; cbLoaiSach.ValueMember = "Mã thể loại"; cbLoaiSach.DataSource = dt; }
private void loadCombo() { TheLoaiBUS theLoaiBUS = new TheLoaiBUS(); List <TheLoai> dsTheLoai = theLoaiBUS.getListTheLoai(); cboMaTLoai.DataSource = dsTheLoai.ToList(); cboMaTLoai.DisplayMember = "TenTLoai"; cboMaTLoai.ValueMember = "MaTLoai"; }
private void LoadTheLoai() { gvTheLoai.DataSource = null; var theloais = TheLoaiBUS.LoadTheLoai(); gvTheLoai.DataSource = theloais; gvTheLoai.Columns[0].HeaderText = "ID thể loại"; gvTheLoai.Columns[1].HeaderText = "Tên thể loại"; AddDataBinding(); }
private void Init() { List <TheLoai> list = new TheLoaiBUS().getTL(); dgvTL.DataSource = list; txtMaTL.DataBindings.Clear(); txtMaTL.DataBindings.Add("Text", list, "MaTheLoai"); txtTheLoai.DataBindings.Clear(); txtTheLoai.DataBindings.Add("Text", list, "TenTheLoai"); }
private void button1_Click(object sender, EventArgs e) { if (this.radioButton_BaoCaoTheoTheLoai.Checked == true) { bcBus = new BaoCaoBUS(); List <TheLoaiDTO> list; list = bcBus.select(); tlBUS = new TheLoaiBUS(); listTheLoai = tlBUS.select(""); listBaoCao = new List <BaoCaoDTO>(); pmBus = new PhieuMuonBUS(); int countnow = 0; listPhieuMuon = pmBus.select(); foreach (PhieuMuonDTO tl in listPhieuMuon) { if (tl.NgayMuon.Month == this.dateTimePicker1.Value.Month) { countnow++; } } foreach (TheLoaiDTO tl in listTheLoai) { int count = 0; foreach (TheLoaiDTO theloaimuon in list) { if (theloaimuon.Ngay.Month == this.dateTimePicker1.Value.Month) { if (tl.MaTheLoai == theloaimuon.MaTheLoai) { count++; } } } BaoCaoDTO temp = new BaoCaoDTO(); temp.MaTheLoai = tl.MaTheLoai; temp.SoLuotMuong = count; Console.WriteLine(countnow); if (countnow == 0) { temp.TyLe = "0%"; } else { temp.TyLe = "" + (count / countnow) * 100 + "%"; } temp.TenTheLoai = tl.TenTheLoai; listBaoCao.Add(temp); } this.label_TongSoLuotMuon.Text = countnow.ToString(); loadBaoCaoTheLoai_Vao_GridView(listBaoCao); } }
private void btnThem_Click(object sender, EventArgs e) { TheLoaiDTO tl = new TheLoaiDTO(); tl.TenTheLoai = txtTenTheLoai.Text; if (TheLoaiBUS.ThemTheLoai(tl) == false) { MessageBox.Show("Du lieu nhap vao da co trong co so du lieu", "Thong bao"); } HienThiDanhSach(); }
/* Sự kiện sửa tên thể loại */ private void dgvBookCate_CellEndEdit(object sender, DataGridViewCellEventArgs e) { TheLoaiDTO theLoai = (dgvBookCate.DataSource as List <TheLoaiDTO>)[e.RowIndex]; int check = TheLoaiBUS.ChangeBookCategory(theLoai); if (check < 1) { MessageBox.Show("Lưu không thành công.", "Thông báo"); this.OnLoad(new EventArgs()); } }
private void btnXoa_Click(object sender, EventArgs e) { if (TheLoaiBUS.XoaTL(dgvDanhSach.CurrentRow.Cells[0].Value.ToString()) == true) { txtMaTL.Text = TheLoaiBUS.GetIDTheLoai(); txtTenTL.ResetText(); LoadData(); } else { MessageBox.Show("Không thể xóa vì còn tồn tại sách thuộc thể loại đó.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnSua_Click(object sender, EventArgs e) { string idTheLoai = txtMaTheLoai.Text; string tenTheLoai = txtTenTheLoai.Text; if (idTheLoai != "" && tenTheLoai != "") { TheLoaiBUS.UpdateTheLoai(idTheLoai, tenTheLoai); MessageBox.Show(this, "Cập nhật thể loại thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadTheLoai(); return; } MessageBox.Show(this, "ID thể loại và tên thể loại không được để trống", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); }
private void InitBookCate() { List <TheLoaiDTO> bookCates = TheLoaiBUS.GetBookCategorys(); if (bookCates.Count > 0) { cbbBookCate.DataSource = bookCates; cbbBookCate.DisplayMember = "ten"; } else { cbbBookCate.Items.Add("Không tìm thấy thể loại"); cbbBookCate.SelectedIndex = 0; } }
private void btnThem_Click(object sender, EventArgs e) { if (txtThemTenLoaiSach.Text.Length == 0) { MessageBox.Show("Bạn Chưa Nhập Tên Thể Loại!", "Cảnh báo!"); } else { TheLoaiDTO theLoai = new TheLoaiDTO(); theLoai.TenTheLoai = txtThemTenLoaiSach.Text; TheLoaiBUS.Insert(theLoai); MessageBox.Show("Thêm thành công!", "Thông báo!"); this.Close(); } }
private void btnXoa_Click(object sender, EventArgs e) { TheLoaiDTO tl = new TheLoaiDTO(); tl.TenTheLoai = txtTenTheLoai.Text; if (TheLoaiBUS.XoaTheLoai(tl) == false) { MessageBox.Show("Xóa thất bại", "Thông báo"); } else { MessageBox.Show("Xóa thành công", "Thông báo"); HienThiDanhSach(); } }
/* Sự kiện load form để lấy thể loại cho vào cbb */ private void FAddTitle_Load(object sender, EventArgs e) { List <TheLoaiDTO> theLoais = TheLoaiBUS.GetBookCategorys(); if (theLoais.Count > 0) { cbbBookCate.DataSource = theLoais; cbbBookCate.DisplayMember = "Ten"; } else { cbbBookCate.Items.Add("Không tìm thấy thể loại"); cbbBookCate.SelectedIndex = 0; } }
private void btnSua_Click(object sender, EventArgs e) { TheLoaiDTO TL = new TheLoaiDTO(); TL.MaTL = txtMaTL.Text; TL.TenTL = txtTenTL.Text; if (TheLoaiBUS.SuaTL(TL) == true) { LoadData(); } else { MessageBox.Show("Cập nhật thất bại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } }