Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

database and client side: garage sale api and multiview page

  • Loading branch information...
commit 1e2ce143c2aeccd37a32846bd1df89df40338610 1 parent 73d6bf8
@Martikos Martikos authored
View
23 App_Code/DataServices/GarageDataService.cs
@@ -12,7 +12,26 @@ public class GarageDataService
public GarageDataService()
{
- }
+ }
+
+ public static List<Garage> getGarageSales()
+ {
+ List<Garage> returnList = new List<Garage>();
+
+ SqlConnection conn = DBConnector.getSqlConnection();
+ conn.Open();
+ SqlCommand cmd = new SqlCommand("SELECT * FROM GarageSale", conn);
+
+ SqlDataReader reader = cmd.ExecuteReader();
+ while (reader.Read())
+ {
+ Garage garage = extractGS(reader);
+ returnList.Add(garage);
+ }
+ conn.Close();
+
+ return returnList;
+ }
public static Garage getGarageSale(string id)
{
@@ -82,7 +101,7 @@ public static class ColumnNames
public static string UserId = "UserID";
public static string DateBegin = "DateBegin";
public static string DateEnd = "DateEnd";
- public static string Address = "Address";
+ public static string Address = "Address";
public static string Description = "Description";
}
private static Garage extractGS(SqlDataReader reader)
View
80 Views/Private/GarageSale.aspx
@@ -14,34 +14,62 @@
}
}
</script>
- <div id="form_item">
- Create a new Garage Sale <br />
- <table align="center">
- <tr>
- <td>
- <fieldset>
- <label for="Date" class="form_label">Date of Sale</label><br />
- <%--<asp:TextBox ID="textbox_date" runat="server" name="Date" class="form_field"></asp:TextBox>--%>
- <asp:Calendar width="100%" ID="date_cal" runat="server"></asp:Calendar>
+ <div id="form_item">
+ <div style="text-align: center">
+ <asp:Button ID="Button1" runat="server" Text="Explore Around You" OnClick="Button1_Click1" /> <span> </span>
+ <asp:Button ID="Button2" runat="server" Text="Setup Your Own" OnClick="Button2_Click" />
+ </div>
+
+ <asp:MultiView ID="garagesale_view" runat="server">
+
+ <asp:View ID="view_viewgarage" runat="server">
+ <div id="viewgarage_title">
+ Garage Sales Around You
+ </div>
+ <table align="center">
+ <tr>
+ <td>
+
+ <div id="garagesales" runat="server">
+
+ </div>
+ </td>
+ </tr>
+ </table>
+
+ </asp:View>
+ <asp:View ID="view_creategarage" runat="server">
+ Create a new Garage Sale <br />
+ <table align="center">
+ <tr>
+ <td>
+ <fieldset>
+ <label for="Date" class="form_label">Date of Sale</label><br />
+ <%--<asp:TextBox ID="textbox_date" runat="server" name="Date" class="form_field"></asp:TextBox>--%>
+ <asp:Calendar width="100%" ID="date_cal" runat="server"></asp:Calendar>
- <br />
- <label for="BeginTime" class="form_label">Begin Time</label><br /><asp:DropDownList ID="begin_time_list" width="100%" runat="server"></asp:DropDownList>
- <br /><br />
- <label for="EndTime" class="form_label">End Time</label><asp:DropDownList ID="end_time_list" width="100%" runat="server"></asp:DropDownList><br /><br />
- <label for="Location" class="form_label">Address</label><textarea ID="textbox_location" runat="server" name="Location" class="form_field"></textarea>
- <br /><br />
- <label for="Description" class="form_label">Description</label><textarea id="textbox_description" runat="server" name="Description" class="form_field"></textarea><br /><br />
- <label for="Image" class="form_label">Image (Optional)</label><asp:FileUpload ID="imageUpload" runat="server" onchange="changeImagePreview(this)"/><br /><br />
- <asp:Label ID="creategarage_output" runat="server" Text=""></asp:Label><br />
- <asp:Button ID="button_post" runat="server" Text="List New Garage Sale" class="form_button" OnClick="Button1_Click"/>
+ <br />
+ <label for="BeginTime" class="form_label">Begin Time</label><br /><asp:DropDownList ID="begin_time_list" width="100%" runat="server"></asp:DropDownList>
+ <br /><br />
+ <label for="EndTime" class="form_label">End Time</label><asp:DropDownList ID="end_time_list" width="100%" runat="server"></asp:DropDownList><br /><br />
+ <label for="Location" class="form_label">Address</label><textarea ID="textbox_location" runat="server" name="Location" class="form_field"></textarea>
+ <br /><br />
+ <label for="Description" class="form_label">Description</label><textarea id="textbox_description" runat="server" name="Description" class="form_field"></textarea><br /><br />
+ <label for="Image" class="form_label">Image (Optional)</label><asp:FileUpload ID="imageUpload" runat="server" onchange="changeImagePreview(this)"/><br /><br />
+ <asp:Label ID="creategarage_output" runat="server" Text=""></asp:Label><br />
+ <asp:Button ID="button_post" runat="server" Text="List New Garage Sale" class="form_button" OnClick="Button1_Click"/>
- </fieldset>
- </td>
- <td style="background-color: #eee; width: 200px; height: 100px" >
- <img id="image_preview" src="../../public/img/grey_wash_wall.png" width="200"/>
- </td>
- </tr>
- </table>
+ </fieldset>
+ </td>
+ <td style="background-color: #eee; width: 200px; height: 100px" >
+ <img id="image_preview" src="../../public/img/grey_wash_wall.png" width="200"/>
+ </td>
+ </tr>
+ </table>
+ </asp:View>
+
+ </asp:MultiView>
+
</div>
</asp:Content>
View
45 Views/Private/GarageSale.aspx.cs
@@ -87,6 +87,11 @@ protected void Button1_Click(object sender, EventArgs e)
}
else
{
+ bool b1 = begin_time_list.SelectedIndex > 0;
+ bool b2 = (date_cal.SelectedDate != null);
+ bool b3 = (end_time_list.SelectedIndex > 0);
+ bool b4 = (textbox_location.Value != "");
+ bool b5 = (textbox_description.Value != "");
/* Please fill all fields */
creategarage_output.Text = "Please fill all of the fields.";
creategarage_output.Style.Add("color", "#ff0000");
@@ -141,5 +146,43 @@ private int saveImageFile()
Image fullImage = new Image(data, contentType, height, width);
Image thumbImage = new Image(thumbData, "image/jpg", thumbHeight, thumbWidth);
return ImageDataService.addImage(fullImage, thumbImage);
- }
+ }
+ protected void Button1_Click1(object sender, EventArgs e)
+ {
+
+ garagesale_view.ActiveViewIndex = 0;
+ loadGarageSales();
+
+ }
+ protected void Button2_Click(object sender, EventArgs e)
+ {
+ garagesale_view.ActiveViewIndex = 1;
+ }
+
+ private void loadGarageSales()
+ {
+ List<Garage> garages = GarageDataService.getGarageSales();
+ String objectHTML = garages.Count + " Found In Your Area";
+ foreach(Garage garage in garages)
+ {
+ objectHTML += createGarageDiv(garage);
+ }
+ garagesales.InnerHtml = objectHTML;
+ }
+ private String createGarageDiv(Garage garage)
+ {
+ string objectHTML = "</br></br><div class=\"garage_item_div\">";
+
+ objectHTML += "<div class=\"garage_item_img\"><img width=\"200px\" height=\"200px\" src=\"../../Helpers/GetImage.ashx?ID=" + garage.imageId + "\"></img></div>";
+ objectHTML += "<div class=\"garage_item_desc\"><div class=\"garage_item_user\">" + UserDataService.getUser(garage.userID).name + "</div>";
+ objectHTML += "<div class=\"garage_item_description\">" + garage.Description + "</div>";
+ objectHTML += "<div class=\"garage_item_datebegin\">From: " + garage.DateBegin + "</div>";
+ objectHTML += "<div class=\"garage_item_dateend\">To: " + garage.DateEnd + "</div>";
+ objectHTML += "<div class=\"garage_item_address\">Address: " + garage.Address + "</div>";
+
+ objectHTML += "</div></div></br></br>";
+
+ return objectHTML;
+
+ }
}
View
12 public/css/style.css
@@ -373,6 +373,18 @@ div.featured_item_div:hover {
text-align: left;
}
+.garage_item_div {
+ border: 1px #333 solid;
+ padding: 10px;
+}
+.garage_item_img {
+
+}
+.garage_item_desc {
+
+}
+
+
#stitch {
border: 2px #ccc dotted;
Please sign in to comment.
Something went wrong with that request. Please try again.