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

交通/航空行业

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Begin VB.Form frmAcc2 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "车辆事故查询"
  5.    ClientHeight    =   2256
  6.    ClientLeft      =   48
  7.    ClientTop       =   336
  8.    ClientWidth     =   4704
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   2256
  13.    ScaleWidth      =   4704
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   1  'CenterOwner
  16.    Begin VB.Frame Frame1 
  17.       Height          =   1095
  18.       Left            =   1560
  19.       TabIndex        =   11
  20.       Top             =   600
  21.       Width           =   2895
  22.       Begin VB.ComboBox cboMonth 
  23.          Height          =   300
  24.          Index           =   0
  25.          Left            =   1845
  26.          Style           =   2  'Dropdown List
  27.          TabIndex        =   2
  28.          Top             =   240
  29.          Width           =   645
  30.       End
  31.       Begin VB.ComboBox cboMonth 
  32.          Height          =   300
  33.          Index           =   1
  34.          Left            =   1845
  35.          Style           =   2  'Dropdown List
  36.          TabIndex        =   4
  37.          Top             =   690
  38.          Width           =   645
  39.       End
  40.       Begin VB.ComboBox cboYear 
  41.          Height          =   300
  42.          Index           =   0
  43.          Left            =   675
  44.          Style           =   2  'Dropdown List
  45.          TabIndex        =   1
  46.          Top             =   240
  47.          Width           =   765
  48.       End
  49.       Begin VB.ComboBox cboYear 
  50.          Height          =   300
  51.          Index           =   1
  52.          Left            =   675
  53.          Style           =   2  'Dropdown List
  54.          TabIndex        =   3
  55.          Top             =   690
  56.          Width           =   765
  57.       End
  58.       Begin VB.Label Label1 
  59.          Caption         =   "月"
  60.          Height          =   210
  61.          Index           =   7
  62.          Left            =   2520
  63.          TabIndex        =   17
  64.          Top             =   720
  65.          Width           =   240
  66.       End
  67.       Begin VB.Label Label1 
  68.          Caption         =   "从:"
  69.          Height          =   210
  70.          Index           =   6
  71.          Left            =   240
  72.          TabIndex        =   16
  73.          Top             =   240
  74.          Width           =   375
  75.       End
  76.       Begin VB.Label Label1 
  77.          Caption         =   "年"
  78.          Height          =   210
  79.          Index           =   1
  80.          Left            =   1515
  81.          TabIndex        =   15
  82.          Top             =   240
  83.          Width           =   240
  84.       End
  85.       Begin VB.Label Label1 
  86.          Caption         =   "月"
  87.          Height          =   210
  88.          Index           =   2
  89.          Left            =   2520
  90.          TabIndex        =   14
  91.          Top             =   240
  92.          Width           =   240
  93.       End
  94.       Begin VB.Label Label1 
  95.          Caption         =   "到:"
  96.          Height          =   210
  97.          Index           =   3
  98.          Left            =   255
  99.          TabIndex        =   13
  100.          Top             =   735
  101.          Width           =   375
  102.       End
  103.       Begin VB.Label Label1 
  104.          Caption         =   "年"
  105.          Height          =   210
  106.          Index           =   4
  107.          Left            =   1545
  108.          TabIndex        =   12
  109.          Top             =   735
  110.          Width           =   225
  111.       End
  112.    End
  113.    Begin VB.CheckBox chkItem 
  114.       Caption         =   "Check1"
  115.       Height          =   180
  116.       Index           =   1
  117.       Left            =   240
  118.       TabIndex        =   10
  119.       Top             =   720
  120.       Width           =   255
  121.    End
  122.    Begin VB.CheckBox chkItem 
  123.       Caption         =   "Check1"
  124.       Height          =   180
  125.       Index           =   0
  126.       Left            =   240
  127.       TabIndex        =   9
  128.       Top             =   240
  129.       Value           =   1  'Checked
  130.       Width           =   255
  131.    End
  132.    Begin VB.CommandButton cmdOk 
  133.       Caption         =   "确定 (&O)"
  134.       Default         =   -1  'True
  135.       Height          =   375
  136.       Left            =   960
  137.       TabIndex        =   5
  138.       Top             =   1800
  139.       Width           =   1215
  140.    End
  141.    Begin VB.CommandButton cmdExit 
  142.       Caption         =   "取消 (&X)"
  143.       Height          =   375
  144.       Left            =   2520
  145.       TabIndex        =   6
  146.       Top             =   1800
  147.       Width           =   1215
  148.    End
  149.    Begin VB.TextBox txtItem 
  150.       Height          =   270
  151.       Index           =   0
  152.       Left            =   1560
  153.       TabIndex        =   0
  154.       Top             =   240
  155.       Width           =   2895
  156.    End
  157.    Begin VB.Label lblitem 
  158.       Caption         =   "时    间:"
  159.       Height          =   255
  160.       Index           =   1
  161.       Left            =   600
  162.       TabIndex        =   8
  163.       Top             =   720
  164.       Width           =   1095
  165.    End
  166.    Begin VB.Label lblitem 
  167.       Caption         =   "车 牌 号:"
  168.       Height          =   255
  169.       Index           =   0
  170.       Left            =   600
  171.       TabIndex        =   7
  172.       Top             =   240
  173.       Width           =   1095
  174.    End
  175. End
  176. Attribute VB_Name = "frmAcc2"
  177. Attribute VB_GlobalNameSpace = False
  178. Attribute VB_Creatable = False
  179. Attribute VB_PredeclaredId = True
  180. Attribute VB_Exposed = False
  181. Option Explicit
  182. Private Sub cboMonth_Click(Index As Integer)
  183. If cboMonth(0) <> "" And cboMonth(1) <> "" Then
  184. If CInt(cboYear(0)) = CInt(cboYear(1)) Then
  185.     Select Case Index
  186.         Case 0
  187.             If CInt(cboMonth(Index)) > CInt(cboMonth(1)) Then
  188.                 cboMonth(Index) = cboMonth(1)
  189.             End If
  190.         Case 1
  191.             If CInt(cboMonth(Index)) < CInt(cboMonth(0)) Then
  192.                 cboMonth(Index) = cboMonth(0)
  193.             End If
  194.     End Select
  195.     End If
  196. End If
  197. End Sub
  198. Private Sub cboYear_Click(Index As Integer)
  199. If cboYear(0) <> "" And cboYear(1) <> "" Then
  200. Select Case Index
  201.         Case 0
  202.             If CInt(cboYear(Index)) > CInt(cboYear(1)) Then
  203.                 cboYear(Index) = cboYear(1)
  204.             End If
  205.         Case 1
  206.             If CInt(cboYear(Index)) < CInt(cboYear(1)) Then
  207.                 cboYear(Index) = cboYear(0)
  208.             End If
  209.     End Select
  210.     Call cboMonth_Click(Index)
  211. End If
  212. End Sub
  213. Private Sub chkItem_Click(Index As Integer)
  214.     If Index = 1 Then
  215.         cboYear(0).SetFocus
  216.     Else
  217.         txtItem(Index).SetFocus
  218.     End If
  219. End Sub
  220. Private Sub cmdExit_Click()
  221.     Me.Hide
  222. End Sub
  223. Private Sub cmdOK_Click()
  224.     Dim dBeginDate As String
  225.     Dim dEndDateTemp As Date
  226.     Dim dEndDate As String
  227.     Dim txtSQL As String
  228.     
  229.     If chkItem(0).Value = vbChecked Then
  230.         txtSQL = " sgid ='" & Trim(txtItem(0) & " ") & "'"
  231.     End If
  232.     
  233.     If chkItem(1).Value = vbChecked Then
  234.         dBeginDate = Format(CDate(cboYear(0) & "-" & cboMonth(0) & "-1"), "yyyy-mm-dd")
  235.         dEndDateTemp = DateAdd("d", -1, DateAdd("m", 1, DateSerial(CInt(cboYear(1)), CInt(cboMonth(1)), 1)))
  236.         dEndDate = Format(dEndDateTemp, "yyyy-mm-dd")
  237.         
  238.         If Trim(txtSQL & " ") = "" Then
  239.             txtSQL = " sgdate>='" & dBeginDate & "' and sgdate<='" & dEndDate & "'"
  240.         Else
  241.             txtSQL = txtSQL & " and (sgdate>='" & dBeginDate & "' and sgdate<='" & dEndDate & "')"
  242.         End If
  243.     End If
  244.     If Trim(txtSQL) = "" Then
  245.         MsgBox "请设置查询方式!", vbOKOnly + vbExclamation, "警告"
  246.         Exit Sub
  247.     Else
  248.         If flagaEdit Then
  249.             Unload frmAcc
  250.         End If
  251.         frmAcc.txtSQL = "select sgid,sgdate,sgplace,sgreason,sgdriver,sgopp_dept,sgopp_id,sgmode,sgvalue,sgmemo from accident where" & txtSQL
  252.         frmAcc.Show
  253.     End If
  254.     Me.Hide
  255. End Sub
  256. Private Sub Form_Load()
  257.     Dim i As Integer
  258.     Dim j As Integer
  259.     Dim txtSQL As String
  260.     Dim mrc As ADODB.Recordset
  261.     Dim MsgText As String
  262.     
  263.   
  264.   
  265.     txtSQL = "select distinct datepart(yy,sgdate) from accident"
  266.     Set mrc = ExecuteSQL(txtSQL, MsgText)
  267.     If mrc.EOF = False Then
  268.         With mrc
  269.             Do While Not .EOF
  270.                 cboYear(0).AddItem .Fields(0)
  271.                 cboYear(1).AddItem .Fields(0)
  272.                 .MoveNext
  273.             Loop
  274.         End With
  275.         
  276.         For i = 0 To 1
  277.             cboYear(i).ListIndex = 0
  278.         Next i
  279.         
  280.         For i = 0 To 1
  281.             For j = 1 To 12
  282.                 cboMonth(i).AddItem j
  283.             Next j
  284.         Next i
  285.         For i = 0 To 1
  286.             cboMonth(i).Text = Month(Now())
  287.         Next i
  288.     Else
  289.         cmdOk.Enabled = False
  290.     End If
  291.     mrc.Close
  292.     
  293. End Sub
  294. Private Sub lblitem_Click(Index As Integer)
  295.     chkItem(Index).Value = vbChecked
  296. End Sub
  297. Private Sub txtItem_GotFocus(Index As Integer)
  298.     txtItem(Index).SelStart = 0
  299.     txtItem(Index).SelLength = Len(txtItem(Index))
  300. End Sub