Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ss

301 views

Published on

  • Be the first to comment

  • Be the first to like this

Ss

  1. 1. import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import javax.microedition.io.*;import java.io.*;public class MoneyTransfer extends MIDlet implements CommandListener{ Display D;///Registration Form F=new Form("Registration"); TextField t1=new TextField("Account No:","",20,TextField.ANY); TextField t2=new TextField("Date of Birth:","",20,TextField.ANY); TextField t3=new TextField("Password:","",20,TextField.PASSWORD); TextField t4=new TextField("Confirm Password:","",20,TextField.PASSWORD); TextField t5=new TextField("Your Security Code:","",20,TextField.PASSWORD); StringItem si=new StringItem("Message:",""); Command submit=new Command("Submit",Command.SCREEN,1); Command reset=new Command("Reset",Command.SCREEN,2);////////////LoginForm F1=new Form("Sign In");TextField t6=new TextField("Account No:","",20,TextField.ANY);TextField t7=new TextField("Password:","",20,TextField.PASSWORD);Command signin=new Command("Sign In",Command.SCREEN,1);StringItem msg=new StringItem("Message:",""); ////// List menu=new List("Menu",List.IMPLICIT); List usermenu=new List("Your Options",List.IMPLICIT);//account detailsForm AD=new Form("Your Accounts Details");StringItem s1=new StringItem("Account No:","");StringItem s2=new StringItem("Name:","");StringItem s3=new StringItem("Birth Date:","");StringItem s4=new StringItem("Address:","");StringItem s5=new StringItem("Gender:","");StringItem s6=new StringItem("Email Id:","");StringItem s7=new StringItem("Date Ac:","");StringItem s8=new StringItem("Type:","");StringItem s9=new StringItem("Balance:","");StringItem s10=new StringItem("Picture:","");Image im=null;ImageItem mi=null;////Money TransferForm MT=new Form("Money Transfer");StringItem from=new StringItem("Your Account No:","");TextField to=new TextField("Account To:","",20,TextField.ANY);Command mtok=new Command("Ok",Command.SCREEN,1);Form MTT=new Form("Money Transfer Transaction");StringItem t_from=new StringItem("Account No From:","");StringItem t_from_name=new StringItem("Name:","");StringItem t_to=new StringItem("Account No To:","");StringItem t_to_name=new StringItem("Name:","");Image im_to=null;ImageItem mi_to=null;StringItem cd=new StringItem("Date:","");TextField amt=new TextField("Amount:","",20,TextField.NUMERIC);////// public void startApp() { D=Display.getDisplay(this); ///registration
  2. 2. F.append(t1); F.append(t2); F.append(t3); F.append(t4); F.append(t5); F.append(si); F.addCommand(submit); F.addCommand(reset); F.setCommandListener(this); ///// ///Login F1.append(t6); F1.append(t7); F1.append(msg); F1.addCommand(signin); F1.setCommandListener(this); ///// ///account detail/// AD.append(s1); AD.append(s2); AD.append(s3); AD.append(s4); AD.append(s5); AD.append(s6); AD.append(s7); AD.append(s8); AD.append(s9); AD.append(s10);///money transferMT.append(from);MT.append(to);MT.addCommand(mtok);MT.setCommandListener(this);///////User Menu///usermenu.append("Account Details",null);usermenu.append("Transaction",null);usermenu.append("Money Transfer",null);usermenu.append("Main Menu",null);usermenu.append("Exit",null);usermenu.setCommandListener(this);/// //main menu menu.append("Registration",null); menu.append("Sign In", null); menu.setCommandListener(this); //// D.setCurrent(menu); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command c,Displayable d) {if(c==List.SELECT_COMMAND && d==menu) {
  3. 3. switch(menu.getSelectedIndex()) { case 0: D.setCurrent(F); break; case 1: D.setCurrent(F1); break; default: break; } } else if(c==List.SELECT_COMMAND && d==usermenu) {switch(usermenu.getSelectedIndex()) {case 0: con_acc ac=new con_acc(); ac.start(); break; case 1: break; case 2: from.setText(t6.getString()); D.setCurrent(MT); break; } } else if(c==submit) { connect cc=new connect(); cc.start(); } else if(c==reset) {t1.setString(""); t2.setString(""); t3.setString(""); t4.setString(""); t5.setString(""); si.setText(""); } else if(c==signin) {con_signin cs=new con_signin(); cs.start(); } }///////////registration///// class connect extends Thread {public void run(){ try{ HttpConnectioncn=(HttpConnection)Connector.open("http://localhost:8080/servlet/registration?acn="+t1.getString()+"&db="+t2.getString()+"&pwd="+t3.getString()+"&cpwd="+t4.getString()+"&sc="+t5.getString()); cn.setRequestMethod(HttpConnection.GET); if(cn.getResponseCode()==HttpConnection.HTTP_OK) { InputStream in=cn.openInputStream(); ByteArrayOutputStream b=new ByteArrayOutputStream();
  4. 4. int i; while((i=in.read())!=-1) { b.write(i); } byte by[]=b.toByteArray(); String s=new String(by); si.setText(s); cn.close(); } else { si.setText("Connection Fail"); } } catch(Exception e) {si.setText(e+"");} } }/////////////////////signin///// class con_signin extends Thread {public void run(){ try{ HttpConnectioncn=(HttpConnection)Connector.open("http://localhost:8080/servlet/signin?acn="+t6.getString()+"&pwd="+t7.getString()); cn.setRequestMethod(HttpConnection.GET); if(cn.getResponseCode()==HttpConnection.HTTP_OK) { InputStream in=cn.openInputStream(); ByteArrayOutputStream b=new ByteArrayOutputStream(); int i; while((i=in.read())!=-1) { b.write(i); } byte by[]=b.toByteArray(); String s=new String(by); if(s.equals("true")) { D.setCurrent(usermenu); }else{ msg.setText(s);} cn.close(); } else { si.setText("Connection Fail"); } } catch(Exception e) {si.setText(e+"");} } }//////////
  5. 5. ///////////accounts detail///// class con_acc extends Thread {public void run(){ try{ HttpConnectioncn=(HttpConnection)Connector.open("http://localhost:8080/servlet/account_details?acn="+t6.getString()); cn.setRequestMethod(HttpConnection.GET); if(cn.getResponseCode()==HttpConnection.HTTP_OK) { InputStream in=cn.openInputStream(); ByteArrayOutputStream b=new ByteArrayOutputStream(); int i; while((i=in.read())!=-1) { b.write(i); } byte by[]=b.toByteArray(); String s=new String(by); String Fi[]=split(s); s1.setText(Fi[0]); s2.setText(Fi[1]); s3.setText(Fi[2]); s4.setText(Fi[3]); s5.setText(Fi[4]); s6.setText(Fi[5]); s7.setText(Fi[6]); s8.setText(Fi[7]); s9.setText(Fi[8]); s10.setText(Fi[9]); con_pic cp=new con_pic(); cp.start(); D.setCurrent(AD); cn.close(); } else { si.setText("Connection Fail"); } } catch(Exception e) {si.setText(e+"");} } }/////////////////////fetch picture///// class con_pic extends Thread {public void run(){ try{ HttpConnectioncn=(HttpConnection)Connector.open("http://localhost:8080/mt/"+s10.getText()); cn.setRequestMethod(HttpConnection.GET); if(cn.getResponseCode()==HttpConnection.HTTP_OK) { InputStream in=cn.openInputStream(); ByteArrayOutputStream b=new ByteArrayOutputStream(); int i;
  6. 6. while((i=in.read())!=-1) { b.write(i); } byte by[]=b.toByteArray(); try{ im=Image.createImage(by, 0, by.length); mi=new ImageItem("",im,ImageItem.LAYOUT_DEFAULT,""); AD.append(mi); }catch(Exception e){} cn.close(); } else { si.setText("Connection Fail"); } } catch(Exception e) {si.setText(e+"");} } }/////////////Split StringString [] split(String s){int i,count=0; for(i=0;i<s.length();i++) { char ch=s.charAt(i); if(ch==,) {count++;} }String Fi[]=new String[count+1];Fi[0]=new String();int j=0;for(i=0;i<s.length();i++){ char ch=s.charAt(i); if(ch!=,) {Fi[j]=Fi[j]+ch; } else {j++; Fi[j]=new String(); } }return(Fi);}////}

×