ElaKiri Programmer's Club

tery123

Well-known member
  • Feb 25, 2011
    6,031
    177
    63
    34
    kukulani inentory control ekak hadanna inne..danne na hoyan hadanna one...java walin...standalone...

    monada step????

    1.2.3.4 ewage kiyala dihallako danna ekek...man kiwwe mulin ui hadanawada er hadanawada data base hadanawada?kohomada wade salasum kara ganne.palaweni project eka meka..mita kalin karala na coding.....:no::no::no:
     

    CorD SaC

    Well-known member
  • Feb 4, 2015
    15,725
    28,086
    113
    කාට හරි පුලුවන්නම් මට save andsave as කරන Code එකක් දෙනවද..සාමාන්‍ය නෝට්පෑඩ් එකේ තියෙන විදිහටමයි වැඩ කරන්ඩ ඕනිත් :)
     

    thilina91

    Member
    May 28, 2008
    18,560
    858
    0
    New World, Grand Line

    DooA

    Well-known member
  • Jun 22, 2011
    5,202
    773
    113
    ආගිය අතක් නැත
    kukulani inentory control ekak hadanna inne..danne na hoyan hadanna one...java walin...standalone...

    monada step????

    1.2.3.4 ewage kiyala dihallako danna ekek...man kiwwe mulin ui hadanawada er hadanawada data base hadanawada?kohomada wade salasum kara ganne.palaweni project eka meka..mita kalin karala na coding.....:no::no::no:

    1. requirement ganin
    2. ER eka adapan
    3. use case adapan
    4. database eka hadapan
    5. ui
    6. coding
     
    • Like
    Reactions: tery123

    MihiCherub

    Well-known member
  • Sep 14, 2009
    18,861
    1
    9,626
    113
    Gampaha
    මේක රෙෆරල් program එකක්. අයිතිකාරයාට රෙෆරර් කෙනෙක් නෑ. අනිත් හැම රෙගිස්ටර් වෙන හැම යූසර් කෙනෙක්ටම අනිවා රෙෆරර් කෙනෙක් ඉන්නව. එකෙක් පමණයි.

    මගේ database එකේ ටේබල් එක තියෙන්නෙ මේ විදියට.. ටයිප් එක බොස් වෙන්නෙ පලවෙනි එකට විතරමයි. දැන් මේකෙ එක යූසර් කෙනෙක් තව කෙනෙකුට රෙෆරර් වෙනව.

    table_zpsnykpfay2.png


    මට ඕනෙ එක යූසර් කෙනෙක් ගත්තාම චේන් එකේ අන්තිම වෙනකම්ම ඉන්න රෙෆරර්ස්ල ටික ගන්න. ඒ කියන්නෙ රෙෆරර්ගෙ රෙෆරර්, රෙෆරර්ගෙ රෙෆරර් විදියට

    Ex -
    A002 ගත්තොත් A001
    A004 ගත්තොත් A002,A001
    A008 ගත්තොත් A006,A003,A001

    මේක ගන්න ක්‍රමයක් තමයි ඔනෙ.

    උදවු, bump දෙන හැමෝටම 14+ ගානෙ තමයි දෙන්න පුලුවන්.. :)
    http://www.elakiri.com/forum/showthread.php?p=20774017#post20774017

    :(:(
     

    tery123

    Well-known member
  • Feb 25, 2011
    6,031
    177
    63
    34
    PHP:
    import java.io.*;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.*;
    import javax.xml.ws.handler.MessageContext;
    
    public class client extends JFrame {
    	
    	private JTextField userText;
    	private JTextArea chatWindow;
    	private ObjectOutput output;
    	private ObjectInputStream input;
    	private String message= "";
    	private String serverIp;
    	private Socket connection;
    	
    	//constructor
    	
    	public client(String host){
    		
    		super("CLINENT MOFO !!!!");
    		serverIp = host;
    		userText.setEditable(false);
    		userText.addActionListener(
    				
    				new ActionListener() {
    					
    					@Override
    					public void actionPerformed(ActionEvent event) {
    						// TODO Auto-generated method stub
    						
    						sendMessage(event.getActionCommand());
    						userText.setText("");
    						
    						}
    					}
    				
    				);
    		
    		add(userText,BorderLayout.NORTH);
    		chatWindow = new JTextArea();
    		add(new JScrollPane(chatWindow),BorderLayout.CENTER);
    		setSize(300,150);
    		setVisible(true);
    	}
    	
    	//connect to server
    	public void startRunning(){
    		
    		try{
    			connectToServer();
    			setupStreams();
    			whileChatting();
    			
    		}catch(EOFException eofException){
    			showMessage("\n Client terminated connection");
    			
    		}catch(IOException ioException){
    			ioException.printStackTrace();
    			
    		}finally{
    			closeCrap();
    		}
    	}
    	
    	// connect to server
    	private void connectToServer() throws IOException{
    		showMessage("Attempting connection.....\n");
    		
    		connection = new Socket(InetAddress.getByName(serverIp),6789);
    		showMessage("Connected to : " + connection.getInetAddress().getHostName());
    	}
    	
    	//setting up streams to recive massages
    	
    	private void setupStreams() throws IOException{
    		output= new ObjectOutputStream(connection.getOutputStream());
    		output.flush();
    		input = new ObjectInputStream(connection.getInputStream());
    		showMessage("\n dude your streams are now good to go");
    	}
    	
    	//while chatting method
    	
    	private void whileChatting() throws IOException{
    		ableToType(true);
    		
    		do{
    			try{
    				
    				message=(String) input.readObject();
    				showMessage("\n" + message);
    				
    			}catch(ClassNotFoundException classNotFoundException){
    				showMessage("\n i dont know that object type");
    			}
    			
    		}while(!message.equals("SERVER - END"));
    		
    	}
    	
    	//close crap to close everything
    	
    	private void closeCrap(){
    		showMessage("\n closing crap down...");
    		ableToType(false);
    		
    		try{
    			output.close();
    			input.close();
    			connection.close();
    			
    		}catch(IOException ioException){
    			ioException.printStackTrace();
    		}
    	}
    	
    	//send massages to server
    	
    	private void sendMessage(String message){
    		try{
    			output.writeObject("CLIENT - " + message);
    			output.flush();
    			showMessage("\n CLIENT - " + message);
    			
    		}catch(IOException ioException){
    			
    			chatWindow.append("\n something messed up with sending massages");
    		}
    	}
    	
    	//show message to show all massage to window
    	private void showMessage(final String m){
    		SwingUtilities.invokeLater(
    				new Runnable() {
    					
    					@Override
    					public void run() {
    						// TODO Auto-generated method stub
    						chatWindow.append(m);
    						}
    					}
    				
    				);
    	}
    	
    	// give user permission to type 
    	
    	private void ableToType(final boolean tof){
    		SwingUtilities.invokeLater(
    				 new Runnable() {
    					
    					@Override
    					public void run() {
    						// TODO Auto-generated method stub
    						userText.setEditable(tof);
    						}
    				 	}
    				
    				);
    	}
    	
    }
    PHP:
    import javax.swing.JFrame;
    
    
    public class clientTest {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		
    		client mychat;
    		mychat= new client("127.0.0.1");
    		mychat.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		mychat.startRunning();
    		
    
    	}
    
    }

    meke mehema exception ekak enawane bun...mokakda case eka???

    Exception in thread "main" java.lang.NullPointerException
    at client.<init>(client.java:27)
    at clientTest.main(clientTest.java:10)


    :dull::dull::dull::dull::dull: