主题:网上选课系统中的容量,已选,余量如何增减.
If titlename = "" Then
Response.Write("<script>alert('请选择论文题目!')</script>")
Else
Dim ds11 As DataSet = New DataSet
ada = New OleDb.OleDbDataAdapter("select * from info where id='" & Session("ID") & "'", conn)
ada.Fill(ds11, "info")
Dim ds3 As DataSet = New DataSet
ada = New OleDb.OleDbDataAdapter("select * from courseinfo where id=" & b & "", conn)
ada.Fill(ds3, "courseinfo")
Dim ds5 As DataSet = New DataSet
ada = New OleDb.OleDbDataAdapter("select * from courseinfo where 课程名称='" & ds3.Tables("courseinfo").Rows(0).Item("课程名称") & "' and 已选='1'", conn)
ada.Fill(ds5, "courseinfo")
If ds11.Tables("info").Rows.Count > 0 Then
Response.Write("<script>alert('你已经选过了,不予重新选择!')</script>")
ElseIf ds5.Tables("courseinfo").Rows.Count < 0 Then
Response.Write("<script>alert('该课程已被选择,请选择其他题目!')</script>")
Else
ds3.Tables("courseinfo").Rows(0).Item("容量") = ds3.Tables("courseinfo").Rows(0).Item("容量") - 1
ds3.Tables("courseinfo").Rows(0).Item("已选") = ds3.Tables("courseinfo").Rows(0).Item("已选") + 1
ds3.Tables("courseinfo").Rows(0).Item("余量") = ds3.Tables("courseinfo").Rows(0).Item("余量") - 1
If ds3.Tables("courseinfo").Rows(0).Item("容量") < 0 Then
Response.Write("<script>alert('人数已满,你选择其他题目!')</script>")
Else
Dim cmd As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand
Dim str As String
str = "insert into info(id,课程名称,课程类别,起止周,上课时间,上课地点,教师姓名,学分) values('" & Session("id") & "','" & titlename & "','" & kcq & "','" & qzz & "','" & time & "','" & address & "','" & teacher & "','" & fs & "')"
cmd.Connection = conn
cmd.Connection.Open()
cmd.CommandText = str
cmd.ExecuteNonQuery()
cmd.Connection.Close()
str = "update courseinfo set 容量='" & a & "' where 课程名称='" & ds3.Tables("courseinfo").Rows(0).Item("课程名称") & "'"
cmd.Connection = conn
cmd.Connection.Open()
cmd.CommandText = str
cmd.ExecuteNonQuery()
cmd.Connection.Close()
str = "update courseinfo set 已选='1 ' where 课程名称='" & ds3.Tables("courseinfo").Rows(0).Item("课程名称") & "'"
cmd.Connection = conn
cmd.Connection.Open()
cmd.CommandText = str
cmd.ExecuteNonQuery()
cmd.Connection.Close()
Response.Write("<script>alert('操作成功,请退出!')</script>")
End If
End If
End If
End Sub
这里的容量,已选,余量不能增减,在网页中不能更新
Response.Write("<script>alert('请选择论文题目!')</script>")
Else
Dim ds11 As DataSet = New DataSet
ada = New OleDb.OleDbDataAdapter("select * from info where id='" & Session("ID") & "'", conn)
ada.Fill(ds11, "info")
Dim ds3 As DataSet = New DataSet
ada = New OleDb.OleDbDataAdapter("select * from courseinfo where id=" & b & "", conn)
ada.Fill(ds3, "courseinfo")
Dim ds5 As DataSet = New DataSet
ada = New OleDb.OleDbDataAdapter("select * from courseinfo where 课程名称='" & ds3.Tables("courseinfo").Rows(0).Item("课程名称") & "' and 已选='1'", conn)
ada.Fill(ds5, "courseinfo")
If ds11.Tables("info").Rows.Count > 0 Then
Response.Write("<script>alert('你已经选过了,不予重新选择!')</script>")
ElseIf ds5.Tables("courseinfo").Rows.Count < 0 Then
Response.Write("<script>alert('该课程已被选择,请选择其他题目!')</script>")
Else
ds3.Tables("courseinfo").Rows(0).Item("容量") = ds3.Tables("courseinfo").Rows(0).Item("容量") - 1
ds3.Tables("courseinfo").Rows(0).Item("已选") = ds3.Tables("courseinfo").Rows(0).Item("已选") + 1
ds3.Tables("courseinfo").Rows(0).Item("余量") = ds3.Tables("courseinfo").Rows(0).Item("余量") - 1
If ds3.Tables("courseinfo").Rows(0).Item("容量") < 0 Then
Response.Write("<script>alert('人数已满,你选择其他题目!')</script>")
Else
Dim cmd As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand
Dim str As String
str = "insert into info(id,课程名称,课程类别,起止周,上课时间,上课地点,教师姓名,学分) values('" & Session("id") & "','" & titlename & "','" & kcq & "','" & qzz & "','" & time & "','" & address & "','" & teacher & "','" & fs & "')"
cmd.Connection = conn
cmd.Connection.Open()
cmd.CommandText = str
cmd.ExecuteNonQuery()
cmd.Connection.Close()
str = "update courseinfo set 容量='" & a & "' where 课程名称='" & ds3.Tables("courseinfo").Rows(0).Item("课程名称") & "'"
cmd.Connection = conn
cmd.Connection.Open()
cmd.CommandText = str
cmd.ExecuteNonQuery()
cmd.Connection.Close()
str = "update courseinfo set 已选='1 ' where 课程名称='" & ds3.Tables("courseinfo").Rows(0).Item("课程名称") & "'"
cmd.Connection = conn
cmd.Connection.Open()
cmd.CommandText = str
cmd.ExecuteNonQuery()
cmd.Connection.Close()
Response.Write("<script>alert('操作成功,请退出!')</script>")
End If
End If
End If
End Sub
这里的容量,已选,余量不能增减,在网页中不能更新