⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 流通查询.vb

📁 图书管理系统 万千可以用于小规模的图书管理拉 用access作为数据库
💻 VB
📖 第 1 页 / 共 2 页
字号:
        '
        'TabPage2
        '
        Me.TabPage2.Controls.Add(Me.DataGrid2)
        Me.TabPage2.Location = New System.Drawing.Point(4, 21)
        Me.TabPage2.Name = "TabPage2"
        Me.TabPage2.Size = New System.Drawing.Size(400, 167)
        Me.TabPage2.TabIndex = 1
        Me.TabPage2.Text = "过刊与图书"
        Me.TabPage2.Visible = False
        '
        'DataGrid2
        '
        Me.DataGrid2.DataMember = ""
        Me.DataGrid2.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.DataGrid2.Location = New System.Drawing.Point(0, 0)
        Me.DataGrid2.Name = "DataGrid2"
        Me.DataGrid2.Size = New System.Drawing.Size(408, 168)
        Me.DataGrid2.TabIndex = 0
        '
        'PrintDocument2
        '
        '
        '流通查询
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(424, 249)
        Me.Controls.Add(Me.TabControl1)
        Me.Controls.Add(Me.GroupBox1)
        Me.MaximizeBox = False
        Me.Menu = Me.MainMenu1
        Me.Name = "流通查询"
        Me.Text = "流通查询"
        Me.GroupBox1.ResumeLayout(False)
        Me.TabControl1.ResumeLayout(False)
        Me.TabPage1.ResumeLayout(False)
        CType(Me.DataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.TabPage2.ResumeLayout(False)
        CType(Me.DataGrid2, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region
    Dim dsa1 As DataSet = New DataSet
    Dim dsa2 As DataSet = New DataSet
    Sub zidian()
        Dim nianjicomm As New OleDbCommand("select DISTINCT 年级 from 字典表 order by 年级 ", myconn) 'where 分类='" & 0 & "'
        Dim nianjibataad As OleDbDataAdapter = New OleDbDataAdapter(nianjicomm)
        Dim nianjidataset As DataSet = New DataSet
        nianjidataset.Clear()
        nianjibataad.Fill(nianjidataset)
        ComboBox1.DataSource = nianjidataset.Tables(0)
        ComboBox1.DisplayMember = "年级"
        myconn.Close()
    End Sub
    Private Sub 流通查询_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        zidian()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim sqlstr1, sqlstr2 As String
        If CheckBox1.Checked Then
            If ComboBox1.Text = "全部" Then
                sqlstr1 = "select * from 中外文现刊 where 挂失 = ""Yes""  order by 年级"
                sqlstr2 = "select * from 过刊图书 where  挂失 = ""Yes"" order by 年级 "
            Else
                sqlstr1 = "select * from 中外文现刊 where 挂失 like ""Yes"" and  年级 like '" & ComboBox1.Text & "'  order by 年级"
                sqlstr2 = "select * from 过刊图书 where  挂失 like ""Yes"" and  年级 like '" & ComboBox1.Text & "' order by 年级 "
            End If

        Else
            If ComboBox1.Text = "全部" Then
                sqlstr1 = "select * from 中外文现刊 where 挂失 = ""No""  order by 年级"
                sqlstr2 = "select * from 过刊图书 where  挂失 = ""No"" order by 年级 "
            Else
                sqlstr1 = "select * from 中外文现刊 where 挂失 like ""No"" and  年级 like '" & ComboBox1.Text & "'  order by 年级"
                sqlstr2 = "select * from 过刊图书 where  挂失 like ""No"" and  年级 like '" & ComboBox1.Text & "' order by 年级 "
            End If
        End If
        myconn.Open()
        Dim cmda1 As New OleDbCommand(sqlstr1, myconn)
        Dim da1 As OleDbDataAdapter = New OleDbDataAdapter(cmda1)
        dsa1.Clear()
        da1.Fill(dsa1)
        DataGrid1.DataSource = dsa1.Tables(0)
        myconn.Close()
        myconn.Open()
        Dim cmda2 As New OleDbCommand(sqlstr2, myconn)
        Dim da2 As OleDbDataAdapter = New OleDbDataAdapter(cmda2)
        dsa2.Clear()
        da2.Fill(dsa2)
        DataGrid2.DataSource = dsa2.Tables(0)
        myconn.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
            myconn.Open()
            Dim mycmda As New OleDbCommand("select * from 中外文现刊", myconn)
            Dim myda As OleDbDataAdapter = New OleDbDataAdapter(mycmda)
            Dim mydsa As DataSet = New DataSet
            mydsa.Clear()
            myda.Fill(mydsa)
            DataGrid1.DataSource = mydsa.Tables(0)
            myconn.Close()
            myconn.Open()
            Dim cmda2 As New OleDbCommand("select * from 过刊图书", myconn)
            Dim da2 As OleDbDataAdapter = New OleDbDataAdapter(cmda2)
            dsa2.Clear()
            da2.Fill(dsa2)
            DataGrid2.DataSource = dsa2.Tables(0)
            myconn.Close()
        Catch ex As Exception

        End Try
       
    End Sub

    Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click
        Dim excelApp1 As New Microsoft.Office.Interop.Excel.Application
        Dim excelBook1 As Microsoft.Office.Interop.Excel.Workbook = excelApp1.Workbooks.Add
        Dim excelWorksheet1 As Microsoft.Office.Interop.Excel.Worksheet = CType(excelBook1.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
        excelApp1.Visible = True
        With excelWorksheet1
            .Columns().ColumnWidth = 15
            .Range("A1").Value = "姓名"
            .Range("A1").Font.Bold = True
            .Range("B1").Value = "专业"
            .Range("B1").Font.Bold = True
            .Range("C1").Value = "年级"
            .Range("C1").Font.Bold = True
            .Range("D1").Value = "刊名"
            .Range("D1").Font.Bold = True
            .Range("E1").Value = "挂失"
            .Range("E1").Font.Bold = True

            Dim i As Integer = 2
            Dim dr As DataRow
            For Each dr In dsa1.Tables(0).Rows
                .Range("A" & i.ToString).Value = dr("姓名")
                .Range("B" & i.ToString).Value = dr("专业")
                .Range("C" & i.ToString).Value = dr("年级")
                .Range("D" & i.ToString).Value = dr("刊名")
                .Range("E" & i.ToString).Value = dr("挂失")

                i += 1
            Next
        End With
    End Sub


    Private Sub MenuItem7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem7.Click
        Dim excelApp1 As New Microsoft.Office.Interop.Excel.Application
        Dim excelBook1 As Microsoft.Office.Interop.Excel.Workbook = excelApp1.Workbooks.Add
        Dim excelWorksheet1 As Microsoft.Office.Interop.Excel.Worksheet = CType(excelBook1.Worksheets(1), Microsoft.Office.Interop.Excel.Worksheet)
        excelApp1.Visible = True
        With excelWorksheet1
            .Columns().ColumnWidth = 15
            .Range("A1").Value = "姓名"
            .Range("A1").Font.Bold = True
            .Range("B1").Value = "专业"
            .Range("B1").Font.Bold = True
            .Range("C1").Value = "年级"
            .Range("C1").Font.Bold = True
            .Range("D1").Value = "书刊名"
            .Range("D1").Font.Bold = True
            .Range("E1").Value = "出版社"
            .Range("E1").Font.Bold = True
            .Range("F1").Value = "挂失"
            .Range("F1").Font.Bold = True

            Dim i As Integer = 2
            Dim dr As DataRow
            For Each dr In dsa2.Tables(0).Rows
                .Range("A" & i.ToString).Value = dr("姓名")
                .Range("B" & i.ToString).Value = dr("专业")
                .Range("C" & i.ToString).Value = dr("年级")
                .Range("D" & i.ToString).Value = dr("书刊名")
                .Range("E" & i.ToString).Value = dr("出版社")
                .Range("F" & i.ToString).Value = dr("挂失")

                i += 1
            Next
        End With
    End Sub
    Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click
        PrintDocument1.Print()
    End Sub

    Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim myPaintArgs As New PaintEventArgs(e.Graphics, New Rectangle(New Point(0, 0), Me.Size))
        Me.InvokePaint(DataGrid1, myPaintArgs)
    End Sub

    Private Sub MenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem8.Click
        PrintDocument1.Print()
    End Sub

    Private Sub PrintDocument2_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument2.PrintPage
        Dim myPaintArgs As New PaintEventArgs(e.Graphics, New Rectangle(New Point(0, 0), Me.Size))
        Me.InvokePaint(DataGrid2, myPaintArgs)
    End Sub

    Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem6.Click
        Process.Start(Application.StartupPath & ("\4.txt"))
    End Sub

    Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
        Me.Close()
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -