VB代码
请问有那位高手可以帮我解释下这些代码什么意思????Imports System.Data.SqlClient
Public Class Login
Inherits System.Windows.Forms.Form
Dim conn As System.Data.SqlClient.SqlConnection
Public Function GetUserInf() As Boolean
Try
If TextBox1.Text = "" Then
Me.Label3.Text = "用户名为空"
Else
If TextBox2.Text = "" Then
Me.Label3.Text = "密码为空"
Else
Dim sp As SqlParameter
Dim cmd As New SqlCommand("p_Admin", conn)
= CommandType.StoredProcedure
sp = New SqlParameter
sp.ParameterName = "@c_AdminName"
sp.SqlDbType = SqlDbType.VarChar
sp.Size = 20
sp.Value = TextBox1.Text
cmd.Parameters.Add(sp)
sp = New SqlParameter
sp.ParameterName = "@c_AdminPassWord"
sp.SqlDbType = SqlDbType.VarChar
sp.Size = 20
sp.Value = TextBox2.Text
cmd.Parameters.Add(sp)
Dim sc As String = CType(cmd.ExecuteScalar(), String)
cmd.Dispose()
If sc <> "0" Then
Return True
Else
Me.Label3.Text = "用户名或密码错误"
End If
End If
End If
Catch ex As Exception
Return False
End Try
Return False
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Login As New index
If GetUserInf() Then
Login.Show()
Me.Finalize() '隐藏原窗体
End If
End Sub
Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn = New System.Data.SqlClient.SqlConnection("workstation id=JOLIN;packet size=4096;integrated security=SSPI;data source='.';persist security info=False;initial catalog=WageManage")
conn.Open()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.Close()
End Sub
End Class