Permalink
Browse files

Register page SQL syntax modifications

  • Loading branch information...
1 parent 6877274 commit f85a122bd1763eb9f1f044f5ea98fa00cb39141c @ArtisOracle committed Apr 7, 2012
Binary file not shown.
@@ -52,7 +52,7 @@ protected void RegisterUser_CreatedUser(object sender, EventArgs e)
// First verify that this user is unique; do this by finding the email and checking against DB
TextBox EmailTextBox = (TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("Email");
- string connectionString;
+ string connectionString = "";
SqlConnection DBConn = new SqlConnection(connectionString);
SqlCommand DBCmd = new SqlCommand();
SqlCommand sqlComm = new SqlCommand();
@@ -86,14 +86,13 @@ protected void RegisterUser_CreatedUser(object sender, EventArgs e)
{
// Add SQL statement to insert into database
DBCmd = new SqlCommand(
- "INSERT INTO userprofile(UID, Email, Fname, Lname)" +
- "VALUES (@UID, @Email, @Fname, @Lname)", DBConn);
+ "INSERT ");
// Add database parameters
- DBCmd.Parameters.Add("@UID", MySqlDbType.Int32).Value = newUserId;
- DBCmd.Parameters.Add("@Email", MySqlDbType.VarChar).Value = EmailTextBox.Text;
- DBCmd.Parameters.Add("@Fname", MySqlDbType.VarChar).Value = FirstNameTextBox.Text;
- DBCmd.Parameters.Add("@Lname", MySqlDbType.VarChar).Value = LastNameTextBox.Text;
+ // DBCmd.Parameters.Add("@UID", System.Data.SqlDbType.Int).Value = newUserId;
+ DBCmd.Parameters.Add("@Email", System.Data.SqlDbType.VarChar).Value = EmailTextBox.Text;
+ DBCmd.Parameters.Add("@Fname", System.Data.SqlDbType.VarChar).Value = FirstNameTextBox.Text;
+ DBCmd.Parameters.Add("@Lname", System.Data.SqlDbType.VarChar).Value = LastNameTextBox.Text;
DBCmd.ExecuteNonQuery();
}

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -46,9 +46,9 @@
</asp:Menu>
</ContentTemplate>
</asp:RoleGroup>
- <asp:RoleGroup Roles = "admin">
- <ContentTemplate>
- <asp:Menu ID="AdminNavigationMenu" runat="server" CssClass="menu"
+ </RoleGroups>
+ <LoggedInTemplate>
+ <asp:Menu ID="AdminNavigationMenu" runat="server" CssClass="menu"
EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal"
onmenuitemclick="NavigationMenu_MenuItemClick">
<Items>
@@ -60,10 +60,8 @@
<asp:MenuItem NavigateUrl="~/About.aspx" Text="About"/>
<asp:MenuItem NavigateUrl="~/Account/Logout.aspx" Text="Logout"/>
</Items>
- </asp:Menu>
- </ContentTemplate>
- </asp:RoleGroup>
- </RoleGroups>
+ </asp:Menu>
+ </LoggedInTemplate>
<AnonymousTemplate>
<asp:Menu ID="DefaultNavigationMenu" runat="server" CssClass="menu"
EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal"
@@ -1,4 +1,4 @@
-<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
+<%@ Page Title="Search" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="Search.aspx.cs" Inherits="StudentAlumniTrackingTool.WebPages.Search" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
@@ -449,8 +449,8 @@
</p>
</fieldset>
- <asp:Button ID="SearchButton" runat="server" Text="Search"
- ValidationGroup="SearchUserValidationGroup" onclick="OnSearchClick" />
+ <asp:Button ID="SearchButton" runat="server" Text="Search" ValidationGroup="SearchUserValidationGroup"
+ OnClientClick="OnSearchClick" PostBackUrl="SearchResults.aspx" />
<span class = "failureNotification" >
<asp:Literal ID = "EntryError" Visible="false" runat = "server"></asp:Literal>
</span>
@@ -50,7 +50,6 @@ protected void OnSearchClick(object sender, EventArgs e)
TextBox EmployerHistoryEmailBox = (TextBox)FindControl("EmployerHistoryEmailBox");
// Query the DB
- SqlConnection dbConn = new SqlConnection();
SqlCommand sqlComm = new SqlCommand();
int emptyCount = 0;
@@ -211,8 +210,8 @@ protected void OnSearchClick(object sender, EventArgs e)
EntryError.Text = "You did not specify any criteria. You cannot run an empty search";
EntryError.Visible = true;
} else {
- // Generate search query here as a session variable
- string sqlQuery = "SELECT ";
+ string sqlQuery = sqlComm.ToString();
+ // Generate search query here as a session variable - will be passed to results page
Session["SearchQuery"] = sqlQuery;
}
@@ -221,7 +220,6 @@ protected void OnSearchClick(object sender, EventArgs e)
}
finally {
// Close DB connection and queries
- dbConn.Close();
sqlComm.Dispose();
}
}
@@ -1,33 +1,40 @@
-<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="SearchResults.aspx.cs"
- Inherits="StudentAlumniTrackingTool.WebPages.SearchResults" %>
-<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
+<%@ Page Title="Results" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
+ CodeBehind="SearchResults.aspx.cs" Inherits="StudentAlumniTrackingTool.WebPages.SearchResults" %>
+
+<asp:Content ID="Header" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
-<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
+<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<h1>Search Results</h1>
<p>
Here are the result(s):
</p>
-
<asp:Panel ID="ResultsPanel" runat="server" Visible="False">
<asp:GridView ID = "ResultsGridView" runat = "server"
AutoGenerateColumns = "False" DataSourceID = "SqlDataSource1"
Width="100%" onselectedindexchanged="ResultsGridView_SelectedIndexChanged">
<Columns>
- <asp:BoundField DataField = "LastName" HeaderText = "Last Name" SortExpression = "LastName" />
- <asp:TemplateField HeaderText = "First Name">
- <ItemTemplate>
- <asp:LinkButton ID = "LinkName" runat = "server" Text='<%# Eval("FirstName") %>'
- PostBackUrl='<%#"~/Profile.aspx?ID="Eval("ID") %>'></asp:LinkButton>
- </ItemTemplate>
- </asp:TemplateField>
- <asp:BoundField DataField = "Education" HeaderText = "Education" SortExpression = "Education" />
- <asp:ImageField AlternateText="Edit" DataImageUrlField="../Images/pencil.gif"></asp:ImageField>
- <asp:ImageField DataImageUrlField="../Images/delete.gif" AlternateText="Delete"></asp:ImageField>
+ <asp:BoundField DataField = "LastName" HeaderText = "Last Name" SortExpression = "LastName" />
+ <asp:TemplateField HeaderText = "First Name">
+ <ItemTemplate>
+ <asp:LinkButton ID = "LinkName" runat = "server"></asp:LinkButton>
+ </ItemTemplate>
+ </asp:TemplateField>
+ <asp:BoundField DataField = "Education" HeaderText = "Education" SortExpression = "Education" />
+ <asp:TemplateField HeaderText="Edit" ControlStyle-Width = "25px" >
+ <ItemTemplate>
+ <asp:Image AlternateText = "Edit" ImageUrl = "~/Images/pencil.gif" runat = "server" />
+ </ItemTemplate>
+ </asp:TemplateField>
+ <asp:TemplateField HeaderText="Delete" ControlStyle-Width="25px">
+ <ItemTemplate>
+ <asp:Image ID = "DeleteImg" AlternateText = "Delete" ImageUrl = "~/Images/delete.gif" runat = "server" />
+ </ItemTemplate>
+ </asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID = "SqlDataSource1" runat = "server" ConnectionString = "<%$ ConnectionStrings:ConnectionString %>"
- SelectCommand = "<%= %>">
+ SelectCommand = "<%= Session["SearchQuery"] %>">
<SelectParameters>
<asp:ControlParameter ControlID = " " Name = "FirstName" PropertyName = "Text" Type = "String" />
@@ -14,7 +14,14 @@ protected void Page_Load(object sender, EventArgs e)
{
int count = 0;
if (Session["SearchQuery"] == null)
+ {
NoResultsPanel.Visible = true;
+ ResultsPanel.Visible = false;
+ }
+ else
+ {
+ ResultsPanel.Visible = true;
+ }
}
protected void ResultsGridView_SelectedIndexChanged(object sender, EventArgs e)

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit f85a122

Please sign in to comment.