Example #1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            string         maNhaXuatBan  = txtMaNhaXuatBan.Text;
            string         tenNhaXuatBan = txtTenNhaXuatBan.Text;
            string         email         = txtEmail.Text;
            string         trangThai     = "Tồn tại";
            BEL_NhaXuatBan nhaXuatBan    = new BEL_NhaXuatBan(maNhaXuatBan, tenNhaXuatBan, email, trangThai);

            //
            try
            {
                if (BAL_NhaXuatBan.Add(nhaXuatBan))
                {
                    MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //
                    txtMaNhaXuatBan.Text = "NXB" + (BAL_NhaXuatBan.Count() + 1);
                    txtTenNhaXuatBan.Focus();
                }
                else
                {
                    MessageBox.Show("Thêm thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void btnXoaNhaXuatBan_Click(object sender, EventArgs e)
        {
            string maNhaXuatBan = txtMaNhaXuatBan.Text;
            //
            DialogResult xoa = MessageBox.Show("Bạn có chắc xóa không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (xoa == DialogResult.Yes)
            {
                try
                {
                    if (BAL_NhaXuatBan.Delete(maNhaXuatBan))
                    {
                        MessageBox.Show("Xóa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        loadDanhSachNhaXuatBan(dgvDanhSachNhaXuatBan, BAL_NhaXuatBan.Load());
                        //
                        txtMaNhaXuatBan.Text    = "";
                        txtTenNhaXuatBan.Text   = "";
                        txtEmailNhaXuatBan.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("Xóa thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #3
0
        private void btnSuaNhaXuatBan_Click(object sender, EventArgs e)
        {
            string         maNhaXuatBan  = txtMaNhaXuatBan.Text;
            string         tenNhaXuatBan = txtTenNhaXuatBan.Text;
            string         email         = txtEmailNhaXuatBan.Text;
            string         trangThai     = "Tồn tại";
            BEL_NhaXuatBan nhaXuatBan    = new BEL_NhaXuatBan(maNhaXuatBan, tenNhaXuatBan, email, trangThai);

            try
            {
                if (BAL_NhaXuatBan.Update(nhaXuatBan))
                {
                    MessageBox.Show("Cập nhật thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    loadDanhSachNhaXuatBan(dgvDanhSachNhaXuatBan, BAL_NhaXuatBan.Load());
                    //
                    for (int i = 0; i < dgvDanhSachNhaXuatBan.RowCount; i++)
                    {
                        if (dgvDanhSachNhaXuatBan["MaNhaXuatBan", i].Value.ToString() == maNhaXuatBan)
                        {
                            dgvDanhSachNhaXuatBan["MaNhaXuatBan", i].Selected = true;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Cập nhật thất bại!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #4
0
        private void dgvDanhSachNhaXuatBan_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            string         maNhaXuatBan = dgvDanhSachNhaXuatBan.CurrentRow.Cells["MaNhaXuatBan"].Value.ToString().Trim();
            BEL_NhaXuatBan nhaXuatBan   = BAL_NhaXuatBan.GetObjectById(maNhaXuatBan);

            txtMaNhaXuatBan.Text    = nhaXuatBan.Ma;
            txtTenNhaXuatBan.Text   = nhaXuatBan.Ten;
            txtEmailNhaXuatBan.Text = nhaXuatBan.Email;
        }
Example #5
0
        private void btnThemNhaXuatBan_Click(object sender, EventArgs e)
        {
            frmThemNhaXuatBan frmThemNhaXuatBan = new frmThemNhaXuatBan();

            frmThemNhaXuatBan.ShowDialog();
            //
            loadDanhSachNhaXuatBan(dgvDanhSachNhaXuatBan, BAL_NhaXuatBan.Load());
            for (int i = 0; i < dgvDanhSachNhaXuatBan.RowCount; i++)
            {
                if (dgvDanhSachNhaXuatBan["MaNhaXuatBan", i].Value.ToString() == ("NXB" + BAL_NhaXuatBan.Count()))
                {
                    dgvDanhSachNhaXuatBan["MaNhaXuatBan", i].Selected = true;
                }
            }
        }
Example #6
0
        private void frmThuThu_Load(object sender, EventArgs e)
        {
            tmrTime.Start();
            DateTime dateTime = DateTime.Now;

            lblNgayGio.Text          = dateTime.ToString("  HH:mm:ss \ndd/MM/yyyy");
            lblNhanVienDangNhap.Text = "Xin chào,  " + tenNhanVienDangNhap;
            //
            khoaTextBoxThongTinTimKiem(true);
            //
            loadDanhSachTacGia(dgvDanhSachTacGia, BAL_TacGia.Load());
            loadDanhSachNhaXuatBan(dgvDanhSachNhaXuatBan, BAL_NhaXuatBan.Load());
            loadDanhSachNgonNgu(dgvDanhSachNgonNgu, BAL_NgonNgu.Load());
            loadDanhSachLoaiSach(dgvDanhSachLoaiSach, BAL_LoaiSach.Load());
            //
        }
Example #7
0
        private void txtThongTinTimKiemNhaXuatBan_TextChanged(object sender, EventArgs e)
        {
            string thongTinTimKiem = txtThongTinTimKiemNhaXuatBan.Text;

            if (thongTinTimKiem != "")
            {
                try
                {
                    if (cboPhuongThucTimKiemNhaXuatBan.SelectedItem.ToString() == "Tìm kiếm theo mã nhà xuất bản")
                    {
                        if (BAL_NhaXuatBan.SearchById(thongTinTimKiem) != null)
                        {
                            loadDanhSachNhaXuatBan(dgvDanhSachNhaXuatBan, BAL_NhaXuatBan.SearchById(thongTinTimKiem));
                        }
                        else
                        {
                            loadDanhSachNhaXuatBan(dgvDanhSachNhaXuatBan, BAL_NhaXuatBan.Load());
                        }
                    }
                    else if (cboPhuongThucTimKiemNhaXuatBan.SelectedItem.ToString() == "Tìm kiếm theo tên nhà xuất bản")
                    {
                        if (BAL_NhaXuatBan.SearchByName(thongTinTimKiem) != null)
                        {
                            loadDanhSachNhaXuatBan(dgvDanhSachNhaXuatBan, BAL_NhaXuatBan.SearchByName(thongTinTimKiem));
                        }
                        else
                        {
                            loadDanhSachNhaXuatBan(dgvDanhSachNhaXuatBan, BAL_NhaXuatBan.Load());
                        }
                    }
                }
                catch (Exception err)
                {
                    MessageBox.Show(err.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                loadDanhSachNhaXuatBan(dgvDanhSachNhaXuatBan, BAL_NhaXuatBan.Load());
            }
        }
Example #8
0
 private void frmThemNhaXuatBan_Load(object sender, EventArgs e)
 {
     txtMaNhaXuatBan.Text = "NXB" + (BAL_NhaXuatBan.Count() + 1);
     txtTenNhaXuatBan.Focus();
 }