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

交通/航空行业

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Begin VB.Form frmVehicle1 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "车辆信息"
  5.    ClientHeight    =   3444
  6.    ClientLeft      =   48
  7.    ClientTop       =   336
  8.    ClientWidth     =   7932
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   3444
  13.    ScaleWidth      =   7932
  14.    ShowInTaskbar   =   0   'False
  15.    StartUpPosition =   1  'CenterOwner
  16.    Begin VB.Frame Frame2 
  17.       Caption         =   "车辆相关信息"
  18.       Height          =   2655
  19.       Left            =   4080
  20.       TabIndex        =   20
  21.       Top             =   240
  22.       Width           =   3615
  23.       Begin VB.TextBox txtItem 
  24.          Height          =   270
  25.          Index           =   11
  26.          Left            =   1200
  27.          MaxLength       =   10
  28.          TabIndex        =   11
  29.          Top             =   2160
  30.          Width           =   2175
  31.       End
  32.       Begin VB.TextBox txtItem 
  33.          Height          =   270
  34.          Index           =   10
  35.          Left            =   1200
  36.          MaxLength       =   4
  37.          TabIndex        =   10
  38.          Top             =   1800
  39.          Width           =   2175
  40.       End
  41.       Begin VB.TextBox txtItem 
  42.          Height          =   270
  43.          Index           =   9
  44.          Left            =   1200
  45.          MaxLength       =   20
  46.          TabIndex        =   9
  47.          Top             =   1440
  48.          Width           =   2175
  49.       End
  50.       Begin VB.TextBox txtItem 
  51.          Height          =   270
  52.          Index           =   8
  53.          Left            =   1200
  54.          MaxLength       =   20
  55.          TabIndex        =   8
  56.          Top             =   1080
  57.          Width           =   2175
  58.       End
  59.       Begin VB.TextBox txtItem 
  60.          Height          =   270
  61.          Index           =   7
  62.          Left            =   1200
  63.          MaxLength       =   2
  64.          TabIndex        =   7
  65.          Top             =   720
  66.          Width           =   2175
  67.       End
  68.       Begin VB.TextBox txtItem 
  69.          Height          =   270
  70.          Index           =   6
  71.          Left            =   1200
  72.          MaxLength       =   8
  73.          TabIndex        =   6
  74.          Top             =   360
  75.          Width           =   2175
  76.       End
  77.       Begin VB.Label Label2 
  78.          Caption         =   "主要司机:"
  79.          Height          =   255
  80.          Index           =   10
  81.          Left            =   240
  82.          TabIndex        =   27
  83.          Top             =   2160
  84.          Width           =   975
  85.       End
  86.       Begin VB.Label Label2 
  87.          Caption         =   "颜    色:"
  88.          Height          =   255
  89.          Index           =   9
  90.          Left            =   240
  91.          TabIndex        =   26
  92.          Top             =   1800
  93.          Width           =   975
  94.       End
  95.       Begin VB.Label Label2 
  96.          Caption         =   "发证时间:"
  97.          Height          =   255
  98.          Index           =   8
  99.          Left            =   240
  100.          TabIndex        =   25
  101.          Top             =   1440
  102.          Width           =   975
  103.       End
  104.       Begin VB.Label Label2 
  105.          Caption         =   "登记时间:"
  106.          Height          =   255
  107.          Index           =   7
  108.          Left            =   240
  109.          TabIndex        =   24
  110.          Top             =   1080
  111.          Width           =   975
  112.       End
  113.       Begin VB.Label Label2 
  114.          Caption         =   "核定载客:"
  115.          Height          =   255
  116.          Index           =   5
  117.          Left            =   240
  118.          TabIndex        =   22
  119.          Top             =   720
  120.          Width           =   975
  121.       End
  122.       Begin VB.Label Label2 
  123.          Caption         =   "总 质 量:"
  124.          Height          =   255
  125.          Index           =   4
  126.          Left            =   240
  127.          TabIndex        =   21
  128.          Top             =   360
  129.          Width           =   975
  130.       End
  131.    End
  132.    Begin VB.Frame Frame1 
  133.       Caption         =   "车辆基本信息"
  134.       Height          =   2655
  135.       Left            =   240
  136.       TabIndex        =   14
  137.       Top             =   240
  138.       Width           =   3735
  139.       Begin VB.TextBox txtItem 
  140.          Height          =   270
  141.          Index           =   5
  142.          Left            =   1320
  143.          MaxLength       =   20
  144.          TabIndex        =   5
  145.          Top             =   2160
  146.          Width           =   2175
  147.       End
  148.       Begin VB.TextBox txtItem 
  149.          Height          =   270
  150.          Index           =   4
  151.          Left            =   1320
  152.          MaxLength       =   10
  153.          TabIndex        =   4
  154.          Top             =   1800
  155.          Width           =   2175
  156.       End
  157.       Begin VB.TextBox txtItem 
  158.          Height          =   270
  159.          Index           =   0
  160.          Left            =   1320
  161.          MaxLength       =   10
  162.          TabIndex        =   0
  163.          Top             =   360
  164.          Width           =   2175
  165.       End
  166.       Begin VB.TextBox txtItem 
  167.          Height          =   270
  168.          Index           =   1
  169.          Left            =   1320
  170.          MaxLength       =   10
  171.          TabIndex        =   1
  172.          Top             =   720
  173.          Width           =   2175
  174.       End
  175.       Begin VB.TextBox txtItem 
  176.          Height          =   270
  177.          Index           =   2
  178.          Left            =   1320
  179.          MaxLength       =   20
  180.          TabIndex        =   2
  181.          Top             =   1080
  182.          Width           =   2175
  183.       End
  184.       Begin VB.TextBox txtItem 
  185.          Height          =   270
  186.          Index           =   3
  187.          Left            =   1320
  188.          MaxLength       =   10
  189.          TabIndex        =   3
  190.          Top             =   1440
  191.          Width           =   2175
  192.       End
  193.       Begin VB.Label Label2 
  194.          Caption         =   "车    主:"
  195.          Height          =   255
  196.          Index           =   6
  197.          Left            =   240
  198.          TabIndex        =   23
  199.          Top             =   1080
  200.          Width           =   975
  201.       End
  202.       Begin VB.Label Label2 
  203.          Caption         =   "车 架 号:"
  204.          Height          =   255
  205.          Index           =   3
  206.          Left            =   240
  207.          TabIndex        =   19
  208.          Top             =   1800
  209.          Width           =   975
  210.       End
  211.       Begin VB.Label Label2 
  212.          Caption         =   "车    号:"
  213.          Height          =   255
  214.          Index           =   0
  215.          Left            =   240
  216.          TabIndex        =   18
  217.          Top             =   360
  218.          Width           =   975
  219.       End
  220.       Begin VB.Label Label2 
  221.          Caption         =   "类    型:"
  222.          Height          =   255
  223.          Index           =   1
  224.          Left            =   240
  225.          TabIndex        =   17
  226.          Top             =   720
  227.          Width           =   975
  228.       End
  229.       Begin VB.Label Label2 
  230.          Caption         =   "厂牌型号:"
  231.          Height          =   255
  232.          Index           =   2
  233.          Left            =   240
  234.          TabIndex        =   16
  235.          Top             =   2160
  236.          Width           =   975
  237.       End
  238.       Begin VB.Label Label2 
  239.          Caption         =   "发动机号:"
  240.          Height          =   255
  241.          Index           =   16
  242.          Left            =   240
  243.          TabIndex        =   15
  244.          Top             =   1440
  245.          Width           =   975
  246.       End
  247.    End
  248.    Begin VB.CommandButton cmdExit 
  249.       Caption         =   "返回 (&X)"
  250.       Height          =   375
  251.       Left            =   6240
  252.       TabIndex        =   13
  253.       Top             =   3000
  254.       Width           =   1215
  255.    End
  256.    Begin VB.CommandButton cmdSave 
  257.       Caption         =   "保存 (&S)"
  258.       Height          =   375
  259.       Left            =   4800
  260.       TabIndex        =   12
  261.       Top             =   3000
  262.       Width           =   1215
  263.    End
  264. End
  265. Attribute VB_Name = "frmVehicle1"
  266. Attribute VB_GlobalNameSpace = False
  267. Attribute VB_Creatable = False
  268. Attribute VB_PredeclaredId = True
  269. Attribute VB_Exposed = False
  270. Option Explicit
  271. '是否改动过记录,ture为改过
  272. Dim mblChange As Boolean
  273. Dim mrc As ADODB.Recordset
  274. Public txtSQL As String
  275. Private Sub cmdExit_Click()
  276.     If mblChange And cmdSave.Enabled Then
  277.         If MsgBox("保存当前记录的变化吗?", vbOKCancel + vbExclamation, "警告") = vbOK Then
  278.             '保存
  279.             Call cmdSave_Click
  280.         End If
  281.     End If
  282.     Unload Me
  283. End Sub
  284. Private Sub cmdSave_Click()
  285.     Dim intCount As Integer
  286.     Dim sMeg As String
  287.     Dim MsgText As String
  288.       
  289.   
  290.     For intCount = 0 To 3
  291.         If Trim(txtItem(intCount) & " ") = "" Then
  292.             Select Case intCount
  293.                 Case 0
  294.                     sMeg = "车号"
  295.                 Case 1
  296.                     sMeg = "类型"
  297.                 Case 2
  298.                     sMeg = "车主"
  299.                 Case 3
  300.                     sMeg = "发动机号"
  301.             End Select
  302.             sMeg = sMeg & "不能为空!"
  303.             MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
  304.             txtItem(intCount).SetFocus
  305.         
  306.             Exit Sub
  307.         End If
  308.     Next intCount
  309.    
  310.     For intCount = 6 To 7
  311.         If Not IsNumeric(txtItem(intCount)) Then
  312.             MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
  313.             Exit Sub
  314.         End If
  315.     Next intCount
  316.     
  317.     If Trim(txtItem(8) & "") <> "" Then
  318.         If Not IsDate(txtItem(8)) Then
  319.             MsgBox "登记时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
  320.             txtItem(8).SetFocus
  321.             
  322.             Exit Sub
  323.         Else
  324.             txtItem(8) = Format(txtItem(8), "yyyy-mm-dd")
  325.         End If
  326.     End If
  327.     
  328.     If Trim(txtItem(9) & "") <> "" Then
  329.         If Not IsDate(txtItem(9)) Then
  330.             MsgBox "发证时间应输入日期(yyyy-mm-dd)!", vbOKOnly + vbExclamation, "警告"
  331.             txtItem(9).SetFocus
  332.             
  333.             Exit Sub
  334.         Else
  335.             txtItem(9) = Format(txtItem(9), "yyyy-mm-dd")
  336.         End If
  337.     End If
  338.     
  339.     '添加判断是否有相同的ID记录
  340.     If gintvMode = 1 Then
  341.         txtSQL = "select * from vehicle where clid='" & Trim(txtItem(0)) & "'"
  342.         Set mrc = ExecuteSQL(txtSQL, MsgText)
  343.         If mrc.EOF = False Then
  344.             MsgBox "已经存在此车号的记录!", vbOKOnly + vbExclamation, "警告"
  345.             txtItem(0).SetFocus
  346.             Exit Sub
  347.         End If
  348.         mrc.Close
  349.     End If
  350.      
  351.       
  352.     '先删除已有记录
  353.     txtSQL = "delete from vehicle where clid='" & Trim(txtItem(0)) & "'"
  354.     Set mrc = ExecuteSQL(txtSQL, MsgText)
  355.    
  356.     
  357.     '再加入新记录
  358.     txtSQL = "select * from vehicle"
  359.     Set mrc = ExecuteSQL(txtSQL, MsgText)
  360.     mrc.AddNew
  361.     
  362.     mrc.Fields(0) = Trim(txtItem(0))
  363.     
  364.     For intCount = 1 To 11
  365.         mrc.Fields(intCount) = Trim(txtItem(intCount))
  366.     Next intCount
  367.     
  368.     
  369.     
  370.     mrc.Update
  371.     mrc.Close
  372.     
  373.     If gintvMode = 1 Then
  374.         For intCount = 0 To 11
  375.         txtItem(intCount) = ""
  376.         Next intCount
  377.         mblChange = False
  378.     ElseIf gintvMode = 2 Then
  379.         Unload Me
  380.         If flagvEdit Then
  381.             Unload frmVehicle
  382.         End If
  383.         txtSQL = "select * from vehicle"
  384.         frmVehicle.Show
  385.     End If
  386.  End Sub
  387. Private Sub Form_Load()
  388.     Dim MsgText As String
  389.     Dim intCount As Integer
  390.        
  391.     If gintvMode = 1 Then
  392.         Me.Caption = Me.Caption & "添加"
  393.         
  394.     ElseIf gintvMode = 2 Then
  395.        
  396.         
  397.         Set mrc = ExecuteSQL(txtSQL, MsgText)
  398.         
  399.         If mrc.EOF = False Then
  400.             With mrc
  401.                 For intCount = 0 To 11
  402.                     If Trim(.Fields(intCount) & " ") <> "" Then
  403.                         txtItem(intCount) = .Fields(intCount)
  404.                     End If
  405.                 Next intCount
  406.                
  407.             End With
  408.             txtItem(0).Enabled = False
  409.         End If
  410.         
  411.         Me.Caption = Me.Caption & "修改"
  412.             
  413.         mrc.Close
  414.     End If
  415.     
  416.     mblChange = False
  417.     End Sub
  418. Private Sub Form_Unload(Cancel As Integer)
  419.     gintvMode = 0
  420. End Sub
  421. Private Sub txtItem_Change(Index As Integer)
  422.     '有变化设置gblchange
  423.     mblChange = True
  424. End Sub
  425. Private Sub txtItem_GotFocus(Index As Integer)
  426.     txtItem(Index).SelStart = 0
  427.     txtItem(Index).SelLength = Len(txtItem(Index))
  428. End Sub
  429. Private Sub txtItem_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer)
  430.     EnterToTab KeyCode
  431. End Sub