Exemplo n.º 1
0
        private void btnLuuCV_Click(object sender, EventArgs e)
        {
            DAL_CHUCVU cv    = new DAL_CHUCVU(txtMaCV.Text, txtTenCV.Text, Convert.ToInt32(txtSTGT.Text));
            DAO_CHUCVU daoCV = new DAO_CHUCVU();
            int        index = valCV == 1 ? dataCV.RowCount : dataCV.CurrentRow.Index;
            int        check = 0;

            if (valCV == 1)
            {
                check = daoCV.Insert_CV(cv);
            }
            else if (valCV == 2)
            {
                check = daoCV.Update_CV(cv);
            }
            else
            {
                return;
            }
            if (check != 0)
            {
                dataCV.DataSource  = cn.LoadTable(sqlCV);
                dataCV.CurrentCell = dataCV.Rows[index].Cells[0];
            }
            else
            {
                MessageBox.Show("Không thực hiện được thao tác!", "Thông báo!");
            }
            btnThemCV.Enabled = btnSuaCV.Enabled = btnXoaCV.Enabled = panelHH.Enabled = dataCV.Enabled = true;
            valCV             = 0; txtMaCV.ReadOnly = false;
            hienthiCV();
        }
Exemplo n.º 2
0
 private void btnXoaCV_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có muốn xóa chức vụ này?", "Verify!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         int        cur   = dataCV.CurrentRow.Index;
         DataRow    row   = cn.LoadTable(sqlCV).Rows[cur];
         DAL_CHUCVU cv    = new DAL_CHUCVU(row);
         DAO_CHUCVU daoCV = new DAO_CHUCVU();
         int        check = daoCV.Delete_CV(cv);
         int        index = dataCV.CurrentRow.Index == dataCV.RowCount - 1 ? dataCV.RowCount - 2 : cur;
         if (check != 0)
         {
             dataCV.DataSource = cn.LoadTable(sqlCV);
             if (dataCV.RowCount > 1)
             {
                 dataCV.CurrentCell = dataCV.Rows[index].Cells[0];
             }
         }
         else
         {
             MessageBox.Show("Không xóa được học hàm này!", "Thông báo!");
         }
         hienthiCV();
     }
 }