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

📄 bookinfosimulation.vb

📁 vb.net写的图书管理系统,功能完备,能正常使用,可用于二次开发.
💻 VB
字号:
Public Class BookInfoSimulation
    Inherits System.Windows.Forms.Form

    Dim sql As String
#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    Public Sub New(ByVal sql As String)
        MyBase.New()
        Me.sql = sql
        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents pnlGragh As System.Windows.Forms.Panel
    Friend WithEvents btnClose As System.Windows.Forms.Button
    Friend WithEvents pnlColor As System.Windows.Forms.Panel
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.pnlGragh = New System.Windows.Forms.Panel
        Me.btnClose = New System.Windows.Forms.Button
        Me.pnlColor = New System.Windows.Forms.Panel
        Me.SuspendLayout()
        '
        'pnlGragh
        '
        Me.pnlGragh.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)
        Me.pnlGragh.Location = New System.Drawing.Point(10, 9)
        Me.pnlGragh.Name = "pnlGragh"
        Me.pnlGragh.Size = New System.Drawing.Size(427, 289)
        Me.pnlGragh.TabIndex = 0
        '
        'btnClose
        '
        Me.btnClose.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.btnClose.Location = New System.Drawing.Point(524, 308)
        Me.btnClose.Name = "btnClose"
        Me.btnClose.Size = New System.Drawing.Size(67, 28)
        Me.btnClose.TabIndex = 2
        Me.btnClose.Text = "退出"
        '
        'pnlColor
        '
        Me.pnlColor.Anchor = CType(((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
        Me.pnlColor.Location = New System.Drawing.Point(437, 9)
        Me.pnlColor.Name = "pnlColor"
        Me.pnlColor.Size = New System.Drawing.Size(154, 289)
        Me.pnlColor.TabIndex = 3
        '
        'BookInfoSimulation
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(600, 341)
        Me.Controls.Add(Me.pnlColor)
        Me.Controls.Add(Me.btnClose)
        Me.Controls.Add(Me.pnlGragh)
        Me.Name = "BookInfoSimulation"
        Me.Text = "书籍信息分析"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Dim g As Graphics
    Dim pen As New pen(Color.Red)
    Dim brush As New SolidBrush(Color.Black)

    Dim arrCount As ArrayList
    Dim arrTypename As ArrayList
    Dim arrArc As ArrayList
    Dim arrBrush As ArrayList

    Dim hasLength As Boolean = False
    Dim length As Integer = 50

    '要分析的数据
    Dim detSim As DataSet

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

        g = pnlGragh.CreateGraphics()
        pnlGragh.Refresh()
        getSimDate()
        Dim i As Integer
        Dim count As Single
        Dim arc As Single
        For i = 0 To arrCount.Count - 1
            arc = arrArc(i)
            g.FillPie(arrBrush(i), 0, 0, pnlGragh.Width, pnlGragh.Height, count, arc)
            count = count + arc
            Debug.WriteLine("count=" & count)

        Next

        Dim height As Single
        g = pnlColor.CreateGraphics()
        For i = 0 To arrCount.Count - 1
            height = i * pnlColor.Height / (arrCount.Count * 2)
            g.DrawString(arrTypename(i), New Font("Arial", 10, FontStyle.Regular), brush, 10, height)
            Debug.WriteLine("DrawString=" & count)
            g.FillRectangle(arrBrush(i), 100, height, 40, 20)
        Next
 


    End Sub

    Sub getSimDate()
        arrCount = New ArrayList
        arrArc = New ArrayList
        arrBrush = New ArrayList
        arrTypename = New ArrayList
        Dim i As Integer
        Dim strSQL As String
        Dim mydet As DataSet
        Dim mydetType As DataSet
        Dim myHT As New Hashtable

        strSQL = "Select  count(*) as num ,type  from  BookInfo " & sql & " group by type"
        mydet = DBManager.executeSelectQuery(strSQL, "BookInfo")

        strSQL = "Select  CODE,NAME  from  BookType "
        mydetType = DBManager.executeSelectQuery(strSQL, "BookType")

        '将书种类和种类名称放到HashTable中
        For i = 0 To mydetType.Tables(0).Rows.Count - 1
            With mydetType.Tables(0).Rows(i)
                myHT.Add(.Item("CODE"), .Item("NAME"))
            End With
        Next

        '将查询结果付给变量
        For i = 0 To mydet.Tables(0).Rows.Count - 1
            With mydet.Tables(0).Rows(i)
                arrCount.Add(.Item("num"))
                arrTypename.Add(myHT.Item(.Item("type")))

            End With
        Next


        Dim count As Integer

        For i = 0 To arrCount.Count - 1
            count = count + arrCount(i)
        Next
        For i = 0 To arrCount.Count - 1
            arrArc.Add(arrCount(i) * 360 / count)
            Debug.WriteLine("Arc=" & arrArc(i))
        Next

        Dim T As Integer

        For i = 0 To arrCount.Count - 1
            T = i * 255 / arrCount.Count
            arrBrush.Add(New SolidBrush(Color.FromArgb(255, T, T, T)))
        Next
    End Sub

    Private Sub btnColor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        If hasLength Then
            hasLength = Not hasLength
            Me.Height = Me.Height - length
        Else
            hasLength = Not hasLength
            Me.Height = Me.Height + length
        End If
    End Sub

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

End Class


⌨️ 快捷键说明

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