user1.frm
上传用户:bubble
上传日期:2007-03-02
资源大小:403k
文件大小:12k
源码类别:

教育系统应用

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Begin VB.Form frmuser1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "新增用户"
  5.    ClientHeight    =   4425
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   6510
  9.    LinkTopic       =   "Form2"
  10.    MaxButton       =   0   'False
  11.    MDIChild        =   -1  'True
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   4425
  14.    ScaleWidth      =   6510
  15.    Begin VB.Frame Frame1 
  16.       Caption         =   "新增用户"
  17.       ForeColor       =   &H000000FF&
  18.       Height          =   4215
  19.       Left            =   120
  20.       TabIndex        =   0
  21.       Top             =   120
  22.       Width           =   6255
  23.       Begin VB.TextBox Text1 
  24.          Appearance      =   0  'Flat
  25.          BackColor       =   &H80000018&
  26.          ForeColor       =   &H000000FF&
  27.          Height          =   270
  28.          IMEMode         =   3  'DISABLE
  29.          Index           =   2
  30.          Left            =   4200
  31.          PasswordChar    =   "*"
  32.          TabIndex        =   16
  33.          TabStop         =   0   'False
  34.          Top             =   720
  35.          Width           =   855
  36.       End
  37.       Begin VB.Frame Frame3 
  38.          Caption         =   "用户类别"
  39.          ForeColor       =   &H000000FF&
  40.          Height          =   2175
  41.          Left            =   120
  42.          TabIndex        =   12
  43.          Top             =   1320
  44.          Width           =   2175
  45.          Begin VB.OptionButton Option1 
  46.             Caption         =   "普通用户"
  47.             BeginProperty Font 
  48.                Name            =   "楷体_GB2312"
  49.                Size            =   12
  50.                Charset         =   134
  51.                Weight          =   400
  52.                Underline       =   0   'False
  53.                Italic          =   0   'False
  54.                Strikethrough   =   0   'False
  55.             EndProperty
  56.             ForeColor       =   &H00C00000&
  57.             Height          =   495
  58.             Index           =   2
  59.             Left            =   240
  60.             TabIndex        =   15
  61.             Top             =   1320
  62.             Width           =   1815
  63.          End
  64.          Begin VB.OptionButton Option1 
  65.             Caption         =   "只读用户"
  66.             BeginProperty Font 
  67.                Name            =   "楷体_GB2312"
  68.                Size            =   12
  69.                Charset         =   134
  70.                Weight          =   400
  71.                Underline       =   0   'False
  72.                Italic          =   0   'False
  73.                Strikethrough   =   0   'False
  74.             EndProperty
  75.             ForeColor       =   &H00C00000&
  76.             Height          =   495
  77.             Index           =   1
  78.             Left            =   240
  79.             TabIndex        =   14
  80.             Top             =   840
  81.             Width           =   1815
  82.          End
  83.          Begin VB.OptionButton Option1 
  84.             Caption         =   "超级用户"
  85.             BeginProperty Font 
  86.                Name            =   "楷体_GB2312"
  87.                Size            =   12
  88.                Charset         =   134
  89.                Weight          =   400
  90.                Underline       =   0   'False
  91.                Italic          =   0   'False
  92.                Strikethrough   =   0   'False
  93.             EndProperty
  94.             ForeColor       =   &H00C00000&
  95.             Height          =   495
  96.             Index           =   0
  97.             Left            =   240
  98.             TabIndex        =   13
  99.             Top             =   360
  100.             Width           =   1815
  101.          End
  102.       End
  103.       Begin VB.CommandButton Command2 
  104.          Caption         =   "取消"
  105.          Height          =   255
  106.          Left            =   4200
  107.          TabIndex        =   11
  108.          Top             =   3720
  109.          Width           =   1095
  110.       End
  111.       Begin VB.CommandButton Command1 
  112.          Caption         =   "确定"
  113.          Height          =   255
  114.          Left            =   960
  115.          TabIndex        =   10
  116.          Top             =   3720
  117.          Width           =   1095
  118.       End
  119.       Begin VB.Frame Frame2 
  120.          Caption         =   "权限"
  121.          ForeColor       =   &H000000FF&
  122.          Height          =   2175
  123.          Left            =   2400
  124.          TabIndex        =   5
  125.          Top             =   1320
  126.          Width           =   3615
  127.          Begin VB.CheckBox Check1 
  128.             Caption         =   "课程与成绩管理"
  129.             BeginProperty Font 
  130.                Name            =   "楷体_GB2312"
  131.                Size            =   12
  132.                Charset         =   134
  133.                Weight          =   400
  134.                Underline       =   0   'False
  135.                Italic          =   0   'False
  136.                Strikethrough   =   0   'False
  137.             EndProperty
  138.             ForeColor       =   &H00C00000&
  139.             Height          =   255
  140.             Index           =   3
  141.             Left            =   360
  142.             TabIndex        =   9
  143.             Top             =   1560
  144.             Width           =   2175
  145.          End
  146.          Begin VB.CheckBox Check1 
  147.             Caption         =   "学生交费管理"
  148.             BeginProperty Font 
  149.                Name            =   "楷体_GB2312"
  150.                Size            =   12
  151.                Charset         =   134
  152.                Weight          =   400
  153.                Underline       =   0   'False
  154.                Italic          =   0   'False
  155.                Strikethrough   =   0   'False
  156.             EndProperty
  157.             ForeColor       =   &H00C00000&
  158.             Height          =   255
  159.             Index           =   2
  160.             Left            =   360
  161.             TabIndex        =   8
  162.             Top             =   1200
  163.             Width           =   2175
  164.          End
  165.          Begin VB.CheckBox Check1 
  166.             Caption         =   "班级与学生档案管理"
  167.             BeginProperty Font 
  168.                Name            =   "楷体_GB2312"
  169.                Size            =   12
  170.                Charset         =   134
  171.                Weight          =   400
  172.                Underline       =   0   'False
  173.                Italic          =   0   'False
  174.                Strikethrough   =   0   'False
  175.             EndProperty
  176.             ForeColor       =   &H00C00000&
  177.             Height          =   255
  178.             Index           =   1
  179.             Left            =   360
  180.             TabIndex        =   7
  181.             Top             =   840
  182.             Width           =   3135
  183.          End
  184.          Begin VB.CheckBox Check1 
  185.             BackColor       =   &H80000000&
  186.             Caption         =   "系统管理"
  187.             BeginProperty Font 
  188.                Name            =   "楷体_GB2312"
  189.                Size            =   12
  190.                Charset         =   134
  191.                Weight          =   400
  192.                Underline       =   0   'False
  193.                Italic          =   0   'False
  194.                Strikethrough   =   0   'False
  195.             EndProperty
  196.             ForeColor       =   &H00C00000&
  197.             Height          =   255
  198.             Index           =   0
  199.             Left            =   360
  200.             TabIndex        =   6
  201.             Top             =   480
  202.             Width           =   2175
  203.          End
  204.       End
  205.       Begin VB.TextBox Text1 
  206.          Appearance      =   0  'Flat
  207.          BackColor       =   &H80000018&
  208.          ForeColor       =   &H000000FF&
  209.          Height          =   270
  210.          IMEMode         =   3  'DISABLE
  211.          Index           =   1
  212.          Left            =   2400
  213.          PasswordChar    =   "*"
  214.          TabIndex        =   3
  215.          TabStop         =   0   'False
  216.          Top             =   720
  217.          Width           =   855
  218.       End
  219.       Begin VB.TextBox Text1 
  220.          Appearance      =   0  'Flat
  221.          BackColor       =   &H80000018&
  222.          ForeColor       =   &H000000FF&
  223.          Height          =   270
  224.          Index           =   0
  225.          Left            =   2400
  226.          TabIndex        =   1
  227.          TabStop         =   0   'False
  228.          Top             =   360
  229.          Width           =   855
  230.       End
  231.       Begin VB.Label Label3 
  232.          Caption         =   "确定密码:"
  233.          ForeColor       =   &H00FF0000&
  234.          Height          =   255
  235.          Left            =   3360
  236.          TabIndex        =   17
  237.          Top             =   750
  238.          Width           =   975
  239.       End
  240.       Begin VB.Image Image1 
  241.          Height          =   480
  242.          Left            =   5280
  243.          Picture         =   "user1.frx":0000
  244.          Top             =   480
  245.          Width           =   480
  246.       End
  247.       Begin VB.Label Label1 
  248.          Caption         =   "密码:"
  249.          ForeColor       =   &H00FF0000&
  250.          Height          =   255
  251.          Left            =   1800
  252.          TabIndex        =   4
  253.          Top             =   750
  254.          Width           =   975
  255.       End
  256.       Begin VB.Label Label2 
  257.          Caption         =   "新用户名:"
  258.          ForeColor       =   &H00FF0000&
  259.          Height          =   255
  260.          Left            =   1440
  261.          TabIndex        =   2
  262.          Top             =   390
  263.          Width           =   975
  264.       End
  265.    End
  266. End
  267. Attribute VB_Name = "frmuser1"
  268. Attribute VB_GlobalNameSpace = False
  269. Attribute VB_Creatable = False
  270. Attribute VB_PredeclaredId = True
  271. Attribute VB_Exposed = False
  272. Private Sub Command1_Click()
  273. If Trim(Text1(0).Text) = "" Then
  274.  MsgBox "用户名不能为空!", vbExclamation + vbOKOnly, "警告"
  275.  Text1(0).SetFocus
  276.  Exit Sub
  277. End If
  278. If Trim(Text1(1).Text) = "" Then
  279.  MsgBox "密码不能为空!", vbExclamation + vbOKOnly, "警告"
  280.  Text1(1).SetFocus
  281.  Exit Sub
  282. End If
  283. If Trim(Text1(2).Text) = "" Then
  284.  MsgBox "确认密码不能为空!", vbExclamation + vbOKOnly, "警告"
  285.  Text1(2).SetFocus
  286.  Exit Sub
  287. End If
  288. If Trim(Text1(1).Text) <> Trim(Text1(2).Text) Then
  289.  MsgBox "确认密码不正确!", vbExclamation + vbOKOnly, "警告"
  290.  Text1(2).SetFocus
  291.  Exit Sub
  292. End If
  293. Dim aa As Integer
  294. aa = 0
  295. If Option1(2).Value = True Then
  296.  For i = 0 To 3
  297.  If Check1(i).Value = 1 Then
  298.    aa = 1
  299.    Exit For
  300.  End If
  301. Next i
  302. If aa = 0 Then
  303.  MsgBox " 普通用户至少要有一项权限!", vbExclamation + vbOKOnly, "警告"
  304. Exit Sub
  305. End If
  306. End If
  307. Dim mrc As ADODB.Recordset
  308. txtsql = "select * from use where username='" & Trim(Text1(0).Text) & "'"
  309. Set mrc = ExecuteSQL(txtsql)
  310. If mrc.EOF = False Then
  311.   MsgBox " 已存在该用户!", vbExclamation + vbOKOnly, "警告"
  312.   Text1(0).SetFocus
  313.   Text1(0).SelStart = 0
  314.   Text1(0).SelLength = Len(Text1(0).Text)
  315.   Exit Sub
  316. End If
  317. txtsql = "select * from use"
  318. Set mrc = ExecuteSQL(txtsql)
  319. mrc.AddNew
  320.   mrc.Fields(0) = Trim(Text1(0).Text)
  321.   mrc.Fields(1) = Trim(Text1(1).Text)
  322. For i = 0 To 2
  323.   If Option1(i).Value = True Then
  324.     Select Case i
  325.     Case 0
  326.     mrc.Fields("admin") = "y"
  327.     Case 1
  328.       mrc.Fields("readonly") = "y"
  329.     Case 2
  330.       For j = 0 To 3
  331.          If Check1(j).Value = 1 Then
  332.           Select Case j
  333.             Case 0
  334.               mrc.Fields("qx1") = "y"
  335.               Case 1
  336.                  mrc.Fields("qx2") = "y"
  337.                Case 2
  338.                 mrc.Fields("qx3") = "y"
  339.                Case 3
  340.                mrc.Fields("qx4") = "y"
  341.            End Select
  342.           End If
  343.         Next j
  344.     End Select
  345.  
  346.    End If
  347.   
  348. Next i
  349.    mrc.Update
  350.    MsgBox " 用户添加成功!", vbExclamation + vbOKOnly, "警告"
  351.    Text1(0).Text = ""
  352.    Text1(1).Text = ""
  353.    Text1(2).Text = ""
  354. End Sub
  355. Private Sub Command2_Click()
  356. Unload Me
  357. End Sub
  358. Private Sub Form_Load()
  359. Option1(2).Value = True
  360. End Sub
  361. Private Sub Form_Resize()
  362. Text1(0).SetFocus
  363. End Sub
  364. Private Sub Option1_Click(Index As Integer)
  365. If Index <> 2 Then
  366. For i = 0 To 3
  367.   Check1(i).Enabled = False
  368. Next i
  369. Else
  370. For i = 0 To 3
  371.   Check1(i).Enabled = True
  372. Next i
  373. End If
  374. End Sub