private void BuildPage() { tblList.Rows.Add(this.CreateListHeader(true, new string[] { "ID", "Nome", "Stato" })); CategoryManager cm = new CategoryManager(); List<Category> items = cm.GetCategories(); for (int i = 0; i < items.Count; i++) { TableRow tr = CreateTableRow(); tr.Cells.Add(CreateTableCell(items[i].CategoryID.ToString())); tr.Cells.Add(CreateTableCell(items[i].Name)); if (items[i].Status) tr.Cells.Add(CreateTableCell("Attiva")); else tr.Cells.Add(CreateTableCell("Non attiva")); List<Control> buttons = new List<Control>(); buttons.Add(CreateImageLink("Edit.aspx?ID=" + items[i].CategoryID, "Modifica", ImageButtons.Edit)); buttons.Add(CreateImageButton(JsUtils.CreateJsFunction("performAction", true, new JsonObject(new string[] { "action", "argument" }, new string[] { "delete", items[i].CategoryID.ToString() })), "Elimina", ImageButtons.Delete)); tr.Controls.Add(CreateCommandsCell(buttons)); tblList.Rows.Add(tr); } }
protected void Page_Load(object sender, EventArgs e) { RegisterAjaxSessionKey(); CategoryManager cm = new CategoryManager(); ddlCategories.DataSource = cm.GetActive(); ddlCategories.DataBind(); }
private void BuildPage() { if (QueryStringContains("ID")) { CategoryManager cm = new CategoryManager(); Category c = cm.Load(int.Parse(GetFromQueryString("ID"))); txtName.Text = c.Name; chkActive.Checked = c.Status; } }
private void RenderPage() { CategoryManager cm = new CategoryManager(); ddlCategories.DataSource = cm.GetActive(); ddlCategories.DataBind(); ltCity.Text = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(GetFromQueryString("city").ToLower()); if (QueryStringContains("address")) txtAddress.Text = GetFromQueryString("address"); }
protected void lnkAction_Click(object sender, EventArgs e) { JsonObject action = GetAction(); CategoryManager cm = new CategoryManager(); switch (action["action"].ToString()) { case "delete": cm.Delete(int.Parse(action["argument"].ToString())); Alert("Segnalazione cancellata"); break; } BuildPage(); }
protected void btnSave_Click(object sender, EventArgs e) { CategoryManager cm = new CategoryManager(); Category c = new Category(); c.Name = txtName.Text; c.Status = chkActive.Checked; if (QueryStringContains("ID")) { c.CategoryID = int.Parse(GetFromQueryString("ID")); cm.Update(c); } else cm.Create(c); Response.Redirect("Edit.aspx?ID=" + c.CategoryID); }
/// <summary> /// Handles the ItemDataBound event of the rptList control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param> protected void rptList_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { ((HtmlAnchor)e.Item.FindControl("title")).InnerText = ((Signal)e.Item.DataItem).Subject; ((HtmlAnchor)e.Item.FindControl("title")).HRef = ((Signal)e.Item.DataItem).Link; if (((Signal)e.Item.DataItem).Status == 1) ((System.Web.UI.WebControls.Image)e.Item.FindControl("status")).ImageUrl = "/images/alert.png"; else ((System.Web.UI.WebControls.Image)e.Item.FindControl("status")).ImageUrl = "/images/check.png"; ((Label)e.Item.FindControl("timeframe")).Text = SignalUtils.GetTimeframe(((Signal)e.Item.DataItem).CreationDate); CategoryManager cm = new CategoryManager(); ((Label)e.Item.FindControl("category")).Text = ((Signal)e.Item.DataItem).CategoryName; } }
private void RenderPage() { if (QueryStringContains("id")) { SignalManager sm = new SignalManager(); Signal s = sm.LoadSingnal(int.Parse(GetFromQueryString("id"))); divTitle.InnerHtml = s.Subject; plhDescription.Controls.Add(new LiteralControl(s.Description)); this.Title = String.Format(this.Title, s.Subject, s.Address, s.City); metaOgDescription.Attributes["content"] = s.Excerpt; ogTitle.Attributes["content"] = String.Format(ogTitle.Attributes["content"], s.Subject, s.Address, s.City); if (!s.ShowName) ltAuthor.Text = "Anonimo"; else ltAuthor.Text = s.Name; lblAddress.Text = s.Address; ltTimeFrame.Text = SignalUtils.GetTimeframe(s.CreationDate); CategoryManager cm = new CategoryManager(); ltCategory.Text = cm.Load(s.CategoryID).Name; string markerImage = "MARKERIMAGE_ALERT"; if (s.Status == Signal.SignalStatus.Resolved) markerImage = "MARKERIMAGE_OK"; JsonObject currentMarker = new JsonObject(); currentMarker["id"] = s.SignalID.ToString(); currentMarker["lat"] = s.Latitude;//.ToString(new CultureInfo("en-US")); currentMarker["lng"] = s.Longitude;//.ToString(new CultureInfo("en-US")); currentMarker["zoom"] = s.Zoom;//.ToString(); currentMarker["image"] = new OpenSignals.Framework.Core.Utility.JsUtils.JsConstant(markerImage); currentMarker["zip"] = s.Zip; currentMarker["status"] = s.Status; ClientScript.RegisterClientScriptBlock(this.GetType(), "currentMarker", "currentMarker=" + currentMarker.ToString() + ";", true); if (!s.Attachment.Equals(string.Empty)) { divPhoto.Visible = true; lnkPhoto.HRef = WebUtils.GetImageUrl(UploadPaths.Big, s.Attachment); imgPhoto.ImageUrl = WebUtils.GetImageUrl(UploadPaths.Small, s.Attachment); ogImage.Attributes["content"] = WebUtils.GetImageUrl(UploadPaths.Small, s.Attachment); } switch (s.Status) { case Signal.SignalStatus.ReOpened: divStatusReopened.Visible = true; divStatusReopened.InnerHtml = String.Format(divStatusReopened.InnerHtml, s.ReopenDate.ToShortDateString(), s.ReopenDescription); break; case Signal.SignalStatus.Approved: divStatusNotResolved.Visible = true; break; case Signal.SignalStatus.Resolved: divStatusResolved.Visible = true; divStatusResolved.InnerHtml = String.Format(divStatusResolved.InnerHtml, s.ResolutionDate, s.ResolutionDescription); break; case Signal.SignalStatus.Expired: divStatusExpired.Visible = true; break; } switch (s.CriticalLevel) { case Signal.CriticalLevels.Normal: lblCriticalLevel.Text = "Bassa"; lblCriticalLevel.CssClass = "criticalNormal"; break; case Signal.CriticalLevels.Medium: lblCriticalLevel.Text = "Media"; lblCriticalLevel.CssClass = "criticalMedium"; break; case Signal.CriticalLevels.High: lblCriticalLevel.Text = "Alta"; lblCriticalLevel.CssClass = "criticalHigh"; break; } if (sm.SearchNearZip(s.Zip, s.SignalID).Count == 0) { liMapNearby.Visible = false; mapNearby.Visible = false; } } }
private void RenderPage() { CategoryManager cm = new CategoryManager(); ddlCategories.DataSource = cm.GetActive(); ddlCategories.DataBind(); }
/// <summary> /// Builds the signal description. /// </summary> /// <param name="currentSignal">The current signal.</param> public void BuildSignalDescription(Signal currentSignal) { title.InnerText = currentSignal.Subject; address.Text = currentSignal.Address; CategoryManager cm = new CategoryManager(); category.Text = cm.Load(currentSignal.CategoryID).Name; lnkDetail.HRef = currentSignal.Link; timeframe.Text = SignalUtils.GetTimeframe(currentSignal.CreationDate); if (!currentSignal.Attachment.Equals(string.Empty)) { divImage.Visible = true; imgImage.ImageUrl = WebUtils.GetImageUrl(UploadPaths.Comments, currentSignal.Attachment); } }