Exemplo n.º 1
0
        private void btnLuuBM_Click(object sender, EventArgs e)
        {
            DAL_BOMON bm    = new DAL_BOMON(txtMABM.Text, txtTENBM.Text, Convert.ToInt32(txtSOGV.Text), cbBCN.SelectedValue.ToString());
            DAO_BOMON daoBM = new DAO_BOMON();
            int       index = val == 1 ? dataBomon.RowCount : dataBomon.CurrentRow.Index;
            int       check = 0;

            if (val == 1)
            {
                check = daoBM.Insert_BM(bm);
            }
            else if (val == 2)
            {
                check = daoBM.Update_BM(bm);
            }
            else
            {
                return;
            }
            if (check != 0)
            {
                dataBomon.DataSource  = cn.LoadTable(sql);
                dataBomon.CurrentCell = dataBomon.Rows[index].Cells[0];
            }
            else
            {
                MessageBox.Show("Không thực hiện được thao tác!", "Thông báo!");
            }
            hienthiBomon();
            txtMABM.ReadOnly      = false;
            panelControl1.Enabled = btnThemBM.Enabled = btnSuaBM.Enabled = btnXoaBM.Enabled = true;
            val = 0;
        }
Exemplo n.º 2
0
 private void btnXoaBM_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có muốn xóa bộ môn này?", "Verify!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         int       cur   = dataBomon.CurrentRow.Index;
         DataRow   row   = cn.LoadTable(sql).Rows[cur];
         DAL_BOMON bm    = new DAL_BOMON(row);
         DAO_BOMON daoBM = new DAO_BOMON();
         int       check = daoBM.Delete_BM(bm);
         int       index = cur == dataBomon.RowCount - 1 ? dataBomon.RowCount - 2 : cur;
         if (check != 0)
         {
             dataBomon.DataSource = cn.LoadTable(sql);
             if (dataBomon.RowCount > 1)
             {
                 dataBomon.CurrentCell = dataBomon.Rows[index].Cells[0];
             }
         }
         else
         {
             MessageBox.Show("Không xóa được học phần này!", "Thông báo!");
         }
         hienthiBomon();
     }
 }
Exemplo n.º 3
0
        public List <DAL_BOMON> GetDSLOPHP()
        {
            DataTable        dt   = cn.LoadTable("Select * from BOMON");
            List <DAL_BOMON> DSBM = new List <DAL_BOMON>();

            foreach (DataRow dr in dt.Rows)
            {
                DAL_BOMON bm = new DAL_BOMON(dr);
                DSBM.Add(bm);
            }
            return(DSBM);
        }
Exemplo n.º 4
0
        public int Delete_BM(DAL_BOMON bm)
        {
            string[] para = new string[1] {
                "@ma"
            };
            object[] values = new object[1] {
                bm.MaBM
            };
            int check = 0;

            try
            {
                check = cn.Excute_Sql("XoaBM", CommandType.StoredProcedure, para, values);
            }
            catch
            { }
            return(check);
        }
Exemplo n.º 5
0
        public int Update_BM(DAL_BOMON bm)
        {
            string[] para = new string[4] {
                "@ma", "@ten", "@sogv", "@macn"
            };
            object[] values = new object[4] {
                bm.MaBM, bm.TenBM, bm.Sogv, bm.MaCnBM
            };
            int check = 0;

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