Example #1
0
        public static void DeleteRecord(IDB deleteObject)
        {
            string tableName = String.Empty;

            if (deleteObject is Employee employee)
            {
                employeeList.Remove(employee);
                tableName = "Employee";
            }
            if (deleteObject is Department department)
            {
                departmentList.Remove(department);
                tableName = "Department";
            }

            if (String.IsNullOrEmpty(tableName))
            {
                return;
            }

            command = new SqlCommand(deleteObject.DeleteString(tableName), connection);
            command.ExecuteNonQuery();
        }