public ActionResult Delete(int Id, FormCollection collection) { EmployeeBAL emp = new EmployeeBAL(); int NewId = emp.Delete(Id); return(RedirectToAction("Index", "Employee")); }
private void btnDelete_Click(object sender, EventArgs e) { try { int MaNV = int.Parse(txtEmpID.Text); string status = ""; DialogResult result = MessageBox.Show("Có chắc chắn muốn xóa?", "STATUS", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result == DialogResult.OK) { status = Employee.Delete(MaNV); if (status != "Successful") { throw new Exception(status); } MessageBox.Show("Xóa thành công", "STATUS", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); Reset(); } } catch (FormatException exception) { MessageBox.Show("Mã không hợp lệ!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception exception) { MessageBox.Show(exception.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public ActionResult Delete(int id) { var bal = new EmployeeBAL(); bal.Delete(id); return(RedirectToAction("Index", "Employee")); }
public ActionResult Delete(int id) { try { // TODO: Add delete logic here EmployeeBAL balObject = new EmployeeBAL(); balObject.Delete(id); return(RedirectToAction("Index")); } catch { return(View()); } }