frmModifyclassinfo.frm
上传用户:rocksue
上传日期:2013-06-17
资源大小:41926k
文件大小:16k
源码类别:

SQL Server

开发平台:

SQL

  1. VERSION 5.00
  2. Begin VB.Form frmModifyclassinfo 
  3.    Caption         =   "修改班级信息"
  4.    ClientHeight    =   4824
  5.    ClientLeft      =   48
  6.    ClientTop       =   348
  7.    ClientWidth     =   7956
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   4824
  10.    ScaleWidth      =   7956
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.Frame Frame2 
  13.       Caption         =   "查看班级信息"
  14.       BeginProperty Font 
  15.          Name            =   "MS Sans Serif"
  16.          Size            =   12
  17.          Charset         =   0
  18.          Weight          =   400
  19.          Underline       =   0   'False
  20.          Italic          =   0   'False
  21.          Strikethrough   =   0   'False
  22.       EndProperty
  23.       Height          =   1092
  24.       Left            =   360
  25.       TabIndex        =   13
  26.       Top             =   2160
  27.       Width           =   6972
  28.       Begin VB.CommandButton lastCommand 
  29.          Caption         =   "最后一条记录"
  30.          BeginProperty Font 
  31.             Name            =   "MS Sans Serif"
  32.             Size            =   12
  33.             Charset         =   0
  34.             Weight          =   400
  35.             Underline       =   0   'False
  36.             Italic          =   0   'False
  37.             Strikethrough   =   0   'False
  38.          EndProperty
  39.          Height          =   492
  40.          Left            =   4920
  41.          TabIndex        =   17
  42.          Top             =   360
  43.          Width           =   1692
  44.       End
  45.       Begin VB.CommandButton nextCommand 
  46.          Caption         =   "下一条记录"
  47.          BeginProperty Font 
  48.             Name            =   "MS Sans Serif"
  49.             Size            =   12
  50.             Charset         =   0
  51.             Weight          =   400
  52.             Underline       =   0   'False
  53.             Italic          =   0   'False
  54.             Strikethrough   =   0   'False
  55.          EndProperty
  56.          Height          =   492
  57.          Left            =   3360
  58.          TabIndex        =   16
  59.          Top             =   360
  60.          Width           =   1452
  61.       End
  62.       Begin VB.CommandButton previousCommand 
  63.          Caption         =   "上一条记录"
  64.          BeginProperty Font 
  65.             Name            =   "MS Sans Serif"
  66.             Size            =   12
  67.             Charset         =   0
  68.             Weight          =   400
  69.             Underline       =   0   'False
  70.             Italic          =   0   'False
  71.             Strikethrough   =   0   'False
  72.          EndProperty
  73.          Height          =   492
  74.          Left            =   1800
  75.          TabIndex        =   15
  76.          Top             =   360
  77.          Width           =   1452
  78.       End
  79.       Begin VB.CommandButton firstCommand 
  80.          Caption         =   "第一条记录"
  81.          BeginProperty Font 
  82.             Name            =   "MS Sans Serif"
  83.             Size            =   12
  84.             Charset         =   0
  85.             Weight          =   400
  86.             Underline       =   0   'False
  87.             Italic          =   0   'False
  88.             Strikethrough   =   0   'False
  89.          EndProperty
  90.          Height          =   492
  91.          Left            =   240
  92.          TabIndex        =   14
  93.          Top             =   360
  94.          Width           =   1452
  95.       End
  96.    End
  97.    Begin VB.Frame Frame3 
  98.       Caption         =   "修改班级信息"
  99.       BeginProperty Font 
  100.          Name            =   "MS Sans Serif"
  101.          Size            =   12
  102.          Charset         =   0
  103.          Weight          =   400
  104.          Underline       =   0   'False
  105.          Italic          =   0   'False
  106.          Strikethrough   =   0   'False
  107.       EndProperty
  108.       Height          =   1092
  109.       Left            =   360
  110.       TabIndex        =   8
  111.       Top             =   3360
  112.       Width           =   6972
  113.       Begin VB.CommandButton deleteCommand 
  114.          Caption         =   "删除记录"
  115.          BeginProperty Font 
  116.             Name            =   "MS Sans Serif"
  117.             Size            =   12
  118.             Charset         =   0
  119.             Weight          =   400
  120.             Underline       =   0   'False
  121.             Italic          =   0   'False
  122.             Strikethrough   =   0   'False
  123.          EndProperty
  124.          Height          =   492
  125.          Left            =   5160
  126.          TabIndex        =   12
  127.          Top             =   360
  128.          Width           =   1452
  129.       End
  130.       Begin VB.CommandButton cancelCommand 
  131.          Caption         =   "取消修改记录"
  132.          BeginProperty Font 
  133.             Name            =   "MS Sans Serif"
  134.             Size            =   12
  135.             Charset         =   0
  136.             Weight          =   400
  137.             Underline       =   0   'False
  138.             Italic          =   0   'False
  139.             Strikethrough   =   0   'False
  140.          EndProperty
  141.          Height          =   492
  142.          Left            =   3360
  143.          TabIndex        =   11
  144.          Top             =   360
  145.          Width           =   1692
  146.       End
  147.       Begin VB.CommandButton updateCommand 
  148.          Caption         =   "更新数据"
  149.          BeginProperty Font 
  150.             Name            =   "MS Sans Serif"
  151.             Size            =   12
  152.             Charset         =   0
  153.             Weight          =   400
  154.             Underline       =   0   'False
  155.             Italic          =   0   'False
  156.             Strikethrough   =   0   'False
  157.          EndProperty
  158.          Height          =   492
  159.          Left            =   1800
  160.          TabIndex        =   10
  161.          Top             =   360
  162.          Width           =   1452
  163.       End
  164.       Begin VB.CommandButton editCommand 
  165.          Caption         =   "修改记录"
  166.          BeginProperty Font 
  167.             Name            =   "MS Sans Serif"
  168.             Size            =   12
  169.             Charset         =   0
  170.             Weight          =   400
  171.             Underline       =   0   'False
  172.             Italic          =   0   'False
  173.             Strikethrough   =   0   'False
  174.          EndProperty
  175.          Height          =   492
  176.          Left            =   240
  177.          TabIndex        =   9
  178.          Top             =   360
  179.          Width           =   1452
  180.       End
  181.    End
  182.    Begin VB.TextBox txtClassno 
  183.       BeginProperty Font 
  184.          Name            =   "宋体"
  185.          Size            =   10.8
  186.          Charset         =   0
  187.          Weight          =   700
  188.          Underline       =   0   'False
  189.          Italic          =   0   'False
  190.          Strikethrough   =   0   'False
  191.       EndProperty
  192.       Height          =   372
  193.       Left            =   2040
  194.       TabIndex        =   3
  195.       Top             =   600
  196.       Width           =   1332
  197.    End
  198.    Begin VB.TextBox txtDirector 
  199.       BeginProperty Font 
  200.          Name            =   "宋体"
  201.          Size            =   10.8
  202.          Charset         =   0
  203.          Weight          =   700
  204.          Underline       =   0   'False
  205.          Italic          =   0   'False
  206.          Strikethrough   =   0   'False
  207.       EndProperty
  208.       Height          =   372
  209.       Left            =   2040
  210.       TabIndex        =   2
  211.       Top             =   1320
  212.       Width           =   1332
  213.    End
  214.    Begin VB.TextBox txtClassroom 
  215.       BeginProperty Font 
  216.          Name            =   "宋体"
  217.          Size            =   10.8
  218.          Charset         =   0
  219.          Weight          =   700
  220.          Underline       =   0   'False
  221.          Italic          =   0   'False
  222.          Strikethrough   =   0   'False
  223.       EndProperty
  224.       Height          =   372
  225.       Left            =   4560
  226.       TabIndex        =   1
  227.       Top             =   1320
  228.       Width           =   1692
  229.    End
  230.    Begin VB.ComboBox comboGrade 
  231.       BeginProperty Font 
  232.          Name            =   "宋体"
  233.          Size            =   10.8
  234.          Charset         =   0
  235.          Weight          =   700
  236.          Underline       =   0   'False
  237.          Italic          =   0   'False
  238.          Strikethrough   =   0   'False
  239.       EndProperty
  240.       Height          =   312
  241.       Left            =   4560
  242.       TabIndex        =   0
  243.       Top             =   600
  244.       Width           =   1692
  245.    End
  246.    Begin VB.Label Label1 
  247.       Caption         =   "班号:"
  248.       BeginProperty Font 
  249.          Name            =   "宋体"
  250.          Size            =   10.8
  251.          Charset         =   134
  252.          Weight          =   700
  253.          Underline       =   0   'False
  254.          Italic          =   0   'False
  255.          Strikethrough   =   0   'False
  256.       EndProperty
  257.       Height          =   252
  258.       Left            =   1080
  259.       TabIndex        =   7
  260.       Top             =   600
  261.       Width           =   732
  262.    End
  263.    Begin VB.Label Label2 
  264.       Caption         =   "年级:"
  265.       BeginProperty Font 
  266.          Name            =   "宋体"
  267.          Size            =   10.8
  268.          Charset         =   134
  269.          Weight          =   700
  270.          Underline       =   0   'False
  271.          Italic          =   0   'False
  272.          Strikethrough   =   0   'False
  273.       EndProperty
  274.       Height          =   252
  275.       Left            =   3720
  276.       TabIndex        =   6
  277.       Top             =   600
  278.       Width           =   732
  279.    End
  280.    Begin VB.Label Label3 
  281.       Alignment       =   2  'Center
  282.       Caption         =   "班主任:"
  283.       BeginProperty Font 
  284.          Name            =   "宋体"
  285.          Size            =   10.8
  286.          Charset         =   134
  287.          Weight          =   700
  288.          Underline       =   0   'False
  289.          Italic          =   0   'False
  290.          Strikethrough   =   0   'False
  291.       EndProperty
  292.       Height          =   252
  293.       Left            =   960
  294.       TabIndex        =   5
  295.       Top             =   1320
  296.       Width           =   972
  297.    End
  298.    Begin VB.Label Label4 
  299.       Caption         =   "教室:"
  300.       BeginProperty Font 
  301.          Name            =   "宋体"
  302.          Size            =   10.8
  303.          Charset         =   134
  304.          Weight          =   700
  305.          Underline       =   0   'False
  306.          Italic          =   0   'False
  307.          Strikethrough   =   0   'False
  308.       EndProperty
  309.       Height          =   252
  310.       Left            =   3720
  311.       TabIndex        =   4
  312.       Top             =   1320
  313.       Width           =   732
  314.    End
  315. End
  316. Attribute VB_Name = "frmModifyclassinfo"
  317. Attribute VB_GlobalNameSpace = False
  318. Attribute VB_Creatable = False
  319. Attribute VB_PredeclaredId = True
  320. Attribute VB_Exposed = False
  321. Dim mrc As ADODB.Recordset
  322. Dim myBookmark As Variant
  323. Dim mcclean As Boolean
  324. Private Sub cancelCommand_Click()
  325.     If Not mcclean Then
  326.         Frame2.Enabled = True
  327.         firstCommand.Enabled = True
  328.         previousCommand.Enabled = True
  329.         nextCommand.Enabled = True
  330.         lastCommand.Enabled = True
  331.             
  332.         txtClassno.Enabled = False
  333.         comboGrade.Enabled = False
  334.         txtDirector.Enabled = False
  335.         txtClassroom.Enabled = False
  336.         
  337.         mrc.Bookmark = myBookmark
  338.         Call viewData
  339.     Else
  340.         MsgBox "什么都没有修改,有什么好取消的!", vbOKOnly + vbExclamation, "警告"
  341.     End If
  342. End Sub
  343. Private Sub deleteCommand_Click()
  344.     myBookmark = mrc.Bookmark
  345.     str2$ = MsgBox("是否删除当前记录?", vbOKCancel, "删除当前记录")
  346.     If str2$ = vbOK Then
  347.             mrc.MoveNext
  348.             If mrc.EOF Then
  349.                 mrc.MoveFirst
  350.                 myBookmark = mrc.Bookmark
  351.                 mrc.MoveLast
  352.                 mrc.Delete
  353.                 mrc.Bookmark = myBookmark
  354.                 Call viewData
  355.             Else
  356.                 myBookmark = mrc.Bookmark
  357.                 mrc.MovePrevious
  358.                 mrc.Delete
  359.                 mrc.Bookmark = myBookmark
  360.                 Call viewData
  361.             End If
  362.     Else
  363.         mrc.Bookmark = myBookmark
  364.         Call viewData
  365.     End If
  366. End Sub
  367. Private Sub editCommand_Click()
  368.     mcclean = False
  369.     Frame2.Enabled = False
  370.     firstCommand.Enabled = False
  371.     previousCommand.Enabled = False
  372.     nextCommand.Enabled = False
  373.     lastCommand.Enabled = False
  374.         
  375.     txtClassno.Enabled = True
  376.     comboGrade.Enabled = True
  377.     txtDirector.Enabled = True
  378.     txtClassroom.Enabled = True
  379.     
  380.     comboGrade.AddItem "初中一年级"
  381.     comboGrade.AddItem "初中二年级"
  382.     comboGrade.AddItem "初中三年级"
  383.     comboGrade.AddItem "高中一年级"
  384.     comboGrade.AddItem "高中二年级"
  385.     comboGrade.AddItem "高中三年级"
  386.     
  387.     myBookmark = mrc.Bookmark
  388. End Sub
  389. Private Sub firstCommand_Click()
  390.     mrc.MoveFirst
  391.     Call viewData
  392. End Sub
  393. Private Sub Form_Load()
  394.     Dim txtSQL As String
  395.     Dim MsgText As String
  396.     
  397.     txtClassno.Enabled = False
  398.     comboGrade.Enabled = False
  399.     txtDirector.Enabled = False
  400.     txtClassroom.Enabled = False
  401.     
  402.     txtSQL = "select * from class_Info "
  403.     Set mrc = ExecuteSQL(txtSQL, MsgText)
  404.     mrc.MoveFirst
  405.     Call viewData
  406.     myBookmark = mrc.Bookmark
  407.     mcclean = True
  408.     
  409.     
  410. End Sub
  411. Public Sub viewData()
  412.     txtClassno.Text = mrc.Fields(0)
  413.     comboGrade.Text = mrc.Fields(1)
  414.     txtDirector.Text = mrc.Fields(2)
  415.     txtClassroom.Text = mrc.Fields(3)
  416.     
  417. End Sub
  418. Private Sub lastCommand_Click()
  419.     mrc.MoveLast
  420.     Call viewData
  421. End Sub
  422. Private Sub nextCommand_Click()
  423.     mrc.MoveNext
  424.     If mrc.EOF Then
  425.         mrc.MoveFirst
  426.     End If
  427.     Call viewData
  428. End Sub
  429. Private Sub previousCommand_Click()
  430.     mrc.MovePrevious
  431.     If mrc.BOF Then
  432.         mrc.MoveLast
  433.     End If
  434.     Call viewData
  435. End Sub
  436. Private Sub updateCommand_Click()
  437.     Dim txtSQL As String
  438.     Dim MsgText As String
  439.     Dim mrcc As ADODB.Recordset
  440.     
  441.     If mcclean Then
  442.         MsgBox "请先修改班级信息", vbOKOnly + vbExclamation, "警告"
  443.         Exit Sub
  444.     End If
  445.     
  446.     If Not Testtxt(txtClassno.Text) Then
  447.         MsgBox "请输入班号!", vbOKOnly + vbExclamation, "警告"
  448.         txtClassno.SetFocus
  449.         Exit Sub
  450.     End If
  451.     
  452.     If Not IsNumeric(Trim(txtClassno.Text)) Then
  453.         MsgBox "请输入数字!", vbOKOnly + vbExclamation, "警告"
  454.         Exit Sub
  455.         txtClassno.SetFocus
  456.     End If
  457.     
  458.         
  459.     If Not Testtxt(comboGrade.Text) Then
  460.         MsgBox "请选择年级!", vbOKOnly + vbExclamation, "警告"
  461.         comboGrade.SetFocus
  462.         
  463.         Exit Sub
  464.     End If
  465.     
  466.     If Not Testtxt(txtDirector.Text) Then
  467.         MsgBox "请输入班主任姓名!", vbOKOnly + vbExclamation, "警告"
  468.         txtDirector.SetFocus
  469.         Exit Sub
  470.     End If
  471.     
  472.     
  473.     If Not Testtxt(txtClassroom.Text) Then
  474.         MsgBox "请输入教室号码!", vbOKOnly + vbExclamation, "警告"
  475.         txtClassroom.SetFocus
  476.         Exit Sub
  477.     End If
  478.     
  479.     mrc.Delete
  480.     txtSQL = "select * from class_Info where class_No = '" & Trim(txtClassno.Text) & "'"
  481.     Set mrcc = ExecuteSQL(txtSQL, MsgText)
  482.     If mrcc.EOF = False Then
  483.         MsgBox "班号重复,请重新输入!", vbOKOnly + vbExclamation, "警告"
  484.         mrcc.Close
  485.         txtClassno.SetFocus
  486.     Else
  487.         mrcc.Close
  488.         mrc.AddNew
  489.         mrc.Fields(0) = Trim(txtClassno.Text)
  490.         mrc.Fields(1) = Trim(comboGrade.Text)
  491.         mrc.Fields(2) = Trim(txtDirector.Text)
  492.         mrc.Fields(3) = Trim(txtClassroom.Text)
  493.         mrc.Update
  494.         MsgBox "修改班级信息成功!", vbOKOnly + vbExclamation, "警告"
  495.         mrc.Bookmark = myBookmark
  496.         Call viewData
  497.         Frame2.Enabled = True
  498.         firstCommand.Enabled = True
  499.         previousCommand.Enabled = True
  500.         nextCommand.Enabled = True
  501.         lastCommand.Enabled = True
  502.         
  503.         txtClassno.Enabled = False
  504.         comboGrade.Enabled = False
  505.         txtDirector.Enabled = False
  506.         txtClassroom.Enabled = False
  507.                 
  508.         mcclean = True
  509.     End If
  510. End Sub