Example #1
0
 private void btnCancel_Click(object sender, EventArgs e)
 {
     LoadData();
     ResetControls();
     theloai = null;
     IsAdd   = true;
 }
Example #2
0
 // xóa nhà xuất bản
 private void XoaTheLoai()
 {
     BUS.TheLoaiBUS.XoaTheLoai(theloai);
     MessageBox.Show(BUS.TheLoaiBUS.Message);
     if (BUS.TheLoaiBUS.IsSuccess)
     {
         LoadData();
         ResetControls();
         theloai = null;
         IsAdd   = true;
     }
 }
Example #3
0
 // sửa nhà xuất bản
 private void SuaTheLoai()
 {
     if (!this.CheckData())
     {
         return;
     }
     theloai.TenTheLoai = txtTenTheLoai.Text;
     BUS.TheLoaiBUS.SuaTheLoai(theloai);
     MessageBox.Show(BUS.TheLoaiBUS.Message);
     if (BUS.TheLoaiBUS.IsSuccess)
     {
         LoadData();
         ResetControls();
         theloai = null;
         IsAdd   = true;
     }
 }
Example #4
0
 private void dgvDanhSach_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         int rowIndex = e.RowIndex;
         int id       = Int32.Parse(dgvDanhSach.Rows[rowIndex].Cells[0].Value.ToString());
         theloai = DanhSachTheLoai.Find(tl => tl.MaTheLoai == id);
         if (theloai == null)
         {
             return;
         }
         IsAdd = false;
         txtTenTheLoai.Text = theloai.TenTheLoai;
         btnDelete.Enabled  = true;
     }
     catch (Exception er)
     {
     }
 }
Example #5
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (checkErr().Length == 0)
            {
                if (choose == 1)
                {

                    #region Thêm
                    try
                    {
                        DTO.TheLoai TheLoaiThem = new DTO.TheLoai();
                        TheLoaiThem.TenTL = txtTenTL.Text.Trim();
                        TheLoaiThem.GhiChu = txtGhiChu.Text.Trim();
                        if (theLoaiBUS.themTheLoai(TheLoaiThem))
                        {
                            MessageBox.Show("Thêm Thể Loại thành công!");
                            loadGridView();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                    //viết hàm thêm
                    #endregion
                }
                else
                        if (choose == 2)
                {
                    #region Sửa
                    //viết hàm sửa
                    DTO.TheLoai TheLoaiSua = new DTO.TheLoai();

                    TheLoaiSua.MaTL = TheLoaiID;
                    TheLoaiSua.TenTL = txtTenTL.Text.Trim();
                    TheLoaiSua.GhiChu = txtGhiChu.Text.Trim();
                    TheLoaiSua.MaTL = TheLoaiID;
                    if (theLoaiBUS.suaTheLoai(TheLoaiSua))
                    {
                        MessageBox.Show("Sửa Thể Loại thành công!");
                        loadGridView();
                    }
                    #endregion
                }
                else if (choose == 3)
                {
                    #region Xóa
                    //viết hàm xóa
                    DTO.TheLoai TheLoaiXoa = new DTO.TheLoai();
                    TheLoaiXoa.MaTL = TheLoaiID;
                    if (theLoaiBUS.xoaTheLoai(TheLoaiXoa))
                    {
                        MessageBox.Show("Xóa Thể Loại thành công!");
                        loadGridView();
                    }
                    #endregion
                }
            }
            else
            {
                MessageBox.Show(checkErr(), "Lỗi");
            }
        }