Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

client side: your garages edit and update views, update still not wor…

…king
  • Loading branch information...
commit a46452a9cf3419991e645e187c3a92a24911b502 1 parent 35247cb
@Martikos Martikos authored
View
4 App_Code/DataServices/GarageDataService.cs
@@ -112,7 +112,7 @@ public static List<Garage> getGarageSalesBy(String columnName, String value, int
}
else
{
- cmd = new SqlCommand("SELECT * FROM Listing where " + columnName + " = @Value", conn);
+ cmd = new SqlCommand("SELECT * FROM GarageSale where " + columnName + " = @Value", conn);
}
cmd.Parameters.AddWithValue("@Value", value);
SqlDataReader reader = cmd.ExecuteReader();
@@ -123,7 +123,7 @@ public static List<Garage> getGarageSalesBy(String columnName, String value, int
garageSales.Add(listing);
}
conn.Close();
-
+ reader.Dispose();
return garageSales;
}
View
19 Views/Private/GarageSale.aspx
@@ -24,6 +24,7 @@
<asp:MultiView ID="garagesale_view" runat="server">
<asp:View ID="view_viewgarage" runat="server">
+
<div id="viewgarage_title">
Garage Sales Around You
</div>
@@ -68,7 +69,25 @@
</tr>
</table>
</asp:View>
+ <asp:View ID="view_editgarage" runat="server">
+ List of your garage sales here
+ <script type="text/javascript">
+ function editgarage(parameter, number) {
+ __doPostBack(parameter, parameter)
+ }
+ </script>
+ <table align="center">
+ <tr>
+ <td>
+ <div id="your_garages" runat="server">
+
+ </div>
+ </td>
+ </tr>
+ </table>
+
+ </asp:View>
</asp:MultiView>
View
76 Views/Private/GarageSale.aspx.cs
@@ -13,29 +13,49 @@ public partial class Views_Private_GarageSale : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
{
- int[] hours = {12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
- if (!IsPostBack)
+ string parameter = Request["__EVENTARGUMENT"];
+ if (parameter == "" || parameter == null)
{
- foreach (int i in hours) {
- for (int j = 0; j < 4; j++)
- {
- begin_time_list.Items.Add(i + ":" + (j*15).ToString().PadLeft(2,'0') + " AM");
- end_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " AM");
- }
+ String view = Request.QueryString["View"];
+ if (view == "3")
+ {
+ garagesale_view.SetActiveView(view_editgarage);
+ loadYourGarageSales();
}
- foreach (int i in hours)
+ else
{
- for (int j = 0; j < 4; j++)
+
+ int[] hours = { 12, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
+ if (!IsPostBack)
{
- begin_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " PM");
- end_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " PM");
+ foreach (int i in hours)
+ {
+ for (int j = 0; j < 4; j++)
+ {
+ begin_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " AM");
+ end_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " AM");
+ }
+ }
+ foreach (int i in hours)
+ {
+ for (int j = 0; j < 4; j++)
+ {
+ begin_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " PM");
+ end_time_list.Items.Add(i + ":" + (j * 15).ToString().PadLeft(2, '0') + " PM");
+ }
+ }
+ date_cal.SelectedDate = DateTime.Today;
+ date_cal.VisibleDate = DateTime.Today;
+ begin_time_list.SelectedIndex = 0;
+ end_time_list.SelectedIndex = 0;
+
}
}
- date_cal.SelectedDate = DateTime.Today;
- date_cal.VisibleDate = DateTime.Today;
- begin_time_list.SelectedIndex = 0;
- end_time_list.SelectedIndex = 0;
-
+ }
+ else
+ {
+ /* update page */
+ Response.Redirect("~/Views/Private/UpdateGarage.aspx?G=" + parameter);
}
}
protected void Button1_Click(object sender, EventArgs e)
@@ -162,8 +182,24 @@ protected void Button2_Click(object sender, EventArgs e)
protected void Button3_Click(object sender, EventArgs e)
{
- Response.Redirect("~/Views/Private/UpdateGarage.aspx");
+ // Response.Redirect("~/Views/Private/UpdateGarage.aspx");
+ garagesale_view.SetActiveView(view_editgarage);
+ loadYourGarageSales();
}
+ private void loadYourGarageSales()
+ {
+ /* load user garage sales here */
+ MembershipUser user = Membership.GetUser();
+ Guid userId = (Guid)user.ProviderUserKey;
+
+ List<Garage> garages = GarageDataService.getGarageSalesBy("UserId", userId.ToString());
+ your_garages.InnerHtml = "";
+ foreach (Garage garage in garages)
+ {
+ your_garages.InnerHtml += createGarageDiv(garage);
+ }
+ }
+
private void loadGarageSales()
{
List<Garage> garages = GarageDataService.getGarageSales();
@@ -185,9 +221,9 @@ private String createGarageDiv(Garage garage)
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>";
+ objectHTML += "</div><button onclick=\"editgarage('"+ garage.GarageID + "', '');\">Update</button></div></br></br>";
return objectHTML;
-
}
+
}
View
14 Views/Private/UpdateGarage.aspx.cs
@@ -90,24 +90,20 @@ protected void Update_Click(object sender, EventArgs e)
Guid userId = (Guid)user.ProviderUserKey;
Garage oldGarage = GarageDataService.getGarageSale(Request.QueryString["G"]);
- oldGarage.userID = userId;
- oldGarage.DateBegin = begintime;
- oldGarage.DateEnd = endtime;
- oldGarage.Address = address;
- oldGarage.Description = description;
-
- bool success = GarageDataService.updateGarageSale(oldGarage.GarageID.ToString(), oldGarage);
+ Garage newGarage = new Garage(userId, begintime, endtime, address, description);
if (imageUpload.HasFile)
{
int imageId = saveImageFile();
oldGarage.imageId = imageId;
+ newGarage.imageId = imageId;
}
-
+ bool success = GarageDataService.updateGarageSale(oldGarage.GarageID.ToString(), newGarage);
+
updategarage_output.Text = "Garage Sale updated successfully!";
updategarage_output.Style.Add("color", "#00ff00");
- Response.Redirect("~/Views/Private/UpdateGarage.aspx?G=" + oldGarage.GarageID);
+ Response.Redirect("~/Views/Private/GarageSale.aspx?View=" + 3);
}
catch (Exception ex)
{
Please sign in to comment.
Something went wrong with that request. Please try again.