回 帖 发 新 帖 刷新版面

主题:如何制作一个ATM的登录界面

如何制作一个ATM的登录界面,使输入正确密码后转到主界面,原登录界面关闭。

回复列表 (共6个回复)

沙发

Dim User As String
    Dim Password As String
    Dim sqlstr As String

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       
        User = Me.ComboBox1.Text.Trim
        Password = Me.TextBox1.Text.Trim
        sqlstr = "SELECT * FROM pass WHERE username= " & _
        "'" & User & "' AND password='" & Password & "'"

        Dim objDataRow As DataRow
        Try

            objDataRow = GetDataFromDB(sqlstr).Tables(0).Rows(0)
        Catch
            MsgBox("密码和账号不符,请重试,并检查该账号是否存在。", _
            MsgBoxStyle.Information + MsgBoxStyle.OKOnly, "系统登录失败")
            Me.TextBox1.Text = ""
            Exit Sub
        End Try

        Dim main As New main
        Me.Hide()
        main.TextBox1.Text = Me.TextBox2.Text
        main.ShowDialog()
        Me.Close()
    End Sub

板凳

对不起,漏贴了一段类
Module Module1
    Public UserName As String
    Public pepdom As Integer
    Public objDataSet As DataSet
    '定义一个数据集对象
    Public objDataView As DataView
    '定义一个数据视图对象
    Public objDataAdpter As SqlDataAdapter
    '定义一个数据适配器对象
    Public objSqlConnection As SqlConnection = New _
    SqlConnection("server=localhost;database=dangan;integrated security=sspi")
    '定义一个数据连接对象,并初始化
    Public objCurrencyMannager As CurrencyManager
    '定义一个当前的绑定管理对象
    Public UserSqlstr As String = "SELECT * FROM pass"
    '定义了查询语句

    Public Function GetDataFromDB(ByVal sqlstr As String) As DataSet
        objDataSet = New DataSet
        objDataSet.Clear()
        '实例化一个数据集对象
        Try
            objSqlConnection.Open()
            '打开数据库连接
            objDataAdpter = New SqlDataAdapter(sqlstr, objSqlConnection)
            '将数据库的数据映射到数据适配器
            objDataAdpter.Fill(objDataSet)
            '填充数据集的数据
            objSqlConnection.Close()
            '关闭数据连接,这一点很重要
        Catch
            MsgBox("错误号:" & Err.Number & "错误描述:" & Err.Description)
        End Try
        Return objDataSet
        objDataSet = Nothing
    End Function
End Module

3 楼

我太爱你了,你都全把内容写下来了,但是我自己也做了一个登录功能,不知道和你的一不一样呢?不过我想都基本上差不多了.

4 楼

呵呵,瞧你说的,我都不好意思了[em4]
我是把我自己做的东西都粘下来给你了哦。楼主,加分吧,哈哈[em5]
估计都是差不多的,能用就行了歪,呵呵
中间有很多是你用不着的,就忽略不要看了……

5 楼

[font=Verdana]The host love you so much that he forgot to add bonus to u.[/font]

6 楼

[em5]

我来回复

您尚未登录,请登录后再回复。点此登录或注册