package cn.edu.ynu.sei.atm.client.ui;
import java.rmi.RemoteException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Text;
/**
* 餘額查詢時段
* @author 88250
*/
public class BalanceQueryComposite extends Composite
{
/**
* 返回按鈕
*/
private Button returnBtn = null;
/**
* 提示可取款數標籤
*/
private Label promptAvailableAmountLbl = null;
/**
* 可取款數顯示域
*/
private Text availableAmountText = null;
/**
* 餘額顯示域
*/
private Text balanceText = null;
/**
* 提示餘額標籤
*/
private Label promptBalanceLbl = null;
/**
* 提示帳戶類型標籤
*/
private Label promptAccountTypeLbl = null;
/**
* 帳戶類型顯示域
*/
private Text accountTypeText = null;
/**
* 帳戶ID顯示域
*/
private Text accountIDText = null;
/**
* 提示帳戶ID標籤
*/
private Label promptAccountIDLbl = null;
/**
* 建立餘額查詢時段容器
* @param parent 父視窗容器
*/
public BalanceQueryComposite(Composite parent)
{
super(parent, SWT.NONE);
createContents();
}
/**
* 顯示帳戶相關資訊
*/
public void displayAccountInfo()
{
try
{
accountIDText.setText(Integer
.toString(AccountSelectComposite.account.getID()));
accountTypeText.setText(AccountSelectComposite.account
.getAccountType());
balanceText.setText(Float.toString(AccountSelectComposite.account
.getBalance()));
availableAmountText.setText(Float
.toString(AccountSelectComposite.account.getRemain()));
}
catch (RemoteException re)
{
MessageBox exitDlg = new MessageBox(this.getShell());
exitDlg.setText("網路連接出現問題....");
exitDlg.setMessage("不能串連到伺服器,系統將退出!");
exitDlg.open();
System.exit(0);
re.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
}
/**
* 建立餘額查詢時段容器內含控制項
*/
private void createContents()
{
promptAccountIDLbl = new Label(this, SWT.NONE);
promptAccountIDLbl.setText("帳戶ID:");
promptAccountIDLbl.setBounds(26, 20, 55, 20);
accountIDText = new Text(this, SWT.BORDER);
accountIDText.setEditable(false);
accountIDText.setBounds(82, 14, 80, 25);
accountTypeText = new Text(this, SWT.BORDER);
accountTypeText.setEditable(false);
accountTypeText.setBounds(82, 46, 80, 25);
promptAccountTypeLbl = new Label(this, SWT.NONE);
promptAccountTypeLbl.setText("帳戶類型:");
promptAccountTypeLbl.setBounds(14, 51, 65, 20);
promptBalanceLbl = new Label(this, SWT.NONE);
promptBalanceLbl.setText("當前餘額:");
promptBalanceLbl.setBounds(15, 86, 65, 20);
balanceText = new Text(this, SWT.BORDER);
balanceText.setEditable(false);
balanceText.setBounds(83, 82, 80, 25);
availableAmountText = new Text(this, SWT.BORDER);
availableAmountText.setEditable(false);
availableAmountText.setBounds(83, 118, 80, 25);
promptAvailableAmountLbl = new Label(this, SWT.NONE);
promptAvailableAmountLbl.setText("可取款數:");
promptAvailableAmountLbl.setBounds(17, 122, 65, 20);
returnBtn = new Button(this, SWT.BORDER);
returnBtn.setText("返回");
returnBtn.setBounds(124, 154, 40, 30);
}
/**
* 取得返回按鈕
* @return 返回按鈕
*/
public Button getReturnLbl()
{
return returnBtn;
}
@Override
public void dispose()
{
super.dispose();
}
@Override
protected void checkSubclass()
{
// Disable the check that prevents subclassing of SWT components
}
}