📄 main.aspx
字号:
<%@ Import NameSpace="System.Data" %>
<%@ Import NameSpace="System.Data.OleDb" %>
<script language="VB" runat="Server">
Dim objConn As OleDbConnection
Dim strSQL As String
Sub Page_Load(Sender As Object, E as EventArgs)
if session("master")="" then
response.redirect("cancel.aspx")
end if
textbox5.text=now()
end sub
Function Get_DSN(bolSQL As Boolean) As String
'--- bolSQL: True for SQL Server, False for Access ---
If Not bolSQL Then 'Access
Get_DSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& Server.MapPath("database.mdb")
Else 'SQL Server
Get_DSN = "Provider=SQLOLEDB.1;Data Source=Alvinnt;User ID=sa;" _
& "Password=;Initial Catalog=ASPNew;autotranslate=no;"
End If
End Function
Function Check_No(id As String) As Boolean
Dim objDR As OleDbDataReader
Dim objCmd As OleDbCommand
'---
strSQL = "select * from info where id='" & textbox1.text & "'"
'--- 创建OleDbCommand对象 ---
objCmd = New OleDbCommand(strSQL, objConn)
'--- 执行SQL命令 ---
objCmd.Connection.Open()
objDR = objCmd.ExecuteReader()
Check_No = False
While objDR.Read()
Check_No = True
End While
objCmd.Connection.Close()
End Function
Sub onclick1(Sender As Object, E As EventArgs)
Dim objCmd As OleDbCommand
Dim strDSN As String
strDSN = Get_DSN(False)
objConn = New OleDbConnection(strDSN)
If Not Check_No(id) and textbox1.text<>"" and textbox2.text<>"" and textbox4.text<>"" and textbox3.text<>"" and textbox6.text<>"" and textbox7.text<>"" Then
'--- 定义SQL字符串 ---
strSQL = " insert into info(id,name,class,grade,branch,state,place,buydate,date1,master,teacher,content) values ('" + textbox1.text + "','" + textbox2.text +"','" + select1.SelectedItem.text +"' ,'" +select2.SelectedItem.text +"','" + select3.SelectedItem.text +"','"+ select4.SelectedItem.text +"','" + textbox3.text +"','"+ textbox4.text +"','" + now() +"','" + textbox6.text +"','" + "未借出" +"','" + textbox7.text +"')"
'--- 创建OleDbConnection ---
objConn = New OleDbConnection(strDSN)
'--- 创建OleDbCommand对象 ---
objCmd = New OleDbCommand(strSQL, objConn)
'--- 执行SQL命令 ---
objCmd.Connection.Open()
objCmd.ExecuteNonQuery()
objCmd.Connection.Close()
label1.text=" 数据录入成功,请继续努力!!"
textbox1.text=""
textbox2.text=""
textbox3.text=""
textbox4.text=""
textbox6.text=""
textbox7.text=""
else
label1.text=" 你好粗心,项目没有填写完整或者输入的编号已经存在!!"
Response.Write("<hr><a href='javascript:history.go(-1)'>")
Response.Write("回前一画面</a>")
End If
End Sub
</script>
<html>
<head><title>欢迎使用音像资料管理系统</title></head>
<body>
<link href="css/class.css" type=text/css rel=stylesheet>
<form id="Form1" method="post" runat="server">
<font size=6><center>致远工作室音像资料管理系统</center></font>
<table border="1" align="center" bordercolor="blue">
<tr>
<td>编 号:</td><td><asp:textbox id="textbox1" runat="server"/></td>
</tr>
<tr>
<td>名 称:</td><td><asp:textbox id="textbox2" runat="server"/></td>
</tr>
<tr>
<td>存储介质:</td><td><asp:DropDownList id="Select1" runat="server" >
<asp:ListItem Text="CD-ROM" />
<asp:ListItem Text="DVD-ROM" />
<asp:ListItem Text="VCD" />
<asp:ListItem Text="录象带" />
<asp:ListItem Text="投影片" />
<asp:ListItem Text="录音带" />
<asp:ListItem Text="挂 图" />
<asp:ListItem Text="其 他" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>适用年级:</td><td><asp:DropDownList id="Select2" runat="server" >
<asp:ListItem Text="一年级" />
<asp:ListItem Text="二年级" />
<asp:ListItem Text="三年级" />
<asp:ListItem Text="四年级" />
<asp:ListItem Text="五年级" />
<asp:ListItem Text="六年级" />
<asp:ListItem Text="通 用" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>学 科:</td><td><asp:DropDownList id="Select3" runat="server" >
<asp:ListItem Text="语 文" />
<asp:ListItem Text="数 学" />
<asp:ListItem Text="英 语" />
<asp:ListItem Text="音 乐" />
<asp:ListItem Text="美 术" />
<asp:ListItem Text="科 学" />
<asp:ListItem Text="思 品" />
<asp:ListItem Text="综 合" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>借出标记:</td><td><asp:DropDownList id="Select4" runat="server" >
<asp:ListItem Text="未 借" />
<asp:ListItem Text="借 出" />
</asp:DropDownList>
</td>
</tr>
<tr>
<td>存储位置:</td><td><asp:textbox id="textbox3" runat="server"/></td>
</tr>
<tr>
<td>出版时间:</td><td><asp:textbox id="textbox4" runat="server"/></td>
</tr>
<tr>
<td>收录时间:</td><td><asp:textbox id="textbox5" runat="server"/><td>
</tr>
<tr>
<td>操 作 员:</td><td><asp:textbox id="textbox6" runat="server"/></td>
</tr>
<tr>
<td>内容概要:</td><td><asp:textbox id="textbox7" textmode="multiline" columns="30" rows="10" runat="server"/></td>
</tr>
<tr>
<td>
<asp:button id="button1" text=" 确 定 " onclick="onclick1" runat="server"/></td>
<td align="center">
<asp:button id="button2" text=" 取 消 " runat="server"/></td>
</tr>
</table>
<a href="default.aspx">返回资源管理中心</a>
<hr>
<center>
<asp:label id="label1" runat="server"/>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -