C#三层ATM-6.查询账户基本信息

查询账户基本信息

1.DAL--cardinfo增加GetModel方法--通过卡号查询

/// <summary>

/// 得到一个对象实体

/// </summary>

public Model.cardinfo GetModel(string cardID)

{

StringBuilder strSql=new StringBuilder();

strSql.Append("select  top 1  ");

strSql.Append(" cardID,curType,savingType,openDate,openMoney,balance,pass,IsReportLoss,customerID ");

strSql.Append(" from cardinfo ");

strSql.Append(" where cardID='"+cardID+"' " );

Model.cardinfo model=new Model.cardinfo();

DataSet ds=DbHelperSQL.Query(strSql.ToString());

if(ds.Tables[0].Rows.Count>0)

{

return DataRowToModel(ds.Tables[0].Rows[0]);

}

else

{

return null;

}

}

/// <summary>

/// 数据行转换得到一个对象实体

/// </summary>

public Model.cardinfo DataRowToModel(DataRow row)

{

Model.cardinfo model=new Model.cardinfo();

if (row != null)

{

if(row["cardID"]!=null)

{

model.cardID=row["cardID"].ToString();

}

if(row["curType"]!=null)

{

model.curType=row["curType"].ToString();

}

if(row["savingType"]!=null)

{

model.savingType=row["savingType"].ToString();

}

if(row["openDate"]!=null && row["openDate"].ToString()!="")

{

model.openDate=DateTime.Parse(row["openDate"].ToString());

}

if(row["openMoney"]!=null && row["openMoney"].ToString()!="")

{

model.openMoney=decimal.Parse(row["openMoney"].ToString());

}

if(row["balance"]!=null && row["balance"].ToString()!="")

{

model.balance=decimal.Parse(row["balance"].ToString());

}

if(row["pass"]!=null)

{

model.pass=row["pass"].ToString();

}

if(row["IsReportLoss"]!=null && row["IsReportLoss"].ToString()!="")

{

if((row["IsReportLoss"].ToString()=="1")||(row["IsReportLoss"].ToString().ToLower()=="true"))

{

model.IsReportLoss=true;

}

else

{

model.IsReportLoss=false;

}

}

if(row["customerID"]!=null && row["customerID"].ToString()!="")

{

model.customerID=int.Parse(row["customerID"].ToString());

}

}

return model;

}

2.BLL--cardinfo增加GetModel方法

/// <summary>

/// 得到一个对象实体

/// </summary>

public Model.cardinfo GetModel(string cardID)

{

return dal.GetModel(cardID);

}

3.WinF--show窗体

1)为窗体类增加卡号字段

2)编写窗体load方法

代码如下:

wps5278.tmp

4.WinF--main窗体---编写查余额菜单项代码

wps5279.tmp

转载于:https://www.cnblogs.com/lingr/p/5563557.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值