-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyBks.aspx.cs
More file actions
85 lines (73 loc) · 2.78 KB
/
myBks.aspx.cs
File metadata and controls
85 lines (73 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Assignment3
{
public partial class myBks : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
booksTable.CssClass = "table table-hover";
TableRow tRow = new TableRow();
booksTable.Rows.Add(tRow);
TableCell tCell1 = new TableCell();
TableCell tCell2 = new TableCell();
TableCell tCell3 = new TableCell();
TableCell tCell5 = new TableCell();
tCell1.Text = "Title";
tCell2.Text = "Author";
tCell3.Text = "ISBN";
tCell5.Text = "Category";
tRow.Cells.Add(tCell1);
tRow.Cells.Add(tCell2);
tRow.Cells.Add(tCell3);
tRow.Cells.Add(tCell5);
Object idU = Session["id"];
string idUserStr = (string)idU;
int idUser = int.Parse(idUserStr);
string connStr = ConfigurationManager.ConnectionStrings["connStr"].ConnectionString;
string sql = "select distinct BookTitle, BookAuthor, ISBN, CAT_NAME, BookId from Book, Category, History, ud WHERE Book.CAT_ID=Category.CAT_ID AND History.HUserId="+idUser+" AND History.HBookId=Book.BookId AND ReturnDate IS NULL ";
SqlConnection con = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader dr;
try
{
con.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
TableRow tRow2 = new TableRow();
booksTable.Rows.Add(tRow2);
for (int j = 0; j <= 3; j++)
{
// Create a new cell and add it to the row.
TableCell tCell = new TableCell();
tCell.Text = dr[j].ToString();
tRow2.Cells.Add(tCell);
}
if (Session["id"] != null)
{
TableCell tCell4 = new TableCell();
string id = dr[4].ToString();
tCell4.Text = "<a href='return.aspx?id=" + id + "'><span class='btn btn-primary glyphicon glyphicon-cloud-upload'>Return </span></a>";
tRow2.Cells.Add(tCell4);
}
}
dr.Close();
}
catch (Exception ex)
{
Response.Write(ex.ToString());
}
finally
{
con.Close();
}
}
}
}