Exemple #1
0
        private int SaveGiftCertificate()
        {
            if (Page.IsValid)
            {
                IGiftCertKeyProvider gckProvider = AbleContext.Container.Resolve <IGiftCertKeyProvider>();
                _GiftCertificate.Name = Name.Text;
                decimal newBalance = AlwaysConvert.ToDecimal(Balance.Text);

                if (newBalance != _GiftCertificate.Balance)
                {
                    _GiftCertificate.AddBalanceUpdatedTransaction(_GiftCertificate.Balance, newBalance);
                    _GiftCertificate.Balance = newBalance;
                }

                DateTime newDate = ExpireDate.SelectedEndDate;
                DateTime oldDate = _GiftCertificate.ExpirationDate.HasValue ? _GiftCertificate.ExpirationDate.Value : DateTime.MinValue;
                if (!oldDate.Equals(newDate))
                {
                    _GiftCertificate.AddExpiryUpdatedTransaction(oldDate, newDate);
                    _GiftCertificate.ExpirationDate = ExpireDate.NullableSelectedEndDate;
                }

                if (GenerateSerialNumber.Checked)
                {
                    if (string.IsNullOrEmpty(_GiftCertificate.SerialNumber))
                    {
                        _GiftCertificate.AddActivatedTransaction();
                    }
                    _GiftCertificate.SerialNumber = gckProvider.GenerateGiftCertificateKey();
                }
                _GiftCertificate.Save();
                return(_GiftCertificate.Id);
            }
            return(0);
        }
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            short quantity = AlwaysConvert.ToInt16(KitQuantity.Text);

            if (quantity > 0)
            {
                ProductVariant productVariant = null;
                if (_KitProduct.Product.ProductOptions.Count > 0)
                {
                    productVariant = ProductVariantDataSource.LoadForOptionList(_KitProduct.Product.Id, selectedOptions);
                }
                if (productVariant != null)
                {
                    _KitProduct.OptionList = productVariant.OptionList;
                }
                _KitProduct.Name         = DisplayName.Text;
                _KitProduct.Quantity     = quantity;
                _KitProduct.PriceModeId  = AlwaysConvert.ToByte(PriceMode.SelectedIndex);
                _KitProduct.Price        = AlwaysConvert.ToDecimal(Price.Text);
                _KitProduct.WeightModeId = AlwaysConvert.ToByte(WeightMode.SelectedIndex);
                _KitProduct.Weight       = AlwaysConvert.ToDecimal(Weight.Text);
                _KitProduct.IsSelected   = IsSelected.Checked;
                _KitProduct.Save();
            }
            Response.Redirect(string.Format("EditKit.aspx?CategoryId={0}&ProductId={1}", _CategoryId, _ProductId));
        }
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            OrderShipment newShipment = new OrderShipment();

            newShipment.Order       = _Order;
            newShipment.WarehouseId = AlwaysConvert.ToInt(ShipFrom.SelectedValue);
            SetAddress(newShipment);
            if (ShipMethodList.SelectedIndex > -1)
            {
                newShipment.ShipMethodId   = AlwaysConvert.ToInt(ShipMethodList.SelectedItem.Value);
                newShipment.ShipMethodName = ShipMethodList.SelectedItem.Text;
                decimal shippingCost = AlwaysConvert.ToDecimal(ShipCharges.Text);
                if (shippingCost > 0)
                {
                    // Add Shipping & Handling item
                    OrderItem shippingCharge = new OrderItem();
                    shippingCharge.Name          = ShipMethodList.SelectedItem.Text;
                    shippingCharge.OrderItemType = OrderItemType.Shipping;
                    shippingCharge.Price         = AlwaysConvert.ToDecimal(ShipCharges.Text);
                    shippingCharge.Order         = newShipment.Order;
                    shippingCharge.Quantity      = 1;
                    shippingCharge.OrderShipment = newShipment;
                    newShipment.OrderItems.Add(shippingCharge);

                    // ADD TO ORDER ITEMS
                    _Order.Items.Add(shippingCharge);
                }
            }
            newShipment.ShipMessage = ShipMessage.Text;

            // ADD TO ORDER, SAVE AND RECALCULATE
            _Order.Shipments.Add(newShipment);
            _Order.Save(true, false);
            Response.Redirect("Default.aspx?OrderNumber=" + _Order.OrderNumber.ToString());
        }
Exemple #4
0
 protected void SaveSpecial()
 {
     _Special.Price     = AlwaysConvert.ToDecimal(Price.Text);
     _Special.StartDate = StartDate.SelectedDate;
     _Special.EndDate   = EndDate.SelectedEndDate;
     _Special.Groups.Clear();
     _Special.Save();
     if (SelectedGroups.Checked)
     {
         foreach (ListItem item in Groups.Items)
         {
             CommerceBuilder.Users.Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value));
             if (item.Selected)
             {
                 _Special.Groups.Add(group);
             }
         }
         if (_Special.Groups.Count == 0)
         {
             SelectedGroups.Checked = false;
             AllGroups.Checked      = true;
         }
     }
     _Special.Save();
 }
Exemple #5
0
 protected void AddButton_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         WrapStyle style = new WrapStyle();
         style.WrapGroupId  = WrapGroupId;
         style.Name         = Name.Text;
         style.ThumbnailUrl = ThumbnailUrl.Text;
         style.ImageUrl     = ImageUrl.Text;
         style.Price        = AlwaysConvert.ToDecimal(Price.Text);
         style.TaxCodeId    = AlwaysConvert.ToInt(TaxCode.SelectedValue);
         style.Save();
         Name.Text             = string.Empty;
         ThumbnailUrl.Text     = string.Empty;
         ImageUrl.Text         = string.Empty;
         Price.Text            = string.Empty;
         TaxCode.SelectedIndex = -1;
         AddedMessage.Text     = string.Format(AddedMessage.Text, style.Name);
         AddedMessage.Visible  = true;
         UpdatePanel panel = AbleCommerce.Code.PageHelper.RecursiveFindControl(this.Page, "WrapStylesAjax") as UpdatePanel;
         if (panel != null)
         {
             GridView wrapStyleGrid = AbleCommerce.Code.PageHelper.RecursiveFindControl(panel, "WrapStylesGrid") as GridView;
             if (wrapStyleGrid != null)
             {
                 wrapStyleGrid.DataBind();
                 panel.Update();
             }
         }
     }
 }
        private decimal GetPaymentAmount(bool getInputPrice = false)
        {
            decimal originalAmount = this.PaymentAmount;

            if (originalAmount <= 0)
            {
                originalAmount = AbleContext.Current.User.Basket.Items.TotalPrice();
            }

            // get the input price if price input is enabled and page is posted back
            if (Page.IsPostBack && trAmount.Visible && getInputPrice)
            {
                // check for posted back amount
                string  postedAmount  = Request.Form[Amount.UniqueID];
                decimal paymentAmount = AlwaysConvert.ToDecimal(postedAmount);

                // AC8-3022, AC8-2854: IF amount is not changed by merchant then
                // to avoid rounding issues, restore the original amount upto 4 decimal digits
                string originalRoundedAmount = string.Format("{0:F2}", originalAmount);
                if (originalRoundedAmount == postedAmount)
                {
                    paymentAmount = originalAmount;
                }

                if (paymentAmount > 0)
                {
                    return(paymentAmount);
                }
            }

            // otherwise use provided value or basket total
            return(originalAmount);
        }
Exemple #7
0
        private Dictionary <string, ProviderShipRateQuote> ParseProviderRateReponseIntl(XmlDocument providerResponse, Package[] packageList)
        {
            //CREATE TEMPORARY STORAGE FOR PARSING THE QUOTED SERVICES
            Dictionary <string, ProviderShipRateQuote> availableServices = new Dictionary <string, ProviderShipRateQuote>();
            ProviderShipRateQuote serviceQuote;
            //LOOP EACH PACKAGE IN THE RESPONSE
            XmlNodeList packageNodeList = providerResponse.DocumentElement.SelectNodes("Package");

            foreach (XmlNode packageNode in packageNodeList)
            {
                XmlNodeList serviceNodeList = packageNode.SelectNodes("Service");
                foreach (XmlNode serviceNode in serviceNodeList)
                {
                    string    serviceName = XmlUtility.GetElementValue(serviceNode, "SvcDescription", string.Empty);
                    LSDecimal postage     = AlwaysConvert.ToDecimal(XmlUtility.GetElementValue(serviceNode, "Postage", string.Empty));
                    if (postage > 0)
                    {
                        //GET THE INSTANCE OF SERVICEQUOTE TO BE UPDATED
                        if (availableServices.ContainsKey(serviceName))
                        {
                            serviceQuote = availableServices[serviceName];
                        }
                        else
                        {
                            //CREATE A NEW INSTANCE OF ProviderShipRateQuote
                            serviceQuote             = new ProviderShipRateQuote();
                            serviceQuote.ServiceCode = serviceName;
                            availableServices.Add(serviceName, serviceQuote);
                        }
                        //GET THE PACKAGE ID FROM THE RATE
                        int packageId = AlwaysConvert.ToInt(XmlUtility.GetAttributeValue(packageNode, "ID", string.Empty), -1);
                        if (packageId != -1)
                        {
                            //FIND THE PACKAGE IN THE LIST
                            Package package = packageList[packageId];
                            serviceQuote.Rate         += (postage * package.Multiplier);
                            serviceQuote.PackageCount += 1;
                        }
                    }
                }
            }
            //MOVE THROUGH LIST AND FIND SERVICES THAT ARE NOT AVAILABLE
            //FOR ALL PACKAGES IN THE SHIPMENT
            List <string> removeServices = new List <string>();

            foreach (string serviceName in availableServices.Keys)
            {
                serviceQuote = availableServices[serviceName];
                if (serviceQuote.PackageCount < packageList.Length)
                {
                    removeServices.Add(serviceName);
                }
            }
            //REMOVE ANY SERVICES THAT WERE IDENTIFIED
            foreach (string serviceName in removeServices)
            {
                availableServices.Remove(serviceName);
            }
            return(availableServices);
        }
        private void SaveSearchFilter()
        {
            ProductFilter criteria = new ProductFilter();

            criteria.Name = Name.Text;
            criteria.SearchDescriptions = SearchDescriptions.Checked;
            criteria.Sku = Sku.Text;

            if (!_DisplayCategorySearch)
            {
                criteria.CategoryId = AlwaysConvert.ToInt(CategoriesList.SelectedValue);
            }
            else
            {
                criteria.CategoryId = AlwaysConvert.ToInt(HiddenSelectedCategoryId.Value);
            }

            criteria.ManufacturerId       = AlwaysConvert.ToInt(ManufacturerList.SelectedValue);
            criteria.VendorId             = AlwaysConvert.ToInt(VendorList.SelectedValue);
            criteria.Featured             = OnlyFeatured.Checked ? BitFieldState.True : BitFieldState.Any;
            criteria.FromPrice            = AlwaysConvert.ToDecimal(FromPrice.Text);
            criteria.ToPrice              = AlwaysConvert.ToDecimal(ToPrice.Text);
            criteria.DigitalGoodsOnly     = OnlyDigitalGoods.Checked;
            criteria.GiftCertificatesOnly = OnlyGiftCertificates.Checked;
            criteria.KitsOnly             = OnlyKits.Checked;
            criteria.SubscriptionsOnly    = OnlySubscriptions.Checked;
            criteria.IncludeThumbnails    = ShowProductThumbnails.Checked;
            criteria.GroupId              = AlwaysConvert.ToInt(ProductGroups.SelectedValue);

            // RETURN THE CRITERIA OBJECT
            Session["ProductSearchFilter"] = criteria;
        }
        protected void SubmitCaptureButton_Click(object sender, EventArgs e)
        {
            int     paymentId = AlwaysConvert.ToInt(HiddenPaymentId.Value);
            Payment payment   = PaymentDataSource.Load(paymentId);

            if (payment != null)
            {
                //GET THE CAPTURE AMOUNT
                decimal captureAmount = AlwaysConvert.ToDecimal(CaptureAmount.Text);
                bool    finalCapture  = NoAdditionalCapture.Checked;
                if (captureAmount > 0)
                {
                    payment.Capture(captureAmount, finalCapture, false);
                    if (!string.IsNullOrEmpty(CustomerNote.Text))
                    {
                        OrderNote note = new OrderNote(payment.Order.Id, AbleContext.Current.UserId, DateTime.UtcNow, CustomerNote.Text, NoteType.Public);
                        note.Save();
                    }
                }

                // UPDATE THE GRID
                CapturePopup.Hide();
                PaymentGrid.DataBind();
                SearchResultAjax.Update();
            }
        }
Exemple #10
0
        private ProviderShipRateQuote ParseProviderResponse(string providerResponse, Address destination, string serviceCode)
        {
            ProviderShipRateQuote quote = new ProviderShipRateQuote();

            if (string.IsNullOrEmpty(providerResponse))
            {
                return(null);
            }
            StringReader sr         = new StringReader(providerResponse);
            string       chargeLine = sr.ReadLine();
            string       days       = sr.ReadLine();
            string       errmsg     = sr.ReadLine();

            if (!string.IsNullOrEmpty(errmsg) && errmsg.EndsWith("OK"))
            {
                int index;
                if (!string.IsNullOrEmpty(chargeLine))
                {
                    index              = chargeLine.IndexOf("charge=");
                    quote.Rate         = AlwaysConvert.ToDecimal(chargeLine.Substring(index + 7));
                    quote.PackageCount = 1;
                    quote.ServiceCode  = serviceCode;
                    quote.ServiceName  = GetServiceName(serviceCode);
                }
            }
            return(quote);
        }
Exemple #11
0
        protected void UpdateCurrency()
        {
            if (Page.IsValid)
            {
                Currency currency = CurrencyDataSource.Load(this.CurrencyId);
                currency.Name             = Name.Text;
                currency.ExchangeRate     = AlwaysConvert.ToDecimal(ExchangeRate.Text, 1M);
                currency.AutoUpdate       = AutoUpdate.Checked;
                currency.ISOCode          = ISOCode.Text;
                currency.ISOCodePattern   = (byte)ISOCodePattern.SelectedIndex;
                currency.CurrencySymbol   = CurrencySymbol.Text;
                currency.PositivePattern  = (byte)PositivePattern.SelectedIndex;
                currency.NegativePattern  = (byte)NegativePattern.SelectedIndex;
                currency.NegativeSign     = NegativeSign.Text;
                currency.DecimalSeparator = DecimalSeparator.Text;
                currency.DecimalDigits    = AlwaysConvert.ToInt(DecimalDigits.Text);
                currency.GroupSeparator   = GroupSeparator.Text;
                currency.GroupSizes       = GroupSizes.Text;
                currency.Save();
                if (currency.AutoUpdate)
                {
                    currency.UpdateExchangeRate(false);
                }
                if (ItemUpdated != null)
                {
                    ItemUpdated(this, new PersistentItemEventArgs(this.CurrencyId, currency.Name));
                }

                // RESET CURRENCY ID
                this.CurrencyId = 0;
            }
        }
Exemple #12
0
        private void SaveGateWayProviderDHL()
        {
            DHLInternational provider = (DHLInternational)_ShipGateway.GetProviderInstance();

            provider.UseDebugMode         = UseDebugMode.Checked;
            provider.UseTestMode          = UseTestMode.Checked;
            provider.EnablePackageBreakup = EnablePackaging.Checked;
            provider.ShippingKey          = ShippingKey.Text;
            provider.AccountNumber        = AccountNumber.Text;
            provider.UserID     = UserID.Text;
            provider.Password   = Password.Text;
            provider.DaysToShip = AlwaysConvert.ToInt(DaysToShip.Text, 1);
            if (provider.DaysToShip < 1)
            {
                provider.DaysToShip = 1;
            }
            DaysToShip.Text                 = provider.DaysToShip.ToString();
            provider.LiveModeUrl            = LiveServerURL.Text;
            provider.TestModeUrl            = TestServerURL.Text;
            provider.TrackingUrl            = TrackingURL.Text;
            provider.MaxPackageWeight       = AlwaysConvert.ToDecimal(MaxWeight.Text, (decimal)provider.MaxPackageWeight);
            provider.MinPackageWeight       = AlwaysConvert.ToDecimal(MinWeight.Text, (decimal)provider.MinPackageWeight);
            provider.DutiableFlag           = DutiableFlag.Checked;
            provider.CustomsValueMultiplier = AlwaysConvert.ToDecimal(CustomsValueMultiplier.Text, 1);
            provider.CommerceLicensed       = CommerceLicensed.Checked;
            provider.FilingType             = (DHLInternational.FilingTypeFlags)AlwaysConvert.ToEnum(typeof(DHLInternational.FilingTypeFlags), FilingType.SelectedValue, DHLInternational.FilingTypeFlags.ITN);
            provider.FTRExemptionCode       = FTRExemptionCode.Text;
            provider.ITNNumber              = ITNNumber.Text;
            provider.EINCode                = EINCode.Text;
            _ShipGateway.UpdateConfigData(provider.GetConfigData());
            _ShipGateway.Save();
        }
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid && CustomValidation())
            {
                PaymentMethod method = GetSelectedMethod();
                if (method != null)
                {
                    Payment payment = new Payment();
                    payment.Order           = _Order;
                    payment.PaymentMethodId = method.Id;
                    AccountDataDictionary paymentInstrumentBuilder = new AccountDataDictionary();
                    switch (method.PaymentInstrumentType)
                    {
                    case PaymentInstrumentType.AmericanExpress:
                    case PaymentInstrumentType.Discover:
                    case PaymentInstrumentType.JCB:
                    case PaymentInstrumentType.MasterCard:
                    case PaymentInstrumentType.Visa:
                    case PaymentInstrumentType.DinersClub:
                    case PaymentInstrumentType.Maestro:
                    case PaymentInstrumentType.SwitchSolo:
                    case PaymentInstrumentType.VisaDebit:
                        paymentInstrumentBuilder["AccountName"]     = CardName.Text;
                        paymentInstrumentBuilder["AccountNumber"]   = CardNumber.Text;
                        paymentInstrumentBuilder["ExpirationMonth"] = ExpirationMonth.SelectedItem.Value;
                        paymentInstrumentBuilder["ExpirationYear"]  = ExpirationYear.SelectedItem.Value;
                        paymentInstrumentBuilder["SecurityCode"]    = SecurityCode.Text;
                        if (IssueNumber.Text.Length > 0)
                        {
                            paymentInstrumentBuilder["IssueNumber"] = IssueNumber.Text;
                        }
                        if ((StartDateMonth.SelectedIndex > 0) && (StartDateYear.SelectedIndex > 0))
                        {
                            paymentInstrumentBuilder["StartDateMonth"] = StartDateMonth.SelectedItem.Value;
                            paymentInstrumentBuilder["StartDateYear"]  = StartDateYear.SelectedItem.Value;
                        }
                        payment.ReferenceNumber = StringHelper.MakeReferenceNumber(CardNumber.Text);
                        payment.Amount          = AlwaysConvert.ToDecimal(CreditCardPaymentAmount.Text);
                        break;

                    case PaymentInstrumentType.Check:
                        paymentInstrumentBuilder["RoutingNumber"] = RoutingNumber.Text;
                        paymentInstrumentBuilder["BankName"]      = BankName.Text;
                        paymentInstrumentBuilder["AccountHolder"] = AccountHolder.Text;
                        paymentInstrumentBuilder["AccountNumber"] = BankAccountNumber.Text;
                        payment.ReferenceNumber = StringHelper.MakeReferenceNumber(BankAccountNumber.Text);
                        payment.Amount          = AlwaysConvert.ToDecimal(CheckPaymentAmount.Text);
                        break;
                    }
                    if (payment.Amount > 0)
                    {
                        //ADD IN PAYMENT INSTRUMENT DATA FOR PROCESSING
                        payment.AccountData = paymentInstrumentBuilder.ToString();
                        payment.Authorize(false);
                        //REDIRECT TO PAYMENT PAGE
                        Response.Redirect("Default.aspx?OrderNumber=" + _Order.OrderNumber.ToString());
                    }
                }
            }
        }
Exemple #14
0
        private void SaveDiscount()
        {
            VolumeDiscount discount = _VolumeDiscount;

            discount.Name = _Product.Name;
            //LOOP THROUGH GRID ROWS AND SET MATRIX
            int rowIndex = 0;

            foreach (GridViewRow row in DiscountLevelGrid.Rows)
            {
                if (discount.Levels.Count < (rowIndex + 1))
                {
                    // ADD A NEW DISCOUNT LEVEL FOR NEW ROWS
                    VolumeDiscountLevel newDiscountLevel = new VolumeDiscountLevel();
                    newDiscountLevel.VolumeDiscountId = _VolumeDiscountId;
                    discount.Levels.Add(newDiscountLevel);
                }
                decimal             minValue       = AlwaysConvert.ToDecimal(((TextBox)row.FindControl("MinValue")).Text);
                decimal             maxValue       = AlwaysConvert.ToDecimal(((TextBox)row.FindControl("MaxValue")).Text);
                decimal             discountAmount = AlwaysConvert.ToDecimal(((TextBox)row.FindControl("DiscountAmount")).Text);
                bool                isPercent      = false;
                VolumeDiscountLevel thisLevel      = discount.Levels[rowIndex];
                thisLevel.MinValue       = minValue;
                thisLevel.MaxValue       = maxValue;
                thisLevel.DiscountAmount = discountAmount;
                thisLevel.IsPercent      = isPercent;
                rowIndex++;
            }
            //SCOPE
            discount.IsGlobal = false;
            discount.Save();
        }
Exemple #15
0
        protected void UpdateRanges()
        {
            //PROCESS MATRIX UPDATES
            int index = 0;

            foreach (GridViewRow row in RateMatrixGrid.Rows)
            {
                ShipRateMatrix matrixItem      = _ShipMethod.ShipRateMatrices[index];
                string         rangeStartValue = GetTextBoxValue(row, "RangeStart");
                if (!string.IsNullOrEmpty(rangeStartValue))
                {
                    matrixItem.RangeStart = AlwaysConvert.ToDecimal(rangeStartValue);
                }
                else
                {
                    matrixItem.RangeStart = null;
                }
                string rangeEndValue = GetTextBoxValue(row, "RangeEnd");
                if (!string.IsNullOrEmpty(rangeEndValue))
                {
                    matrixItem.RangeEnd = AlwaysConvert.ToDecimal(rangeEndValue);
                }
                else
                {
                    matrixItem.RangeEnd = null;
                }
                matrixItem.Rate      = AlwaysConvert.ToDecimal(GetTextBoxValue(row, "Rate"));
                matrixItem.IsPercent = GetCheckBoxValue(row, "IsPercent");
                index++;
            }
        }
 protected void SaveButton_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         // UPDATE THE SETTINGS
         StoreSettingsManager settings = AbleContext.Current.Store.Settings;
         settings.AffiliateParameterName   = StringHelper.Truncate(AffiliateParameter.Text.Trim(), 200);
         settings.AffiliateTrackerUrl      = StringHelper.Truncate(TrackerUrl.Text.Trim(), 200);
         settings.AffiliateAllowSelfSignup = SelfSignup.Checked;
         settings.AffiliateReferralRule    = AlwaysConvert.ToEnum <ReferralRule>(AffiliateReferralRule.SelectedValue, ReferralRule.NewSignupsOnly);
         settings.AffiliatePersistence     = ((AffiliateReferralPeriod)AlwaysConvert.ToByte(AffiliatePersistence.SelectedValue));
         AffiliateReferralPeriod referralPeriod = ((AffiliateReferralPeriod)AlwaysConvert.ToByte(AffiliatePersistence.SelectedValue));
         if ((referralPeriod != AffiliateReferralPeriod.Persistent && referralPeriod != AffiliateReferralPeriod.FirstOrder))
         {
             settings.AffiliateReferralPeriod = AlwaysConvert.ToInt16(ReferralPeriod.Text);
         }
         else
         {
             settings.AffiliateReferralPeriod = 0;
         }
         settings.AffiliateCommissionRate      = AlwaysConvert.ToDecimal(CommissionRate.Text);
         settings.AffiliateCommissionIsPercent = (CommissionType.SelectedIndex > 0);
         settings.AffiliateCommissionOnTotal   = (CommissionType.SelectedIndex == 2);
         settings.Save();
         AffiliateSettingsMessage.Text    = string.Format(AffiliateSettingsMessage.Text, LocaleHelper.LocalNow);
         AffiliateSettingsMessage.Visible = true;
     }
 }
Exemple #17
0
        protected void SubmitCaptureButton_Click(object sender, EventArgs e)
        {
            //GET THE CAPTURE AMOUNT
            decimal rem = _Payment.Transactions.GetRemainingAuthorized();
            decimal bal = _Order.GetBalance(false);
            string  originalCaptureAmount = string.Format("{0:F2}", rem > bal ? bal : rem);

            decimal captureAmount = AlwaysConvert.ToDecimal(CaptureAmount.Text);

            // AC8-2854: IF amount is not changed by merchant then
            // to avoid rounding issues, restore the original amount upto 4 decimal digits
            if (originalCaptureAmount == CaptureAmount.Text)
            {
                captureAmount = rem > bal ? bal : rem;
            }
            bool finalCapture = NoAdditionalCapture.Checked;

            if (captureAmount > 0)
            {
                _Payment.Capture(captureAmount, finalCapture, false);
                if (!string.IsNullOrEmpty(CustomerNote.Text))
                {
                    OrderNote note = new OrderNote(_Order.Id, AbleContext.Current.UserId, DateTime.UtcNow, CustomerNote.Text, NoteType.Public);
                    note.Save();
                }
            }
            Response.Redirect("Default.aspx?OrderNumber=" + _Order.OrderNumber.ToString());
        }
Exemple #18
0
 private decimal GetPaymentAmount()
 {
     if (Page.IsPostBack)
     {
         if (trAmount.Visible && !string.IsNullOrEmpty(Amount.Text))
         {
             return(AlwaysConvert.ToDecimal(Amount.Text));
         }
         else if (this.PaymentAmount > 0)
         {
             return(this.PaymentAmount);
         }
         else
         {
             return(_Basket.Items.TotalPrice());
         }
     }
     else
     {
         if (this.PaymentAmount > 0)
         {
             return(this.PaymentAmount);
         }
         return(_Basket.Items.TotalPrice());
     }
 }
Exemple #19
0
        protected decimal GetPrice(object dataItem)
        {
            WishlistItem item = (WishlistItem)dataItem;
            //DETERMINE THE BASE PRICE OF THE ITEM
            decimal price;

            if (item.Product.UseVariablePrice)
            {
                price = AlwaysConvert.ToDecimal(item.Price);
                if (price < item.Product.MinimumPrice)
                {
                    price = AlwaysConvert.ToDecimal(item.Product.MinimumPrice);
                }
                if (price > item.Product.MaximumPrice)
                {
                    price = AlwaysConvert.ToDecimal(item.Product.MaximumPrice);
                }
                item.Price = price;
            }
            else
            {
                // ADD PRICE OF KIT PRODUCTS AS WELL
                ProductCalculator c = ProductCalculator.LoadForProduct(item.Product.Id, 1, item.OptionList, item.KitList);
                price = c.Price;
            }
            return(price);
        }
        private void SaveOrder()
        {
            if (AlwaysConvert.ToInt16(ItemType.SelectedValue) == (Int16)OrderItemType.Coupon)
            {
                //IF IT IS A COUPON, VALIDATE THE ENTERED SKU ( COUPON CODE )
                if (CouponDataSource.LoadForCouponCode(Sku.Text) == null)
                {
                    CustomValidator skuValidator = new CustomValidator();
                    skuValidator.IsValid           = false;
                    skuValidator.ControlToValidate = "Sku";
                    skuValidator.ValidationGroup   = ValidationSummary.ValidationGroup;
                    skuValidator.ErrorMessage      = "Sku is not a valid coupon code.";
                    skuValidator.Text = "*";
                    phSkuValidators.Controls.Add(skuValidator);
                    return;
                }
            }
            //add the custom item
            OrderItem oi = new OrderItem();

            oi.OrderId         = _OrderId;
            oi.OrderItemTypeId = AlwaysConvert.ToInt16(ItemType.SelectedValue);
            if (_OrderShipment == null)
            {
                oi.OrderShipmentId = AlwaysConvert.ToInt(ShipmentsList.SelectedValue);
            }
            else
            {
                oi.OrderShipmentId = _OrderShipmentId;
            }
            oi.Name = Name.Text;
            oi.Sku  = Sku.Text;
            Decimal price = AlwaysConvert.ToDecimal(Price.Text);

            //We should not allow positive values for Discount or Credit.  We should not
            //  allow negative values for Charge.
            switch (oi.OrderItemTypeId)
            {
            case ((short)OrderItemType.Discount):
            case ((short)OrderItemType.Credit):
                if (price > 0)
                {
                    price = Decimal.Negate(price);
                }
                break;

            case ((short)OrderItemType.Charge):
                if (price < 0)
                {
                    price = Decimal.Negate(price);
                }
                break;
            }

            oi.Price    = price;
            oi.Quantity = AlwaysConvert.ToInt16(Quantity.Text);
            _Order.Items.Add(oi);
            _Order.Save(true, false);
        }
        private Transaction ProcessResponse(Payment payment, String sResponse, TransactionType transactionType)
        {
            //CREATE THE TRANSACTION OBJECT
            Transaction transaction = new Transaction();

            transaction.PaymentGatewayId = this.PaymentGatewayId;
            transaction.TransactionType  = transactionType;

            XmlDocument xmlresponse = new XmlDocument();

            xmlresponse.LoadXml(sResponse);

            string resultCode = XmlUtility.GetElementValue(xmlresponse.DocumentElement, "Page");

            transaction.TransactionStatus     = ((resultCode == "2000") || (resultCode == "90000")) ? TransactionStatus.Successful : TransactionStatus.Failed;
            transaction.ProviderTransactionId = XmlUtility.GetElementValue(xmlresponse.DocumentElement, "ReceiptNumber");
            transaction.TransactionDate       = DateTime.UtcNow;
            string amount = XmlUtility.GetElementValue(xmlresponse.DocumentElement, "TotalAmount");

            if (string.IsNullOrEmpty(amount))
            {
                transaction.Amount = payment.Amount;
            }
            else
            {
                transaction.Amount = AlwaysConvert.ToDecimal(amount, (decimal)payment.Amount);
            }
            if (transaction.TransactionStatus != TransactionStatus.Successful)
            {
                string errorMessage = XmlUtility.GetElementValue(xmlresponse.DocumentElement, "Error");
                if (string.IsNullOrEmpty(errorMessage))
                {
                    errorMessage = XmlUtility.GetElementValue(xmlresponse.DocumentElement, "Verbiage");
                }
                transaction.ResponseCode    = resultCode;
                transaction.ResponseMessage = errorMessage;
            }
            transaction.AuthorizationCode = XmlUtility.GetElementValue(xmlresponse.DocumentElement, "ApprovalCode") + ":" + XmlUtility.GetElementValue(xmlresponse.DocumentElement, "GUID");
            transaction.AVSResultCode     = XmlUtility.GetElementValue(xmlresponse.DocumentElement, "AVSResponseCode");
            if (string.IsNullOrEmpty(transaction.AVSResultCode))
            {
                transaction.AVSResultCode = "U";
            }
            transaction.CVVResultCode = XmlUtility.GetElementValue(xmlresponse.DocumentElement, "CVV2ResponseCode");
            if (string.IsNullOrEmpty(transaction.CVVResultCode))
            {
                transaction.CVVResultCode = "X";
            }
            HttpContext context = HttpContext.Current;

            if (context != null)
            {
                transaction.RemoteIP = context.Request.ServerVariables["REMOTE_ADDR"];
                transaction.Referrer = context.Request.ServerVariables["HTTP_REFERER"];
            }

            return(transaction);
        }
Exemple #22
0
 public override void Initialize(int ShipGatewayId, Dictionary <string, string> ConfigurationData)
 {
     base.Initialize(ShipGatewayId, ConfigurationData);
     //INITIALIZE MY FIELDS
     if (ConfigurationData.ContainsKey("AccountNumber"))
     {
         AccountNumber = ConfigurationData["AccountNumber"];
     }
     if (ConfigurationData.ContainsKey("MeterNumber"))
     {
         MeterNumber = ConfigurationData["MeterNumber"];
     }
     if (ConfigurationData.ContainsKey("EnablePackageBreakup"))
     {
         EnablePackageBreakup = AlwaysConvert.ToBool(ConfigurationData["EnablePackageBreakup"], true);
     }
     if (ConfigurationData.ContainsKey("MinPackageWeight"))
     {
         MinPackageWeight = AlwaysConvert.ToDecimal(ConfigurationData["MinPackageWeight"], (decimal)MinPackageWeight);
     }
     if (ConfigurationData.ContainsKey("MaxPackageWeight"))
     {
         MaxPackageWeight = AlwaysConvert.ToDecimal(ConfigurationData["MaxPackageWeight"], (decimal)MaxPackageWeight);
     }
     if (ConfigurationData.ContainsKey("IncludeDeclaredValue"))
     {
         IncludeDeclaredValue = AlwaysConvert.ToBool(ConfigurationData["IncludeDeclaredValue"], true);
     }
     if (ConfigurationData.ContainsKey("UseTestMode"))
     {
         UseTestMode = AlwaysConvert.ToBool(ConfigurationData["UseTestMode"], false);
     }
     if (ConfigurationData.ContainsKey("AccountActive"))
     {
         AccountActive = AlwaysConvert.ToBool(ConfigurationData["AccountActive"], false);
     }
     if (ConfigurationData.ContainsKey("DropOffType"))
     {
         DropOffType = (FDXDropOffType)AlwaysConvert.ToEnum(typeof(FDXDropOffType), ConfigurationData["DropOffType"], FDXDropOffType.REGULARPICKUP, true);
     }
     if (ConfigurationData.ContainsKey("PackagingType"))
     {
         PackagingType = (FDXPackagingType)AlwaysConvert.ToEnum(typeof(FDXPackagingType), ConfigurationData["PackagingType"], FDXPackagingType.YOURPACKAGING, true);
     }
     if (ConfigurationData.ContainsKey("TestModeUrl"))
     {
         TestModeUrl = ConfigurationData["TestModeUrl"];
     }
     if (ConfigurationData.ContainsKey("LiveModeUrl"))
     {
         LiveModeUrl = ConfigurationData["LiveModeUrl"];
     }
     if (ConfigurationData.ContainsKey("TrackingUrl"))
     {
         TrackingUrl = ConfigurationData["TrackingUrl"];
     }
 }
Exemple #23
0
        private void SaveWrapStyle()
        {
            WrapStyle style = WrapStyleDataSource.Load(WrapStyleId);

            style.Name         = Name.Text;
            style.ThumbnailUrl = ThumbnailUrl.Text;
            style.ImageUrl     = ImageUrl.Text;
            style.Price        = AlwaysConvert.ToDecimal(Price.Text);
            style.TaxCodeId    = AlwaysConvert.ToInt(TaxCode.SelectedValue);
            style.Save();
        }
Exemple #24
0
        private void SaveShipGateWay()
        {
            AustraliaPost provider = (AustraliaPost)_ShipGateway.GetProviderInstance();

            provider.UseDebugMode         = UseDebugMode.Checked;
            provider.EnablePackageBreakup = EnablePackaging.Checked;
            provider.MaxPackageWeight     = AlwaysConvert.ToDecimal(MaxWeight.Text, (decimal)provider.MaxPackageWeight);
            provider.MinPackageWeight     = AlwaysConvert.ToDecimal(MinWeight.Text, (decimal)provider.MinPackageWeight);
            _ShipGateway.UpdateConfigData(provider.GetConfigData());
            _ShipGateway.Save();
        }
Exemple #25
0
        protected void SaveButton_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                _Affiliate.Name                = Name.Text;
                _Affiliate.ReferralDays        = AlwaysConvert.ToInt16(ReferralDays.Text);
                _Affiliate.CommissionRate      = AlwaysConvert.ToDecimal(CommissionRate.Text);
                _Affiliate.CommissionIsPercent = (CommissionType.SelectedIndex > 0);
                _Affiliate.CommissionOnTotal   = (CommissionType.SelectedIndex == 2);
                _Affiliate.WebsiteUrl          = WebsiteUrl.Text;
                _Affiliate.Email               = Email.Text;
                _Affiliate.Group               = GroupDataSource.Load(AlwaysConvert.ToInt(AffiliateGroup.SelectedValue));

                AffiliateReferralPeriod referralPeriod = (AffiliateReferralPeriod)AlwaysConvert.ToByte(ReferralPeriod.SelectedValue);
                _Affiliate.ReferralPeriodId = (byte)referralPeriod;
                _Affiliate.ReferralPeriod   = referralPeriod;

                if (referralPeriod != AffiliateReferralPeriod.Persistent && referralPeriod != AffiliateReferralPeriod.FirstOrder)
                {
                    _Affiliate.ReferralDays = AlwaysConvert.ToInt16(ReferralDays.Text);
                }
                else
                {
                    _Affiliate.ReferralDays = 0;
                }

                //ADDRESS INFORMATION
                _Affiliate.FirstName    = FirstName.Text;
                _Affiliate.LastName     = LastName.Text;
                _Affiliate.Company      = Company.Text;
                _Affiliate.Address1     = Address1.Text;
                _Affiliate.Address2     = Address2.Text;
                _Affiliate.City         = City.Text;
                _Affiliate.Province     = Province.Text;
                _Affiliate.PostalCode   = PostalCode.Text;
                _Affiliate.CountryCode  = CountryCode.SelectedValue;
                _Affiliate.PhoneNumber  = PhoneNumber.Text;
                _Affiliate.FaxNumber    = FaxNumber.Text;
                _Affiliate.MobileNumber = MobileNumber.Text;
                _Affiliate.Save();

                // SAVE TAX ID
                User user = _Affiliate.Group != null && _Affiliate.Group.Users.Count > 0 ? _Affiliate.Group.Users[0] : null;
                if (user != null)
                {
                    user.TaxExemptionReference = TaxId.Text;
                    user.Save();
                }

                SavedMessage.Visible = true;
                SavedMessage.Text    = string.Format(SavedMessage.Text, LocaleHelper.LocalNow);
            }
        }
        private void SaveDiscount()
        {
            VolumeDiscount discount = _VolumeDiscount;

            discount.Name         = Name.Text;
            discount.IsValueBased = IsValueBased.SelectedIndex == 1 ? true : false;
            //LOOP THROUGH GRID ROWS AND SET MATRIX
            int rowIndex = 0;

            foreach (GridViewRow row in DiscountLevelGrid.Rows)
            {
                if (discount.Levels.Count < (rowIndex + 1))
                {
                    // ADD A NEW DISCOUNT LEVEL FOR NEW ROWS
                    VolumeDiscountLevel newDiscountLevel = new VolumeDiscountLevel();
                    newDiscountLevel.Id = _VolumeDiscountId;
                    discount.Levels.Add(newDiscountLevel);
                }
                decimal             minValue       = AlwaysConvert.ToDecimal(((TextBox)row.FindControl("MinValue")).Text);
                decimal             maxValue       = AlwaysConvert.ToDecimal(((TextBox)row.FindControl("MaxValue")).Text);
                decimal             discountAmount = AlwaysConvert.ToDecimal(((TextBox)row.FindControl("DiscountAmount")).Text);
                bool                isPercent      = (((DropDownList)row.FindControl("IsPercent")).SelectedIndex == 0);
                VolumeDiscountLevel thisLevel      = discount.Levels[rowIndex];
                thisLevel.MinValue       = minValue;
                thisLevel.MaxValue       = maxValue;
                thisLevel.DiscountAmount = discountAmount;
                thisLevel.IsPercent      = isPercent;
                thisLevel.Save();
                rowIndex++;
            }
            //SCOPE
            discount.IsGlobal = (UseGlobalScope.SelectedIndex == 0);
            //GROUP RESTRICTION
            if (UseGroupRestriction.SelectedIndex > 0)
            {
                _VolumeDiscount.Groups.Clear();
                _VolumeDiscount.Save();
                foreach (ListItem item in GroupList.Items)
                {
                    Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value));
                    if (item.Selected)
                    {
                        _VolumeDiscount.Groups.Add(group);
                    }
                }
            }
            else
            {
                _VolumeDiscount.Groups.Clear();
            }
            discount.Save();
        }
Exemple #27
0
        protected string GetPrice(object dataItem)
        {
            //DETERMINE THE BASE PRICE OF THE ITEM
            WishlistItem item = (WishlistItem)dataItem;
            decimal      price;

            if (item.Product.IsSubscription && item.Product.SubscriptionPlan.IsOptional)
            {
                ProductCalculator c = ProductCalculator.LoadForProduct(item.Product.Id, 1, item.OptionList, item.KitList, AbleContext.Current.UserId, false, !item.IsSubscription);
                price = c.Price;
            }
            else
            {
                if (item.Product.UseVariablePrice)
                {
                    price = AlwaysConvert.ToDecimal(item.Price);
                    if (price < item.Product.MinimumPrice)
                    {
                        price = AlwaysConvert.ToDecimal(item.Product.MinimumPrice);
                    }
                    if (price > item.Product.MaximumPrice)
                    {
                        price = AlwaysConvert.ToDecimal(item.Product.MaximumPrice);
                    }
                    item.Price = price;
                }
                else
                {
                    // ADD PRICE OF KIT PRODUCTS AS WELL
                    ProductCalculator c = ProductCalculator.LoadForProduct(item.Product.Id, 1, item.OptionList, item.KitList);
                    price = c.Price;
                }
            }

            if (item.Product.VolumeDiscounts.Count > 0)
            {
                foreach (var rec in item.Product.VolumeDiscounts[0].Levels)
                {
                    if (item.Desired >= rec.MinValue && item.Desired <= rec.MaxValue)
                    {
                        return((rec.DiscountAmount).LSCurrencyFormat("ulc") + " ea.");
                    }
                }
            }

            decimal shopPrice = TaxHelper.GetShopPrice(price, item.Product.TaxCode != null ? item.Product.TaxCode.Id : 0);

            return(shopPrice > 0 ? shopPrice.LSCurrencyFormat("ulc") + " ea." : "");
        }
        protected void CreateCurrency()
        {
            if (Page.IsValid)
            {
                Currency currency = new Currency();
                currency.Name             = Name.Text;
                currency.ExchangeRate     = AlwaysConvert.ToDecimal(ExchangeRate.Text, 1M);
                currency.AutoUpdate       = AutoUpdate.Checked;
                currency.ISOCode          = ISOCode.Text;
                currency.ISOCodePattern   = (byte)ISOCodePattern.SelectedIndex;
                currency.CurrencySymbol   = CurrencySymbol.Text;
                currency.PositivePattern  = (byte)PositivePattern.SelectedIndex;
                currency.NegativePattern  = (byte)NegativePattern.SelectedIndex;
                currency.NegativeSign     = NegativeSign.Text;
                currency.DecimalSeparator = DecimalSeparator.Text;
                currency.DecimalDigits    = AlwaysConvert.ToInt(DecimalDigits.Text);
                currency.GroupSeparator   = GroupSeparator.Text;
                currency.GroupSizes       = GroupSizes.Text;
                currency.Save();
                if (currency.AutoUpdate)
                {
                    currency.UpdateExchangeRate(false);
                }


                //RESET FORM
                Name.Text = string.Empty;
                Name.Focus();
                ExchangeRate.Text             = "1";
                AutoUpdate.Checked            = true;
                ManualUpdate.Checked          = false;
                ISOCode.Text                  = string.Empty;
                ISOCodePattern.SelectedIndex  = 0;
                CurrencySymbol.Text           = "$";
                PositivePattern.SelectedIndex = 0;
                NegativePattern.SelectedIndex = 1;
                NegativeSign.Text             = "-";
                DecimalSeparator.Text         = ".";
                DecimalDigits.Text            = "2";
                GroupSeparator.Text           = ",";
                GroupSizes.Text               = "3";
                if (ItemAdded != null)
                {
                    ItemAdded(this, new PersistentItemEventArgs(currency.Id, currency.Name));
                }
                HideDisplayOptions_Click(null, null);
            }
        }
        public void Load(ISiteMapOptionKeys settingKeys)
        {
            StoreSettingCollection settings = Token.Instance.Store.Settings;

            _CompressedSiteMapFileName = settings.GetValueByKey(settingKeys.CompressedSiteMapFileName);
            _SiteMapDataPath           = settings.GetValueByKey(settingKeys.SiteMapDataPath);
            _SiteMapFileName           = settings.GetValueByKey(settingKeys.SiteMapFileName);
            _IncludeProducts           = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.IncludeProducts), true);
            _IncludeCategories         = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.IncludeCategories), true);
            _IncludeWebpages           = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.IncludeWebpages), true);
            _OverwriteCompressedFile   = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.OverwriteCompressedFile), true);
            _OverwriteSiteMapFile      = AlwaysConvert.ToBool(settings.GetValueByKey(settingKeys.OverwriteSiteMapFile), true);
            _DefaultChangeFrequency    = (changefreq)AlwaysConvert.ToEnum(typeof(changefreq), settings.GetValueByKey(settingKeys.DefaultChangeFrequency), changefreq.weekly);
            _DefaultUrlPriority        = AlwaysConvert.ToDecimal(settings.GetValueByKey(settingKeys.DefaultUrlPriority), 0.5M);
            IsDirty = false;
        }
        private void SaveShipGateWayProvider()
        {
            CanadaPost provider = (CanadaPost)_ShipGateway.GetProviderInstance();

            provider.UseDebugMode         = UseDebugMode.Checked;
            provider.UseTestMode          = UseTestMode.Checked;
            provider.EnablePackageBreakup = EnablePackaging.Checked;
            provider.MerchantCPCID        = MerchantId.Text;
            provider.LiveModeUrl          = LiveServerURL.Text;
            provider.TestModeUrl          = TestServerURL.Text;
            provider.TrackingUrl          = TrackingURL.Text;
            provider.MaxPackageWeight     = AlwaysConvert.ToDecimal(MaxWeight.Text, (decimal)provider.MaxPackageWeight);
            provider.MinPackageWeight     = AlwaysConvert.ToDecimal(MinWeight.Text, (decimal)provider.MinPackageWeight);
            _ShipGateway.UpdateConfigData(provider.GetConfigData());
            _ShipGateway.Save();
        }