frmPerson.vb
上传用户:wj57717022
上传日期:2014-12-16
资源大小:4093k
文件大小:19k
- Public Class frmPerson
- 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 StatusBar1 As System.Windows.Forms.StatusBar
- Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
- Friend WithEvents Label1 As System.Windows.Forms.Label
- Friend WithEvents txtNumber As System.Windows.Forms.TextBox
- Friend WithEvents Label2 As System.Windows.Forms.Label
- Friend WithEvents txtName As System.Windows.Forms.TextBox
- Friend WithEvents Label3 As System.Windows.Forms.Label
- Friend WithEvents txtPassword As System.Windows.Forms.TextBox
- Friend WithEvents tbrSave As System.Windows.Forms.ToolBarButton
- Friend WithEvents tbrmodify As System.Windows.Forms.ToolBarButton
- Friend WithEvents tbrdelete As System.Windows.Forms.ToolBarButton
- Friend WithEvents tbrSpr As System.Windows.Forms.ToolBarButton
- Friend WithEvents tbrExit As System.Windows.Forms.ToolBarButton
- Friend WithEvents MsdnTextboxValidator1 As MSDNTextboxValidator.MSDNTextboxValidator
- Friend WithEvents ErrorProvider1 As System.Windows.Forms.ErrorProvider
- Friend WithEvents tbrAdd As System.Windows.Forms.ToolBarButton
- Friend WithEvents tbrps As System.Windows.Forms.ToolBar
- Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
- Friend WithEvents dgperson As System.Windows.Forms.DataGrid
- Friend WithEvents ImageList2 As System.Windows.Forms.ImageList
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.components = New System.ComponentModel.Container
- Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmPerson))
- Me.tbrps = New System.Windows.Forms.ToolBar
- Me.tbrAdd = New System.Windows.Forms.ToolBarButton
- Me.tbrSave = New System.Windows.Forms.ToolBarButton
- Me.tbrmodify = New System.Windows.Forms.ToolBarButton
- Me.tbrdelete = New System.Windows.Forms.ToolBarButton
- Me.tbrSpr = New System.Windows.Forms.ToolBarButton
- Me.tbrExit = New System.Windows.Forms.ToolBarButton
- Me.ImageList2 = New System.Windows.Forms.ImageList(Me.components)
- Me.StatusBar1 = New System.Windows.Forms.StatusBar
- Me.GroupBox1 = New System.Windows.Forms.GroupBox
- Me.txtPassword = New System.Windows.Forms.TextBox
- Me.Label3 = New System.Windows.Forms.Label
- Me.txtName = New System.Windows.Forms.TextBox
- Me.Label2 = New System.Windows.Forms.Label
- Me.txtNumber = New System.Windows.Forms.TextBox
- Me.Label1 = New System.Windows.Forms.Label
- Me.MsdnTextboxValidator1 = New MSDNTextboxValidator.MSDNTextboxValidator(Me.components)
- Me.ErrorProvider1 = New System.Windows.Forms.ErrorProvider
- Me.GroupBox2 = New System.Windows.Forms.GroupBox
- Me.dgperson = New System.Windows.Forms.DataGrid
- Me.GroupBox1.SuspendLayout()
- Me.GroupBox2.SuspendLayout()
- CType(Me.dgperson, System.ComponentModel.ISupportInitialize).BeginInit()
- Me.SuspendLayout()
- '
- 'tbrps
- '
- Me.tbrps.Appearance = System.Windows.Forms.ToolBarAppearance.Flat
- Me.tbrps.Buttons.AddRange(New System.Windows.Forms.ToolBarButton() {Me.tbrAdd, Me.tbrSave, Me.tbrmodify, Me.tbrdelete, Me.tbrSpr, Me.tbrExit})
- Me.tbrps.DropDownArrows = True
- Me.tbrps.ImageList = Me.ImageList2
- Me.tbrps.Location = New System.Drawing.Point(0, 0)
- Me.tbrps.Name = "tbrps"
- Me.tbrps.ShowToolTips = True
- Me.tbrps.Size = New System.Drawing.Size(748, 44)
- Me.tbrps.TabIndex = 0
- '
- 'tbrAdd
- '
- Me.tbrAdd.ImageIndex = 7
- Me.tbrAdd.Text = "添加"
- '
- 'tbrSave
- '
- Me.tbrSave.ImageIndex = 4
- Me.tbrSave.Text = "保存"
- '
- 'tbrmodify
- '
- Me.tbrmodify.ImageIndex = 5
- Me.tbrmodify.Text = "修改"
- '
- 'tbrdelete
- '
- Me.tbrdelete.ImageIndex = 6
- Me.tbrdelete.Text = "删除"
- '
- 'tbrSpr
- '
- Me.tbrSpr.Style = System.Windows.Forms.ToolBarButtonStyle.Separator
- '
- 'tbrExit
- '
- Me.tbrExit.ImageIndex = 11
- Me.tbrExit.Text = "退出"
- '
- 'ImageList2
- '
- Me.ImageList2.ImageSize = New System.Drawing.Size(16, 16)
- Me.ImageList2.ImageStream = CType(resources.GetObject("ImageList2.ImageStream"), System.Windows.Forms.ImageListStreamer)
- Me.ImageList2.TransparentColor = System.Drawing.Color.Transparent
- '
- 'StatusBar1
- '
- Me.StatusBar1.Location = New System.Drawing.Point(0, 437)
- Me.StatusBar1.Name = "StatusBar1"
- Me.StatusBar1.Size = New System.Drawing.Size(748, 23)
- Me.StatusBar1.TabIndex = 1
- '
- 'GroupBox1
- '
- Me.GroupBox1.Controls.Add(Me.txtPassword)
- Me.GroupBox1.Controls.Add(Me.Label3)
- Me.GroupBox1.Controls.Add(Me.txtName)
- Me.GroupBox1.Controls.Add(Me.Label2)
- Me.GroupBox1.Controls.Add(Me.txtNumber)
- Me.GroupBox1.Controls.Add(Me.Label1)
- Me.GroupBox1.Dock = System.Windows.Forms.DockStyle.Left
- Me.GroupBox1.Location = New System.Drawing.Point(0, 44)
- Me.GroupBox1.Name = "GroupBox1"
- Me.GroupBox1.Size = New System.Drawing.Size(256, 393)
- Me.GroupBox1.TabIndex = 2
- Me.GroupBox1.TabStop = False
- Me.GroupBox1.Text = "人员信息"
- '
- 'txtPassword
- '
- Me.MsdnTextboxValidator1.SetCustomValidationEnabled(Me.txtPassword, True)
- Me.MsdnTextboxValidator1.SetDataType(Me.txtPassword, MSDNTextboxValidator.DataTypeConstants.StringType)
- Me.MsdnTextboxValidator1.SetDisplayName(Me.txtPassword, "")
- Me.txtPassword.Location = New System.Drawing.Point(72, 112)
- Me.MsdnTextboxValidator1.SetMaxValue(Me.txtPassword, "")
- Me.MsdnTextboxValidator1.SetMinValue(Me.txtPassword, "")
- Me.txtPassword.Name = "txtPassword"
- Me.txtPassword.PasswordChar = Microsoft.VisualBasic.ChrW(42)
- Me.MsdnTextboxValidator1.SetRegularExpression(Me.txtPassword, "")
- Me.MsdnTextboxValidator1.SetRequired(Me.txtPassword, False)
- Me.txtPassword.Size = New System.Drawing.Size(176, 25)
- Me.txtPassword.TabIndex = 5
- Me.txtPassword.Text = ""
- '
- 'Label3
- '
- Me.Label3.AutoSize = True
- Me.Label3.Location = New System.Drawing.Point(8, 112)
- Me.Label3.Name = "Label3"
- Me.Label3.Size = New System.Drawing.Size(52, 21)
- Me.Label3.TabIndex = 4
- Me.Label3.Text = "密码:"
- '
- 'txtName
- '
- Me.MsdnTextboxValidator1.SetCustomValidationEnabled(Me.txtName, True)
- Me.MsdnTextboxValidator1.SetDataType(Me.txtName, MSDNTextboxValidator.DataTypeConstants.StringType)
- Me.MsdnTextboxValidator1.SetDisplayName(Me.txtName, "")
- Me.txtName.Location = New System.Drawing.Point(72, 72)
- Me.MsdnTextboxValidator1.SetMaxValue(Me.txtName, "")
- Me.MsdnTextboxValidator1.SetMinValue(Me.txtName, "")
- Me.txtName.Name = "txtName"
- Me.MsdnTextboxValidator1.SetRegularExpression(Me.txtName, "")
- Me.MsdnTextboxValidator1.SetRequired(Me.txtName, False)
- Me.txtName.Size = New System.Drawing.Size(176, 25)
- Me.txtName.TabIndex = 3
- Me.txtName.Text = ""
- '
- 'Label2
- '
- Me.Label2.AutoSize = True
- Me.Label2.Location = New System.Drawing.Point(8, 72)
- Me.Label2.Name = "Label2"
- Me.Label2.Size = New System.Drawing.Size(52, 21)
- Me.Label2.TabIndex = 2
- Me.Label2.Text = "姓名:"
- '
- 'txtNumber
- '
- Me.MsdnTextboxValidator1.SetCustomValidationEnabled(Me.txtNumber, True)
- Me.MsdnTextboxValidator1.SetDataType(Me.txtNumber, MSDNTextboxValidator.DataTypeConstants.Int64Type)
- Me.MsdnTextboxValidator1.SetDisplayName(Me.txtNumber, "")
- Me.txtNumber.Location = New System.Drawing.Point(72, 32)
- Me.MsdnTextboxValidator1.SetMaxValue(Me.txtNumber, "")
- Me.MsdnTextboxValidator1.SetMinValue(Me.txtNumber, "")
- Me.txtNumber.Name = "txtNumber"
- Me.MsdnTextboxValidator1.SetRegularExpression(Me.txtNumber, "")
- Me.MsdnTextboxValidator1.SetRequired(Me.txtNumber, False)
- Me.txtNumber.Size = New System.Drawing.Size(176, 25)
- Me.txtNumber.TabIndex = 1
- Me.txtNumber.Text = ""
- '
- 'Label1
- '
- Me.Label1.AutoSize = True
- Me.Label1.Location = New System.Drawing.Point(8, 32)
- Me.Label1.Name = "Label1"
- Me.Label1.Size = New System.Drawing.Size(52, 21)
- Me.Label1.TabIndex = 0
- Me.Label1.Text = "编号:"
- '
- 'MsdnTextboxValidator1
- '
- Me.MsdnTextboxValidator1.DisplayControl = Nothing
- Me.MsdnTextboxValidator1.ErrorProvider = Nothing
- Me.MsdnTextboxValidator1.InvalidBackColor = System.Drawing.Color.Empty
- Me.MsdnTextboxValidator1.TooltipProvider = Nothing
- '
- 'ErrorProvider1
- '
- Me.ErrorProvider1.ContainerControl = Me
- '
- 'GroupBox2
- '
- Me.GroupBox2.Controls.Add(Me.dgperson)
- Me.GroupBox2.Dock = System.Windows.Forms.DockStyle.Fill
- Me.GroupBox2.Location = New System.Drawing.Point(256, 44)
- Me.GroupBox2.Name = "GroupBox2"
- Me.GroupBox2.Size = New System.Drawing.Size(492, 393)
- Me.GroupBox2.TabIndex = 3
- Me.GroupBox2.TabStop = False
- '
- 'dgperson
- '
- Me.dgperson.DataMember = ""
- Me.dgperson.Dock = System.Windows.Forms.DockStyle.Fill
- Me.dgperson.HeaderForeColor = System.Drawing.SystemColors.ControlText
- Me.dgperson.Location = New System.Drawing.Point(3, 21)
- Me.dgperson.Name = "dgperson"
- Me.dgperson.Size = New System.Drawing.Size(486, 369)
- Me.dgperson.TabIndex = 0
- '
- 'frmPerson
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(8, 18)
- Me.ClientSize = New System.Drawing.Size(748, 460)
- Me.Controls.Add(Me.GroupBox2)
- Me.Controls.Add(Me.GroupBox1)
- Me.Controls.Add(Me.StatusBar1)
- Me.Controls.Add(Me.tbrps)
- Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
- Me.Name = "frmPerson"
- Me.Text = "frmPerson"
- Me.GroupBox1.ResumeLayout(False)
- Me.GroupBox2.ResumeLayout(False)
- CType(Me.dgperson, System.ComponentModel.ISupportInitialize).EndInit()
- Me.ResumeLayout(False)
- End Sub
- #End Region
- Public lsweb As New jxcmanage
- Public dslocals As New DataSet
- Private Sub frmPerson_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- dslocals = lsweb.returndataset("select * from wz_mm", "wz_mm")
- ' dslocals.Clear()
- dgperson.DataSource = dslocals.Tables("wz_mm").DefaultView
- End Sub
- Private Sub add()
- txtNumber.Text = "".Trim()
- txtName.Text = "".Trim()
- txtPassword.Text = "".Trim()
- End Sub
- Private Sub save()
- dslocals = lsweb.returndataset("select * from wz_mm", "wz_mm")
- Dim dr As DataRow = dslocals.Tables(0).NewRow()
- dr("人员代码") = txtNumber.Text.Trim
- dr("操作员") = txtName.Text.Trim
- dr("密码") = txtPassword.Text.Trim
- dslocals.Tables(0).Rows.Add(dr)
- If lsweb.updatedataset("select * from wz_mm", "wz_mm", dslocals, DataRowState.Added) = True Then
- Dim strquery As String
- strquery = "insert into dbo.wz_Qxmenu(username,Cname,Ename,Ctype,Cctype,Cbit,DBit) select '" & txtName.Text & "',Cname,Ename,Ctype,Cctype,Cbit,DBit from dbo.wz_Qxmenu where username='admin'"
- lsweb.runSql(strquery)
- MessageBox.Show("信息成功保存!", "提示", MessageBoxButtons.OK)
- Else
- MessageBox.Show("信息保存失败!", "提示", MessageBoxButtons.AbortRetryIgnore)
- End If
-
- End Sub
- Private Sub modify()
- If lsweb.updatedataset("select 人员代码,操作员,密码 from wz_mm", "wz_mm", dslocals, DataRowState.Modified) = True Then
- MessageBox.Show("人员信息修改成功!", "提示", MessageBoxButtons.OK)
- Else
- MessageBox.Show("人员信息修改失败!", "提示", MessageBoxButtons.OK)
- End If
- End Sub
- Private Sub delete()
- Dim drv As DataRowView = BindingContext(Me.dgperson.DataSource).Current
- If drv(0) Is System.DBNull.Value Then
- MessageBox.Show("没有要删除的记录!", "提示", MessageBoxButtons.OK)
- Else
- Dim strquery As String = drv(0)
- Try
- Dim strsql, strCustomer As String
- strCustomer = "delete wz_mm where 操作员='" & drv(1) & "'"
- lsweb.runSql(strCustomer)
- strsql = "delete wz_Qxmenu where username='" & drv(1) & "'"
- lsweb.runSql(strsql)
- MessageBox.Show("已经删除记录啦!", "提示", MessageBoxButtons.OK)
- Catch ex As Exception
- MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK)
- End Try
-
-
- End If
- End Sub
- Private Sub view()
- Dim drv As DataRowView = BindingContext(Me.dgperson.DataSource).Current
- Dim dr As DataRow
- dr = drv.Row
- txtNumber.Text = IIf(dr("人员代码") Is System.DBNull.Value, "", dr("人员代码"))
- txtName.Text = IIf(dr("操作员") Is System.DBNull.Value, "", dr("操作员"))
- txtPassword.Text = IIf(dr("密码") Is System.DBNull.Value, "", dr("密码"))
- End Sub
- Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs) Handles tbrps.ButtonClick
- Select Case e.Button.Text
- Case "添加"
- tbnEnable("tbrAdd.Enabled = False", tbrps)
- add()
- Case "保存"
- If txtNumber.Text = "" Or txtName.Text = "" Then
- MessageBox.Show("信息不完整,保存失败!", "提示", MessageBoxButtons.OK)
- Else
- tbnEnable("tbrSave.Enabled = False", tbrps)
- save()
- Dim frmmaininst As New frmMain
- Dim mi As MenuItem
- For Each mi In frmmaininst.Menu.MenuItems
- lsweb.menuuser(Me.txtName.Text.Trim, "menuitemid", mi.Text.Trim)
- Next
- End If
-
- Case "修改"
- tbnEnable("tbrModify.Enabled = False", tbrps)
- modify()
- Case "删除"
- tbnEnable("tbrDelete.Enabled = False", tbrps)
- delete()
- Case "退出"
- Me.Close()
- End Select
- End Sub
- Public Sub tbnEnable(ByVal strboolean As String, ByVal tbr As ToolBar)
- If strboolean = "tbrAdd.Enabled = True" Then
- tbrSave.Enabled = False
- tbrmodify.Enabled = False
- tbrdelete.Enabled = False
- tbrExit.Enabled = True
- ElseIf strboolean = "tbrAdd.Enabled = False" Then
- tbrAdd.Enabled = False
- tbrSave.Enabled = True
- tbrmodify.Enabled = False
- tbrdelete.Enabled = False
- tbrExit.Enabled = True
- ElseIf strboolean = "tbrSave.Enabled = True" Then
- tbrAdd.Enabled = False
- tbrmodify.Enabled = False
- tbrdelete.Enabled = False
- tbrExit.Enabled = True
- ElseIf strboolean = "tbrSave.Enabled = False" Then
- tbrSave.Enabled = False
- tbrAdd.Enabled = True
- tbrmodify.Enabled = True
- tbrdelete.Enabled = True
- tbrExit.Enabled = True
- ElseIf strboolean = "tbrModify.Enabled = True" Then
- tbrAdd.Enabled = False
- tbrSave.Enabled = True
- tbrdelete.Enabled = False
- tbrExit.Enabled = True
- ElseIf strboolean = "tbrModify.Enabled = False" Then
- tbrmodify.Enabled = False
- tbrAdd.Enabled = False
- tbrSave.Enabled = True
- tbrdelete.Enabled = False
- tbrExit.Enabled = True
- ElseIf strboolean = "tbrDelete.Enabled = True" Then
- tbrAdd.Enabled = False
- tbrSave.Enabled = True
- tbrmodify.Enabled = False
- tbrExit.Enabled = True
- ElseIf strboolean = "tbrDelete.Enabled = False" Then
- tbrdelete.Enabled = False
- tbrAdd.Enabled = False
- tbrSave.Enabled = True
- tbrmodify.Enabled = False
- tbrExit.Enabled = True
- End If
- End Sub
- Private Sub txtNumber_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtNumber.Validating
- If txtNumber.Text = String.Empty Then
- ErrorProvider1.SetError(txtNumber, "不能为空,请输入人员代码!")
- e.Cancel = True
- Else
- ErrorProvider1.SetError(txtNumber, "")
- End If
- End Sub
- Private Sub txtName_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtName.Validating
- If txtName.Text = String.Empty Then
- ErrorProvider1.SetError(txtName, "不能为空,请输入姓名!")
- e.Cancel = True
- Else
- ErrorProvider1.SetError(txtName, "")
- End If
- End Sub
- Private Sub txtPassword_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtPassword.Validating
- If txtPassword.Text = String.Empty Then
- ErrorProvider1.SetError(txtPassword, "不能为空,请输入密码!")
- e.Cancel = True
- Else
- ErrorProvider1.SetError(txtPassword, "")
- End If
- End Sub
-
- Private Sub dgperson_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgperson.CurrentCellChanged
- view()
- tbrmodify.Enabled = True
- tbrdelete.Enabled = True
- tbrExit.Enabled = True
- End Sub
- End Class