⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setclass.frm

📁 SQL Server 2000应用系统开发教案例 学习SQL Server 2000 的好东西!~
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   465
         Left            =   870
         TabIndex        =   6
         Top             =   4440
         Width           =   1065
      End
      Begin VB.ListBox List1 
         DataSource      =   "Adodc1"
         BeginProperty Font 
            Name            =   "宋体"
            Size            =   10.5
            Charset         =   134
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   1950
         Left            =   300
         Sorted          =   -1  'True
         TabIndex        =   5
         Top             =   480
         Width           =   2385
      End
      Begin VB.Frame Frame1 
         Caption         =   "添加专业"
         BeginProperty Font 
            Name            =   "隶书"
            Size            =   12
            Charset         =   134
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000FF&
         Height          =   1335
         Left            =   210
         TabIndex        =   2
         Top             =   2850
         Width           =   2565
         Begin VB.TextBox Text1 
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   10.5
               Charset         =   134
               Weight          =   400
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   345
            Left            =   150
            TabIndex        =   4
            Top             =   360
            Width           =   2355
         End
         Begin VB.CommandButton Comm11 
            Caption         =   "确定"
            BeginProperty Font 
               Name            =   "宋体"
               Size            =   10.5
               Charset         =   134
               Weight          =   700
               Underline       =   0   'False
               Italic          =   0   'False
               Strikethrough   =   0   'False
            EndProperty
            Height          =   405
            Left            =   930
            TabIndex        =   3
            Top             =   840
            Width           =   705
         End
      End
   End
   Begin VB.CommandButton retCom 
      Caption         =   "返回"
      BeginProperty Font 
         Name            =   "宋体"
         Size            =   12
         Charset         =   134
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   615
      Left            =   6960
      TabIndex        =   0
      Top             =   4590
      Width           =   825
   End
End
Attribute VB_Name = "Setclass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim rs As ADODB.Recordset
Dim sqltxt As String


Private Sub Comm11_Click()
  If Trim(Text1.Text) <> "" Then
     sqltxt = "select * from prof where 专业='" + Trim(Text1.Text) + " '"
     Set rs = exesql(sqltxt)
     If rs.RecordCount <> 0 Then
        MsgBox "存在相同的专业,不能添加到专业表中", vbOKOnly, "信息提示"
     Else
        Adodc1.Recordset.AddNew
        Adodc1.Recordset.Fields("专业") = Trim(Text1.Text)
        Adodc1.Recordset.Update
        Adodc1.Recordset.Requery             '刷新rsprof记录源
        List1.AddItem (Trim(Text1.Text))
        Text1.Text = ""
     End If
     rs.Close
  Else
     MsgBox "输入的专业不能为空", vbOKOnly, "信息提示"
  End If
End Sub


Private Sub Comm12_Click()  '删除专业
   If List1.ListIndex >= 0 Then
      If MsgBox("真的要删除[" + Trim(List1.Text) + "]专业吗?", vbYesNo, "确认") = vbYes Then
         Adodc1.Recordset.MoveFirst
         Adodc1.Recordset.Find ("专业 = '" + List1.Text + "'")
         Adodc1.Recordset.Delete
         Adodc1.Recordset.Update
         sqltxt = "delete classn where 专业='" & Trim(List1.Text) + "'"
         Set conn = New ADODB.Connection
         conn.ConnectionString = "DSN=STUD;UID=sa;PWD=;"
         conn.Open
         conn.Execute sqltxt
         conn.Close
         List1.RemoveItem List1.ListIndex
      End If
   Else
      MsgBox "没有选择从左列表中选择任何专业", vbOKOnly, "信息提示"
   End If
End Sub

Private Sub Comm21_Click()
  If Trim(Text2.Text) <> "" Then
     sqltxt = "select * from classn where 专业='" + Trim(List1.Text) + " ' and 班号='" + Trim(Text2.Text) + "'"
     Set rs = exesql(sqltxt)
     If rs.RecordCount <> 0 Then
        MsgBox "存在相同专业的相同班号,不能添加到班号表中", vbOKOnly, "信息提示"
     Else
        Adodc2.Recordset.AddNew
        Adodc2.Recordset.Fields("专业") = Trim(List1.Text)
        Adodc2.Recordset.Fields("班号") = Trim(Text2.Text)
        Adodc2.Recordset.Update
        Adodc2.Recordset.Requery             '刷新记录源
        List2.AddItem (Trim(Text2.Text))
        Text2.Text = ""
     End If
     rs.Close
  Else
     MsgBox "输入的班号不能为空", vbOKOnly, "信息提示"
  End If
  
End Sub

Private Sub Comm22_Click()
   If List2.ListIndex >= 0 Then
      If MsgBox("真的要删除[" + Trim(List1.Text) + "]专业的[" + Trim(List2.Text) + "]班吗?", vbYesNo, "确认") = vbYes Then
         Adodc2.Recordset.MoveFirst
         Adodc2.Recordset.Find ("班号='" + Trim(List2.Text) + "'")
         Adodc2.Recordset.Delete
         Adodc2.Recordset.Update
         List2.RemoveItem List2.ListIndex
      End If
   Else
      MsgBox "没有选择从右列表中选择任何班号", vbOKOnly, "信息提示"
   End If
End Sub

Private Sub Form_Load()
  If Adodc1.Recordset.RecordCount > 0 Then
    Adodc1.Recordset.MoveFirst
    Do While Not Adodc1.Recordset.EOF
       List1.AddItem (Adodc1.Recordset.Fields("专业"))
       Adodc1.Recordset.MoveNext
    Loop
  End If
  Comm21.Enabled = False
  Comm22.Enabled = False
End Sub

Private Sub List1_Click()
  If List1.ListIndex >= 0 Then
     Comm21.Enabled = True
  End If
  List2.Clear
  If List1.ListIndex >= 0 Then
    Adodc2.RecordSource = "select * from classn where 专业='" + Trim(List1.Text) + "'"
    Adodc2.Refresh
    If Adodc2.Recordset.RecordCount > 0 Then
       Adodc2.Recordset.MoveFirst
       Do While Not Adodc2.Recordset.EOF
          List2.AddItem (Adodc2.Recordset.Fields("班号"))
          Adodc2.Recordset.MoveNext
       Loop
       Comm21.Enabled = True
    End If
  Else
    MsgBox "先从左列表框中选择一个专业", vbOKOnly, "信息提示"
  End If
End Sub

Private Sub List2_Click()
  Comm22.Enabled = True
End Sub

Private Sub retCom_Click()
  Unload Me
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -