protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { if (Page.IsValid) { if (LinhVucVB == null) { VBPQ_LinhVuc vc = new VBPQ_LinhVuc(); vc.TenLinhVuc = txtCQBH.Text; vc.GhiChu = txtGhiChu.Text; db.VBPQ_LinhVucs.InsertOnSubmit(vc); db.SubmitChanges(); } else { LinhVucVB.TenLinhVuc = txtCQBH.Text; LinhVucVB.GhiChu = txtGhiChu.Text; db.SubmitChanges(); } Response.Redirect(Common.GenerateAdminUrl("vbpq_linhvuc")); } } }
protected void grvCQBH_RowDeleting(object sender, GridViewDeleteEventArgs e) { int id = Convert.ToInt32(grvCQBH.DataKeys[e.RowIndex].Value); VBPQ_LinhVuc vCate = db.VBPQ_LinhVucs.SingleOrDefault <VBPQ_LinhVuc>(vc => vc.Id == id); if (vCate != null) { db.VBPQ_LinhVucs.DeleteOnSubmit(vCate); db.SubmitChanges(); LoadData(); } }