public ActionResult Edit(GiftCard giftCard) { try { giftCard.LastUpdate = DateTime.Now; ViewBag.Success = true; if (giftCard.ID == -1) { GiftCards.Insert(giftCard); UserNotifications.Send(UserID, String.Format("جدید - سریال تخفیف '{0}' با '{1}' درصد اضافه شد", giftCard.Serial, giftCard.Percent), "/Admin/GiftCards/Edit/" + giftCard.ID, NotificationType.Success); giftCard = new GiftCard(); } else { GiftCards.Update(giftCard); } } catch (Exception ex) { SetErrors(ex); } return(ClearView(giftCard)); }
protected void Page_Init(object sender, EventArgs e) { int id = int.Parse(Request.Params["id"]); if (id > 0) { _giftCards = _giftCardRepository.GetById(id); if (_giftCards == null) { Response.Redirect(Constant.GiftCardListPage); } NameText.Text = _giftCards.Name; CodeText.Text = _giftCards.Code; AmountText.Text = string.Format("{0:0.00}", _giftCards.Amount); } else { if (!IsPostBack) { var code = Helper.RandomString(7); while (_giftCardRepository.IsCodeExists(code)) { code = Helper.RandomString(7); } CodeText.Text = code; } } }
public void IPNVoid(int OrderNumber) { String result = ""; int ONX = OrderNumber; Order ord = new Order(ONX, Localization.GetDefaultLocale()); Customer c = new Customer(ord.CustomerID); using (SqlConnection conn = DB.dbConn()) { conn.Open(); using (IDataReader rs = DB.GetRS("Select * from Orders with (NOLOCK) where OrderNumber=" + ONX.ToString(), conn)) { if (rs.Read()) { if (DB.RSFieldDateTime(rs, "VoidedOn") == System.DateTime.MinValue) { decimal OrderTotal = 0.0M; int CouponType = 0; string CouponCode = ""; decimal CouponDiscountAmount = 0.0M; OrderTotal = DB.RSFieldDecimal(rs, "OrderTotal"); CouponType = DB.RSFieldInt(rs, "CouponType"); CouponCode = DB.RSField(rs, "CouponCode"); CouponDiscountAmount = DB.RSFieldDecimal(rs, "CouponDiscountAmount"); // make sure inventory was restored. safe to call repeatedly. proc protects against deducting twice DB.ExecuteSQL("aspdnsf_AdjustInventory " + ONX.ToString() + ",1"); Gateway.DecrementMicropayProductsInOrder(ONX); // update transactionstate DB.ExecuteSQL("update Orders set VoidTXCommand='Instant Payment Notification', VoidTXResult=" + DB.SQuote(AppLogic.ro_OK) + ", TransactionState=" + DB.SQuote(AppLogic.ro_TXStateVoided) + ", VoidedOn=getdate(), IsNew=0 where ordernumber=" + ONX.ToString()); //Invalidate GiftCards ordered on this order GiftCards GCs = new GiftCards(ONX, GiftCardCollectionFilterType.OrderNumber); foreach (GiftCard gc in GCs) { gc.GiftCardTransactions.Add(GiftCardUsageTransaction.CreateTransaction(gc.GiftCardID, GiftCardUsageReasons.FundsRemovedByAdmin, 0, 0, gc.Balance, "")); gc.UpdateCard(null, null, null, null, 1, null, null, null, null, null, null, null, null, null, null); } //Restore Amount to coupon used in paying for the order if ((CouponTypeEnum)CouponType == CouponTypeEnum.GiftCard) { GiftCard gc = new GiftCard(CouponCode); if (gc.GiftCardID != 0) { gc.GiftCardTransactions.Add(GiftCardUsageTransaction.CreateTransaction(gc.GiftCardID, GiftCardUsageReasons.FundsAddedByAdmin, 0, 0, CouponDiscountAmount, "")); } } result = AppLogic.ro_OK; } } } } }
public JsonResult Get(int pageIndex, int pageSize, string pageOrder, string serial, string fromDate, string toDate, string isUsed) { DateTime?sDate = null, eDate = null; bool?used = null; if (fromDate != String.Empty) { sDate = Utilities.ToEnglishDate(fromDate).Date; } if (toDate != String.Empty) { eDate = Utilities.ToEnglishDate(toDate).Date; } if (isUsed != "-1") { used = Boolean.Parse(isUsed); } var list = GiftCards.Get(pageIndex, pageSize, pageOrder, serial, sDate, eDate, used); int total = GiftCards.Count(serial, sDate, eDate, used); int totalPage = (int)Math.Ceiling((decimal)total / pageSize); if (pageSize > total) { pageSize = total; } if (list.Count < pageSize) { pageSize = list.Count; } JsonResult result = new JsonResult() { Data = new { TotalPages = totalPage, PageIndex = pageIndex, PageSize = pageSize, Rows = list }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; return(result); }
public ActionResult QueryByAuditStatus(GiftCards giftCard, int page = 1, int rows = 20) { var pageInfo = new PageInfo() { Page = page, Rows = rows }; var result = cos.FilterByAuditStatus(giftCard.ReviewStatus, out totalCount, pageInfo); return(Json(new { total = totalCount, rows = result })); }
public override string ToString() { var groups = new string[] { string.Join("&", Variants.Select(x => x.ToString())), string.Join("&", GiftCards.Select(x => x.ToString())), string.Join("&", CheckoutAttributes.Select(x => x.ToString())) }; return(string.Join("&", groups.Where(x => x.HasValue()))); }
public ActionResult GiftCardsGenerate(GiftCards giftCard) { if (giftCard.EndValidDate != new DateTime()) { giftCard.EndValidDate = DateTime.Parse(giftCard.EndValidDate.ToString("yyyy-MM-dd 23:59:59")); } string createdBy = UserCache.CurrentUser.UserName; GiftCards card = new GiftCards(giftCard.Quantity, giftCard.Denomination, giftCard.BeginValidDate, giftCard.EndValidDate, giftCard.SalesMoney, createdBy); card.Title = string.IsNullOrEmpty(giftCard.Title) ? "枫客代金卡" : giftCard.Title; card.GiftBatch = CommonRules.CommonNoRules("giftbatch"); var result = cos.CreateNewOrder(card); return(Json(result)); }
public ActionResult Edit(int?id) { GiftCard giftCard; if (id.HasValue) { giftCard = GiftCards.GetByID(id.Value); } else { giftCard = new GiftCard(); } return(View(giftCard)); }
public JsonResult GiftCardParm(string param1) { int _GiftCardID; if (int.TryParse(param1, out _GiftCardID)) { using (GiftCardEntities db = new GiftCardEntities()) { GiftCards giftCard = new GiftCards(); try { giftCard = db.GiftCards.Where(g => g.GiftCardID == _GiftCardID).SingleOrDefault(); } catch { } if (giftCard != null) { GiftCards _GiftCard = new GiftCards() { Credit = giftCard.Credit, Email = giftCard.Email, FirstName = giftCard.FirstName, FromWho = giftCard.FromWho, GiftCardID = giftCard.GiftCardID, GiftCardValid = giftCard.GiftCardValid, LastName = giftCard.LastName, StoreID = giftCard.StoreID, StoreName = giftCard.StoreName }; return(new JsonResult { Data = _GiftCard, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); } } } return(this.Json(new { success = false })); }
public IActionResult addGiftCard([FromBody] Dictionary <string, object> JSONinput) { GiftCards giftCard = new GiftCards(); try { var giftCardsJson = JsonConvert.SerializeObject(JSONinput["giftCards"], Newtonsoft.Json.Formatting.Indented); giftCard = JsonConvert.DeserializeObject <GiftCards>(giftCardsJson); } catch (Exception) { return(StatusCode(500, "Error parsing JSON")); throw; } string StoredProcedureName = GiftCardsProcedures.addGiftCard; Dictionary <string, object> Parameters = new Dictionary <string, object>(); Parameters.Add("@code", giftCard.code); Parameters.Add("@value", giftCard.value); Parameters.Add("@expiryDate", giftCard.expiryDate); try { int returnCode = dbMan.ExecuteNonQuery(StoredProcedureName, Parameters); if (returnCode == -1) { return(StatusCode(200, "Giftcard added successfully")); } else { return(StatusCode(500, "Failed to add giftcard")); } } catch (Exception) { return(StatusCode(500, "Failed to add giftcard")); throw; } }
public JsonResult Delete(int id) { var jsonSuccessResult = new JsonSuccessResult(); try { GiftCards.Delete(id); jsonSuccessResult.Success = true; } catch (Exception ex) { jsonSuccessResult.Errors = new string[] { ex.Message }; jsonSuccessResult.Success = false; } return(new JsonResult() { Data = jsonSuccessResult }); }
/// <summary> /// 生成代金卡批次订单 /// </summary> /// <param name="order"></param> /// <returns></returns> public OpResult CreateNewOrder(GiftCards order) { var result = new OpResult(); context.GiftCards.Add(order); if (context.SaveChanges() > 0) { result = new OpResult() { Successed = true, Message = "提交成功" }; } else { result = new OpResult() { Successed = false, Message = "数据对象保存错误" }; } return(result); }
/// <summary> /// 获得一个新卡对象,但不持久化到数据库 /// </summary> /// <param name="denomination"></param> /// <param name="beginValidDate"></param> /// <param name="endValidDate"></param> /// <param name="salesMoney"></param> /// <param name="createdBy"></param> /// <returns></returns> public GiftCardDetail MakeGiftCardAsCanRecharge(GiftCards giftCards, Random _random) { var results = new GiftCardDetail(); results.Id = CommonRules.GUID; results.GiftCardId = giftCards.Id; results.GiftCardSN = CommonRules.GiftCardSN(12, _random); //生成12位 results.GiftCardPwd = CommonRules.GiftCardPwd(6, _random); //6位密码 results.Title = giftCards.Title; results.Denomination = giftCards.Denomination; results.SalesMoney = giftCards.SalesMoney; results.BeginValidDate = giftCards.BeginValidDate; results.EndValidDate = giftCards.EndValidDate; results.CreatedBy = giftCards.CreatedBy; results.CreatedOn = DateTime.Now; results.GiftBatch = giftCards.GiftBatch; ///让对象成为刚生成状态 results.UseState = (short)Domain.Enums.GiftCardUseStatus.UnUsed; return(results); }
public int PublishManyGiftCard(GiftCards giftCards) { var publishCount = 0; var quantity = giftCards.Quantity; Random _random = new Random(); for (int i = 0; i < quantity; i++) { var obj = MakeGiftCardAsCanRecharge(giftCards, _random); var count = context.GiftCardDetail.Where(p => p.GiftCardSN.Equals(obj.GiftCardSN) && p.IsDeleted != 1).Count(); if (count > 0) { quantity++; } else { context.GiftCardDetail.Add(obj); } publishCount += context.SaveChanges(); } return(publishCount); }
void HandleGiftCardsOnCancelledOrder(int orderNumber, int couponType, string couponCode, decimal couponDiscountAmount) { var giftCards = new GiftCards(orderNumber, GiftCardCollectionFilterType.OrderNumber); foreach (GiftCard card in giftCards) { card .GiftCardTransactions .Add(GiftCardUsageTransaction .CreateTransaction(card.GiftCardID, GiftCardUsageReasons.FundsRemovedByAdmin, 0, 0, card.Balance, string.Empty)); card.UpdateCard(null, null, null, null, 1, null, null, null, null, null, null, null, null, null, null); } //Restore Amount to gift card used in paying for the order if ((CouponTypeEnum)couponType == CouponTypeEnum.GiftCard) { var giftCard = new GiftCard(couponCode); if (giftCard.GiftCardID != 0) { giftCard .GiftCardTransactions .Add(GiftCardUsageTransaction .CreateTransaction(giftCard.GiftCardID, GiftCardUsageReasons.FundsAddedByAdmin, 0, 0, couponDiscountAmount, string.Empty)); } } }
public ActionResult cardImplement(Receipts d) { using (GiftCardEntities db = new GiftCardEntities()) { try { GiftCards _GiftCard = db.GiftCards.Where(g => g.GiftCardID == d.GiftCardID).FirstOrDefault(); if (d.PurchaseAmount == 0) { d.PurchaseAmount = Convert.ToInt32(_GiftCard.Credit); _GiftCard.Credit = 0; } else if (d.PurchaseAmount > 0) { int KeepOriganalCredit = Convert.ToInt32(_GiftCard.Credit); _GiftCard.Credit = d.PurchaseAmount; d.PurchaseAmount = KeepOriganalCredit - d.PurchaseAmount; } else if (d.PurchaseAmount < 0) { d.PurchaseAmount = (d.PurchaseAmount + (Convert.ToInt32(_GiftCard.Credit) * -1)) * -1; _GiftCard.Credit = 0; } _GiftCard.FirstName = "amicam"; _GiftCard.Receipts.Add(d); db.SaveChanges(); } catch (Exception) { return(Json(new { success = false, errors = true })); } return(Json(new { success = true, errors = true })); } }
public void RefreshPage() { Address BillingAddress = new Address(); Address ShippingAddress = new Address(); BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing); ShippingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryShippingAddressID, AddressTypes.Shipping); if (Checkout) { if (ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 || !ThisCustomer.HasAtLeastOneAddress() || (AppLogic.AppConfigBool("DisallowShippingToPOBoxes") && (!(new POBoxAddressValidator()).IsValid(ShippingAddress)))) { lblErrorMessage.Text = AppLogic.GetString("account.aspx.73", ThisCustomer.SkinID, ThisCustomer.LocaleSetting); pnlErrorMsg.Visible = true; } } ErrorMessage e = new ErrorMessage(CommonLogic.QueryStringNativeInt("errormsg")); lblErrorMessage.Text += Server.HtmlEncode(e.Message); pnlAccountUpdated.Visible = AccountUpdated; if (AccountUpdated) { if (!NewEmailAddressAllowed) { lblAcctUpdateMsg.Text += CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "") + AppLogic.GetString("account.aspx.3", SkinID, ThisCustomer.LocaleSetting); ctrlAccount.Email = ThisCustomer.EMail; } else { lblAcctUpdateMsg.Text = CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "") + AppLogic.GetString("account.aspx.2", SkinID, ThisCustomer.LocaleSetting); } //In case email address confirmation is on. TextBox txtReEnterEmail = (TextBox)ctrlAccount.FindControl("txtReEnterEmail"); if (txtReEnterEmail != null) { txtReEnterEmail.Text = String.Empty; } } pnlNotCheckOutButtons.Visible = !Checkout; pnlShowWishButton.Visible = AppLogic.AppConfigBool("ShowWishButtons"); pnlShowGiftRegistryButtons.Visible = AppLogic.AppConfigBool("ShowGiftRegistryButtons"); pnlSubscriptionExpiresOn.Visible = (ThisCustomer.SubscriptionExpiresOn > System.DateTime.Now); lblSubscriptionExpiresOn.Text = String.Format(AppLogic.GetString("account.aspx.5", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), Localization.ToThreadCultureShortDateString(ThisCustomer.SubscriptionExpiresOn)); OriginalEMail.Text = ThisCustomer.EMail; //lblCustomerLevel.Visible = pnlCustomerLevel.Visible = (ThisCustomer.CustomerLevelID != 0); lblCustomerLevel.Visible = pnlCustomerLevel.Visible = false; lblCustomerLevel.Text = String.Format(AppLogic.GetString("account.aspx.9", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CustomerLevelName); lblMicroPayEnabled.Visible = pnlMicroPayEnabled.Visible = (AppLogic.MicropayIsEnabled() && ThisCustomer.IsRegistered && AppLogic.GetMicroPayProductID() != 0); lblMicroPayEnabled.Text = String.Format(AppLogic.GetString("account.aspx.10", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("account.aspx.11", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CurrencyString(ThisCustomer.MicroPayBalance)); btnContinueToCheckOut.Visible = Checkout; GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon(); if (ThisCustomer.PrimaryBillingAddressID == 0 || checkoutByAmazon.IsAmazonAddress(ThisCustomer.PrimaryBillingAddress)) { // pnlBilling.Visible = false; } if (ThisCustomer.PrimaryShippingAddressID == 0 || checkoutByAmazon.IsAmazonAddress(ThisCustomer.PrimaryShippingAddress)) { //pnlShipping.Visible = false; } lnkChangeBilling.NavigateUrl = "javascript:self.location='JWMyAddresses.aspx?Checkout=" + Checkout.ToString() + "&AddressType=1&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'"; lnkChangeShipping.NavigateUrl = "javascript:self.location='JWMyAddresses.aspx?Checkout=" + Checkout.ToString() + "&AddressType=2&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'"; //lnkAddBillingAddress.NavigateUrl = "JWMyAddresses.aspx?add=true&addressType=1&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()); //lnkAddBillingAddress.Text = "<div>" + AppLogic.GetString("account.aspx.63", SkinID, ThisCustomer.LocaleSetting) + "</div>"; //lnkAddShippingAddress.NavigateUrl = "JWMyAddresses.aspx?add=true&addressType=2&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()); //lnkAddShippingAddress.Text = "<div>" + AppLogic.GetString("account.aspx.62", SkinID, ThisCustomer.LocaleSetting) + "</div>"; if (BillingAddress.AddressID != 0) { litBillingAddress.Text = BillingAddress.DisplayHTML(true); } if (BillingAddress.PaymentMethodLastUsed.Length != 0) { //need for future use //litBillingAddress.Text += "<div>" + AppLogic.GetString("account.aspx.31", SkinID, ThisCustomer.LocaleSetting); // litBillingAddress.Text += "<div>" + BillingAddress.DisplayPaymentMethodInfo(ThisCustomer, BillingAddress.PaymentMethodLastUsed) + "</div>"; } if (!(new POBoxAddressValidator()).IsValid(ShippingAddress)) { litShippingAddress.Text = "<div class='error-wrap'>" + "createaccount_process.aspx.3".StringResource() + "</div>"; //PO box not allowed } else { if (ShippingAddress.AddressID != 0) { litShippingAddress.Text = "Cannot ship to P.O boxes" + ShippingAddress.DisplayHTML(true); } } pnlOrderHistory.Visible = !Checkout; GiftCards gc = new GiftCards(ThisCustomer.CustomerID, GiftCardCollectionFilterType.UsingCustomerID); if (gc.Count > 0) { rptrGiftCards.DataSource = gc; rptrGiftCards.DataBind(); pnlGiftCards.Visible = true; } if (ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.RecurringCart) != 0) { ltRecurringOrders.Text = "<div class=\"group-header account-header recurring-header\">" + AppLogic.GetString("account.aspx.35", SkinID, ThisCustomer.LocaleSetting) + "</div>"; // build JS code to show/hide address update block: StringBuilder tmpS = new StringBuilder(4096); tmpS.Append("<script type=\"text/javascript\">\n"); tmpS.Append("function toggleLayer(DivID)\n"); tmpS.Append("{\n"); tmpS.Append(" var elem;\n"); tmpS.Append(" var vis;\n"); tmpS.Append(" if(document.getElementById)\n"); tmpS.Append(" {\n"); tmpS.Append(" // standards\n"); tmpS.Append(" elem = document.getElementById(DivID);\n"); tmpS.Append(" }\n"); tmpS.Append(" else if(document.all)\n"); tmpS.Append(" {\n"); tmpS.Append(" // old msie versions\n"); tmpS.Append(" elem = document.all[DivID];\n"); tmpS.Append(" }\n"); tmpS.Append(" else if(document.layers)\n"); tmpS.Append(" {\n"); tmpS.Append(" // nn4\n"); tmpS.Append(" elem = document.layers[DivID];\n"); tmpS.Append(" }\n"); tmpS.Append(" vis = elem.style;\n"); tmpS.Append(" if(vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined)\n"); tmpS.Append(" {\n"); tmpS.Append(" vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block' : 'none';\n"); tmpS.Append(" }\n"); tmpS.Append(" vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block' ;\n"); tmpS.Append("}\n"); tmpS.Append("</script>\n"); tmpS.Append("\n"); tmpS.Append("<style type=\"text/css\">\n"); tmpS.Append(" .addressBlockDiv { margin: 0px 20px 0px 20px; display: none;}\n"); tmpS.Append("</style>\n"); ltRecurringOrders.Text += tmpS.ToString(); using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rsr = DB.GetRS("Select distinct OriginalRecurringOrderNumber from ShoppingCart with (NOLOCK) where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + " and CustomerID=" + ThisCustomer.CustomerID.ToString() + " order by OriginalRecurringOrderNumber desc", con)) { while (rsr.Read()) { ltRecurringOrders.Text += AppLogic.GetRecurringCart(base.EntityHelpers, base.GetParser, ThisCustomer, DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"), SkinID, false); } } } } string[] TrxStates = { DB.SQuote(AppLogic.ro_TXStateAuthorized), DB.SQuote(AppLogic.ro_TXStateCaptured), DB.SQuote(AppLogic.ro_TXStatePending) }; using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rs = DB.GetRS(string.Format("Select OrderNumber, OrderDate, RecurringSubscriptionID, PaymentMethod, CardNumber, TransactionState, QuoteCheckout, ShippedOn, ShippedVIA, ShippingTrackingNumber, DownloadEMailSentOn, QuoteCheckout, PaymentMethod, " + "OrderTotal, CouponType, isnull(CouponDiscountAmount, 0) CouponDiscountAmount, CustomerServiceNotes from dbo.orders with (NOLOCK) where TransactionState in ({0}) and CustomerID={1} and ({2} = 0 or StoreID = {3}) order by OrderDate desc", String.Join(",", TrxStates), ThisCustomer.CustomerID, CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowCustomerFiltering") == true, 1, 0), AppLogic.StoreID()), con)) { orderhistorylist.DataSource = rs; orderhistorylist.DataBind(); } } accountaspx55.Visible = (orderhistorylist.Items.Count == 0); ClientScriptManager cs = Page.ClientScript; cs.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "function ReOrder(OrderNumber) {if(confirm('" + AppLogic.GetString("account.aspx.64", SkinID, ThisCustomer.LocaleSetting) + "')) {top.location.href='reorder.aspx?ordernumber='+OrderNumber;} }", true); ctrlAccount.Password = String.Empty; ctrlAccount.PasswordConfirm = String.Empty; }
public int Add(GiftCardBookings entity) { using (var transaction = new TransactionScope()) { var customerInfos = CustomerInfoList.FirstOrDefault(ci => ci.CustomerId == entity.CustomerId); var giftCard = new GiftCards { Amount = entity.TotalPrice, Code = string.Format(Constant.GiftCardFormat, entity.CustomerId, Helper.RandomString(7)), Name = string.Format(Constant.GiftCardNameFormat, customerInfos != null ? customerInfos.EmailAddress : entity.CustomerId.ToString(), entity.RecipientName, entity.RecipientEmail), IsDelete = false, Status = (byte)Enums.GiftCardType.Available }; DayaxeDbContext.GiftCards.InsertOnSubmit(giftCard); Commit(); entity.GiftCardId = giftCard.Id; DayaxeDbContext.GiftCardBookings.InsertOnSubmit(entity); Commit(); if (entity.PayByCredit > 0) { var creditLogs = new CustomerCreditLogs { Amount = entity.PayByCredit, CreatedBy = entity.CustomerId, CreatedDate = DateTime.UtcNow, CreditType = (byte)Enums.CreditType.Charge, Description = entity.Description, CustomerId = entity.CustomerId, Status = true, GiftCardId = entity.GiftCardId }; DayaxeDbContext.CustomerCreditLogs.InsertOnSubmit(creditLogs); var cusCredits = DayaxeDbContext.CustomerCredits .SingleOrDefault(cc => cc.CustomerId == entity.CustomerId); if (cusCredits != null) { cusCredits.Amount -= entity.PayByCredit; } } var schedulesAddOn = new Schedules { ScheduleSendType = (int)Enums.ScheduleSendType.IsEmailGiftCardConfirmation, Name = "Send eGift Card Confirmation", Status = (int)Enums.ScheduleType.NotRun, GiftCardBookingId = entity.Id }; DayaxeDbContext.Schedules.InsertOnSubmit(schedulesAddOn); Commit(); transaction.Complete(); return(entity.Id); } }
public void RefreshPage() { Address BillingAddress = new Address(); Address ShippingAddress = new Address(); BillingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryBillingAddressID, AddressTypes.Billing); ShippingAddress.LoadByCustomer(ThisCustomer.CustomerID, ThisCustomer.PrimaryShippingAddressID, AddressTypes.Shipping); if (Checkout) { pnlCheckoutImage.Visible = true; CheckoutImage.ImageUrl = AppLogic.SkinImage("step_2.gif"); if (ThisCustomer.PrimaryBillingAddressID == 0 || ThisCustomer.PrimaryShippingAddressID == 0 || !ThisCustomer.HasAtLeastOneAddress() || (AppLogic.AppConfigBool("DisallowShippingToPOBoxes") && CheckPOBox(ShippingAddress.Address1))) { ErrorMsgLabel.Text = AppLogic.GetString("account.aspx.73", ThisCustomer.SkinID, ThisCustomer.LocaleSetting);; } } String XRI = AppLogic.SkinImage("redarrow.gif"); redarrow1.ImageUrl = XRI; redarrow2.ImageUrl = XRI; redarrow3.ImageUrl = XRI; pnlCheckoutImage.Visible = Checkout; ErrorMessage e = new ErrorMessage(CommonLogic.QueryStringNativeInt("errormsg")); ErrorMsgLabel.Text += Server.HtmlEncode(e.Message); pnlAccountUpdated.Visible = AccountUpdated; if (AccountUpdated) { if (!NewEmailAddressAllowed) { lblAcctUpdateMsg.Text += CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "<br/>") + AppLogic.GetString("account.aspx.3", SkinID, ThisCustomer.LocaleSetting); } else { lblAcctUpdateMsg.Text = CommonLogic.IIF(lblAcctUpdateMsg.Text.Trim() == "", "", "<br/>") + AppLogic.GetString("account.aspx.2", SkinID, ThisCustomer.LocaleSetting); } } pnlNotCheckOutButtons.Visible = !Checkout; pnlShowWishButton.Visible = AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("ShowWishButtons"); pnlShowGiftRegistryButtons.Visible = AppLogic.ProductIsMLExpress() == false && AppLogic.AppConfigBool("ShowGiftRegistryButtons"); pnlSubscriptionExpiresOn.Visible = (ThisCustomer.SubscriptionExpiresOn > System.DateTime.Now); lblSubscriptionExpiresOn.Text = String.Format(AppLogic.GetString("account.aspx.5", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), Localization.ToThreadCultureShortDateString(ThisCustomer.SubscriptionExpiresOn)); OriginalEMail.Text = ThisCustomer.EMail; imgAccountinfo.ImageUrl = AppLogic.SkinImage("accountinfo.gif"); note1.Visible = (ThisCustomer.CustomerLevelID != 0); note1.Text = String.Format(AppLogic.GetString("account.aspx.9", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CustomerLevelName); MicroPayEnabled.Visible = (AppLogic.MicropayIsEnabled() && ThisCustomer.IsRegistered && AppLogic.GetMicroPayProductID() != 0); MicroPayEnabled.Text = String.Format(AppLogic.GetString("account.aspx.10", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), AppLogic.GetString("account.aspx.11", ThisCustomer.SkinID, ThisCustomer.LocaleSetting), ThisCustomer.CurrencyString(ThisCustomer.MicroPayBalance)); btnContinueToCheckOut.Visible = Checkout; lnkChangeBilling.ImageUrl = AppLogic.SkinImage("change.gif"); lnkChangeShipping.ImageUrl = AppLogic.SkinImage("change.gif"); GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon(); if (ThisCustomer.PrimaryBillingAddressID == 0 || checkoutByAmazon.IsAmazonAddress(ThisCustomer.PrimaryBillingAddress)) { pnlBilling.Visible = false; } if (ThisCustomer.PrimaryShippingAddressID == 0 || checkoutByAmazon.IsAmazonAddress(ThisCustomer.PrimaryShippingAddress)) { pnlShipping.Visible = false; } lnkChangeBilling.NavigateUrl = "javascript:self.location='address.aspx?Checkout=" + Checkout.ToString() + "&AddressType=billing&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'"; lnkChangeShipping.NavigateUrl = "javascript:self.location='address.aspx?Checkout=" + Checkout.ToString() + "&AddressType=shipping&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()) + "'"; imgAddressbook.ImageUrl = AppLogic.SkinImage("addressbook.gif"); lnkAddBillingAddress.NavigateUrl = "address.aspx?add=true&addressType=Billing&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()); lnkAddBillingAddress.Text = AppLogic.GetString("account.aspx.63", SkinID, ThisCustomer.LocaleSetting); lnkAddShippingAddress.NavigateUrl = "address.aspx?add=true&addressType=Shipping&Checkout=" + Checkout.ToString() + "&returnURL=" + Server.UrlEncode("account.aspx?checkout=" + Checkout.ToString()); lnkAddShippingAddress.Text = AppLogic.GetString("account.aspx.62", SkinID, ThisCustomer.LocaleSetting); litBillingAddress.Text = BillingAddress.DisplayHTML(Checkout); if (BillingAddress.PaymentMethodLastUsed.Length != 0) { litBillingAddress.Text += "<b>" + AppLogic.GetString("account.aspx.31", SkinID, ThisCustomer.LocaleSetting) + "</b><br/>"; litBillingAddress.Text += BillingAddress.DisplayPaymentMethodInfo(ThisCustomer, BillingAddress.PaymentMethodLastUsed); } if (CheckPOBox(ShippingAddress.Address1)) { litShippingAddress.Text = "<span style=\"color:red; font-weight:bold;\">" + "createaccount_process.aspx.3".StringResource() + "</span>"; //PO box not allowed } else { litShippingAddress.Text = ShippingAddress.DisplayHTML(Checkout); } pnlOrderHistory.Visible = !Checkout; imgOrderhistory.ImageUrl = AppLogic.SkinImage("orderhistory.gif"); if (!AppLogic.m_ProductIsML()) { // gift cards not supported in PRO } else { GiftCards gc = new GiftCards(ThisCustomer.CustomerID, GiftCardCollectionFilterType.UsingCustomerID); if (gc.Count > 0) { rptrGiftCards.DataSource = gc; rptrGiftCards.DataBind(); tblGiftCards.Attributes.Add("style", "border-style: solid; border-width: 0px; border-color: #" + AppLogic.AppConfig("HeaderBGColor")); tblGiftCardsBox.Attributes.Add("style", AppLogic.AppConfig("BoxFrameStyle")); giftcards_gif.ImageUrl = AppLogic.LocateImageURL("App_Themes/skin_" + SkinID.ToString() + "/images/giftcards.gif"); pnlGiftCards.Visible = true; } } if (ShoppingCart.NumItems(ThisCustomer.CustomerID, CartTypeEnum.RecurringCart) != 0) { RecurringOrders.Text = "<p align=\"left\"><b>" + AppLogic.GetString("account.aspx.35", SkinID, ThisCustomer.LocaleSetting) + "</b></p>"; // build JS code to show/hide address update block: StringBuilder tmpS = new StringBuilder(4096); tmpS.Append("<script type=\"text/javascript\">\n"); tmpS.Append("function toggleLayer(DivID)\n"); tmpS.Append("{\n"); tmpS.Append(" var elem;\n"); tmpS.Append(" var vis;\n"); tmpS.Append(" if(document.getElementById)\n"); tmpS.Append(" {\n"); tmpS.Append(" // standards\n"); tmpS.Append(" elem = document.getElementById(DivID);\n"); tmpS.Append(" }\n"); tmpS.Append(" else if(document.all)\n"); tmpS.Append(" {\n"); tmpS.Append(" // old msie versions\n"); tmpS.Append(" elem = document.all[DivID];\n"); tmpS.Append(" }\n"); tmpS.Append(" else if(document.layers)\n"); tmpS.Append(" {\n"); tmpS.Append(" // nn4\n"); tmpS.Append(" elem = document.layers[DivID];\n"); tmpS.Append(" }\n"); tmpS.Append(" vis = elem.style;\n"); tmpS.Append(" if(vis.display == '' && elem.offsetWidth != undefined && elem.offsetHeight != undefined)\n"); tmpS.Append(" {\n"); tmpS.Append(" vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block' : 'none';\n"); tmpS.Append(" }\n"); tmpS.Append(" vis.display = (vis.display == '' || vis.display == 'block') ? 'none' : 'block' ;\n"); tmpS.Append("}\n"); tmpS.Append("</script>\n"); tmpS.Append("\n"); tmpS.Append("<style type=\"text/css\">\n"); tmpS.Append(" .addressBlockDiv { margin: 0px 20px 0px 20px; display: none;}\n"); tmpS.Append("</style>\n"); RecurringOrders.Text += tmpS.ToString(); using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rsr = DB.GetRS("Select distinct OriginalRecurringOrderNumber from ShoppingCart with (NOLOCK) where CartType=" + ((int)CartTypeEnum.RecurringCart).ToString() + " and CustomerID=" + ThisCustomer.CustomerID.ToString() + " order by OriginalRecurringOrderNumber desc", con)) { while (rsr.Read()) { RecurringOrders.Text += AppLogic.GetRecurringCart(base.EntityHelpers, base.GetParser, ThisCustomer, DB.RSFieldInt(rsr, "OriginalRecurringOrderNumber"), SkinID, false); } } } RecurringOrders.Text += "<br/><br/>"; } string[] TrxStates = { DB.SQuote(AppLogic.ro_TXStateAuthorized), DB.SQuote(AppLogic.ro_TXStateCaptured), DB.SQuote(AppLogic.ro_TXStatePending) }; using (SqlConnection con = new SqlConnection(DB.GetDBConn())) { con.Open(); using (IDataReader rs = DB.GetRS(string.Format("Select OrderNumber, OrderDate, RecurringSubscriptionID, PaymentMethod, CardNumber, TransactionState, QuoteCheckout, ShippedOn, ShippedVIA, ShippingTrackingNumber, DownloadEMailSentOn, QuoteCheckout, PaymentMethod, " + "OrderTotal, CouponType, isnull(CouponDiscountAmount, 0) CouponDiscountAmount, CustomerServiceNotes from dbo.orders with (NOLOCK) where TransactionState in ({0}) and CustomerID={1} and ({2} = 0 or StoreID = {3}) order by OrderDate desc", String.Join(",", TrxStates), ThisCustomer.CustomerID, CommonLogic.IIF(AppLogic.GlobalConfigBool("AllowCustomerFiltering") == true, 1, 0), AppLogic.StoreID()), con)) { orderhistorylist.DataSource = rs; orderhistorylist.DataBind(); } } accountaspx55.Visible = (orderhistorylist.Items.Count == 0); ctrlAccount.Password = String.Empty; ctrlAccount.PasswordConfirm = String.Empty; ClientScriptManager cs = Page.ClientScript; cs.RegisterClientScriptBlock(this.GetType(), Guid.NewGuid().ToString(), "function ReOrder(OrderNumber) {if(confirm('" + AppLogic.GetString("account.aspx.64", SkinID, ThisCustomer.LocaleSetting) + "')) {top.location.href='reorder.aspx?ordernumber='+OrderNumber;} }", true); }
protected void SaveDiscountClick(object sender, EventArgs e) { LblMessage.Visible = false; LblMessage.Text = ""; if (string.IsNullOrEmpty(NameText.Text.Trim())) { LblMessage.Visible = true; LblMessage.Text = "Name is required"; return; } if (string.IsNullOrEmpty(CodeText.Text.Trim())) { LblMessage.Visible = true; LblMessage.Text = "Code is required"; return; } if (string.IsNullOrEmpty(AmountText.Text.Trim())) { LblMessage.Visible = true; LblMessage.Text = "Amount is required"; return; } int gId = int.Parse(Request.Params["id"]); double amount; double.TryParse(AmountText.Text, out amount); if (gId == 0) { _giftCards = new GiftCards { Name = NameText.Text.Trim(), Code = CodeText.Text.ToUpper().Trim(), Amount = amount, IsDelete = false }; try { gId = _giftCardRepository.Add(_giftCards); } catch (Exception ex) { LblMessage.Visible = true; LblMessage.Text = ex.Message; return; } } else { _giftCards = _giftCardRepository.GetById(gId); _giftCards.Name = NameText.Text.Trim(); _giftCards.Code = CodeText.Text.ToUpper().Trim(); _giftCards.Amount = amount; _giftCardRepository.Update(_giftCards); } _giftCardRepository.ResetCache(); Response.Redirect(Constant.GiftCardListPage); }
public async Task <ActionResult> SearchGiftCardsAsync(GiftCardSearch model) { var result = await GiftCards.SearchAsync(this.Tenant, model).ConfigureAwait(false); return(this.Ok(result)); }
public void IPNRefund(int OrderNumber, String RefundTransID, Decimal RefundAmount) { String result = ""; if (RefundAmount < 0) { RefundAmount = (decimal)(-1.0) * RefundAmount; } int ONX = OrderNumber; Order ord = new Order(ONX, Localization.GetDefaultLocale()); Customer c = new Customer(ord.CustomerID); decimal OrderTotal = 0.0M; int CouponType = 0; string CouponCode = ""; decimal CouponDiscountAmount = 0.0M; String RefundReason = "PayPal IPN Refund"; using (SqlConnection conn = DB.dbConn()) { conn.Open(); using (IDataReader rs = DB.GetRS("Select * from Orders with (NOLOCK) where OrderNumber=" + ONX.ToString(), conn)) { if (rs.Read()) { string PM = AppLogic.CleanPaymentMethod(DB.RSField(rs, "PaymentMethod")); if (DB.RSFieldDateTime(rs, "RefundedOn") == System.DateTime.MinValue) { if (DB.RSFieldDateTime(rs, "CapturedOn") != System.DateTime.MinValue) { if (DB.RSField(rs, "TransactionState") == AppLogic.ro_TXStateCaptured) { OrderTotal = DB.RSFieldDecimal(rs, "OrderTotal"); CouponType = DB.RSFieldInt(rs, "CouponType"); CouponCode = DB.RSField(rs, "CouponCode"); CouponDiscountAmount = DB.RSFieldDecimal(rs, "CouponDiscountAmount"); DB.ExecuteSQL("update orders set RefundTXCommand='Instant Payment Notification', RefundTXResult=" + DB.SQuote(AppLogic.ro_OK) + ", AuthorizationPNREF=AuthorizationPNREF+" + DB.SQuote("|REFUND=" + RefundTransID) + " where OrderNumber=" + ONX.ToString()); result = AppLogic.ro_OK; } } } } } } if (result == AppLogic.ro_OK) { // was this a full refund // we can only properly handle IPN's for refunds of the full order amount if (RefundAmount == System.Decimal.Zero || RefundAmount == OrderTotal) { // make sure inventory was restored. safe to call repeatedly. proc protects against deducting twice DB.ExecuteSQL("aspdnsf_AdjustInventory " + ONX.ToString() + ",1"); Gateway.DecrementMicropayProductsInOrder(ONX); // update transactionstate DB.ExecuteSQL("update Orders set RefundReason=" + DB.SQuote(RefundReason) + ", TransactionState=" + DB.SQuote(AppLogic.ro_TXStateRefunded) + ", RefundedOn=getdate(), IsNew=0 where OrderNumber=" + ONX.ToString()); //Invalidate GiftCards ordered on this order GiftCards GCs = new GiftCards(ONX, GiftCardCollectionFilterType.OrderNumber); foreach (GiftCard gc in GCs) { gc.GiftCardTransactions.Add(GiftCardUsageTransaction.CreateTransaction(gc.GiftCardID, GiftCardUsageReasons.FundsRemovedByAdmin, 0, 0, gc.Balance, "")); gc.UpdateCard(null, null, null, null, 1, null, null, null, null, null, null, null, null, null, null); } //Restore Amount to coupon used in paying for the order if ((CouponTypeEnum)CouponType == CouponTypeEnum.GiftCard) { GiftCard gc = new GiftCard(CouponCode); if (gc.GiftCardID != 0) { gc.GiftCardTransactions.Add(GiftCardUsageTransaction.CreateTransaction(gc.GiftCardID, GiftCardUsageReasons.FundsAddedByAdmin, 0, 0, CouponDiscountAmount, "")); } } } } }