⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmmanager.frm

📁 用VB开发的车辆数据库管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
End
Attribute VB_Name = "frmManager"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'*************************************************************************
'**模 块 名:frmManager
'**版权说明:吉林省明日科技有限公司享有本软件的所有版权,如果本软件用于商
'**          业用途,必须经过吉林省明日科技有限公司授权。如果提供网上免费
'**          下载,必须经过吉林省明日科技有限公司授权,并保证程序的完整,
'**          不得修改代码、注释和相关内容,否则,我公司将追究其法律责任
'**网    址:www.mingrisoft.com  价值无限,服务无限
'**电    话:(0431)84978981,84978982
'**创 建 人:明日科技
'**日    期:2007-10-31
'**修 改 人:mraj
'**日    期:2007-10-31
'**描    述:
'*************************************************************************
Dim i As Integer
Dim adoRs1 As New ADODB.Recordset
Private Sub Command1_Click(Index As Integer)
  On Error Resume Next
  Select Case Index
         Case 0
         Adodc1.Recordset.MoveFirst
         Case 1
         If Adodc1.Recordset.BOF = False Then
            Adodc1.Recordset.MovePrevious
         End If
         Case 2
         If Adodc1.Recordset.EOF = False Then
            Adodc1.Recordset.MoveNext
         End If
         Case 3
         Adodc1.Recordset.MoveLast
  End Select
  showdata
End Sub

Private Sub Form_Load()
   '设置窗体大小
    frmManager.Width = 5535
    frmManager.Height = 2445
    '自动识别路径
    Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\clgl.mdb;Persist Security Info=False"
    Adodc1.RecordSource = "select * from 用户表"
    Adodc1.Refresh
    If Adodc1.Recordset.RecordCount > 0 Then showdata
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Imgexit_Click
End Sub
Private Sub Image1_Click(Index As Integer)
  On Error Resume Next
  Select Case Index
         Case 0
         Adodc1.Recordset.MoveFirst
         Case 1
         If Adodc1.Recordset.BOF = False Then
            Adodc1.Recordset.MovePrevious
         End If
         Case 2
         If Adodc1.Recordset.EOF = False Then
            Adodc1.Recordset.MoveNext
         End If
         Case 3
         Adodc1.Recordset.MoveLast
  End Select
  showdata

End Sub

Private Sub Imgadd_Click()  '增加
    Unlockctl
    '清空文本内容
    Text1 = ""
    Text2 = ""
    Text3 = ""
    Combo1.Text = ""
    Text1.SetFocus
    '设置控件状态
    Imgok.Enabled = True
    Imgcancel.Enabled = True
    Imgupdate.Enabled = False
    Imgdelete.Enabled = False
    Imgadd.Enabled = False
    i = 1

End Sub

Private Sub Imgcancel_Click()  '取消
  On Error Resume Next
    Select Case i
        Case 1
            Adodc1.Recordset.MoveFirst
        Case 2
            Adodc1.Recordset.MoveNext
            If Adodc1.Recordset.EOF Then Adodc1.Recordset.MovePrevious
        End Select
    Lockctl
    '设置控件状态
    Imgcancel.Enabled = False
    Imgok.Enabled = False
    Imgupdate.Enabled = True
    Imgdelete.Enabled = True
    Imgadd.Enabled = True
End Sub

Private Sub Imgdelete_Click()  '删除
    If MsgBox("确实要删除这条记录吗?", vbOKCancel, "车辆管理系统") = vbOK Then
       On Error Resume Next
       Adodc1.Recordset.Delete   '删除记录
       Adodc1.Recordset.MoveFirst  '将记录移至第一条
       Dim rs2 As New ADODB.Recordset
       Call main1
       rs2.Open "select * from 权限表 where 用户名= '" + Text1.Text + "'", adoCon, adOpenKeyset, adLockOptimistic
       If rs2.RecordCount > 0 Then
         rs2.Delete
         rs2.Update
       End If
       If Adodc1.Recordset.RecordCount > 0 Then   '如果记录数大于零
       showdata
       Else
          Text1.Text = ""
          Text2.Text = ""
          Text3.Text = ""
          Combo1.Text = ""
       End If
    End If

End Sub

Private Sub Imgexit_Click()  '退出
    On Error Resume Next
    adors.Close
    MDIForm1.StatusBar1.Panels(1).Text = ""
    Unload Me
End Sub
Private Sub Imgok_Click()  '确定
    If Text3 <> Text2 Then
        Text2 = ""
        Text3 = ""
        Text2.SetFocus
        MsgBox "确认密码必须与密码一致!", , "车辆管理系统"
        Exit Sub
    End If
    Select Case i
        Case 1
            If Text1 = "" Then
                MsgBox "用户姓名不能为空", , "车辆管理系统"
                Text1.SetFocus
                Exit Sub
            End If
            If Text2 = "" Then
                MsgBox "密码不能为空", , "车辆管理系统"
                Text2.SetFocus
                Exit Sub
            End If
            If Text3 = "" Then
                MsgBox "确认密码不能为空", , "车辆管理系统"
                Text3.SetFocus
                Exit Sub
            End If
            If Combo1.Text = "" Then
                MsgBox "用户类型不能为空", , "车辆管理系统"
                Combo1.SetFocus
                Exit Sub
            End If
            Adodc1.Recordset.AddNew   '添加一条新记录
            Adodc1.Recordset.Fields("用户姓名") = Text1.Text
            Adodc1.Recordset.Fields("密码") = Text2.Text
            Adodc1.Recordset.Fields("用户类型") = Combo1.Text
            Adodc1.Recordset.Update
            Dim rs1 As New ADODB.Recordset
            Call main1
            rs1.Open "select * from 权限表", adoCon, adOpenKeyset, adLockOptimistic
            rs1.AddNew
            rs1.Fields("用户名") = Text1.Text
            rs1.Fields("密码") = Text2.Text
            rs1.Fields("用户类型") = Combo1.Text
            rs1.Update
            rs1.Close
            MsgBox "记录添加成功!", , "车辆管理系统"
            Lockctl
            '设置控件状态
           Imgupdate.Enabled = True
           Imgdelete.Enabled = True
           Imgadd.Enabled = True
           Imgok.Enabled = False
           Imgcancel.Enabled = False
        Case 2
            Adodc1.Recordset.Fields(0) = Text1.Text
            Adodc1.Recordset.Fields(1) = Text2.Text
            Adodc1.Recordset.Fields(2) = Combo1.Text
            Adodc1.Recordset.Update
            Dim rs2 As New ADODB.Recordset
            rs2.Open "select * from 权限表 where 用户名 ='" + Text1.Text + "'", cnn, adOpenKeyset, adLockOptimistic
            If rs2.RecordCount > 0 Then
              rs2.Fields("密码") = Text2.Text
              rs2.Update
            End If
            MsgBox "记录修改成功!", , "车辆管理系统"
            Lockctl
            '设置控件状态
            Imgupdate.Enabled = True
            Imgdelete.Enabled = True
            Imgadd.Enabled = True
            Imgok.Enabled = False
            Imgcancel.Enabled = False
    End Select
End Sub

Private Sub Imgupdate_Click() '修改
'    设置控件状态
    Text2.Enabled = True
    Text3.Enabled = True
    Combo1.Enabled = True
    Text1.Enabled = False
    Imgok.Enabled = True
    Imgcancel.Enabled = True
    i = 2

End Sub

Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then Text2.SetFocus   '按回车键Text2获得焦点
End Sub

Private Sub Text1_LostFocus()
   Call main1
    Set adoRs1 = adoCon.Execute("select * from 权限表 where 用户名='" & Text1 & "'")
    If Not adoRs1.EOF Then
        MsgBox "此用户已经存在,请重新输入用户姓名!", , "车辆管理系统"
'        Text1 = ""
'        Text1.SetFocus
        Exit Sub
    End If
    adoRs1.Close
    adoCon.Close
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then Text3.SetFocus   '按回车键Text3获得焦点
End Sub
Private Sub text3_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then Combo1.SetFocus  '按回车键Combo1获得焦点
End Sub

Private Sub Lockctl()
'设置控件状态
   Text1.Enabled = False
   Text2.Enabled = False
   Text3.Enabled = False
   Combo1.Enabled = False
End Sub

Private Sub Unlockctl()
'设置控件状态
   Text1.Enabled = True
   Text2.Enabled = True
   Text3.Enabled = True
   Combo1.Enabled = True
End Sub
Sub showdata()
Text1.Text = Adodc1.Recordset.Fields(0)
Text2.Text = Adodc1.Recordset.Fields(1)
Combo1.Text = Adodc1.Recordset.Fields(2)
End Sub



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -