private void btnLuuTD_Click(object sender, EventArgs e) { DAL_TRINHDODT hh = new DAL_TRINHDODT(txtMATD.Text, txtTenTD.Text); DAO_TRINHDODT daoHH = new DAO_TRINHDODT(); int index = valTD == 1 ? dataTD.RowCount : dataTD.CurrentRow.Index; int check = 0; if (valTD == 1) { check = daoHH.Insert_TD(hh); } else if (valTD == 2) { check = daoHH.Update_TD(hh); } else { return; } if (check != 0) { dataTD.DataSource = cn.LoadTable(sqlTD); dataTD.CurrentCell = dataTD.Rows[index].Cells[0]; } else { MessageBox.Show("Không thực hiện được thao tác!", "Thông báo!"); } btnThemTD.Enabled = btnSuaTD.Enabled = btnXoaTD.Enabled = panelHE.Enabled = dataTD.Enabled = true; valTD = 0; txtMATD.ReadOnly = false; hienthiTD(); }
private void btnXoaTD_Click(object sender, EventArgs e) { if (MessageBox.Show("Bạn có muốn xóa trình độ này?", "Verify!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int cur = dataTD.CurrentRow.Index; DataRow row = cn.LoadTable(sqlTD).Rows[cur]; DAL_TRINHDODT hh = new DAL_TRINHDODT(row); DAO_TRINHDODT daoHH = new DAO_TRINHDODT(); int check = daoHH.Delete_TD(hh); int index = dataTD.CurrentRow.Index == dataTD.RowCount - 1 ? dataTD.RowCount - 2 : cur; if (check != 0) { dataTD.DataSource = cn.LoadTable(sqlTD); if (dataTD.RowCount > 1) { dataTD.CurrentCell = dataTD.Rows[index].Cells[0]; } } else { MessageBox.Show("Không xóa được trình độ này!", "Thông báo!"); } hienthiTD(); } }
public List <DAL_TRINHDODT> GetDSTRINHDO() { DataTable dt = cn.LoadTable("Select * from TRINHDODT"); List <DAL_TRINHDODT> DSTRINHDO = new List <DAL_TRINHDODT>(); foreach (DataRow dr in dt.Rows) { DAL_TRINHDODT hh = new DAL_TRINHDODT(dr); DSTRINHDO.Add(hh); } return(DSTRINHDO); }
public int Delete_TD(DAL_TRINHDODT hp) { string[] para = new string[1] { "@ma" }; object[] values = new object[1] { hp.MATD }; int check = 0; try { check = cn.Excute_Sql("XoaTD", CommandType.StoredProcedure, para, values); } catch { } return(check); }
public int Update_TD(DAL_TRINHDODT hp) { string[] para = new string[2] { "@ma", "@ten" }; object[] values = new object[2] { hp.MATD, hp.TENTD }; int check = 0; try { check = cn.Excute_Sql("SuaTD", CommandType.StoredProcedure, para, values); } catch { } return(check); }