• 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

  • 相关阅读:
    改变字段的值
    创建新的对象
    根据方法的名称来执行方法
    获取类的字段
    获取构造器的信息
    找出类的方法
    开始使用Reflection
    反射简介
    leetcode501
    leetcode235
  • 原文地址:https://www.cnblogs.com/lingr/p/5563557.html
Copyright © 2020-2023  润新知