Пример #1
0
        public void Sua(ref DataGridViewX dgvLoaiSach, ref TextBoxX txtMaLoaiSachQDS, ref TextBoxX txtTenLoaiSachQDS, QDLoaiSachBUS lsBUS)
        {
            if (string.IsNullOrEmpty(txtMaLoaiSachQDS.Text) == false || string.IsNullOrEmpty(txtTenLoaiSachQDS.Text) == false)
            {
                QDLoaiSachDTO lsDTO = new QDLoaiSachDTO();
                lsBUS.MapDataLSFromGUILoaiSach(ref lsDTO, txtMaLoaiSachQDS, txtTenLoaiSachQDS);
                if (lsBUS.IsTrungKhopKhoaChinh(lsDTO.Matheloai, dgvLoaiSach))
                {
                    MessageBox.Show("Trùng mã quy định sách", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }

                if (lsBUS.Sua(lsDTO))
                {
                    MessageBox.Show("Cập nhật thành công");
                    lsBUS.LoadPanelLoaiSach(ref dgvLoaiSach, ref txtMaLoaiSachQDS, ref txtTenLoaiSachQDS, lsBUS);
                }

                else
                {
                    MessageBox.Show("Cập nhật không thành công", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Dữ liệu không đầy đủ", "Asterrisk", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Пример #2
0
 public void Xoa(ref DataGridViewX dgvLoaiSach, ref TextBoxX txtMaLoaiSachQDS, ref TextBoxX txtTenLoaiSachQDS, QDLoaiSachBUS lsBUS)
 {
     if (dgvLoaiSach.RowCount != 0)
     {
         QDLoaiSachDTO lsDTO   = new QDLoaiSachDTO();
         string        chuoiLS = "";
         foreach (DataGridViewRow row in dgvLoaiSach.SelectedRows)
         {
             lsDTO.Matheloai = row.Cells["MATHELOAI"].Value.ToString();
             lsBUS.Xoa(lsDTO, ref chuoiLS);
         }
         if (chuoiLS != "")
         {
             MessageBox.Show("Thể loại sách có mã: " + chuoiLS + " đang được sử dụng cho sách nên không thể xóa", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             chuoiLS = "";
         }
         lsBUS.LoadPanelLoaiSach(ref dgvLoaiSach, ref txtMaLoaiSachQDS, ref txtTenLoaiSachQDS, lsBUS);
     }
 }