public static void ClearTicketCoupons(YearId ticketPrimaryKey) { IEnumerable <TicketCoupon> coupons = TicketCoupon.GetAll(ticketPrimaryKey); foreach (TicketCoupon coupon in coupons) { TicketCoupon.Delete(coupon.PrimaryKey); } }
private void InitializeAppliedCoupons() { List <int> addedIds = new List <int>(); listBoxApplied.Items.Clear(); IEnumerable <TicketCoupon> allTicketCoupons = TicketCoupon.GetAll(SelectedTicket.PrimaryKey); foreach (TicketCoupon ticketCoupon in allTicketCoupons) { Coupon coupon = Coupon.Get(ticketCoupon.CouponId); if (!addedIds.Contains(coupon.Id)) { addedIds.Add(coupon.Id); AddApplied(coupon); } else if (!coupon.ApplyToAll) { AddApplied(coupon); } } }
private void RemoveCoupon() { FormattedListBoxItem selectedItem = (FormattedListBoxItem)listBoxApplied.SelectedItem; listBoxApplied.SelectedItem = null; listBoxApplied.Items.Remove(selectedItem); Coupon coupon = (Coupon)selectedItem.ReferenceObject; IEnumerable <TicketCoupon> allCoupons = TicketCoupon.GetAll(SelectedTicket.PrimaryKey); foreach (TicketCoupon ticketCoupon in allCoupons) { if (ticketCoupon.CouponId == coupon.Id) { TicketCoupon.Delete(ticketCoupon.PrimaryKey); } } InitializeAvailableCoupons(); }
private static void ResetTransactionalTables() { SettingManager.SetStoreSetting("DailyIdOffset", 0); DayOfOperation.Reset(typeof(DayOfOperation)); EmployeeTimesheet.Reset(typeof(EmployeeTimesheet)); EmployeeTimesheetChangeLog.Reset(typeof(EmployeeTimesheetChangeLog)); Lock.Reset(typeof(Lock)); Party.Reset(typeof(Party)); PartyInvite.Reset(typeof(PartyInvite)); RegisterDeposit.Reset(typeof(RegisterDeposit)); RegisterDrawer.Reset(typeof(RegisterDrawer)); RegisterDrop.Reset(typeof(RegisterDrop)); RegisterNoSale.Reset(typeof(RegisterNoSale)); RegisterPayout.Reset(typeof(RegisterPayout)); Ticket.Reset(typeof(Ticket)); TicketCoupon.Reset(typeof(TicketCoupon)); TicketDiscount.Reset(typeof(TicketDiscount)); TicketItem.Reset(typeof(TicketItem)); TicketItemOption.Reset(typeof(TicketItemOption)); TicketItemReturn.Reset(typeof(TicketItemReturn)); TicketPayment.Reset(typeof(TicketPayment)); TicketRefund.Reset(typeof(TicketRefund)); TicketVoid.Reset(typeof(TicketVoid)); }
public static void ClearCoupons(TicketItem ticketItem) { TicketCoupon.DeleteForTicketItem(ticketItem.PrimaryKey); }
private void ApplyCoupon() { TicketCoupon result = null; FormattedListBoxItem selectedItem = (FormattedListBoxItem)listBoxAvailable.SelectedItem; Coupon coupon = (Coupon)selectedItem.ReferenceObject; if (coupon.ApplyToAll) { int count = 0; foreach (TicketItemTemplate ticketItem in Items) { if (HasRestrictions(coupon, ticketItem.TicketItem)) { continue; } // Create TicketCoupon result = TicketCoupon.AddForTicketItem(coupon.Id, SelectedTicket.PrimaryKey, ticketItem.TicketItem.PrimaryKey.Id); count++; if ((coupon.LimitPerTicket != null) && (count >= coupon.LimitPerTicket.Value)) { break; } } } else if (coupon.ApplyToTicket()) { result = TicketCoupon.AddForTicket(coupon.Id, SelectedTicket.PrimaryKey); } else { if (SelectedTicketItem != null) { if (!HasRestrictions(coupon, SelectedTicketItem)) { result = TicketCoupon.AddForTicketItem(coupon.Id, SelectedTicket.PrimaryKey, _selectedTicketItem.PrimaryKey.Id); } } else { // this shouldn't happen PosDialogWindow.ShowDialog( Strings.YouNeedToSelectATicketItemToUseThisCouponOn, Strings.Error); return; } } if (result == null) { PosDialogWindow.ShowDialog( Strings.ThatCouponCanNotBeAppliedToAnyItemsOnThisTicket, Strings.Error); } else { listBoxAvailable.SelectedItem = null; listBoxAvailable.Items.Remove(selectedItem); listBoxAvailable.SelectedItem = AddApplied(coupon); } }