Esempio n. 1
0
 protected void BtnApprove_Click(object sender, EventArgs e)
 {
     if (CustomerAd.SetActiveStatus(Convert.ToInt32(hfAdId.Value), true))
     {
         ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "alert('The ad #" + hfAdId.Value + " has been activated.');", true);
         NotifyCustomer(Convert.ToInt32(hfCustomerId.Value), Convert.ToInt32(hfAdId.Value));
     }
     else
     {
         ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "alert('Failed activating ad #" + hfAdId.Value + ".');", true);
     }
     gvCustomersAds.DataBind();
 }
Esempio n. 2
0
        protected void gvCustomersAd_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "on":
                if (CustomerAd.SetActiveStatus(Convert.ToInt32(e.CommandArgument), true))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "alert('The ad #" + e.CommandArgument + " has been activated.');", true);
                    gvCustomersAds.DataBind();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "alert('Failed activating ad #" + e.CommandArgument + ".');", true);
                }
                break;

            case "off":
                if (CustomerAd.SetActiveStatus(Convert.ToInt32(e.CommandArgument), false))
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "alert('The ad #" + e.CommandArgument + " has been deactivated.');", true);
                    gvCustomersAds.DataBind();
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "alert('Failed deaktivating ad #" + e.CommandArgument + ".');", true);
                }
                break;

            case "Review":
                CustomerAd imgs = CustomerAd.GetCustomerAdDetails(Convert.ToInt32(e.CommandArgument));
                if (imgs != null)
                {
                    PropertyInfo[] props = imgs.GetType().GetProperties();
                    foreach (PropertyInfo p in props)
                    {
                        if (p.Name.Contains("Img"))
                        {
                            object img = p.GetValue(imgs, null);
                            if (img.ToString() != "")
                            {
                                HtmlAnchor lnk = new HtmlAnchor();
                                lnk.HRef = img.ToString();
                                lnk.Attributes.Add("class", "fancybox-effects-a");
                                lnk.InnerHtml = "<img src='/thumbnail.ashx?pic=" + img + "&size=80' class='thumb' alt='' />";
                                plhImages.Controls.Add(lnk);
                            }
                        }
                    }
                    ltlAdDetails.Text = imgs.AdDetails;
                    if (imgs.URL != "")
                    {
                        txtUrl.Text = string.Concat("<a href='", imgs.URL, ", target='_blank'>", imgs.URL, "</a>");
                    }
                    hfAdId.Value       = e.CommandArgument.ToString();
                    hfCustomerId.Value = imgs.CustomerId.ToString();
                }
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Info", "$('#myModal').modal('show');", true);
                break;

            default:
                break;
            }
        }