ASP.NET图书馆管理信息系统

摘  要

本文首先阐述了基于.NET Framework平台的图书馆管理信息系统的开发背景以及其实践意义,其次说明了图书馆管理信息系统的功能以及相比同类软件的创新之处。然后就图书馆管理系统开发中所使用的一些的技术进行研究探讨。主要针对数据库的设计技术、存储过程技术、ADO.NET技术以及用SQL Server .NET Framework 数据提供程序访问SQLserver2000数据库技术四个方面进行了研究。最后还附上了图书馆管理信息系统的安装说明、简单使用说明和一些通用性的经典代码。笔者化了大量的时间用于程序设计,这也是笔者工作的重点,所开发的软件具有实用价值,所编写的代码对.NET程序员也有很好的参考性。在系统的开发过程中,笔者深刻体会到了.NET平台的强大性、优越性以及存储过程在提高数据访问性能和增强数据访问安全性上所起到的重要作用。此外,对于关系代数在数据库科学里的应用,笔者在编程过程中也做了一定的研究。

关键词: 数据库;.NET Framework;ADO.NET;存储过程;SQL Server .NET Framework 数据提供程序

图书馆管理系统基于Microsoft公司最新的.NET Framework平台构建,编码的基本语言是VB.NET。开发过程中统一使用.NET框架的数据类型、方法,抛弃了原来vb6的内容。充分体现了.NET的优越性,使软件易安装部署、易维护。系统使用ADO.NET+SQLserver2000模式,数据层基本都基于存储过程构建,使得速度更快、安全性更高。

2.1系统提供的功能:

   针对图书馆管理员设计的部分

    管理部分是一个基于WinForms的windows窗体应用程序,主要为图书馆管理人员提供服务。截图如下:

管理部分提供以下功能:

  1. 用户功能。(提供登陆验证、用户切换,管理员锁定系统等功能。)
  2. 事务处理  

    图书证挂失管理。(可以针对读者情况对图书证进行挂失,以防冒借。)

    借书、还书管理。(实现日常图书借阅及归还。)

  1. 数据管理

    图书、读者管理。(实现图书、读者的添加,删除,编辑。)

  1. 综合查询统计。(可以根据不同条件的组合检索图书或读者以及借阅数据,对检索出来的数据可提供多种方式的操作:导出为Excel格式、pdf格式、或导出为水晶报表以便打印等。)
  2. 系统设定。(设置一些图书馆基本规则,如读者类别、图书类别、读者借阅最大天数等,此外设定数据服务器信息也在这里。)
  3. 帮助功能。(提供一个chm帮助文档,帮助图书馆工作人员快速适应本系统,此外还提供在线问题反馈,软件更新提示等功能。)

   针对读者设计的部分:

   由于读者的多元性和位置不确定性,该部分采取基于B/S的方式实现。代码使用ASP.NET编写,利用ASP.NET的优点,可以自动适应多种客户浏览器。截图如下:


    读者只需要有一台联网的计算机和一个常用WEB浏览器。就可以轻松的进行图书查询、更改个人信息、向图书馆反馈信息等。该部分主要提供以下功能:

  1. 登陆验证。(防止读者信息被盗用。)
  2. 图书查询。(一个综合的图书查询系统,可以方便的使读者查到需要的书籍。)
  3. 读者个人信息查询以及管理。(可以适当的更改一些读者个人的资料,如email等,此外在这里还可以查到读者当前的、所有的借阅记录等。)
  4. 信息服务。(定期公布超期的读者列表,以及新到的图书等信息。)

5.1存储过程

--备份数据的存储过程

--将数据库备份到服务器C:\下,文件名为 当前日期+.zjx

ALTER PROCEDURE BACKUPmyData   

AS

    DECLARE @path varchar(15)

    set @path=convert(varchar,getdate(),112)

    set @path='C:\'+@path+'.zjx'

    BACKUP DATABASE lib2004

         TO Disk = @path

    WITH FORMAT,

    NAME = 'Full Backup of lib2004'

    RETURN

/*检索某图书是哪位读者借去的*/

ALTER PROCEDURE Book1IsBorrowByWho

    @Book_code nvarchar(50)

AS

SELECT Au_id

FROM borrow

WHERE (book_code = @Book_code) AND (Return_date IS NULL)

    RETURN

/*检索某图书是否在馆*/

/*检索在馆的图书 只要图书id不在 借阅记录没有归还的记录 里 就表示在馆*/

/*不在馆 则返回0

  在馆  返回1 */

ALTER PROCEDURE Book1IsInLib

    @Book_code nvarchar(50)

AS

SELECT COUNT(*) as IsInLib

FROM book

WHERE Book_code = @Book_code AND Book_code IN

          (SELECT book_code

         FROM Book

         WHERE Book_code NOT IN

                   (SELECT borrow.Book_code

                  FROM borrow

                  WHERE Return_date IS NULL))

    RETURN

/* 用于获取一位读者的

    当前借阅书数,

    总共借阅书数,

    可借书数

    最大借阅时间

    输入参数Au_id */

ALTER PROCEDURE Get1AuInfo

    @Au_id nvarchar(50), /*1*/

    @BorrowNo int output,

    @BorrowNoCurrent int output,

    @MaxBorrowDays int output,

    @MaxBorrowBooks int output

AS

    begin transaction

   

    SELECT @BorrowNo=COUNT(*)

    FROM borrow

    WHERE (Au_id = @Au_id)

   

    SELECT @BorrowNoCurrent=COUNT(*)

    FROM borrow

    WHERE (Au_id = @Au_id) AND (Return_date IS NULL)

    SELECT @MaxBorrowDays=ausort.Au_borrowdays ,

          @MaxBorrowBooks=ausort.Au_borrowbooks

    FROM ausort INNER JOIN

          au ON ausort.Au_sort = au.Au_sort

    WHERE (au.Au_id = @Au_id)

   

    commit transaction

    RETURN

/* 用于获取一位读者所有超期的借书列表 Au_id */

/*author:翟靖轩 */

ALTER PROCEDURE Select1AuMaxDateBookList

    @Au_id nvarchar(50) /*1*/

AS

    SELECT borrow.book_code AS 图书条码号, book.Book_name AS 图书题名,

          borrow.Borrow_date AS 借阅日期, borrow.Should_date AS 应还日期

    FROM book INNER JOIN

          borrow ON book.Book_code = borrow.book_code

    WHERE (borrow.Au_id = @Au_id) AND (borrow.Return_date IS NULL) AND

          (borrow.Should_date < GETDATE())

    ORDER BY borrow.Should_date DESC

    RETURN

/*返回超期的所有读者*/

/*author:翟靖轩 2004-5-10*/

ALTER PROCEDURE SelectMaxDateAuList

AS

    SELECT borrow.Au_id AS 借书证号, au.Au_name AS 读者姓名,

          borrow.book_code AS 图书条码号, book.Book_name AS 图书名称,

          borrow.Borrow_date AS 借书日期, borrow.Should_date AS 应归还日期

    FROM borrow INNER JOIN

          au ON borrow.Au_id = au.Au_id INNER JOIN

          book ON borrow.book_code = book.Book_code

    WHERE (borrow.Return_date IS NULL) AND (GETDATE() > borrow.Should_date)

    ORDER BY borrow.Au_id   

    RETURN

/*查询一个读者的所有借阅记录  包括已经借过的已经归还的书籍

 作者:翟靖轩

 日期:2004-5-2 */        

ALTER PROCEDURE SelectAuAllBorrowList

    @Au_id nvarchar(50)

AS

    SELECT book.Book_code AS 条码号, book.Book_name AS 图书题名,

          borrow.Borrow_date AS 借阅日期, borrow.Return_date AS 归还日期,

          borrow.Should_date AS 应归还日期, book.Book_isbn AS ISBN号,

          book.Book_pub AS 出版社, book.Book_sort AS 图书分类,

          book.Book_author AS 图书作者

    FROM book LEFT OUTER JOIN

          borrow ON book.Book_code = borrow.book_code

    WHERE (borrow.Au_id = @Au_id)

    ORDER BY borrow.Return_date, borrow.Borrow_date DESC

    RETURN

/* 综合图书查询 */

-- 查询所有在馆图书

ALTER PROCEDURE searchBookInLib

    @Book_code nvarchar(50)='',

    @Book_name nvarchar(50)='',

    @Book_pub nvarchar(50)='',

    @Book_isbn nvarchar(50)='',

    @Book_pubdate smalldatetime='1900-01-01',

    @Book_author nvarchar(50)='',  

    @Book_sort nvarchar(50)='' 

AS

    SELECT Book_code AS 条形码, Book_name AS 图书名称, Book_author AS 图书作者,

          Book_pub AS 出版社, Book_isbn AS ISBN号, Book_pubdate AS 出版日期,

          Book_page AS 图书页数, Book_price AS 图书价格, Book_adddate AS 入馆日期,

          Book_place AS 存放位置, Book_sort AS 图书分类

    FROM book

    WHERE (Book_code LIKE '%' + @Book_code + '%') AND

          (Book_name LIKE '%' + @Book_name + '%') AND

          (Book_pub LIKE '%' + @Book_pub + '%') AND

          (Book_isbn LIKE '%' + @Book_isbn + '%') AND

          (Book_author LIKE '%' + @Book_author + '%') AND

          (Book_sort LIKE '%' + @Book_sort + '%') AND

          (Book_pubdate > @Book_pubdate) and       

           Book_code not IN

                   (SELECT borrow.Book_code

                  FROM borrow

                  WHERE Return_date IS NULL)       

    RETURN

5.2  winForms代码选录

一个用于执行存储过程的类

Imports System.Data

Imports System.Data.SqlClient

Public Class CdataService

    Protected Connection As SqlConnection

    Private m_DSN As String

    '构建一个带有参数的sqlcommand

    Private Overloads Function CreateCommand(ByVal sprocName As String, ByVal parameters() As IDataParameter) As SqlCommand

        Dim command As SqlCommand = New SqlCommand(sprocName, Connection)

        command.CommandType = CommandType.StoredProcedure

        Dim para As SqlParameter

        For Each para In parameters

            command.Parameters.Add(para)

        Next

        command.Parameters.Add(New SqlParameter("Return Value", _

        SqlDbType.Int, _

        4, _

        System.Data.ParameterDirection.ReturnValue, _

         False, _

          0, _

          0, _

          String.Empty, _

          DataRowVersion.Default, _

          Nothing))

        Return command

    End Function

    '构建一个没有参数的sqlcommand

    Private Overloads Function CreateCommand(ByVal sprocName As String) As SqlCommand

        Dim command As SqlCommand = New SqlCommand(sprocName, Connection)

        command.CommandType = CommandType.StoredProcedure

        command.Parameters.Add(New SqlParameter("Return Value", _

        SqlDbType.Int, _

        4, _

        System.Data.ParameterDirection.ReturnValue, _

         False, _

          0, _

          0, _

          String.Empty, _

          DataRowVersion.Default, _

          Nothing))

        Return command

    End Function

    Public ReadOnly Property DSN() As String

        Get

            Return m_DSN

        End Get

    End Property

    Public Overloads Function RunSP(ByVal sprocName As String) As Int32

        Dim result As Int32

        Connection.Open()

        Dim command As SqlCommand = Me.CreateCommand(sprocName)

        command.ExecuteNonQuery()

        result = CType(command.Parameters("Return Value").Value, Int32)

        Me.Connection.Close()

        Return result

    End Function

    Public Overloads Function RunSP(ByVal sprocName As String, ByVal parameters() As IDataParameter) As Int32

        Dim result As Int32

        Connection.Open()

        Dim command As SqlCommand = Me.CreateCommand(sprocName, parameters)

        command.ExecuteNonQuery()

        result = CType(command.Parameters("Return Value").Value, Int32)

        Me.Connection.Close()

        Return result

    End Function

    Public Overloads Function RunSP(ByVal sprocName As String, _

   ByVal parameters() As IDataParameter, ByVal DataSet As DataSet) As Int32

        Dim result As Int32

        Dim sqlDA As New SqlDataAdapter

        Connection.Open()

        sqlDA.SelectCommand = Me.CreateCommand(sprocName, parameters)

        sqlDA.Fill(DataSet, "SourceTable")

        result = CType(sqlDA.SelectCommand.Parameters("Return Value").Value, Int32)

        Connection.Close()

        Return result

    End Function

    Public Overloads Function RunSP(ByVal sprocName As String, _

    ByRef DataSet1 As DataSet) As Int32

        Dim result As Int32

        Dim sqlDA As New SqlDataAdapter

        Connection.Open()

        sqlDA.SelectCommand = Me.CreateCommand(sprocName)

        sqlDA.Fill(DataSet1)

        result = CType(sqlDA.SelectCommand.Parameters("Return Value").Value, Int32)

        Connection.Close()

        Return result

    End Function

    Public Overloads Function RunSP(ByVal sprocName As String, _

       ByVal parameters() As IDataParameter, ByRef DataSet As DataSet, ByVal TableName As String) As Int32

        Dim result As Int32

        Dim sqlDA As New SqlDataAdapter

        Connection.Open()

        sqlDA.SelectCommand = Me.CreateCommand(sprocName, parameters)

        sqlDA.Fill(DataSet, TableName)

        result = CType(sqlDA.SelectCommand.Parameters("Return Value").Value, Int32)

        Connection.Close()

        Return result

    End Function

    Public Function Construct(ByVal ConstructString As String)

        m_DSN = ConstructString

    End Function

    Public Function Activate()

        Connection = New SqlConnection(m_DSN)

    End Function

    Public Function Deactivate()

        Connection = Nothing

    End Function

    Public Sub New()

    End Sub

    Public Sub New(ByVal ConstrucString As String)

        Construct(ConstrucString)

        Me.Activate()

    End Sub

    Protected Overrides Sub Finalize()

        MyBase.Finalize()

        Me.Deactivate()

    End Sub

End Class

图书查询窗体的全部代码frmBookQuery.vb

Imports System.Data.SqlClient

Imports System.Drawing.Printing

Public Class frmBookQuery

    Inherits library.frmBase

#Region " Windows 窗体设计器生成的代码 "

    此处略去

#End Region

    Private Sub frmBookQuery_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        With Me.dbgBookList

            .Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _

                Or System.Windows.Forms.AnchorStyles.Left) _

                Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)

            .BackColor = System.Drawing.Color.Snow

            .BackgroundColor = System.Drawing.SystemColors.ActiveCaptionText

            .CaptionVisible = False

            .HeaderForeColor = System.Drawing.SystemColors.ControlText

            .ReadOnly = True

        End With

        BindComboBox1()

        Me.cboBook_sort.Text = ""

    End Sub

    Function search()

      

        Dim cn As New SqlClient.SqlConnection(cnstr)

        Dim cmd As New SqlCommand

        Dim da As SqlDataAdapter

        Dim ds As New DataSet

        With cmd

            If Me.radAllBook.Checked = True Then

                .CommandText = "searchBook"

            Else

                .CommandText = "searchBookInlib"

            End If

            .CommandType = CommandType.StoredProcedure

            .Connection = cn

        End With

        Dim mBook_code As New SqlParameter("@Book_code", SqlDbType.NVarChar, 50) '1

        Dim mBook_name As New SqlParameter("@Book_name", SqlDbType.NVarChar, 50) '2

        Dim mBook_pub As New SqlParameter("@Book_pub", SqlDbType.NVarChar, 50) '3

        Dim mBook_isbn As New SqlParameter("@Book_isbn", SqlDbType.NVarChar, 50) '4

        Dim mBook_pubdate As New SqlParameter("@Book_pubdate", SqlDbType.SmallDateTime, 4)

        Dim mBook_author As New SqlParameter("@Book_author", SqlDbType.NVarChar, 50) '6

        Dim mBook_sort As New SqlParameter("@Book_sort", SqlDbType.NVarChar, 50) '11

        With cmd.Parameters

            .Add(mBook_code)

            .Add(mBook_name)

            .Add(mBook_pub)

            .Add(mBook_isbn)

            .Add(mBook_pubdate)

            .Add(mBook_author)

            .Add(mBook_sort)

        End With

        '赋值

        mBook_code.Value = Me.txtBook_code.Text.Trim  '1

        mBook_name.Value = Me.txtBook_name.Text.Trim  '2

        mBook_pub.Value = Me.txtBook_pub.Text.Trim  '3

        mBook_isbn.Value = Me.txtBook_isbn.Text.Trim  '4

        mBook_pubdate.Value = Me.dtpBook_pubdate.Value '5

        mBook_author.Value = Me.txtBook_author.Text.Trim   '6

        mBook_sort.Value = Me.cboBook_sort.Text.Trim   '11

        da = New SqlDataAdapter(cmd)

        Try

            da.Fill(ds)

            ds.Tables(0).Columns(0).Caption = "图书条码号"

            Me.dbgBookList.DataSource = ds.Tables(0)

            Me.Label8.Text = "共检索到" + ds.Tables(0).Rows.Count.ToString + "条记录"

        Catch ex As Exception

            MessageBox.Show(ex.Message)

        Finally

            cn.Close()

            If Not cn Is Nothing Then

                cn.Dispose()

            End If

        End Try

    End Function

    Function BindComboBox1()

        Dim cnLib2004 As SqlConnection

        Dim cmdbooksort As SqlCommand

        Dim drBooksort As SqlDataReader

        cnLib2004 = New SqlConnection(cnstr)

        cmdbooksort = New SqlCommand

        With cmdbooksort

            .CommandType = CommandType.StoredProcedure

            .Connection = cnLib2004

            .CommandText = "selectBookSort"

        End With

        Try

            cnLib2004.Open()

            drBooksort = cmdbooksort.ExecuteReader

            Dim myarr As New ArrayList

            While drBooksort.Read

                myarr.Add(drBooksort.Item(0))

            End While

            Me.cboBook_sort.DataSource = myarr

        Catch ex As Exception

            MessageBox.Show(ex.Message)

            Me.Close()

        Finally

            cnLib2004.Close()

        End Try

    End Function

    Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles ToolBar1.ButtonClick

        If e.Button Is Me.tbtnQuery Then

            search()

        ElseIf e.Button Is Me.tbtnExit Then

            Me.Close()

        ElseIf e.Button Is Me.tbtnReset Then

            frmClear()

        ElseIf e.Button Is Me.tbtnExcel Then

            excel()

        ElseIf e.Button Is Me.tbtnPrint Then

            print()

        End If

    End Sub

    Private Sub frmClear()

        Dim p1 As Control

        Dim u As New Label

        For Each p1 In Me.Panel2.Controls

            If Not p1.GetType Is u.GetType Then

                p1.Text = ""

            End If

        Next

        Me.cboBook_sort.Text = ""

        Me.radAllBook.Checked = True

        Me.dtpBook_pubdate.Value = "1990-1-1"

        Me.txtBook_code.Focus()

        Me.dbgBookList.DataSource = Nothing

    End Sub

  Sub excel()

        Dim tableAu As DataTable

        tableAu = CType(Me.dbg.DataSource, DataTable)

        If tableAu Is Nothing Then

            MessageBox.Show("没有任何记录可以导出!", "error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

            Exit Sub

        End If

     

        Dim myfrm As New frmShowProgress

        myfrm.Show("正在建立excel对象...")

        Try

            Dim exl As New Microsoft.Office.Interop.Excel.ApplicationClass

            Dim workbook As Microsoft.Office.Interop.Excel.Workbook

            Dim sheet As Microsoft.Office.Interop.Excel.Worksheet

            workbook = CType(exl.Workbooks.Add(), Microsoft.Office.Interop.Excel.Workbook)

            sheet = CType(workbook.Sheets(1), Microsoft.Office.Interop.Excel.Worksheet)

            Dim mycount, mycolumn As Int16

            With tableAu

                myfrm.setMsg("正在导出数据,请等待......")

                For mycount = 0 To .Rows.Count - 1

                    For mycolumn = 0 To .Columns.Count - 1

                        With sheet

                            .Cells(mycount + 2, mycolumn + 1) = tableAu.Rows(mycount).Item(mycolumn)

                        End With

                    Next

                    'MsgBox(CType(mycount / .Rows.Count * 100, Int16))

                    myfrm.setProgress(CType(mycount / .Rows.Count * 100, Int16))

                Next

                myfrm.setMsg("正在设定excel表头格式...")

                For mycolumn = 0 To .Columns.Count - 1

                    exl.Workbooks(1).Worksheets(1).cells(1, mycolumn + 1) = .Columns(mycolumn).ColumnName

                    exl.Workbooks(1).Worksheets(1).cells(1, mycolumn + 1).Font.Bold = True

                Next

            End With

            myfrm.setProgress(100)

            myfrm.Close()

            'workbook.SaveAs(myfile)

            sheet.Application.Visible = True

            'exl.Quit()          

            Catch ex As Exception

            MessageBox.Show("导出失败!", "fail", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)           

            myfrm.Close()

        End Try

    End Sub

    Private Sub print()

        Dim tableAu As DataTable

        tableAu = CType(Me.dbgBookList.DataSource, DataTable)

        If tableAu Is Nothing Then

            MessageBox.Show("没有任何记录可以导出!", "error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

            Exit Sub

        End If

        Dim myfrm2 As New frmStatus

        myfrm2.Show("正在导出报表...")

        Dim myfrm As New frmShowReport

        Dim rtd As New crtBook

        rtd.SetDataSource(tableAu)

        myfrm.Text = "报表输出窗口..."

        myfrm.rpt.ReportSource = rtd

        myfrm.rpt.DisplayGroupTree = False

        myfrm2.Close()

        myfrm.ShowDialog()

    End Sub

End Class

登陆窗体代码frmLogin.vb

Public Class frmLogin

    Inherits System.Windows.Forms.Form

    Public IsLogSuccess As Boolean

Public strLogUser As String

#Region " Windows 窗体设计器生成的代码 "

    此处略……

    #End Region

Private Sub frmLogin_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

        IsLogSuccess = False     

    End Sub

    Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click       

        IsLogSuccess = validateLogin(Me.txtUser.Text.Trim, Me.txtPwd.Text.Trim)

        If IsLogSuccess = True Then

            strLogUser = Me.txtUser.Text.Trim

            Me.Close()

        Else

            MessageBox.Show("密码错误!", "请重新登陆!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

        End If

    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

        Me.Close()

    End Sub

    Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint

        Dim grbrush As Drawing2D.LinearGradientBrush

        grbrush = New Drawing2D.LinearGradientBrush(New Point(0, 0), _

         New Point(sender.Width, sender.Height), Color.DarkSlateGray, Color.White)

        sender.CreateGraphics.FillRectangle(grbrush, New Rectangle(0, 0, sender.Width, sender.Height))

    End Sub

End Class

将数据服务器信息序列化为xml文件的类

Imports System.Xml.Serialization

Imports System.IO

Imports System.Collections

Public Class CsetCnInfo

    Structure CnInfo

        Public server As String

        Public database As String

        Public uid As String

        Public password As String

    End Structure

    Private mCC(4) As String

    Public Function setCnTofile()

        Dim mcn As CnInfo

        mcn.server = mCC(0)

        mcn.database = mCC(1)

        mcn.uid = mCC(2)

        mcn.password = mCC(3)

        Dim xmlS As New XmlSerializer(GetType(CnInfo))

        Dim txtwt As TextWriter = New StreamWriter("cninfo.xml")

        xmlS.Serialize(txtwt, mCn)

        txtwt.Close()

    End Function

    Public Function GetCnFromfile() As String

        Dim mcn As CnInfo

        Dim xmls As New XmlSerializer(GetType(CnInfo))

        Dim txtwt As TextReader = New StreamReader("cninfo.xml")

        Try

            mcn = xmls.Deserialize(txtwt)

            mCC(0) = mcn.server

            mCC(1) = mcn.database

            mCC(2) = mcn.uid

            mCC(3) = mcn.password

        Catch ex As Exception

            Throw ex

        Finally

            txtwt.Close()

        End Try

        Return returnCnstr()

    End Function

    Public Function returnCnstr() As String

        Return "server=" + mCC(0) + ";database=" _

        + mCC(1) + ";uid=" + mCC(2) + ";pwd=" + mCC(3)

    End Function

    Public Property cnstr() As String()

        Get

            Return mCC

        End Get

        Set(ByVal Value As String())

            Value.CopyTo(mCC, 0)

        End Set

    End Property

    Public Sub New()

    End Sub

End Class

验证登陆的函数

Public Function validateLogin(ByVal uid As String, ByVal pwd As String) As Boolean

        Dim IsCorrect As Boolean = False

        Dim cnmy As New SqlConnection(cnstr)

        Dim cmd As New SqlCommand

        With cmd

            .Connection = cnmy

            .CommandType = CommandType.Text

            .CommandText = "select count(*) from manager where Man_id=@Man_id and Man_pwd=@Man_pwd"

        End With

        Dim mMan_id As New SqlParameter("@Man_id", SqlDbType.NVarChar, 50)

        Dim mMan_pwd As New SqlParameter("@Man_pwd", SqlDbType.NVarChar, 12)

        With cmd.Parameters

            .Add(mMan_id)

            .Add(mMan_pwd)

        End With

        mMan_id.Value = uid

        mMan_pwd.Value = pwd

        Try

            cnmy.Open()

            If cmd.ExecuteScalar = 1 Then

                IsCorrect = True

            End If

        Catch ex As Exception

            MessageBox.Show("登陆验证时数据库发生错误" + vbCrLf + ex.Message, _

            "error", MessageBoxButtons.OK, MessageBoxIcon.Stop)

            Return False

        Finally

            cnmy.Close()

            If Not cnmy Is Nothing Then

                cnmy.Dispose()

            End If

        End Try

        Return IsCorrect

    End Function

5.3  ASP.NET WebForms代码选录

显示读者基本信息Userinfo.aspx的页面后置代码(CodeBehind)

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        '在此处放置初始化页的用户代码

        If Session("UID") Is Nothing Then

            Page.Response.Redirect("login.aspx")

        End If

        If Not IsPostBack Then

            If Not Session("UID") Is Nothing Then

                AuTextBind(Session("UID"))

                setBorrowState(Session("UID"))

            Else

                Page.Response.Redirect("login.aspx")

            End If

        End If

    End Sub

    '显示某读者基本情况

    Function AuTextBind(ByVal strAu_id As String)

        Dim cnlib2004 As SqlConnection

        Dim cmdAuBorrowList As SqlCommand

        Dim drAuBorrowList As SqlDataReader

        cnlib2004 = New SqlConnection(ConfigurationSettings.AppSettings("cncstr"))

        cmdAuBorrowList = New SqlCommand

        With cmdAuBorrowList

            .CommandType = CommandType.StoredProcedure

            .CommandText = "Select1Au"

            .Connection = cnlib2004

        End With

        Dim mAu_id As New SqlParameter("@Au_id", SqlDbType.NVarChar, 50) '1

        cmdAuBorrowList.Parameters.Add(mAu_id)

        mAu_id.Value = strAu_id

        Try

            cnlib2004.Open()

            drAuBorrowList = cmdAuBorrowList.ExecuteReader(CommandBehavior.SingleRow)

            With drAuBorrowList

                If .Read() Then

                    Me.spAuadddate.InnerHtml = CType(.Item("Au_adddate"), String)

                    Me.spAuadr.InnerHtml = .Item("Au_adr")

                    Me.spAuname.InnerHtml = .Item("Au_name")

                    Me.spAusex.InnerHtml = .Item("Au_sex")

                    Me.spAusort.InnerHtml = .Item("Au_sort")

                    Me.spAuid.InnerHtml = strAu_id

                    Me.spAuemail.InnerHtml = .Item("Au_email")

                    Me.spAuremarks.InnerHtml = .Item("Au_remarks")

                Else

                  

                End If

            End With

        Catch ex As Exception

            Response.Write(ex.Message)

        Finally

            cnlib2004.Close()

        End Try

    End Function

    '显示读者借书状态 最大借书册书,当前借书册数 等

    Function setBorrowState(ByVal strAu_id As String)

        Dim cnlib2004 As SqlConnection

        Dim cmd As SqlCommand

        Dim dr As SqlDataReader

        Dim CurBorrowNo As Int16

        Dim AllborrowNo As Int16

        Dim BorrowDays As Int16

        Dim BorrowBooks As Int16

        cnlib2004 = New SqlConnection(ConfigurationSettings.AppSettings("cncstr"))

        cmd = New SqlCommand

        With cmd

            .CommandType = CommandType.StoredProcedure

            .CommandText = "SelectAuCurrentBorrowNo"

            .Connection = cnlib2004

        End With

        Dim mAu_id As New SqlParameter("@Au_id", SqlDbType.NVarChar, 50) '1

        cmd.Parameters.Add(mAu_id)

        mAu_id.Value = strAu_id

        Try

            cnlib2004.Open()

            CurBorrowNo = CType(cmd.ExecuteScalar, Int16)

            cmd.CommandText = "SelectAuAllBorrowNo"

            AllborrowNo = CType(cmd.ExecuteScalar, Int16)

            cmd.CommandText = "SelectAuSortInfo"

            dr = cmd.ExecuteReader(CommandBehavior.SingleRow)

            While dr.Read()

                BorrowDays = dr.Item("Au_borrowdays")

                BorrowBooks = dr.Item("Au_borrowbooks")

            End While

            Me.spTotalBorrowNo.InnerHtml = "共借书" + AllborrowNo.ToString + "册"

            Me.spMaxBorrowDays.InnerHtml = BorrowDays.ToString + "天"

            Me.spBorrowQinkuang.InnerHtml = "[" + CurBorrowNo.ToString + "/"

            Me.spBorrowQinkuang.InnerHtml += BorrowBooks.ToString + "]"

        Catch ex As Exception

            Response.Redirect("error.aspx?errmsg=" + ex.Message)

        Finally

            cnlib2004.Close()

        End Try

    End Function

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/590466.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Qt模型视图代理之MVD(模型-视图-代理)概念的简单介绍

往期回顾 Qt绘图与图形视图之Graphics View坐标系的简单介绍-CSDN博客 Qt绘图与图形视图之基本图元绘制的简单介绍-CSDN博客 Qt绘图与图形视图之自定义图元实现拖拽、拉伸、旋转功能-CSDN博客 Qt模型视图代理之MVD(模型-视图-代理)概念的简单介绍 一、基本概念 Qt模型视图代理…

浅谈MOS管的发热原因和解决办法

大家好&#xff0c;我是砖一。 今天给大家分享一下MOS管基础知识&#xff0c;为什么内阻那么小的MOS管&#xff0c;也会发热&#xff1f;有做功率元器件&开关电源和IC的朋友可以了解一下&#xff0c;希望对你有用~ 一&#xff0c;MOS管发热影响因素 经常查阅MOS管的数据手…

xftp破解版?No!xftp平替开源工具✔

文章目录 一、背景说明二、WindTerm介绍三、简单使用说明3.1 新建一个ssh连接窗口![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/bfbe5114916e4a7e94ca0f9ceb05ca37.png)3.2 输入主机ip和端口号3.3 点击Continue3.4 输入密码3.5 登入成功3.6 下载文件到本地3.7 上…

vue+element-ui实现横向长箭头,横向线上下可自定义文字(使用after伪元素实现箭头)

项目场景&#xff1a; 需要实现一个长箭头&#xff0c;横向线上下可自定义文字 代码描述 <div><span class"data-model">{{ //上方文字}}</span><el-divider class"q"> </el-divider>//分隔线<span class"data-mod…

C语言/数据结构——每日一题(环形链表的约瑟夫问题)

一.前言 今天在牛客网上面看到了一道环形链表题&#xff0c;想着和大家们分享一下。可能我有点笨&#xff0c;那道题的链接我没搞好&#xff0c;所以很抱歉&#xff0c;只能麻烦大家们看一下截屏的题目信息了。废话不多数&#xff0c;让我们开始今天的题目分享吧。 二.正文 …

Day01-zabbix监控详解

Day01-zabbix监控详解 一、什么是监控&#xff0c;为什么需要监控1.1 监控概述1.2 监控课程大纲 二、Linux的那些独孤九剑级别的命令五、监控的现代时六、Zabbix监控架构6.1 生命周期6.2 Zabbix监控架构 七、Zabbix 6.x Centos7 生产快速实践指南7.1 主机规划1&#xff09; 推荐…

alphassl ocsp通配符证书

AlphaSSL是GlobalSign旗下的一个子品牌&#xff0c;GlobalSign是知名度较高的正规SSL证书颁发机构&#xff0c;应用范围广泛&#xff0c;比如电子商务、在线支付、网上银行等网站&#xff0c;还可以兼容几乎99%的主流浏览器。AlphaSSL旗下的DV基础型通配符SSL证书&#xff0c;不…

idm线程怎么设置 idm线程数怎么上不去 idm免安装

IDM&#xff08;Internet Download Manager&#xff09;是一款流行的下载管理软件&#xff0c;IDM采用高级的多线程下载技术&#xff0c;可以将下载文件分成多个部分同时下载&#xff0c;从而提高下载速度&#xff0c;它因高效的下载速度和丰富的功能而受到用户的喜爱。接下来&…

YOLO实验记录

2023年2月17日 配置与环境 CPU&#xff1a;Intel Xeon Gold 6133 CPU 2.50GHz x8 GPU&#xff1a;NVIDIA Tesla V100 32G显存 python 3.8 pytorch1.12.1 cuda11.4 cuDNN 8.2.1 训练配置信息 输入图像尺寸&#xff1a;1280x1024 预训练模型&#xff1a;无 训练epoch&#x…

下载Node.js及其他环境推荐nvm

文章目录 项目场景&#xff1a;下载Node.js环境配置配置环境变量 安装脚手架安装依赖安装淘宝镜像安装 cnpm&#xff08;我需要安装&#xff09;nvm 安装 Node.js &#xff08;推荐&#xff09; 项目场景&#xff1a; 提示&#xff1a;这里简述项目相关背景&#xff1a; 项目…

基于STM32的最小系统电路设计(STM32F103C8T6为例)

前言&#xff1a;本篇博客为嵌入式硬件领域的文章&#xff0c;对 STM32 的最小系统电路设计进行教学。本篇博客以嘉立创 EDA&#xff08;标准版&#xff09;进行绘制 STM32F103C8T6 的最小系统电路 PCB 板&#xff0c;STM32 的最小系统通常包括&#xff1a;微控制器、时钟电路、…

PHP医院安全(不良)事件报告系统源码 vue2+element支持11大类不良事件上报、审核处理、分析改进

PHP医院安全&#xff08;不良&#xff09;事件报告系统源码 vue2element支持11大类不良事件上报、审核处理、分析改进 医院安全&#xff08;不良&#xff09;事件管理系统采用无责的、自愿的填报不良事件方式&#xff0c;有效地减轻医护人员的思想压力&#xff0c;实现以事件为…

unity制作app(4)--PANEL套scroll view

这个东西之前做过&#xff0c;主要是唤醒界面可能失去控制权&#xff0c;一步一步做吧。 1.panel是一个容器&#xff0c;初始形状等价于屏幕&#xff0c;是可以按比例调整的&#xff01; 比如此时我想做“加入我们”里面的信息录入功能&#xff0c;panel的大小和位置如下所示…

【深入浅出MySQL】「性能调优」高性能查询优化MySQL的SQL语句编写

高性能查询优化MySQL的SQL语句编写准则这里写目录标题 总体优化大纲&#xff08;1&#xff09;优化查询性能&#xff1a;通过索引降低全表扫描频率优化方向案例介绍问题分析解决方案建立复合索引建立单独索引 &#xff08;2&#xff09;优化数据表与查询&#xff1a;合理使用非…

零基础学习数据库SQL语句之操作表中数据的DML语句

我们的数据库是根据页面原型和相关需求完成相关开发的 在表中添加数据 删除数据 修改数据 添加数据 页面模型 当点击保存的时候就能将表单数据提交到服务端 服务端将数据添加到数据库 我们要用insert语句 将数据添加到数据库中 代码演示 CREATE DATABASE Dduo; USE Dduo…

数据库(MySQL)—— 多表查询

数据库&#xff08;MySQL&#xff09;—— 多表查询 多表关系一对多多对多一对一多表查询概述数据准备查询形式笛卡尔积 分类连接查询内连接外连接左外连接右外连接 自连接联合查询 今天我们来进入MySQL中一个非常重要的部分&#xff1a;多表查询&#xff1a; 多表关系 多表关…

生产看板:最直观的车间管理方式之一,是马是马户牵出来溜溜。

可视化生产看板在组织工业生产中扮演着重要的角色&#xff0c;它可以提供实时的信息和可视化的数据&#xff0c;帮助团队和管理层更好地监控和管理生产过程。 以下是可视化生产看板在组织工业生产中的作用&#xff1a; 实时监控&#xff1a;可视化生产看板可以显示实时的生产数…

Spring - 10 ( 9000 字 Spring 入门级教程 )

一&#xff1a;MyBatis 进阶 动态 SQL 是 Mybatis 的强大特性之⼀&#xff0c;能够完成不同条件下不同的 sql 拼接。 1.1 if 标签 在注册用户的时候&#xff0c;可能会有这样⼀个问题&#xff0c;如下图所示&#xff1a; 注册分为两种字段&#xff1a;必填字段和非必填字段&…

原创字幕雨技术,二次剪辑混剪搬运短视频必备,轻松过原创

原创字幕雨素材教程&#xff0c;教你如何制作自己专属的字幕雨&#xff0c; 把素材运营到自己的二次剪辑&#xff0c;提升二创短视频的原创度&#xff0c; 帮助你做搬运或者短视频运营&#xff0c;轻松过原创。 课程目录&#xff1a; 1&#xff1a;什么是字幕雨 2&#xf…

FP16、BF16、INT8、INT4精度模型加载所需显存以及硬件适配的分析

大家好,我是herosunly。985院校硕士毕业,现担任算法研究员一职,热衷于机器学习算法研究与应用。曾获得阿里云天池比赛第一名,CCF比赛第二名,科大讯飞比赛第三名。拥有多项发明专利。对机器学习和深度学习拥有自己独到的见解。曾经辅导过若干个非计算机专业的学生进入到算法…