protected void Page_Load(object sender, EventArgs e) { int certificateId = GetIdFromQueryString(); if (certificateId > 0) { CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); DollarSaverDB.CertificateDataTable certificateTable = certificateAdapter.GetCertificate(certificateId); if (certificateTable.Rows.Count == 1) { DollarSaverDB.CertificateRow certificate = certificateTable[0]; if (certificate.Advertiser.StationId != StationId) { RedirectToHomePage(); } certificateDetail.DisplayCertificate = certificate; } else { RedirectToHomePage(); } } else { RedirectToHomePage(); } }
void deleteButton_Click(object sender, EventArgs e) { int advertiserId = Int32.Parse(advertiserIdHidden.Value); if (idHidden.Value != String.Empty) { certificateId = Int32.Parse(idHidden.Value); try { CertificateNumberTableAdapter certNumberAdapter = new CertificateNumberTableAdapter(); certNumberAdapter.DeleteByCertificate(certificateId); CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); certificateAdapter.Delete(certificateId); Response.Redirect("~/admin/AdvertiserEdit.aspx?id=" + advertiserId); } catch (SqlException ex) { if (ex.Number == 547) { ErrorMessage = "Certificate cannot be deleted due to database constraints. De-activate it instead."; } else { throw ex; } } } }
protected void Page_Load(object sender, EventArgs e) { runningLowGrid.RowDataBound += new GridViewRowEventHandler(runningLowGrid_RowDataBound); if (!Page.IsPostBack) { if (CurrentUser.Role == AdminRole.SalesRep) { managerHolder.Visible = false; } else { managerHolder.Visible = true; OrderTableAdapter orderAdapter = new OrderTableAdapter(); DollarSaverDB.OrderDataTable recentOrders = orderAdapter.GetRecent(StationId, 10); DollarSaverDB.OrderDataTable nonPrintableOrders = orderAdapter.GetRecentUnprintable(StationId, 10); nonPrintableOrderGrid.DataSource = nonPrintableOrders.Rows; nonPrintableOrderGrid.DataBind(); recentOrderGrid.DataSource = recentOrders.Rows; recentOrderGrid.DataBind(); } CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); DollarSaverDB.CertificateDataTable runningLowCertificates = certificateAdapter.GetRunningLow(StationId); runningLowGrid.DataSource = runningLowCertificates.Rows; runningLowGrid.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { certificateId = GetIdFromQueryString(); CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); DollarSaverDB.CertificateDataTable certificateTable = certificateAdapter.GetCertificate(certificateId); if (certificateTable.Count != 1) { Response.Redirect("~/admin/AdvertiserList.aspx"); } certificate = certificateTable[0]; if (certificate.Advertiser.StationId != StationId) { Response.Redirect("~/admin/AdvertiserList.aspx"); } if (certificate.Advertiser.IsDeleted) { InfoMessage = "Sorry, this advertiser has been deleted"; Response.Redirect("~/admin/AdvertiserList.aspx"); } if (!Page.IsPostBack) { returnToCertificateLink.NavigateUrl = "~/admin/CertificateEdit.aspx?id=" + certificate.CertificateId; advertiserNameLabel.Text = certificate.Advertiser.Name; certificateNameLabel.Text = certificate.ShortName; DollarSaverDB.CertificateNumberDataTable usedNumbers = certificate.UsedNumbers; usedCountLabel.Text = usedNumbers.Count.ToString(); usedNumbers.DefaultView.Sort = "CreateDate"; var sortedNumbers = from DollarSaverDB.CertificateNumberRow cn in usedNumbers orderby cn.CreateDate.ToString("yyyyMMdd") descending, cn.OrderId ascending select cn; usedNumberGrid.DataSource = sortedNumbers; usedNumberGrid.DataBind(); } }
void sendSoldoutNoticeButton_Click(object sender, EventArgs e) { int certificateId = Convert.ToInt32(certificateIdBox.Text); CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); DollarSaverDB.CertificateDataTable certificateLookup = certificateAdapter.GetCertificate(certificateId); if (certificateLookup.Count == 1) { NotifySoldOut(certificateLookup[0]); InfoMessage = "Sent Sold Out Notice for Certificate " + certificateLookup[0].ShortName; } else { ErrorMessage = "Certificate Not Found"; } }
private void BindData() { //DealTableAdapter dealAdapter = new DealTableAdapter(); //DollarSaverDB.DealDataTable deals = dealAdapter.GetByStation(StationId); CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); DollarSaverDB.CertificateDataTable certificates = certificateAdapter.GetActive(StationId); certificates.DefaultView.Sort = "OnSaleDate DESC"; //certificates = (DollarSaverDB.CertificateDataTable) certificates.DefaultView.ToTable(); if (certificates.Count > 0) { //startDate = deals[0].StartDate; DollarSaverDB.CertificateDataTable c = new DollarSaverDB.CertificateDataTable(); foreach (DataRow row in certificates.DefaultView.ToTable().Rows) { c.ImportRow(row); } dealHolder.Visible = true; noDealHolder.Visible = false; //dealGrid.DataSource = ((DollarSaverDB.CertificateDataTable)certificates.DefaultView.ToTable()).Rows; dealGrid.DataSource = c.Rows; dealGrid.DataBind(); } else { dealHolder.Visible = false; noDealHolder.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.RawUrl.StartsWith("/dollarsaver/index")) { //Response.Redirect("~/Default.aspx?station_id=" + StationId); DollarSaverRedirect("~/Default.aspx"); } DateTime currentDate = DateTime.Now; currentDate = new DateTime(currentDate.Year, currentDate.Month, currentDate.Day); StationTableAdapter stationAdapter = new StationTableAdapter(); DollarSaverDB.StationRow station = stationAdapter.GetStation(StationId)[0]; siteType = (SiteType)station.SiteTypeId; CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); //stationNameLabel.Text = station.Name; if (!station.IsContent1Null()) { content1Label.Text = station.Content1; } if (!station.IsContent2Null()) { content2Label.Text = station.Content2; } String ImageDir = Request.PhysicalApplicationPath + station.ImageDirUrl; if (station.StationSiteType == SiteType.Standard) { standardHolder.Visible = true; dealHolder.Visible = false; signUpTopLink.NavigateUrl = GetUrl(signUpTopLink.NavigateUrl); SpecialSettingsTableAdapter specialSettingsAdapter = new SpecialSettingsTableAdapter(); DollarSaverDB.SpecialSettingsDataTable specialSettingsTable = specialSettingsAdapter.GetSpecialSettings(StationId); bool dailyHeader = false; if (specialSettingsTable.Count == 1) { dailyHeader = specialSettingsTable[0].DailyHeader; } Image dailyWeeklyImage = new Image(); if (dailyHeader) { //dailyWeeklyImage.SkinID = "dailyImage"; if (!station.Content.IsDailyDealImageNull() && File.Exists(ImageDir + station.Content.DailyDealImage)) { dailyWeeklyImage.ImageUrl = station.ImageDirUrl + station.Content.DailyDealImage; } else { dailyWeeklyImage.ImageUrl = "~/images/boxtop_daily.gif"; } } else { //dailyWeeklyImage.SkinID = "weeklyImage"; if (!station.Content.IsWeeklyDealImageNull() && File.Exists(ImageDir + station.Content.WeeklyDealImage)) { dailyWeeklyImage.ImageUrl = station.ImageDirUrl + station.Content.WeeklyDealImage; } else { dailyWeeklyImage.ImageUrl = "~/images/boxtop_weekly.gif"; } } dailyWeeklyImageHolder.Controls.Add(dailyWeeklyImage); DollarSaverDB.CertificateDataTable daily = certificateAdapter.GetSpecial(StationId, 1); if (daily.Count == 1) { SpecialCert1.DisplayCertificate = daily[0]; if (HitCounterEnabled) { LogHit(currentDate, daily[0].CertificateId, PageHitType.HomePage); } } DollarSaverDB.CertificateDataTable cert2 = certificateAdapter.GetSpecial(StationId, 2); if (cert2.Count == 1) { SpecialCert2.DisplayCertificate = cert2[0]; if (HitCounterEnabled) { LogHit(currentDate, cert2[0].CertificateId, PageHitType.HomePage); } } DollarSaverDB.CertificateDataTable cert3 = certificateAdapter.GetSpecial(StationId, 3); if (cert3.Count == 1) { SpecialCert3.DisplayCertificate = cert3[0]; if (HitCounterEnabled) { LogHit(currentDate, cert3[0].CertificateId, PageHitType.HomePage); } } DollarSaverDB.CertificateDataTable cert4 = certificateAdapter.GetSpecial(StationId, 4); if (cert4.Count == 1) { SpecialCert4.DisplayCertificate = cert4[0]; if (HitCounterEnabled) { LogHit(currentDate, cert4[0].CertificateId, PageHitType.HomePage); } } if (!station.Content.IsOtherDealsImageNull() && File.Exists(ImageDir + station.Content.OtherDealsImage)) { otherDealsImage.ImageUrl = station.ImageDirUrl + station.Content.OtherDealsImage; } if (!station.Content.IsLogoImageNull() && File.Exists(ImageDir + station.Content.LogoImage)) { logoImage.ImageUrl = station.ImageDirUrl + station.Content.LogoImage; } } else // Deal of the Week { standardHolder.Visible = false; dealHolder.Visible = true; if (!Station.IsSiteNameNull() && Station.SiteName != String.Empty) { dotwStationNameLabel.Text = Regex.Replace(Station.SiteName, "<[^>]+>", ""); } else { dotwStationNameLabel.Text = "DollarSaver Deal of the Week"; } if (!Station.Content.IsDotwSubheaderImageNull() && File.Exists(ImageDir + station.Content.DotwSubheaderImage)) { subheaderCell.Style["background-image"] = "url(" + station.ImageDirUrl + station.Content.DotwSubheaderImage + ")"; } else { subheaderCell.Style["background-image"] = "url(" + ResolveUrl("~/images/dotw_background.gif") + ")"; } DollarSaverDB.CertificateDataTable certificateTable = certificateAdapter.GetCurrentDeal(StationId); if (certificateTable.Count == 1) { dealOfTheWeek.Deal = certificateTable[0]; if (HitCounterEnabled) { LogHit(currentDate, certificateTable[0].CertificateId, PageHitType.HomePage); } } } } }
protected void Page_Load(object sender, EventArgs e) { if (Order == null || Order.StationId != StationId || Order.OrderStatusId != (int)OrderStatus.New) { OrderId = 0; Response.Redirect("~/Cart.aspx"); } com.paypal.sdk.services.NVPCallerServices caller = PayPalAPI.PayPalAPIInitialize(IsDev); NVPCodec encoder = new NVPCodec(); encoder["METHOD"] = "GetExpressCheckoutDetails"; encoder["TOKEN"] = Session["TOKEN"].ToString(); string paypalRequest = encoder.Encode(); string paypalResponse = caller.Call(paypalRequest); NVPCodec decoder = new NVPCodec(); decoder.Decode(paypalResponse); String billingEmailAddress = String.Empty; String firstName = String.Empty; String lastName = String.Empty; String phoneNumber = String.Empty; /* * String address1 = String.Empty; * String address2 = String.Empty; * String city = String.Empty; * String stateCode = String.Empty; * String zipCode = String.Empty; */ string strAck = decoder["ACK"]; if (strAck != null && (strAck == "Success" || strAck == "SuccessWithWarning")) { Session["PAYERID"] = decoder["PAYERID"]; billingEmailAddress = decoder["EMAIL"]; firstName = decoder["FIRSTNAME"]; lastName = decoder["LASTNAME"]; phoneNumber = decoder["PHONENUM"]; } else { /* * string pStrError = * "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" + * "Desc=" + decoder["L_SHORTMESSAGE0"] + "&" + * "Desc2=" + decoder["L_LONGMESSAGE0"]; * * Response.Redirect("APIError.aspx?" + pStrError); * */ ErrorMessage = decoder["L_LONGMESSAGE0"]; //Response.Redirect("~/Cart.aspx"); ResetAndRedirect(); } OrderLineItemTableAdapter orderLineItemAdapter = new OrderLineItemTableAdapter(); OrderTableAdapter orderAdapter = new OrderTableAdapter(); CertificateNumberTableAdapter numberAdapter = new CertificateNumberTableAdapter(); decimal subtotal = 0.0m; foreach (DollarSaverDB.OrderLineItemRow lineItem in Order.LineItems) { int numberAssigned = Convert.ToInt32(numberAdapter.Assign(lineItem.OrderLineItemId)); if (numberAssigned != lineItem.Quantity) { if (numberAssigned == 0) { ErrorMessage = "We're sorry, " + lineItem.Certificate.AdvertiserName + " is no longer available"; orderLineItemAdapter.Delete(lineItem.OrderLineItemId); } else { lineItem.Quantity = numberAssigned; orderLineItemAdapter.Update(lineItem); ErrorMessage = "We're sorry, " + lineItem.Certificate.AdvertiserName + " is no longer available in the quantity you requested. Please review your updated order and click on the chechout button if you would like to purchase the new quantity"; } ResetAndRedirect(); } subtotal += lineItem.Total; } // Check max purchase qty for Deal of the Week if (Station.StationSiteType == SiteType.DealOfTheWeek) { CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); DollarSaverDB.CertificateDataTable certificateTable = certificateAdapter.GetCurrentDeal(StationId); if (certificateTable.Count == 1) { DollarSaverDB.CertificateRow deal = certificateTable[0]; if (deal.MaxPurchaseQty > 0) { foreach (DollarSaverDB.OrderLineItemRow lineItem in Order.LineItems) { if (lineItem.CertificateId == deal.CertificateId) { int pastQty = Convert.ToInt32(orderLineItemAdapter.GetQtyByConsumer(firstName, lastName, billingEmailAddress, null, null, null, Order.ShippingEmail, deal.CertificateId)); if (pastQty + lineItem.Quantity > deal.MaxPurchaseQty) { ErrorMessage = "Sorry, the maximum purchase quantity per person for the Deal of the Week is " + deal.MaxPurchaseQty + "."; if (pastQty >= deal.MaxPurchaseQty) { ErrorMessage += "<BR>You have already purchased the maximum allowed."; } else { int allowedAmount = deal.MaxPurchaseQty - pastQty; ErrorMessage += "<BR>You may only purchase " + allowedAmount + " more."; } ResetAndRedirect(); } } } } } } //charge order here Order.SubTotal = subtotal; Order.GrandTotal = subtotal; Order.BillingFirstName = firstName; Order.BillingLastName = lastName; Order.BillingEmail = billingEmailAddress; /* * Order.BillingAddress1 = address1; * if (address2 != String.Empty) { * Order.BillingAddress2 = address2; * } else { * Order.SetBillingAddress2Null(); * } * Order.BillingCity = city; * Order.BillingStateCode = stateCode; * Order.BillingZipCode = zipCode; */ Order.BillingPhone = phoneNumber; Order.PaymentMethodId = (int)PaymentMethod.PayPal; orderAdapter.Update(Order); if (Order.CheckoutStartDate < Order.LineItemModifiedDate) { ErrorMessage = "Your cart has been updated while checking out, please verify your items and continue the checkout process."; ResetAndRedirect(); } Order.OrderStatusId = (int)OrderStatus.Processing; orderAdapter.Update(Order); encoder["METHOD"] = "DoExpressCheckoutPayment"; encoder["TOKEN"] = Session["TOKEN"].ToString(); encoder["PAYERID"] = Session["PAYERID"].ToString(); encoder["AMT"] = subtotal.ToString("0.00"); encoder["PAYMENTACTION"] = "Sale"; encoder["CURRENCYCODE"] = "USD"; encoder["INVNUM"] = Order.OrderId.ToString(); encoder["ITEMAMT"] = Order.LineItems.SubTotal.ToString("0.00"); foreach (DollarSaverDB.OrderLineItemRow lineItem in Order.LineItems.Rows) { int itemNumber = lineItem.SeqNo - 1; encoder["L_NAME" + itemNumber] = lineItem.ShortName; encoder["L_NUMBER" + itemNumber] = lineItem.CertificateId.ToString(); encoder["L_QTY" + itemNumber] = lineItem.Quantity.ToString(); encoder["L_AMT" + itemNumber] = lineItem.DiscountValue.ToString("0.00"); } paypalRequest = encoder.Encode(); paypalResponse = String.Empty; try { paypalResponse = caller.Call(paypalRequest); } catch { ErrorMessage = "An error occurred while processing your order, please try submitting it again."; ResetAndRedirect(); } decoder.Decode(paypalResponse); strAck = decoder["ACK"]; if (strAck != null && (strAck == "Success" || strAck == "SuccessWithWarning")) { /* * string pStrResQue = "TRANSACTIONID=" + decoder["TRANSACTIONID"] + "&" + * "CURRENCYCODE=" + decoder["CURRENCYCODE"] + "&" + * "AMT=" + decoder["AMT"]; * * Response.Redirect("DoExpressCheckoutPayment.aspx?" + pStrResQue); * */ string transactionId = decoder["TRANSACTIONID"]; Order.TransactionId = transactionId; Order.OrderDate = DateTime.Now; Order.OrderStatusId = (int)OrderStatus.Complete; orderAdapter.Update(Order); InfoMessage = "Successfully processed order"; if (SendReceipt()) { InfoMessage += "<BR />Receipt sent to " + Order.ShippingEmail; } if (Order.AddToMailingList) { CustomerContactTableAdapter customerContactAdapter = new CustomerContactTableAdapter(); customerContactAdapter.Insert(StationId, DateTime.Now, Order.ShippingEmail, Order.BillingFirstName, Order.BillingLastName); } Response.Redirect("~/Confirmation.aspx"); } else { /* * string pStrError = * "ErrorCode=" + decoder["L_ERRORCODE0"] + "&" + * "Desc=" + decoder["L_SHORTMESSAGE0"] + "&" + * "Desc2=" + decoder["L_LONGMESSAGE0"]; * * Response.Redirect("APIError.aspx?" + pStrError); * */ ErrorMessage = "An error has occurred while processing your order: " + decoder["L_LONGMESSAGE0"] + " (" + decoder["L_ERRORCODE0"] + ")"; ResetAndRedirect(); } }
protected void Page_Load(object sender, EventArgs e) { addToCartButton.Click += new ImageClickEventHandler(addToCartButton_Click); upcomingDealsRepeater.ItemDataBound += new RepeaterItemEventHandler(upcomingDealsRepeater_ItemDataBound); if (!Page.IsPostBack) { StationPageBase parent = (StationPageBase)this.Page; if (Deal != null) { dealHolder.Visible = true; dealNotFoundHolder.Visible = false; DateTime now = DateTime.Now; now = TimeZoneInfo.ConvertTime(now, TimeZoneInfo.Local, Deal.Advertiser.Station.StationTimeZoneInfo); todayLiteral.Text = now.ToString("MMM dd, yyyy HH:mm:ss"); saleDayLiteral.Text = Deal.AdjustedOnSaleDate.ToString("MMM dd, yyyy HH:mm:ss"); //stationName1Label.Text = Deal.Advertiser.Station.Name; //stationName2Label.Text = Deal.Advertiser.Station.Name; //stationName3Label.Text = Deal.Advertiser.Station.Name; if (Deal.Advertiser.LogoUrl != String.Empty) { advertiserImage.Visible = true; if (Deal.Advertiser.IsLogoImageVertical) { advertiserImage.Width = 75; advertiserImage.Height = 125; } else { advertiserImage.Width = 125; advertiserImage.Height = 75; } advertiserImage.AlternateText = Deal.AdvertiserName; advertiserImage.ToolTip = Deal.AdvertiserName; advertiserImage.ImageUrl = Deal.Advertiser.LogoUrl; } else { advertiserImage.Visible = false; } if (Deal.Advertiser.FullAddress != String.Empty) { addressLabel.Text = "<strong>Address</strong><br />" + Deal.Advertiser.FullAddress; } if (Deal.Advertiser.DisplayPhoneNumber != String.Empty) { phoneLabel.Text = "<strong>Phone</strong><br />" + Deal.Advertiser.DisplayPhoneNumber; } advertiserNameLabel.Text = Deal.Advertiser.Name; advertiserDescriptionLabel.Text = Deal.Advertiser.DisplayDescription; if (!Deal.Advertiser.IsWebsiteUrlNull()) { viewWebsiteLink.NavigateUrl = Deal.Advertiser.WebsiteUrl; } else { viewWebsiteLink.Visible = false; } nameLabel.Text = Deal.ShortName; descriptionLabel.Text = Deal.Description; quantityLabel.Text = Deal.QtyRemaining.ToString(); valueLabel.Text = Deal.FaceValue.ToString("$#,0.00"); priceLabel.Text = Deal.DiscountValue.ToString("$#,0.00"); if (Deal.DiscountTypeId == 1) { savingsLabel.Text = Deal.Discount.ToString("0") + "%"; } else { savingsLabel.Text = Deal.Discount.ToString("$#,0.00"); } OnLoadScript = "countdown();"; if (Deal.AdjustedOnSaleDate > now) { onSaleDateLabel.Text = "ON SALE " + Deal.AdjustedOnSaleDate.ToString("dddd").ToUpper() + " AT " + Deal.AdjustedOnSaleDate.ToString("hh:mm tt"); //OnLoadScript = "countdown(" + Deal.StartDate.Year + ", " + Deal.StartDate.Month + ", " + Deal.StartDate.Day + ", " + Deal.StartDate.Hour + ", " + Deal.StartDate.Minute + ");"; } else { onSaleDateLabel.Text = "ON SALE NOW"; onSaleDateLabel.Style["font-size"] = "20px"; } if (Deal.QtyRemaining == 0) { mainTable.Attributes["class"] = "soldOut"; addToCartButton.Visible = false; qtyDropDown.Visible = false; qtyLabel.Visible = false; } else { addToCartButton.Visible = true; qtyDropDown.Visible = true; qtyLabel.Visible = true; // form fields certificateIdHidden.Value = Deal.CertificateId.ToString(); stationIdHidden.Value = Deal.Advertiser.StationId.ToString(); int startQty = 1; if (Deal.MinPurchaseQty > 1) { startQty = Deal.MinPurchaseQty; } if (startQty > Deal.QtyRemaining) { startQty = Deal.QtyRemaining; } int endQty = 20; if (Deal.MaxPurchaseQty > 0 && Deal.MaxPurchaseQty < 20) { endQty = Deal.MaxPurchaseQty; } if (endQty > Deal.QtyRemaining) { endQty = Deal.QtyRemaining; } for (int i = startQty; i <= endQty; i++) { qtyDropDown.Items.Add(new ListItem(i.ToString())); } } CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); DollarSaverDB.CertificateDataTable upcomingDeals = certificateAdapter.GetUpcomingDeals(Deal.Advertiser.StationId); if (upcomingDeals.Count > 0) { upcomingDealsHolder.Visible = true; upcomingDealsRepeater.DataSource = upcomingDeals.Rows; upcomingDealsRepeater.DataBind(); } else { upcomingDealsHolder.Visible = false; } StationPageBase parentPage = (StationPageBase)this.Page; String advertiserUrl = "http://"; if (parentPage.UseSubdomain) { advertiserUrl += Deal.Advertiser.Station.Subdomain + "."; } advertiserUrl += parentPage.EnvDomain + ResolveUrl("~/Advertiser.aspx?advertiser_id=" + Deal.AdvertiserId); advertiserUrlLiteral.Text = advertiserUrl; twitterAdvertiserUrlLiteral.Text = advertiserUrl; twitterTextLiteral.Text = Server.HtmlEncode("Save " + Deal.Savings + " at " + Deal.AdvertiserName); } else { dealHolder.Visible = false; dealNotFoundHolder.Visible = true; } } }
void saveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { int advertiserId = Int32.Parse(advertiserIdHidden.Value); String shortName = nameBox.Text.Trim(); String description = descriptionBox.Text.Trim(); if (shortName == String.Empty) { ErrorMessage = "Name is required"; return; } if (shortName.Length > 100) { shortName = shortName.Substring(0, 100); } if (description == String.Empty) { ErrorMessage = "Description is required"; return; } if (description.Length > 500) { description = description.Substring(0, 500); } int minPurchaseQty = 0; try { minPurchaseQty = Int32.Parse(minPurchaseQtyBox.Text); } catch { ErrorMessage = "Min Purchase Qty must be an integer"; return; } if (minPurchaseQty <= 0) { ErrorMessage = "Min Purchase Qty must be a postive number"; return; } int maxPurchaseQty = 0; try { maxPurchaseQty = Int32.Parse(maxPurchaseQtyBox.Text); } catch { ErrorMessage = "Max Purchase Qty must be an integer"; return; } if (maxPurchaseQty < 0) { ErrorMessage = "Min Purchase Qty must be greater than or equal to 0"; return; } decimal faceValue = 0; try { faceValue = Decimal.Parse(faceValueBox.Text); } catch { ErrorMessage = "Face Value must be a decimal"; return; } if (faceValue <= 0) { ErrorMessage = "Face Value be a postive"; return; } decimal discount = 0; try { discount = Decimal.Parse(discountBox.Text); } catch { ErrorMessage = "Discount must be a decimal"; return; } if (discount <= 0) { ErrorMessage = "Discount be a postive"; return; } int discountTypeId = Int32.Parse(discountList.SelectedValue); String onSaleDateStr = String.Empty; if (Station.StationSiteType == SiteType.DealOfTheWeek) { onSaleDateStr = onSaleDateList.SelectedValue; } else { onSaleDateStr = onSaleDateBox.Text.Trim(); } if (onSaleDateStr == String.Empty) { ErrorMessage = "On Sale Date is required"; return; } if (Station.StationSiteType == SiteType.Standard) { onSaleDateStr += " " + onSaleHourList.SelectedValue + ":" + onSaleMinuteList.SelectedValue + ":00 "; } DateTime onSaleDate; try { onSaleDate = Convert.ToDateTime(onSaleDateStr); } catch { ErrorMessage = "On Sale Date must by in the format MM/DD/YYYY"; return; } onSaleDate = TimeZoneInfo.ConvertTime(onSaleDate, Station.StationTimeZoneInfo, TimeZoneInfo.Local); int lowStockAmount = 0; try { lowStockAmount = Int32.Parse(lowStockAmountBox.Text); } catch { ErrorMessage = "Low Stock Amount must be an integer"; return; } if (lowStockAmount < 0) { ErrorMessage = "Low Stock Amount must be greater than or equal to 0"; return; } int numberLength = Convert.ToInt32(numberLengthList.SelectedValue); int deliveryTypeId = Convert.ToInt32(deliveryList.SelectedValue); string deliveryNote = deliveryNoteBox.Text.Trim(); if (deliveryNote.Length > 500) { deliveryNote = deliveryNote.Substring(0, 500); } bool isActive = isActiveBox.Checked; CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); if (idHidden.Value != String.Empty) { certificateId = Int32.Parse(idHidden.Value); certificate = certificateAdapter.GetCertificate(certificateId)[0]; certificate.ShortName = shortName; certificate.Description = description; certificate.MinPurchaseQty = minPurchaseQty; certificate.MaxPurchaseQty = maxPurchaseQty; certificate.FaceValue = faceValue; certificate.Discount = discount; certificate.DiscountTypeId = discountTypeId; certificate.OnSaleDate = onSaleDate; certificate.LowStockAmount = lowStockAmount; certificate.NumberLength = numberLength; certificate.DeliveryTypeId = deliveryTypeId; certificate.DeliveryNote = deliveryNote; certificate.IsActive = isActive; certificateAdapter.Update(certificate); CertificateNumberTableAdapter certificateNumberAdapter = new CertificateNumberTableAdapter(); InfoMessage = "Certificate updated"; } else { int quantity = 0; try { quantity = Int32.Parse(qtyBox.Text.Trim()); } catch { ErrorMessage = "Quantity must be an integer"; return; } if (quantity <= 0) { ErrorMessage = "Quantity must be a postive"; return; } certificateId = Convert.ToInt32(certificateAdapter.InsertPK(advertiserId, shortName, description, minPurchaseQty, maxPurchaseQty, faceValue, discount, discountTypeId, deliveryTypeId, deliveryNote, isActive, onSaleDate, lowStockAmount, numberLength)); CertificateNumberTableAdapter certificateNumberAdapter = new CertificateNumberTableAdapter(); certificateNumberAdapter.Generate(certificateId, quantity); InfoMessage = "Certificate created"; } Response.Redirect("~/admin/AdvertiserEdit.aspx?id=" + advertiserId); } }
protected void Page_Load(object sender, EventArgs e) { saveButton.Click += new EventHandler(saveButton_Click); cancelButton.Click += new EventHandler(cancelButton_Click); deleteButton.Click += new EventHandler(deleteButton_Click); deleteButton.Attributes["onclick"] = "javascript: return confirm('Are you sure want to delete this item?');"; emailButton.Click += new EventHandler(emailButton_Click); addNumbersButton.Click += new EventHandler(addNumbersButton_Click); removeNumbersButton.Click += new EventHandler(removeNumbersButton_Click); createHistoryRepeater.ItemDataBound += new RepeaterItemEventHandler(createHistoryRepeater_ItemDataBound); availableNumberGrid.RowDataBound += new GridViewRowEventHandler(availableNumberGrid_RowDataBound); certificateId = GetIdFromQueryString(); int advertiserId = 0; CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); if (certificateId > 0) { DollarSaverDB.CertificateDataTable certificateTable = certificateAdapter.GetCertificate(certificateId); if (certificateTable.Count != 1) { Response.Redirect("~/admin/AdvertiserList.aspx"); } certificate = certificateTable[0]; advertiserId = certificate.AdvertiserId; } else { advertiserId = GetValueFromQueryString("advertiserId"); } if (!Page.IsPostBack) { if (Station.StationSiteType == SiteType.DealOfTheWeek) { standardDateHolder.Visible = false; onSaleDateBoxRFV.Enabled = false; onSaleDateList.Visible = true; ArrayList onSaleDates = new ArrayList(); onSaleDates = certificateAdapter.GetDealDates(StationId); onSaleDateList.DataSource = onSaleDates; onSaleDateList.DataTextFormatString = "{0:MM/dd/yyyy hh:mm:ss tt}"; onSaleDateList.DataBind(); DateTime onSaleNow = TimeZoneInfo.ConvertTime(DateTime.Now, TimeZoneInfo.Local, Station.StationTimeZoneInfo); onSaleNow = onSaleNow.AddDays(-14); onSaleDateList.Items.Add(new ListItem("-- On Sale Now --", onSaleNow.ToString("MM/dd/yyyy hh:mm:ss tt"))); } else { standardDateHolder.Visible = true; onSaleDateBoxRFV.Enabled = true; onSaleDateList.Visible = false; for (int i = 0; i <= 23; i++) { String hour; if (i % 12 == 0) { hour = "12"; } else { hour = (i % 12).ToString("00"); } onSaleHourList.Items.Add(new ListItem(hour + " " + (i < 12 ? "AM" : "PM"), i.ToString("00"))); } for (int i = 0; i <= 59; i++) { onSaleMinuteList.Items.Add(new ListItem(i.ToString("00"), i.ToString("00"))); } } AdvertiserTableAdapter advertiserAdapter = new AdvertiserTableAdapter(); DollarSaverDB.AdvertiserDataTable advertiserTable = advertiserAdapter.GetAdvertiser(advertiserId); if (advertiserTable.Count != 1) { Response.Redirect("~/admin/AdvertiserList.aspx"); } DollarSaverDB.AdvertiserRow advertiser = advertiserTable[0]; if (advertiser.StationId != StationId) { Response.Redirect("~/admin/AdvertiserList.aspx"); } if (advertiser.IsDeleted) { InfoMessage = "Sorry, this advertiser has been deleted"; Response.Redirect("~/admin/AdvertiserList.aspx"); } discountList.Items.Add(new ListItem("Percentage", "1")); discountList.Items.Add(new ListItem("Flat Amount", "2")); advertiserNameLabel.Text = advertiser.Name; advertiserIdHidden.Value = advertiserId.ToString(); if (certificateId > 0) { createEditLabel.Text = "Edit"; newCertHolder.Visible = false; idHidden.Value = certificateId.ToString(); nameBox.Text = certificate.ShortName; descriptionLengthLabel.Text = certificate.Description.Length.ToString(); descriptionBox.Text = certificate.Description; minPurchaseQtyBox.Text = certificate.MinPurchaseQty.ToString(); maxPurchaseQtyBox.Text = certificate.MaxPurchaseQty.ToString(); faceValueBox.Text = certificate.FaceValue.ToString("0.00"); discountBox.Text = certificate.Discount.ToString("0.00"); discountList.SelectedValue = certificate.DiscountTypeId.ToString(); if (CurrentUser.Role == AdminRole.Manager || CurrentUser.Role == AdminRole.SalesRep) { faceValueBox.Enabled = false; discountBox.Enabled = false; discountList.Enabled = false; } deliveryList.SelectedValue = certificate.DeliveryTypeId.ToString(); deliveryNoteBox.Text = certificate.DeliveryNote; isActiveBox.Checked = certificate.IsActive; lowStockAmountBox.Text = certificate.LowStockAmount.ToString(); if (numberLengthList.Items.FindByValue(certificate.NumberLength.ToString()) != null) { numberLengthList.SelectedValue = certificate.NumberLength.ToString(); } if (Station.StationSiteType == SiteType.DealOfTheWeek) { ListItem dateItem = onSaleDateList.Items.FindByText(certificate.AdjustedOnSaleDate.ToString("MM/dd/yyyy hh:mm:ss tt}")); if (dateItem != null) { onSaleDateList.SelectedIndex = onSaleDateList.Items.IndexOf(dateItem); } else { onSaleDateList.Items.Insert(0, new ListItem(certificate.AdjustedOnSaleDate.ToString("MM/dd/yyyy hh:mm:ss tt"), certificate.AdjustedOnSaleDate.ToString("M/d/yyyy h:mm:ss tt"))); } } else { onSaleDateBox.Text = certificate.AdjustedOnSaleDate.ToString("MM/dd/yyyy"); onSaleHourList.SelectedValue = certificate.AdjustedOnSaleDate.Hour.ToString("00"); onSaleMinuteList.SelectedValue = certificate.AdjustedOnSaleDate.Minute.ToString("00"); } CertificateNumberTableAdapter certificateNumberAdapter = new CertificateNumberTableAdapter(); ArrayList createDates = certificateNumberAdapter.GetDates(certificateId); createDateList.DataSource = createDates; createDateList.DataTextFormatString = "{0:MM/dd/yyyy}"; createDateList.DataBind(); createDateList.Items.Insert(0, new ListItem("-- All Dates --", "")); certificateNumberHolder.Visible = true; createHistoryRepeater.DataSource = createDates; createHistoryRepeater.DataBind(); if (certificate.DeliveryType == DeliveryType.Print) { printableHolder.Visible = true; notPrintableHolder.Visible = false; String queryString = "sample_id=" + certificate.CertificateId; String encryptedString = Server.UrlEncode(Cipher.Encrypt(queryString)); viewSampleLink.NavigateUrl = "~/ViewCertificate.aspx?x=" + encryptedString; BindNumbers(); } else { printableHolder.Visible = false; notPrintableHolder.Visible = true; availableCountLabel.Text = certificate.AvailableNumbers.Count.ToString(); usedCountLabel.Text = certificate.UsedNumbers.Count.ToString(); } } else { deleteButton.Visible = false; saveButton.Text = "Create"; createEditLabel.Text = "Create"; certificateNumberHolder.Visible = false; newCertHolder.Visible = true; onSaleDateBox.Text = DateTime.Now.ToString("MM/dd/yyyy"); } } }
private void LoadCertificateNumber() { CertificateNumberTableAdapter certificateNumberAdapter = new CertificateNumberTableAdapter(); int id = 0; int orderId = 0; int sampleId = 0; String cipherText = Request.QueryString["x"]; if (cipherText != null && cipherText != String.Empty) { try { String plainText = Server.UrlDecode(Cipher.Decrypt(cipherText)); String[] keysAndValues = plainText.Split('&'); foreach (String keyAndValueStr in keysAndValues) { String[] keyAndValue = keyAndValueStr.Split('='); if (keyAndValue.Length == 2) { if (keyAndValue[0] == "id") { try { id = Convert.ToInt32(keyAndValue[1]); } catch { } } else if (keyAndValue[0] == "order_id") { try { orderId = Convert.ToInt32(keyAndValue[1]); } catch { } } else if (keyAndValue[0] == "sample_id") { try { sampleId = Convert.ToInt32(keyAndValue[1]); } catch { } } } } } catch { } } if (sampleId == 0) { if (id == 0 || orderId == 0) { // check for old parameters for backward compatibility // viewcertificate?orderNum=13651&certNum=755426&backBtn=no orderId = GetValueFromQueryString("orderNum"); id = 0; // cut off backward compatibility after certain order id if (orderId < 17000) { String number = Convert.ToString(Request.QueryString["certNum"]); if (orderId == 0 || number == String.Empty) { return; } DollarSaverDB.CertificateNumberDataTable numberSearch = certificateNumberAdapter.GetBackward(orderId, number); if (numberSearch.Count == 1) { id = numberSearch[0].CertificateNumberId; } else { return; } } } DollarSaverDB.CertificateNumberDataTable certNumberTable = certificateNumberAdapter.GetCertificateNumber(id); if (certNumberTable.Count != 1) { return; } DollarSaverDB.CertificateNumberRow checkCertNumber = certNumberTable[0]; OrderTableAdapter orderAdapter = new OrderTableAdapter(); DollarSaverDB.OrderDataTable orderTable = orderAdapter.GetOrder(orderId); if (orderTable.Count != 1) { return; } DollarSaverDB.OrderRow order = orderTable[0]; if (order.OrderStatusId != (int)OrderStatus.Complete) { return; } if (checkCertNumber.IsOrderLineItemIdNull() || !order.LineItems.Contains(checkCertNumber.OrderLineItemId)) { return; } certNumber = checkCertNumber; certificate = certNumber.Certificate; } else { CertificateTableAdapter certAdapter = new CertificateTableAdapter(); DollarSaverDB.CertificateDataTable certificateTable = certAdapter.GetCertificate(sampleId); if (certificateTable.Count != 1) { return; } certificate = certificateTable[0]; } }
protected void Page_Load(object sender, EventArgs e) { lineItemRepeater.ItemDataBound += new RepeaterItemEventHandler(lineItemRepeater_ItemDataBound); lineItemRepeater.ItemCommand += new RepeaterCommandEventHandler(lineItemRepeater_ItemCommand); updateButton.Click += new EventHandler(updateButton_Click); continueButton.Click += new EventHandler(continueButton_Click); /* * if (Order != null && * (Order.OrderStatusId != 1 || Order.StationId != StationId)) { * Order = null; * Response.Redirect("~/Cart.aspx"); * }*/ if (displayCookieMessage) { itemHolder.Visible = false; emptyCartHolder.Visible = false; cookieMessageHolder.Visible = true; homeLink.NavigateUrl += "?station_id=" + StationId; return; } else { cookieMessageHolder.Visible = false; } if (!Page.IsPostBack) { OrderTableAdapter orderAdapter = new OrderTableAdapter(); int certificateId = GetCertificateIdFromQueryString(); if ((Order == null && certificateId > 0) || (Order != null && Order.OrderStatusId != 1) || (Order != null && Order.StationId != StationId)) { Order = GenerateOrder(); } if (certificateId > 0) { CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); DollarSaverDB.CertificateDataTable certificateTable = certificateAdapter.GetCertificate(certificateId); if (certificateTable.Count != 1) { Response.Redirect("~/Cart.aspx"); } DollarSaverDB.CertificateRow certificate = certificateTable[0]; if (certificate.Advertiser.StationId != StationId) { Response.Redirect("~/Cart.aspx"); } if (!certificate.IsActive || !certificate.Advertiser.IsActive) { InfoMessage = "Sorry, this certificate is no longer available"; Response.Redirect("~/Cart.aspx"); } if (certificate.OnSaleDate > DateTime.Now) { InfoMessage = "Sorry, this certificate is not yet available"; Response.Redirect("~/Cart.aspx"); } int quantity = GetValueFromQueryString("qty"); if (quantity == 0) { quantity = 1; } OrderLineItemTableAdapter orderLineItemAdapter = new OrderLineItemTableAdapter(); DollarSaverDB.OrderLineItemRow lineItem = Order.LineItems.GetLineItem(certificateId); if (lineItem == null) { quantity = CheckQuantity(quantity, certificate); if (quantity > 0) { Order.LineItems.AddOrderLineItemRow(Order.OrderId, -1, quantity, certificate.CertificateId, certificate.ShortName, certificate.Description, certificate.FaceValue, certificate.Discount, certificate.DiscountTypeId, false, certificate.DeliveryTypeId, certificate.DeliveryNote); orderLineItemAdapter.Update(Order.LineItems); } } else { quantity += lineItem.Quantity; quantity = CheckQuantity(quantity, certificate); if (quantity == 0) { orderLineItemAdapter.Delete(lineItem.OrderLineItemId); } else { lineItem.Quantity = quantity; orderLineItemAdapter.Update(lineItem); } } UpdateLineItemModifiedDate(); if (InfoMessage == String.Empty) { InfoMessage = "Certificate(s) added to your cart"; } // reload the cart Response.Redirect("~/Cart.aspx"); } if (Order != null && Order.LineItems.Count > 0) { itemHolder.Visible = true; emptyCartHolder.Visible = false; lineItemRepeater.DataSource = Order.LineItems.Rows; lineItemRepeater.DataBind(); subTotalLabel.Text = Order.LineItems.SubTotal.ToString("$#,0.00"); continueShoppingLink.NavigateUrl = "~/Default.aspx?station_id=" + StationId; } else { itemHolder.Visible = false; emptyCartHolder.Visible = true; } } else { // if page is postback, make sure the order is still in the session if (Order == null) { InfoMessage = "Sorry, your session has timed out"; Response.Redirect("~/Cart.aspx"); } } }
void placeOrderButton_Click(object sender, EventArgs e) { // Validate fields /* * string patternLenient = @"\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"; * * string patternStrict = @"^(([^<>()[\]\\.,;:\s@\""]+" + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@" + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}" + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+" + @"[a-zA-Z]{2,}))$"; + */ String creditCardType = creditCardList.SelectedValue; String creditCardNumber = creditCardNumberBox.Text.Trim(); creditCardNumber = Regex.Replace(creditCardNumber, @"\D", ""); String verificationNumber = verificationNumberBox.Text.Trim(); String firstName = firstNameBox.Text.Trim(); String lastName = lastNameBox.Text.Trim(); String address1 = address1Box.Text.Trim(); String address2 = address2Box.Text.Trim(); String city = cityBox.Text.Trim(); String stateCode = stateList.SelectedValue; String zipCode = zipCodeBox.Text.Trim(); String phoneNumber = phoneNumberBox.Text.Trim(); if (firstName == String.Empty) { ErrorMessage = "First Name is required"; return; } if (lastName == String.Empty) { ErrorMessage = "Last Name is required"; return; } if (address1 == String.Empty) { ErrorMessage = "Address is required"; return; } if (city == String.Empty) { ErrorMessage = "City is required"; return; } if (stateCode == String.Empty) { ErrorMessage = "State is required"; return; } if (zipCode == String.Empty) { ErrorMessage = "Zip Code is required"; return; } if (phoneNumber == String.Empty) { ErrorMessage = "Phone Number is required"; return; } if (phoneNumber.Length < 10) { ErrorMessage = "Phone Number must include area code plus 7 digit phone number"; return; } if (DsCookie["_c"] == "1") { DsCookie["_c_ba"] = Cipher.Encrypt2(firstName); DsCookie["_c_bb"] = Cipher.Encrypt2(lastName); DsCookie["_c_bc"] = Cipher.Encrypt2(address1); DsCookie["_c_bd"] = Cipher.Encrypt2(address2); DsCookie["_c_be"] = Cipher.Encrypt2(city); DsCookie["_c_bf"] = Cipher.Encrypt2(stateCode); DsCookie["_c_bg"] = Cipher.Encrypt2(zipCode); DsCookie["_c_bh"] = Cipher.Encrypt2(phoneNumber); } if (creditCardNumber == String.Empty) { ErrorMessage = "Credit Card Number is required"; return; } if (verificationNumber == String.Empty) { ErrorMessage = "Card Verification Number is required"; return; } OrderTableAdapter orderAdapter = new OrderTableAdapter(); CertificateNumberTableAdapter numberAdapter = new CertificateNumberTableAdapter(); OrderLineItemTableAdapter orderLineItemAdapter = new OrderLineItemTableAdapter(); decimal subtotal = 0.0m; foreach (DollarSaverDB.OrderLineItemRow lineItem in Order.LineItems) { int numberAssigned = Convert.ToInt32(numberAdapter.Assign(lineItem.OrderLineItemId)); if (numberAssigned != lineItem.Quantity) { if (numberAssigned == 0) { ErrorMessage = "We're sorry, " + lineItem.Certificate.AdvertiserName + " is no longer available"; orderLineItemAdapter.Delete(lineItem.OrderLineItemId); } else { lineItem.Quantity = numberAssigned; orderLineItemAdapter.Update(lineItem); ErrorMessage = "We're sorry, " + lineItem.Certificate.AdvertiserName + " is no longer available in the quantity you requested. Please review your updated order and click on the checkout button if you would like to purchase the new quantity"; } Order.LineItemModifiedDate = DateTime.Now; orderAdapter.Update(Order); ResetOrder(); Response.Redirect("~/Cart.aspx"); } subtotal += lineItem.Total; } switch (creditCardType) { case "Visa": Order.PaymentMethodId = (int)PaymentMethod.Visa; break; case "MasterCard": Order.PaymentMethodId = (int)PaymentMethod.MasterCard; break; case "Discover": Order.PaymentMethodId = (int)PaymentMethod.Discover; break; case "Amex": Order.PaymentMethodId = (int)PaymentMethod.Amex; break; default: break; } Order.SubTotal = subtotal; Order.GrandTotal = subtotal; Order.BillingFirstName = firstName; Order.BillingLastName = lastName; Order.BillingAddress1 = address1; if (address2 != String.Empty) { Order.BillingAddress2 = address2; } else { Order.SetBillingAddress2Null(); } Order.BillingCity = city; Order.BillingStateCode = stateCode; Order.BillingZipCode = zipCode; Order.BillingPhone = phoneNumber; orderAdapter.Update(Order); // Check max purchase qty for Deal of the Week if (Station.StationSiteType == SiteType.DealOfTheWeek) { CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); DollarSaverDB.CertificateDataTable certificateTable = certificateAdapter.GetCurrentDeal(StationId); if (certificateTable.Count == 1) { DollarSaverDB.CertificateRow deal = certificateTable[0]; if (deal.MaxPurchaseQty > 0) { foreach (DollarSaverDB.OrderLineItemRow lineItem in Order.LineItems) { if (lineItem.CertificateId == deal.CertificateId) { int pastQty = Convert.ToInt32(orderLineItemAdapter.GetQtyByConsumer(firstName, lastName, null, address1, city, stateCode, Order.ShippingEmail, deal.CertificateId)); if (pastQty + lineItem.Quantity > deal.MaxPurchaseQty) { ErrorMessage = "Sorry, the maximum purchase quantity per person for the Deal of the Week is " + deal.MaxPurchaseQty + "."; if (pastQty >= deal.MaxPurchaseQty) { ErrorMessage += "<BR>You have already purchased the maximum allowed."; } else { int allowedAmount = deal.MaxPurchaseQty - pastQty; ErrorMessage += "<BR>You may only purchase " + allowedAmount + " more."; } ResetOrder(); Response.Redirect("~/Cart.aspx"); } } } } } } if (Order.CheckoutStartDate < Order.LineItemModifiedDate) { ResetOrder(); ErrorMessage = "Your cart has been updated while checking out, please verify you items and continue the checkout process."; Response.Redirect("~/Cart.aspx"); } Order.OrderStatusId = (int)OrderStatus.Processing; orderAdapter.Update(Order); // charge order... NVPCallerServices caller = PayPalAPI.PayPalAPIInitialize(IsDev); NVPCodec encoder = new NVPCodec(); encoder["VERSION"] = "50.0"; encoder["METHOD"] = "DoDirectPayment"; encoder["PAYMENTACTION"] = "Sale"; encoder["AMT"] = subtotal.ToString("0.00"); encoder["CREDITCARDTYPE"] = creditCardType; encoder["ACCT"] = creditCardNumber; encoder["EXPDATE"] = expirationMonthList.SelectedValue + expirationYearList.SelectedValue; encoder["CVV2"] = verificationNumber; encoder["FIRSTNAME"] = firstName; encoder["LASTNAME"] = lastName; encoder["STREET"] = address1; encoder["CITY"] = city; encoder["STATE"] = stateCode; encoder["ZIP"] = zipCode; encoder["COUNTRYCODE"] = "US"; encoder["CURRENCYCODE"] = "USD"; /* * encoder["INVNUM"] = Order.OrderId.ToString(); * encoder["ITEMAMT"] = Order.LineItems.SubTotal.ToString("0.00"); * foreach (DollarSaverDB.OrderLineItemRow lineItem in Order.LineItems.Rows) { * int itemNumber = lineItem.SeqNo - 1; * * encoder["L_NAME" + itemNumber] = lineItem.ShortName; * encoder["L_NUMBER" + itemNumber] = lineItem.CertificateId.ToString(); * encoder["L_QTY" + itemNumber] = lineItem.Quantity.ToString(); * encoder["L_AMT" + itemNumber] = lineItem.DiscountValue.ToString("0.00"); * } */ string paypalRequest = encoder.Encode(); string paypalResponse = String.Empty; try { paypalResponse = caller.Call(paypalRequest); } catch { ResetOrder(); ErrorMessage = "An error occurred while processing your order, please try submitting it again."; return; } NVPCodec decoder = new NVPCodec(); decoder.Decode(paypalResponse); string strAck = decoder["ACK"]; if (strAck != null && (strAck == "Success" || strAck == "SuccessWithWarning")) { string transactionId = decoder["TRANSACTIONID"]; Order.TransactionId = transactionId; Order.OrderDate = DateTime.Now; Order.OrderStatusId = (int)OrderStatus.Complete; orderAdapter.Update(Order); InfoMessage = "Successfully processed order"; if (SendReceipt()) { InfoMessage += "<BR />Receipt sent to " + Order.ShippingEmail; } if (Order.AddToMailingList) { CustomerContactTableAdapter customerContactAdapter = new CustomerContactTableAdapter(); customerContactAdapter.Insert(StationId, DateTime.Now, Order.ShippingEmail, Order.BillingFirstName, Order.BillingLastName); } Response.Redirect("~/Confirmation.aspx", true); return; } else { ResetOrder(); ErrorMessage = "Error! " + decoder["L_LONGMESSAGE0"] + " (" + decoder["L_ERRORCODE0"] + ")"; return; } }
protected void Page_Load(object sender, EventArgs e) { saveButton.Click += new EventHandler(saveButton_Click); cancelButton.Click += new EventHandler(cancelButton_Click); if (Station.SiteTypeId != (int)SiteType.Standard) { Response.Redirect("~/admin/Default.aspx"); } specialTable = specialAdapter.GetStationSpecial(StationId, 1); if (specialTable.Count == 1) { specialOne = specialTable[0]; } specialTable = specialAdapter.GetStationSpecial(StationId, 2); if (specialTable.Count == 1) { specialTwo = specialTable[0]; } specialTable = specialAdapter.GetStationSpecial(StationId, 3); if (specialTable.Count == 1) { specialThree = specialTable[0]; } specialTable = specialAdapter.GetStationSpecial(StationId, 4); if (specialTable.Count == 1) { specialFour = specialTable[0]; } if (!Page.IsPostBack) { CategoryTableAdapter categoryAdapter = new CategoryTableAdapter(); DollarSaverDB.CategoryDataTable categories = categoryAdapter.GetPrimaryCategoriesByStation(StationId); CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); DollarSaverDB.CertificateDataTable certificates = certificateAdapter.GetActive(StationId); //certificates.DefaultView.Sort SpecialSettingsTableAdapter specialSettingsAdapter = new SpecialSettingsTableAdapter(); DollarSaverDB.SpecialSettingsDataTable specialSettingsTable = specialSettingsAdapter.GetSpecialSettings(StationId); if (specialSettingsTable.Count == 1) { if (specialSettingsTable[0].DailyHeader) { dailyWeeklyList.SelectedValue = "1"; } else { dailyWeeklyList.SelectedValue = "2"; } } // Daily/Weekly Special 1 /* * specialOneCategoryList.DataSource = categories; * specialOneCategoryList.DataTextField = "Name"; * specialOneCategoryList.DataValueField = "CategoryId"; * specialOneCategoryList.DataBind(); */ specialOneCertificateList.DataSource = certificates.Rows; specialOneCertificateList.DataTextField = "AdvertiserAndCertificate"; specialOneCertificateList.DataValueField = "CertificateId"; specialOneCertificateList.DataBind(); if (specialOne != null) { if (!specialOne.IsCertificateIdNull()) { //specialOneCertificateBox.Checked = true; if (certificates.FindByCertificateId(specialOne.CertificateId) != null) { specialOneCertificateList.SelectedValue = specialOne.CertificateId.ToString(); } } /* * else if (!specialOne.IsCategoryIdNull()) { * specialOneCategoryBox.Checked = true; * * specialOneCategoryList.SelectedValue = specialOne.CategoryId.ToString(); * } else { * specialOneRandomBox.Checked = true; * } */ } // Special 2 specialTwoCategoryList.DataSource = categories; specialTwoCategoryList.DataTextField = "Name"; specialTwoCategoryList.DataValueField = "CategoryId"; specialTwoCategoryList.DataBind(); specialTwoCertificateList.DataSource = certificates.Rows; specialTwoCertificateList.DataTextField = "AdvertiserAndCertificate"; specialTwoCertificateList.DataValueField = "CertificateId"; specialTwoCertificateList.DataBind(); if (specialTwo != null) { if (!specialTwo.IsCertificateIdNull()) { specialTwoCertificateBox.Checked = true; if (certificates.FindByCertificateId(specialTwo.CertificateId) != null) { specialTwoCertificateList.SelectedValue = specialTwo.CertificateId.ToString(); } } else if (!specialTwo.IsCategoryIdNull()) { specialTwoCategoryBox.Checked = true; specialTwoCategoryList.SelectedValue = specialTwo.CategoryId.ToString(); } else { specialTwoRandomBox.Checked = true; } } // Special 3 specialThreeCategoryList.DataSource = categories; specialThreeCategoryList.DataTextField = "Name"; specialThreeCategoryList.DataValueField = "CategoryId"; specialThreeCategoryList.DataBind(); specialThreeCertificateList.DataSource = certificates.Rows; specialThreeCertificateList.DataTextField = "AdvertiserAndCertificate"; specialThreeCertificateList.DataValueField = "CertificateId"; specialThreeCertificateList.DataBind(); if (specialThree != null) { if (!specialThree.IsCertificateIdNull()) { specialThreeCertificateBox.Checked = true; if (certificates.FindByCertificateId(specialThree.CertificateId) != null) { specialThreeCertificateList.SelectedValue = specialThree.CertificateId.ToString(); } } else if (!specialThree.IsCategoryIdNull()) { specialThreeCategoryBox.Checked = true; specialThreeCategoryList.SelectedValue = specialThree.CategoryId.ToString(); } else { specialThreeRandomBox.Checked = true; } } // Special 4 specialFourCategoryList.DataSource = categories; specialFourCategoryList.DataTextField = "Name"; specialFourCategoryList.DataValueField = "CategoryId"; specialFourCategoryList.DataBind(); specialFourCertificateList.DataSource = certificates.Rows; specialFourCertificateList.DataTextField = "AdvertiserAndCertificate"; specialFourCertificateList.DataValueField = "CertificateId"; specialFourCertificateList.DataBind(); if (specialFour != null) { if (!specialFour.IsCertificateIdNull()) { specialFourCertificateBox.Checked = true; if (certificates.FindByCertificateId(specialFour.CertificateId) != null) { specialFourCertificateList.SelectedValue = specialFour.CertificateId.ToString(); } } else if (!specialFour.IsCategoryIdNull()) { specialFourCategoryBox.Checked = true; specialFourCategoryList.SelectedValue = specialFour.CategoryId.ToString(); } else { specialFourRandomBox.Checked = true; } } } }
protected void Page_Load(object sender, EventArgs e) { recentDealsRepeater.ItemDataBound += new RepeaterItemEventHandler(recentDealsRepeater_ItemDataBound); if (!Page.IsPostBack) { StationPageBase parent = (StationPageBase)this.Parent; int stationId = parent.StationId; headerLink.NavigateUrl = parent.GetUrl("~/Default.aspx"); DollarSaverDB.StationRow station = parent.Station; //stationNameLabel.Text = station.Name; content1Label.Text = station.Content1; content2Label.Text = station.Content2; if (!station.IsStationUrlNull()) { stationUrlHolder.Visible = true; stationLink.Text = "Return to " + station.Name; stationLink.NavigateUrl = station.StationUrl; } else { stationUrlHolder.Visible = false; } if (File.Exists(Request.PhysicalApplicationPath + station.StationDirUrl + "station.css")) { stationStyleSheet.Href = station.StationDirUrl + "station.css"; } else { stationStyleSheet.Href = "~/styles/station.css"; } String ImageDir = Request.PhysicalApplicationPath + station.ImageDirUrl; if (!station.Content.IsTopperImageNull() && File.Exists(ImageDir + station.Content.TopperImage)) { topperImage.ImageUrl = station.ImageDirUrl + station.Content.TopperImage; } if (!station.Content.IsTopperImageNull() && File.Exists(ImageDir + station.Content.TopperImage)) { topperImagem.ImageUrl = "~/" + station.ImageDirUrl + station.Content.TopperImage; } if (!station.Content.IsLocalSavingsImageNull() && File.Exists(ImageDir + station.Content.LocalSavingsImage)) { localSavingsImagem.ImageUrl = "~/" + station.ImageDirUrl + station.Content.LocalSavingsImage; } if (!station.Content.IsLocalSavingsImageNull() && File.Exists(ImageDir + station.Content.LocalSavingsImage)) { localSavingsImage.ImageUrl = station.ImageDirUrl + station.Content.LocalSavingsImage; } if (!station.Content.IsHeaderImageNull() && File.Exists(ImageDir + station.Content.HeaderImage)) { headerImage.ImageUrl = station.ImageDirUrl + station.Content.HeaderImage; } if (!station.Content.IsLogoImageNull() && File.Exists(ImageDir + station.Content.LogoImage)) { logoImage.ImageUrl = station.ImageDirUrl + station.Content.LogoImage; } if (File.Exists(Request.PhysicalApplicationPath + station.StationDirUrl + "end_include.html")) { endIncludeLiteral.Text = File.ReadAllText(Request.PhysicalApplicationPath + station.StationDirUrl + "end_include.html"); } signUpTopLink.NavigateUrl = parent.GetUrl(signUpTopLink.NavigateUrl); signUpBottomLink.NavigateUrl = parent.GetUrl(signUpBottomLink.NavigateUrl); cartLink.NavigateUrl = parent.GetUrl(cartLink.NavigateUrl); contactLink.NavigateUrl = parent.GetUrl(contactLink.NavigateUrl); privacyLink.NavigateUrl = parent.GetUrl(privacyLink.NavigateUrl); termsLink.NavigateUrl = parent.GetUrl(termsLink.NavigateUrl); faqLink.NavigateUrl = parent.GetUrl(faqLink.NavigateUrl); rssLink.NavigateUrl = parent.GetUrl(rssLink.NavigateUrl); CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); DollarSaverDB.CertificateDataTable onSaleDeals = certificateAdapter.GetOnSale(station.StationId); var latestDeals = (from DollarSaverDB.CertificateRow cert in onSaleDeals orderby cert.OnSaleDate descending select cert).Take(10); if (latestDeals.Count() > 0) { recentDealsHolder.Visible = true; recentDealsRepeater.DataSource = latestDeals; recentDealsRepeater.DataBind(); } else { recentDealsHolder.Visible = false; } } }
private void GenerateFeed() { CertificateTableAdapter certificateAdapter = new CertificateTableAdapter(); String description = ""; String siteUrl = "http://" + EnvDomain; String homePageUrl = siteUrl + ResolveUrl("~/Default.aspx") + "?station_id=" + StationId; //mainFeed.Title = TextSyndicationContent.CreatePlaintextContent(Station.SiteNamePlainText); //mainFeed.Links.Add(SyndicationLink.CreateSelfLink(new Uri(homePageUrl))); List <DollarSaverDB.CertificateRow> listCertificates = new List <DollarSaverDB.CertificateRow>(); if (Station.StationSiteType == SiteType.Standard) { SpecialSettingsTableAdapter specialSettingsAdapter = new SpecialSettingsTableAdapter(); DollarSaverDB.SpecialSettingsDataTable specialSettingsTable = specialSettingsAdapter.GetSpecialSettings(StationId); bool dailyHeader = false; if (specialSettingsTable.Count == 1) { dailyHeader = specialSettingsTable[0].DailyHeader; } if (dailyHeader) { description = "Daily Deal"; } else { description = "Weekly Deal"; } DollarSaverDB.CertificateDataTable daily = certificateAdapter.GetSpecial(StationId, 1); if (daily.Count == 1) { listCertificates.Add(daily[0]); } } else { description = "Deal of the Week"; DollarSaverDB.CertificateDataTable certificateTable = certificateAdapter.GetCurrentDeal(StationId); if (certificateTable.Count == 1) { listCertificates.Add(certificateTable[0]); } } List <SyndicationItem> items = new List <SyndicationItem>(); foreach (DollarSaverDB.CertificateRow certificate in listCertificates) { SyndicationItem item = new SyndicationItem(); item.Title = TextSyndicationContent.CreatePlaintextContent(certificate.AdvertiserName); String advertiserUrl = siteUrl + ResolveUrl("~/Advertiser.aspx?advertiser_id=" + certificate.AdvertiserId); item.Links.Add(SyndicationLink.CreateAlternateLink(new Uri(advertiserUrl))); StringBuilder content = new StringBuilder(); if (certificate.Advertiser.LogoUrl != String.Empty) { String logoUrl = siteUrl + ResolveUrl(certificate.Advertiser.LogoUrl); int logoWidth = 125; int logoHeight = 75; if (certificate.Advertiser.IsLogoImageVertical) { logoWidth = 75; logoHeight = 125; } content.Append("<div>"); content.Append("<a href=\"" + advertiserUrl + "\">"); content.Append("<img src=\"" + logoUrl + "\" alt=\"" + Server.HtmlEncode(certificate.AdvertiserName) + "\" style=\"border-color:#404040;border-width:1px;border-style:solid;height:" + logoHeight + "px;width:" + logoWidth + "px;\">"); content.Append("</a>"); content.Append("</div>"); } content.Append("<div style=\"font-family: Arial;\">"); //content.Append("<a href=\"" + advertiserUrl + "\" style=\"font-weight: bold; font-size: 1.3em; line-height: 1.7em;\">" + Server.HtmlEncode(certificate.AdvertiserName) + "</a>"); content.Append("<p>"); content.Append(certificate.Advertiser.Description); content.Append("</p>"); content.Append("<a href=\"" + advertiserUrl + "\" style=\"font-weight: bold; font-size: 1.1em; line-height: 1.5em;\">" + Server.HtmlEncode(certificate.ShortName) + "<a>"); content.Append("<p> "); content.Append(certificate.Description); content.Append("</p>"); content.Append("<p style=\"font-weight: bold;\"> "); content.Append("Certificate Value: " + certificate.FaceValue.ToString("$0.00") + "<br />"); content.Append("Price: <span style=\"color: red;\">" + certificate.DiscountValue.ToString("$0.00") + "</span><br />"); content.Append("Your Savings: " + certificate.Savings + "<br />"); content.Append("</p>"); content.Append("<a href=\"" + advertiserUrl + "\" style=\"font-weight: bold; font-size: 1.1em; line-height: 1.5em;\">BUY NOW</a>"); content.Append("</div>"); content.Append("<div style=\"clear: both;\"></div>"); item.Content = SyndicationContent.CreateHtmlContent(content.ToString()); items.Add(item); } SyndicationFeed mainFeed = new SyndicationFeed(Station.SiteNamePlainText, description, new Uri(homePageUrl)); mainFeed.Description = TextSyndicationContent.CreatePlaintextContent(description); mainFeed.Items = items; Response.ContentType = "application/rss+xml"; using (XmlWriter xmlWriter = XmlWriter.Create(Response.OutputStream)) { Rss20FeedFormatter rssFeed = new Rss20FeedFormatter(mainFeed); rssFeed.WriteTo(xmlWriter); } }