ATM系统实现[16]——交易事务类[00原创]
来源:互联网 发布:钢铁侠玩具模型淘宝 编辑:程序博客网 时间:2024/04/28 21:02
package cn.edu.ynu.sei.atm.transactions;
import cn.edu.ynu.sei.atm.account.BankAccount;
import cn.edu.ynu.sei.atm.interfaceDef.ITransaction;
import cn.edu.ynu.sei.atm.sqlManager.SqlStatementsManager;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* 实现了帐户的基本交易事务功能
*
* @author 88250
*/
public class Transaction extends UnicastRemoteObject implements ITransaction
{
/**
* SQL语句管理器实例
*/
private SqlStatementsManager sqlSM = SqlStatementsManager.getInstance();
/**
* 构造一个交易实例
* @throws RemoteException
*/
public Transaction() throws RemoteException
{
super();
}
/**
* 转帐事务处理
* @param sourceAccountID 源帐户帐号
* @param targetAccountID 目标帐户帐号
* @param amount 转帐金额
* @throws RemoteException
*/
public void transfer(int sourceAccountID, int targetAccountID, float amount)
throws RemoteException
{
String sourceAccountTableName = null;
String targetAccountTableName = null;
String sourceAccountType = sqlSM.getAccountType(sourceAccountID);
String targetAccountType = sqlSM.getAccountType(targetAccountID);
if (sourceAccountType.equals("cur"))
{
sourceAccountTableName = "CurrentAccount";
}
else if (sourceAccountType.equals("dep"))
{
sourceAccountTableName = "DepositAccount";
}
else
{
sourceAccountTableName = "CreditAccount";
}
if (targetAccountType.equals("cur"))
{
targetAccountTableName = "CurrentAccount";
}
else if (targetAccountType.equals("dep"))
{
targetAccountTableName = "DepositAccount";
}
else
{
targetAccountTableName = "CreditAccount";
}
GregorianCalendar theTime = new GregorianCalendar();
String date = BankAccount.formatTime(theTime.get(Calendar.YEAR),
theTime.get(Calendar.MONTH),
theTime.get(Calendar.DAY_OF_MONTH), theTime
.get(Calendar.HOUR_OF_DAY), theTime
.get(Calendar.MINUTE), theTime.get(Calendar.SECOND));
sqlSM.transfer(sourceAccountID, targetAccountID, date, amount,
sourceAccountTableName, targetAccountTableName);
}
/**
* 返回转帐历史事务列表
* @param accountID 帐户帐号
* @param queryType 查询类型
* @see #getDWInfoList(int, int)
* @throws RemoteException
* @return 转帐历史事务列表
*/
public ArrayList getTransferInfoList(int accountID, int queryType)
throws RemoteException
{
return sqlSM.getTransferInfoList(accountID, queryType);
}
/**
* 返回存款/取款历史事务列表
* @param accountID 帐户帐号
* @param queryType 查询类型,包括:
* <ul>
* <li>0:最近一次交易事务查询</li>
* <li>1:最近一个月交易事务查询</li>
* <li>2:最近一年交易事务查询</li>
* </ul>
* @see #getTransferInfoList(int, int)
* @return 存款/取款历史事务列表
* @throws RemoteException
*/
public ArrayList getDWInfoList(int accountID, int queryType)
throws RemoteException
{
return sqlSM.getDWInfoList(accountID, queryType);
}
}
import cn.edu.ynu.sei.atm.account.BankAccount;
import cn.edu.ynu.sei.atm.interfaceDef.ITransaction;
import cn.edu.ynu.sei.atm.sqlManager.SqlStatementsManager;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
/**
* 实现了帐户的基本交易事务功能
*
* @author 88250
*/
public class Transaction extends UnicastRemoteObject implements ITransaction
{
/**
* SQL语句管理器实例
*/
private SqlStatementsManager sqlSM = SqlStatementsManager.getInstance();
/**
* 构造一个交易实例
* @throws RemoteException
*/
public Transaction() throws RemoteException
{
super();
}
/**
* 转帐事务处理
* @param sourceAccountID 源帐户帐号
* @param targetAccountID 目标帐户帐号
* @param amount 转帐金额
* @throws RemoteException
*/
public void transfer(int sourceAccountID, int targetAccountID, float amount)
throws RemoteException
{
String sourceAccountTableName = null;
String targetAccountTableName = null;
String sourceAccountType = sqlSM.getAccountType(sourceAccountID);
String targetAccountType = sqlSM.getAccountType(targetAccountID);
if (sourceAccountType.equals("cur"))
{
sourceAccountTableName = "CurrentAccount";
}
else if (sourceAccountType.equals("dep"))
{
sourceAccountTableName = "DepositAccount";
}
else
{
sourceAccountTableName = "CreditAccount";
}
if (targetAccountType.equals("cur"))
{
targetAccountTableName = "CurrentAccount";
}
else if (targetAccountType.equals("dep"))
{
targetAccountTableName = "DepositAccount";
}
else
{
targetAccountTableName = "CreditAccount";
}
GregorianCalendar theTime = new GregorianCalendar();
String date = BankAccount.formatTime(theTime.get(Calendar.YEAR),
theTime.get(Calendar.MONTH),
theTime.get(Calendar.DAY_OF_MONTH), theTime
.get(Calendar.HOUR_OF_DAY), theTime
.get(Calendar.MINUTE), theTime.get(Calendar.SECOND));
sqlSM.transfer(sourceAccountID, targetAccountID, date, amount,
sourceAccountTableName, targetAccountTableName);
}
/**
* 返回转帐历史事务列表
* @param accountID 帐户帐号
* @param queryType 查询类型
* @see #getDWInfoList(int, int)
* @throws RemoteException
* @return 转帐历史事务列表
*/
public ArrayList getTransferInfoList(int accountID, int queryType)
throws RemoteException
{
return sqlSM.getTransferInfoList(accountID, queryType);
}
/**
* 返回存款/取款历史事务列表
* @param accountID 帐户帐号
* @param queryType 查询类型,包括:
* <ul>
* <li>0:最近一次交易事务查询</li>
* <li>1:最近一个月交易事务查询</li>
* <li>2:最近一年交易事务查询</li>
* </ul>
* @see #getTransferInfoList(int, int)
* @return 存款/取款历史事务列表
* @throws RemoteException
*/
public ArrayList getDWInfoList(int accountID, int queryType)
throws RemoteException
{
return sqlSM.getDWInfoList(accountID, queryType);
}
}
- ATM系统实现[16]——交易事务类[00原创]
- ATM系统实现[15]——身份验证类[00原创]
- ATM系统实现[18]——数据管理类[00原创]
- ATM系统实现[9]——事务查询窗口[00原创]
- ATM系统实现[5]——注意事项窗口[00原创]
- ATM系统实现[10]——转帐窗口[00原创]
- ATM系统实现[11]——取款窗口[00原创]
- ATM系统实现[12]——抽象转户类[00原创]
- ATM系统实现[19]——服务端[00原创]
- ATM系统实现[13]——业务帐户类[00原创]
- ATM系统实现[14]——可用帐户类[00原创]
- ATM系统实现[17]——数据格式验证类[00原创]
- ATM系统实现[1]——用户登录界面[00原创]
- ATM系统实现[2]——密码修改窗口[00原创]
- ATM系统实现[3]——余额查询窗口[00原创]
- ATM系统实现[4]——帐户选择窗口[00原创]
- ATM系统实现[6]——密码面板组件[00原创]
- ATM系统实现[7]——服务选择窗口[00原创]
- ATM系统实现[13]——业务帐户类[00原创]
- 产生不重复的随机数
- ATM系统实现[14]——可用帐户类[00原创]
- ATM系统实现[15]——身份验证类[00原创]
- 原创:大数阶乘的讨论(2)
- ATM系统实现[16]——交易事务类[00原创]
- ATM系统实现[17]——数据格式验证类[00原创]
- Linux系统下SVN服务器的搭建过程详解
- 原创:大数阶乘的讨论(3)
- ShowDeviceInformation
- 程序员为什么不写单元测试
- asp.net 很简单的ConfirmBox 对话框 实现
- 原创:大数阶乘的讨论(4) (源码未实现)
- 步入事业发展快车道