frmLJ.frm
上传用户:naidiweb
上传日期:2013-08-15
资源大小:672k
文件大小:12k
开发平台:

WORD

  1. VERSION 5.00
  2. Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
  3. Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
  4. Begin VB.Form frmLJ 
  5.    Caption         =   "车辆添加零件"
  6.    ClientHeight    =   3120
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   5025
  10.    ForeColor       =   &H80000001&
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MDIChild        =   -1  'True
  14.    ScaleHeight     =   3120
  15.    ScaleWidth      =   5025
  16.    Begin VB.CommandButton Command1 
  17.       Caption         =   "尾记录"
  18.       Height          =   330
  19.       Index           =   3
  20.       Left            =   2955
  21.       TabIndex        =   14
  22.       Top             =   840
  23.       Width           =   975
  24.    End
  25.    Begin VB.CommandButton Command1 
  26.       Caption         =   "首记录"
  27.       Height          =   330
  28.       Index           =   0
  29.       Left            =   30
  30.       TabIndex        =   13
  31.       Top             =   840
  32.       Width           =   975
  33.    End
  34.    Begin VB.CommandButton Command1 
  35.       Caption         =   "下一条"
  36.       Height          =   330
  37.       Index           =   2
  38.       Left            =   1980
  39.       TabIndex        =   12
  40.       Top             =   840
  41.       Width           =   975
  42.    End
  43.    Begin VB.CommandButton Command1 
  44.       Caption         =   "上一条"
  45.       Height          =   330
  46.       Index           =   1
  47.       Left            =   1005
  48.       TabIndex        =   11
  49.       Top             =   840
  50.       Width           =   975
  51.    End
  52.    Begin MSDataGridLib.DataGrid DataGrid1 
  53.       Bindings        =   "frmLJ.frx":0000
  54.       Height          =   1470
  55.       Left            =   90
  56.       TabIndex        =   10
  57.       Top             =   1605
  58.       Width           =   4785
  59.       _ExtentX        =   8440
  60.       _ExtentY        =   2593
  61.       _Version        =   393216
  62.       AllowUpdate     =   0   'False
  63.       HeadLines       =   1
  64.       RowHeight       =   15
  65.       FormatLocked    =   -1  'True
  66.       BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  67.          Name            =   "宋体"
  68.          Size            =   9
  69.          Charset         =   134
  70.          Weight          =   400
  71.          Underline       =   0   'False
  72.          Italic          =   0   'False
  73.          Strikethrough   =   0   'False
  74.       EndProperty
  75.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  76.          Name            =   "宋体"
  77.          Size            =   9
  78.          Charset         =   134
  79.          Weight          =   400
  80.          Underline       =   0   'False
  81.          Italic          =   0   'False
  82.          Strikethrough   =   0   'False
  83.       EndProperty
  84.       ColumnCount     =   2
  85.       BeginProperty Column00 
  86.          DataField       =   "零件名"
  87.          Caption         =   "零件名"
  88.          BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
  89.             Type            =   0
  90.             Format          =   ""
  91.             HaveTrueFalseNull=   0
  92.             FirstDayOfWeek  =   0
  93.             FirstWeekOfYear =   0
  94.             LCID            =   2052
  95.             SubFormatType   =   0
  96.          EndProperty
  97.       EndProperty
  98.       BeginProperty Column01 
  99.          DataField       =   "单价"
  100.          Caption         =   "单价"
  101.          BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED} 
  102.             Type            =   0
  103.             Format          =   ""
  104.             HaveTrueFalseNull=   0
  105.             FirstDayOfWeek  =   0
  106.             FirstWeekOfYear =   0
  107.             LCID            =   2052
  108.             SubFormatType   =   0
  109.          EndProperty
  110.       EndProperty
  111.       SplitCount      =   1
  112.       BeginProperty Split0 
  113.          BeginProperty Column00 
  114.             ColumnWidth     =   3374.929
  115.          EndProperty
  116.          BeginProperty Column01 
  117.             ColumnWidth     =   959.811
  118.          EndProperty
  119.       EndProperty
  120.    End
  121.    Begin VB.CommandButton cmdAdd 
  122.       Caption         =   "添 加(&A)"
  123.       Height          =   330
  124.       Left            =   30
  125.       TabIndex        =   9
  126.       Top             =   1170
  127.       Width           =   975
  128.    End
  129.    Begin VB.CommandButton cmdok 
  130.       Caption         =   "确 定(&O)"
  131.       Enabled         =   0   'False
  132.       Height          =   330
  133.       Left            =   2955
  134.       TabIndex        =   8
  135.       Top             =   1170
  136.       Width           =   975
  137.    End
  138.    Begin VB.CommandButton cmdCancel 
  139.       Caption         =   "取 消(&Q)"
  140.       Enabled         =   0   'False
  141.       Height          =   330
  142.       Left            =   3930
  143.       TabIndex        =   7
  144.       Top             =   1170
  145.       Width           =   975
  146.    End
  147.    Begin VB.CommandButton cmdUpdate 
  148.       Caption         =   "修 改(&U)"
  149.       Height          =   330
  150.       Left            =   1005
  151.       TabIndex        =   6
  152.       Top             =   1170
  153.       Width           =   975
  154.    End
  155.    Begin VB.CommandButton cmdDelete 
  156.       Caption         =   "删 除(&D)"
  157.       Height          =   330
  158.       Left            =   1980
  159.       TabIndex        =   5
  160.       Top             =   1170
  161.       Width           =   975
  162.    End
  163.    Begin VB.Frame Frame1 
  164.       Caption         =   "汽车零件信息"
  165.       BeginProperty Font 
  166.          Name            =   "宋体"
  167.          Size            =   10.5
  168.          Charset         =   134
  169.          Weight          =   400
  170.          Underline       =   0   'False
  171.          Italic          =   0   'False
  172.          Strikethrough   =   0   'False
  173.       EndProperty
  174.       ForeColor       =   &H80000001&
  175.       Height          =   765
  176.       Left            =   30
  177.       TabIndex        =   0
  178.       Top             =   75
  179.       Width           =   4860
  180.       Begin MSAdodcLib.Adodc Adodc1 
  181.          Height          =   330
  182.          Left            =   3990
  183.          Top             =   -180
  184.          Visible         =   0   'False
  185.          Width           =   1200
  186.          _ExtentX        =   2117
  187.          _ExtentY        =   582
  188.          ConnectMode     =   0
  189.          CursorLocation  =   3
  190.          IsolationLevel  =   -1
  191.          ConnectionTimeout=   15
  192.          CommandTimeout  =   30
  193.          CursorType      =   3
  194.          LockType        =   3
  195.          CommandType     =   2
  196.          CursorOptions   =   0
  197.          CacheSize       =   50
  198.          MaxRecords      =   0
  199.          BOFAction       =   0
  200.          EOFAction       =   0
  201.          ConnectStringType=   1
  202.          Appearance      =   1
  203.          BackColor       =   12632256
  204.          ForeColor       =   -2147483647
  205.          Orientation     =   0
  206.          Enabled         =   -1
  207.          Connect         =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=clgl.mdb;Persist Security Info=False"
  208.          OLEDBString     =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=clgl.mdb;Persist Security Info=False"
  209.          OLEDBFile       =   ""
  210.          DataSourceName  =   ""
  211.          OtherAttributes =   ""
  212.          UserName        =   ""
  213.          Password        =   ""
  214.          RecordSource    =   "零件表"
  215.          Caption         =   "     浏览零件信息"
  216.          BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  217.             Name            =   "宋体"
  218.             Size            =   10.5
  219.             Charset         =   134
  220.             Weight          =   400
  221.             Underline       =   0   'False
  222.             Italic          =   0   'False
  223.             Strikethrough   =   0   'False
  224.          EndProperty
  225.          _Version        =   393216
  226.       End
  227.       Begin VB.TextBox Text2 
  228.          DataSource      =   "Adodc1"
  229.          Enabled         =   0   'False
  230.          Height          =   300
  231.          Left            =   3555
  232.          TabIndex        =   4
  233.          Top             =   330
  234.          Width           =   1200
  235.       End
  236.       Begin VB.TextBox Text1 
  237.          DataSource      =   "Adodc1"
  238.          Enabled         =   0   'False
  239.          Height          =   300
  240.          Left            =   990
  241.          TabIndex        =   3
  242.          Top             =   330
  243.          Width           =   1935
  244.       End
  245.       Begin VB.Label Label2 
  246.          Caption         =   "单价:"
  247.          Height          =   210
  248.          Left            =   3000
  249.          TabIndex        =   2
  250.          Top             =   330
  251.          Width           =   540
  252.       End
  253.       Begin VB.Label Label1 
  254.          Caption         =   "零件名称:"
  255.          Height          =   225
  256.          Left            =   105
  257.          TabIndex        =   1
  258.          Top             =   330
  259.          Width           =   930
  260.       End
  261.    End
  262. End
  263. Attribute VB_Name = "frmLJ"
  264. Attribute VB_GlobalNameSpace = False
  265. Attribute VB_Creatable = False
  266. Attribute VB_PredeclaredId = True
  267. Attribute VB_Exposed = False
  268. Dim i As Integer
  269. Private Sub Lockctl()
  270.    Text1.Enabled = False
  271.    Text2.Enabled = False
  272. End Sub
  273. Private Sub Unlockctl()
  274.    Text1.Enabled = True
  275.    Text2.Enabled = True
  276. End Sub
  277. Private Sub cmdAdd_Click()
  278.     Unlockctl
  279.     Text1 = ""
  280.     Text2 = ""
  281.     Text1.SetFocus
  282.     cmdok.Enabled = True
  283.     cmdCancel.Enabled = True
  284.     cmdUpdate.Enabled = False
  285.     cmdDelete.Enabled = False
  286.     i = 1
  287.     Adodc1.Enabled = False
  288. End Sub
  289. Private Sub cmdCancel_Click()
  290.     On Error Resume Next     '当没有添加数据的时候 处理异常
  291.     Adodc1.Recordset.CancelUpdate
  292.     Adodc1.Refresh
  293.     Lockctl
  294.     cmdCancel.Enabled = False
  295.     cmdok.Enabled = False
  296.     cmdAdd.Enabled = True
  297.     cmdUpdate.Enabled = True
  298.     cmdDelete.Enabled = True
  299.     Adodc1.Enabled = True
  300. End Sub
  301. Private Sub cmdDelete_Click()
  302.     If MsgBox("您确实要删除记录吗?", vbOKCancel, "系统提示") = vbOK Then
  303.         On Error Resume Next
  304. '        adoCon.Execute ("delete from 车辆违章表 where 零件名='" & Text1 & "'")
  305.          Adodc1.Recordset.Delete
  306.         MsgBox " 记录已删除!", , "系统提示"
  307.         Adodc1.Refresh
  308.     End If
  309.     Text1.Text = ""
  310.     Text2.Text = ""
  311. End Sub
  312. Private Sub cmdOk_Click()
  313.     Select Case i
  314.         Case 1
  315.             If Text1 = "" Then
  316.                 MsgBox "零件名称不能为空!", , "系统提示"
  317.                 Text1.SetFocus
  318.                 Exit Sub
  319.             End If
  320.             If Text2 = "" Then
  321.                 MsgBox "价格不能为空!", , "系统提示"
  322.                 Text2.SetFocus
  323.                 Exit Sub
  324.             End If
  325.             adoCon.Execute ("insert into 零件表 values ('" & Text1 & "','" & Text2 & "')")
  326.             MsgBox "记录添加成功!", , "系统提示"
  327.         Case 2
  328.         adoCon.Execute ("update 零件表 set 单价='" & Text2 & "'where 零件名='" + Text1.Text + "'")
  329.             MsgBox "记录修改成功!", , "系统提示"
  330.     End Select
  331.     Lockctl
  332.     cmdok.Enabled = False
  333.     cmdCancel.Enabled = False
  334.     cmdAdd.Enabled = True
  335.     cmdUpdate.Enabled = True
  336.     cmdDelete.Enabled = True
  337.     Adodc1.Refresh
  338.     DataGrid1.Refresh
  339. End Sub
  340. Private Sub cmdUpdate_Click()
  341.     Unlockctl
  342.     i = 2
  343.     Text1.Enabled = False
  344.     cmdok.Enabled = True
  345.     cmdCancel.Enabled = True
  346.     cmdAdd.Enabled = False
  347.     cmdDelete.Enabled = False
  348.     Adodc1.Enabled = False
  349. End Sub
  350. Private Sub Command1_Click(Index As Integer)
  351.   On Error Resume Next
  352.   Select Case Index
  353.          Case 0
  354.          Adodc1.Recordset.MoveFirst
  355.          Case 1
  356.          If Adodc1.Recordset.BOF = False Then
  357.             Adodc1.Recordset.MovePrevious
  358.          Else
  359.             MsgBox "向前已经没有记录了!", , "系统提示"
  360.          End If
  361.          Case 2
  362.          If Adodc1.Recordset.EOF = False Then
  363.             Adodc1.Recordset.MoveNext
  364.          Else
  365.             MsgBox "向后已经没有记录了!", , "系统提示"
  366.          End If
  367.          Case 3
  368.          Adodc1.Recordset.MoveLast
  369.   End Select
  370.   Text1.Text = Adodc1.Recordset.Fields(0)
  371.   Text2.Text = Adodc1.Recordset.Fields(1)
  372. End Sub
  373. Private Sub Form_Load()
  374. frmLJ.Width = 5145
  375. frmLJ.Height = 3525
  376. End Sub
  377. Private Sub Text1_KeyPress(KeyAscii As Integer)
  378.  If KeyAscii = vbKeyReturn Then Text2.SetFocus
  379. End Sub
  380. Private Sub Text2_KeyPress(KeyAscii As Integer)
  381.   KeyAscii = valiText(KeyAscii, "0123456789" & Chr(8), True)
  382. End Sub