protected void Page_Load(object sender, EventArgs e) { UserPageBase pageBase = (UserPageBase)Page; Collective.User user = pageBase.GetLoggedCollectiveUser(); if(user == null) Response.Redirect(Page.ResolveUrl("~/default.aspx")); int coupId; if(Int32.TryParse(Request.QueryString["coupid"], out coupId)) { _coup = Collective.Coupon.GetCouponForClient(coupId, PutovalicaUtil.GetLanguageId()); if(user.Id != _coup.UserId) Response.Redirect(Page.ResolveUrl("~/default.aspx")); _offer = Collective.Offer.GetOffer(_coup.CollectiveOfferId, PutovalicaUtil.GetLanguageId()); if (_offer.AgencyId.HasValue) { _agency = Collective.Agency.GetAgency(_offer.AgencyId.Value); } phAgency.Visible = _agency != null; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { UserPageBase pageBase = (UserPageBase)Page; List<Collective.Offer> lstOffers = pageBase.ListOffers(); if (lstOffers.Count == 0) { this.Visible = false; return; } _firstOffer = lstOffers.FirstOrDefault(); this.imgOffer.ImageUrl = !String.IsNullOrEmpty(_firstOffer.FirstImgSrc) ? _firstOffer.FirstImgSrc : "/uploads/offerimages/default.jpg"; imgOffer.AlternateText = _firstOffer.Translation.Title; isOfferSuccess = _firstOffer.BoughtCount >= _firstOffer.MinBoughtCount; } else { this.Visible = false; return; } }
protected Collective.Offer GetOffer() { if (_offer == null) { int offerId; if (Int32.TryParse(Request.QueryString["offerid"], out offerId)) { _offer = Collective.Offer.GetOffer(offerId, null); } } return _offer; }
protected void Page_Load(object sender, EventArgs e) { _pageBase = (UserPageBase)Page; _currOffer = _pageBase.GetCurrentOffer(); if (_currOffer == null) Response.Redirect(Page.ResolveUrl("~/Default.aspx")); if (!IsPostBack) { this.ddlSelCount.Attributes["onChange"] = "changeCount(this)"; this.ddlSelCount.Attributes["basicPrice"] = _currOffer.Price.ToString().Replace(',', '.'); int couponsPerUser = _currOffer.NumberOfCouponsPerUser.HasValue ? _currOffer.NumberOfCouponsPerUser.Value : 1; for (int i = 0; i < couponsPerUser; ++i) { this.ddlSelCount.Items.Add(new ListItem((i + 1).ToString(), (i + 1).ToString())); } if (_pageBase.GetLoggedCollectiveUser() != null) { _userBoughtCount = _currOffer.GetUserBoughtCount(_pageBase.GetLoggedCollectiveUser().Id); StringBuilder sbScript = new StringBuilder(); sbScript.Append("\n"); sbScript.Append("var _userBoughtCount=" + _userBoughtCount.ToString() + ";\n"); sbScript.Append("var _maxBoughtCount=" + (_currOffer.NumberOfCouponsPerUser.HasValue ? _currOffer.NumberOfCouponsPerUser.Value : 1).ToString() + ";\n"); sbScript.Append("\n"); Page.ClientScript.RegisterStartupScript(this.GetType(), "startupScript", sbScript.ToString(), true); phLoginRegister.Visible = false; phBuyForm.Visible = true; } else { phLoginRegister.Visible = true; phBuyForm.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { UserPageBase pageBase = (UserPageBase)Page; currOffer = pageBase.GetCurrentOffer(); if (currOffer == null) Response.Redirect(Page.ResolveUrl("~/Default.aspx")); this.phGMapsIframe.Visible = currOffer.Longitude.HasValue && currOffer.Latitude.HasValue; this.phAgencyInfo.Visible = false; if (currOffer.AgencyId.HasValue) { this.offerAgency = Collective.Agency.GetAgency(currOffer.AgencyId.Value); if (this.offerAgency != null) { this.phAgencyInfo.Visible = true; string contactLine = !String.IsNullOrEmpty(this.offerAgency.ContactPhone) ? this.offerAgency.ContactPhone : string.Empty; if (!String.IsNullOrEmpty(offerAgency.ContactEmail)) { contactLine += !String.IsNullOrEmpty(contactLine) ? ", " : string.Empty; contactLine += offerAgency.ContactEmail; } this.ltContact.Text = contactLine; } } isOfferSuccess = currOffer.BoughtCount >= currOffer.MinBoughtCount; } else { this.Visible = false; return; } }
protected void Page_Load(object sender, EventArgs e) { _currentOffer = ((UserPageBase)Page).GetCurrentOffer(); }
private Collective.Offer GetOffer() { if(!_isOfferSet) { _isOfferSet = true; int offerId; if (Int32.TryParse(Request.QueryString["offerid"], out offerId)) { _offer = Collective.Offer.GetOffer(offerId, null); } } return _offer; }
void btnSaveOffer_Click(object sender, EventArgs e) { int? agencyId = null; int collectiveCategoryId = Int32.Parse(ddlCategories.SelectedValue); string name = tbName.Text; double? priceReal = null; double? priceSave = null; double? price = null; int currencyId = Int32.Parse(ddlCurrency.SelectedValue); Collective.OfferStatusType status = (Collective.OfferStatusType)Char.Parse(ddlStatus.SelectedValue); double? discount = null; DateTime? dateStart = null; DateTime? dateEnd = null; DateTime? dateCouponStart = null; DateTime? dateCouponEnd = null; int? numberOfPersons = null; int? numberOfCouponsPerUser = null; string offerType = String.IsNullOrEmpty(tbOfferType.Text) == false ? tbOfferType.Text : null; double? longitude = null; double? latitude = null; int minBoughtCount; int maxBoughtCount; int priority; bool active = cbActive.Checked; int agid; if (Int32.TryParse(ddlAgencies.SelectedValue, out agid)) { agencyId = (int?)agid; } this.lblErrMsg.Text = string.Empty; this.lblMsgSuccess.Text = string.Empty; // cijene if (!String.IsNullOrEmpty(tbPriceReal.Text)) { double prR; if (!Double.TryParse(tbPriceReal.Text.Replace('.', ','), out prR)) { this.lblErrMsg.Text = "Pogrešno unesena \"Prava cijena\"."; fillOfferValues = false; return; } priceReal = (double?)prR; } if (!String.IsNullOrEmpty(tbPriceSave.Text)) { double prS; if (!Double.TryParse(tbPriceSave.Text.Replace('.', ','), out prS)) { this.lblErrMsg.Text = "Pogrešno unesena \"Ušteda\"."; fillOfferValues = false; return; } priceSave = (double?)prS; } if (!String.IsNullOrEmpty(tbPrice.Text)) { double pr; if (!Double.TryParse(tbPrice.Text.Replace('.', ','), out pr)) { this.lblErrMsg.Text = "Pogrešno unesena \"Cijena\"."; fillOfferValues = false; return; } price = (double?)pr; } if (!String.IsNullOrEmpty(tbDiscount.Text)) { double dis; if (!Double.TryParse(tbDiscount.Text.Replace('.', ','), out dis)) { this.lblErrMsg.Text = "Pogrešno unesen \"Popust\"."; fillOfferValues = false; return; } discount = (double?)dis; } // odabrani datumi if (!String.IsNullOrEmpty(tbDateStart.Text)) { DateTime dtSt; if (!DateTime.TryParse(tbDateStart.Text, out dtSt)) { this.lblErrMsg.Text = "Pogrešno unesen \"Datum početka ponude\"."; fillOfferValues = false; return; } dateStart = (DateTime?)dtSt; } if (!String.IsNullOrEmpty(tbDateEnd.Text)) { DateTime dtEnd; if (!DateTime.TryParse(tbDateEnd.Text, out dtEnd)) { this.lblErrMsg.Text = "Pogrešno unesen \"Datum završetka ponude\"."; fillOfferValues = false; return; } dateEnd = (DateTime?)dtEnd; } if (!String.IsNullOrEmpty(tbDateCouponStart.Text)) { DateTime dtcs; if (!DateTime.TryParse(tbDateCouponStart.Text, out dtcs)) { this.lblErrMsg.Text = "Pogrešno unesen \"Datum početka kupona\"."; fillOfferValues = false; return; } dateCouponStart = (DateTime?)dtcs; } if (!String.IsNullOrEmpty(tbDateCouponEnd.Text)) { DateTime dtce; if (!DateTime.TryParse(tbDateCouponEnd.Text, out dtce)) { this.lblErrMsg.Text = "Pogrešno unesen \"Datum završetka kupona\"."; fillOfferValues = false; return; } dateCouponEnd = (DateTime?)dtce; } // broj osoba int numOfPer; if (!String.IsNullOrEmpty(tbNumberOfPersons.Text)) { if (!Int32.TryParse(tbNumberOfPersons.Text, out numOfPer)) { this.lblErrMsg.Text = "Pogrešno unesen \"Broj osoba\"."; fillOfferValues = false; return; } numberOfPersons = (int?)numOfPer; } int numOfCoupPerPer; if (!String.IsNullOrEmpty(tbNumberOfCouponsPerUser.Text)) { if (!Int32.TryParse(tbNumberOfCouponsPerUser.Text, out numOfCoupPerPer)) { this.lblErrMsg.Text = "Pogrešno unesen \"Broj kupona po osobi\"."; fillOfferValues = false; return; } numberOfCouponsPerUser = (int?)numOfCoupPerPer; } // longitude, latitude if (!String.IsNullOrEmpty(tbLongitude.Text)) { double lng; if (!Double.TryParse(tbLongitude.Text.Replace('.', ','), out lng)) { this.lblErrMsg.Text = "Pogrešno unesen \"Longitude\"."; fillOfferValues = false; return; } longitude = (double?)lng; } if (!String.IsNullOrEmpty(tbLatitude.Text)) { double lat; if (!Double.TryParse(tbLatitude.Text.Replace('.', ','), out lat)) { this.lblErrMsg.Text = "Pogrešno unesen \"Latitude\"."; fillOfferValues = false; return; } latitude = (double?)lat; } // min max bought count if(!Int32.TryParse(tbMinBoughtCount.Text, out minBoughtCount)) { this.lblErrMsg.Text = "Pogrešno uneseno \"Minimalano kupona za prodaju\"."; fillOfferValues = false; return; } if (!Int32.TryParse(tbMaxBoughtCount.Text, out maxBoughtCount)) { this.lblErrMsg.Text = "Pogrešno uneseno \"Maksimalno kupona za prodaju\"."; fillOfferValues = false; return; } // priority if(String.IsNullOrEmpty(tbPriority.Text)) { priority = 0; } else if(!Int32.TryParse(tbPriority.Text, out priority)) { this.lblErrMsg.Text = "Pogrešno unesen \"Prioritet\"."; fillOfferValues = false; return; } if (GetOffer() == null) { Collective.Offer offer = Collective.Offer.CreateOffer(null, agencyId, collectiveCategoryId, name, priceReal, priceSave, price, currencyId, status, discount, dateStart, dateEnd, dateCouponStart, dateCouponEnd, numberOfPersons, numberOfCouponsPerUser, minBoughtCount, maxBoughtCount, offerType, longitude, latitude, priority, active, GetPlacesIds()); Response.Redirect(Request.Url.AbsoluteUri.Substring(0, (Request.Url.AbsoluteUri.IndexOf(".aspx") + ".aspx".Length)) + "?offerid=" + offer.OfferId.ToString() + "&msg=success"); //Response.Redirect("http://" + Request.Url.Authority + "/manage/CollectiveOfferList.aspx"); } else { _offer = Collective.Offer.UpdateOffer(GetOffer().OfferId, null, agencyId, collectiveCategoryId, name, priceReal, priceSave, price, currencyId, status, discount, dateStart, dateEnd, dateCouponStart, dateCouponEnd, numberOfPersons, numberOfCouponsPerUser, minBoughtCount, maxBoughtCount, offerType, longitude, latitude, priority, active, GetPlacesIds()); this.lblMsgSuccess.Text = "Izmjene uspješno spremljene."; } }