frmLogin.vb
上传用户:wj57717022
上传日期:2014-12-16
资源大小:4093k
文件大小:8k
- Public Class frmLogin
- Inherits System.Windows.Forms.Form
- #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 PictureBox1 As System.Windows.Forms.PictureBox
- Friend WithEvents Label1 As System.Windows.Forms.Label
- Friend WithEvents Label2 As System.Windows.Forms.Label
- Friend WithEvents txtPassword As System.Windows.Forms.TextBox
- Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
- Friend WithEvents cboUser As System.Windows.Forms.ComboBox
- Friend WithEvents txtExit As System.Windows.Forms.Button
- Friend WithEvents BtnCreate As System.Windows.Forms.Button
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmLogin))
- Me.PictureBox1 = New System.Windows.Forms.PictureBox
- Me.Label1 = New System.Windows.Forms.Label
- Me.Label2 = New System.Windows.Forms.Label
- Me.txtPassword = New System.Windows.Forms.TextBox
- Me.GroupBox1 = New System.Windows.Forms.GroupBox
- Me.cboUser = New System.Windows.Forms.ComboBox
- Me.txtExit = New System.Windows.Forms.Button
- Me.BtnCreate = New System.Windows.Forms.Button
- Me.SuspendLayout()
- '
- 'PictureBox1
- '
- Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
- Me.PictureBox1.Location = New System.Drawing.Point(40, 37)
- Me.PictureBox1.Name = "PictureBox1"
- Me.PictureBox1.Size = New System.Drawing.Size(80, 94)
- Me.PictureBox1.TabIndex = 0
- Me.PictureBox1.TabStop = False
- '
- 'Label1
- '
- Me.Label1.AutoSize = True
- Me.Label1.Location = New System.Drawing.Point(138, 37)
- Me.Label1.Name = "Label1"
- Me.Label1.Size = New System.Drawing.Size(54, 17)
- Me.Label1.TabIndex = 1
- Me.Label1.Text = "用户名:"
- Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
- '
- 'Label2
- '
- Me.Label2.AutoSize = True
- Me.Label2.Location = New System.Drawing.Point(150, 62)
- Me.Label2.Name = "Label2"
- Me.Label2.Size = New System.Drawing.Size(42, 17)
- Me.Label2.TabIndex = 3
- Me.Label2.Text = "密码:"
- Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
- '
- 'txtPassword
- '
- Me.txtPassword.Location = New System.Drawing.Point(192, 62)
- Me.txtPassword.Name = "txtPassword"
- Me.txtPassword.PasswordChar = Microsoft.VisualBasic.ChrW(42)
- Me.txtPassword.Size = New System.Drawing.Size(90, 21)
- Me.txtPassword.TabIndex = 5
- Me.txtPassword.Text = ""
- Me.txtPassword.WordWrap = False
- '
- 'GroupBox1
- '
- Me.GroupBox1.Location = New System.Drawing.Point(120, 93)
- Me.GroupBox1.Name = "GroupBox1"
- Me.GroupBox1.Size = New System.Drawing.Size(192, 7)
- Me.GroupBox1.TabIndex = 8
- Me.GroupBox1.TabStop = False
- '
- 'cboUser
- '
- Me.cboUser.Location = New System.Drawing.Point(192, 37)
- Me.cboUser.Name = "cboUser"
- Me.cboUser.Size = New System.Drawing.Size(91, 20)
- Me.cboUser.TabIndex = 9
- '
- 'txtExit
- '
- Me.txtExit.DialogResult = System.Windows.Forms.DialogResult.Cancel
- Me.txtExit.FlatStyle = System.Windows.Forms.FlatStyle.Flat
- Me.txtExit.Image = CType(resources.GetObject("txtExit.Image"), System.Drawing.Image)
- Me.txtExit.Location = New System.Drawing.Point(240, 106)
- Me.txtExit.Name = "txtExit"
- Me.txtExit.RightToLeft = System.Windows.Forms.RightToLeft.Yes
- Me.txtExit.Size = New System.Drawing.Size(64, 25)
- Me.txtExit.TabIndex = 7
- '
- 'BtnCreate
- '
- Me.BtnCreate.FlatStyle = System.Windows.Forms.FlatStyle.Flat
- Me.BtnCreate.Image = CType(resources.GetObject("BtnCreate.Image"), System.Drawing.Image)
- Me.BtnCreate.Location = New System.Drawing.Point(168, 106)
- Me.BtnCreate.Name = "BtnCreate"
- Me.BtnCreate.Size = New System.Drawing.Size(64, 25)
- Me.BtnCreate.TabIndex = 10
- '
- 'frmLogin
- '
- Me.AcceptButton = Me.BtnCreate
- Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
- Me.CancelButton = Me.txtExit
- Me.ClientSize = New System.Drawing.Size(334, 172)
- Me.Controls.Add(Me.BtnCreate)
- Me.Controls.Add(Me.cboUser)
- Me.Controls.Add(Me.GroupBox1)
- Me.Controls.Add(Me.txtExit)
- Me.Controls.Add(Me.txtPassword)
- Me.Controls.Add(Me.Label2)
- Me.Controls.Add(Me.Label1)
- Me.Controls.Add(Me.PictureBox1)
- Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
- Me.Name = "frmLogin"
- Me.Text = "系统登录"
- Me.ResumeLayout(False)
- End Sub
- #End Region
- Public lswebpd As New jxcmanage
- Public Shared struser As String
- Public dslocalmm As DataSet = lswebpd.returndataset("select 操作员 from wz_mm", "wz_mm")
- Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- cboUser.DataSource = dslocalmm.Tables("wz_mm").DefaultView
- cboUser.DisplayMember = "操作员"
- If txtExit.Enabled = False Then
- Dim frmmainer As FrmMainStart = New FrmMainStart
- frmmainer.Hide()
- 'Me.Hide()
- End If
- End Sub
- Private Function GetInstanceState(ByVal name As String) As Boolean
- '获得frmMain窗体的子窗体的数量
- Dim i As Integer = Me.MdiChildren.Length
- '循环判断是否有名为name的子窗体实例
- For i = 0 To Me.MdiChildren.Length - 1
- If Me.MdiChildren(i).Name = name Then
- '存在名为name的子窗体,是子窗体获得焦点并返回True
- Me.MdiChildren(i).Focus()
- Return True
- End If
- Next
- '不存在名为Name的子窗体False
- Return False
- End Function
-
- Private Sub BtnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCreate.Click
- struser = cboUser.Text
- Dim strpassword As String = txtPassword.Text
- If lswebpd.userinfo(struser, strpassword) = 0 Then
- MessageBox.Show("没有这个用户或您输入的密码不正确!", "提示!", MessageBoxButtons.OK)
- ElseIf lswebpd.userinfo(struser, strpassword) > 0 Then
- If GetInstanceState("frmLogin") Then
- Exit Sub
- End If
- If txtExit.Enabled = False Then
- Me.Hide()
- Else
- Dim frmmainer As FrmMainStart = New FrmMainStart
- frmmainer.Show()
- Me.Hide()
- End If
- End If
- End Sub
- Private Sub txtExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtExit.Click
- Me.Close()
- End Sub
-
- End Class