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

📄 login.vb

📁 大型数据库系统程序球员转会系统解决方案
💻 VB
字号:
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO


Public Class login
    Inherits System.Windows.Forms.Form
    Dim myconnection As SqlConnection = New _
    SqlConnection("server=(local);database=footballplayer_change;" & _
   "uid=sa;pwd=sa;")
    Dim myadapter As SqlDataAdapter = New SqlDataAdapter("select * from users", myconnection)
    Dim myds As DataSet
    Dim mydv As DataView
    Dim mycurrencymanager As CurrencyManager

    Public Shared tempname As String
    Public Shared tempid As Integer
    Public Shared temp_username As String
    Public Shared temppwd As String
    Public Shared tempcid As String



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

    Public Sub New()
        MyBase.New()

        '该调用是 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 Button1 As System.Windows.Forms.Button
    Friend WithEvents names As System.Windows.Forms.TextBox
    Friend WithEvents pwds As System.Windows.Forms.TextBox
    Friend WithEvents 用户名 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    Friend WithEvents lbl_time As System.Windows.Forms.Label
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox
    Friend WithEvents PictureBox3 As System.Windows.Forms.PictureBox
    Friend WithEvents PictureBox4 As System.Windows.Forms.PictureBox
    Friend WithEvents PictureBox5 As System.Windows.Forms.PictureBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(login))
        Me.names = New System.Windows.Forms.TextBox
        Me.pwds = New System.Windows.Forms.TextBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.用户名 = New System.Windows.Forms.Label
        Me.Label2 = New System.Windows.Forms.Label
        Me.lbl_time = New System.Windows.Forms.Label
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.PictureBox2 = New System.Windows.Forms.PictureBox
        Me.PictureBox3 = New System.Windows.Forms.PictureBox
        Me.PictureBox4 = New System.Windows.Forms.PictureBox
        Me.PictureBox5 = New System.Windows.Forms.PictureBox
        Me.SuspendLayout()
        '
        'names
        '
        Me.names.Location = New System.Drawing.Point(248, 120)
        Me.names.Name = "names"
        Me.names.Size = New System.Drawing.Size(150, 21)
        Me.names.TabIndex = 0
        Me.names.Text = ""
        '
        'pwds
        '
        Me.pwds.Location = New System.Drawing.Point(248, 192)
        Me.pwds.Name = "pwds"
        Me.pwds.PasswordChar = Microsoft.VisualBasic.ChrW(42)
        Me.pwds.Size = New System.Drawing.Size(150, 21)
        Me.pwds.TabIndex = 1
        Me.pwds.Text = "123"
        '
        'Button1
        '
        Me.Button1.BackColor = System.Drawing.Color.Transparent
        Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Popup
        Me.Button1.Font = New System.Drawing.Font("宋体", 10.5!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Button1.Image = CType(resources.GetObject("Button1.Image"), System.Drawing.Image)
        Me.Button1.Location = New System.Drawing.Point(24, 256)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(96, 32)
        Me.Button1.TabIndex = 2
        '
        '用户名
        '
        Me.用户名.BackColor = System.Drawing.Color.Transparent
        Me.用户名.Font = New System.Drawing.Font("宋体", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.用户名.Location = New System.Drawing.Point(80, 112)
        Me.用户名.Name = "用户名"
        Me.用户名.Size = New System.Drawing.Size(90, 36)
        Me.用户名.TabIndex = 3
        Me.用户名.Text = "用户名"
        Me.用户名.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'Label2
        '
        Me.Label2.BackColor = System.Drawing.Color.Transparent
        Me.Label2.Font = New System.Drawing.Font("宋体", 14.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.Label2.Location = New System.Drawing.Point(80, 184)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(104, 24)
        Me.Label2.TabIndex = 4
        Me.Label2.Text = "密码"
        Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
        '
        'lbl_time
        '
        Me.lbl_time.Location = New System.Drawing.Point(408, 288)
        Me.lbl_time.Name = "lbl_time"
        Me.lbl_time.Size = New System.Drawing.Size(144, 32)
        Me.lbl_time.TabIndex = 5
        '
        'Timer1
        '
        '
        'PictureBox1
        '
        Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
        Me.PictureBox1.Location = New System.Drawing.Point(328, 256)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(40, 72)
        Me.PictureBox1.TabIndex = 7
        Me.PictureBox1.TabStop = False
        '
        'PictureBox2
        '
        Me.PictureBox2.Image = CType(resources.GetObject("PictureBox2.Image"), System.Drawing.Image)
        Me.PictureBox2.Location = New System.Drawing.Point(200, 120)
        Me.PictureBox2.Name = "PictureBox2"
        Me.PictureBox2.Size = New System.Drawing.Size(32, 24)
        Me.PictureBox2.TabIndex = 8
        Me.PictureBox2.TabStop = False
        '
        'PictureBox3
        '
        Me.PictureBox3.BackColor = System.Drawing.Color.Transparent
        Me.PictureBox3.Image = CType(resources.GetObject("PictureBox3.Image"), System.Drawing.Image)
        Me.PictureBox3.Location = New System.Drawing.Point(200, 184)
        Me.PictureBox3.Name = "PictureBox3"
        Me.PictureBox3.Size = New System.Drawing.Size(32, 24)
        Me.PictureBox3.TabIndex = 9
        Me.PictureBox3.TabStop = False
        '
        'PictureBox4
        '
        Me.PictureBox4.BackgroundImage = CType(resources.GetObject("PictureBox4.BackgroundImage"), System.Drawing.Image)
        Me.PictureBox4.Location = New System.Drawing.Point(472, 8)
        Me.PictureBox4.Name = "PictureBox4"
        Me.PictureBox4.Size = New System.Drawing.Size(80, 120)
        Me.PictureBox4.TabIndex = 10
        Me.PictureBox4.TabStop = False
        '
        'PictureBox5
        '
        Me.PictureBox5.BackgroundImage = CType(resources.GetObject("PictureBox5.BackgroundImage"), System.Drawing.Image)
        Me.PictureBox5.Location = New System.Drawing.Point(8, 16)
        Me.PictureBox5.Name = "PictureBox5"
        Me.PictureBox5.Size = New System.Drawing.Size(64, 88)
        Me.PictureBox5.TabIndex = 11
        Me.PictureBox5.TabStop = False
        '
        'login
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.BackColor = System.Drawing.SystemColors.ActiveCaptionText
        Me.ClientSize = New System.Drawing.Size(574, 332)
        Me.Controls.Add(Me.PictureBox5)
        Me.Controls.Add(Me.PictureBox4)
        Me.Controls.Add(Me.PictureBox3)
        Me.Controls.Add(Me.PictureBox2)
        Me.Controls.Add(Me.PictureBox1)
        Me.Controls.Add(Me.lbl_time)
        Me.Controls.Add(Me.Label2)
        Me.Controls.Add(Me.用户名)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.pwds)
        Me.Controls.Add(Me.names)
        Me.Font = New System.Drawing.Font("隶书", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte))
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
        Me.Name = "login"
        Me.Text = "欢迎进入球员转会系统"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        filldatasetandview()
        bindfields()
        lbl_time.Text = Date.Now
        Timer1.Interval = 1000
        Timer1.Start()
        'showposition()
    End Sub
    Private Sub filldatasetandview()
        myds = New DataSet()
        Try
            myadapter.Fill(myds, "user")
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
        mydv = New DataView(myds.Tables("user"))
        mycurrencymanager = CType(Me.BindingContext(mydv), CurrencyManager)
    End Sub
    Private Sub bindfields()
        names.DataBindings.Clear()
        names.DataBindings.Add("text", mydv, "username")
 
    End Sub
    Private Sub showposition()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim intposition As Integer
        Dim vals(1) As Object
        Dim level As Integer
        tempname = names.Text
        temp_username = tempname
        temppwd = pwds.Text

        mydv.Sort = "username,pwd"
        vals(0) = tempname
        vals(1) = temppwd
        intposition = mydv.Find(vals)

        Dim myCommand As SqlCommand = New SqlCommand()
        myCommand.Connection = myconnection
        myCommand.CommandText = "p_cid"
        myCommand.CommandType = CommandType.StoredProcedure
        myCommand.Parameters.Add("@username", names.Text)
        myadapter.SelectCommand = myCommand
        myconnection.Open()
        myadapter.SelectCommand.ExecuteNonQuery()
        myconnection.Close()
        Dim mydataset As DataSet = New DataSet()
        myadapter.Fill(mydataset, "club")
        Dim newview As DataView = New DataView(mydataset.Tables("club"))
        Dim count As Integer = newview.Count
        MsgBox(tempcid)


        If intposition = -1 Then
            MsgBox("信息错误,请重新输入")
        Else
            level = myds.Tables("user").Rows(intposition).Item("level")
            Dim user As String
            user = myds.Tables("user").Rows(intposition).Item("username")
            MsgBox(user)
            MsgBox(level)
            Select Case level
                Case "1"
                    If count = 0 Then
                        MsgBox("该用户没有注册俱乐部")
                    Else
                        tempcid = mydataset.Tables("club").Rows(0).Item("cid")

                        Me.Visible = False
                        Dim main As main = New main()
                        main.Show()
                    End If
                Case "2"
                    Me.Visible = False
                    Dim apply_manage As apply_manage = New apply_manage()
                    apply_manage.Show()
                Case "3"
                    ' Dim sa_club As sa_club = New sa_club()
                    ' sa_club.Show()
                    Dim modify_player As New modify_player()
                    modify_player.Show()
            End Select
        End If
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        lbl_time.Text = Date.Now
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Dispose()
    End Sub
End Class

⌨️ 快捷键说明

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