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

交通/航空行业

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
  3. Begin VB.Form frmDriver 
  4.    Caption         =   "司机列表"
  5.    ClientHeight    =   4476
  6.    ClientLeft      =   60
  7.    ClientTop       =   348
  8.    ClientWidth     =   6996
  9.    Icon            =   "frmDriver.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MDIChild        =   -1  'True
  12.    ScaleHeight     =   4476
  13.    ScaleWidth      =   6996
  14.    WindowState     =   2  'Maximized
  15.    Begin MSFlexGridLib.MSFlexGrid msgList 
  16.       Height          =   3135
  17.       Left            =   240
  18.       TabIndex        =   1
  19.       Top             =   600
  20.       Width           =   6255
  21.       _ExtentX        =   11028
  22.       _ExtentY        =   5525
  23.       _Version        =   393216
  24.       Cols            =   4
  25.       FixedCols       =   3
  26.       AllowUserResizing=   1
  27.    End
  28.    Begin VB.Label lblTitle 
  29.       Caption         =   "司    机    列    表"
  30.       BeginProperty Font 
  31.          Name            =   "宋体"
  32.          Size            =   12
  33.          Charset         =   134
  34.          Weight          =   700
  35.          Underline       =   0   'False
  36.          Italic          =   0   'False
  37.          Strikethrough   =   0   'False
  38.       EndProperty
  39.       ForeColor       =   &H8000000D&
  40.       Height          =   255
  41.       Left            =   240
  42.       TabIndex        =   0
  43.       Top             =   120
  44.       Width           =   3015
  45.    End
  46. End
  47. Attribute VB_Name = "frmDriver"
  48. Attribute VB_GlobalNameSpace = False
  49. Attribute VB_Creatable = False
  50. Attribute VB_PredeclaredId = True
  51. Attribute VB_Exposed = False
  52. Option Explicit
  53. Public txtSQL As String
  54. Dim mrc As ADODB.Recordset
  55. Dim MsgText As String
  56. Private Sub Form_Load()
  57.     ShowTitle
  58.     ShowData
  59.     flagdEdit = True
  60. End Sub
  61. Private Sub Form_Resize()
  62.     If Me.WindowState <> vbMinimized And fMainForm.WindowState <> vbMinimized Then
  63.         '边界处理
  64.         If Me.ScaleHeight < 10 * lblTitle.Height Then
  65.             
  66.             Exit Sub
  67.         End If
  68.         If Me.ScaleWidth < lblTitle.Width + lblTitle.Width / 2 Then
  69.             
  70.             Exit Sub
  71.         End If
  72.         '控制控件的位置
  73.                 
  74.         lblTitle.Top = lblTitle.Height
  75.         lblTitle.Left = (Me.Width - lblTitle.Width) / 2
  76.         
  77.         msgList.Top = lblTitle.Top + lblTitle.Height + lblTitle.Height / 2
  78.         msgList.Width = Me.ScaleWidth - 200
  79.         msgList.Left = Me.ScaleLeft + 100
  80.         msgList.Height = Me.ScaleHeight - msgList.Top - 200
  81.     End If
  82. End Sub
  83. Public Sub RecordEdit()
  84.     Dim intCount As Integer
  85.     
  86.     If msgList.Rows > 1 Then
  87.         gintmode = EDIT
  88.         intCount = msgList.Row
  89.         gsSql = " where sjid='" & Trim(msgList.TextMatrix(msgList.Row, 1)) & "'"
  90.         frmDriver1.Show 1
  91.         ShowData
  92.         Call MovCursor(intCount, msgList)
  93.     Else
  94.         Call RecordAdd
  95.     End If
  96. End Sub
  97. Public Sub FormClose()
  98.     flagdEdit = False
  99.     gintdMode = 0
  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 sjid='" & 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. Private Sub Form_Unload(Cancel As Integer)
  131.     flagdEdit = False
  132.     gintdMode = 0
  133. End Sub
  134. '显示Grid的内容
  135. Public Sub ShowData()
  136.     Dim j As Integer
  137.     Dim i As Integer
  138.         
  139.     Set mrc = ExecuteSQL(txtSQL, MsgText)
  140.     With msgList
  141.         .Rows = 1
  142.         
  143.         Do While Not mrc.EOF
  144.             .Rows = .Rows + 1
  145.             For i = 1 To mrc.Fields.Count
  146.                 Select Case mrc.Fields(i - 1).Type
  147.                     Case adDBDate
  148.                         .TextMatrix(.Rows - 1, i) = Format(mrc.Fields(i - 1) & "", "yyyy-mm-dd")
  149.                     Case Else
  150.                         .TextMatrix(.Rows - 1, i) = mrc.Fields(i - 1) & ""
  151.                 End Select
  152.             Next i
  153.             mrc.MoveNext
  154.         Loop
  155.               
  156.         
  157.     End With
  158.     mrc.Close
  159.     
  160. End Sub
  161. '显示Grid表头
  162. Public Sub ShowTitle()
  163.     Dim i As Integer
  164.     
  165.     With msgList
  166.         .Cols = 10
  167.         .TextMatrix(0, 1) = "执照号码"
  168.         .TextMatrix(0, 2) = "姓名"
  169.         .TextMatrix(0, 3) = "性别"
  170.         .TextMatrix(0, 4) = "出生年月"
  171.         .TextMatrix(0, 5) = "住址"
  172.         .TextMatrix(0, 6) = "初次领证时间"
  173.         .TextMatrix(0, 7) = "准驾车型"
  174.         .TextMatrix(0, 8) = "有效期起始日期"
  175.         .TextMatrix(0, 9) = "有效期结束日期"
  176.         
  177.         
  178.         '固定表头
  179.         .FixedRows = 1
  180.                 
  181.         '设置各列的对齐方式
  182.         For i = 0 To 9
  183.             .ColAlignment(i) = 0
  184.         Next i
  185.         
  186.         '表头项居中
  187.         .FillStyle = flexFillRepeat
  188.         .Col = 0
  189.         .Row = 0
  190.         .RowSel = 1
  191.         .ColSel = .Cols - 1
  192.         .CellAlignment = 4
  193.         
  194.         '设置单元大小
  195.         .ColWidth(0) = 300
  196.         .ColWidth(1) = 1000
  197.         .ColWidth(2) = 1000
  198.         .ColWidth(3) = 600
  199.         .ColWidth(4) = 1000
  200.         .ColWidth(5) = 3000
  201.         .ColWidth(6) = 1200
  202.         .ColWidth(7) = 1000
  203.         .ColWidth(8) = 1400
  204.         .ColWidth(9) = 1400
  205.         .Row = 1
  206.         
  207.     End With
  208. End Sub
  209. Private Sub msgList_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  210.     '右键弹出
  211.     If Button = 2 And Shift = 0 Then
  212.         PopupMenu fMainForm.menuDrivers
  213.     End If
  214.     
  215.     
  216. End Sub