protected void Page_Load(object sender, EventArgs e) { if (Global.CurrentPerson == null || Global.CurrentPerson.accountType != Models.Account.Faculty) { // Login - for expo purposes, we are just grabbing a random student from the DB LoginRandomEmployee(); } DataTable upcomingEventsTable = new DataTable(); List <Models.Event> upcomingEvents = new List <Models.Event>(); using (OracleConnection objConn = new OracleConnection(Global.ConnectionString)) { // Set up the upcomingEvents command var upcomingEventsCommand = new OracleCommand("TICKETS_QUERIES.getUpcomingEvents", objConn) { BindByName = true, CommandType = CommandType.StoredProcedure }; upcomingEventsCommand.Parameters.Add("p_Return", OracleDbType.RefCursor, ParameterDirection.ReturnValue); try { // Execute the queries and auto map the results to models objConn.Open(); var upcomingEventsAdapter = new OracleDataAdapter(upcomingEventsCommand); upcomingEventsAdapter.Fill(upcomingEventsTable); upcomingEvents = Mapper.DynamicMap <IDataReader, List <Models.Event> >(upcomingEventsTable.CreateDataReader()); } catch (Exception) { Response.Redirect("../Default.aspx"); } objConn.Close(); } // Fill list dropdowns with data from the database if (upcomingEvents.Count > 0) { EventListview.DataSource = upcomingEvents; } EventListview.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable upcomingEventsTable = new DataTable(); List <Models.Event> upcomingEvents = new List <Models.Event>(); using (OracleConnection objConn = new OracleConnection(Global.ConnectionString)) { // Set up the upcomingEvents command var upcomingEventsCommand = new OracleCommand("TICKETS_QUERIES.getAllEvents", objConn) { BindByName = true, CommandType = CommandType.StoredProcedure }; upcomingEventsCommand.Parameters.Add("p_Return", OracleDbType.RefCursor, ParameterDirection.ReturnValue); try { // Execute the queries and auto map the results to models objConn.Open(); var upcomingEventsAdapter = new OracleDataAdapter(upcomingEventsCommand); upcomingEventsAdapter.Fill(upcomingEventsTable); upcomingEvents = Mapper.DynamicMap <IDataReader, List <Models.Event> >(upcomingEventsTable.CreateDataReader()); } catch (Exception ex) { // TODO: Handle Exception throw (ex); } objConn.Close(); } // Fill list dropdowns with data from the database if (upcomingEvents.Count > 0) { EventListview.DataSource = upcomingEvents; } EventListview.DataBind(); } }