frmStatistic.frm
上传用户:lizhip88
上传日期:2007-06-21
资源大小:42k
文件大小:7k
源码类别:

交通/航空行业

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
  3. Begin VB.Form frmStatistic 
  4.    Caption         =   "运营统计"
  5.    ClientHeight    =   4080
  6.    ClientLeft      =   60
  7.    ClientTop       =   348
  8.    ClientWidth     =   6756
  9.    LinkTopic       =   "Form1"
  10.    MDIChild        =   -1  'True
  11.    ScaleHeight     =   4080
  12.    ScaleWidth      =   6756
  13.    WindowState     =   2  'Maximized
  14.    Begin MSFlexGridLib.MSFlexGrid msgList 
  15.       Height          =   3135
  16.       Left            =   240
  17.       TabIndex        =   1
  18.       Top             =   600
  19.       Width           =   6255
  20.       _ExtentX        =   11028
  21.       _ExtentY        =   5525
  22.       _Version        =   393216
  23.       Cols            =   4
  24.       FixedCols       =   3
  25.       AllowUserResizing=   1
  26.    End
  27.    Begin VB.Label lblTitle 
  28.       Caption         =   "运    营    统    计"
  29.       BeginProperty Font 
  30.          Name            =   "宋体"
  31.          Size            =   12
  32.          Charset         =   134
  33.          Weight          =   700
  34.          Underline       =   0   'False
  35.          Italic          =   0   'False
  36.          Strikethrough   =   0   'False
  37.       EndProperty
  38.       ForeColor       =   &H8000000D&
  39.       Height          =   255
  40.       Left            =   240
  41.       TabIndex        =   0
  42.       Top             =   120
  43.       Width           =   3015
  44.    End
  45. End
  46. Attribute VB_Name = "frmStatistic"
  47. Attribute VB_GlobalNameSpace = False
  48. Attribute VB_Creatable = False
  49. Attribute VB_PredeclaredId = True
  50. Attribute VB_Exposed = False
  51. Option Explicit
  52. Public txtSQL As String
  53. Dim mrc As ADODB.Recordset
  54. Dim MsgText As String
  55. Private Sub Form_Load()
  56.     ShowTitle
  57.     ShowData
  58.     flagsEdit = True
  59. End Sub
  60. Private Sub Form_Resize()
  61.     If Me.WindowState <> vbMinimized And fMainForm.WindowState <> vbMinimized Then
  62.         '边界处理
  63.         If Me.ScaleHeight < 10 * lblTitle.Height Then
  64.             
  65.             Exit Sub
  66.         End If
  67.         If Me.ScaleWidth < lblTitle.Width + lblTitle.Width / 2 Then
  68.             
  69.             Exit Sub
  70.         End If
  71.         '控制控件的位置
  72.                 
  73.         lblTitle.Top = lblTitle.Height
  74.         lblTitle.Left = (Me.Width - lblTitle.Width) / 2
  75.         
  76.         msgList.Top = lblTitle.Top + lblTitle.Height + lblTitle.Height / 2
  77.         msgList.Width = Me.ScaleWidth - 200
  78.         msgList.Left = Me.ScaleLeft + 100
  79.         msgList.Height = Me.ScaleHeight - msgList.Top - 200
  80.     End If
  81. End Sub
  82. Public Sub RecordEdit()
  83.     Dim intCount As Integer
  84.     
  85.     If msgList.Rows > 1 Then
  86.         gintmode = EDIT
  87.         intCount = msgList.Row
  88.         gsSql = " where yyid='" & Trim(msgList.TextMatrix(msgList.Row, 1)) & "' and yydriver='" & Trim(msgList.TextMatrix(msgList.Row, 2)) & "' and yybegin_date=cdate('" & Format(msgList.TextMatrix(msgList.Row, 3), "yyyy-mm-dd") & "')"
  89.         frmStatistic1.Show 1
  90.         ShowData
  91.         Call MovCursor(intCount, msgList)
  92.     Else
  93.         Call RecordAdd
  94.     End If
  95. End Sub
  96. Public Sub FormClose()
  97.     Unload Me
  98. End Sub
  99. '删除记录
  100. Public Sub RecordDelete()
  101.     Dim sSql As String
  102.     Dim intCount As Integer
  103.     
  104.   On Error GoTo myErr
  105.     
  106.     If msgList.Rows > 1 Then
  107.         If MsgBox("真的要删除这条文件记录么?", vbOKCancel + vbExclamation, "警告") = vbOK Then
  108.             intCount = msgList.Row
  109.             sSql = "delete from " & msTableName & " where yyid='" & Trim(msgList.TextMatrix(msgList.Row, 1)) & "' and yydriver='" & Trim(msgList.TextMatrix(msgList.Row, 2)) & "' and yybegin_date=cdate('" & Format(msgList.TextMatrix(msgList.Row, 3), "yyyy-mm-dd") & "')"
  110.             dbHuaxia.Execute sSql, dbSQLPassThrough
  111.             ShowData
  112.             If msgList.Rows > 1 Then
  113.                 If intCount = msgList.Rows Then
  114.                     MovCursor msgList.Rows - 1, msgList
  115.                 Else
  116.                     MovCursor intCount, msgList
  117.                 End If
  118.             End If
  119.         End If
  120.     End If
  121.     
  122.     Exit Sub
  123.     
  124. myErr:
  125.     ShowError
  126. End Sub
  127. Public Sub RecordRefresh()
  128.     '设置msSql
  129.     msSql = msSelect & msTableName & " where yybegin_date>='" & Format(DateAdd("m", -1, Now), "yyyy-mm-dd") & "' and yybegin_date<='" & Format(Now, "yyyy-mm-dd") & "'" & msOrderBy
  130.         
  131.     '显示数据
  132.     msBarText = "当前数据时间范围:" & Format(DateAdd("m", -1, Now), "yyyy-mm-dd") & "至" & Format(Now, "yyyy-mm-dd")
  133.     sOrder0 = "+ {yyid}"
  134.     sOrder1 = ""
  135.     ShowData
  136. End Sub
  137. Public Sub RecordAdd()
  138.     gintmode = Add
  139.     frmStatistic1.Show 1
  140.     ShowData
  141. End Sub
  142. Public Sub RecordFind()
  143.     frmStatistic2.Show 1
  144.     If Trim(frmStatistic2.sQSql & " ") <> "" Then
  145.         msSql = msSelect & msTableName & " where" & frmStatistic2.sQSql & msOrderBy
  146.         ShowData
  147.     End If
  148.     Unload frmStatistic2
  149. End Sub
  150. Private Sub Form_Unload(Cancel As Integer)
  151.     gintsMode = 0
  152.     flagsEdit = False
  153. End Sub
  154. '详细显示记录
  155. Public Sub RecordView()
  156.     If msgList.Rows > 1 = False Then
  157.         gintmode = View
  158.         gsSql = " where yyid='" & Trim(msgList.TextMatrix(msgList.Row, 1)) & "' and yydriver='" & Trim(msgList.TextMatrix(msgList.Row, 2)) & "' and yybegin_date=cdate('" & Format(msgList.TextMatrix(msgList.Row, 3), "yyyy-mm-dd") & "')"
  159.         frmAcc1.Show 1
  160.     End If
  161. End Sub
  162. '显示Grid的内容
  163. Private Sub ShowData()
  164.     
  165.     Dim j As Integer
  166.     Dim i As Integer
  167.   
  168.     Set mrc = ExecuteSQL(txtSQL, MsgText)
  169.         With msgList
  170.         .Rows = 1
  171.         
  172.         Do While Not mrc.EOF
  173.             .Rows = .Rows + 1
  174.             For i = 1 To mrc.Fields.Count
  175.                 Select Case mrc.Fields(i - 1).Type
  176.                     Case adDBDate
  177.                         .TextMatrix(.Rows - 1, i) = Format(mrc.Fields(i - 1) & "", "yyyy-mm-dd")
  178.                     Case Else
  179.                         .TextMatrix(.Rows - 1, i) = mrc.Fields(i - 1) & ""
  180.                 End Select
  181.             Next i
  182.             mrc.MoveNext
  183.         Loop
  184.     End With
  185.     mrc.Close
  186. End Sub
  187. '显示Grid表头
  188. Private Sub ShowTitle()
  189.     Dim i As Integer
  190.     
  191.     With msgList
  192.         .Cols = 7
  193.         .TextMatrix(0, 1) = "车号"
  194.         .TextMatrix(0, 2) = "司机"
  195.         .TextMatrix(0, 3) = "开始时间"
  196.         .TextMatrix(0, 4) = "结束时间"
  197.         .TextMatrix(0, 5) = "运行公里"
  198.         .TextMatrix(0, 6) = "耗油"
  199.         
  200.         
  201.         '固定表头
  202.         .FixedRows = 1
  203.                 
  204.         '设置各列的对齐方式
  205.         For i = 0 To 4
  206.             .ColAlignment(i) = 0
  207.         Next i
  208.         For i = 5 To 6
  209.             .ColAlignment(i) = 7
  210.         Next i
  211.         
  212.         '表头项居中
  213.         .FillStyle = flexFillRepeat
  214.         .Col = 0
  215.         .Row = 0
  216.         .RowSel = 1
  217.         .ColSel = .Cols - 1
  218.         .CellAlignment = 4
  219.         
  220.         '设置单元大小
  221.         .ColWidth(0) = 300
  222.         .ColWidth(1) = 1000
  223.         .ColWidth(2) = 1000
  224.         .ColWidth(3) = 1000
  225.         .ColWidth(4) = 1000
  226.         .ColWidth(5) = 1000
  227.         .ColWidth(6) = 1000
  228.         .Row = 1
  229.         
  230.     End With
  231. End Sub
  232. Private Sub msgList_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  233.     '右键弹出
  234.     If Button = 2 And Shift = 0 Then
  235.         PopupMenu fMainForm.menuRun
  236.     End If
  237.         
  238. End Sub