package main;
import items.LString;
import java.util.ArrayList;
import dbdao.DBaseManager;
public class AddParam
{
String menuTable;
String display;
String colName;
int index;
public AddParam( String menuTable , String colName , String display , int indice )
{
this.menuTable = menuTable;
this.display = display;
this.colName = colName;
index = indice;
ArrayList<String> lSQL = new ArrayList<String>();
ArrayList<LString> lElem = new ArrayList<LString>();
DBaseManager dbm = new DBaseManager();
int fin = dbm.getLastIndex("params");
lElem = dbm.getElements("SELECT * FROM params");
lSQL.add( "INSERT INTO params VALUES ("+ (int)(fin+1) + ",'" + lElem.get(fin-1).get(1) + "','" + lElem.get(fin-1).get(2) + "','" + lElem.get(fin-1).get(3) + "','1','0')" );
for( int i=fin ; i>index ; i-- )
lSQL.add( "UPDATE params SET menuTable='" + lElem.get(i-2).get(1) + "',display='" + lElem.get(i-2).get(2) + "',colName='" + lElem.get(i-2).get(3) + "' WHERE ID=" + i );
lSQL.add("UPDATE params SET menuTable='" + menuTable + "',display='" + display + "',colName='" + colName + "' WHERE ID=" + index);
for( int i=0 ; i<lSQL.size() ; i++ )
System.out.println(lSQL.get(i));
dbm.updateElements(lSQL);
}
}