Beispiel #1
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            string       maLoaiSach  = txtMaLoaiSach.Text;
            string       tenLoaiSach = txtTenLoaiSach.Text;
            string       trangThai   = "Tồn tại";
            BEL_LoaiSach loaiSach    = new BEL_LoaiSach(maLoaiSach, tenLoaiSach, trangThai);

            //
            try
            {
                if (BAL_LoaiSach.Add(loaiSach))
                {
                    MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //
                    txtMaLoaiSach.Text = "LS" + (BAL_LoaiSach.Count() + 1);
                    txtTenLoaiSach.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);
            }
        }
Beispiel #2
0
        private void btnThemLoaiSach_Click(object sender, EventArgs e)
        {
            frmThemLoaiSach frmThemLoaiSach = new frmThemLoaiSach();

            frmThemLoaiSach.ShowDialog();
            //
            loadDanhSachLoaiSach(dgvDanhSachLoaiSach, BAL_LoaiSach.Load());
            for (int i = 0; i < dgvDanhSachLoaiSach.RowCount; i++)
            {
                if (dgvDanhSachLoaiSach["MaLoai", i].Value.ToString() == ("LS" + BAL_LoaiSach.Count()))
                {
                    dgvDanhSachLoaiSach["MaLoai", i].Selected = true;
                }
            }
        }
Beispiel #3
0
 private void frmThemLoaiSach_Load(object sender, EventArgs e)
 {
     txtMaLoaiSach.Text = "LS" + (BAL_LoaiSach.Count() + 1);
 }