protected void Page_Load(object sender, EventArgs e) { PatronAddLink.NavigateUrl = addPatronUrl; if (!IsPostBack) { DataTable dt; if (CustomUser.IsLibrarian) { dt = DatabaseHelper.Retrieve(@" Select FirstName, LastName, Email, LibraryCardNumber, Address, Zipcode, State From Patron "); } else { int libraryCardNumber = int.Parse(CustomUser.Identity.Name); dt = DatabaseHelper.Retrieve(@" Select FirstName, LastName, Email, LibraryCardNumber, Address, Zipcode, State From Patron where LibraryCardNumber = @LibraryCardNumber ", new SqlParameter("@LibraryCardNumber", libraryCardNumber)); } Patrons.DataSource = dt.Rows; Patrons.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { DataTable dt = DatabaseHelper.Retrieve(@" SELECT Patron.FirstName FROM Patron "); Patrons.DataSource = dt.Rows; Patrons.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { PatronAddLink.NavigateUrl = addPatronUrl; if (!IsPostBack) { DataTable dt = DatabaseHelper.Retrieve(@" Select FirstName, LastName, Email, LibraryCardNumber, Address, Zipcode, State From Patron "); Patrons.DataSource = dt.Rows; Patrons.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!int.TryParse(Request.QueryString["ID"], out bookCopyId)) { Response.Redirect("~/BookCopy.aspx"); } if (!IsPostBack) { DataTable dt = DatabaseHelper.Retrieve(@" select Title, ISBN, FirstName, LastName, BranchName from BookCopy join Book on (BookCopy.BookId = Book.Id) join Author on (Book.AuthorId = Author.Id) join Library on (BookCopy.LibraryId = Library.Id) where BookCopy.Id = @BookCopyId ", new SqlParameter("@BookCopyId", bookCopyId)); if (dt.Rows.Count == 1) { Title.Text = "Title: " + dt.Rows[0].Field <string>("Title"); Author.Text = "Author: " + dt.Rows[0].Field <string>("FirstName") + " " + dt.Rows[0].Field <string>("LastName"); ISBN.Text = "ISBN: " + dt.Rows[0].Field <string>("ISBN"); Library.Text = "Library: " + dt.Rows[0].Field <string>("BranchName"); DataTable dt2 = DatabaseHelper.Retrieve(@" select LibraryCardNumber, FirstName + ' ' + LastName as Name from Patron "); Patrons.DataValueField = "LibraryCardNumber"; Patrons.DataTextField = "Name"; Patrons.AppendDataBoundItems = true; Patrons.Items.Add(new ListItem("Select a patron...", "")); Patrons.DataSource = dt2; Patrons.DataBind(); } else { Response.Redirect("~/BookCopy.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { if (edit) { AddOrEdit.Text = "Edit Librarian"; Cancel.Visible = true; if (!int.TryParse(Request.QueryString["ID"], out librarianId)) { Response.Redirect(LibrarianList); } if (!IsPostBack) { DataTable dt = DatabaseHelper.Retrieve(@" select Librarian.LibraryCardNumber, LibraryId from Librarian join Library on (Librarian.LibraryId = Library.Id) join Patron on (Librarian.LibraryCardNumber = Patron.LibraryCardNumber) where Librarian.Id = @LibrarianId ", new SqlParameter("@LibrarianId", librarianId)); if (dt.Rows.Count == 1) { int selectedPatronId = dt.Rows[0].Field <int>("LibraryCardNumber"); int selectedLibraryId = dt.Rows[0].Field <int>("LibraryId"); Patrons.SelectedValue = selectedPatronId.ToString(); Libraries.SelectedValue = selectedLibraryId.ToString(); } else { Response.Redirect(LibrarianList); } } } else { AddOrEdit.Text = "Add Librarian"; } if (!IsPostBack) { DataTable dt = DatabaseHelper.Retrieve(@" select LibraryCardNumber, FirstName + ' ' + LastName As Name from Patron "); Patrons.DataValueField = "LibraryCardNumber"; Patrons.DataTextField = "Name"; Patrons.AppendDataBoundItems = true; Patrons.Items.Add(new ListItem("Select Value...", string.Empty)); Patrons.DataSource = dt; Patrons.DataBind(); DataTable dt2 = DatabaseHelper.Retrieve(@" select BranchName, Id from Library "); Libraries.DataValueField = "Id"; Libraries.DataTextField = "BranchName"; Libraries.AppendDataBoundItems = true; Libraries.Items.Add(new ListItem("Select Value...", string.Empty)); Libraries.DataSource = dt2; Libraries.DataBind(); } }