frmstatistic.frm

来自「车辆管理系统是一个协助各单位进行全面的车辆管理的系统。包括车辆档案管理;驾驶员档」· FRM 代码 · 共 358 行

FRM
358
字号
VERSION 5.00
Begin VB.Form Frmstatistic 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "运营统计"
   ClientHeight    =   4995
   ClientLeft      =   1740
   ClientTop       =   2025
   ClientWidth     =   4500
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   4995
   ScaleWidth      =   4500
   Begin VB.CommandButton cmdcancel 
      Caption         =   "取 消"
      Height          =   375
      Left            =   2760
      TabIndex        =   14
      Top             =   4320
      Width           =   1215
   End
   Begin VB.CommandButton cmdok 
      Caption         =   "确 定"
      Height          =   375
      Left            =   1320
      TabIndex        =   13
      Top             =   4320
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Caption         =   "运营信息"
      Height          =   3735
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   3975
      Begin VB.TextBox txtitem 
         Height          =   375
         Index           =   3
         Left            =   1320
         TabIndex        =   12
         Top             =   3120
         Width           =   2415
      End
      Begin VB.TextBox txtitem 
         Height          =   375
         Index           =   2
         Left            =   1320
         TabIndex        =   11
         Top             =   2520
         Width           =   2415
      End
      Begin VB.TextBox txtitem 
         Height          =   375
         Index           =   1
         Left            =   1320
         TabIndex        =   10
         Top             =   1920
         Width           =   2415
      End
      Begin VB.TextBox txtitem 
         Height          =   375
         Index           =   0
         Left            =   1320
         TabIndex        =   9
         Top             =   1320
         Width           =   2415
      End
      Begin VB.ComboBox Cobdriver 
         Height          =   300
         Left            =   1320
         TabIndex        =   8
         Top             =   840
         Width           =   2415
      End
      Begin VB.ComboBox Cobid 
         Height          =   300
         Left            =   1320
         TabIndex        =   7
         Top             =   360
         Width           =   2415
      End
      Begin VB.Label Label6 
         Caption         =   "各项开支(元):"
         Height          =   255
         Left            =   120
         TabIndex        =   6
         Top             =   3240
         Width           =   1335
      End
      Begin VB.Label Label5 
         Caption         =   "行程(公里):"
         Height          =   255
         Left            =   120
         TabIndex        =   5
         Top             =   2640
         Width           =   1095
      End
      Begin VB.Label Label4 
         Caption         =   "结束时间:"
         Height          =   375
         Left            =   120
         TabIndex        =   4
         Top             =   2040
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "开始时间:"
         Height          =   375
         Left            =   120
         TabIndex        =   3
         Top             =   1440
         Width           =   975
      End
      Begin VB.Label Label2 
         Alignment       =   2  'Center
         Caption         =   "司 机:"
         Height          =   255
         Left            =   120
         TabIndex        =   2
         Top             =   840
         Width           =   735
      End
      Begin VB.Label Label1 
         Alignment       =   2  'Center
         Caption         =   "牌 照:"
         Height          =   255
         Left            =   120
         TabIndex        =   1
         Top             =   360
         Width           =   735
      End
   End
End
Attribute VB_Name = "Frmstatistic"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim txtchange As Boolean   '标志修改时内容是否已经被修改
Dim mrc As ADODB.Recordset
Public txtsql As String

Private Sub cmdcancel_Click()
  If gintsMode = 2 Then
     If txtchange And CmdOK.Enabled Then
        If MsgBox("数据已经修改,是否保存修改?", vbOKCancel + vbExclamation, "警告") = vbOK Then
           Call cmdok_Click
        End If
     End If
  End If
  Unload Me
End Sub

Private Sub cmdok_Click()
   Dim txtcount As Integer
   Dim tmsg As String
   Dim msgtext As String
   
   If cobid.Text = "" Then
      MsgBox "车辆牌照不能为空,请选择车辆牌照", vbOKOnly + vbExclamation, "警告"
      cobid.SetFocus
      Exit Sub
   End If
   If Cobdriver.Text = "" Then
      MsgBox "司机姓名不能为空,请选择司机名称", vbOKOnly + vbExclamation, "警告"
      Cobdriver.SetFocus
      Exit Sub
   End If
   For txtcount = 0 To 1
       If Trim(txtitem(txtcount)) = "" Then
          MsgBox "运营的开始和结束时间不能为空", vbOKOnly + vbExclamation, "警告"
          txtitem(txtcount).SetFocus
          Exit Sub
          If Not IsDate(txtitem(txtcount)) Then
             MsgBox "请输入时间格式:yyyy-mm-dd !", vbOKOnly + vbExclamation, "警告"
             txtitem(txtcount).SetFocus
             Exit Sub
          Else
             txtitem(txtcount) = Format(txtitem(txtcount), "yyyy-mm-dd")
          End If
       End If
   Next txtcount
  ' If Trim(txtitem(2) & "") = "" Then
    '  txtitem(2) = Null
  ' Else
   If Not IsNumeric(txtitem(2)) Then
       MsgBox "对不起,您输入的不是数据,请重新输入 !", vbOKOnly + vbExclamation, "警告"
       txtitem(2).SetFocus
       Exit Sub
  '    End If
   End If
  ' If Trim(txtitem(3) & "") = "" Then
   '   txtitem(3) = Null
  ' Else
   If Not IsNumeric(txtitem(3)) Then
         MsgBox "对不起,您输入的不是数据,请重新输入 !", vbOKOnly + vbExclamation, "警告"
         txtitem(3).SetFocus
         Exit Sub
'      End If
   End If
   If gintsMode = 1 Then
      txtsql = "select * from statistic"
      Set mrc = ExecuteSQL(txtsql, msgtext)
      mrc.AddNew
      mrc.Fields(0) = Trim(cobid.Text)
      mrc.Fields(1) = Trim(Cobdriver.Text)
      For txtcount = 0 To 3
          mrc.Fields(txtcount + 2) = Trim(txtitem(txtcount))
      Next txtcount
      mrc.Update
      mrc.Close
      MsgBox "添加运营信息成功,按确定继续添加", vbOKOnly + vbExclamation, "添加"
   End If
   
   If gintsMode = 2 Then
      'txtsql = "delete from statistic where yy_id='" & Trim(cobid.Text) & "' and yy_bdate='" & txtitem(0) & "'"
      txtsql = "delete from statistic where yy_id='" & Trim(frmstatisticlist.msglist.TextMatrix(frmstatisticlist.msglist.Row, 1)) & "' and yy_bdate='" & Trim(frmstatisticlist.msglist.TextMatrix(frmstatisticlist.msglist.Row, 3)) & "'"
      ExecuteSQL txtsql, msgtext
      txtsql = "select * from statistic"
      Set mrc = ExecuteSQL(txtsql, msgtext)
      mrc.AddNew
      mrc.Fields(0) = Trim(cobid.Text)
      mrc.Fields(1) = Trim(Cobdriver.Text)
      For txtcount = 0 To 3
          mrc.Fields(txtcount + 2) = Trim(txtitem(txtcount))
      Next txtcount
      mrc.Update
      mrc.Close
      MsgBox "修改信息成功", vbOKOnly + vbExclamation, "修改"
      flagsEdit = True
   End If
   If gintsMode = 1 Then
      cobid.Text = ""
      Cobdriver.Text = ""
      For txtcount = 0 To 3
          txtitem(txtcount) = ""
      Next txtcount
   End If
   If gintsMode = 2 Then
      Unload Me
      If flagsEdit Then
         Unload frmstatisticlist
      End If
      frmstatisticlist.txtsql = ""                 '重新载入数据
      frmstatisticlist.Show
   End If
End Sub

Private Sub Cobdriver_Change()
   txtchange = True
End Sub

Private Sub cobid_Change()
   txtchange = True
End Sub

Private Sub Form_Load()
Dim txtcount As Integer
Dim msgtext As String
Me.Left = 5310
Me.Top = 1695
    If gintsMode = 1 Then
       Me.Caption = Me.Caption & "添加"
       txtsql = "select DISTINCT cl_id from vehicle"
       'txtsql = "select * from vehicle"
       Set mrc = ExecuteSQL(txtsql, msgtext)
       If Not mrc.EOF Then
          Do While Not mrc.EOF
             cobid.AddItem Trim(mrc!cl_id)
             'Cobdriver.AddItem Trim(mrc!yy_driver)
             mrc.MoveNext
          Loop
          'Cobid.ListIndex = 0
        End If
  '      mrc.Close
        txtsql = "select DISTINCT sj_name from driver"
        Set mrc = ExecuteSQL(txtsql, msgtext)
        If Not mrc.EOF Then
          Do While Not mrc.EOF
             Cobdriver.AddItem Trim(mrc!sj_name)
             'Cobdriver.AddItem Trim(mrc!yy_driver)
             mrc.MoveNext
          Loop
      '    Cobdriver.ListIndex = 0
        End If
      '' Else
       ''   MsgBox "无任何运营信息", vbOKOnly + vbExclamation, "警告"
       ''   cmdok.Enabled = False
       ''   Exit Sub
       ''End If
       mrc.Close
    End If
    If gintsMode = 2 Then
           Set mrc = ExecuteSQL(txtsql, msgtext)
           If mrc.EOF = False Then
              With mrc
                   If (.Fields(0) & "") <> "" Then
                       cobid.Text = .Fields(0)
                   End If
                   If (.Fields(1) & "") <> "" Then
                       Cobdriver.Text = .Fields(1)
                   End If
                   For txtcount = 0 To 3
                       If (.Fields(txtcount + 2) & "") <> "" Then
                           txtitem(txtcount) = .Fields(txtcount + 2)
                       End If
                   Next txtcount
               End With
              ' Cobid.Enabled = False
            End If
            mrc.Close
            Me.Caption = Me.Caption & "修改"
    ' End If
           
           txtsql = "select DISTINCT cl_id from vehicle"
            'txtsql = "select * from vehicle"
           Set mrc = ExecuteSQL(txtsql, msgtext)
           If Not mrc.EOF Then
              Do While Not mrc.EOF
                  cobid.AddItem Trim(mrc!cl_id)
             'Cobdriver.AddItem Trim(mrc!yy_driver)
                   mrc.MoveNext
              Loop
                  'Cobid.ListIndex = 0
           End If
                '      mrc.Close
           txtsql = "select DISTINCT sj_name from driver"
           Set mrc = ExecuteSQL(txtsql, msgtext)
           If Not mrc.EOF Then
              Do While Not mrc.EOF
                 Cobdriver.AddItem Trim(mrc!sj_name)
             'Cobdriver.AddItem Trim(mrc!yy_driver)
                 mrc.MoveNext
              Loop
      ''    Cobdriver.ListIndex = 0
           End If
      
       mrc.Close
       txtchange = False
 End If
                  
End Sub

Private Sub Form_Unload(Cancel As Integer)
  txtchange = True
End Sub

Private Sub txtitem_Change(Index As Integer)
   txtchange = True
End Sub

Private Sub txtitem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
   EnterToTab KeyCode
End Sub

⌨️ 快捷键说明

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