import java.net.URISyntaxException;
import java.sql.*;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.Map;

import javax.management.Query;

import com.heroku.sdk.jdbc.DatabaseUrl;

class IdealPrice 
{
	private Connection connection = null;
	private Statement stmt = null;
	private HashMap<String, NPD> DictNPD;
	private Account account;

	private String QueryCmd = "";
	private String listID = "";
	
	public IdealPrice(String listNPD)
	{	
		DictNPD = new HashMap<String, NPD>();		
        LoadData(DataManager.Query("SELECT * FROM salesforce.NPD__c where NPD__c in (" + listNPD + ")"));

        QueryCmd = "SELECT * FROM salesforce.NPD__c where NPD__c in (" + listNPD + ")";
	}
	
	public IdealPrice(Account newAcc)
	{
		account = newAcc;
		DictNPD = new HashMap<String, NPD>();
        LoadData(DataManager.Query("SELECT * FROM salesforce.NPD__c where Account_Name__c='" + newAcc.Id + "'"));

        QueryCmd = "SELECT * FROM salesforce.NPD__c where Account_Name__c='" + newAcc.Id + "'";
	}
	
	private void LoadData(ResultSet rs)
	{
		try {
			listID = "ID: "; 
			while (rs.next()) 	
			{
				NPD newNPD = new NPD(rs);
				DictNPD.put(newNPD.Id, newNPD);
				listID += newNPD.Id;
			}
			listID += "<br/>";
		} catch (SQLException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
	}
	
	public String getResult()
	{
		String output = "Query: " + QueryCmd + "<br/> ";
		output += listID;
		for(NPD npd : DictNPD.values())
		{
			output += "NPD Id: " + npd.Id + "<br/>";
			
			for(FG fg : npd.listFG)
			{
				output += " - FG Name: " + fg.Name + ", MOQ: " + fg.MOQ1 + ", Annual: " + fg.AnnualVolume + ", Launch:" + fg.LaunchVolume + "<br/>";
			}
			
		}
		return output;
		//return "Success";
	}
}

@@ -796,24 +796,25 @@
 NPD%3E();%0A
+%0A
         
 LoadData
@@ -809,35 +809,19 @@
     
-LoadData(DataManager.Query(
+QueryCmd = 
 %22SEL
@@ -891,20 +891,17 @@
 Id + %22'%22
-));%0A
+;
 %0A       
@@ -905,148 +905,120 @@
     
-QueryCmd = %22SELECT * FROM salesforce.NPD__c where Account_Name__c='%22 + newAcc.Id + %22'%22;%0A%09%7D%0A%09%0A%09private void LoadData(ResultSet rs)%0A%09%7B%0A%09%09try %7B
+LoadData(QueryCmd);%0A%09%7D%0A%09%0A%09private void LoadData(String cmd)%0A%09%7B%0A%09%09try %7B%0A%09%09%09ResultSet rs = DataManager.Query(cmd);
 %0A%09%09%09

Restructure Object