Package main

Source Code of main.SwapDB

package main;

import items.LString;

import java.util.ArrayList;

import dbdao.DBaseManager;

public class SwapDB
{
  String table;
  int index1;
  int index2;
  ArrayList<String> lSQL;
 
  public SwapDB( String tabla , int indice1 , int indice2 )
  {
    table = tabla;
    index1 = indice1;
    index2 = indice2;
   
    DBaseManager dbm = new DBaseManager();
    lSQL = new ArrayList<String>();
   
    ArrayList<LString> lElem = dbm.getElements("SELECT * FROM " + tabla + " WHERE ID=" + index1 + " OR ID=" + index2);
    /*
    LString aux = lElem.get(0);
    for( int i=1 ; i<lElem.get(0).length ; i++ )
    {
      lElem.get(0).set(i,lElem.get(1).get(i));
      lElem.get(1).set(i,aux.get(i));
    }
    */
    if( table.equalsIgnoreCase("params") )
    {
      lSQL.add( "UPDATE params SET menuTable='" + lElem.get(0).get(1) + "',display='" + lElem.get(0).get(2) + "',colName='" + lElem.get(0).get(3) + "' WHERE ID=" + lElem.get(1).get(0) );
      lSQL.add( "UPDATE params SET menuTable='" + lElem.get(1).get(1) + "',display='" + lElem.get(1).get(2) + "',colName='" + lElem.get(1).get(3) + "' WHERE ID=" + lElem.get(0).get(0) );
    }
    else
    {
      System.out.println("Aun no esta implementada la parte de para cualquier tabla que no sea params. No seas vago y hazlo xD");
    }
   
    for( int i=0 ; i<lSQL.size() ; i++ )
      System.out.println( lSQL.get(i));
    dbm.updateElements(lSQL);
  }
}
TOP

Related Classes of main.SwapDB

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.