惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
H
Help Net Security
MongoDB | Blog
MongoDB | Blog
I
InfoQ
N
Netflix TechBlog - Medium
T
Tailwind CSS Blog
量子位
博客园 - 叶小钗
月光博客
月光博客
IT之家
IT之家
G
Google Developers Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
S
SegmentFault 最新的问题
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
aimingoo的专栏
aimingoo的专栏
云风的 BLOG
云风的 BLOG
Vercel News
Vercel News
爱范儿
爱范儿
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享

博客园 - chenglingr

C#三层ATM-12.资产查询 C#三层ATM-13.ATM开户 C#三层ATM-10.改密码 C#三层ATM-11.查看交易信息 C#三层ATM-9.转账功能设计 C#三层ATM-7.挂失 C#三层ATM-8.存款、取款功能设计 C#三层ATM-5.登陆功能设计 C#三层ATM-4.ATM界面设计 C#三层ATM-3.编写数据库访问类 C#三层ATM-2.编写Model项目实体类 C#三层ATM-1.搭建三层ATM项目框架 C#三层ATM-0.数据表设计 MVC系列15-首页 MVC系列-13.前台文章显示页 MVC系列14-后台我的文章页 MVC系列-12.项目的重新规划 MVC系列-11.两表联合-发表文章 MVC系列-10.用户验证-导航条改造
C#三层ATM-6.查询账户基本信息
chenglingr · 2016-06-06 · via 博客园 - chenglingr

查询账户基本信息

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