protected void _DeleteButton_Command(object sender, CommandEventArgs e) { try { int i = 0; CheckBox cb; int id; DB.DB_Object.ClassTypeNews objClassData = new DB.DB_Object.ClassTypeNews(); foreach (DataGridItem dgi in _grid.Items) { cb = (CheckBox)dgi.Cells[0].Controls[1]; if (cb.Checked) { // lấy Mã số của record cần xóa... id = (int)_grid.DataKeys[i]; // gọi hàm xóa từng record... if (objClassData.DeleteTypeNews(id) > 0) { CommonClass.MessageBox.Show("Còn tồn tại tin tức hoặc loại tin tức thuộc menu này.\nYêu cầu kiểm tra lại!"); return; } } i++; } LoadGrid(); } catch (Exception ex) { SetErrorMessage(ex.Message); } }
protected void btDelete_Click(object sender, EventArgs e) { int intID = 0; if (CommonClass.StringValidator.IsNumber(Request["TypeNewsID"].ToString().Trim())) { intID = int.Parse(Request["TypeNewsID"].ToString().Trim()); } DB.DB_Object.ClassTypeNews objClassData = new DB.DB_Object.ClassTypeNews(); if (objClassData.DeleteTypeNews(intID) > 0) { CommonClass.MessageBox.Show("Còn tồn tại tin tức hoặc loại tin tức thuộc menu này.\nYêu cầu kiểm tra lại!"); return; } else { Response.Redirect("~/Amincp/ManagerTopFicList.aspx"); } }