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

📄 frmcardalr.frm

📁 用VB开发的车辆数据库管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         TabIndex        =   14
         Top             =   2025
         Width           =   975
      End
      Begin VB.Label Label16 
         Caption         =   "备    注:"
         Height          =   255
         Left            =   120
         TabIndex        =   13
         Top             =   1995
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "车牌号码:"
         Height          =   255
         Left            =   120
         TabIndex        =   12
         Top             =   285
         Width           =   975
      End
      Begin VB.Label Label7 
         Caption         =   "厂牌型号:"
         Height          =   255
         Left            =   3120
         TabIndex        =   11
         Top             =   285
         Width           =   975
      End
   End
   Begin VB.Image Imgexit 
      Height          =   330
      Left            =   5040
      Picture         =   "frmcarDAlr.frx":1CDA
      Stretch         =   -1  'True
      Top             =   3000
      Width           =   900
   End
   Begin VB.Image Imgcancel 
      Height          =   330
      Left            =   4125
      Picture         =   "frmcarDAlr.frx":5CAC
      Stretch         =   -1  'True
      Top             =   3000
      Width           =   900
   End
   Begin VB.Image Imgok 
      Height          =   330
      Left            =   3210
      Picture         =   "frmcarDAlr.frx":9CBE
      Stretch         =   -1  'True
      Top             =   3000
      Width           =   900
   End
   Begin VB.Image Imgfind 
      Height          =   330
      Left            =   4995
      Picture         =   "frmcarDAlr.frx":DCCB
      Stretch         =   -1  'True
      Top             =   60
      Width           =   900
   End
   Begin VB.Image Imgupdate 
      Height          =   330
      Left            =   4080
      Picture         =   "frmcarDAlr.frx":11CD3
      Stretch         =   -1  'True
      Top             =   60
      Width           =   900
   End
   Begin VB.Image Imgdelete 
      Height          =   330
      Left            =   3165
      Picture         =   "frmcarDAlr.frx":15CEE
      Stretch         =   -1  'True
      Top             =   60
      Width           =   900
   End
   Begin VB.Image Imgadd 
      Height          =   330
      Left            =   2250
      Picture         =   "frmcarDAlr.frx":19CFD
      Stretch         =   -1  'True
      Top             =   60
      Width           =   900
   End
End
Attribute VB_Name = "frmcarDAlr"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'*************************************************************************
'**模 块 名:frmcardalr
'**版权说明:吉林省明日科技有限公司享有本软件的所有版权,如果本软件用于商
'**          业用途,必须经过吉林省明日科技有限公司授权。如果提供网上免费
'**          下载,必须经过吉林省明日科技有限公司授权,并保证程序的完整,
'**          不得修改代码、注释和相关内容,否则,我公司将追究其法律责任
'**网    址:www.mingrisoft.com  价值无限,服务无限
'**电    话:(0431)84978981,84978982
'**创 建 人:明日科技
'**日    期:2007-10-31
'**修 改 人:mraj
'**日    期:2007-10-31
'**描    述:
'*************************************************************************
Dim i As Integer

Private Sub cmbf_KeyPress(KeyAscii As Integer)
    KeyAscii = valiText(KeyAscii, Chr(13), True)
End Sub

Private Sub cmnj_KeyPress(KeyAscii As Integer)
    KeyAscii = valiText(KeyAscii, Chr(13), True)
    If KeyAscii = 13 Then cmbx.SetFocus
End Sub
Private Sub cmbx_KeyPress(KeyAscii As Integer)
    KeyAscii = valiText(KeyAscii, Chr(13), True)
    If KeyAscii = 13 Then cmyd.SetFocus
End Sub
Private Sub cmyd_KeyPress(KeyAscii As Integer)
    KeyAscii = valiText(KeyAscii, Chr(13), True)
    If KeyAscii = 13 Then cmbf.SetFocus
End Sub
Private Sub DTPicker1_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = vbKeyReturn Then cmnj.SetFocus
End Sub
Private Sub Form_Load()
    '自动识别路径
    
    Adodc1.RecordSource = "select * from 车辆档案"
    Adodc1.Refresh
    If Adodc1.Recordset.RecordCount > 0 Then DTPicker1.Value = Adodc1.Recordset.Fields("购置日期")
    Adodc2.RecordSource = "select * from 车辆类型表"
    Adodc2.Refresh
    
    If Adodc2.Recordset.RecordCount = 0 Then Exit Sub
    For i = 0 To Adodc2.Recordset.RecordCount - 1
        Combo1.AddItem Adodc2.Recordset.Fields(0).Value
        Adodc2.Recordset.MoveNext
    Next
    
    Adodc3.RecordSource = "select * from 驾驶员档案"
    Adodc3.Refresh
    
    If Adodc3.Recordset.RecordCount = 0 Then Exit Sub
    For i = 0 To Adodc3.Recordset.RecordCount - 1
        Combo2.AddItem Adodc3.Recordset.Fields(0).Value
        Adodc3.Recordset.MoveNext
    Next
    On Error Resume Next
    Combo1.Text = Adodc1.Recordset.Fields(1)
    Combo2.Text = Adodc1.Recordset.Fields(2)
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Imgexit_Click
End Sub

Private Sub Imgadd_Click()  '添加
    Unlockctl
    DTPicker1.Value = Format(Now, "yyyy-mm-dd")
    Text1 = "": Text2 = "": Combo2 = "": Text4 = "": Text5 = "": Text6 = "": Text7 = ""
    Combo1.Text = ""
    cmnj.Text = "是"
    cmbx.Text = "是"
    cmyd.Text = "是"
    cmbf.Text = "是"
    Text1.SetFocus
    Imgok.Enabled = True: Imgcancel.Enabled = True
    Imgdelete.Enabled = False: Combo1.Visible = True
    Adodc1.Enabled = False: Imgupdate.Enabled = False
    i = 1
End Sub

Private Sub Imgdelete_Click()  '删除
  If MsgBox("您确实要删除记录吗?", vbOKCancel, "车辆管理系统") = vbOK Then
        adoCon.Execute ("delete from 车辆档案 where 车牌号码='" & Text1 & "'")
        MsgBox " 记录已删除!", , "车辆管理系统"
        Unload Me
        Adodc1.Refresh
        frmcarDAlr.Show
    End If
End Sub

Private Sub Imgupdate_Click()  '修改
   '设置控件状态
   Text1.Enabled = False: Combo1.Enabled = True: Combo2.Enabled = True
   Text4.Enabled = True: Text5.Enabled = True: Text6.Enabled = True
   Text7.Enabled = True
   DTPicker1.Enabled = True
   cmnj.Enabled = True: cmbx.Enabled = True: cmyd.Enabled = True: cmbf.Enabled = True
    
    i = 2
    Imgok.Enabled = True: Imgcancel.Enabled = True
    Imgadd.Enabled = False: Imgdelete.Enabled = False
    Adodc1.Enabled = False: Text1.Enabled = False
End Sub
Private Sub Imgfind_Click()   '查询
  Dim str As String
  str = InputBox$("输入你要查询的车牌号码:", "车辆管理系统")
  If str = "" Then Exit Sub
  Adodc1.RecordSource = "select * from 车辆档案 where 车牌号码='" + str + "'"
  Adodc1.Refresh
  If Adodc1.Recordset.RecordCount > 0 Then
     On Error Resume Next
     Text1.Text = Adodc1.Recordset.Fields(0)
     Combo1.Text = Adodc1.Recordset.Fields(1)
     Combo2.Text = Adodc1.Recordset.Fields(2)
     DTPicker1.Value = Adodc1.Recordset.Fields(3)
     Text7.Text = Adodc1.Recordset.Fields(4)
     Text4.Text = Adodc1.Recordset.Fields(5)
     Text5.Text = Adodc1.Recordset.Fields(6)
     cmnj.Text = Adodc1.Recordset.Fields(7)
     cmbx.Text = Adodc1.Recordset.Fields(8)
     cmyd.Text = Adodc1.Recordset.Fields(9)
     cmbf.Text = Adodc1.Recordset.Fields(10)
     Text6.Text = Adodc1.Recordset.Fields(11)
     Imgupdate.Enabled = True
     Imgdelete.Enabled = True
  Else
     MsgBox "没有你需要的信息!", 4, "车辆管理系统"
     Imgupdate.Enabled = False
     Imgdelete.Enabled = False
  End If
End Sub
Private Sub Imgok_Click()  '确定
 Select Case i
        Case 1
            If Text1 = "" Then
                MsgBox "车牌号码不能为空", 4, "车辆管理系统"
                Text1.SetFocus
                Exit Sub
            End If
            If Combo1.Text = "" Then
                MsgBox "车辆类型不能为空", 4, "车辆管理系统"
                Combo1.SetFocus
                Exit Sub
            End If
            If DTPicker1.Value = "" Then
                MsgBox "购置日期不能为空", 4, "车辆管理系统"
                DTPicker1.SetFocus
                Exit Sub
            End If
          cnn.Execute ("insert into 车辆档案 values ('" & Text1 & "','" & Combo1 & "','" & Combo2 & "','" & DTPicker1.Value & "','" & Text7 & "','" & Text4 & "','" & Text5 & "','" & cmnj & "','" & cmbx & "','" & cmyd & "','" & cmbf & "','" & Text6 & "')")
          If cmyd.Text = "是" Then    '是否异动
           Dim rs1 As New ADODB.Recordset
            rs1.Open "select * from 车辆异动表", adoCon, adOpenKeyset, adLockOptimistic
            rs1.AddNew
            rs1.Fields("车牌号码") = Text1.Text
            rs1.Fields("异动时间") = DTPicker1.Value
            rs1.Fields("异动地点") = " "
            rs1.Fields("经手人") = " "
            rs1.Fields("备注") = " "
            rs1.Update
            rs1.Close
          End If
          
          If cmbf.Text = "是" Then    '是否报废
            Dim rs2 As New ADODB.Recordset
            rs2.Open "select * from 车辆报废表", adoCon, adOpenKeyset, adLockOptimistic
            rs2.AddNew
            rs2.Fields("车牌号码") = Text1.Text
            rs2.Fields("报废原因") = " "
            rs2.Fields("报废日期") = DTPicker1.Value
            rs2.Fields("经手人") = " "
            rs2.Fields("备注") = " "
            rs2.Update
            rs2.Close
          End If
          MsgBox "记录添加成功!", 4, "车辆管理系统"
          Adodc1.Refresh
        Case 2
          cnn.Execute ("update 车辆档案 set 车辆类型='" & Combo1 & "',驾驶员编号='" & Combo2 & "',使用人或单位='" & Text4 & "',车辆所在单位='" & Text5 & "',备注='" & Text6 & "', 厂牌型号='" & Text7 & "',购置日期='" & DTPicker1.Value & "',年检审='" & cmnj.Text & "',保险否='" & cmbx.Text & "',异动否='" & cmyd.Text & "',报废否='" & cmbf.Text & "' where 车牌号码='" & Text1 & "'")
           If cmyd.Text = "否" Then
'           Dim rs1 As New ADODB.Recordset
             rs1.Open "select * from 车辆异动表 where 车牌号码='" + Text1.Text + "'", cnn, adOpenKeyset, adLockOptimistic
             If rs1.RecordCount > 0 Then
               rs1.Delete
               rs1.Update
               rs1.Close
             End If
           ElseIf cmyd.Text = "是" Then    '是否异动
            rs1.Open "select * from 车辆异动表 where 车牌号码 ='" + Text1.Text + "'", cnn, adOpenKeyset, adLockOptimistic
            If rs1.RecordCount = 0 Then
              rs1.AddNew
              rs1.Fields("车牌号码") = Text1.Text
              rs1.Fields("异动时间") = DTPicker1.Value
              rs1.Fields("异动地点") = " "
              rs1.Fields("经手人") = " "
              rs1.Fields("备注") = " "
              rs1.Update
              rs1.Close
            End If
           End If
           
           If cmbf.Text = "是" Then    '是否报废
'             Dim rs2 As New ADODB.Recordset
             rs2.Open "select * from 车辆报废表 where 车牌号码 ='" + Text1.Text + "'", cnn, adOpenKeyset, adLockOptimistic
             If rs2.RecordCount = 0 Then
               rs2.AddNew
               rs2.Fields("车牌号码") = Text1.Text
               rs2.Fields("报废原因") = " "
               rs2.Fields("报废日期") = DTPicker1.Value
               rs2.Fields("经手人") = " "
               rs2.Fields("备注") = " "
               rs2.Update
               rs2.Close
             End If
           ElseIf cmbf.Text = "否" Then
             rs2.Open "select * from 车辆报废表 where 车牌号码 ='" + Text1.Text + "'", cnn, adOpenKeyset, adLockOptimistic
             If rs2.RecordCount > 0 Then
                rs2.Delete
                rs2.Update
                rs2.Close
             End If
           End If
           MsgBox "记录修改成功!", , "车辆管理系统"
          
          Adodc1.Refresh
  End Select
    Lockctl
    Imgok.Enabled = False: Imgcancel.Enabled = False
    Imgadd.Enabled = True: Imgupdate.Enabled = True
    Imgdelete.Enabled = True: Adodc1.Enabled = True
End Sub

Private Sub Imgcancel_Click()  '取消
  On Error Resume Next     '当没有添加数据的时候 处理异常
    Adodc1.Recordset.CancelUpdate
    Adodc1.Refresh
    Lockctl
    Imgok.Enabled = False: Imgcancel.Enabled = False
    Imgadd.Enabled = True: Imgupdate.Enabled = True
    Imgdelete.Enabled = True: Adodc1.Enabled = True
End Sub


Private Sub Imgexit_Click()   '退出
    MDIForm1.StatusBar1.Panels(1).Text = ""
    Unload Me
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 13 Then Combo1.SetFocus
End Sub
Private Sub Text1_LostFocus()
    Dim rs As New ADODB.Recordset
    Call main1
    Set rs = adoCon.Execute("select * from 车辆档案 where 车牌号码='" & Text1.Text & "'")
    If rs.EOF = False Then
        MsgBox "此车牌号码已经存在!", 4, "车辆管理系统"
        Text1 = ""
    End If
    rs.Close
End Sub
Private Sub Combo1_KeyPress(KeyAscii As Integer)
   KeyAscii = valiText(KeyAscii, Chr(13), True)
    If KeyAscii = 13 Then Combo2.SetFocus
End Sub
Private Sub Combo2_KeyPress(KeyAscii As Integer)
   KeyAscii = valiText(KeyAscii, Chr(13), True)
    If KeyAscii = 13 Then Text4.SetFocus
End Sub
Private Sub Text5_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then Text6.SetFocus
End Sub
Private Sub Text6_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then Text7.SetFocus
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then Text5.SetFocus
End Sub
Private Sub Text7_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then DTPicker1.SetFocus
End Sub

Private Sub Lockctl()
   Text1.Enabled = False: Combo1.Enabled = False: Combo2.Enabled = False
   Text4.Enabled = False: Text5.Enabled = False: Text6.Enabled = False
   Text7.Enabled = False
   DTPicker1.Enabled = False
   cmnj.Enabled = False: cmbx.Enabled = False: cmyd.Enabled = False: cmbf.Enabled = False
End Sub
Private Sub Unlockctl()
   Text1.Enabled = True: Combo1.Enabled = True: Combo2.Enabled = True
   Text4.Enabled = True: Text5.Enabled = True: Text6.Enabled = True
   Text7.Enabled = True
   DTPicker1.Enabled = True
   cmnj.Enabled = True: cmbx.Enabled = True: cmyd.Enabled = True: cmbf.Enabled = True
End Sub


⌨️ 快捷键说明

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