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

📄 frmmajor.frm

📁 是一个 学生管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form frmmajor 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "专业设置"
   ClientHeight    =   4320
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   5865
   Icon            =   "frmmajor.frx":0000
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4320
   ScaleWidth      =   5865
   StartUpPosition =   1  '所有者中心
   Begin VB.CommandButton Command5 
      Caption         =   "关闭(&C)"
      Height          =   375
      Left            =   4320
      TabIndex        =   8
      Top             =   3840
      Width           =   1035
   End
   Begin VB.Frame Frame1 
      Height          =   3135
      Index           =   0
      Left            =   240
      TabIndex        =   14
      Top             =   480
      Width           =   5355
      Begin VB.CommandButton delyx 
         Caption         =   "删除(&D)"
         Height          =   375
         Left            =   4080
         TabIndex        =   3
         Top             =   2640
         Width           =   1035
      End
      Begin MSComctlLib.ListView ListView1 
         Height          =   1815
         Left            =   120
         TabIndex        =   17
         Top             =   240
         Width           =   4935
         _ExtentX        =   8705
         _ExtentY        =   3201
         LabelEdit       =   1
         Sorted          =   -1  'True
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         FullRowSelect   =   -1  'True
         GridLines       =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   0
      End
      Begin VB.TextBox Text2 
         Height          =   315
         Left            =   1320
         TabIndex        =   1
         Top             =   2700
         Width           =   2595
      End
      Begin VB.TextBox Text1 
         Height          =   315
         Left            =   1320
         TabIndex        =   0
         Top             =   2213
         Width           =   1455
      End
      Begin VB.CommandButton Command1 
         Caption         =   "添加(&A)"
         Height          =   375
         Left            =   4080
         TabIndex        =   2
         Top             =   2160
         Width           =   1035
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "院/系代码:"
         Height          =   180
         Left            =   240
         TabIndex        =   16
         Top             =   2280
         Width           =   990
      End
      Begin VB.Label Label2 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "院/系名称:"
         Height          =   180
         Left            =   240
         TabIndex        =   15
         Top             =   2760
         Width           =   990
      End
   End
   Begin VB.Frame Frame1 
      Height          =   3135
      Index           =   1
      Left            =   240
      TabIndex        =   10
      Top             =   480
      Width           =   5355
      Begin VB.TextBox Text3 
         Height          =   320
         Left            =   3480
         TabIndex        =   4
         Top             =   600
         Width           =   1335
      End
      Begin VB.TextBox Text4 
         Height          =   320
         Left            =   3480
         TabIndex        =   5
         Top             =   1320
         Width           =   1695
      End
      Begin VB.CommandButton Command2 
         Caption         =   "添加(&A)"
         Height          =   375
         Left            =   3840
         TabIndex        =   6
         Top             =   1920
         Width           =   1035
      End
      Begin VB.CommandButton delzy 
         Caption         =   "删除(&D)"
         Height          =   375
         Left            =   3840
         TabIndex        =   7
         Top             =   2520
         Width           =   1035
      End
      Begin MSComctlLib.ListView ListView 
         Height          =   2775
         Left            =   120
         TabIndex        =   11
         Top             =   240
         Width           =   3255
         _ExtentX        =   5741
         _ExtentY        =   4895
         LabelWrap       =   -1  'True
         HideSelection   =   -1  'True
         FullRowSelect   =   -1  'True
         GridLines       =   -1  'True
         _Version        =   393217
         ForeColor       =   -2147483640
         BackColor       =   -2147483643
         BorderStyle     =   1
         Appearance      =   1
         NumItems        =   0
      End
      Begin VB.Label Label5 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "专业代码:"
         Height          =   180
         Left            =   3480
         TabIndex        =   13
         Top             =   300
         Width           =   900
      End
      Begin VB.Label Label6 
         AutoSize        =   -1  'True
         BackStyle       =   0  'Transparent
         Caption         =   "专业名称:"
         Height          =   180
         Left            =   3480
         TabIndex        =   12
         Top             =   1020
         Width           =   900
      End
   End
   Begin MSComctlLib.TabStrip TabStrip1 
      Height          =   3645
      Left            =   120
      TabIndex        =   9
      Top             =   120
      Width           =   5595
      _ExtentX        =   9869
      _ExtentY        =   6429
      MultiRow        =   -1  'True
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   2
         BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "院/系设置"
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "专业设置"
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
End
Attribute VB_Name = "frmmajor"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
   Dim yxid As String, yxname As String
   
   On Error Resume Next
If Trim(Text1.Text) = "" Then
    MsgBox "院/系代码不能为空!", vbOKOnly + 48, "提示:"
    Text1.SetFocus
    Exit Sub
End If

If Trim(Text2.Text) = "" Then
    MsgBox "院/系名称不能为空,请输入院/系名称!", vbOKOnly + 48, "提示:"
    Text2.SetFocus
    Exit Sub
End If

 yxid = Trim(Text1.Text)
yxname = Trim(Text2.Text)
 
sqlstr = "select * from Depart where ID='" & Text1.Text & "'"
rs.Open sqlstr, con, 1, 1
 
Do While Not rs.EOF
   If Text1.Text = rs.Fields("ID") Then
        MsgBox "已经存在代码为 " & zyid & " 的院/系", vbInformation
        Text1.SetFocus
        Exit Sub
     End If
   rs.MoveNext
Loop
 
 rs.Close: Set rs = Nothing
 
 '添加用户
 MsgBox "添加代码为" & Text1.Text & "的院/系成功", vbOKOnly, "添加院/系"
 
 sqlstr = "insert into Depart(ID,Name)values('" & yxid & "','" & yxname & "')"
 con.Execute sqlstr
  
 Text1.Text = ""
 Text2.Text = ""
 
 '更新列表
 LoadOperator

End Sub

Private Sub Command2_Click()
 Dim zyid As String, zyname As String
   
   On Error Resume Next
If Trim(Text3.Text) = "" Then
    MsgBox "专业代码不能为空!", vbOKOnly + 48, "提示:"
    Text3.SetFocus
    Exit Sub
End If

If Trim(Text4.Text) = "" Then
    MsgBox "专业名称不能为空,请输入专业名称!", vbOKOnly + 48, "提示:"
    Text4.SetFocus
    Exit Sub
End If

 zyid = Trim(Text3.Text)
zyname = Trim(Text4.Text)
 
sqlstr = "select * from Major where ID='" & Text3.Text & "'"
rs.Open sqlstr, con, 1, 1
 
Do While Not rs.EOF
   If Text3.Text = rs.Fields("ID") Then
        MsgBox "已经存在代码为 " & zyid & " 的专业", vbInformation
        Text3.SetFocus
        Exit Sub
     End If
   rs.MoveNext
Loop
 
 rs.Close: Set rs = Nothing
 
 '添加用户
 MsgBox "添加代码为" & Text3.Text & "的专业成功", vbOKOnly, "添加专业"
 
 sqlstr = "insert into Major(ID,Name)values('" & zyid & "','" & zyname & "')"
 con.Execute sqlstr
  
 Text3.Text = ""
 Text4.Text = ""
 
 '更新列表
 LoadOperator
End Sub

Private Sub Command5_Click()
   Unload Me
End Sub

Private Sub delyx_Click()
   '删除院系
   DelRecord
End Sub

Private Sub delzy_Click()
   '删除专业
   DeleteRecord
End Sub

Private Sub Form_Load()
   Dim clmX As ColumnHeader
    Set clmX = ListView.ColumnHeaders.Add(, , "专业代码", ListView.Width / 3.5)
    Set clmX = ListView.ColumnHeaders.Add(, , "专业名称", ListView.Width / 1.65, 2)
    
    Set clmX = ListView1.ColumnHeaders.Add(, , "院系代码", ListView.Width / 3.5)
    Set clmX = ListView1.ColumnHeaders.Add(, , "院系名称", ListView1.Width / 1.35, 2)
   
   LoadOperator
End Sub

Private Sub DeleteRecord()
'删除操作
On Error Resume Next
If ListView.SelectedItem.Selected Then
   If MsgBox("确定要删除代码为" & ListView.SelectedItem.Text & "的专业吗?", vbYesNo + 32 + vbDefaultButton2) = vbYes Then
            
            sqlstr = "delete from Major where ID='" & ListView.SelectedItem.Text & "'"
            con.Execute sqlstr
            
            LoadOperator
    End If
End If
End Sub

Private Sub DelRecord()
 On Error Resume Next
If ListView1.SelectedItem.Selected Then
   If MsgBox("确定要删除代码为" & ListView1.SelectedItem.Text & "的院/系吗?", vbYesNo + 32 + vbDefaultButton2) = vbYes Then
            
            sqlstr = "delete from Depart where ID='" & ListView1.SelectedItem.Text & "'"
            con.Execute sqlstr
            
            LoadOperator
    End If
End If
End Sub

Private Sub LoadOperator()
 On Error Resume Next

Dim Listit As ListItem
'装载listview中的项目
ListView.ListItems.Clear
ListView.LabelEdit = lvwAuto
ListView.View = 3

Dim ef As New ADODB.Recordset, sqlstr As String

sqlstr = "select * from Major"
ef.Open sqlstr, con, 1, 1
    Do While Not ef.EOF
       Set Listit = ListView.ListItems.Add(, , ef.Fields("ID"))
           Listit.SubItems(1) = ef("Name")
        ef.MoveNext
    Loop
Set ef = Nothing

'装载listview1中的项目
ListView1.ListItems.Clear
ListView1.LabelEdit = lvwAuto
ListView1.View = 3

sqlstr = "select * from Depart"
ef.Open sqlstr, con, 1, 1
  Do While Not ef.EOF
       Set Listit = ListView1.ListItems.Add(, , ef.Fields("ID"))
           Listit.SubItems(1) = ef("Name")
        ef.MoveNext
   Loop
Set ef = Nothing
End Sub

Private Sub ListView_DblClick()
   Call delzy_Click
End Sub

Private Sub ListView1_DblClick()
   Call delyx_Click
End Sub

Private Sub TabStrip1_Click()
   Static PreTab As Long
    PreTab = TabStrip1.SelectedItem.Index
    If PreTab = 1 Then
        Frame1(0).Visible = True
        Frame1(1).Visible = False
        Text1.SetFocus
    ElseIf PreTab = 2 Then
        Frame1(0).Visible = False
        Frame1(1).Visible = True
        Text3.SetFocus
    End If
End Sub

⌨️ 快捷键说明

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