ONLINE CAMPUS TOUR REGISTRATION MANAGEMENT SYSTEM A Project Presented to the faculty of the Department of Computer Science California State University, Sacramento Submitted in partial satisfaction of requirements for the degree of MASTERS OF SCIENCE in Computer Science by Maulik M. Gandhi SPRING 2012 ONLINE CAMPUS TOUR REGISTRATION MANAGEMENT SYSTEM A Project by Maulik M. Gandhi Approved by: __________________________________, Committee Chair Meiliu Lu, Ph.D. ____________________ Date __________________________________, Second Advisor William Mitchell, Ph.D. ____________________ Date ii Student: Maulik M. Gandhi I certify that this student has met the requirements for format contained in the University format manual, and that this project is suitable for shelving in the Library and credit is to be awarded for the Project. __________________________, Graduate Coordinator ________________ Nikrouz Faroughi, Ph.D. Date Department of Computer Science iii Abstract of ONLINE CAMPUS TOUR REGISTRATION MANAGEMENT SYSTEM by Maulik M. Gandhi Online Campus Tour Registration Management system is a web site project, which will help prospective, newly admitted students and their family or a member of group, to schedule an individual or group campus tour. Currently there is a campus tour registration web page, on CSUS web site, but it has limited functionality, the user interface is not user friendly, it has very less or no administrative functionality and is developed using low level language, which makes it impossible to maintain and update. Online Campus Tour Registration Management System is an attempt to provide a prototype solution, with the added functionalities, improvement in user interface, proper error handling for the existing website. The project is implemented in high level language using C# and SQL Server as database for storing the information. Hence when implemented as a real project on campus website by Student Affairs department, it will be easy for them to maintain and make necessary updates to the web site. Approved by: ________________________________, Committee Chair Meiliu Lu, Ph. D __________________________ Date iv ACKNOWLEDGEMENTS While working on this project many people have helped me and keep me motivated to achieve my goal. At this moment I would like to thank Dr. Meiliu Lu for investing her valuable time reviewing this project. Without the support and guidance of Dr. Meiliu Lu, it would have been difficult for me to achieve the goal and hence complete the project. I am also thankful to Dr. William Mitchell for being second reader on the project, and giving his valuable inputs, which helped me compete the project successfully. I would like to take this opportunity to express my gratitude towards my parents, Mr. Mukesh C. Gandhi and Varsha M. Gandhi, for being there when I needed them the most and for their never ending love and support. I would also like to thank, Jayesh C. Gandhi, Khushsboo A. Modi for their support, which helped me achieve my goal. v TABLE OF CONTENTS Page Acknowledgements ............................................................................................................. v List of Figures .................................................................................................................... ix Chapter 1. INTRODUCTION .......................................................................................................... 1 2. PROJECT REQUIREMENTS ........................................................................................ 3 2.1 Tour Registration Requirements ............................................................................... 3 2.1.1 Individual Tour Requirements ............................................................................ 4 2.1.2 Group Tour Requirements .................................................................................. 5 2.2 Tour Management Requirements .............................................................................. 7 2.3 System Implementation Requirements.................................................................... 10 2.4 Operating System Requirements ............................................................................. 10 3. ARCHITECTURE ........................................................................................................ 11 3.1 ASP.NET Overview ................................................................................................ 11 3.1.1 ASP.NET Page and Control Framework .......................................................... 11 3.1.2 ASP.NET Compiler .......................................................................................... 12 3.1.3 State Management Facilities ............................................................................. 13 vi 3.1.4 ASP .NET Web Configuration Guidelines ....................................................... 15 3.2 ASP.NET Page Life Cycles Overview .................................................................... 16 4. SYSTEM IMPLEMENTATION .................................................................................. 19 4.1 Tools Required for Web Site Project Development ................................................ 19 4.1.1 Installing Visual Studio 2010 Premium............................................................ 20 4.2 Creating Web Site Project: CollegeProject ............................................................. 20 4.3 CollegeProject Project Structure ............................................................................. 23 4.3.1 Admin/ .............................................................................................................. 25 4.3.2 App_Code/ ........................................................................................................ 27 4.3.3 App_Data/ ......................................................................................................... 27 4.3.4 bin/ .................................................................................................................... 32 4.3.5 css/ .................................................................................................................... 32 4.3.6 images/ .............................................................................................................. 32 4.3.7 scripts/ ............................................................................................................... 33 4.3.8 Other files in the default folder......................................................................... 33 4.4 Implementation of UI .............................................................................................. 35 4.5 Implementation of Business Logic .......................................................................... 37 4.6 Retrieving Data from Database using LINQ ........................................................... 40 vii 4.7 Run Project .............................................................................................................. 41 5. CONCLUSION ............................................................................................................. 44 Appendix A Web Configuration File (web.config) .......................................................... 46 Appendix B Code Snippet (admin-add-update.apsx) ....................................................... 50 Appendix C Code Snippet (admin-add-update.aspx.cs) ................................................... 53 Appendix D Code Snippet (Admin/MasterPage.master.cs) ............................................. 55 Appendix E Code snippet (Admin/MasterPage.master) ................................................... 56 Bibliography ..................................................................................................................... 60 viii LIST OF FIGURES Figures Page Figure 1 Use Case for Individual / Group Campus Tour Registration ............................... 6 Figure 2 Use Case for Campus Tour Management ............................................................. 9 Figure 3 Creating Project CollegeProject ......................................................................... 22 Figure 4 Default.aspx web page of CollegeProject .......................................................... 23 Figure 5 Project Structure of CollegeProject .................................................................... 25 Figure 6 Directory Structure for Data Connections directory .......................................... 28 Figure 7 User table definition ........................................................................................... 29 Figure 8 Ambassador table definition ............................................................................... 30 Figure 9 TourPlan table definition .................................................................................... 31 Figure 10 Tables used in the project, with their properties............................................... 31 Figure 11 Web Page admin-add-update.aspx showing error messages ............................ 37 Figure 12 Web page showing admin list after successfully adding new user .................. 39 Figure 13 Build CollegeProject output ............................................................................. 42 ix 1 Chapter 1 INTRODUCTION In this chapter, I will talk about what Online Campus Tour Registration Management system is about, define the problem with the current existing system, and go over what will be the end benefit once the project is completed. Online Campus Tour Registration Management System is a web application which can be integrated into current campus website. Currently CSUS [1] has a web page which can be visited by a prospective, newly admitted or current student and their parents, if they desire to visit CSUS campus and have a guided campus tour. The current system simply takes users inputs by form filling and does not have administration or maintenance console, which makes the current system not much efficient or transparent between students and Student Affairs department. There is a need of improvements in terms of functionality, user interface and transparency in terms of how the system should work. Hence the department was planning to make the necessary improvements and enhancements to the system. Online Campus Tour Registration Management System project will serve as a prototype for Student Affairs department, as it will have all the added functionality, better web page design, friendly user interface of what actually the department intend to make the system look and function like. Online Campus Tour Registration Management System project will serve as a centralized web based project, through which prospective and current students and their parents, or member of groups can register for an individual or group campus tour and for staff and administration department for performing 2 administrative work related to campus tour. The prospective and current students and their parents can request for a campus tour by either registering for an individual or group tour, at a specified data and time. On successful registration for an individual or group tour, the individual or group member will be sent an email confirmation with the confirmation number and other details provided, at the email address used during registration process. The individual or group member can login to the system and perform necessary changes, if needed using the email address used for registration and confirmation number. On the administration side, the admin will be able to view scheduled individual or group tours, assign student ambassador for the specific tour, turn on or off the campus tour registration for specific date and time, make print reports, add new admin users to the system. Thus the result of this project will serve as a centralized system for registration and management of campus tour. It will serve as a prototype for implementation of new functionalities like email confirmation and much other functionality related to admin users, which will be discussed in the later chapters. In the next chapter I will talk about the requirements, which are necessary to build the system, and how I was able to classify them into various groups. 3 Chapter 2 PROJECT REQUIREMENTS In this chapter, I will talk about what were the requirements from the Student Affairs department. After gathering the requirements from the department and analyzing them, I have classified the requirements as tour registration requirements which is further classified as individual or group tour, tour management requirements, system implementation requirements and operating system requirements. The main requirement of the project is for students or groups to register for a campus tour and for administrator is to perform administrative work related to scheduling campus tours, assign student ambassadors for the registered tours, and add new ambassador or administrator to the system. 2.1 Tour Registration Requirements This section describes information is to be collected from the prospective or current student and their parents or from member of a group, when they are registering for an individual or group tour. Also this section will cover what are the functional requirements for individual or group tour. The system should make necessary validation checks based on the required fields, whether they are empty or not, whether they are formatted in proper or order or not. The email addresses and phone numbers should be properly validated for proper format and proper warning messages should be shown to the user if either of them is not valid or formatted incorrectly. Also proper warning message should be shown to the user if any of the required field is missing. Once all the validations are done, the web page should be submitted for further processing on web 4 server, and the information should be stored in the database. A proper confirmation page with the details, obtained during registration should be shown on successful registration for a campus tour. Also an email with the tour details and confirmation number should be sent to the email address provided at the time of campus tour registration. The following are the functional requirements, which a registered user, for campus tour should be able to perform. Anyone who has already registered for campus tour should be able to edit the information provided during registration process, by login to the system using the email address used during registration process and confirmation number, which is sent to their email address at the end of registration process. Anyone who has already registered for campus tour should be able to view the information provided during registration process, by login to the system using the email address used during registration process and confirmation number, which is sent to their email address at the end of registration process. 2.1.1 Individual Tour Requirements When a prospective student, applicants, newly admitted students and their parents try to register for an individual campus tour following are the requirements which should be collected from them. Tour time and date Name of individual registering for a tour Email address Phone Number 5 Address City State Postal code Country Number attending with the individual included.(1-10) Academic Level Intended Major 2.1.2 Group Tour Requirements When a member of group try to register for a group campus tour following are the requirements which should be collected from them. Tour time and date Name of individual registering on behalf of the group Email address Phone number Address City State Postal code Country Number attending with the member of group registering for tour (1-100) 6 Academic level Name of school currently attending Means of Transportation (Van, Bus, others) Presentation Additional comments / specifications Figure 1 Use Case for Individual / Group Campus Tour Registration 7 2.2 Tour Management Requirements In this section, I will talk about various administrative functional requirements which an administrator should be able to perform. Below are the details about each functional requirement, which an admin user should be able to perform. Tour Maintenance Page: - The web application should have Campus Tour maintenance page, which will help administrator users to dynamically create individual or group tours. Once the administrator has created the tour, the calendar on the registration side should allow student or members of group to register for the either individual or group tour. The administrator should be able to set maximum seats limit for either individual or group tours. The administrator should easily toggle between either individual or group tours. Roaster Page: - The administrator should be allowed to assign a student ambassador, for a tour scheduled for a specific date. Guide Schedule: - The administrator should be able to view the tour schedule of the student ambassador. The administrator should be able to unassigned the tour schedule if needed. Administrator Maintenance Page: - The current administrator should be allowed to add new administrator or student ambassador to the system using their SacLink account. The current administrator should be able to change the access level from guide to full access. The guide should only be able to view their tour schedule. Response Maintenance Page: - From here the administrator should be able to control how the confirmation page for the campus tour registration system will 8 look. The administrator will be able to make a preview of the current confirmation page. The administrator should be able to change confirmation page based on the dynamic values which student or member of group has entered during campus tour registration. The dynamic values can be from following list: tour id, tour type, tour date, tour time, name, email address, phone, address1, address 2, city, state, postal code, country, number of attendees, academic level, intended major. Site Control Page: - The administrator should be allowed to enable and disable campus tour registration process. The administrator should be allowed to set a general message, which should be visible before a student or member of group tries to register for a campus tour. The administrator should be able to preview the general message, before setting it. Report Page: - The administrator should be able to perform statistical procedure based on individual or group tour, date range. 9 Campus Tour Maintenance View - Print Tour Reports Tour Maintenance Roaster- Assign Student Ambassador Adminstration Maintenance View Guide Schedule Admin User Modify Confirmation Response Site Control Page Figure 2 Use Case for Campus Tour Management 10 2.3 System Implementation Requirements Over here, I will talk about what tools, programming language; database should be used for developing the web application. The web application should be developed with following system requirements. Database: - SQL Server 2005 or higher. Programming Language: - C#, ASP.NET, VB.NET Scripting: - JavaScript. 2.4 Operating System Requirements A user who is connected to internet through Wi-Fi or 3G should be able to access the web application through their browser, on any operating system. In this chapter, we talked about the requirements gathered from the client side that is Student Affairs department and how it has been analyzed and classified into various sections. In the next chapter I will talk about architecture overview of ASP.NET [2], as the whole project has been developed using Microsoft Visual Studio 2010 Premium. 11 Chapter 3 ARCHITECTURE In this chapter I will talk about ASP.NET Framework, as the whole project is built using C# as language, along with Javascript as client side scripting language and SQL Server, which comes along with Microsoft Visual Studio 2010 Professional, has been used as database. In the chapter I will go over some of the important topics and concepts of ASP.NET and explain how they have been used in the project. 3.1 ASP.NET Overview ASP.NET provides us a single platform for Web development. We have the freedom of either using Visual Basic or C# languages for coding the web application, but as C# is one of the requirements for implementing the project, we will use C#. ASP.NET being a part of .NET Framework gives us easy access to various classes and libraries of the .NET Framework, which helps us write clean and more manageable code and focus on the core logic of the application, which will save our time. I have used Microsoft Visual Studio 2010 for creating the Online Campus Tour Registration Management web site project. 3.1.1 ASP.NET Page and Control Framework ASP.NET Web site project can contain ASP.NET web pages which are generated dynamically on Web server using ASP.NET page and controls framework. The client, which is a user, can request a web page from any web browser, which sends the request to the Web server, which creates the dynamic ASP.NET web pages, rendered as HTML [3] in the requesting web browser. ASP.NET web pages works on object oriented 12 programming structure. We can make our own reusable controls by encapsulating common UI [4] functionality in a user defined control. This gives us the freedom of writing code for controls once only, and using them in different web pages, which is dynamically rendered when a page is requested from the web browser. We do not have to worry about separation of client and server side code as the ASP.NET gives unified model which responds to various client side events in the code that runs at server. The framework automatically maintains the page state and controls of the page, during the page processing life cycle. We can define a master page, which helps us to make a consistent layout for all the pages in the application. We can create a master page which defines the layout and the standard behavior for all the pages in the application. We can also create page specific contents and behavior, thus when a particular page is requested by the client, web browser on behalf of a user, the contents from the master and that particular page is merged to produce a output, which in rendered in the web browser. We can create web pages which are SEO [5] friendly, thus giving us the freedom to define the pattern or web URL [6], which can be used to access the web page. Also the HTML generated is in accordance to the standard accessibility guidelines, for HTML 4.01. 3.1.2 ASP.NET Compiler The ASP.NET framework includes a compiler which will compile all the pages and controls used on the pages and generates an assembly modules having file extension .dll [7], thus compiler checks for strong typing, optimizes code for performance and 13 performs early binding. Some of the benefits of the compiling the application code are as follows: Performance: - As the assembly file with extension .dll is generated by compiling all the components of a web page, it is faster to run as the assembly file is a close representation of machine code, thus it does not require any further parsing. Security:- As the assembly file, which is close representation of machine code, is hard to read and does not have abstraction of high level language, hence difficult to reverse engineer, thus providing more secure code. Stability: - As the compiler checks for syntax errors, type errors and ASP.NET enables strong type, the web page is less prone to errors apart from the run time errors. 3.1.3 State Management Facilities In the traditional web page when submitted to the server, a new instance of the page is created, thus all the controls of the page are created again and the information is lost. To overcome this ASP.NET includes two options with different implementations, which help the developer to save the state of the submitted page, on per-page basis and application-wide basis also. We can perform state management either on client side or on the server side. Below is the brief explanation of the implementation which has been used in the project. View State: - This type of state management is done on client side. In this View State property provides a dictionary object, which can be used to store values and thus retain the state between multiple requests of the same page. Thus when the 14 page is submitted the current state of the page and the control is hashed into a string and saved in the page as hidden field(s). Hidden Fields: - This type of state managements is done on the client side. As the name suggests ASP.NET allows us to store the information in Hidden Field control, which is not visible in web browser. We can only store single value in the Value property of Hidden Field control. A page should be submitted through the POST command in order for the hidden field value to be available during page processing. Query Strings: - In this type of state management a string with attribute/value pair is appended to the end of the web page URL. Below is the web page URL from the project http://localhost:55024/CollegeProject%20-%20Copy/confirmationgroup.aspx?type=individual&id=9 In the web page URL above the query string starts with (?) and includes two attribute/value pair, the first is “type” and the second is “id”. Session State: - I have used session state, to save a user's session, scoping it to the web browser in which the user is logged in. Thus each user will have its own session state maintained at the server. The session state is basically stored as key/value pair for storing user specific session information, which is maintained between server round trips and between requests for other pages on the web site. The session state can be used to achieve the following tasks: 15 o Raise session based events. If a user tries to access a specific page on the web site, unless the session for that user is not created, a login page is shown. I have implemented this in the project, about which I will talk in a later chapter. o Store session specific data on the server, hence if a user accesses a web site from multiple web browsers and if a session for the user is created on the server, they get a uniform experience. o Session state can also be used to identify different web browsers or the devices from which the user is accessing the web site. Thus each device or web browser session can be mapped to an individual session on the server. 3.1.4 ASP .NET Web Configuration Guidelines ASP.NET gives us the freedom of configuring web application in a variety of ways. We can have application wide configuration which will affect that particular web application, configuration per web page, server wide configuration which will affect all the web applications deployed on the server, or configuration according to the web pages grouped in a folder structure. A developer has the freedom of configuring the web application with individual features of their choice according to the need of the application. Below is the glimpse of configuration features which I have used in the project, also you can refer Appendix A, for further details. Compiler configuration, which will be used during compiling the web application Debug configuration, which will help us debug the code modules and step into each line of code. We should set the debug attribute to true during the 16 development of the application, but when the application is ready for deployment and put into production it should be set to false, thus optimizing the performance. Run time configuration, which tells the web application to reference which dependent assemblies. Language configuration such as C# or Visual Basic Connection strings configuration, this type of configuration helps us to write a connection string for a database connection or data source. Error message display configuration, this type of configuration helps us to configure how an error message should be displayed or specify a default redirect web page whenever an unhandled error occurs during the execution of a web request. User authentication configuration, this type of configuration helps us to specify authentication schema which should be used for accessing specific admin pages of a particular web site. We need to use mode attribute to specify the authentication schema. 3.2 ASP.NET Page Life Cycles Overview Once a web page is requested by a user and runs inside a web browser, it passes through a page life cycle, during which it performs s series of processing steps. The series of steps included during page life cycle are initialization of page, instantiating controls of the page, running event handler associated with the controls, maintaining and restoring the state of page, if a post back is done, rendering the controls and other elements in the web browser. It is very important for us to understand the page life cycle, as this helps in 17 writing code modules according to firing of different events, which takes place inside the web page during the entire life cycle. Thus we can achieve the intended effects, according to the events fired at various stages of page life cycle. Below is the brief glimpse of various stages that takes life during entire page life cycle. Page Request: - This is the very first stage of page which occurs before the page life cycle begins. When a user request for a particular page, the ASP.NET framework determines, whether the cache copy of the requested page is present or not, if a cache copy of page is present it is served to the browser or else a fresh copy of page is build by parsing and compiling the page. Start: - During this page various properties of a page such as Request, Response, and IsPostBack properties are determined and set. Initialization: - During this stage each controls UniqueID property is set. If the web site is using one standard master page and theme, than they are applied to the requested page at this time. If the requested page is a postback, than the postback data is not loaded yet nor are the control property values restored, to the values from view state. Load: - If the requested page is postabck, than the control property value is loaded from the view state during this stage. Postback Event Handling: - This stage occurs only if the request page is a postback page. The control event handlers for all the controls are called and executed. The Validate method of all validator control is called, which sets the IsValid property of individual validator controls of the page. 18 Rendering: - View state or the page and all controls is saved before the page goes in rendering stage. Unload: - This stage takes place, when a user is navigating away from the page either by requesting other page, or due to page submission or any other reason. The properties such as Response and Request are unloaded and a cleanup is performed, thus the resources are freed up. So to summarize, in this chapter, we learnt about the system architecture and design, and how different concepts of ASP.NET have been implemented at various places in the project. In the next chapter, I will talk about how to install Microsoft Visual Studio 2010 Premium and start with creating a basic web site project, how to bind data to web pages, how to store information collected from the users through submitting forms to SQL Server, which comes along with the installation of Visual Studio. Also I will talk about how to run the project. 19 Chapter 4 SYSTEM IMPLEMENTATION In the earlier chapters, we have talked about requirement gathering, about architecture design of the language and project which we will be using to build the web site project. Now finally we have come to a point where I will talk about how to start building the web site project from scratch and go over the important topics which will help in maintenance and updating the web site project at any time in future. I will walk you through on how to install the required tools for creating the very first web page, then give an example and explain how to bind data to the application web page, then talk about storing the information in the database, and finally explain how to run the project. 4.1 Tools Required for Web Site Project Development Below are the tools, which I have used for the development of the web site project. Microsoft Visual Studio 2010 Premium It comes with all the required components which are necessary to build the web site. I have used SQL Server for all database related work, C# as the high level language for implementation of the project and Javascript as a scripting language for the client side validation of the web pages. I have downloaded the Visual Studio IDE [8] from MSDN [10] Academic Alliance under software section of ECS [9] web portal applications. Students of the Computer Science and Electronics departments can login to their ECS account and visit the software section of the portal to download the required software. 20 4.1.1 Installing Visual Studio 2010 Premium After downloading the installation package from the ECS portal, begin the installation process by double clicking on the package. Administration privileges are required for a user account to perform the installation process. I have used a machine with Windows 7 operating system for the development purposes. One does not need administration privilege for the development purpose. Once the installation is completed, please install all the necessary updates before starting the development work. To check for updates, go to the Help menu and click on Check for Updates, this will prompt for installation of additional updates if available. 4.2 Creating Web Site Project: CollegeProject In this section, I will talk about how to create the web site project. I have used Visual Studio 2010, as an IDE for all the development of the project. There are many benefits of using Visual Studio as IDE for creating this project as it allows us to drag and drop server controls to layout web form pages. After the controls are laid out we can set the properties, methods, and events for the controls or for the web page in the code behind file which will define the page’s look, feel and behavior. The Online Campus Tour Registration Management is a file system web site project in which the files are kept on the hard disk of my local machine. File System web site projects do not require installation of IIS [11] hence the project can be compiled and ran directly from Visual Studio in any web browser installed on the machine. As the files are located on the local machine hard drive, the web pages are not accessible from other 21 machines and can run only on the development machine’s web browser. Below are the steps for creating the web site project. Open Visual Studio 2010. From the File menu, select New Web Site A pop-up with different options will be shown on the screen. From the Recent Templates on the right, select the type of language, I have used Visual C#. In the center of the popup on the top, the development framework needs to be chosen, I have used .NET Framework 3.5 and selected ASP.NET web site. Under Web Location, I have chosen File System and specified the path where I want the files to be stored on my local machine, and named it CollegeProject. After completing all the options, click OK, and the project with a general template based on the selected language and framework will be created on the local machine. Below is the snapshot of the screen which shows the necessary configuration to select to create the project. 22 Figure 3 Creating Project CollegeProject A web project with a pre-built template, folder structure, and functionality for layout, which includes some web pages with extension aspx are created. A folder named “Scripts” is created, where all the Javascript and Ajax files, used for client side scripting are kept. A folder called “Styles” is created, where the files related to cascading styles and styles for the controls of the page are kept. A folder called “App_Data” is also created where the database files are kept. A folder called “Account” is also created where all the web site authentication related business logic goes. A file called “web.config” with default basic web configuration is created. Below is the screenshot which shows the default template once the project is created. 23 Figure 4 Default.aspx web page of CollegeProject 4.3 CollegeProject Project Structure The Online Campus Tour Registration Management System is a website project called CollegeProject, which is organized in a tree structure. Below are the root contents of the project. 24 /Admin /App_Code /App_Data /bin /css /images /scripts web.config MasterPage.master Other web pages (confirmation-group.aspx, confirmation.apsx, Default.aspx, login.aspx, register-group.apsx, register.aspx) 25 Figure 5 Project Structure of CollegeProject 4.3.1 Admin/ This directory structure contains all administration related web pages. Below I will talk about some of the important web pages under the admin/ directory, discuss their functionality and their role in the project. 26 MasterPage.master defines the layout and theme of all the admin pages, thus giving a uniform layout to the web pages related to administration. The “MasterPage.master.cs” is the code behind file for “MasterPage.master” which maintains the session logic, thus redirecting a user to the login web page “login.aspx” if a user, who is not logged in, is trying to access any web page under this directory. The “MasterPage.master.cs” contains the code for maintaining a user session and clears the session when the admin user wants to logout. Please refer Appendix D and Appendix E for further details The “login.apx” is a web page which is shown to the user where they have to enter SacLink email address and password to enter the system and perform admin related functionality. The code behind file of this web page, perform LINQ [12] query and tries to see if the supplied credentials match the database records. If a match is found the user is logged in to the system as admin user or else a proper error message is shown. The “tour-add-update.apsx” is the web page, where the logged in admin user can add individual or group tours, for a specified date and time, maximum seat allowed for tour can also be set from here. The “settings.apsx” is the page, where the logged in admin user can enable or disable campus tour registration. The “welcome.aspx” is the web page where the logged in admin user can configure the generic welcome message, which is visible to students at the time of campus tour registration. 27 The “admin-add-update.aspx” is the web page where the logged in admin user can add a new user by providing their first name, last name, email address, defining role as either admin or ambassador and granting access as a guide or full access. 4.3.2 App_Code/ This folder contains layout of the database which is used for the project. It contains “DataClasses.dbml.layout” which shows all the properties of the tables. It also contains the code behind file “DataClasses.designer.cs” which basically contains the getter and setter method for all the tables in the entire database. 4.3.3 App_Data/ This folder basically contains master data file(s) for the entire project. This folder contains all the tables, views, database diagrams, stored procedures, functions, synonyms, types and assemblies which are used in the project. For this project, I am only storing tables, views and database diagrams in it. Below is the snap shot from the project which shows the directory structure of Data Connections for this project. 28 Figure 6 Directory Structure for Data Connections directory Now I will talk about some of the important tables which are being used in the project. User Table: - This table stores all the information which a student or member of group enters in the form at the time of campus tour registration either individual 29 or group tour. In addition this table also stores the confirmation number which is referenced from the confirmation table. Thus for a registered user there is a one to one correspondence between the email address they used at time of registration and the confirmation number. Figure 7 User table definition 30 Ambassador table: - This table is used for admin purposes. It has an access level and role column in it, which defines the permission of the admin user and ambassador. The admin can have the role of “admin” or “ambassador” and thus if the user is an ambassador, then they can only have a guide access, but if the user has the role of admin then, they can either have full access or guide level access. Below is the snap shot which shows the table definition for the ambassador table. Figure 8 Ambassador table definition Tour Plan table: - This table is used by admin, for scheduling campus tours. The admin user can schedule a tour which can be configured either as an individual or group tour, which is open for registration to students between a date range on which there is limited number of seats. The admin user can assign a tour ambassador at the time of creating a tour or at a later time. Below is the snap shot from the project which shows the table definition of the ambassador table. 31 Figure 9 TourPlan table definition Below is the figure which shows all the tables used in the project with their properties. Figure 10 Tables used in the project, with their properties 32 4.3.4 bin/ This folder contains the external assembly file “AjaxControlToolkit.dll” which we are using in the project. This file is used basically on the client side to do some animation and show and hide the appropriate error messages and controls on the web page. 4.3.5 css/ This folder contains all the style sheets used in the project. It has following style sheets in it. custom.css StyleSheet.cs template.css 4.3.6 images/ This folder contains all the graphical images which are used in the project. Following is the list of images which are being used in the project. aboutsacstate.gif admissions.gif contactus.gif darkgreenheader-right.gif edit_icon.gif footerbg.gif givingagift.gif gobutton.gif 33 header.gif printer.gif sacstatehome.gif siteindex.gif trans.gif 4.3.7 scripts/ This folder contains files related to content management. cms.txt:- This file contains content for group and individual tours which are visible to students, when they are in the registration process and land on the very first page of the application. confirmation.txt:- This file contains the content related to the confirmation page for an individual campus tour, which is shown to the student on successful registration for an individual campus tour. confirm-group.txt:- This file contains the content related to the confirmation page for a group campus tour, which is shown to the member of a group on successful registration for a group campus tour. 4.3.8 Other files in the default folder The default CollegeProject folder contains some web page files which can be accessed directly, and a login user session is not required to access them. Below are some of the files, about which I will give a brief introduction about their functionality. 34 default.aspx:- This is the very first web page which is shown to the students, when they visit the campus tour registration section of the campus website. On this page a brief introduction about the Campus Tour is given and explains the purpose for individual and group tours and talks about the target audience. A user can either opt for individual campus tour registration or group tour registration by clicking on the hyper link. Apart from that, there is also a Student Login hyper link, which shows the login page for the user who has already registered for the campus tour. They can use the email address and a confirmation number to login to the system and make the necessary updates to the already scheduled campus tour. register.aspx:- This is the web page requested by the student user, when they want to register for an individual campus tour. It has all the validation for inputs of the form, if any of the form validation fails, the proper error message is shown to the user. The web page form checks for the form validation like email address, phone number, and other required fields. Once the students successfully complete the tour registration process a confirmation email is sent to the email address provided and redirected to “confirmation.aspx”, where they are shown the details they provided at time of tour registration and a confirmation number is also shown which is used for login purpose with email address later. register-group.aspx:- This is the web page requested by the member of the group, who wants to register for a group campus tour for their organization or school. It has all the validation for inputs of the form, if any of the form validation fails, proper error message is shown to the user. The web page form checks for the form 35 validation like email address, phone number, required fields, and maximum set limit for the group tour. Once the user successfully completes the tour registration process a confirmation email is sent to the email address provided and redirected to “confirmation-group.aspx”, where they are shown the details they provided at time of tour registration and a confirmation number is also shown which is used for login purpose with email address later. web.config:- This file contains all the configuration settings related to the web site project. Some of the configurations which I have used in the project are as specifying compile language configuration, debug configuration, error handling configuration, and database connection string configuration. Please refer to the Appendix A for further details about the “web.config” file. 4.4 Implementation of UI In this section I will talk about how to create the user interface for a web page. In ASP.NET the user interface and the business logic are separated into two different files. The file which contains the form layout of the web page has an extension of aspx and the file which contains the business logic corresponding to that web page has an extension of aspx.cs. From the extension file, we can tell that C# has been used as the language of implementation for business logic. Now I will explain how to create a web page taking “admin-add-update.aspx” file as an example. Right click on the CollegeProject, and select “Add New Item” and from the popup choose Visual C# from the Installed Template on the right and Web Form in the centre and name the file as “admin-add-update.aspx” and click OK. A web page with 36 C# as language is created and placed in the directory you specified. To give a uniform layout for all the web pages, we have used a master file called “MasterPage.master”. The “admin-add-update.aspx” file contains a table structure layout which contains rows and columns. This type of layout helps in alignment of different fields next to each other on the web page. For example, in the first row of the “admin-add-update.aspx” page I have two columns. In the first column, of the “admin-add-update.aspx” page I have placed a label field with content “First Name”. The different properties of the element like height, width, color, background-color, and font-weight can be set here. In the second column, next to the label, I have aligned input text field, for admin user to type in the first name. The different properties of the input field like color, id, and runat are set here. Also the validation property for the input text field is set here. Please look at Appendix B that contains the snippet of the code which shows the different configuration for input text field of the “admin-add-update.aspx” web page. From the above snippet of code, we can see that field type of input with type text, has validation, error message, and runat property set. Thus when the form is submitted the field is validated based on value txtFirstName and proper error message is shown if the user has not filled the field with the proper name. Also from the snippet, it is clear that the error message has been configured to show dynamically, and thus it is only visible when there is error on the form submission. 37 Figure 11 Web Page admin-add-update.aspx showing error messages Thus in the similar way other web pages of the application can be created. I have separated all the admin related pages and placed them in directory “Admin”. 4.5 Implementation of Business Logic In this section I will talk about writing the business logic for each web page. In the previous section, I demonstrated how to create a web page “admin-add-update.aspx”. We will continue our talk using the same file as an example in this section. When “admin-add-update.aspx” file was created Visual Studio also created a class file 38 corresponding to it “admin-add-update.aspx.cs”, which in ASP.NET terminology is called code behind file for the web page. As the file extension contains “cs” in it, we can identify that C# is being used as language of implementation. The code behind file contains the method for the event handling, for page load, and other user defined methods which constitute to the business logic for the web page of the application. The page load is the method which is fired every time when a page load or unload event takes place. We can determine whether the page requested is postback or not by checking for Page.IsPostBack property. In the code, I am using this property to make the function call to fetchData(). If the requested page is post back, I get the “id” of the page by using QueryString property of the page. If the “id” is not null, I call the fetchData() function, which basically gets the data corresponding to the “id” which I get from QueryString property. Once I have retrieved the data from the database, I display the data on the form by filling in the respective field of the web page corresponding to the data. I have used LINQ to get the data from the database. When a user fills in all the details for adding new user on the form, and click on the Submit button, I call the function btnSubmit_Click() which first checks if the page is valid and the user is logged into the system or not, than the action attribute for submit button is checked. If value of action is edit then the information corresponding to the “id” value obtained from QueryString is updated successfully, else a new entry is created in the table. All the filled information from the form is collected and pushed in the ambassador table of the database. If a user clicks on Cancel button, than the page redirects to “admin-list.aspx” web page and the list of admin users and ambassador is shown. Below is the snap shot 39 which shows the list of admin users. Once a user has filled the details for the new admin user and clicked submit they are redirected to the page where all the admin users are made visible. Figure 12 Web page showing admin list after successfully adding new user The same implementation has been used to create other code behind files like “register.aspx.cs” and “register-group.aspx.cs”. Some web pages require more validation like the web pages used for campus tour registration requires validation on phone number or the number of people allowed for tour, but one can write the validation logic once they understood how fields are being validating in our example of “admin-add-update.aspx”. 40 4.6 Retrieving Data from Database using LINQ In this topic I will talk about how to use LINQ to retrieve data from the database. All the entity classes are created and stored using LINQ to SQL [13] classes.dbml files. To add LINQ to the CollegeProject follow the following steps. Right click on the CollegeProject folder Select Add New Item from the context menu. Select LINQ to SQL classes, and specify the name DataClasses.dbml and click Add. Visual Studio will prompt to add the file in the separated folder called App_Data, click Yes. Once the DataClasses.dbml, has been added to the project, the design surface with two separate panes opens on the screen. On the pane on the left the entity classes are to be added and configured. The pane on the right is for methods, where the DataContext methods are to be added. Now to map the database tables to the entity classes, follow the below steps. Click on the Server Explorer, and expand the Data Connections directory. Expand the table’s directory, finally drag the ambassador table. This will create entity class with the name ambassador. It will also have properties corresponding to the columns of the ambassador table. Now follow the above steps to add other tables to the designer. Once all the tables are added to the designer, one can start using them, as the code for 41 DataClassesDataContext and the public method for each table is added to DataClasses.designer.cs file. Now we simply have to create an instance of the table in our example ambassador table and DataClassesDataContext in the code behind file and write a LINQ query to retrieve the data. The retrieved data should be stored in the instance variable of the corresponding table from which the data is retrieved. Once we have the retrieved data in the table instance variable, we can use the column name of the table to retrieve the data corresponding to each property. The retrieved data can be used to display on any field of the web page. Similarly repeat the same procedure for other web pages to retrieve the data and display it on the web page. 4.7 Run Project Over here I will talk about how to run the project. Before running the web site project, we need to build the project to make sure all the class files and assemblies used in the project are compiled. To build the CollegeProject, follow the below steps: Right Click on the project in Visual Studio 2010 Choose Build Web Site, from the context menu. If the web site project is build successfully, you will be able to see something similar to the below snap shot in the output window on Visual Studio. 42 Figure 13 Build CollegeProject output Once the CollegeProject is built successfully, we can now run the project by following the steps below. Right click on the CollegeProject in Visual Studio. From the context menu, choose View in Browser, this will run the Default.aspx in the default web browser of the system. The entire project is run using Visual Studio Development Server; hence it is local to the machine on which development is being done. One can see localhost:port number in the URL of the web browser. The default web page is Default.aspx, as from this page the user can decided for which campus tour they intend to register. There is no direct link to access any admin page right now, but we can manually run any admin page 43 and view them in the web browser, by following the above steps. Also, if no admin user session is present on the system, then the requested page is redirected to the login page. By providing the admin credentials, user can move further and log in to system and perform administrative related work. To summarize the contents I discussed in the chapter, we went through installation steps of the required tools for building the project. We went through steps on how to create a basic simple web site project, than I gave a brief explanation about the project structure and talked about each of the folders of the project and discussed the important web pages in them. Later, I gave a simple demonstration for how to create a simple web page and code behind file for it, and how to retrieve data from database using LINQ and bind it to the controls of the web page. Finally I discussed how to build and run the project. Upon a successful build and running the project one will be able to view contents of Default.aspx file in the default web browser of their machine. 44 Chapter 5 CONCLUSION Overall the Online Campus Tour Registration Management System is a very useful web site project, which acts as a prototype for actual implementation that can be integrated on the CSUS campus web site. It will provide very useful functionality to the prospective and new admitted students and their parents registered for an individual campus tour. It is also useful for the organization, who wants to schedule for a group campus tour for their school students. On the admin side it will provide enhanced functionalities which the existing system lacks. On the admin side I have added new features and functionalities, such as add new ambassadors and define their role, schedule a campus tour within a data range, view or print report based on current group or individual tours, to the project. This added functionality to the project will be boon for the Student Affairs department. I feel honored and take pride as I got a chance to demonstrate the knowledge obtained through the Computer Science course work and put it to use by working on a real world project. I feel content as I got a chance to contribute and work on a project which acts as a prototype for an actual project which will be used by students and staff at CSUS. In spite of being familiar with the object oriented programming structure, working on ASP.NET was challenging for me. It was a nice learning curve to work on the web site project in ASP.NET as I had been using Java as my primary choice of language to work on projects. At the end I feel I gained experience to work on the technology which 45 was new to me. I will continue to learn and expand my knowledge by taking up the projects which are based on technology which I am not aware of or are new to me. I will submit the web site CollegeProject to Student Affairs department, and they will provide support and maintain the project. They can make the necessary changes to the project, and add or remove the functionality from the project, as per the administrative decisions. The project has been implemented using C# and Visual Studio 2010 has been used for the implementation, which was one of the requirements from the department for maintenance of the project; hence I believe that they would not face any difficulty in the maintenance of the project. Lastly, I would like to conclude by saying that although lots of new functionalities have been added by me to the project, I believe additional functionalities can be added to the project. There is room for improvements to the project based on user’s feedback, new requirements from the administrative department or improving existing functionality. 46 Appendix A Web Configuration File (web.config) <?xml version="1.0"?> <!-For more information on how to configure your ASP.NET application, please visit http://go.microsoft.com/fwlink/?LinkId=169433 --> <configuration> <configSections> <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/> <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/> </sectionGroup> </sectionGroup> </sectionGroup> </configSections> <connectionStrings> <add name="DatabaseConnectionString" connectionString="Data 47 Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/> </connectionStrings> <system.web> <compilation debug="true"> <assemblies> <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/> <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/> </assemblies> </compilation> <pages> <controls> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </controls> </pages> <httpHandlers> <remove verb="*" path="*.asmx"/> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </httpHandlers> <httpModules> 48 <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </httpModules> </system.web> <system.codedom> <compilers> <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4"> <providerOption name="CompilerVersion" value="v3.5"/> <providerOption name="WarnAsError" value="false"/> </compiler> <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4"> <providerOption name="CompilerVersion" value="v3.5"/> <providerOption name="OptionInfer" value="true"/> <providerOption name="WarnAsError" value="false"/> </compiler> </compilers> </system.codedom> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules> <remove name="ScriptModule"/> <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </modules> <handlers> <remove name="WebServiceHandlerFactory-Integrated"/> <remove name="ScriptHandlerFactory"/> <remove name="ScriptHandlerFactoryAppServices"/> <remove name="ScriptResource"/> <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add name="ScriptResource" verb="GET,HEAD" 49 path="ScriptResource.axd" preCondition="integratedMode" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </handlers> </system.webServer> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50727"> <dependentAssembly> <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/> <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/> <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration> 50 Appendix B Code Snippet (admin-add-update.apsx) <%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" CodeFile="admin-add-update.aspx.cs" Inherits="Admin_admin_add_update" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <div style="margin-top: 15px; margin-left: 35px; margin-bottom: 55px;"> <label style="color: Green; font-size: 28px; margin-bottom: 20px;"> Admin add/update:</label> </div> <table rules="all" id="ctl00_cph_dvwTour" style="color: rgb(51, 51, 51); height: 50px; width: 100%; border-collapse: collapse;" border="1" cellpadding="4" cellspacing="0"> <tbody> <tr style="background-color: rgb(247, 246, 245);"> <td style="color: rgb(0, 87, 61); background-color: rgb(198, 214, 206); font-weight: bold;" colspan="2"> <asp:Label runat="server" ID="lblmsg" ForeColor="Green"></asp:Label> </td> </tr> <tr style="background-color: rgb(247, 246, 245);"> <td style="color: rgb(0, 87, 61); background-color: rgb(198, 214, 206); font-weight: bold;"> First Name </td> <td> <input type="text" runat="server" id="txtFirstName" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic" ErrorMessage="Required" ControlToValidate="txtFirstName"></asp:RequiredFieldValidator> </td> </tr> <tr style="background-color: rgb(247, 246, 245);"> <td style="color: rgb(0, 87, 61); background-color: rgb(198, 214, 206); font-weight: bold;"> Last Name </td> <td> <input type="text" runat="server" id="txtLastName" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator11" runat="server" Display="Dynamic" ErrorMessage="Required" ControlToValidate="txtLastName"></asp:RequiredFieldValidator> </td> </tr> <tr style="background-color: rgb(247, 246, 245);"> <td style="color: rgb(0, 87, 61); background-color: rgb(198, 214, 206); font-weight: 51 bold;"> Email </td> <td> <input type="text" runat="server" id="txtEmail" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" Display="Dynamic" ErrorMessage="Required" ControlToValidate="txtEmail"></asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Invalid" Display="Dynamic" ControlToValidate="txtEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([.]\w+)*"></asp:RegularExpressionValidator> </td> </tr> <tr style="background-color: rgb(247, 246, 245);"> <td style="color: rgb(0, 87, 61); background-color: rgb(198, 214, 206); font-weight: bold;"> Password </td> <td> <input type="password" runat="server" id="txtPassword" /> <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" Display="Dynamic" ErrorMessage="Required" ControlToValidate="txtPassword"></asp:RequiredFieldValidator> </td> </tr> <tr style="background-color: rgb(247, 246, 245);"> <td style="color: rgb(0, 87, 61); background-color: rgb(198, 214, 206); font-weight: bold;"> Role: </td> <td> <asp:RadioButtonList ID="rbtnAdmin" runat="server"> <asp:ListItem Value="Admin" Selected="True">Admin</asp:ListItem> <asp:ListItem Value="Ambassador">Ambassador</asp:ListItem> </asp:RadioButtonList> </td> </tr> <tr style="background-color: rgb(247, 246, 245);"> <td style="color: rgb(0, 87, 61); background-color: rgb(198, 214, 206); font-weight: bold;"> Grant Access: </td> <td> <asp:RadioButtonList ID="rbtnAccess" runat="server"> <asp:ListItem Value="Guide">Guide</asp:ListItem> <asp:ListItem Value="Full Access" Selected="True">Full Access</asp:ListItem> 52 </asp:RadioButtonList> </td> </tr> <tr style="background-color: rgb(198, 214, 206); font-weight: bold;"> <td colspan="2" align="right"> <asp:Button runat="server" ID="btnSubmit" Text="Submit" OnClick="btnSubmit_Click" /> <asp:Button runat="server" ID="btnCancel" Text="Cancel" UseSubmitBehavior="false" onclick="btnCancel_Click" CausesValidation="false" /> </td> </tr> </tbody> </table> <br /><br /><br /> </asp:Content> 53 Appendix C Code Snippet (admin-add-update.aspx.cs) using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class Admin_admin_add_update : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.QueryString["id"] != null) fetchData(); } } private void fetchData() { int adminID = Convert.ToInt32(Request.QueryString["id"]); DataClassesDataContext db = new DataClassesDataContext(); var data = from u in db.ambassadors where u.id == adminID select u; if (data.Count() > 0) { ambassador result = (ambassador)data.ToList()[0]; txtFirstName.Value = result.FirstName; txtLastName.Value = result.LastName; txtEmail.Value = result.Email; txtPassword.Attributes.Add("value", result.Pwd); rbtnAdmin.SelectedValue = result.Role; rbtnAccess.SelectedValue = result.Access; } } protected void btnSubmit_Click(object sender, EventArgs e) { if (!Page.IsValid) return; string action = ""; int adminid = 0; ambassador data = new ambassador(); DataClassesDataContext db = new DataClassesDataContext(); 54 if (Request.QueryString["id"] != null) { action = "edit"; adminid = Convert.ToInt32(Request.QueryString["id"]); data = (from u in db.ambassadors where u.id == adminid select u).Single(); } else { action = "add"; } //save data data.FirstName = txtFirstName.Value; data.LastName = txtLastName.Value; data.Email = txtEmail.Value; data.Pwd = txtPassword.Value; data.Role = rbtnAdmin.SelectedValue; data.Access = rbtnAccess.SelectedValue; if (action == "add") { db.ambassadors.InsertOnSubmit(data); db.SubmitChanges(); int id = data.id; Response.Redirect("admin-list.aspx"); } else { lblmsg.Text = "Information updated successfully."; db.SubmitChanges(); } } protected void btnCancel_Click(object sender, EventArgs e) { Response.Redirect("admin-list.aspx"); } } 55 Appendix D Code Snippet (Admin/MasterPage.master.cs) using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class Admin_MasterPage : System.Web.UI.MasterPage { protected void Page_Load(object sender, EventArgs e) { if (Session["adminId"] == null) { if(Request.Url.ToString().Contains("login.aspx") == false) Response.Redirect("login.aspx"); } } protected void lnkLogout_Click(object sender, EventArgs e) { Session.Abandon(); Response.Redirect("login.aspx"); } } 56 Appendix E Code snippet (Admin/MasterPage.master) <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="Admin_MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="ctl00_Head1" runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Campus Tours - Sac State </title> <link rel="stylesheet" type="text/css" href="../css/template.css"> <link rel="stylesheet" type="text/css" href="../css/custom.css"> <link rel="icon" href="http://webapps2.csus.edu/oar/campus_tour/image/logo.ico" type="image/x-icon"> <link rel="shortcut icon" href="http://webapps2.csus.edu/oar/campus_tour/image/logo.ico" type="image/x-icon"> <script type="text/javascript" language="JavaScript"> <!-function MM_swapImgRestore() { //v3.0 var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc; } function MM_preloadImages() { //v3.0 var d = document; if (d.images) { if (!d.MM_p) d.MM_p = new Array(); var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++) if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } } } function MM_findObj(n, d) { //v4.01 var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) { d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p); } if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n]; for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document); if (!x && d.getElementById) x = d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3) if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = 57 x.src; x.src = a[i + 2]; } } //--> </script> <!-- CUSTOM: Begin script block --> <script type="text/javascript"> function toggle(eId, pId, offX, offY) { var e, p, cLeft, cTop; cLeft = cTop = 0; if ((e = document.getElementById(eId))) { if (e.style.display != 'none') e.style.display = 'none'; else { if ((p = document.getElementById(pId))) { if (p.offsetParent) { cLeft = p.offsetLeft cTop = p.offsetTop while (p = p.offsetParent) { cLeft += p.offsetLeft cTop += p.offsetTop } } cLeft += offX; cTop += offY; e.style.left = cLeft + 'px'; e.style.top = cTop + 'px'; } e.style.display = 'block'; } } } function show(id) { var e = document.getElementById(id); if (e) e.style.display = 'block'; } function hide(id) { var e = document.getElementById(id); if (e) e.style.display = 'none'; } function printPage() { var e; e = document.body.getElementsByTagName("tr"); e[2].style.display = 'none'; // green horiz links 58 e[3].style.display = 'none'; // gray horiz links e = document.body.getElementsByTagName("td"); e[2].style.display = 'none'; // search form e[6].style.display = 'none'; // vertical menu window.print(); e = document.body.getElementsByTagName("tr"); e[2].style.display = 'block'; // green horiz links e[3].style.display = 'block'; // gray horiz links e = document.body.getElementsByTagName("td"); e[2].style.display = 'block'; // search form e[6].style.display = 'block'; // vertical menu } </script> </head> <body> <form id="form1" runat="server"> <table border="0" cellpadding="0" cellspacing="0" width="735"> <tbody> <tr> <td colspan="2"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tbody> <tr> <td height="74"> <a name="top" id="top"></a><a href="#content"> <img src="../images/trans.gif" alt="jump to content" height="1" border="0" width="1"></a><!-- InstanceBeginEditable name="headergraphic" --><a href="http://www.csus.edu/"><img src="../images/header.gif" alt="sacramento state - leadership begins here" height="74" border="0" width="500"></a><!-InstanceEndEditable --> </td> <td id="noPrint0" nowrap="nowrap" align="right"> &nbsp; </td> </tr> <tr id="noPrint1"> <td height="20" nowrap="nowrap" bgcolor="#00573D" style="color:White;"> &nbsp;&nbsp;&nbsp; <a href="admin-list.aspx" style="color: White;">Admin</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp; <a href="tour-list.aspx" style="color: White;">Tour</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp; <a href="student-list.aspx" style="color: White;">Student</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp; <a href="welcome.aspx" style="color: White;">Welcome</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp; <a href="settting.aspx" style="color: White;">Setting</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp; <asp:LinkButton runat="server" ID="lnkLogout" ForeColor="White" 59 onclick="lnkLogout_Click">Logout</asp:LinkButton> </td> <td nowrap="nowrap" bgcolor="#00573D" align="right"> <img src="../images/darkgreenheader-right.gif" alt="" height="20" width="10" /> </td> </tr> </tbody> </table> </td> </tr> <tr> <td> <table> <tr> <td valign="top" width="565"> <a name="content" id="content"></a> <div class="content"> <div> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> </div> </div> </td> </tr> </table> </td> </tr> <tr> <td colspan="2" height="5"> <img src="../images/trans.gif" alt="" height="5" width="1"> </td> </tr> <tr> <td colspan="2" style="background-image: url('../images/footerbg.gif');" id="footercell" height="24" align="center"> <div id="footer"> California State University, Sacramento | 6000 J Street | Sacramento, CA 95819 | (916) 278-6011</div> </td> </tr> </tbody> </table> </form> </body> </html> 60 Bibliography [1] CSUS, In California State University Sacramento, Retrieved on April 14, 2012. From online http://www.csus.edu [2] ASP.NET, In Active Server Pages, Retrieved on April 14, 2012. From online http://www.javascriptkit.com/howto/aspnet.shtml [3] HTML, In Hyper Text Markup Language, Retrieved on April 14, 2012. From online http://www.w3schools.com/html/html_intro.asp [4] UI, In User Interface, Retrieved on April 14, 2012. From online http://full-form.in/UI.html [5] SEO, In Search Engine Optimization, Retrieved on April 14, 2012. From online http://full-form.in/SEO.html [6] URL, In Uniform Resource Locator, Retrieved on April 14, 2012. From online http://www.abbreviations.com/URL [7] .dll, In Dynamic-Link Library, Retrieved on April 14, 2012. From online http://support.microsoft.com/kb/815065 [8] IDE, In Integrated Development Environment, Retrieved on April 14, 2012. From online http://msdn.microsoft.com/en-us/library/ms235632(v=vs.80).aspx [9] ECS, In Engineering & Computer Science, Retrieved on April 14, 2012. From online https://www.ecs.csus.edu [10] MSDN, In Microsoft Developer Network, Retrieved on April 14, 2012. From online http://social.msdn.microsoft.com/Search/en-US?query=msdn%20&ac=8 [11] IIS, In Internet Information Services, Retrieved on April 14, 2012. From online http://www.microsoft.com/download/en/details.aspx?id=17275 [12] LINQ, In Language Integrated Query, Retrieved on April 14, 2012. From online http://msdn.microsoft.com/en-us/library/bb397926.aspx [13] SQL, In Structured Query Language, Retrieved on April 14, 2012. From online http://www.w3schools.com/sql/sql_intro.asp