Example #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();
        }
Example #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();
     }
 }
Example #3
0
        public List <DAL_HEDT> GetDSHEDT()
        {
            DataTable       dt     = cn.LoadTable("Select * from HEDAOTAO");
            List <DAL_HEDT> DSHEDT = new List <DAL_HEDT>();

            foreach (DataRow dr in dt.Rows)
            {
                DAL_HEDT hh = new DAL_HEDT(dr);
                DSHEDT.Add(hh);
            }
            return(DSHEDT);
        }
Example #4
0
        public int Delete_HE(DAL_HEDT hp)
        {
            string[] para = new string[1] {
                "@ma"
            };
            object[] values = new object[1] {
                hp.MAHE
            };
            int check = 0;

            try
            {
                check = cn.Excute_Sql("XoaHE", CommandType.StoredProcedure, para, values);
            }
            catch
            { }
            return(check);
        }
Example #5
0
        public int Update_HE(DAL_HEDT hp)
        {
            string[] para = new string[2] {
                "@ma", "@ten"
            };
            object[] values = new object[2] {
                hp.MAHE, hp.TENHE
            };
            int check = 0;

            try
            {
                check = cn.Excute_Sql("SuaHE", CommandType.StoredProcedure, para, values);
            }
            catch
            { }
            return(check);
        }