Beispiel #1
0
        /// <summary>
        /// Determines whether fulltext search is installed on the server
        /// </summary>
        /// <param name="logError">If true, exceptions thrown by the database are logged to the AbleCommerce error log.</param>
        /// <returns>True if fulltext search is installed; false otherwise.</returns>
        public static bool IsFullTextSearchInstalled(bool logError)
        {
            // QUERY DATABASE TO SEE WHETHER FULLTEXT IS INSTALLED
            Database database = Token.Instance.Database;
            string   sql      = "SELECT ServerProperty('IsFullTextInstalled')";

            try
            {
                DbCommand command = database.GetSqlStringCommand(sql);
                return(AlwaysConvert.ToInt(database.ExecuteScalar(command)) == 1);
            }
            catch (SqlException se)
            {
                if (logError)
                {
                    Logger.Warn("Could not detect if FTS is installed.", se);
                }
                return(false);
            }
        }
        protected string GetAvailableQuantity(object dataItem)
        {
            BasketItem item = (BasketItem)dataItem;

            if (_StoreInventoryEnabled && item.Product != null && item.Product.InventoryMode != InventoryMode.None)
            {
                List <int> kitList = null;
                if (!string.IsNullOrEmpty(item.KitList))
                {
                    kitList = new List <int>();
                    kitList.AddRange(AlwaysConvert.ToIntArray(item.KitList));
                }
                InventoryManagerData inv = _InventoryManager.CheckStock(item.ProductId, item.OptionList, kitList);
                return(inv.InStock.ToString());
            }
            else
            {
                return("n/a");
            }
        }
 protected void DigitalGoodGrid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "Copy")
     {
         int         dgid        = AlwaysConvert.ToInt(e.CommandArgument);
         DigitalGood digitalGood = DigitalGoodDataSource.Load(dgid);
         DigitalGood copy        = digitalGood.Copy();
         if (copy != null)
         {
             String newName = "Copy of " + copy.Name;
             if (newName.Length > 100)
             {
                 newName = newName.Substring(0, 97) + "...";
             }
             copy.Name = newName;
             copy.Save();
         }
         DigitalGoodGrid.DataBind();
     }
 }
        protected void InitAddressBook()
        {
            //REARRANGE THE ADDRESSES SO THAT THE PRIMARY ADDRESS DISPLAYS FIRST
            //AND THE REMAINING ADDRESSES ARE IN ALPHABETICAL ORDER BY LAST NAME
            IList <Address> addresses = AbleContext.Current.User.Addresses;

            addresses.Sort("LastName");
            int defaultIndex = addresses.IndexOf(AlwaysConvert.ToInt(AbleContext.Current.User.PrimaryAddressId));

            if (defaultIndex > 0)
            {
                Address tempAddress = addresses[defaultIndex];
                addresses.RemoveAt(defaultIndex);
                addresses.Insert(0, tempAddress);
            }
            //BIND THE ADDRESSES TO THE DATALIST
            ShipToAddressList.DataSource = AbleContext.Current.User.Addresses;
            ShipToAddressList.DataBind();
            AddressValidationPanel.Visible = _addressValidator != null;
        }
Beispiel #5
0
 /// <summary>
 /// Determines whether full text search is enabled on the current database
 /// </summary>
 /// <param name="logError">If true, exceptions thrown by the database are logged to the AbleCommerce error log.</param>
 /// <returns>True if fulltext search is enabled on the current database; false otherwise.</returns>
 public static bool IsFullTextSearchEnabled(bool logError)
 {
     try
     {
         // QUERY DATABASE TO SEE WHETHER FULLTEXT IS ENABLED
         Database  database     = Token.Instance.Database;
         string    databaseName = DatabaseHelper.GetCurrentDatabaseName();
         string    sql          = "SELECT DatabaseProperty('" + databaseName + "', 'IsFullTextEnabled')";
         DbCommand command      = database.GetSqlStringCommand(sql);
         return(AlwaysConvert.ToInt(database.ExecuteScalar(command)) == 1);
     }
     catch (SqlException se)
     {
         if (logError)
         {
             Logger.Warn("Could not detect if FTS is enabled.", se);
         }
         return(false);
     }
 }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _SubscriptionId = AlwaysConvert.ToInt(Request.QueryString["SubscriptionId"]);
            _Subscription   = SubscriptionDataSource.Load(_SubscriptionId);
            if (_Subscription == null)
            {
                Response.Redirect(AbleCommerce.Code.NavigationHelper.GetAdminUrl("Catalog/Browse.aspx"));
            }
            _returnUrl = GetReturnUrl();
            _Product   = _Subscription.Product;

            Caption.Text = string.Format(Caption.Text, _Product.Name);

            if (!Page.IsPostBack)
            {
                InitFormValues();
            }

            CancelButton.NavigateUrl = _returnUrl;
        }
Beispiel #7
0
 public override void Initialize(int PaymentGatewayId, Dictionary <string, string> ConfigurationData)
 {
     base.Initialize(PaymentGatewayId, ConfigurationData);
     if (ConfigurationData.ContainsKey("UseAuthCapture"))
     {
         UseAuthCapture = AlwaysConvert.ToBool(ConfigurationData["UseAuthCapture"], true);
     }
     if (ConfigurationData.ContainsKey("UseTestMode"))
     {
         UseTestMode = AlwaysConvert.ToBool(ConfigurationData["UseTestMode"], true);
     }
     if (ConfigurationData.ContainsKey("LoginName"))
     {
         LoginName = ConfigurationData["LoginName"];
     }
     if (ConfigurationData.ContainsKey("Password"))
     {
         Password = ConfigurationData["Password"];
     }
 }
Beispiel #8
0
 protected void SaveButton_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         EmailList list = new EmailList();
         list.Name                  = Name.Text;
         list.IsPublic              = IsPublic.Checked;
         list.Description           = StringHelper.Truncate(Description.Text, 250);
         list.SignupRule            = (EmailListSignupRule)Enum.Parse(typeof(EmailListSignupRule), SignupRule.SelectedValue);
         list.SignupEmailTemplateId = AlwaysConvert.ToInt(SignupEmailTemplate.SelectedValue);
         list.Save();
         if (ItemAdded != null)
         {
             ItemAdded(this, new PersistentItemEventArgs(list.Id, list.Name));
         }
         AddedMessage.Visible = true;
         AddedMessage.Text    = string.Format(AddedMessage.Text, list.Name);
         ResetForm();
     }
 }
        protected void RemoveButton_Click(object sender, EventArgs e)
        {
            ImageButton removeButton  = (ImageButton)sender;
            int         dataItemIndex = AlwaysConvert.ToInt(removeButton.CommandArgument);
            GridView    grid          = PG;
            int         productId     = (int)grid.DataKeys[dataItemIndex].Value;

            if (OnAssignProduct != null)
            {
                OnAssignProduct(this, new FindAssignProductEventArgs(productId, false));
            }
            ImageButton attachButton = removeButton.Parent.FindControl("AttachButton") as ImageButton;

            if (attachButton != null)
            {
                attachButton.Visible = true;
            }
            removeButton.Visible = false;
            PG.DataBind();
        }
        protected void Page_Load(object sender, System.EventArgs e)
        {
            int optionId = AlwaysConvert.ToInt(Request.QueryString["OptionId"]);

            _Option = OptionDataSource.Load(optionId);
            if (_Option == null)
            {
                Response.Redirect("Options.aspx?ProductId=" + AbleCommerce.Code.PageHelper.GetProductId());
            }
            if (!Page.IsPostBack)
            {
                // initialize the form on first visit
                OptionName.Text        = _Option.Name;
                HeaderText.Text        = _Option.HeaderText;
                ShowThumbnails.Checked = _Option.ShowThumbnails;
                ThumbnailWidth.Text    = _Option.ThumbnailWidth > 0 ? _Option.ThumbnailWidth.ToString() : string.Empty;
                ThumbnailHeight.Text   = _Option.ThumbnailHeight > 0 ? _Option.ThumbnailHeight.ToString() : string.Empty;
                ThumbnailColumns.Text  = _Option.ThumbnailColumns > 0 ? _Option.ThumbnailColumns.ToString() : string.Empty;
            }
        }
        /// <summary>
        /// Parses an option list to an int array
        /// </summary>
        /// <param name="optionList"></param>
        /// <returns></returns>
        public static int[] ParseOptionList(string optionList)
        {
            optionList = ValidateOptionList(optionList);
            if (string.IsNullOrEmpty(optionList))
            {
                return(null);
            }
            string[]   choices    = optionList.Split(',');
            List <int> choiceList = new List <int>();

            foreach (string choice in choices)
            {
                int choiceId = AlwaysConvert.ToInt(choice.Trim());
                if (choiceId != 0)
                {
                    choiceList.Add(choiceId);
                }
            }
            return(choiceList.ToArray());
        }
Beispiel #12
0
 protected void UpsellProductGrid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "MoveUp")
     {
         IList <UpsellProduct> UpsellProducts = _Product.UpsellProducts;
         int itemIndex = AlwaysConvert.ToInt(e.CommandArgument);
         if ((itemIndex < 1) || (itemIndex > UpsellProducts.Count - 1))
         {
             return;
         }
         UpsellProduct selectedItem = UpsellProducts[itemIndex];
         UpsellProduct swapItem     = UpsellProducts[itemIndex - 1];
         UpsellProducts.RemoveAt(itemIndex - 1);
         UpsellProducts.Insert(itemIndex, swapItem);
         for (int i = 0; i < UpsellProducts.Count; i++)
         {
             UpsellProducts[i].OrderBy = (short)i;
         }
         UpsellProducts.Save();
         UpsellProductGrid.DataBind();
     }
     else if (e.CommandName == "MoveDown")
     {
         IList <UpsellProduct> UpsellProducts = _Product.UpsellProducts;
         int itemIndex = AlwaysConvert.ToInt(e.CommandArgument);
         if ((itemIndex > UpsellProducts.Count - 2) || (itemIndex < 0))
         {
             return;
         }
         UpsellProduct selectedItem = UpsellProducts[itemIndex];
         UpsellProduct swapItem     = UpsellProducts[itemIndex + 1];
         UpsellProducts.RemoveAt(itemIndex + 1);
         UpsellProducts.Insert(itemIndex, swapItem);
         for (int i = 0; i < UpsellProducts.Count; i++)
         {
             UpsellProducts[i].OrderBy = (short)i;
         }
         UpsellProducts.Save();
         UpsellProductGrid.DataBind();
     }
 }
Beispiel #13
0
        private void Save()
        {
            _Subscription.Name = SubscriptionName.Text;
            int selectedGroupId = AlwaysConvert.ToInt(SubscriptionGroup.SelectedValue);

            _Subscription.GroupId  = selectedGroupId;
            _Subscription.IsActive = Active.Checked;
            short frequency = AlwaysConvert.ToInt16(Frequency.Text);

            // IF PAYMENT FREQUENCY IS CHANGED BY MERCHANT
            if (trFrequency.Visible && frequency > 0 && _Subscription.PaymentFrequency != frequency)
            {
                _Subscription.PaymentFrequency = frequency;

                // RECALCULATE NEXT ORDER DATE ACCORDING TO NEW FREQUENCY VALUE
                _Subscription.RecalculateNextOrderDueDate();

                // RECALCULATE EXPIRATION ACCORDING TO NEW FREQUENCY VALUE
                _Subscription.RecalculateExpiration();
            }

            short numberOfPayments = AlwaysConvert.ToInt16(NumberOfPayments.Text);

            if (numberOfPayments != _Subscription.NumberOfPayments)
            {
                _Subscription.NumberOfPayments = numberOfPayments;
                _Subscription.RecalculateExpiration();
            }

            try
            {
                EmailProcessor.NotifySubscriptionUpdated(_Subscription);
            }
            catch (Exception ex)
            {
                Logger.Error("Error sending subscription updated email.", ex);
            }

            _Subscription.Save();
            InitFormValues();
        }
Beispiel #14
0
 public override void Initialize(int ShipGatewayId, Dictionary <string, string> ConfigurationData)
 {
     base.Initialize(ShipGatewayId, ConfigurationData);
     //INITIALIZE MY FIELDS
     if (ConfigurationData.ContainsKey("MerchantCPCID"))
     {
         MerchantCPCID = ConfigurationData["MerchantCPCID"];
     }
     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("UseTestMode"))
     {
         UseTestMode = AlwaysConvert.ToBool(ConfigurationData["UseTestMode"], false);
     }
     if (ConfigurationData.ContainsKey("AccountActive"))
     {
         AccountActive = AlwaysConvert.ToBool(ConfigurationData["AccountActive"], false);
     }
     if (ConfigurationData.ContainsKey("TestModeUrl"))
     {
         TestModeUrl = ConfigurationData["TestModeUrl"];
     }
     if (ConfigurationData.ContainsKey("LiveModeUrl"))
     {
         LiveModeUrl = ConfigurationData["LiveModeUrl"];
     }
     if (ConfigurationData.ContainsKey("TrackingUrl"))
     {
         TrackingUrl = ConfigurationData["TrackingUrl"];
     }
 }
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            GridView grid = SearchResultsGrid;

            foreach (GridViewRow row in grid.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    int dataItemIndex = row.DataItemIndex;
                    dataItemIndex = (dataItemIndex - (grid.PageSize * grid.PageIndex));
                    int     productId = (int)grid.DataKeys[dataItemIndex].Value;
                    Product product   = ProductDataSource.Load(productId);
                    if (product == null)
                    {
                        continue;
                    }
                    DropDownList crossSellState = (DropDownList)grid.Rows[row.RowIndex].FindControl("CrossSellState");
                    int          state          = AlwaysConvert.ToInt(crossSellState.SelectedValue);
                    switch (state)
                    {
                    case 0:
                        AdjustCrossSellLinking(_Product.Id, product.Id, CrossSellState.Unlinked);
                        break;

                    case 1:
                        AdjustCrossSellLinking(_Product.Id, product.Id, CrossSellState.CrossLinked);
                        break;

                    case 2:
                        AdjustCrossSellLinking(_Product.Id, product.Id, CrossSellState.LinksTo);
                        break;

                    case 3:
                        AdjustCrossSellLinking(_Product.Id, product.Id, CrossSellState.LinkedFrom);
                        break;
                    }
                }
            }
            grid.DataBind();
            SavedMessage.Visible = true;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            _profileId = AlwaysConvert.ToInt(Request.QueryString["ProfileId"]);
            _profile   = GatewayPaymentProfileDataSource.Load(_profileId);

            if (_profile == null || _profile.User != AbleContext.Current.User)
            {
                Response.Redirect("PaymentTypes.aspx");
            }

            if (!Page.IsPostBack)
            {
                CardType.Text   = _profile.InstrumentType.ToString();
                CardName.Text   = _profile.NameOnCard;
                CardNumber.Text = _profile.ReferenceNumber.PadLeft(8, 'x').ToUpper();

                // POPULATE EXPIRATON DATE DROPDOWN
                int thisYear = LocaleHelper.LocalNow.Year;
                for (int i = 0; (i <= 10); i++)
                {
                    ExpirationYear.Items.Add(new ListItem((thisYear + i).ToString()));
                }

                DateTime expirationDate = _profile.Expiry ?? DateTime.MinValue;
                if (expirationDate != DateTime.MinValue)
                {
                    string   eMonth = expirationDate.Month.ToString().PadLeft(2, '0');
                    string   eYear  = expirationDate.Year.ToString();
                    ListItem item   = ExpirationYear.Items.FindByValue(eYear);
                    if (item != null)
                    {
                        item.Selected = true;
                    }
                    item = ExpirationMonth.Items.FindByValue(eMonth);
                    if (item != null)
                    {
                        item.Selected = true;
                    }
                }
            }
        }
Beispiel #17
0
 /// <summary>
 /// Moves the source wishlist to the target wishlist.
 /// </summary>
 /// <param name="sourceId">The ID of the user with the source wishlist.</param>
 /// <param name="targetId">The ID of the user to transfer the wishlist to.</param>
 /// <param name="transferEmptyWishlist">If false, the wishlist is not transferred when the source wishlist is empty.  If true, the wishlist is always transferred.</param>
 /// <remarks>Any existing contents of the target wishlist are removed prior to transfer.</remarks>
 public static void Transfer(int sourceId, int targetId, bool transferEmptyWishlist)
 {
     if (sourceId != targetId)
     {
         //GET THE DEFAULT BASKET FOR THE SOURCE USER
         WishlistCollection sourceWishlists = WishlistDataSource.LoadForUser(sourceId);
         if (sourceWishlists.Count == 0)
         {
             return;
         }
         Wishlist sourceWishlist = sourceWishlists[0];
         if (!transferEmptyWishlist)
         {
             //WE SHOULD NOT TRANSFER EMPTY BASKETS, COUNT THE SOURCE ITEMS
             int sourceCount = WishlistItemDataSource.CountForWishlist(sourceWishlist.WishlistId);
             if (sourceCount == 0)
             {
                 return;
             }
         }
         //DETERMINE WHETHER USER HAS A WISHLIST ALREADY
         Database  database = Token.Instance.Database;
         DbCommand command  = database.GetSqlStringCommand("SELECT WishlistId FROM ac_Wishlists WHERE UserId = @targetId");
         database.AddInParameter(command, "@targetId", System.Data.DbType.Int32, targetId);
         int targetWishlistId = AlwaysConvert.ToInt(database.ExecuteScalar(command));
         if (targetWishlistId == 0)
         {
             //USER HAS NO WISHLIST, SO MOVE THE SOURCE WISHLIST TO NEW USER
             sourceWishlist.UserId = targetId;
             sourceWishlist.Save();
         }
         else
         {
             //USER HAS A WISHLIST, JUST MOVE ITEMS FROM SOURCE TO TARGET
             command = database.GetSqlStringCommand("UPDATE ac_WishlistItems SET WishlistId = @targetWishlistId WHERE WishlistId = @sourceWishlistId");
             database.AddInParameter(command, "@targetWishlistId", System.Data.DbType.Int32, targetWishlistId);
             database.AddInParameter(command, "@sourceWishlistId", System.Data.DbType.Int32, sourceWishlist.WishlistId);
             database.ExecuteNonQuery(command);
         }
     }
 }
        /// <summary>
        /// Determines the category context for the current request.
        /// </summary>
        /// <returns>The category context for the current request.</returns>
        private static int GetCategoryId()
        {
            HttpRequest request    = HttpContext.Current.Request;
            int         categoryId = AlwaysConvert.ToInt(request.QueryString["CategoryId"]);

            if (categoryId != 0)
            {
                return(categoryId);
            }
            int productId = GetProductId();

            if (productId != 0)
            {
                categoryId = CatalogDataSource.GetCategoryId(productId, CatalogNodeType.Product);
                if (categoryId != 0)
                {
                    return(categoryId);
                }
            }
            int webpageId = GetWebpageId();

            if (webpageId != 0)
            {
                categoryId = CatalogDataSource.GetCategoryId(webpageId, CatalogNodeType.Webpage);
                if (categoryId != 0)
                {
                    return(categoryId);
                }
            }
            int linkId = GetLinkId();

            if (linkId != 0)
            {
                categoryId = CatalogDataSource.GetCategoryId(linkId, CatalogNodeType.Link);
                if (categoryId != 0)
                {
                    return(categoryId);
                }
            }
            return(0);
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            _ProductId  = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
            _Product    = ProductDataSource.Load(_ProductId);
            _CategoryId = AbleCommerce.Code.PageHelper.GetCategoryId();
            if (_Product == null)
            {
                Response.Redirect("../../Catalog/Browse.aspx?CategoryId=" + _CategoryId);
            }

            // PREVENT CREATION OF RECURSIVE KITS (MEMBER PRODUCTS CANNOT BE MASTER PRODUCTS)
            if (_Product.KitStatus == KitStatus.Member)
            {
                Response.Redirect("ViewKitProduct.aspx?CategoryId=" + _CategoryId + "&ProductId=" + _ProductId.ToString());
            }
            _Kit = _Product.Kit;

            // INITIALIZE PAGE ELEMENTS
            Caption.Text = string.Format(Caption.Text, _Product.Name);
            SortComponents.NavigateUrl += "?ProductId=" + _ProductId;
            if (!Page.IsPostBack)
            {
                if (_Kit != null)
                {
                    ItemizedDisplayOption.SelectedIndex = _Kit.ItemizeDisplay ? 1 : 0;
                }
            }
            AttachLink.NavigateUrl += "?CategoryId=" + _CategoryId + "&ProductId=" + _ProductId;

            // POPULATE THE ADD COMPONENT INPUT TYPE LIST
            foreach (string inputName in Enum.GetNames(typeof(KitInputType)))
            {
                AddComponentInputTypeId.Items.Add(new ListItem(FixInputTypeName(inputName), Enum.Parse(typeof(KitInputType), inputName).ToString()));
            }
            AddComponentInputTypeId.SelectedIndex = 1;

            if (Page.IsPostBack)
            {
                BindComponentList();
            }
        }
Beispiel #20
0
        private int SaveShippingAddress()
        {
            //UPDATE THE FIELDS FROM FORM
            Address shippingAddress = GetShippingAddress();

            shippingAddress.UserId      = _UserId;
            shippingAddress.FirstName   = StringHelper.StripHtml(ShipToFirstName.Text);
            shippingAddress.LastName    = StringHelper.StripHtml(ShipToLastName.Text);
            shippingAddress.Company     = StringHelper.StripHtml(ShipToCompany.Text);
            shippingAddress.Address1    = StringHelper.StripHtml(ShipToAddress1.Text);
            shippingAddress.Address2    = StringHelper.StripHtml(ShipToAddress2.Text);
            shippingAddress.City        = StringHelper.StripHtml(ShipToCity.Text);
            shippingAddress.Province    = ShipToProvinceList.Visible ? ShipToProvinceList.SelectedValue : StringHelper.StripHtml(ShipToProvince.Text);
            shippingAddress.PostalCode  = StringHelper.StripHtml(ShipToPostalCode.Text);
            shippingAddress.CountryCode = ShipToCountry.SelectedValue;
            shippingAddress.Residence   = (AlwaysConvert.ToInt(ShipToAddressType.SelectedValue) == 1);
            shippingAddress.Phone       = StringHelper.StripHtml(ShipToPhone.Text);
            shippingAddress.Save();
            _User.Addresses.Add(shippingAddress);
            return(shippingAddress.Id);
        }
Beispiel #21
0
 public override void Initialize(int ShipGatewayId, Dictionary <string, string> ConfigurationData)
 {
     base.Initialize(ShipGatewayId, ConfigurationData);
     //INITIALIZE MY FIELDS
     if (ConfigurationData.ContainsKey("EnablePackageBreakup"))
     {
         EnablePackageBreakup = AlwaysConvert.ToBool(ConfigurationData["EnablePackageBreakup"], true);
     }
     if (ConfigurationData.ContainsKey("AccountActive"))
     {
         AccountActive = AlwaysConvert.ToBool(ConfigurationData["AccountActive"], false);
     }
     if (ConfigurationData.ContainsKey("MinPackageWeight"))
     {
         MinPackageWeight = AlwaysConvert.ToDecimal(ConfigurationData["MinPackageWeight"], (decimal)MinPackageWeight);
     }
     if (ConfigurationData.ContainsKey("MaxPackageWeight"))
     {
         MaxPackageWeight = AlwaysConvert.ToDecimal(ConfigurationData["MaxPackageWeight"], (decimal)MaxPackageWeight);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            _CategoryId = AlwaysConvert.ToInt(Request.QueryString["CategoryId"]);
            InitializeCatalogItems();

            // INITIALIZE ICON PATH
            _IconPath = AbleCommerce.Code.PageHelper.GetAdminThemeIconPath(this.Page);

            CGrid.DataSource = _CatalogItems;
            CGrid.DataBind();

            if (!Page.IsPostBack)
            {
                // Caption.Text = string.Format(Caption.Text, CatalogNode.Name);

                // SET THE CURRENT PATH
                IList <CatalogPathNode> currentPath = CatalogDataSource.GetPath(_CategoryId, false);
                CurrentPath.DataSource = currentPath;
                CurrentPath.DataBind();
            }
        }
Beispiel #23
0
 protected void CurrencyGrid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "UpdateRate")
     {
         Currency currency = CurrencyDataSource.Load(AlwaysConvert.ToInt(e.CommandArgument));
         if (currency != null)
         {
             try
             {
                 currency.UpdateExchangeRate(true);
                 CurrencyGrid.DataBind();
                 CurrencyAjax.Update();
             }
             catch (Exception ex)
             {
                 // Throw the exception with proper error message
                 throw new Exception("Unable to update the exchange rate.  The rate provider may be experiencing technical difficulties, please try again later.  Exception message: " + ex.Message, ex);
             }
         }
     }
 }
Beispiel #24
0
        /// <summary>
        /// Attempts to get the order from the current context
        /// </summary>
        /// <returns></returns>
        public static Order GetOrderFromContext()
        {
            Order       order   = null;
            HttpRequest request = HttpContextHelper.SafeGetRequest();

            if (request != null)
            {
                int orderNumber = AlwaysConvert.ToInt(request.QueryString["OrderNumber"]);
                if (orderNumber > 0)
                {
                    order = OrderDataSource.Load(OrderDataSource.LookupOrderId(orderNumber));
                }

                if (order == null)
                {
                    int orderId = AlwaysConvert.ToInt(request.QueryString["OrderId"]);
                    order = OrderDataSource.Load(orderId);
                }
            }
            return(order);
        }
 protected void SaveButton_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(SortOrder.Value))
     {
         IList <ProductKitComponent> components = _Product.ProductKitComponents;
         string[] componentIds = SortOrder.Value.Split(",".ToCharArray());
         int      order        = 0;
         foreach (string sPartId in componentIds)
         {
             int componentId = AlwaysConvert.ToInt(sPartId);
             ProductKitComponent kitComponent = _Product.ProductKitComponents.FirstOrDefault(pkc => pkc.KitComponentId == componentId);
             if (kitComponent != null)
             {
                 kitComponent.OrderBy = (short)order;
                 order++;
             }
         }
         components.Save();
     }
     Response.Redirect("EditKit.aspx?CategoryId=" + _CategoryId.ToString() + "&ProductId=" + _ProductId.ToString());
 }
Beispiel #26
0
        protected void ChangePage(object sender, EventArgs e)
        {
            string WhichSender = sender.ToString();

            // If display criteria has changed or user has clicked "Update Display" button, display first page with selected criteria
            // If user has clicked navigation link (first,previous,next,last) or selected page to jump to, display selected page
            if (WhichSender == "System.Web.UI.WebControls.LinkButton")
            {
                SaveGrid();
                LinkButton lb = (LinkButton)sender;
                _CurrentPage = AlwaysConvert.ToInt(lb.CommandArgument);
                BindVariantGrid();
            }
            else
            {
                SaveGrid();
                DropDownList ddl = (DropDownList)sender;
                _CurrentPage = AlwaysConvert.ToInt(ddl.SelectedItem.Text);
                BindVariantGrid();
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            int shipmentId = AlwaysConvert.ToInt(Request.QueryString["ShipmentId"]);

            _OrderShipment = OrderShipmentDataSource.Load(shipmentId);
            if (_OrderShipment == null)
            {
                int orderId     = AbleCommerce.Code.PageHelper.GetOrderId();
                int orderNumber = OrderDataSource.LookupOrderNumber(orderId);
                Response.Redirect("Default.aspx?OrderNumber=" + orderNumber.ToString());
            }
            Caption.Text            = string.Format(Caption.Text, _OrderShipment.ShipmentNumber);
            CancelLink.NavigateUrl += "?OrderNumber=" + _OrderShipment.Order.OrderNumber.ToString();

            // BIND ITEMS
            ShipTo.Text              = _OrderShipment.FormatToAddress(true);
            ShipFrom.Text            = _OrderShipment.FormatFromAddress(true);
            ShippingMethod.Text      = _OrderShipment.ShipMethodName;
            ShipmentItems.DataSource = _OrderShipment.OrderItems;
            ShipmentItems.DataBind();
        }
 protected void BindAutoDelieveryOptions(Product product)
 {
     if (product.SubscriptionPlan != null)
     {
         string[]             vals = product.SubscriptionPlan.OptionalPaymentFrequencies.Split(',');
         PaymentFrequencyUnit unit = product.SubscriptionPlan.PaymentFrequencyUnit;
         AutoDeliveryInterval.Items.Clear();
         if (vals != null && vals.Length > 0)
         {
             foreach (string val in vals)
             {
                 var item = AlwaysConvert.ToInt(val);
                 if (item > 0)
                 {
                     string text = string.Format("{0} {1}{2}", item, unit, item > 1 ? "s" : string.Empty);
                     AutoDeliveryInterval.Items.Add(new ListItem(text, item.ToString()));
                 }
             }
         }
     }
 }
 protected void SaveButton_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(SortOrder.Value))
     {
         IList <KitProduct> parts   = _KitComponent.KitProducts;
         string[]           partIds = SortOrder.Value.Split(",".ToCharArray());
         int order = 0;
         foreach (string sPartId in partIds)
         {
             int partId = AlwaysConvert.ToInt(sPartId);
             int index  = parts.IndexOf(partId);
             if (index > -1)
             {
                 parts[index].OrderBy = (short)order;
             }
             order++;
         }
         parts.Save();
     }
     Response.Redirect("EditKit.aspx?CategoryId=" + _CategoryId.ToString() + "&ProductId=" + _ProductId.ToString());
 }
 protected void Page_Init(object sender, EventArgs e)
 {
     //INITIALIZE VARIABLES
     _CategoryId = AbleCommerce.Code.PageHelper.GetCategoryId();
     _Category   = CategoryDataSource.Load(_CategoryId);
     _ProductId  = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
     _Product    = ProductDataSource.Load(_ProductId);
     if (_Product == null)
     {
         Response.Redirect(AbleCommerce.Code.NavigationHelper.GetAdminUrl("Catalog/Browse.aspx"));
     }
     _KitComponentId = AlwaysConvert.ToInt(Request.QueryString["KitComponentId"]);
     _KitComponent   = KitComponentDataSource.Load(_KitComponentId);
     if (_KitComponent == null)
     {
         Response.Redirect("EditKit.aspx?CategoryId=" + _CategoryId.ToString() + "&ProductId=" + _ProductId.ToString());
     }
     //INITIALIZE PAGE ELEMENTS
     Caption.Text = string.Format(Caption.Text, _KitComponent.Name);
     BindKitList();
 }