Results 1 to 2 of 2
  1. #1
    deena is offline Member
    Join Date
    Nov 2012
    Posts
    3
    Rep Power
    0

    Default display emp info .

    hi,

    i have created a employee class that display emp info, my program prints emp info based on id. i need a way to print emp name based on state city area in dropdown list. i have tried to this with hardcoded values then i will try with database values.

    ie. my first list should print states.

    based on this selection of states all corresponding cities should be retrieved .

    in third all areas corresponding to cities selected should be displayed.

    in the last dropdown all(employees) emp name from this area should be displayed.

    first i want to know how to accomplish this with these hardcoded values.



    import java.util.ArrayList;
    import java.io.*;

    public class Employeelookup {

    static ArrayList<Employeelookup> al = new ArrayList<Employeelookup>();
    int id;
    String name;
    String State;
    String city;
    String Area;

    static int count = 0;
    {
    }
    Employeelookup()
    {
    }
    Employeelookup(int id, String name, String State,String city,String Area)
    {
    this.id = id;
    this.name = name;
    this.State=State;
    this.city=city;
    this.Area=Area;

    count++;
    }
    public void SetId(int id)

    {
    this.id=id;
    }
    public int getId()
    {
    return id;
    }
    public void SetName()
    {
    this.name=name;
    }


    public void putDetails(Employeelookup e)
    {
    al.add(e);

    }

    public Employeelookup getDetails(int id)
    {
    Employeelookup es = (Employeelookup)al.get(id);
    return es;
    }

    public static void main(String[] args ) throws IOException
    {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    Employeelookup e = new Employeelookup();
    Employeelookup e1 = new Employeelookup(1, "SaiRam", "karnataka","bangalore","rajajinagar");
    Employeelookup e2 = new Employeelookup(2, "Anu", "karnataka","mysore","temple road");
    Employeelookup e3 = new Employeelookup(3, "Vasu", "karnataka","bangalore","rajajinagar");
    Employeelookup e4 = new Employeelookup(4, "Shillu", "Tamil Nadu","madhurai","b");
    Employeelookup e5 = new Employeelookup(5, "Madhu", "Karnataka","shimoga","bus stop");
    Employeelookup e6 = new Employeelookup(6, "Volga", "Andra","abc","railway stop");


    e.putDetails(e1);
    e.putDetails(e2);
    e.putDetails(e3);
    e.putDetails(e4);
    e.putDetails(e5);
    e.putDetails(e6);

    System.out.println("The total number of Employeelookups are: " +count);
    System.out.println(" ");

    while(true)
    {
    System.out.println("Enter Employeelookup id to get the Employeelookup details: ");
    int id = Integer.parseInt(br.readLine());
    boolean flag = false;


    for(int i=0; i <al.size();i++) {
    Employeelookup es = e1.getDetails(i);
    if(id == es.id)
    {
    System.out.println("The details of the Employeelookup with id " +id +" is: ");
    System.out.print(es.id +" " +es.name+" " +es.State+" " + es.city+" " +es.Area+" "+"" );
    flag = true;
    break;
    }
    }

    System.out.println(" ");

    if(!flag)
    {
    System.out.println("Sorry, no data exists with the id " +id);
    }
    System.out.println(" ");
    String ch = null;

    while(true)
    {
    System.out.println("Want to Continue(y/n)?)");
    System.out.println(" ");
    ch = br.readLine();
    if(ch.equalsIgnoreCase("y") || ch.equalsIgnoreCase("n")) break;
    if(!(ch.equalsIgnoreCase("y") || ch.equalsIgnoreCase("n")))
    {
    System.out.println("Invalid option : please type y/n");
    System.out.println(" ");
    }
    }

    if(ch.equalsIgnoreCase("n"))
    {
    System.out.println(" ");
    System.out.println("Thank you");
    break;
    }
    }
    }
    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

Similar Threads

  1. Replies: 1
    Last Post: 12-01-2010, 07:35 PM
  2. Replies: 1
    Last Post: 05-31-2010, 09:46 AM
  3. How to display info when a JPanel gains focus
    By toymachiner62 in forum Java Applets
    Replies: 8
    Last Post: 10-19-2009, 06:13 AM
  4. Replies: 8
    Last Post: 12-29-2008, 08:12 AM
  5. Replies: 0
    Last Post: 06-28-2008, 10:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •