ATM system implementation [10]--transfer window [00 original]

Source: Internet
Author: User
Package cn.edu.ynu.sei.atm.client.ui;

Import Cn.edu.ynu.sei.atm.interfaceDef.IAvailableAccount;
Import Cn.edu.ynu.sei.atm.interfaceDef.IDataFormatChecker;
Import cn.edu.ynu.sei.atm.interfaceDef.ITransaction;
Import java.rmi.Naming;
Import java.rmi.RemoteException;
Import Org.eclipse.swt.SWT;
Import Org.eclipse.swt.events.MouseAdapter;
Import org.eclipse.swt.events.MouseEvent;
Import Org.eclipse.swt.widgets.Button;
Import Org.eclipse.swt.widgets.Combo;
Import Org.eclipse.swt.widgets.Composite;
Import Org.eclipse.swt.widgets.Display;
Import Org.eclipse.swt.widgets.Label;
Import Org.eclipse.swt.widgets.MessageBox;
Import Org.eclipse.swt.widgets.Text;

/**
* transfer window
* @author 88250
*/
public class Transferaccountcomposite extends composite
{
/**
* Back button
*/
Private Button returnbtn = null;

/**
* Status Display label
*/
Private Label STATESHOWLBL = null;

/**
* Source Account Label
*/
Private Label SOURCEACCOUNTLBL = null;

/**
* Withdrawal Amount Label
*/
Private Label AMOUNTLBL = null;

/**
* Target Account Label
*/
Private Label TARGETACCOUNTLBL = null;

/**
* Status Hint Label
*/
Private Label STATELBL = null;

/**
* Transfer Amount Input field
*/
Private Text amounttext = null;

/**
* Target Account combo box
*/
Private Combo Targetcombo = null;

/**
* Source Account combo Box
*/
Private Combo Sourcecombo = null;

/**
* Available Account Instances
*/
Private Iavailableaccount availableaccount = null;

/**
* Transaction Services Interface
*/
Private ITransaction transaction = NULL;

/**
* Input data legality verification interface
*/
Private Idataformatchecker dataformatchecker = null;

/**
* Parent Window Container
*/
Private composite parent = NULL;

/**
* Create transfer window
* @param parent window Container
*/
Public Transferaccountcomposite (composite parent)
{
Super (parent, SWT. NONE);
this. Parent = parent;

Try
{
Availableaccount = (iavailableaccount) naming
. lookup (logininterface.serviceaddr + "Availableaccount");

Transaction = (ITransaction) naming
. lookup (logininterface.serviceaddr + "Transaction");
Dataformatchecker = (idataformatchecker) naming
. lookup (logininterface.serviceaddr + "Dataformatchecker");
}
catch (RemoteException re)
{
Re.printstacktrace ();
MessageBox Exitdlg = new MessageBox (Parent.getshell ());
Exitdlg.settext ("Network connectivity problem ....") " );
Exitdlg.setmessage ("Cannot connect to the server, the system will exit.") " );
Exitdlg.open ();
System.exit (0);
}
catch (Exception e)
{
E.printstacktrace ();
}
Createcontents ();

Final button comfirmbtn = New button (this, SWT. NONE);
Comfirmbtn.addmouselistener (New Mouseadapter ()
{
public void MouseDown (MouseEvent arg0)
{
Try
{
float amount = 0;
Try
{if (! Dataformatchecker.checkamount (Amounttext.gettext ()))
{
Amount = 0;
}
Else
{
Amount = Float.parsefloat (Amounttext.gettext ());
}
}
catch (NumberFormatException NFE)
{
Stateshowlbl.settext (Nfe.getmessage ());
}
AccountSelectComposite.account.setAmount (amount);
Float balance = AccountSelectComposite.account.getBalance ()
-AccountSelectComposite.account.getAmount ()
-(float) (accountselectcomposite.account
. Getamount () * 1.0/100.0);

if (Balance < 0)
{//Insufficient balance
Stateshowlbl.settext ("The balance is insufficient.") " );
return;
}

if (AccountSelectComposite.account.getAmount () > 10000)
{//Transfer amount is greater than 10000 yuan
Stateshowlbl.settext ("Transfer amount cannot be greater than 10000 yuan.") " );
return;
}
Transaction.transfer (Integer.parseint (Sourcecombo
. GetText ()), Integer.parseint (Targetcombo
. GetText ()), Accountselectcomposite.account
. Getamount ());
Stateshowlbl.settext ("Transfer succeeded.") " );
}
catch (RemoteException re)
{
Re.printstacktrace ();
}
catch (Exception ex)
{
Ex.printstacktrace ();
}
}
});
Comfirmbtn.settext ("OK");
Comfirmbtn.setbounds (75, 101, 40, 30);
}

/**
* Create a transfer window containing controls
*
*/
private void Createcontents ()
{
Sourcecombo = new Combo (this, SWT.  Drop_down | Swt. READ_ONLY);
Sourcecombo.setbounds (75, 8, 121, 25);

Targetcombo = new Combo (this, SWT.  Drop_down | Swt. READ_ONLY);
Targetcombo.setbounds (75, 38, 119, 25);

Amounttext = new Text (this, SWT. BORDER);
Amounttext.setbounds (75, 70, 95, 25);

SOURCEACCOUNTLBL = new Label (this, SWT. NONE);
Sourceaccountlbl.settext ("Source account:");
Sourceaccountlbl.setbounds (21, 15, 55, 20);

TARGETACCOUNTLBL = new Label (this, SWT. NONE);
Targetaccountlbl.settext ("Target account:");
Targetaccountlbl.setbounds (9, 43, 65, 20

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.