frmAcc.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 frmAcc 
  4.    Caption         =   "车辆事故列表"
  5.    ClientHeight    =   4140
  6.    ClientLeft      =   60
  7.    ClientTop       =   348
  8.    ClientWidth     =   6792
  9.    Icon            =   "frmAcc.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MDIChild        =   -1  'True
  12.    ScaleHeight     =   4140
  13.    ScaleWidth      =   6792
  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             =   240
  44.       Width           =   3015
  45.    End
  46. End
  47. Attribute VB_Name = "frmAcc"
  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.     flagaEdit = True
  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 sgid='" & Trim(msgList.TextMatrix(msgList.Row, 1)) & "' and sgdate=cdate('" & Format(msgList.TextMatrix(msgList.Row, 2), "yyyy-mm-dd") & "') and sgplace='" & Trim(msgList.TextMatrix(msgList.Row, 3)) & "'"
  91.         frmAcc1.Show 1
  92.         ShowData
  93.         Call MovCursor(intCount, msgList)
  94.     Else
  95.         Call RecordAdd
  96.     End If
  97. End Sub
  98. Public Sub FormClose()
  99.     Unload Me
  100. End Sub
  101. '删除记录
  102. Public Sub RecordDelete()
  103.     Dim sSql As String
  104.     Dim intCount As Integer
  105.     
  106.   On Error GoTo myErr
  107.     
  108.     If msgList.Rows > 1 Then
  109.         If MsgBox("真的要删除这条文件记录么?", vbOKCancel + vbExclamation, "警告") = vbOK Then
  110.             intCount = msgList.Row
  111.             sSql = "delete from " & msTableName & " where sgid='" & Trim(msgList.TextMatrix(msgList.Row, 1)) & "' and sgdate='" & Format(msgList.TextMatrix(msgList.Row, 2), "yyyy-mm-dd") & "' and sgplace='" & Trim(msgList.TextMatrix(msgList.Row, 3)) & "'"
  112.             dbHuaxia.Execute sSql, dbSQLPassThrough
  113.             ShowData
  114.             If msgList.Rows > 1 Then
  115.                 If intCount = msgList.Rows Then
  116.                     MovCursor msgList.Rows - 1, msgList
  117.                 Else
  118.                     MovCursor intCount, msgList
  119.                 End If
  120.             End If
  121.         End If
  122.     End If
  123.     
  124.     Exit Sub
  125.     
  126. myErr:
  127.     ShowError
  128. End Sub
  129. Public Sub RecordRefresh()
  130.     '设置msSql
  131.     msSql = msSelect & msTableName & " where sgdate>='" & Format(DateAdd("m", -1, Now), "yyyy-mm-dd") & "' and sgdate<='" & Format(Now, "yyyy-mm-dd") & "'" & msOrderBy
  132.         
  133.     '显示数据
  134.     msBarText = "当前数据时间范围:" & Format(DateAdd("m", -1, Now), "yyyy-mm-dd") & "至" & Format(Now, "yyyy-mm-dd")
  135.     
  136.     ShowData
  137.     '重新设置打印时排序顺序
  138.     sOrder0 = "+ {sgdate}"
  139.     sOrder1 = ""
  140. End Sub
  141. Public Sub RecordAdd()
  142.     gintmode = Add
  143.     frmAcc1.Show 1
  144.     ShowData
  145. End Sub
  146. Public Sub RecordFind()
  147.     frmAcc2.Show 1
  148.     
  149.     If Trim(frmAcc2.sQSql & " ") <> "" Then
  150.         msSql = msSelect & msTableName & " where" & frmAcc2.sQSql
  151.         msSql = msSql & msOrderBy
  152.         
  153.         ShowData
  154.     End If
  155.     Unload frmAcc2
  156. End Sub
  157. Private Sub Form_Unload(Cancel As Integer)
  158.     flagaEdit = False
  159.     gintaMode = 0
  160. End Sub
  161. '详细显示记录
  162. Public Sub RecordView()
  163.     If msgList.Rows > 1 = False Then
  164.         gintmode = View
  165.         gsSql = " where sgid='" & Trim(msgList.TextMatrix(msgList.Row, 1)) & "' and sgdate=cdate('" & Format(msgList.TextMatrix(msgList.Row, 2), "yyyy-mm-dd") & "') and sgplace='" & Trim(msgList.TextMatrix(msgList.Row, 3)) & "'"
  166.         frmAcc1.Show 1
  167.     End If
  168. End Sub
  169. '显示Grid的内容
  170. Private Sub ShowData()
  171.     
  172.     Dim j As Integer
  173.     Dim i As Integer
  174.   
  175.   
  176.     Set mrc = ExecuteSQL(txtSQL, MsgText)
  177.         With msgList
  178.         .Rows = 1
  179.         
  180.         Do While Not mrc.EOF
  181.             .Rows = .Rows + 1
  182.             For i = 1 To mrc.Fields.Count
  183.                 Select Case mrc.Fields(i - 1).Type
  184.                     Case adDBDate
  185.                         .TextMatrix(.Rows - 1, i) = Format(mrc.Fields(i - 1) & "", "yyyy-mm-dd")
  186.                     Case Else
  187.                         .TextMatrix(.Rows - 1, i) = mrc.Fields(i - 1) & ""
  188.                 End Select
  189.             Next i
  190.             mrc.MoveNext
  191.         Loop
  192.     End With
  193.     mrc.Close
  194. End Sub
  195. '显示Grid表头
  196. Private Sub ShowTitle()
  197.     Dim i As Integer
  198.     
  199.     With msgList
  200.         .Cols = 11
  201.         .TextMatrix(0, 1) = "车号"
  202.         .TextMatrix(0, 2) = "时间"
  203.         .TextMatrix(0, 3) = "地点"
  204.         .TextMatrix(0, 4) = "原因"
  205.         .TextMatrix(0, 5) = "司机"
  206.         .TextMatrix(0, 6) = "对方单位"
  207.         .TextMatrix(0, 7) = "对方车号"
  208.         .TextMatrix(0, 8) = "处理方式"
  209.         .TextMatrix(0, 9) = "处理金额"
  210.         .TextMatrix(0, 10) = "备注"
  211.         
  212.         
  213.         '固定表头
  214.         .FixedRows = 1
  215.                 
  216.         '设置各列的对齐方式
  217.         For i = 0 To 8
  218.             .ColAlignment(i) = 0
  219.         Next i
  220.         .ColAlignment(9) = 7
  221.         .ColAlignment(10) = 0
  222.         
  223.         '表头项居中
  224.         .FillStyle = flexFillRepeat
  225.         .Col = 0
  226.         .Row = 0
  227.         .RowSel = 1
  228.         .ColSel = .Cols - 1
  229.         .CellAlignment = 4
  230.         
  231.         '设置单元大小
  232.         .ColWidth(0) = 300
  233.         .ColWidth(1) = 1000
  234.         .ColWidth(2) = 1000
  235.         .ColWidth(3) = 3000
  236.         .ColWidth(4) = 3000
  237.         .ColWidth(5) = 1000
  238.         .ColWidth(6) = 3000
  239.         .ColWidth(7) = 1000
  240.         .ColWidth(8) = 3000
  241.         .ColWidth(9) = 1000
  242.         .ColWidth(10) = 1000
  243.         .Row = 1
  244.         
  245.     End With
  246. End Sub
  247. Private Sub msgList_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  248.     '右键弹出
  249.     If Button = 2 And Shift = 0 Then
  250.         PopupMenu fMainForm.menuAccident
  251.     End If
  252.     
  253. End Sub