bankcomponentimpl.cs
来自「工作流的基本资料(文档资料」· CS 代码 · 共 65 行
CS
65 行
using System;
using NetBpm.Util.DB;
using NHibernate.Type;
using log4net;
namespace NetBpm.Test.Bank.Impl
{
public class BankComponentImpl
{
private static readonly BankComponentImpl instance = new BankComponentImpl();
private static readonly log4net.ILog log = LogManager.GetLogger(typeof (BankComponentImpl));
/// <summary> gets the singleton instance.</summary>
public static BankComponentImpl Instance
{
get { return instance; }
}
private const String queryFindBankAccount = "select b " +
"from b in class NetBpm.Test.Bank.BankAccount " +
"where b.BankName = ? " +
" and b.Customer = ?";
public BankAccount GetBankAccount(string bank, string costumer, DbSession dbSession)
{
log.Debug("GetBankAccount");
BankAccount bankAccount = null;
Object[] values = new Object[] {bank, costumer};
IType[] types = new IType[] {DbType.STRING, DbType.STRING};
bankAccount = (BankAccount) dbSession.FindOne(queryFindBankAccount,values,types);
return bankAccount;
}
public void CreateAccount(BankAccount bankAccount, DbSession dbSession)
{
log.Debug("CreateAccount");
dbSession.Save(bankAccount);
}
public void DeleteAccount(string bank, string costumer, DbSession dbSession)
{
log.Debug("DeleteAccount");
Object[] values = new Object[] {bank, costumer};
IType[] types = new IType[] {DbType.STRING, DbType.STRING};
dbSession.Delete(queryFindBankAccount,values,types);
}
public void Withdraw(string bank, string costumer,float amount, DbSession dbSession)
{
Deposid(bank, costumer, -amount, dbSession);
}
public void Deposid(string bank, string costumer,float amount, DbSession dbSession)
{
BankAccount bankAccount = GetBankAccount(bank, costumer, dbSession);
bankAccount.Value=bankAccount.Value+amount;
dbSession.Save(bankAccount);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?