frmLogin.vb
上传用户:wj57717022
上传日期:2014-12-16
资源大小:4093k
文件大小:8k
源码类别:

医药行业

开发平台:

Visual Basic

  1. Public Class frmLogin
  2.     Inherits System.Windows.Forms.Form
  3. #Region " Windows 窗体设计器生成的代码 "
  4.     Public Sub New()
  5.         MyBase.New()
  6.         '该调用是 Windows 窗体设计器所必需的。
  7.         InitializeComponent()
  8.         '在 InitializeComponent() 调用之后添加任何初始化
  9.     End Sub
  10.     '窗体重写 dispose 以清理组件列表。
  11.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  12.         If disposing Then
  13.             If Not (components Is Nothing) Then
  14.                 components.Dispose()
  15.             End If
  16.         End If
  17.         MyBase.Dispose(disposing)
  18.     End Sub
  19.     'Windows 窗体设计器所必需的
  20.     Private components As System.ComponentModel.IContainer
  21.     '注意: 以下过程是 Windows 窗体设计器所必需的
  22.     '可以使用 Windows 窗体设计器修改此过程。
  23.     '不要使用代码编辑器修改它。
  24.     Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
  25.     Friend WithEvents Label1 As System.Windows.Forms.Label
  26.     Friend WithEvents Label2 As System.Windows.Forms.Label
  27.     Friend WithEvents txtPassword As System.Windows.Forms.TextBox
  28.     Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
  29.     Friend WithEvents cboUser As System.Windows.Forms.ComboBox
  30.     Friend WithEvents txtExit As System.Windows.Forms.Button
  31.     Friend WithEvents BtnCreate As System.Windows.Forms.Button
  32.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  33.         Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmLogin))
  34.         Me.PictureBox1 = New System.Windows.Forms.PictureBox
  35.         Me.Label1 = New System.Windows.Forms.Label
  36.         Me.Label2 = New System.Windows.Forms.Label
  37.         Me.txtPassword = New System.Windows.Forms.TextBox
  38.         Me.GroupBox1 = New System.Windows.Forms.GroupBox
  39.         Me.cboUser = New System.Windows.Forms.ComboBox
  40.         Me.txtExit = New System.Windows.Forms.Button
  41.         Me.BtnCreate = New System.Windows.Forms.Button
  42.         Me.SuspendLayout()
  43.         '
  44.         'PictureBox1
  45.         '
  46.         Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
  47.         Me.PictureBox1.Location = New System.Drawing.Point(40, 37)
  48.         Me.PictureBox1.Name = "PictureBox1"
  49.         Me.PictureBox1.Size = New System.Drawing.Size(80, 94)
  50.         Me.PictureBox1.TabIndex = 0
  51.         Me.PictureBox1.TabStop = False
  52.         '
  53.         'Label1
  54.         '
  55.         Me.Label1.AutoSize = True
  56.         Me.Label1.Location = New System.Drawing.Point(138, 37)
  57.         Me.Label1.Name = "Label1"
  58.         Me.Label1.Size = New System.Drawing.Size(54, 17)
  59.         Me.Label1.TabIndex = 1
  60.         Me.Label1.Text = "用户名:"
  61.         Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
  62.         '
  63.         'Label2
  64.         '
  65.         Me.Label2.AutoSize = True
  66.         Me.Label2.Location = New System.Drawing.Point(150, 62)
  67.         Me.Label2.Name = "Label2"
  68.         Me.Label2.Size = New System.Drawing.Size(42, 17)
  69.         Me.Label2.TabIndex = 3
  70.         Me.Label2.Text = "密码:"
  71.         Me.Label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
  72.         '
  73.         'txtPassword
  74.         '
  75.         Me.txtPassword.Location = New System.Drawing.Point(192, 62)
  76.         Me.txtPassword.Name = "txtPassword"
  77.         Me.txtPassword.PasswordChar = Microsoft.VisualBasic.ChrW(42)
  78.         Me.txtPassword.Size = New System.Drawing.Size(90, 21)
  79.         Me.txtPassword.TabIndex = 5
  80.         Me.txtPassword.Text = ""
  81.         Me.txtPassword.WordWrap = False
  82.         '
  83.         'GroupBox1
  84.         '
  85.         Me.GroupBox1.Location = New System.Drawing.Point(120, 93)
  86.         Me.GroupBox1.Name = "GroupBox1"
  87.         Me.GroupBox1.Size = New System.Drawing.Size(192, 7)
  88.         Me.GroupBox1.TabIndex = 8
  89.         Me.GroupBox1.TabStop = False
  90.         '
  91.         'cboUser
  92.         '
  93.         Me.cboUser.Location = New System.Drawing.Point(192, 37)
  94.         Me.cboUser.Name = "cboUser"
  95.         Me.cboUser.Size = New System.Drawing.Size(91, 20)
  96.         Me.cboUser.TabIndex = 9
  97.         '
  98.         'txtExit
  99.         '
  100.         Me.txtExit.DialogResult = System.Windows.Forms.DialogResult.Cancel
  101.         Me.txtExit.FlatStyle = System.Windows.Forms.FlatStyle.Flat
  102.         Me.txtExit.Image = CType(resources.GetObject("txtExit.Image"), System.Drawing.Image)
  103.         Me.txtExit.Location = New System.Drawing.Point(240, 106)
  104.         Me.txtExit.Name = "txtExit"
  105.         Me.txtExit.RightToLeft = System.Windows.Forms.RightToLeft.Yes
  106.         Me.txtExit.Size = New System.Drawing.Size(64, 25)
  107.         Me.txtExit.TabIndex = 7
  108.         '
  109.         'BtnCreate
  110.         '
  111.         Me.BtnCreate.FlatStyle = System.Windows.Forms.FlatStyle.Flat
  112.         Me.BtnCreate.Image = CType(resources.GetObject("BtnCreate.Image"), System.Drawing.Image)
  113.         Me.BtnCreate.Location = New System.Drawing.Point(168, 106)
  114.         Me.BtnCreate.Name = "BtnCreate"
  115.         Me.BtnCreate.Size = New System.Drawing.Size(64, 25)
  116.         Me.BtnCreate.TabIndex = 10
  117.         '
  118.         'frmLogin
  119.         '
  120.         Me.AcceptButton = Me.BtnCreate
  121.         Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
  122.         Me.CancelButton = Me.txtExit
  123.         Me.ClientSize = New System.Drawing.Size(334, 172)
  124.         Me.Controls.Add(Me.BtnCreate)
  125.         Me.Controls.Add(Me.cboUser)
  126.         Me.Controls.Add(Me.GroupBox1)
  127.         Me.Controls.Add(Me.txtExit)
  128.         Me.Controls.Add(Me.txtPassword)
  129.         Me.Controls.Add(Me.Label2)
  130.         Me.Controls.Add(Me.Label1)
  131.         Me.Controls.Add(Me.PictureBox1)
  132.         Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow
  133.         Me.Name = "frmLogin"
  134.         Me.Text = "系统登录"
  135.         Me.ResumeLayout(False)
  136.     End Sub
  137. #End Region
  138.     Public lswebpd As New jxcmanage
  139.     Public Shared struser As String
  140.     Public dslocalmm As DataSet = lswebpd.returndataset("select 操作员 from wz_mm", "wz_mm")
  141.     Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  142.         cboUser.DataSource = dslocalmm.Tables("wz_mm").DefaultView
  143.         cboUser.DisplayMember = "操作员"
  144.         If txtExit.Enabled = False Then
  145.             Dim frmmainer As FrmMainStart = New FrmMainStart
  146.             frmmainer.Hide()
  147.             'Me.Hide()
  148.         End If
  149.     End Sub
  150.     Private Function GetInstanceState(ByVal name As String) As Boolean
  151.         '获得frmMain窗体的子窗体的数量
  152.         Dim i As Integer = Me.MdiChildren.Length
  153.         '循环判断是否有名为name的子窗体实例
  154.         For i = 0 To Me.MdiChildren.Length - 1
  155.             If Me.MdiChildren(i).Name = name Then
  156.                 '存在名为name的子窗体,是子窗体获得焦点并返回True
  157.                 Me.MdiChildren(i).Focus()
  158.                 Return True
  159.             End If
  160.         Next
  161.         '不存在名为Name的子窗体False
  162.         Return False
  163.     End Function
  164.    
  165.     Private Sub BtnCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCreate.Click
  166.         struser = cboUser.Text
  167.         Dim strpassword As String = txtPassword.Text
  168.         If lswebpd.userinfo(struser, strpassword) = 0 Then
  169.             MessageBox.Show("没有这个用户或您输入的密码不正确!", "提示!", MessageBoxButtons.OK)
  170.         ElseIf lswebpd.userinfo(struser, strpassword) > 0 Then
  171.             If GetInstanceState("frmLogin") Then
  172.                 Exit Sub
  173.             End If
  174.             If txtExit.Enabled = False Then
  175.                 Me.Hide()
  176.             Else
  177.                 Dim frmmainer As FrmMainStart = New FrmMainStart
  178.                 frmmainer.Show()
  179.                 Me.Hide()
  180.             End If
  181.         End If
  182.     End Sub
  183.     Private Sub txtExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtExit.Click
  184.         Me.Close()
  185.     End Sub
  186.     
  187. End Class