package main;
import java.util.ArrayList;
import dbdao.DBaseManager;
public class RemoveItem
{
private String table;
private int index;
public RemoveItem( String tabla , int indice )
{
table = tabla;
index = indice;
remove();
}
private void remove()
{
DBaseManager dbm = new DBaseManager();
int fin = dbm.getLastIndex(table);
ArrayList<String> lSQL = new ArrayList<String>();
lSQL.add("DELETE FROM " + table + " WHERE ID=" + index);
for( int i=index ; i<fin ; i++ )
lSQL.add("UPDATE " + table + " SET ID=" + i + " WHERE ID=" + (int)(i+1) );
for( int i=0 ; i<lSQL.size() ; i++ )
System.out.println(lSQL.get(i));
dbm.updateElements(lSQL);
}
}