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

交通/航空行业

开发平台:

Visual Basic

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