机房收费系统中,对于其需求而言,其中少不了要用到datagridview控件来显示一些从数据库中检索到的信息。现在用其中的一个实例来实现以下系统中查询用户充值记录的用例。
以前自己学习的三层资料中,得到的一个学习信息是在三层中,应该把业务逻辑层作为出发点,然后进行功能的实现。或许一个人一个感觉吧,我总是感觉从数据访问层出发,更符合我们的思维逻辑,从而方便业务功能的实现。对于用户充值记录。
Dal数据访问层:
ImportsSystem.Data.sqlClient
Public Function Checkrecord(ByVal Student AsEntity.RechargeRecord) As DataTable
Dim conn As sqlConnection = NewsqlConnection(DAL.DbConnection.Constr)
Dim da As New sqlDataAdapter
Dim dst As New DataSet
Dim dt As New DataTable
conn.Open()
Dim sql As String = "select *from Recharge_Info where CardID='"& Student.CardID & "'"
Dim cmd As sqlCommand = NewsqlCommand(sql,conn)
da.SelectCommand = cmd
da.Fill(dst,"Recharge_Info")
dt =dst.Tables("Recharge_Info")
conn.Close()
Return dt
End Function
BLL业务逻辑层:
PublicFunction CheckRecord(ByVal Student As Entity.RechargeRecord) As DataTable
Dim dalRechargeRecord As NewDAL.RechargeRecordDAL
Dim dt As New DataTable
dt =dalRechargeRecord.Checkrecord(Student)
Return dt
End Function
UI用户界面层:
Dim entityStuRecordAs New Entity.RechargeRecord
entityStuRecord.CardID = txtCardID.Text
Dim bllRechargeRecord As NewBLL.RechargeRecord
DataGridView1.DataSource =bllRechargeRecord.CheckRecord(entityStuRecord)