Додаток 1 – Лістинг програми
Лістинг файлу «man_menu.aspx»
<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
If Len(Session("LibUserID")) = 0 Then
Response.Redirect("./index.aspx")
End If
If Session("UserType") <> "Бібліотекарь" Then
Response.Redirect("./menu.aspx")
End If
If Not IsPostBack Then
Dim DBConn as OleDbConnection
Dim DBCommand As OleDbDataAdapter
Dim DSPageData as New DataSet
DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("/INetBook/C5/Library/" _
& "Access/C5Library.mdb;"))
DBCommand = New OleDbDataAdapter _
("select LibBookCategoryID, CategoryName " _
& "from LibCategories Order By CategoryName" _
, DBConn)
DBCommand.Fill(DSPageData, _
"Categories")
ddlibBookCategoryID.DataSource = _
DSPageData.Tables("Categories").DefaultView
ddlibBookCategoryID.DataBind()
DBCommand = New OleDbDataAdapter _
("select LibBookID, BookTitle " _
& "from LibBooks Order By BookTitle" _
, DBConn)
DBCommand.Fill(DSPageData, _
"Books")
ddlBooks.DataSource = _
DSPageData.Tables("Books").DefaultView
ddlBooks.DataBind()
End If
End Sub
Sub Delete_Click(Sender As Object, E As EventArgs)
Dim DBConn as OleDbConnection
Dim DBCommand As OleDbDataAdapter
Dim DSPageData as New DataSet
Dim DBDelete As New OleDbCommand
DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("/INetBook/C5/Library/" _
& "Access/C5Library.mdb;"))
DBDelete.CommandText = "Delete From LibBooks " _
& "Where LibBookID = " & ddlBooks.SelectedItem.Value
DBDelete.Connection = DBConn
DBDelete.Connection.Open
DBDelete.ExecuteNonQuery()
DBCommand = New OleDbDataAdapter _
("select LibBookID, BookTitle " _
& "from LibBooks Order By BookTitle" _
, DBConn)
DBCommand.Fill(DSPageData, _
"Books")
ddlBooks.DataSource = _
DSPageData.Tables("Books").DefaultView
ddlBooks.DataBind()
End Sub
Sub Add_Click(Sender As Object, E As EventArgs)
Dim DBConn as OleDbConnection
Dim DBInsert As New OleDbCommand
DBConn = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
& "DATA SOURCE=" _
& Server.MapPath("/INetBook/C5/Library/" _
& "Access/C5Library.mdb;"))
DBInsert.CommandText = "Insert Into LibBooks " _
& "(BookTitle, Author, LibBookCategoryID, ISBN, " _
& "Keywords, Description, Status, CheckedOutTo) " _
& "values (" _
& "'" & Replace(txtBookTitle.Text, "'", "''") & "', " _
& "'" & Replace(txtAuthor.Text, "'", "''") & "', " _
& ddlibBookCategoryID.SelectedItem.Value & ", " _
& "'" & Replace(txtISBN.Text, "'", "''") & "', " _
& "'" & Replace(txtKeywords.Text, "'", "''") & "', " _
& "'" & Replace(txtDescription.Text, "'", "''") & "', " _
& "'Доступна', 0)"
DBInsert.Connection = DBConn
DBInsert.Connection.Open
DBInsert.ExecuteNonQuery()
Response.Redirect("./menu.aspx")
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Бібліотека</TITLE>
</HEAD>
<BODY BACKGROUND="./lp.gif" TEXT="darkslateblue" LINK="darkred" VLINK="darkred" ALINK="red" LEFTMARGIN="140">
<form runat="server">
<asp:Label
id="lblTitle"
Font-Size="25pt"
Font-Name="Tahoma"
Text="Меню бібліотекаря"
runat="server"
/>
<IMG SRC="./line.gif">
<Font Face="Tahoma">
<BR>
<B>Вибиріть книгу для видалення.</B>
<BR><BR>
<Table>
<TR>
<TD>
<B>Назва:</B>
</TD>
<TD>
<asp:dropdownlist
id="ddlBooks"
runat=server
DataTextField="BookTitle"
DataValueField="LibBookID">
</asp:dropdownlist>
</TD>
</TR>
<TR>
<TD>
<asp:button
id="butDelete"
text="Видалити"
Type="Submit"
OnClick="Delete_Click"
runat="server"
/>
</TD>
</TR>
</Table>
<IMG SRC="./line.gif">
<BR>
<B>Заповніть всі поля для додавання книги в бібліотеку.</B>
<BR><BR>
<Table>
<TR>
<TD>
<B>Назва:</B>
</TD>
<TD>
<asp:TextBox
id="txtBookTitle"
Columns="25"
MaxLength="100"
runat=server />
</TD> </TR>
<TR> <TD> <B>Категорія:</B> </TD>
<TD>
<asp:dropdownlist
id="ddlibBookCategoryID"
runat=server
DataTextField="CategoryName"
DataValueField="LibBookCategoryID">
</asp:dropdownlist>
</TD> </TR>
<TR> <TD> <B>Автор:</B></TD>
<TD>
<asp:TextBox
id="txtAuthor"
Columns="25"
MaxLength="100"
runat=server />
</TD> </TR>
<TR> <TD> <B>ISBN:</B> </TD>
<TD>
<asp:TextBox
id="txtISBN"
Columns="25"
MaxLength="50"
runat=server />
</TD> </TR>
<TR> <TD> <B>Ключові слова:</B> </TD>
<TD>
<asp:TextBox
id="txtKeywords"
Columns="25"
MaxLength="100"
runat=server />
</TD> </TR>
<TR> <TD> <B>Анотація:</B> </TD>
<TD>
<asp:TextBox
id="txtDescription"
Columns="25"
MaxLength="255"
runat=server />
</TD> </TR>
<TR> <TD>
<asp:button
id="butAdd"
text="Додати"
Type="Submit"
OnClick="Add_Click"
runat="server"/>
</TD> </TR> </Table>
<BR> <A HREF="./menu.aspx"><B>На сторінку Меню</B></A>
</Font>
</Form>
</BODY>
</HTML>
Дата добавления: 2016-06-05 | Просмотры: 340 | Нарушение авторских прав
1 | 2 | 3 | 4 | 5 |
|