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

WORD

  1. VERSION 5.00
  2. Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
  3. Begin VB.Form frmManager 
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "管理员设置"
  6.    ClientHeight    =   2085
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   5445
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MDIChild        =   -1  'True
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   2085
  15.    ScaleWidth      =   5445
  16.    Begin MSAdodcLib.Adodc Adodc1 
  17.       Height          =   330
  18.       Left            =   4980
  19.       Top             =   1575
  20.       Visible         =   0   'False
  21.       Width           =   1200
  22.       _ExtentX        =   2117
  23.       _ExtentY        =   582
  24.       ConnectMode     =   0
  25.       CursorLocation  =   3
  26.       IsolationLevel  =   -1
  27.       ConnectionTimeout=   15
  28.       CommandTimeout  =   30
  29.       CursorType      =   3
  30.       LockType        =   3
  31.       CommandType     =   1
  32.       CursorOptions   =   0
  33.       CacheSize       =   50
  34.       MaxRecords      =   0
  35.       BOFAction       =   0
  36.       EOFAction       =   0
  37.       ConnectStringType=   1
  38.       Appearance      =   1
  39.       BackColor       =   -2147483643
  40.       ForeColor       =   -2147483640
  41.       Orientation     =   0
  42.       Enabled         =   -1
  43.       Connect         =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=clgl.mdb;Persist Security Info=False"
  44.       OLEDBString     =   "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=clgl.mdb;Persist Security Info=False"
  45.       OLEDBFile       =   ""
  46.       DataSourceName  =   ""
  47.       OtherAttributes =   ""
  48.       UserName        =   ""
  49.       Password        =   ""
  50.       RecordSource    =   "select * from 用户表"
  51.       Caption         =   "Adodc1"
  52.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  53.          Name            =   "宋体"
  54.          Size            =   9
  55.          Charset         =   134
  56.          Weight          =   400
  57.          Underline       =   0   'False
  58.          Italic          =   0   'False
  59.          Strikethrough   =   0   'False
  60.       EndProperty
  61.       _Version        =   393216
  62.    End
  63.    Begin VB.CommandButton cmdExit 
  64.       Caption         =   "退出(&E)"
  65.       Height          =   315
  66.       Left            =   4005
  67.       TabIndex        =   5
  68.       Top             =   1695
  69.       Width           =   930
  70.    End
  71.    Begin VB.CommandButton Command1 
  72.       Caption         =   "尾记录"
  73.       Height          =   315
  74.       Index           =   3
  75.       Left            =   3090
  76.       TabIndex        =   22
  77.       Top             =   1695
  78.       Width           =   930
  79.    End
  80.    Begin VB.CommandButton Command1 
  81.       Caption         =   "下一条"
  82.       Height          =   315
  83.       Index           =   2
  84.       Left            =   2175
  85.       TabIndex        =   21
  86.       Top             =   1695
  87.       Width           =   930
  88.    End
  89.    Begin VB.CommandButton Command1 
  90.       Caption         =   "上一条"
  91.       Height          =   315
  92.       Index           =   1
  93.       Left            =   1260
  94.       TabIndex        =   20
  95.       Top             =   1695
  96.       Width           =   930
  97.    End
  98.    Begin VB.CommandButton Command1 
  99.       Caption         =   "首记录"
  100.       Height          =   315
  101.       Index           =   0
  102.       Left            =   345
  103.       TabIndex        =   19
  104.       Top             =   1695
  105.       Width           =   930
  106.    End
  107.    Begin VB.Frame Frame1 
  108.       Caption         =   "管理员信息"
  109.       BeginProperty Font 
  110.          Name            =   "宋体"
  111.          Size            =   10.5
  112.          Charset         =   134
  113.          Weight          =   400
  114.          Underline       =   0   'False
  115.          Italic          =   0   'False
  116.          Strikethrough   =   0   'False
  117.       EndProperty
  118.       ForeColor       =   &H00800000&
  119.       Height          =   1155
  120.       Left            =   90
  121.       TabIndex        =   6
  122.       Top             =   90
  123.       Width           =   5220
  124.       Begin VB.TextBox Text1 
  125.          Enabled         =   0   'False
  126.          Height          =   300
  127.          Left            =   1230
  128.          TabIndex        =   17
  129.          Top             =   285
  130.          Width           =   1335
  131.       End
  132.       Begin VB.ComboBox Combo1 
  133.          Enabled         =   0   'False
  134.          Height          =   300
  135.          ItemData        =   "frmManager.frx":0000
  136.          Left            =   3735
  137.          List            =   "frmManager.frx":000A
  138.          TabIndex        =   12
  139.          Text            =   "管理员"
  140.          Top             =   660
  141.          Width           =   1335
  142.       End
  143.       Begin VB.TextBox Text3 
  144.          Enabled         =   0   'False
  145.          Height          =   300
  146.          IMEMode         =   3  'DISABLE
  147.          Left            =   3735
  148.          PasswordChar    =   "*"
  149.          TabIndex        =   11
  150.          Top             =   285
  151.          Width           =   1335
  152.       End
  153.       Begin VB.TextBox Text2 
  154.          Enabled         =   0   'False
  155.          Height          =   300
  156.          IMEMode         =   3  'DISABLE
  157.          Left            =   1230
  158.          PasswordChar    =   "*"
  159.          TabIndex        =   10
  160.          Top             =   660
  161.          Width           =   1335
  162.       End
  163.       Begin VB.Label Label1 
  164.          AutoSize        =   -1  'True
  165.          Caption         =   "用户姓名:"
  166.          Height          =   180
  167.          Left            =   180
  168.          TabIndex        =   18
  169.          Top             =   285
  170.          Width           =   900
  171.       End
  172.       Begin VB.Label Label8 
  173.          AutoSize        =   -1  'True
  174.          Caption         =   "*"
  175.          ForeColor       =   &H000000FF&
  176.          Height          =   180
  177.          Left            =   3570
  178.          TabIndex        =   16
  179.          Top             =   675
  180.          Width           =   90
  181.       End
  182.       Begin VB.Label Label7 
  183.          AutoSize        =   -1  'True
  184.          Caption         =   "*"
  185.          ForeColor       =   &H000000FF&
  186.          Height          =   180
  187.          Left            =   3570
  188.          TabIndex        =   15
  189.          Top             =   315
  190.          Width           =   90
  191.       End
  192.       Begin VB.Label Label6 
  193.          Caption         =   "*"
  194.          ForeColor       =   &H000000FF&
  195.          Height          =   135
  196.          Left            =   1065
  197.          TabIndex        =   14
  198.          Top             =   720
  199.          Width           =   135
  200.       End
  201.       Begin VB.Label Label5 
  202.          Caption         =   "*"
  203.          ForeColor       =   &H000000FF&
  204.          Height          =   135
  205.          Left            =   1065
  206.          TabIndex        =   13
  207.          Top             =   315
  208.          Width           =   135
  209.       End
  210.       Begin VB.Label Label4 
  211.          AutoSize        =   -1  'True
  212.          Caption         =   "用户类型:"
  213.          Height          =   180
  214.          Left            =   2700
  215.          TabIndex        =   9
  216.          Top             =   660
  217.          Width           =   900
  218.       End
  219.       Begin VB.Label Label3 
  220.          Caption         =   "确认密码:"
  221.          Height          =   255
  222.          Left            =   2700
  223.          TabIndex        =   8
  224.          Top             =   285
  225.          Width           =   975
  226.       End
  227.       Begin VB.Label Label2 
  228.          Caption         =   "密    码:"
  229.          Height          =   255
  230.          Left            =   180
  231.          TabIndex        =   7
  232.          Top             =   675
  233.          Width           =   975
  234.       End
  235.    End
  236.    Begin VB.CommandButton cmdCancel 
  237.       Caption         =   "取消(&Q)"
  238.       Enabled         =   0   'False
  239.       Height          =   315
  240.       Left            =   4005
  241.       TabIndex        =   4
  242.       Top             =   1395
  243.       Width           =   930
  244.    End
  245.    Begin VB.CommandButton cmdOk 
  246.       Caption         =   "确定 (&O)"
  247.       Enabled         =   0   'False
  248.       Height          =   315
  249.       Left            =   3090
  250.       TabIndex        =   3
  251.       Top             =   1395
  252.       Width           =   930
  253.    End
  254.    Begin VB.CommandButton cmdDelete 
  255.       Caption         =   "删除 (&D)"
  256.       Height          =   315
  257.       Left            =   2175
  258.       TabIndex        =   2
  259.       Top             =   1395
  260.       Width           =   930
  261.    End
  262.    Begin VB.CommandButton cmdUpdate 
  263.       Caption         =   "修改 (&U)"
  264.       Height          =   315
  265.       Left            =   1260
  266.       TabIndex        =   1
  267.       Top             =   1395
  268.       Width           =   930
  269.    End
  270.    Begin VB.CommandButton cmdAdd 
  271.       Caption         =   "添加 (&A)"
  272.       Height          =   315
  273.       Left            =   345
  274.       TabIndex        =   0
  275.       Top             =   1395
  276.       Width           =   930
  277.    End
  278. End
  279. Attribute VB_Name = "frmManager"
  280. Attribute VB_GlobalNameSpace = False
  281. Attribute VB_Creatable = False
  282. Attribute VB_PredeclaredId = True
  283. Attribute VB_Exposed = False
  284. Dim i As Integer
  285. Dim adoRs1 As New ADODB.Recordset
  286. Private Sub cmdAdd_Click()
  287.     Unlockctl
  288.     Text1 = ""
  289.     Text2 = ""
  290.     Text3 = ""
  291.     Combo1.Text = ""
  292.     Text1.SetFocus
  293.     cmdOk.Enabled = True
  294.     cmdCancel.Enabled = True
  295.     cmdUpdate.Enabled = False
  296.     cmdDelete.Enabled = False
  297.     cmdAdd.Enabled = False
  298.     i = 1
  299.  End Sub
  300. Private Sub cmdCancel_Click()
  301.   On Error Resume Next
  302.     Select Case i
  303.         Case 1
  304.             Adodc1.Recordset.MoveFirst
  305.         Case 2
  306.             Adodc1.Recordset.MoveNext
  307.             If Adodc1.Recordset.EOF Then Adodc1.Recordset.MovePrevious
  308.         End Select
  309.     Lockctl
  310.     cmdCancel.Enabled = False
  311.     cmdOk.Enabled = False
  312.     cmdUpdate.Enabled = True
  313.     cmdDelete.Enabled = True
  314.     cmdAdd.Enabled = True
  315. End Sub
  316. Private Sub cmdDelete_Click()
  317.     If MsgBox("确实要删除这条记录吗?", vbOKCancel, "系统提示") = vbOK Then
  318.        On Error Resume Next
  319.        Adodc1.Recordset.Delete
  320.        Adodc1.Recordset.MoveFirst
  321.        If Adodc1.Recordset.RecordCount > 0 Then
  322.        showdata
  323.        Else
  324.           Text1.Text = ""
  325.           Text2.Text = ""
  326.           Text3.Text = ""
  327.           Combo1.Text = ""
  328.        End If
  329.     End If
  330. End Sub
  331. Private Sub cmdExit_Click()
  332.     On Error Resume Next
  333.     adors.Close
  334.     MDIForm1.StatusBar1.Panels(1).Text = ""
  335.     Unload Me
  336. End Sub
  337. Private Sub cmdFirst_Click()
  338.     On Error Resume Next
  339.     adors.MoveFirst
  340. End Sub
  341. Private Sub cmdLast_Click()
  342.    On Error Resume Next
  343.    adors.MoveLast
  344. End Sub
  345. Private Sub cmdNext_Click()
  346.     On Error Resume Next
  347.     adors.MoveNext
  348.     If Not adors.EOF Then
  349.     Else
  350.         MsgBox "已到末记录!", , "系统提示"
  351.     End If
  352. End Sub
  353. Private Sub cmdOk_Click()
  354.     If Text3 <> Text2 Then
  355.         Text2 = ""
  356.         Text3 = ""
  357.         Text2.SetFocus
  358.         MsgBox "确认密码必须与密码一致!", , "系统提示"
  359.         Exit Sub
  360.     End If
  361.     Select Case i
  362.         Case 1
  363.             If Text1 = "" Then
  364.                 MsgBox "用户姓名不能为空", , "系统提示"
  365.                 Text1.SetFocus
  366.                 Exit Sub
  367.             End If
  368.             If Text2 = "" Then
  369.                 MsgBox "密码不能为空", , "系统提示"
  370.                 Text2.SetFocus
  371.                 Exit Sub
  372.             End If
  373.             If Text3 = "" Then
  374.                 MsgBox "确认密码不能为空", , "系统提示"
  375.                 Text3.SetFocus
  376.                 Exit Sub
  377.             End If
  378.             If Combo1.Text = "" Then
  379.                 MsgBox "用户类型不能为空", , "系统提示"
  380.                 Combo1.SetFocus
  381.                 Exit Sub
  382.             End If
  383.             Adodc1.Recordset.AddNew
  384.             Adodc1.Recordset.Fields(0) = Text1.Text
  385.             Adodc1.Recordset.Fields(1) = Text2.Text
  386.             Adodc1.Recordset.Fields(2) = Combo1.Text
  387.             Adodc1.Recordset.Update
  388.             MsgBox "记录添加成功!", , "系统提示"
  389.             Lockctl
  390.            cmdUpdate.Enabled = True
  391.            cmdDelete.Enabled = True
  392.            cmdAdd.Enabled = True
  393.            cmdOk.Enabled = False
  394.            cmdCancel.Enabled = False
  395.         Case 2
  396.             'adoCon.Execute ("update 用户表 set 密码='" & Text2 & "',用户类型= '" & Combo1.Text & "' where 用户姓名='" & Text1 & "'")
  397.             On Error Resume Next
  398.             Adodc1.Recordset.Fields(0) = Text1.Text
  399.             Adodc1.Recordset.Fields(1) = Text2.Text
  400.             Adodc1.Recordset.Fields(2) = Combo1.Text
  401.             Adodc1.Recordset.Update
  402.             MsgBox "记录修改成功!", , "系统提示"
  403.             Lockctl
  404.             cmdUpdate.Enabled = True
  405.             cmdDelete.Enabled = True
  406.             cmdAdd.Enabled = True
  407.             cmdOk.Enabled = False
  408.             cmdCancel.Enabled = False
  409.     End Select
  410. End Sub
  411. Private Sub cmdUpdate_Click()
  412.     Unlockctl
  413.     Text1.Enabled = False
  414.     cmdOk.Enabled = True
  415.     cmdCancel.Enabled = True
  416.     i = 2
  417. End Sub
  418. Private Sub Command1_Click(Index As Integer)
  419.   On Error Resume Next
  420.   Select Case Index
  421.          Case 0
  422.          Adodc1.Recordset.MoveFirst
  423.          Case 1
  424.          If Adodc1.Recordset.BOF = False Then
  425.             Adodc1.Recordset.MovePrevious
  426.          End If
  427.          Case 2
  428.          If Adodc1.Recordset.EOF = False Then
  429.             Adodc1.Recordset.MoveNext
  430.          End If
  431.          Case 3
  432.          Adodc1.Recordset.MoveLast
  433.   End Select
  434.   showdata
  435. End Sub
  436. Private Sub Form_Load()
  437.     frmManager.Width = 5535
  438.     frmManager.Height = 2460
  439.     adors.Open "select * from 用户表", adoCon, adOpenKeyset, adLockOptimistic
  440.     adors.Close
  441.     Adodc1.RecordSource = "select * from 用户表"
  442.     Adodc1.Refresh
  443.     If Adodc1.Recordset.RecordCount > 0 Then showdata
  444. End Sub
  445. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  446.     cmdExit_Click
  447. End Sub
  448. Private Sub Text1_KeyPress(KeyAscii As Integer)
  449.     If KeyAscii = 13 Then Text2.SetFocus
  450. End Sub
  451. Private Sub Text1_LostFocus()
  452.     Set adoRs1 = adoCon.Execute("select * from 用户表 where 用户姓名='" & Text1 & "'")
  453.     If Not adoRs1.EOF Then
  454.         MsgBox "此用户已经存在,请重新输入用户姓名!", , "系统提示"
  455.         Text1 = ""
  456.         Text1.SetFocus
  457.         Exit Sub
  458.     End If
  459.     adoRs1.Close
  460. End Sub
  461. Private Sub Text2_KeyPress(KeyAscii As Integer)
  462.     If KeyAscii = 13 Then Text3.SetFocus
  463. End Sub
  464. Private Sub text3_KeyPress(KeyAscii As Integer)
  465.     If KeyAscii = 13 Then Combo1.SetFocus
  466. End Sub
  467. Private Sub Lockctl()
  468.    Text1.Enabled = False
  469.    Text2.Enabled = False
  470.    Text3.Enabled = False
  471.    Combo1.Enabled = False
  472. End Sub
  473. Private Sub Unlockctl()
  474.    Text1.Enabled = True
  475.    Text2.Enabled = True
  476.    Text3.Enabled = True
  477.    Combo1.Enabled = True
  478. End Sub
  479. Sub showdata()
  480. Text1.Text = Adodc1.Recordset.Fields(0)
  481. Text2.Text = Adodc1.Recordset.Fields(1)
  482. Combo1.Text = Adodc1.Recordset.Fields(2)
  483. End Sub