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

交通/航空行业

开发平台:

Visual Basic

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