public static DelEmployee_EL DelEmployeeInput() { Console.WriteLine("Enter EmpId to delete record:"); DelEmployee_EL de = new DelEmployee_EL(); de.EmpId = Console.ReadLine(); return(de); }
public static DelEmployee_EL DelEmployeeInput() { Console.WriteLine("Enter EmpId to delete record:"); DelEmployee_EL de = new DelEmployee_EL { EmpId = Convert.ToInt32(Console.ReadLine()) }; return(de); }
public static void DeleteEmployee(DelEmployee_EL e) { try { using (SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-8HC3KF0;Initial Catalog=AttendanceAndLeaveManagementSystem;Integrated Security=True;")) { SqlCommand cmd = new SqlCommand("Delete from EmployeeDetails where EmpId= @EmpId", con); cmd.Parameters.AddWithValue("@EmpId", e.EmpId); con.Open(); cmd.ExecuteNonQuery(); } } catch (SqlException ex) { Console.WriteLine(ex.Message); } }
public static void DeleteEmployee(DelEmployee_EL e) { try { using (SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-8HC3KF0;Initial Catalog=ALMS;Integrated Security=True;")) { SqlCommand cmd = new SqlCommand { CommandText = "spDeleteEmployee", Connection = con, CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@EmpId", e.EmpId); con.Open(); cmd.ExecuteNonQuery(); } } catch (SqlException ex) { Console.WriteLine(ex.Message); } }