VB+Access仓库管理系统 第12页

VB+Access仓库管理系统 第12页

5.6管理员窗体设置

与该窗体相关的代码

  Dim row1 As Integer               '选择某条记录

Dim pd As Integer                 '判断是否选中某一项记录

Dim datacount As Integer          '判断数据库中是否有记录

 

Private Sub cmdadd_Click()        '添加操作员

  operater.RecordSource = "select * from operater where 姓名='" & Trim(Text1(0)) & "'"

  operater.Refresh

  If operater.Recordset.EOF = False Then

    MsgBox "该操作员已经存在!!!"

  Else

    If Option1(0).Value = True Then

      czqx = 1

    Else

      czqx = 2

    End If

    operater.Recordset.AddNew

    operater.Recordset.Fields(0) = Trim(Text1(0))

    operater.Recordset.Fields(1) = Trim(Text1(1))

    operater.Recordset.Fields(2) = czqx

    operater.Recordset.Update

    operater.Refresh

  End If

  List.Enabled = True

  Call flash

  Text1(0) = ""

  Text1(1) = ""

  Option1(1).Value = True

  Text1(0).SetFocus

End Sub

 

Private Sub cmdCancel_Click()     '取消

  Text1(0) = ""

  Text1(1) = ""

  Text1(0).SetFocus

  Text1(0).Locked = False

  Text1(0).TabStop = True

  pd = 0

  cmdADD.Visible = True

  cmdCancel.Enabled = False

  cmdCancel.Visible = False

End Sub

 

Private Sub cmddel_Click()          '删除操作员信息

  operater.RecordSource = "select * from operater where 姓名='" & Trim(Text1(0)) & "'"

  operater.Refresh

  If operater.Recordset.EOF = True Then

    MsgBox "没有这个操作员!!"

    Text1(0).SetFocus

  Else

    aa = MsgBox("是否删除操作员【" & Text1(0) & "】的信息", 1 + 32)

    If aa = 1 Then

      operater.Recordset.Delete

      operater.Recordset.Update

      operater.Refresh

      Call csf

      Call pdd

      If datacount <> 0 Then Call flash

    End If

    Call cmdCancel_Click

  End If

End Sub

 

Private Sub cmdMODI_Click()         '修改操作员信息

  If Trim(Text1(1)) = "" Then

    MsgBox "密码不能为空!!!"

    Text1(1).SetFocus

    Exit Sub

  Else

    aa = MsgBox("是否修改此操作员的信息", 1 + 32)

    If aa = 1 Then

      operater.RecordSource = "select * from operater where 姓名='" & Trim(Text1(0)) & "'"

      operater.Refresh

      operater.Recordset.Fields(1) = Text1(1)

      If Option1(0).Value = True Then

        operater.Recordset.Fields(2) = 1

      Else

        operater.Recordset.Fields(2) = 2

      End If

      operater.Recordset.Update

      operater.Refresh

      Call flash

    End If

  End If

  Call cmdCancel_Click

End Sub

 

Private Sub cmdRet_Click()        '返回

  pd = 0

  Unload frmOperater

End Sub

 

Private Sub Form_Load()           '初始化

  Me.Top = (Mainform.Height - Me.Height) / 2 - 800

  Me.Left = (Mainform.Width - Me.Width) / 2

  Me.Caption = "仓库管理系统→" & "操作员设置"

  operater.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Storehouse.mdb;Persist Security Info=False"

  Call csf

  Call pdd

  If datacount <> 0 Then Call flash

End Sub

 

Private Sub List_Click()          '选中某一条记录

  pd = 1

  row1 = List.Row

  Text1(0) = List.TextMatrix(row1, 0)

  Text1(1) = ""

  If List.TextMatrix(row1, 2) = 1 Then

    Option1(0).Value = True

  Else

    Option1(1).Value = True

  End If

  cmdMODI.Enabled = True

  CmdDel.Enabled = True

  cmdADD.Enabled = False

  cmdADD.Visible = False

  cmdCancel.Enabled = True

  cmdCancel.Visible = True

  Text1(0).Locked = True

  Text1(0).TabStop = False

  Text1(1).SetFocus

End Sub

 

Private Sub Text1_Change(Index As Integer)      '判断输入是否为空

  If Trim(Text1(0)) = "" Or Trim(Text1(1)) = "" Then

    cmdADD.Enabled = False

    CmdDel.Enabled = False

  Else

    If pd = 1 Then

      CmdDel.Enabled = True

    Else

      cmdADD.Enabled = True

      CmdDel.Enabled = True

    End If

  End If

End Sub

 

Private Sub Text1_GotFocus(Index As Integer)

  If Text1(Index).TabStop = True Then

    Text1(Index).BackColor = &HC0FFFF

    Text1(Index).SelStart = 0

    Text1(Index).SelLength = 12

  End If

End Sub

Private Sub Text1_LostFocus(Index As Integer)

  Text1(Index).BackColor = &HFFC0C0

End Sub

Private Sub pdd()             '判断数据库中是否有记录

  operater.RecordSource = "select * from operater"

  operater.Refresh

  datacount = operater.Recordset.RecordCount

  If datacount = 0 Then

    List.Enabled = False

  Else

    List.Enabled = True

  End If

End Sub

 

Private Sub flash()           '刷新列表

Dim roww As Integer           ''

  roww = 1

  List.Clear

  List.rows = 1

  Call csf

  operater.RecordSource = "operater"

  operater.Refresh

  operater.Recordset.MoveFirst

  Do While operater.Recordset.EOF = False

    List.rows = List.rows + 1

    List.TextMatrix(roww, 0) = operater.Recordset.Fields(0)

    List.TextMatrix(roww, 1) = operater.Recordset.Fields(1)

    List.TextMatrix(roww, 2) = operater.Recordset.Fields(2)

    roww = roww + 1

    operater.Recordset.MoveNext

  Loop

End Sub

Private Sub csf()             '列表初始化

  List.TextMatrix(0, 0) = "姓名"

  List.TextMatrix(0, 1) = "密码"

  List.TextMatrix(0, 2) = "权限"

  List.ColWidth(0) = 1500

  List.ColWidth(1) = 2500

  List.ColWidth(2) = 1000

End Sub

 << 上一页  [11] [12] [13] [14] 下一页

Copyright © 2007-2012 www.chuibin.com 六维论文网 版权所有