www.pudn.com > studen.rar > Form1.vb
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports 管理系统.Module1
Public Class 学生管理系统
Dim stt As New student
Dim aConn As SqlConnection
Dim sel As SqlCommand
Public nd0 As New TreeNode
Public nd1 As New TreeNode
Public ds As New DataSet
Public i As Integer
Public j As Integer
Public st As String
Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
Dim selecomm As SqlCommand
Dim aConn As SqlConnection
aConn = New SqlConnection("Server=(local);user id=Sa;Password=;database=class")
aConn.Open()
If e.Node.Level = 3 Then
' Try月
'Dim selecomm As SqlCommandselect
Dim N As String
Dim M As String
Dim B As String
Dim C As String
Dim D As String
N = e.Node.Text.Trim()
M = e.Node.Parent.Parent.Text().Trim()
B = e.Node.Parent.Text().Trim()
A = M + B + N
F = M + B
H = A
Try
If e.Node.Text = "基本表" Then
ListView1.Items.Clear()
selecomm = New SqlCommand(" select 学号,姓名,性别,YEAR(GETDATE())-YEAR(出生年月),考生来源 from """ + A + """ ", aConn)
selecomm.CommandType = CommandType.Text
Dim myAdapter As New SqlDataAdapter
Dim adapter As New SqlDataAdapter
myAdapter.TableMappings.Add("Table", "gg")
adapter.SelectCommand() = selecomm
Dim ds As New DataSet
adapter.Fill(ds)
Dim i As Integer
Dim j As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1
ListView1.Items.Add(ds.Tables(0).Rows(i).Item(0))
For j = 1 To ds.Tables(0).Columns().Count - 1
ListView1.Items(i).SubItems.Add(ds.Tables(0).Rows(i)(j).ToString)
Next
Next
Else
If e.Node.Text = "课程表" Then
C = e.Node.Text
D = F + C
Dim ss As New DataSet
Dim da As SqlDataAdapter
Dim sql As String = "select DISTINCT * from """ + A + """ "
da = New SqlDataAdapter(sql, aConn)
da.Fill(ss)
DataGridView1.DataSource = ss.Tables(0)
'combobox1 填充
ComboBox2.Items.Clear()
selecomm = New SqlCommand(" select b.name from sysobjects a, syscolumns b where a.xtype='U' and a.name='" + A + "' and a.id=b.id ", aConn)
selecomm.CommandType = CommandType.Text
Dim myAdapter As New SqlDataAdapter
Dim adapter As New SqlDataAdapter
myAdapter.TableMappings.Add("Table", "Products")
adapter.SelectCommand() = selecomm
Dim ds As New DataSet
adapter.Fill(ds)
Dim i As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1
ComboBox2.Items.Add(ds.Tables(0).Rows(i).Item(0))
'For j = 1 To ds.Tables(0).Columns().Count - 1
' ListView1.Items(i).SubItems.Add(ds.Tables(0).Rows(i)(j).ToString)
'Next
Next
'ComboBox2.Items.Add("")
Else
Dim P As String
P = e.Node.Text
D = F + P
Dim ss As New DataSet
Dim da As SqlDataAdapter
Dim sql As String = "select * from """ + A + """ "
da = New SqlDataAdapter(sql, aConn)
da.Fill(ss)
DataGridView1.DataSource = ss.Tables(0)
'填充combobox2
ComboBox2.Items.Clear()
selecomm = New SqlCommand(" select b.name from sysobjects a, syscolumns b where a.xtype='U' and a.name='" + A + "' and a.id=b.id ", aConn)
selecomm.CommandType = CommandType.Text
Dim myAdapter As New SqlDataAdapter
Dim adapter As New SqlDataAdapter
myAdapter.TableMappings.Add("Table", "Products")
adapter.SelectCommand() = selecomm
Dim ds As New DataSet
adapter.Fill(ds)
Dim i As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1
ComboBox2.Items.Add(ds.Tables(0).Rows(i).Item(0))
Next
End If
End If
Catch
MsgBox("无信息,请及时录入")
End Try
End If
DF = e.Node.Index
If e.Node.Level = 0 Then
TreeView1.ContextMenuStrip = ContextMenuStrip1
Else
If e.Node.Level = 1 Then
TreeView1.ContextMenuStrip = ContextMenuStrip2
Else
End If
End If
End Sub
Private Sub bb(ByVal sender As Object, ByVal e As System.EventArgs)
'编写当你点击“复制”的时候要做什么样的操作
MsgBox("d")
End Sub
Private Sub aa(ByVal sender As Object, ByVal e As System.EventArgs)
'编写当你点击“复制”的时候要做什么样的操作
'MsgBox("dd")
Dim f3 As New Form3
f3.Show()
End Sub
Private Sub 学生管理系统_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myadapter As New SqlDataAdapter
Dim adapter As New SqlDataAdapter
aConn = New SqlConnection("server=(local);user id=Sa;password=;database=class")
aConn.Open()
' sel = New SqlCommand("select * from Sdept ", aConn)
sel = New SqlCommand("select * from sdept1 ", aConn)
sel.CommandType = CommandType.Text
myadapter.TableMappings.Add("Table", "cc")
adapter.SelectCommand() = sel
adapter.Fill(ds)
Dim str As String
Dim ndChild As TreeNode
Dim ndChild1 As TreeNode
Dim i As Integer
Dim j As Integer
Dim k As Integer
k = 0
ndChild = TreeView1.Nodes.Add("计算机与信息技术学院")
For i = 0 To ds.Tables(0).Rows.Count - 1
str = ds.Tables(0).Rows(i).Item(0)
If ndChild.Text <> str Then
If i = 0 Then
ndChild = ndChild.Nodes.Add(str)
Else
ndChild = ndChild.Parent
ndChild = ndChild.Nodes.Add(str)
End If
For j = 1 To ds.Tables(0).Columns.Count - 1
ndChild = ndChild.Nodes.Add(ds.Tables(0).Rows(i)(j))
ndChild.Nodes.Add("基本表")
ndChild.Nodes.Add("活动表")
ndChild.Nodes.Add("课程表")
ndChild.Nodes.Add("综合测评表")
Next
ndChild1 = ndChild.Parent.Parent
ndChild = ndChild.Parent
Else
For j = 1 To ds.Tables(0).Columns.Count - 1
ndChild = ndChild.Nodes.Add(ds.Tables(0).Rows(i)(j))
ndChild.Nodes.Add("基本表")
ndChild.Nodes.Add("活动表")
ndChild.Nodes.Add("课程表")
ndChild.Nodes.Add("综合测评表")
Next
ndChild = ndChild.Parent
End If
Next
ContextMenuStrip1.Items.Add("新建年级", Nothing, New EventHandler(AddressOf aa)) 'aa为相应事件
ContextMenuStrip1.Items.Add("-", Nothing, New EventHandler(AddressOf cc))
ContextMenuStrip1.Items.Add("退出", Nothing, New EventHandler(AddressOf cc))
ContextMenuStrip2.Items.Add("新建班级", Nothing, New EventHandler(AddressOf bb))
ContextMenuStrip2.Items.Add("-", Nothing, New EventHandler(AddressOf cc))
ContextMenuStrip2.Items.Add("退出", Nothing, New EventHandler(AddressOf cc))
End Sub
Private Sub cc(ByVal sender As Object, ByVal e As System.EventArgs)
'编写当你点击“复制”的时候要做什么样的操作
MsgBox("cc")
End Sub
Private Sub ListView1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
' Me.StudentTableAdapter.Fill(Me._学生_课程数据库DataSet.Student)
Dim name As String
If ListView1.SelectedIndices.Count <> 0 Then
name = ListView1.Items(ListView1.SelectedIndices(0)).Text
End If
If DF = 0 Then
C = A
'F = M
'H = N
D = "成绩表"
G = F + D
Module1.Sno = name
Dim f2 As New Form2
If name <> Nothing Then
Me.Hide()
f2.Show()
Else
End If
End If
End Sub
Private Sub DataGridView1_CellContentClick_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs)
'Name = DataGridView1.SelectionMode(DataGridView1.SelectedIndices(0)).Text
Dim f2 As Form2
f2 = New Form2
Module1.Sno = Name
f2.Show()
End Sub
Private Sub ListView2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub DataGridView1_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim ss As New DataSet
Dim da As SqlDataAdapter
Dim sql As String = "select * from """ + A + """ where " + ComboBox2.Text.Trim() + " like '%" + ComboBox1.Text.Trim() + "%' "
da = New SqlDataAdapter(sql, aConn)
da.Fill(ss)
DataGridView1.DataSource = ss.Tables(0)
Catch
MsgBox("查询结果为:零")
End Try
End Sub
Private Sub TextBox1_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs)
End Sub
Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
ComboBox1.Items.Clear()
Try
Dim selecomm As SqlCommand
selecomm = New SqlCommand(" select DISTINCT " + ComboBox2.Text + " from """ + A + """ ", aConn)
selecomm.CommandType = CommandType.Text
Dim myAdapter As New SqlDataAdapter
Dim adapter As New SqlDataAdapter
myAdapter.TableMappings.Add("Table", "Products")
adapter.SelectCommand() = selecomm
Dim ds As New DataSet
adapter.Fill(ds)
Dim i As Integer
For i = 0 To ds.Tables(0).Rows.Count - 1
ComboBox1.Items.Add(ds.Tables(0).Rows(i).Item(0))
Next
Catch
End Try
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
Private Sub 综合测评ToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 综合测评ToolStripMenuItem1.Click
Dim f6 As New 新建班级
f6.Show()
End Sub
Private Sub 新建ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 新建ToolStripMenuItem.Click
Form3.Show()
End Sub
Private Sub 基本信息管理ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 基本信息管理ToolStripMenuItem.Click
基本信息设置.Show()
End Sub
'Private Sub 活动管理ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 活动管理ToolStripMenuItem.Click
' 基本信息设置.TabControl1.TabPages("活动管理").Show()
'End Sub
Private Sub 新建班级ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 新建班级ToolStripMenuItem.Click
Form3.Show()
End Sub
Private Sub 删除班级ToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 删除班级ToolStripMenuItem.Click
Dim sts As New DataSet
sts = stt.deleteclass(删除班级.ComboBox1.Text.Trim(), 删除班级.ComboBox2.Text.Trim())
End Sub
End Class