Пример #1
0
        private void btnLuuHE_Click(object sender, EventArgs e)
        {
            DAL_HEDT hh    = new DAL_HEDT(txtMAHE.Text, txtTENHE.Text);
            DAO_HEDT daoHH = new DAO_HEDT();
            int      index = valHE == 1 ? dataHE.RowCount : dataHE.CurrentRow.Index;
            int      check = 0;

            if (valHE == 1)
            {
                check = daoHH.Insert_HE(hh);
            }
            else if (valHE == 2)
            {
                check = daoHH.Update_HE(hh);
            }
            else
            {
                return;
            }
            if (check != 0)
            {
                dataHE.DataSource  = cn.LoadTable(sqlHE);
                dataHE.CurrentCell = dataHE.Rows[index].Cells[0];
            }
            else
            {
                MessageBox.Show("Không thực hiện được thao tác!", "Thông báo!");
            }
            btnThemHE.Enabled = btnSuaHE.Enabled = btnXoaHE.Enabled = panelTD.Enabled = dataHE.Enabled = true;
            valHE             = 0; txtMAHE.ReadOnly = false;
            hienthiHE();
        }
Пример #2
0
 private void btnXoaHE_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có muốn xóa hệ này?", "Verify!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         int      cur   = dataHE.CurrentRow.Index;
         DataRow  row   = cn.LoadTable(sqlHE).Rows[cur];
         DAL_HEDT hh    = new DAL_HEDT(row);
         DAO_HEDT daoHH = new DAO_HEDT();
         int      check = daoHH.Delete_HE(hh);
         int      index = dataHE.CurrentRow.Index == dataHE.RowCount - 1 ? dataHE.RowCount - 2 : cur;
         if (check != 0)
         {
             dataHE.DataSource = cn.LoadTable(sqlHE);
             if (dataHE.RowCount > 1)
             {
                 dataHE.CurrentCell = dataHE.Rows[index].Cells[0];
             }
         }
         else
         {
             MessageBox.Show("Không xóa được hệ này!", "Thông báo!");
         }
         hienthiHE();
     }
 }