frmVehicle.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 frmVehicle 
  4.    Caption         =   "车辆列表"
  5.    ClientHeight    =   4368
  6.    ClientLeft      =   60
  7.    ClientTop       =   348
  8.    ClientWidth     =   6804
  9.    LinkTopic       =   "Form1"
  10.    MDIChild        =   -1  'True
  11.    ScaleHeight     =   4368
  12.    ScaleWidth      =   6804
  13.    WindowState     =   2  'Maximized
  14.    Begin MSFlexGridLib.MSFlexGrid msgList 
  15.       Height          =   3135
  16.       Left            =   120
  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 = "frmVehicle"
  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.     flagvEdit = True
  59.     
  60.     
  61. End Sub
  62. Private Sub Form_Resize()
  63.     If Me.WindowState <> vbMinimized And fMainForm.WindowState <> vbMinimized Then
  64.         '边界处理
  65.         If Me.ScaleHeight < 10 * lblTitle.Height Then
  66.             
  67.             Exit Sub
  68.         End If
  69.         If Me.ScaleWidth < lblTitle.Width + lblTitle.Width / 2 Then
  70.             
  71.             Exit Sub
  72.         End If
  73.         '控制控件的位置
  74.                 
  75.         lblTitle.Top = lblTitle.Height
  76.         lblTitle.Left = (Me.Width - lblTitle.Width) / 2
  77.         
  78.         msgList.Top = lblTitle.Top + lblTitle.Height + lblTitle.Height / 2
  79.         msgList.Width = Me.ScaleWidth - 200
  80.         msgList.Left = Me.ScaleLeft + 100
  81.         msgList.Height = Me.ScaleHeight - msgList.Top - 200
  82.     End If
  83. End Sub
  84. Public Sub RecordEdit()
  85.     Dim intCount As Integer
  86.     
  87.     If msgList.Rows > 1 Then
  88.         gintmode = EDIT
  89.         intCount = msgList.Row
  90.         gsSql = " where clid='" & Trim(msgList.TextMatrix(msgList.Row, 1)) & "'"
  91.         frmVehicle1.Show 1
  92.         ShowData
  93.         Call MovCursor(intCount, msgList)
  94.     Else
  95.         Call RecordAdd
  96.     End If
  97.         
  98. End Sub
  99. Public Sub FormClose()
  100.     Unload Me
  101. End Sub
  102. '删除记录
  103. Public Sub RecordDelete()
  104.     Dim sSql As String
  105.     Dim intCount As Integer
  106.     
  107.   On Error GoTo myErr
  108.     
  109.     If msgList.Rows > 1 Then
  110.         If MsgBox("真的要删除这条文件记录么?", vbOKCancel + vbExclamation, "警告") = vbOK Then
  111.             intCount = msgList.Row
  112.             sSql = "delete from " & msTableName & " where clid='" & Trim(msgList.TextMatrix(msgList.Row, 1)) & "'"
  113.             dbHuaxia.Execute sSql, dbSQLPassThrough
  114.             ShowData
  115.             If msgList.Rows > 1 Then
  116.                 If intCount = msgList.Rows Then
  117.                     MovCursor msgList.Rows - 1, msgList
  118.                 Else
  119.                     MovCursor intCount, msgList
  120.                 End If
  121.             End If
  122.         End If
  123.     End If
  124.     
  125.     Exit Sub
  126.     
  127. myErr:
  128.     ShowError
  129. End Sub
  130. Public Sub RecordRefresh()
  131.     '设置msSql
  132.     msSql = msSelect & msTableName & msOrderBy
  133.         
  134.     '显示数据
  135.     msBarText = "当前数据时间范围:所有时间段"
  136.     sOrder0 = "+ {clid}"
  137.     sOrder1 = ""
  138.     ShowData
  139. End Sub
  140. Public Sub RecordAdd()
  141.     gintmode = Add
  142.     frmVehicle1.Show 1
  143.     ShowData
  144. End Sub
  145. Public Sub RecordFind()
  146.     frmVehicle2.Show 1
  147.     If Trim(frmVehicle2.sQSql & " ") <> "" Then
  148.         msSql = msSelect & msTableName & " where" & frmVehicle2.sQSql & msOrderBy
  149.         ShowData
  150.     End If
  151.     Unload frmVehicle2
  152. End Sub
  153. Private Sub Form_Unload(Cancel As Integer)
  154.     flagvEdit = False
  155.     gintvMode = 0
  156. End Sub
  157. '显示Grid的内容
  158. Private Sub ShowData()
  159.     Dim j As Integer
  160.     Dim i As Integer
  161.     Set mrc = ExecuteSQL(txtSQL, MsgText)
  162.     With msgList
  163.         .Rows = 1
  164.         
  165.         Do While Not mrc.EOF
  166.             .Rows = .Rows + 1
  167.             For i = 1 To mrc.Fields.Count
  168.                 Select Case mrc.Fields(i - 1).Type
  169.                     Case adDBDate
  170.                         .TextMatrix(.Rows - 1, i) = Format(mrc.Fields(i - 1) & "", "yyyy-mm-dd")
  171.                     Case Else
  172.                         .TextMatrix(.Rows - 1, i) = mrc.Fields(i - 1) & ""
  173.                 End Select
  174.             Next i
  175.             mrc.MoveNext
  176.         Loop
  177.     End With
  178.     mrc.Close
  179. End Sub
  180. '显示Grid表头
  181. Private Sub ShowTitle()
  182.     Dim i As Integer
  183.     
  184.     With msgList
  185.         .Cols = 13
  186.         .TextMatrix(0, 1) = "车号"
  187.         .TextMatrix(0, 2) = "类型"
  188.         .TextMatrix(0, 3) = "车主"
  189.         .TextMatrix(0, 4) = "发动机号"
  190.         .TextMatrix(0, 5) = "车架号"
  191.         .TextMatrix(0, 6) = "厂牌型号"
  192.         .TextMatrix(0, 7) = "总质量"
  193.         .TextMatrix(0, 8) = "核定载客"
  194.         .TextMatrix(0, 9) = "登记时间"
  195.         .TextMatrix(0, 10) = "发证时间"
  196.         .TextMatrix(0, 11) = "颜色"
  197.         .TextMatrix(0, 12) = "主要司机"
  198.         
  199.         '固定表头
  200.         .FixedRows = 1
  201.                 
  202.         '设置各列的对齐方式
  203.         For i = 0 To 6
  204.             .ColAlignment(i) = 0
  205.         Next i
  206.         For i = 7 To 8
  207.             .ColAlignment(i) = 7
  208.         Next i
  209.         For i = 9 To 12
  210.             .ColAlignment(i) = 0
  211.         Next i
  212.         
  213.         '表头项居中
  214.         .FillStyle = flexFillRepeat
  215.         .Col = 0
  216.         .Row = 0
  217.         .RowSel = 1
  218.         .ColSel = .Cols - 1
  219.         .CellAlignment = 4
  220.         
  221.         '设置单元大小
  222.         .ColWidth(0) = 300
  223.         .ColWidth(1) = 1000
  224.         .ColWidth(2) = 1000
  225.         .ColWidth(3) = 2000
  226.         .ColWidth(4) = 1000
  227.         .ColWidth(5) = 1000
  228.         .ColWidth(6) = 2000
  229.         .ColWidth(7) = 1000
  230.         .ColWidth(8) = 1000
  231.         .ColWidth(9) = 1000
  232.         .ColWidth(10) = 1000
  233.         .ColWidth(11) = 1000
  234.         .ColWidth(12) = 1000
  235.         .Row = 1
  236.     End With
  237. End Sub
  238. Private Sub msgList_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  239.     '右键弹出
  240.     If Button = 2 And Shift = 0 Then
  241.         PopupMenu fMainForm.menuCars
  242.     End If
  243.     
  244.     
  245. End Sub