/// <summary> /// Tyler Collins /// Created: 2015/02/05 /// DELETEs (Sets Boolean Active field to false) a Supplier record in Database using a Stored Procedure. /// </summary> /// <remarks> /// Pat Banks /// Updated: 2015/04/25 /// Added supplier login archive to stored procedure & renamed SP /// </remarks> /// <param name="supplierToDelete">Requires the Supplier object which matches the record to be DELETED in the Database.</param> /// <returns>Returns the number of rows affected</returns> public static int DeleteSupplier(Supplier supplierToDelete) { var conn = DatabaseConnection.GetDatabaseConnection(); string storedProcedure = "spArchiveSupplierSupplierLogin"; var cmd = new SqlCommand(storedProcedure, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@CompanyName", supplierToDelete.CompanyName); cmd.Parameters.AddWithValue("@FirstName", supplierToDelete.FirstName); cmd.Parameters.AddWithValue("@LastName", supplierToDelete.LastName); cmd.Parameters.AddWithValue("@Address1", supplierToDelete.Address1); cmd.Parameters.AddWithValue("@Address2", supplierToDelete.Address2); cmd.Parameters.AddWithValue("@Zip", supplierToDelete.Zip); cmd.Parameters.AddWithValue("@PhoneNumber", supplierToDelete.PhoneNumber); cmd.Parameters.AddWithValue("@EmailAddress", supplierToDelete.EmailAddress); cmd.Parameters.AddWithValue("@ApplicationID", supplierToDelete.ApplicationID); cmd.Parameters.AddWithValue("@SupplierID", supplierToDelete.SupplierID); int rowsAffected; try { conn.Open(); rowsAffected = cmd.ExecuteNonQuery(); } catch (Exception) { throw; } finally { conn.Close(); } return rowsAffected; }
public void setup() { Supplier testSupplier = new Supplier(); testSupplier = new Supplier(); testSupplier.CompanyName = "fakeCompany"; testSupplier.FirstName = "FakeLogin"; testSupplier.LastName = "FakeLogin"; testSupplier.Address1 = "255 East West St"; testSupplier.Address2 = "APT 1"; testSupplier.Zip = "50229"; testSupplier.PhoneNumber = "575-542-8796"; testSupplier.EmailAddress = "*****@*****.**"; testSupplier.ApplicationID = 999; testSupplier.SupplyCost = (decimal)((60) / 100); testSupplier.Active = true; SupplierAccessor.AddSupplier(testSupplier, "Test", "Password#1"); try { var supList = SupplierAccessor.GetSupplierList(); foreach (Supplier x in supList) { if (x.FirstName.Equals("FirstBlab")) { suppID = x.SupplierID; } } } catch(Exception ex) { throw new Exception("what"); } }
/// <summary> /// Reece Maas /// Created: 2015/02/18 /// Adds a single Supplier to the database /// Throws any exceptions caught by the DAL /// </summary> /// <remarks> /// Matt Lapka /// Updated: 2015/03/27 /// Added supplier cache /// </remarks> /// <param name="supplierToAdd">Supplier object containing the information of the supplier to be added</param> /// <param name="userName">The username to be given to the Supplier</param> /// <returns>An enumerated result depicting pass or fail</returns> public SupplierResult AddANewSupplier(Supplier supplierToAdd, string userName) { try { PasswordManager myPass = new PasswordManager(); string password = myPass.supplierHash(userName, "Password#1"); if (SupplierAccessor.AddSupplier(supplierToAdd, userName, password) == 2) { //refresh cache DataCache._currentSupplierList = SupplierAccessor.GetSupplierList(); DataCache._SupplierListTime = DateTime.Now; return SupplierResult.Success; } return SupplierResult.NotAdded; } catch (ApplicationException ex) { return ex.Message == "Concurrency Violation" ? SupplierResult.ChangedByOtherUser : SupplierResult.DatabaseError; } catch (Exception ex) { throw ex; //return SupplierResult.DatabaseError; } }
public void AddItemListing_Success() { Setup(); SupplierManager mySupMan = new SupplierManager(); mySupMan.AddANewSupplier(testSupp, "Test"); modSupp = getSupplierListCompName(suppList); itemListingToTest.SupplierID = modSupp.SupplierID; listResult actual = pMgr.AddItemListing(itemListingToTest); Cleanup(); Assert.AreEqual(listResult.Success, actual); }
/// <summary> /// Will Fritz /// Created: 2015/02/06 /// initializes screen /// </summary> /// <remarks> /// Miguel Santana /// Updated: 2015/04/09 /// combined add/edit screens /// </remarks> /// <param name="supplierToEdit"></param> /// <param name="readOnly"></param> /// <exception cref="WanderingTurtleException">Error setting the fields as read only.</exception> public AddEditSupplier(Supplier supplierToEdit, bool readOnly = false) { InitializeComponent(); _updatableSupplier = supplierToEdit; Title = "Editing Supplier: " + _updatableSupplier.GetFullName; //retrieve the username _supplierUserName = _loginManager.RetrieveSupplierUserName(supplierToEdit.SupplierID); FillComboBox(); FillUpdateList(); TxtUserName.IsEnabled = false; if (readOnly) { (Content as Panel).MakeReadOnly(); } }
public void ArchiveItemListing_ValidItemListing() { Setup(); SupplierManager myMan = new SupplierManager(); ProductManager otherMan = new ProductManager(); myMan.AddANewSupplier(testSupp, "Test"); modSupp = getSupplierListCompName(suppList); itemListingToTest.SupplierID = modSupp.SupplierID; otherMan.AddItemListing(itemListingToTest); itemListingToTest = getItemListingTestObject(itemList); itemListingToTest.CurrentNumGuests = 0; listResult actual = pMgr.ArchiveItemListing(itemListingToTest); Assert.AreEqual(listResult.Success, actual); Cleanup(); }
public void AddItemListing_ValidItemListing() { int expected = 1; setup(); SupplierAccessor.AddSupplier(testSupp, "Test", "Password#1"); modSupp = getSupplierListCompName(suppList); itemListingToTest.SupplierID = modSupp.SupplierID; int actual = ItemListingAccessor.AddItemListing(itemListingToTest); ItemListingAccessor.DeleteItemListingTestItem(itemListingToTest); testSupp.SupplierID = modSupp.SupplierID; testLog = sLA.RetrieveSupplierLogin("Password#1", "Test"); SupplierLoginAccessor.DeleteTestSupplierLogin(testLog); TestCleanupAccessor.DeleteTestSupplier(testSupp); Assert.AreEqual(expected, actual); }
/// <summary> /// Miguel Santana /// Created: 2015/04/18 /// Opens supplier form depending if it is read only or not /// </summary> /// <param name="selectedItem"></param> /// <param name="readOnly"></param> private void OpenSupplier(Supplier selectedItem = null, bool readOnly = false) { try { if (selectedItem == null) { if (new AddEditSupplier().ShowDialog() == false) return; FillList(); } else { if (new AddEditSupplier(selectedItem, readOnly).ShowDialog() == false || readOnly) return; FillList(); } } catch (Exception ex) { throw new WanderingTurtleException(this, ex); } }
/// <summary> /// Tyler Collins /// Created: 2015/02/04 /// INSERTs a Supplier into the Database using a Stored Procedure. /// </summary> /// <param name="supplierToAdd">Requires a Supplier object to INSERT</param> /// <param name="userName">The username of the Supplier</param> /// <returns>Returns the number of rows affected.</returns> public static int AddSupplier(Supplier supplierToAdd, string userName, string password) { var conn = DatabaseConnection.GetDatabaseConnection(); string storedProcedure = "spInsertSupplier"; var cmd = new SqlCommand(storedProcedure, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@UserName", userName); cmd.Parameters.AddWithValue("@CompanyName", supplierToAdd.CompanyName); cmd.Parameters.AddWithValue("@FirstName", supplierToAdd.FirstName); cmd.Parameters.AddWithValue("@LastName", supplierToAdd.LastName); cmd.Parameters.AddWithValue("@Address1", supplierToAdd.Address1); cmd.Parameters.AddWithValue("@Address2", supplierToAdd.Address2); cmd.Parameters.AddWithValue("@Zip", supplierToAdd.Zip); cmd.Parameters.AddWithValue("@PhoneNumber", supplierToAdd.PhoneNumber); cmd.Parameters.AddWithValue("@EmailAddress", supplierToAdd.EmailAddress); cmd.Parameters.AddWithValue("@ApplicationID", supplierToAdd.ApplicationID); cmd.Parameters.AddWithValue("@SupplyCost", (float)supplierToAdd.SupplyCost); cmd.Parameters.AddWithValue("@password", password); int rowsAffected; try { conn.Open(); rowsAffected = cmd.ExecuteNonQuery(); } catch (Exception) { throw; } finally { conn.Close(); } return rowsAffected; }
public void RetrieveSupplierBadIDTest() { string supplierID = "badID"; testSupplierRetrieve = SupplierMang.RetrieveSupplier(supplierID); Assert.IsNull(testSupplierRetrieve); }
public void EditSupplierPartialTest() { Supplier testSupplierPartial = new Supplier(); testSupplierPartial.CompanyName = "test"; testSupplierPartial.SupplierID = 100; testSupplierPartial.PhoneNumber = "234-234-2341"; testSupplierPartial.FirstName = "test"; Assert.AreEqual(SupplierMang.EditSupplier(testSupplierPartial, testSupplierPartial), SupplierResult.DatabaseError); }
public void EditSupplierEmptyTest() { Supplier testSupplierEmpty = new Supplier(); Assert.AreEqual(SupplierMang.EditSupplier(testSupplierEmpty, testSupplierEmpty), SupplierResult.DatabaseError); }
public void AddSupplierNullTest() { Supplier testSupplierNull = new Supplier(); testSupplierNull = null; Assert.AreEqual(SupplierMang.AddANewSupplier(testSupplierNull, "Test"), SupplierResult.DatabaseError); TestCleanupAccessor.DeleteTestSupplier(testSupplierNull); }
public void EditSetup() { SupplierManager mySupMan = new SupplierManager(); mySupMan.AddANewSupplier(testSupp, "Test"); modSupp = getSupplierListCompName(suppList); itemListingToEdit.SupplierID = modSupp.SupplierID; ItemListingAccessor.AddItemListing(itemListingToTest); itemListingToTest = getItemListingTestObject(itemList); itemListingToEdit.SupplierID = modSupp.SupplierID; }
private void Setup(string CompName) { //set up supplier testSupplier = new Supplier(); testSupplier.CompanyName = CompName; testSupplier.FirstName = "FirstBlab"; testSupplier.LastName = "LastBlab"; testSupplier.Address1 = "255 East West St"; testSupplier.Address2 = "APT 1"; testSupplier.Zip = "50229"; testSupplier.PhoneNumber = "575-542-8796"; testSupplier.EmailAddress = "*****@*****.**"; testSupplier.ApplicationID = 999; testSupplier.SupplyCost = (decimal)((60) / 100); testSupplier.Active = true; //setup Supplier application testSupplierApp = new SupplierApplication(); testSupplierApp.ApplicationDate = new DateTime(2005, 2, 3); testSupplierApp.CompanyName = "Awsome Tours"; testSupplierApp.CompanyDescription = "tours of awsomeness"; testSupplierApp.PhoneNumber = "575-542-8796"; testSupplierApp.FirstName = "Test"; testSupplierApp.Address1 = "255 East West St"; testSupplierApp.LastName = "blabla"; testSupplierApp.Zip = "50229"; testSupplierApp.ApplicationID = 999; testSupplierApp.EmailAddress = "*****@*****.**"; testSupplierApp.Address2 = ""; testSupplierApp.ApplicationDate = new DateTime(2005, 2, 2); testSupplierApp.ApplicationStatus = "pending"; testSupplierApp.LastStatusDate = new DateTime(2005, 2, 1); testSupplierApp.Remarks = ""; }
public void RetrieveSupplierWorkingTest() { supplierID = "101"; testSupplierRetrieve = SupplierMang.RetrieveSupplier(supplierID); Assert.IsNotNull(testSupplierRetrieve); }
/// <summary> /// Tyler Collins /// Created: 2015/02/04 /// UPDATEs a Supplier record in the Database with new using a Stored Procedure. /// </summary> /// <param name="newSupplierInfo">Requires the Supplier object containing the new information</param> /// <param name="oldSupplierInfo">Requires the Supplier object to replace that matches the record in the Database</param> /// <returns>Returns the number of rows affected.</returns> public static int UpdateSupplier(Supplier newSupplierInfo, Supplier oldSupplierInfo) { var conn = DatabaseConnection.GetDatabaseConnection(); string storedProcedure = "spUpdateSupplier"; var cmd = new SqlCommand(storedProcedure, conn); cmd.CommandType = CommandType.StoredProcedure; //Updated Supplier Info: cmd.Parameters.AddWithValue("@CompanyName", newSupplierInfo.CompanyName); cmd.Parameters.AddWithValue("@FirstName", newSupplierInfo.FirstName); cmd.Parameters.AddWithValue("@LastName", newSupplierInfo.LastName); cmd.Parameters.AddWithValue("@Address1", newSupplierInfo.Address1); cmd.Parameters.AddWithValue("@Address2", newSupplierInfo.Address2); cmd.Parameters.AddWithValue("@Zip", newSupplierInfo.Zip); cmd.Parameters.AddWithValue("@PhoneNumber", newSupplierInfo.PhoneNumber); cmd.Parameters.AddWithValue("@EmailAddress", newSupplierInfo.EmailAddress); cmd.Parameters.AddWithValue("@ApplicationID", newSupplierInfo.ApplicationID); cmd.Parameters.AddWithValue("@SupplyCost", newSupplierInfo.SupplyCost); //Old Supplier Info cmd.Parameters.AddWithValue("@SupplierID", oldSupplierInfo.SupplierID); cmd.Parameters.AddWithValue("@originalCompanyName", oldSupplierInfo.CompanyName); cmd.Parameters.AddWithValue("@originalFirstName", oldSupplierInfo.FirstName); cmd.Parameters.AddWithValue("@originalLastName", oldSupplierInfo.LastName); cmd.Parameters.AddWithValue("@originalAddress1", oldSupplierInfo.Address1); cmd.Parameters.AddWithValue("@originalAddress2", oldSupplierInfo.Address2); cmd.Parameters.AddWithValue("@originalZip", oldSupplierInfo.Zip); cmd.Parameters.AddWithValue("@originalPhoneNumber", oldSupplierInfo.PhoneNumber); cmd.Parameters.AddWithValue("@originalEmailAddress", oldSupplierInfo.EmailAddress); cmd.Parameters.AddWithValue("@originalApplicationID", oldSupplierInfo.ApplicationID); cmd.Parameters.AddWithValue("@originalSupplyCost", oldSupplierInfo.SupplyCost); int rowsAffected; try { conn.Open(); rowsAffected = cmd.ExecuteNonQuery(); } catch (Exception) { throw; } finally { conn.Close(); } return rowsAffected; }
/// <summary> /// Tyler Collins /// Created: 2015/02/03 /// Retrieves all Supplier data from the Database using a Stored Procedure. /// Creates a Supplier object from retrieved data. /// Adds Supplier object to List of Supplier objects. /// </summary> /// <returns>List of Supplier objects</returns> public static List<Supplier> GetSupplierList() { List<Supplier> supplierList = new List<Supplier>(); var conn = DatabaseConnection.GetDatabaseConnection(); string storedProcedure = "spSelectAllSuppliers"; var cmd = new SqlCommand(storedProcedure, conn); cmd.CommandType = CommandType.StoredProcedure; try { conn.Open(); var reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { var currentSupplier = new Supplier(); currentSupplier.SupplierID = reader.GetInt32(0); currentSupplier.CompanyName = reader.GetString(1); currentSupplier.FirstName = reader.GetString(2); currentSupplier.LastName = reader.GetString(3); currentSupplier.Address1 = reader.GetString(4); currentSupplier.Address2 = !reader.IsDBNull(5) ? currentSupplier.Address2 = reader.GetString(5) : null; currentSupplier.Zip = reader.GetString(6); currentSupplier.PhoneNumber = reader.GetString(7); currentSupplier.EmailAddress = reader.GetString(8); currentSupplier.ApplicationID = reader.GetInt32(9); currentSupplier.SupplyCost = reader.GetDecimal(10); supplierList.Add(currentSupplier); } } else { var pokeball = new ApplicationException("Data Not Found!"); throw pokeball; } } catch (Exception) { throw; } finally { conn.Close(); } return supplierList; }
/// <summary> /// Tyler Collins /// Created: 2015/02/03 /// Retrieves Supplier information from the Database using a Stored Procedure. /// Creates a Supplier object. /// </summary> /// <remarks> /// Ryan Blake /// Updated: 2015/04/03 /// Added Supplier Cost /// </remarks> /// <param name="supplierID">Requires a SupplierID to SELECT the correct Supplier record.</param> /// <returns>Supplier object</returns> public static Supplier GetSupplier(string supplierID) { Supplier supplierToRetrieve = new Supplier(); SqlConnection conn = DatabaseConnection.GetDatabaseConnection(); string storedProcedure = "spSelectSupplier"; SqlCommand cmd = new SqlCommand(storedProcedure, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SupplierID", supplierID); try { conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); supplierToRetrieve.SupplierID = reader.GetInt32(0); supplierToRetrieve.CompanyName = reader.GetString(1); supplierToRetrieve.FirstName = reader.GetString(2); supplierToRetrieve.LastName = reader.GetString(3); supplierToRetrieve.Address1 = reader.GetString(4); supplierToRetrieve.Address2 = !reader.IsDBNull(5) ? supplierToRetrieve.Address2 = reader.GetString(5) : null; supplierToRetrieve.Zip = reader.GetString(6); supplierToRetrieve.PhoneNumber = reader.GetString(7); supplierToRetrieve.EmailAddress = reader.GetString(8); supplierToRetrieve.ApplicationID = reader.GetInt32(9); supplierToRetrieve.SupplyCost = reader.GetDecimal(10); } else { var pokeball = new ApplicationException("Requested ID did not match any records."); throw pokeball; } } catch (Exception) { throw; } finally { conn.Close(); } return supplierToRetrieve; }
/// <summary> /// Reece Maas /// Created: 2015/02/18 /// Updates a Supplier /// Throws any exceptions caught by the DAL /// </summary> /// <remarks> /// Matt Lapka /// Updated: 2015/03/27 /// Added supplier cache /// </remarks> /// <param name="newSupplier">Supplier object containing the new information of the supplier</param> /// <param name="oldSupplier">Supplier object containing the current information of the supplier to be matched to salve concurrency problems</param> /// <returns>An enumerated result depicting pass or fail</returns> public SupplierResult EditSupplier(Supplier oldSupplier, Supplier newSupplier) { try { if (SupplierAccessor.UpdateSupplier(newSupplier, oldSupplier) == 1) { //update cache DataCache._currentSupplierList = SupplierAccessor.GetSupplierList(); DataCache._SupplierListTime = DateTime.Now; return SupplierResult.Success; } return SupplierResult.NotChanged; } catch (ApplicationException ex) { return ex.Message == "Concurrency Violation" ? SupplierResult.ChangedByOtherUser : SupplierResult.DatabaseError; } catch (Exception) { return SupplierResult.DatabaseError; } }
/// <summary> /// Hunter Lind /// Created: 2015/04/16 /// /// Deletes Test Supplier Data /// </summary> /// <param name="supplierToDelete">The fake Supplier object to be deleted from the database</param> /// <returns>An int reflecting number of rows affected</returns> public static int DeleteTestSupplier(Supplier supplierToDelete) { var conn = DatabaseConnection.GetDatabaseConnection(); string storedProcedure = "spDeleteTestSupplier"; var cmd = new SqlCommand(storedProcedure, conn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@SupplierID", supplierToDelete.SupplierID); int rowsAffected; try { conn.Open(); rowsAffected = cmd.ExecuteNonQuery(); } catch (Exception) { throw; } finally { conn.Close(); } return rowsAffected; }
public void RetrieveSupplierEmptyIDTest() { supplierID = ""; testSupplierRetrieve = SupplierMang.RetrieveSupplier(supplierID); Assert.IsNull(testSupplierRetrieve); }
public void RetrieveSupplierNullTest() { supplierID = null; testSupplierRetrieve = SupplierMang.RetrieveSupplier(supplierID); Assert.IsNull(testSupplierRetrieve); }
/// <summary> /// Matt Lapka /// Created: 2015/02/08 /// Archives a Supplier /// </summary> /// <remarks> /// Pat Banks /// Updated: 2015/04/26 /// Added archiving of login at the same time as archiving other supplier information /// </remarks> /// <param name="supplierToDelete">The Supplier object to be deleted/made inactive</param> /// <returns> /// An enumerated result depicting pass or fail /// </returns> public SupplierResult ArchiveSupplier(Supplier supplierToDelete) { try { if (SupplierAccessor.DeleteSupplier(supplierToDelete) == 2) { //update cache DataCache._currentSupplierList = SupplierAccessor.GetSupplierList(); DataCache._SupplierListTime = DateTime.Now; return SupplierResult.Success; } return SupplierResult.NotChanged; } catch (ApplicationException ex) { return ex.Message == "Concurrency Violation" ? SupplierResult.ChangedByOtherUser : SupplierResult.DatabaseError; } catch (Exception) { return SupplierResult.DatabaseError; } }
private void findTestItemDetails() { var listToSearch = SupplierMang.RetrieveSupplierList(); foreach (var item in listToSearch) { if (item.ApplicationID == 999) { testSupplier = item; } } }
public void AddSupplierEmptyTest() { //test 1 empty Supplier Supplier testSupplierEmpty = new Supplier(); Assert.AreEqual(SupplierMang.AddANewSupplier(testSupplierEmpty, "Test"), SupplierResult.DatabaseError); TestCleanupAccessor.DeleteTestSupplier(testSupplierEmpty); }
private Supplier test2() { Supplier toTest = new Supplier(); toTest.CompanyName = "Lame-Name tours"; toTest.FirstName = "Test"; toTest.LastName = "LastBlab"; toTest.Address1 = "255 East West St"; toTest.Address2 = "APT 1"; toTest.Zip = "50229"; toTest.PhoneNumber = "575-542-8796"; toTest.EmailAddress = "*****@*****.**"; toTest.ApplicationID = 100; toTest.SupplyCost = (decimal)((60) / 100); toTest.Active = true; return toTest; }
/// <summary> /// Matt Lapka /// Created 2015/04/16 /// Sets login information based on session data /// </summary> private void testLogin() { try { //attempt to get session value if they are logged in loggedIn = (bool)Session["loggedin"]; _currentSupplier = (Supplier)Session["user"]; supplierID = _currentSupplier.SupplierID; } catch (Exception) { //if it fails, the user must not have logged in on this //session yet, so set it to false Session["loggedIn"] = false; //send them to the login page Response.Redirect("~/login"); } if (!loggedIn) { //if not logged in, send them to login page Response.Redirect("~/login"); } }
/// <summary> /// Will Fritz /// Created: 2015/02/06 /// This will send a supplier object to the business logic layer /// </summary> /// <remarks> /// Will Fritz /// Updated: 2015/02/15 /// Added confirmation message box /// Rose Steffensmeier /// Updated: 2015/04/24 /// deleted checking supplierUserName /// </remarks> private async void EditSupplier() { try { Supplier tempSupplier = new Supplier { CompanyName = TxtCompanyName.Text.Trim(), FirstName = TxtFirstName.Text.Trim(), LastName = TxtLastName.Text.Trim(), Address1 = TxtAddress1.Text.Trim(), Address2 = TxtAddress2.Text.Trim(), PhoneNumber = TxtPhoneNumber.Text, Zip = CboZip.SelectedValue.ToString(), EmailAddress = TxtEmail.Text.Trim(), SupplyCost = (decimal)NumSupplyCost.Value, SupplierID = _updatableSupplier.SupplierID }; if (_manager.EditSupplier(_updatableSupplier, tempSupplier) == SupplierResult.Success) { await this.ShowMessageDialog("The Supplier was successfully edited."); DialogResult = true; Close(); } else { throw new WanderingTurtleException(this, "Supplier wasn't added to the database."); } } catch (Exception ex) { throw new WanderingTurtleException(this, ex); } }
/// <summary> /// Matt Lapka /// Created 2015/04/12 /// Sets login information based on session data /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_PreLoad(object sender, EventArgs e) { try { //attempt to get session value if they are logged in loggedIn = (bool)Session["loggedin"]; _currentSupplier = (Supplier)Session["user"]; _currentLogin = (SupplierLogin)Session["login"]; } catch (Exception) { //if it fails, the user must not have logged in on this //session yet, so set it to false Session["loggedIn"] = false; //send them to the login page Response.Redirect("~/login"); } if (!loggedIn) { //if not logged in, send them to login page Response.Redirect("~/login"); } }