Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            switch (Request.QueryString["item"])
            {
            case "ad":
                if (Convert.ToInt32(Request.QueryString["id"]) > 0)
                {
                    if (CustomerAd.Confirm(Convert.ToInt32(Request.QueryString["id"])))
                    {
                        lblThanks.Text = "Thanks for confirming your ad with us. Please allow 12 - 24 hours for your ad to be approved.";
                    }
                }
                break;

            case "car":
                if (Convert.ToInt32(Request.QueryString["id"]) > 0)
                {
                    if (CustomerVehicleInfo.Confirm(Convert.ToInt32(Request.QueryString["id"])))
                    {
                        lblThanks.Text = @"Thanks for confirming your vehicle ad with us. Please allow 12 - 24 hours for your ad to be approved. ";
                    }
                }
                break;
            }
        }
        protected void GetPaid(string itemType, string aditem, string amnt, CreditCardDetailsType cc)
        {
            HttpContext CurrContext = HttpContext.Current;

            //amnt = "1.00";
            try
            {
                DoDirectPaymentResponseType reply = DirectPayment.DoDirectPaymentAPIOperation(cc, amnt);
                Session["Reply"]       = reply;
                Session["PaymentInfo"] = cc;
                if (reply.Ack.ToString().Trim().ToUpper().Equals("SUCCESS"))
                {
                    switch (itemType)
                    {
                    case "car":
                        VehiclesBilling vb = Session["VehicleBilling"] as VehiclesBilling;
                        vb.PayPalId    = reply.TransactionID;
                        vb.PayPalState = reply.Ack.ToString();
                        vb.CreateTime  = Convert.ToDateTime(reply.Timestamp);
                        if (VehiclesBilling.PaidInFull(vb))
                        {
                            CustomerVehicleInfo.UpdateBillingId(Convert.ToInt32(Session["VehicleId"]), vb.Id);
                            NotifyCustomer(Convert.ToInt32(Session["VehicleId"]), itemType, vb.Payment, "0", reply.TransactionID);
                            NotifyAdmin(Request.QueryString["item"], vb.Payment, "0", reply.TransactionID);
                        }
                        break;

                    case "ad":
                        AdsBilling ad = new AdsBilling
                        {
                            CustomerId  = Convert.ToInt32(Session["CustomerId"]),
                            AdId        = Convert.ToInt32(Request.QueryString["id"]),
                            Payment     = Convert.ToDouble(amnt),
                            PayPalId    = reply.TransactionID,
                            PayPalState = reply.Ack.ToString(),
                            CreateTime  = Convert.ToDateTime(reply.Timestamp)
                        };
                        if (AdsBilling.InsertNewBilling(ad))
                        {
                            CustomerAd.PaidInFull(ad.AdId);
                            NotifyCustomer(ad.AdId, itemType, ad.Payment, "0", reply.TransactionID);
                            NotifyAdmin(Request.QueryString["item"], ad.Payment, "0", reply.TransactionID);
                        }
                        break;
                    }
                }
                else
                {
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Error", " alert('Transaction failed, please check your credit card information and try again.');", true);
                    //Server.Transfer("~/account/PaymentResponse.aspx");
                }
            }
            catch (WebException ex)
            {
                CurrContext.Items.Add("Error", ex.Message);
                ErrorHandler.writeExceptionToLogFile(ex);
            }
        }
Esempio n. 3
0
 protected void BtnDecline_Click(object sender, EventArgs e)
 {
     if (CustomerAd.DeclineAd(Convert.ToInt32(hfAdId.Value)))
     {
         AdDeclined(Convert.ToInt32(hfCustomerId.Value), Convert.ToInt32(hfAdId.Value));
     }
     else
     {
         ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Error", "alert('Failed declining ad #" + hfAdId.Value + ".');", true);
     }
     gvCustomersAds.DataBind();
 }
Esempio n. 4
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();
 }
        protected void LoadImages()
        {
            ltlErr.Text = Session["ImgSizeErr"].ToString();
            CustomerAd adImgs = (CustomerAd)Session["ad"];

            if (adImgs != null)
            {
                if (adImgs.Img1 != "")
                {
                    pnlCrop1.Visible = true;
                    Image1.ImageUrl  = adImgs.Img1;
                    SetCrop(CropImage1);
                }
                else
                {
                    pnlCrop1.Visible = false;
                }
                if (adImgs.Img2 != "")
                {
                    pnlCrop2.Visible = true;
                    Image2.ImageUrl  = adImgs.Img2;
                    SetCrop(CropImage2);
                }
                else
                {
                    pnlCrop2.Visible = false;
                }
                if (adImgs.Img3 != "")
                {
                    pnlCrop3.Visible = true;
                    Image3.ImageUrl  = adImgs.Img3;
                    SetCrop(CropImage3);
                }
                else
                {
                    pnlCrop3.Visible = false;
                }
                if (adImgs.Img4 != "")
                {
                    pnlCrop4.Visible = true;
                    Image4.ImageUrl  = adImgs.Img4;
                    SetCrop(CropImage4);
                }
                else
                {
                    pnlCrop4.Visible = false;
                }
            }
        }
Esempio n. 6
0
        private void UpdateAdBillingAdmin(double amnt)
        {
            AdsBilling ad = new AdsBilling();

            ad.CustomerId  = usr.Id;
            ad.AdId        = filesuploaded;
            ad.Payment     = amnt;
            ad.PayPalId    = "BizAd by admin";
            ad.PayPalState = "SUCCESS";
            ad.CreateTime  = DateTime.Now;
            if (AdsBilling.InsertNewBilling(ad))
            {
                CustomerAd.PaidInFull(ad.AdId);
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", " alert('Business ad completed.');", true);
            }
        }
Esempio n. 7
0
        protected void BtnSaveAd_Click(object sender, EventArgs e)
        {
            string err = ImageErr(rblAdFormat.SelectedValue);

            if (err != string.Empty)
            {
                pnlErr.Visible = true;
                ltlErr.Text    = "<ul>" + err + "</ul><p>Please upload files of correct sizes.</p>";
                return;
            }
            CustomerAd         ad         = new CustomerAd();
            int                CustomerId = usr.Id;
            string             path       = "c" + CustomerId + "_ads";
            HttpFileCollection files      = Request.Files;

            string[] allowedExtension = { ".jpeg", ".jpg", ".png", ".gif" };

            ad.AdType    = rblAdFormat.SelectedValue;
            ad.AdDetails = txtAdDetails.Text;
            if (FileUpload1.HasFile)
            {
                ad.Img1 = @"/imgs/" + path + "/" + Helpers.RemoveInvalidChars(Path.GetFileName(FileUpload1.PostedFile.FileName));
            }
            if (FileUpload2.HasFile)
            {
                ad.Img2 = @"/imgs/" + path + "/" + Helpers.RemoveInvalidChars(Path.GetFileName(FileUpload2.PostedFile.FileName));
            }
            ;
            if (FileUpload3.HasFile)
            {
                ad.Img3 = @"/imgs/" + path + "/" + Helpers.RemoveInvalidChars(Path.GetFileName(FileUpload3.PostedFile.FileName));
            }
            ;
            if (FileUpload4.HasFile)
            {
                ad.Img4 = @"/imgs/" + path + "/" + Helpers.RemoveInvalidChars(Path.GetFileName(FileUpload4.PostedFile.FileName));
            }
            ;

            ad.CustomerId = CustomerId;
            ad.Expires    = DateTime.Now.AddMonths(1);
            if (Session["Role"].ToString() == "admin")
            {
                ad.Active    = true;
                ad.Paid      = true;
                ad.Confirmed = true;
            }
            else
            {
                ad.Active    = false;
                ad.Paid      = false;
                ad.Confirmed = false;
            }
            ad.URL        = (txtUrl.Text == string.Empty) ? string.Empty : txtUrl.Text;
            Session["ad"] = ad;

            filesuploaded = 0;
            try
            {
                if (files.Count > 0)
                {
                    Directory.SetCurrentDirectory(Server.MapPath("~/imgs"));
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    for (var i = 0; i < files.Count; i++)
                    {
                        if (files[i].FileName == "")
                        {
                            break;
                        }
                        if (allowedExtension.Contains(Path.GetExtension(files[i].FileName)))
                        {
                            HttpPostedFile pf        = files[i];
                            string         filetoput = Server.MapPath("~/imgs/" + path + "/" + Helpers.RemoveInvalidChars(Path.GetFileName(files[i].FileName)));
                            pf.SaveAs(filetoput);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Success", "alert('One or more images are of incorrect File format.');", true);
                            return;
                        }
                    }
                }
                filesuploaded = CustomerAd.InsertNewAd(ad);
            }
            catch (Exception ex)
            {
                ErrorHandler.writeExceptionToLogFile(ex);
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Error", "alert('Ad could not be uploaded.');", true);
                filesuploaded = 0;
            }
            if (filesuploaded > 0)
            {
                Session["adId"]   = filesuploaded;
                Session["adSize"] = rblAdFormat.SelectedValue;
                if (err == string.Empty)
                {
                    if (Session["Role"].ToString() == "admin")
                    {
                        double amnt = 299;
                        if (rblAdFormat.SelectedValue == "L")
                        {
                            amnt = 599;
                        }
                        UpdateAdBillingAdmin(amnt);
                        Response.Redirect("~/admin/ads.aspx");
                    }
                    else
                    {
                        Response.Redirect("CheckOut.aspx?item=ad&size=" + rblAdFormat.SelectedValue + "&id=" + filesuploaded + "&promo=0");
                    }
                }
                else
                {
                    pnlErr.Visible = true;
                    ltlErr.Text    = "<ul>" + err + "</ul><p>The images have been uploaded but you cannot continue until you edit the images to correct the size.</p>";
                }
            }
        }
Esempio n. 8
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;
            }
        }