protected void Page_Load(object sender, EventArgs e)
 {
     _ProductTemplateId = AlwaysConvert.ToInt(Request.QueryString["ProductTemplateId"]);
     _ProductTemplate   = ProductTemplateDataSource.Load(_ProductTemplateId);
     if (_ProductTemplate == null)
     {
         Response.Redirect("Default.aspx");
     }
     if (!Page.IsPostBack)
     {
         //set caption
         bool isMerchantField = (AlwaysConvert.ToInt(Request.QueryString["m"]) == 1);
         trUseShopBy.Visible = isMerchantField;
         if (isMerchantField)
         {
             Caption.Text = string.Format(Caption.Text, "Merchant", _ProductTemplate.Name);
         }
         else
         {
             Caption.Text = string.Format(Caption.Text, "Customer", _ProductTemplate.Name);
         }
         ViewState["IsMerchantField"] = isMerchantField;
         BindInputTypes();
         //update visible inputs
         trRequired.Visible = !isMerchantField;
         UpdateVisibleElements();
     }
 }
Exemplo n.º 2
0
 protected void Page_Init(object sender, EventArgs e)
 {
     _ProductTemplateId = AlwaysConvert.ToInt(Request.QueryString["ProductTemplateId"]);
     _ProductTemplate   = ProductTemplateDataSource.Load(_ProductTemplateId);
     if (_ProductTemplate == null)
     {
         Response.Redirect("Default.aspx");
     }
     Caption.Text = string.Format(Caption.Text, _ProductTemplate.Name);
     _IconPath    = AbleCommerce.Code.PageHelper.GetAdminThemeIconPath(this.Page);
     FindAssignProducts1.AssignmentValue  = _ProductTemplateId;
     FindAssignProducts1.OnAssignProduct += new AssignProductEventHandler(FindAssignProducts1_AssignProduct);
     FindAssignProducts1.OnLinkCheck     += new AssignProductEventHandler(FindAssignProducts1_LinkCheck);
     FindAssignProducts1.OnCancel        += new EventHandler(FindAssignProducts1_CancelButton);
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     _ProductTemplateId = AlwaysConvert.ToInt(Request.QueryString["ProductTemplateId"]);
     _ProductTemplate   = ProductTemplateDataSource.Load(_ProductTemplateId);
     if (_ProductTemplate == null)
     {
         Response.Redirect("Default.aspx");
     }
     if (!Page.IsPostBack)
     {
         ViewState["Caption"]          = Caption.Text;
         Caption.Text                  = string.Format(Caption.Text, _ProductTemplate.Name);
         Name.Text                     = _ProductTemplate.Name;
         AssignedProducts.NavigateUrl += "?ProductTemplateId=" + _ProductTemplateId.ToString();
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes the change Templates dialog with current user Template settings
        /// </summary>
        private void InitializeChangeTemplatesDialog()
        {
            AvailableTemplates.Items.Clear();
            SelectedTemplates.Items.Clear();
            IList <ProductTemplate> allTemplates = ProductTemplateDataSource.LoadAll("Name");

            foreach (ProductTemplate t in allTemplates)
            {
                ListItem newItem          = new ListItem(t.Name, t.Id.ToString());
                bool     templateSelected = _Product.ProductTemplates.IndexOf(t.Id) > -1;
                if (templateSelected)
                {
                    SelectedTemplates.Items.Add(newItem);
                }
                else
                {
                    AvailableTemplates.Items.Add(newItem);
                }
            }
        }
Exemplo n.º 5
0
        private static void UpdateProductTemplateAssociation(int productId, int productTemplateId, bool linked)
        {
            Product product = ProductDataSource.Load(productId);

            if (product != null)
            {
                int templateIndex = product.ProductTemplates.IndexOf(productTemplateId);
                if (linked && templateIndex < 0)
                {
                    ProductTemplate pt = ProductTemplateDataSource.Load(productTemplateId);
                    product.ProductTemplates.Add(pt);
                    pt.Save();
                }
                else if (!linked && templateIndex > -1)
                {
                    product.ProductTemplates.RemoveAt(templateIndex);
                    product.Save();
                }
            }
        }
Exemplo n.º 6
0
 private void InitializeTemplateList()
 {
     if (Page.IsPostBack)
     {
         _Product.ProductTemplates.Clear();
         int[] selectedTemplates = AlwaysConvert.ToIntArray(Request.Form[HiddenSelectedTemplates.UniqueID]);
         if (selectedTemplates != null && selectedTemplates.Length > 0)
         {
             foreach (int ptid in selectedTemplates)
             {
                 ProductTemplate template = ProductTemplateDataSource.Load(ptid);
                 if (template != null)
                 {
                     _Product.ProductTemplates.Add(template);
                 }
             }
         }
     }
     else
     {
         HiddenSelectedTemplates.Value = GetTemplateIdList();
     }
     TemplateList.Text = GetTemplateList();
 }
Exemplo n.º 7
0
        private void ProcessRules(BreadCrumbItem breadCrumbItem)
        {
            int id;

            if (breadCrumbItem.Url == "#")
            {
                return;
            }
            switch (breadCrumbItem.Url.ToLowerInvariant())
            {
            case "~/admin/orders/shipments/editshipment.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["OrderShipmentId"]);
                breadCrumbItem.Url  += "?OrderShipmentId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, id);
                break;

            case "~/admin/products/editproduct.aspx":
            case "~/admin/products/variants/variants.aspx":
            case "~/admin/products/variants/options.aspx":
            case "~/admin/products/digitalgoods/digitalgoods.aspx":
            case "~/admin/products/kits/editkit.aspx":
            case "~/admin/products/assets/images.aspx":
            case "~/admin/products/editproducttemplate.aspx":
            case "~/admin/products/specials/default.aspx":
                int categoryId = AbleCommerce.Code.PageHelper.GetCategoryId();
                id = AbleCommerce.Code.PageHelper.GetProductId();
                Product product = ProductDataSource.Load(id);
                if (categoryId > 0)
                {
                    breadCrumbItem.Url += "?CategoryId=" + categoryId + "&ProductId=" + id;
                }
                else
                {
                    breadCrumbItem.Url += "?ProductId=" + id;
                }
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, product.Name);
                break;

            case "~/admin/orders/vieworder.aspx":
            case "~/admin/orders/edit/editorderitems.aspx":
            case "~/admin/orders/viewdigitalgoods.aspx":
            case "~/admin/orders/payments/default.aspx":
            case "~/admin/orders/shipments/default.aspx":
                id = AbleCommerce.Code.PageHelper.GetOrderId();
                Order order = OrderDataSource.Load(id);
                breadCrumbItem.Url  += "?OrderNumber=" + order.OrderNumber;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, order.OrderNumber);
                break;

            case "~/admin/marketing/coupons/editcoupon.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["CouponId"]);
                Coupon coupon = CouponDataSource.Load(id);
                breadCrumbItem.Url  += "?CouponId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, coupon.Name);
                break;

            case "~/admin/products/variants/editoption.aspx":
            case "~/admin/products/variants/editchoices.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["OptionId"]);
                Option option = OptionDataSource.Load(id);
                breadCrumbItem.Url  += "?OptionId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, option.Name);
                break;

            case "~/admin/products/giftwrap/editwrapgroup.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["WrapGroupId"]);
                WrapGroup wrapGroup = WrapGroupDataSource.Load(id);
                breadCrumbItem.Url  += "?WrapGroupId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, wrapGroup.Name);
                break;

            case "~/admin/marketing/email/managelist.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["EmailListId"]);
                EmailList emailList = EmailListDataSource.Load(id);
                if (emailList != null)
                {
                    breadCrumbItem.Url  += "?EmailListId=" + id;
                    breadCrumbItem.Title = string.Format(breadCrumbItem.Title, emailList.Name);
                }
                break;

            case "~/admin/marketing/discounts/editdiscount.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["VolumeDiscountId"]);
                VolumeDiscount discount = VolumeDiscountDataSource.Load(id);
                breadCrumbItem.Url  += "?VolumeDiscountId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, discount.Name);
                break;

            case "~/admin/catalog/editwebpage.aspx":
                id = AbleCommerce.Code.PageHelper.GetWebpageId();
                Webpage webpage = WebpageDataSource.Load(id);
                breadCrumbItem.Url  += "?WebpageId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, webpage.Name);
                break;

            case "~/admin/catalog/editLink.aspx":
                id = AbleCommerce.Code.PageHelper.GetLinkId();
                Link link = LinkDataSource.Load(id);
                breadCrumbItem.Url  += "?LinkId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, link.Name);
                break;

            case "~/admin/people/users/edituser.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["UserId"]);
                User user = UserDataSource.Load(id);
                breadCrumbItem.Url  += "?UserId=" + id;
                breadCrumbItem.Title = string.Format(breadCrumbItem.Title, user.UserName);
                break;

            case "~/admin/digitalgoods/editdigitalgood.aspx":
            case "~/admin/digitalgoods/serialkeyproviders/defaultprovider/configure.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["DigitalGoodId"]);
                DigitalGood dg = DigitalGoodDataSource.Load(id);
                if (dg != null)
                {
                    breadCrumbItem.Url  += "?DigitalGoodId=" + id;
                    breadCrumbItem.Title = string.Format(breadCrumbItem.Title, dg.Name);
                }
                break;

            case "~/admin/products/producttemplates/editproducttemplate.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["ProductTemplateId"]);
                ProductTemplate template = ProductTemplateDataSource.Load(id);
                if (template == null)
                {
                    InputField field = InputFieldDataSource.Load(AlwaysConvert.ToInt(Request.QueryString["InputFieldId"]));
                    if (field != null)
                    {
                        template = field.ProductTemplate;
                        id       = template.Id;
                    }
                }
                if (template != null)
                {
                    breadCrumbItem.Url  += "?ProductTemplateId=" + id;
                    breadCrumbItem.Title = string.Format(breadCrumbItem.Title, template.Name);
                }
                else
                {
                }
                break;

            case "~/admin/reports/dailyabandonedbaskets.aspx":
                id = AlwaysConvert.ToInt(Request.QueryString["BasketId"]);
                Basket basket = BasketDataSource.Load(id);
                if (basket != null)
                {
                    breadCrumbItem.Url += "?ReportDate=" + basket.User.LastActivityDate.Value.ToShortDateString();
                }
                break;
            }

            // resolve relative urls
            if (breadCrumbItem.Url.StartsWith("~/"))
            {
                breadCrumbItem.Url = Page.ResolveUrl(breadCrumbItem.Url);
            }
        }