private IList <Blog> CreateDataSource()
    {
        string       storeID = new StoreRetriever().GetCurrentStoreID();
        IList <Blog> list    = DataAccessContext.BlogRepository.GetRecentPost(storeID, _displayRecentPostListItem);

        return(list);
    }
Exemplo n.º 2
0
    private void PopulateControls()
    {
        Customer customer = DataAccessContext.CustomerRepository.GetOne(CurrentID);

        uxUserName.Text  = customer.UserName;
        uxFirstName.Text = customer.BillingAddress.FirstName;
        uxLastName.Text  = customer.BillingAddress.LastName;
        uxCompany.Text   = customer.BillingAddress.Company;
        uxAddress1.Text  = customer.BillingAddress.Address1;
        uxAddress2.Text  = customer.BillingAddress.Address2;
        uxCity.Text      = customer.BillingAddress.City;
        uxZip.Text       = customer.BillingAddress.Zip;

        uxCountryAndState.CurrentCountry = customer.BillingAddress.Country;
        uxCountryAndState.CurrentState   = customer.BillingAddress.State;

        uxPhone.Text = customer.BillingAddress.Phone;
        uxFax.Text   = customer.BillingAddress.Fax;
        uxEmail.Text = customer.Email;
        IsWholesale  = customer.IsWholesale;

        StoreRetriever storeRetriever = new StoreRetriever();
        NewsLetter     newsLetter     = DataAccessContext.NewsLetterRepository.GetOne(customer.Email, storeRetriever.GetStore());

        if (!newsLetter.IsNull)
        {
            uxSubscribeCheckBox.Checked = true;
        }
        else
        {
            uxSubscribeCheckBox.Checked = false;
        }
    }
Exemplo n.º 3
0
    private DataTable CreateDataSource()
    {
        string    storeID = new StoreRetriever().GetCurrentStoreID();
        DataTable list    = DataAccessContext.BlogRepository.GetArchiveList(storeID);

        return(list);
    }
Exemplo n.º 4
0
    private void GetContentMenu()
    {
        shownContentList = new ArrayList();
        StoreRetriever storeRetriever = new StoreRetriever();

        _contentMenuList = DataAccessContext.ContentMenuItemRepository.GetByStoreID(
            StoreContext.Culture, storeRetriever.GetCurrentStoreID(), "ContentMenuItemID", BoolFilter.ShowTrue);
    }
Exemplo n.º 5
0
    protected void uxSetAsPrimayImageButton_Click(object sender, EventArgs e)
    {
        string     storeID  = new StoreRetriever().GetCurrentStoreID();
        LinkButton myButton = (LinkButton)sender;
        string     imageID  = myButton.CommandArgument;
        Product    product  = DataAccessContext.ProductRepository.GetOne(Culture.Null, ProductID, storeID);

        string originalFilePath;

        if (ProductID == "0")
        {
            ProductImageData.SetPrimary(imageID);
            ImageItem item = ProductImageData.FindItem(imageID);
            originalFilePath = item.LargeImage;
        }
        else
        {
            ProductImage oldPrimaryImage = new ProductImage();
            ProductImage newPrimaryImage = new ProductImage();
            foreach (ProductImage productImage in product.ProductImages)
            {
                if (productImage.ProductImageID == imageID)
                {
                    newPrimaryImage = productImage;
                }
                if (productImage.SortOrder == 0)
                {
                    oldPrimaryImage = productImage;
                }
            }

            SetProductImageOrder(product, oldPrimaryImage.ProductImageID, newPrimaryImage.SortOrder);
            SetProductImageOrder(product, newPrimaryImage.ProductImageID, 0);

            originalFilePath = newPrimaryImage.LargeImage;
        }

        using (ProductImageFile imageFile = ProductImageFile.Load(new FileManager(), Path.GetFileName(originalFilePath)))
        {
            if (ProductID == "0")
            {
                SaveSecondaryNoProduct(imageFile);
            }
            else
            {
                SaveSecondary(product, imageFile);
            }
        }

        if (!product.IsNull)
        {
            DataAccessContext.ProductRepository.Save(product);
        }

        uxMessage.DisplayMessage(Resources.ProductImageMessages.SetPrimarySuccess);

        uxStatusHidden.Value = "SetPrimary";
    }
Exemplo n.º 6
0
    private void IsProductAvailable()
    {
        string  storeID = new StoreRetriever().GetCurrentStoreID();
        Product product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, ProductID, storeID);

        if (!product.IsProductAvailable(storeID))
        {
            Response.Redirect("~/Error404.aspx");
        }
    }
Exemplo n.º 7
0
    private void CopyProductPrice(Product originalProduct, string newProductID)
    {
        string storeID = new StoreRetriever().GetCurrentStoreID();

        Product newProduct = DataAccessContext.ProductRepository.GetOne(uxLanguageControl.CurrentCulture, newProductID, storeID);

        newProduct.ProductPrices = originalProduct.ProductPrices;

        DataAccessContext.ProductRepository.Save(newProduct);
    }
Exemplo n.º 8
0
    private Customer SetUpCustomer()
    {
        Customer customer = new Customer();

        customer.UserName       = uxUserName.Text.Trim();
        customer.BillingAddress = new Address(uxFirstName.Text, uxLastName.Text, uxCompany.Text,
                                              uxAddress1.Text, uxAddress2.Text, uxCity.Text, uxCountryState.CurrentState, uxZip.Text,
                                              uxCountryState.CurrentCountry, uxPhone.Text, uxFax.Text);
        customer.Email = uxEmail.Text.Trim();
        customer.UseBillingAsShipping = uxUseBillingAsShipping.Checked;

        ShippingAddress shippingAddress = new ShippingAddress(new Address(
                                                                  uxShippingFirstName.Text,
                                                                  uxShippingLastName.Text,
                                                                  uxShippingCompany.Text,
                                                                  uxShippingAddress1.Text,
                                                                  uxShippingAddress2.Text,
                                                                  uxShippingCity.Text,
                                                                  uxShippingCountryState.CurrentState,
                                                                  uxShippingZip.Text,
                                                                  uxShippingCountryState.CurrentCountry,
                                                                  uxShippingPhone.Text,
                                                                  uxShippingFax.Text),
                                                              ConvertUtilities.ToBoolean(uxShippingResidentialDrop.SelectedValue));

        shippingAddress.AliasName = uxShippingFirstName.Text + " " + uxShippingLastName.Text + " " + uxShippingAddress1.Text;

        if (shippingAddress.AliasName.Length > 50)
        {
            shippingAddress.AliasName = shippingAddress.AliasName.Substring(0, 50);
        }

        if (uxUseBillingAsShipping.Checked)
        {
            shippingAddress.IsSameAsBillingAddress = true;
        }
        else
        {
            shippingAddress.IsSameAsBillingAddress = false;
        }

        customer.ShippingAddresses.Add(shippingAddress);

        if (!IsCustomerAutoApprove)
        {
            customer.IsEnabled = false;
        }
        customer.FBUserID = uxFacebookID.Value;
        String         storeID     = new StoreRetriever().GetStore().StoreID;
        IList <String> storeIDList = new List <String>();

        storeIDList.Add(storeID);
        customer.StoreIDs = storeIDList;
        return(customer);
    }
Exemplo n.º 9
0
    private void PopulateTitleAndMeta()
    {
        DynamicPageElement element = new DynamicPageElement(this);
        string             storeID = new StoreRetriever().GetCurrentStoreID();
        Product            product = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, ProductID, storeID);

        element.SetUpTitleAndMetaTags(
            product.GetPageTitle(StoreContext.Culture, StoreContext.CurrentStore),
            product.GetMetaDescription(StoreContext.Culture, storeID),
            product.GetMetaKeyword(StoreContext.Culture, storeID));
    }
Exemplo n.º 10
0
    private void InitDropDownList()
    {
        string storeID = new StoreRetriever().GetCurrentStoreID();

        if (!MainContext.IsPostBack)
        {
            uxMultiDepartment.SetupDropDownList(CurrentID, CurrentCulture, false);
        }
        else
        {
            uxMultiDepartment.SetupDropDownList(CurrentID, CurrentCulture, true);
        }
    }
Exemplo n.º 11
0
    protected bool HasOptionStock(string productID)
    {
        string  storeID = new StoreRetriever().GetCurrentStoreID();
        Product product = DataAccessContext.ProductRepository.GetOne(uxLanguageControl.CurrentCulture, productID, storeID);

        if (product.ProductStocks.Count == 1 && product.ProductStocks[0].OptionCombinationID == "0")
        {
            return(false);
        }
        else
        {
            return(true);
        }
    }
Exemplo n.º 12
0
    private void CopyMetaInformation(Product originalProduct, string newProductID)
    {
        string  storeID    = new StoreRetriever().GetCurrentStoreID();
        Product newProduct = DataAccessContext.ProductRepository.GetOne(uxLanguageControl.CurrentCulture, newProductID, storeID);

        foreach (ProductMetaInformation meta in originalProduct.GetMetaInformations())
        {
            Culture culture = DataAccessContext.CultureRepository.GetOne(meta.CultureID);
            newProduct.SetMetaKeyword(culture, meta.StoreID, meta.MetaKeyword);
            newProduct.SetMetaDescription(culture, meta.StoreID, meta.MetaDescription);
            newProduct.SetUseDefaultValueMetaKeyword(culture, meta.StoreID, meta.UseDefaultMetaKeyword);
            newProduct.SetUseDefaultValueMetaDescription(culture, meta.StoreID, meta.UseDefaultMetaDescription);
        }
        DataAccessContext.ProductRepository.Save(newProduct);
    }
Exemplo n.º 13
0
    protected void Page_PreRender(object sender, EventArgs e)
    {
        StoreRetriever storeRetriever = new StoreRetriever();
        Store          store          = storeRetriever.GetStore();

        if (ActionCode == null || ActionCode == string.Empty)
        {
            uxNewsletterSubScribeTR.Visible = true;
            uxNewsletterMessageTR.Visible   = false;
        }
        else
        {
            uxNewsletterSubScribeTR.Visible = false;
            uxNewsletterMessageTR.Visible   = true;
            switch (ActionCode.ToLower())
            {
            case "register":
                SendConfirmationEmail();
                break;

            case "registerbox":
                uxNewsletterSubScribeTR.Visible = true;
                SendConfirmationEmail();
                break;

            case "unsubscribe":
                if (DataAccessContext.NewsLetterRepository.DeleteEmail(Key, store))
                {
                    uxSubscribeLabel.Text = "[$UnsubscribeSuccess]";
                }
                else
                {
                    uxSubscribeLabel.Text = "[$UnsubscribeFail]";
                }
                uxEmailLabel.Text = Email;
                break;

            case "confirm":
                RegisterEmail();
                break;

            default:
                uxSubscribeLabel.Text = "";
                break;
            }
        }
    }
Exemplo n.º 14
0
    protected void uxRemoveImageButton_Click(object sender, EventArgs e)
    {
        LinkButton myButton = (LinkButton)sender;
        string     imageID  = myButton.CommandArgument;

        if (ProductID == "0")
        {
            RemoveNewProductImage(imageID);
        }
        else
        {
            string  storeID = new StoreRetriever().GetCurrentStoreID();
            Product product = DataAccessContext.ProductRepository.GetOne(Culture.Null, ProductID, storeID);
            RemoveExistingProductImage(product, imageID);
            DataAccessContext.ProductRepository.Save(product);
        }
    }
Exemplo n.º 15
0
    private bool ContainsProducts(string[] idArray, out string containingTaxClassID)
    {
        string storeID = new StoreRetriever().GetCurrentStoreID();

        foreach (string id in idArray)
        {
            IList <Product> productList = DataAccessContext.ProductRepository.GetAllByTaxClassID(Culture.Null, id, storeID);
            if (productList.Count > 0)
            {
                containingTaxClassID = id;
                return(true);
            }
        }

        containingTaxClassID = "";
        return(false);
    }
Exemplo n.º 16
0
    private void RegisterEmail()
    {
        StoreRetriever storeRetriever = new StoreRetriever();
        Store          store          = storeRetriever.GetStore();

        if (Email == null | Email == string.Empty)
        {
            EmailDiv.Visible      = false;
            uxSubscribeLabel.Text = "[$RegisterEmpty]";
            return;
        }
        Regex emailregex = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
        Match m          = emailregex.Match(Email);

        if (m.Success)
        {
            string emailHash =
                SecurityUtilities.HashMD5(Email + WebConfiguration.SecretKey);

            NewsLetter newsLetter = DataAccessContext.NewsLetterRepository.GetOne(Email, store);
            if (newsLetter.IsNull)
            {
                newsLetter.Email     = Email;
                newsLetter.EmailHash = emailHash;
                newsLetter.JoinDate  = DateTime.Now;
                newsLetter.StoreID   = store.StoreID;
                DataAccessContext.NewsLetterRepository.Create(newsLetter);
                uxSubscribeLabel.Text           = "[$RegisterSuccess]";
                uxNewsletterSubScribeTR.Visible = false;
            }
            else
            {
                uxSubscribeLabel.Text = "[$RegisterAlready]";
            }
        }
        else
        {
            uxNewsletterSubScribeTR.Visible = true;
            uxSubscribeLabel.ForeColor      = System.Drawing.Color.Red;
            uxSubscribeLabel.Text           = "[$RegisterInvalidEmail]";
        }
        uxEmailLabel.Text = Email;
    }
Exemplo n.º 17
0
    protected override void RefreshGrid()
    {
        int    totalItems;
        string storeID = new StoreRetriever().GetCurrentStoreID();

        uxGridProduct.DataSource = DataAccessContext.ProductRepository.SearchProduct(
            uxLanguageControl.CurrentCulture,
            uxCategoryFilterDrop.SelectedValue,
            GridHelper.GetFullSortText(),
            uxSearchFilter.SearchFilterObj,
            uxPagingControl.StartIndex,
            uxPagingControl.EndIndex,
            out totalItems,
            storeID,
            RootCategoryValue);
        uxPagingControl.NumberOfPages = (int)Math.Ceiling((double)totalItems / uxPagingControl.ItemsPerPages);

        uxGridProduct.DataBind();
    }
Exemplo n.º 18
0
    private void CopyRemainingProductLocales(Product originalProduct, string newProductID)
    {
        string  storeID    = new StoreRetriever().GetCurrentStoreID();
        Product newProduct = DataAccessContext.ProductRepository.GetOne(uxLanguageControl.CurrentCulture, newProductID, storeID);

        newProduct.ImageSecondary = String.Empty;
        foreach (ILocale locale in originalProduct.GetLocales())
        {
            if (locale.CultureID != newProduct.Locales[uxLanguageControl.CurrentCulture].CultureID)
            {
                ProductLocale newLocale = new ProductLocale();
                newLocale.CultureID        = originalProduct.Locales[locale.CultureID].CultureID;
                newLocale.Name             = originalProduct.Locales[locale.CultureID].Name;
                newLocale.ShortDescription = originalProduct.Locales[locale.CultureID].ShortDescription;
                newLocale.LongDescription  = originalProduct.Locales[locale.CultureID].LongDescription;
                newProduct.Locales.Add(newLocale);
            }
        }
        DataAccessContext.ProductRepository.Save(newProduct);
    }
Exemplo n.º 19
0
    private void IsProductAvailable()
    {
        string         storeID                = new StoreRetriever().GetCurrentStoreID();
        Product        product                = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, ProductID, storeID);
        IList <String> storeList              = product.GetAvailableStoreIDList();
        IList <String> categoryList           = product.CategoryIDs;
        IList <String> departmentList         = product.DepartmentIDs;
        bool           hasCategoryAvailable   = false;
        bool           hasDepartmentAvailable = false;

        foreach (string categoryID in categoryList)
        {
            Category category = DataAccessContext.CategoryRepository.GetOne(StoreContext.Culture, categoryID);

            if (category.IsEnabled)
            {
                hasCategoryAvailable = true;
                break;
            }
        }

        foreach (string departmentID in departmentList)
        {
            Department department = DataAccessContext.DepartmentRepository.GetOne(StoreContext.Culture, departmentID);

            if (department.IsEnabled)
            {
                hasDepartmentAvailable = true;
                break;
            }
        }

        if (product.IsNull || !product.IsEnabled || !storeList.Contains(storeID) || (!hasCategoryAvailable && !hasDepartmentAvailable))
        {
            Response.Redirect("~/default.aspx");
        }
    }
Exemplo n.º 20
0
    private void AddCustomer()
    {
        if (Page.IsValid)
        {
            StoreRetriever storeRetriever = new StoreRetriever();
            Store          store = storeRetriever.GetStore();
            bool           validateCountry, validateState, validateShippingCountry, validateShippingState;
            bool           validateBilling, validateShipping;
            validateBilling = uxCountryState.Validate(out validateCountry, out validateState);

            if (uxUseBillingAsShipping.Checked)
            {
                if (!validateBilling)
                {
                    uxBillingCountryStateDiv.Visible  = true;
                    uxBillingCountryStateMessage.Text = ValidateCountryAndState(validateCountry, validateState);
                    return;
                }
            }
            else
            {
                validateShipping = uxShippingCountryState.Validate(out validateShippingCountry, out validateShippingState);
                if (!validateBilling && !validateShipping)
                {
                    uxBillingCountryStateDiv.Visible   = true;
                    uxBillingCountryStateMessage.Text  = ValidateCountryAndState(validateCountry, validateState);
                    uxShippingCountryStateDiv.Visible  = true;
                    uxShippingCountryStateMessage.Text = ValidateCountryAndState(validateShippingCountry, validateShippingState);
                    return;
                }
                else if (!validateBilling)
                {
                    uxBillingCountryStateDiv.Visible  = true;
                    uxBillingCountryStateMessage.Text = ValidateCountryAndState(validateCountry, validateState);
                    return;
                }
                else if (!validateShipping)
                {
                    uxShippingCountryStateDiv.Visible  = true;
                    uxShippingCountryStateMessage.Text = ValidateCountryAndState(validateShippingCountry, validateShippingState);
                    return;
                }
            }

            MembershipUser user = Membership.GetUser(uxUserName.Text.Trim());
            if (user == null && !UsernameExits(uxUserName.Text.Trim()))
            {
                if (uxUseBillingAsShipping.Checked)
                {
                    CopyBillingDetailsToShipping();
                }

                if (uxSubscribeCheckBox.Checked)
                {
                    string Email     = uxEmail.Text.Trim();
                    string EmailHash =
                        SecurityUtilities.HashMD5(Email + WebConfiguration.SecretKey);
                    NewsLetter newsLetter = DataAccessContext.NewsLetterRepository.GetOne(Email, store);
                    if (newsLetter.IsNull)
                    {
                        newsLetter.Email     = Email;
                        newsLetter.EmailHash = EmailHash;
                        newsLetter.JoinDate  = DateTime.Now;
                        newsLetter.StoreID   = store.StoreID;
                        DataAccessContext.NewsLetterRepository.Create(newsLetter);
                    }
                }

                string id;

                Customer customer = SetUpCustomer();
                customer = DataAccessContext.CustomerRepository.Save(customer);
                id       = customer.CustomerID;

                Membership.CreateUser(uxUserName.Text.Trim(), uxPassword.Text, uxEmail.Text.Trim());
                Roles.AddUserToRole(uxUserName.Text, "Customers");

                if (IsCustomerAutoApprove)
                {
                    FormsAuthentication.SetAuthCookie(uxUserName.Text, false);
                }

                SetCartShippingAddress(customer);
                SetTaxExempt();
                try
                {
                    SendMailToCustomer(uxEmail.Text, uxUserName.Text);
                    SendMailToMerchant(uxEmail.Text, uxUserName.Text, id);
                    AffiliateHelper.UpdateAffiliateReference(uxUserName.Text);
                    RedirectPage();
                }
                catch (Exception)
                {
                    ErrorMessage = "[$SentErrorMessage]";
                    ClearData();
                }
            }
            else
            {
                ErrorMessage = "[$User Existed]";
            }
        }
    }
Exemplo n.º 21
0
    private void Update()
    {
        try
        {
            if (Page.IsValid)
            {
                if (uxProductInfo.ConvertToCategoryIDs().Length > 0)
                {
                    if (!uxProductAttributes.VerifyInputListOption())
                    {
                        DisplayErrorOption();
                        return;
                    }

                    string  price;
                    string  retailPrice;
                    string  wholeSalePrice;
                    string  wholeSalePrice2;
                    string  wholeSalePrice3;
                    decimal giftAmount;
                    if (uxProductAttributes.IsFixPrice(
                            uxGiftCertificate.IsFixedPrice, uxGiftCertificate.IsGiftCertificate, uxRecurring.IsRecurring, uxProductAttributes.IsCallForPrice))
                    {
                        price           = uxProductAttributes.Price;
                        retailPrice     = uxProductAttributes.RetailPrice;
                        wholeSalePrice  = uxProductAttributes.WholeSalePrice;
                        wholeSalePrice2 = uxProductAttributes.WholeSalePrice2;
                        wholeSalePrice3 = uxProductAttributes.WholeSalePrice3;

                        giftAmount = ConvertUtilities.ToDecimal(uxGiftCertificate.GiftAmount);
                    }
                    else
                    {
                        price           = "0";
                        retailPrice     = "0";
                        wholeSalePrice  = "0";
                        wholeSalePrice2 = "0";
                        wholeSalePrice3 = "0";
                        giftAmount      = 0m;
                    }
                    string  storeID = new StoreRetriever().GetCurrentStoreID();
                    Product product = DataAccessContext.ProductRepository.GetOne(uxLanguageControl.CurrentCulture, CurrentID, storeID);
                    product = SetUpProduct(product);

                    product = DataAccessContext.ProductRepository.Save(product);

                    uxMessage.DisplayMessage(Resources.ProductMessages.UpdateSuccess);

                    AdminUtilities.ClearSiteMapCache();

                    PopulateControls();
                }
                else
                {
                    uxMessage.DisplayError(Resources.ProductMessages.AddErrorCategoryEmpty);
                    return;
                }
            }
        }
        catch (Exception ex)
        {
            uxMessage.DisplayException(ex);
        }
    }
Exemplo n.º 22
0
    private void PopulateControls()
    {
        string name = string.Empty;
        string catName;

        IList <string> catList              = new List <string>();
        List <string>  categoryCollection   = new List <string>();
        IList <string> depList              = new List <string>();
        List <string>  departmentCollection = new List <string>();
        string         currentManID         = "0";
        int            maxCount             = 9;
        string         currentDeptID        = "0";
        string         currentCatID         = "0";

        Store  store     = new StoreRetriever().GetStore();
        string rootCatID = DataAccessContext.Configurations.GetValue("RootCategory", store);
        string rootDepID = DataAccessContext.Configurations.GetValue("RootDepartment", store);

        bool isManufacturer = false;

        if (IsInCategoryPage())
        {
            if (!String.IsNullOrEmpty(CurrentCategoryName))
            {
                Category category = DataAccessContext.CategoryRepository.GetOneByUrlName(
                    StoreContext.Culture, CurrentCategoryName);
                catName      = category.Name;
                currentCatID = category.CategoryID;
            }
            else
            {
                catName      = CurrentCategory.Name;
                currentCatID = CurrentCategoryID;
            }
            Category cat = DataAccessContext.CategoryRepository.GetOne(
                StoreContext.Culture, currentCatID);
            if (!cat.IsShowNewArrival)
            {
                uxNewArrivalCategory.Visible = false;
                return;
            }

            IList <string> categoryIDs = DataAccessContext.CategoryRepository.GetLeafFromCategoryID(
                currentCatID, catList);

            foreach (string categoryItem in categoryIDs)
            {
                categoryCollection.Add(categoryItem);
            }
            if (cat.CategoryID == rootCatID)
            {
                maxCount = DataAccessContext.Configurations.GetIntValue("ProductNewArrivalNumber", new StoreRetriever().GetStore());
            }
            else
            {
                maxCount = cat.NewArrivalAmount;
            }
        }
        else if (IsInDepartmentPage())
        {
            if (!String.IsNullOrEmpty(CurrentDepartmentName))
            {
                Department department = DataAccessContext.DepartmentRepository.GetOneByUrlName(
                    StoreContext.Culture, CurrentDepartmentName);
                catName       = department.Name;
                currentDeptID = department.DepartmentID;
            }
            else
            {
                catName       = CurrentDepartment.Name;
                currentDeptID = CurrentDepartmentID;
            }
            Department dept = DataAccessContext.DepartmentRepository.GetOne(StoreContext.Culture, currentDeptID);
            if (!dept.IsShowNewArrival)
            {
                uxNewArrivalCategory.Visible = false;
                return;
            }

            IList <string> departmentIDs = DataAccessContext.DepartmentRepository.GetLeafFromDepartmentID(
                currentDeptID, depList);

            foreach (string departmentItem in departmentIDs)
            {
                departmentCollection.Add(departmentItem);
            }

            if (dept.DepartmentID == rootDepID)
            {
                maxCount = DataAccessContext.Configurations.GetIntValue("ProductNewArrivalNumber", new StoreRetriever().GetStore());
            }
            else
            {
                maxCount = dept.NewArrivalAmount;
            }
        }
        else
        {
            if (!String.IsNullOrEmpty(CurrentManufacturerName))
            {
                Manufacturer manufacturer = DataAccessContext.ManufacturerRepository.GetOneByUrlName(
                    StoreContext.Culture, CurrentManufacturerName);
                catName      = manufacturer.Name;
                currentManID = manufacturer.ManufacturerID;
            }
            else
            {
                catName      = CurrentManufacturer.Name;
                currentManID = CurrentManufacturerID;
            }
            isManufacturer = true;
        }

        if ((currentCatID == rootCatID) || (currentDeptID == rootDepID) || (catName == "RootManufacturer") || (catName == String.Empty))
        {
            uxNewArrivalCategoryName.Text = string.Empty;
        }
        else
        {
            uxNewArrivalCategoryName.Text = "-&nbsp;" + char.ToUpper(catName[0]) + catName.Substring(1);
        }

        IList <Product> newProducts;

        if (isManufacturer == false)
        {
            newProducts = DataAccessContext.ProductRepository.GetNewArrivalByCategoryDepartmentID(
                StoreContext.Culture, categoryCollection.ToArray(), departmentCollection.ToArray(), maxCount, new StoreRetriever().GetCurrentStoreID());
        }
        else
        {
            if (currentManID == "0")
            {
                newProducts = DataAccessContext.ProductRepository.GetAllByNewArrival(StoreContext.Culture, DataAccessContext.Configurations.GetIntValue("ProductNewArrivalNumber", new StoreRetriever().GetStore()), DataAccessContext.Configurations.GetIntValue("OutOfStockValue"), true, new StoreRetriever().GetCurrentStoreID(), DataAccessContext.Configurations.GetValue("RootCategory"));
            }
            else
            {
                Manufacturer manufacturer = DataAccessContext.ManufacturerRepository.GetOne(StoreContext.Culture, currentManID);
                if (manufacturer.IsShowNewArrival)
                {
                    newProducts = DataAccessContext.ProductRepository.GetNewArrivalByManufacturerID(
                        StoreContext.Culture,
                        currentManID,
                        manufacturer.NewArrivalAmount,
                        new StoreRetriever().GetCurrentStoreID());
                }
                else
                {
                    newProducts = new List <Product>();
                }
            }
        }

        if (newProducts.Count > 0)
        {
            uxNewArrivalList.DataSource = newProducts;
            uxNewArrivalList.DataBind();
        }
        else
        {
            uxNewArrivalCategory.Visible = false;
        }
    }
Exemplo n.º 23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        System.Drawing.Image    thumbnail_image = null;
        System.Drawing.Image    original_image  = null;
        System.Drawing.Bitmap   final_image     = null;
        System.Drawing.Graphics graphic         = null;
        String       fileNameInfo   = String.Empty;
        MemoryStream ms             = null;
        bool         errorDuplicate = false;

        try
        {
            // Get the data
            HttpPostedFile jpeg_image_upload = Request.Files["Filedata"];
            fileNameInfo = Path.GetFileName(jpeg_image_upload.FileName);
            using (original_image = System.Drawing.Image.FromStream(jpeg_image_upload.InputStream))
            {
                using (ProductImageFile imageFile = new ProductImageFile(new FileManager(), fileNameInfo, original_image))
                {
                    if (IsUsedByAnotherProduct(imageFile.LargeFilePath))
                    {
                        errorDuplicate = true;
                        Response.End();
                    }

                    imageFile.SaveLargeImage();
                    imageFile.SaveRegular();
                    imageFile.SaveThumbnail();

                    if (ProductID == "0")
                    {
                        int sortOrder = ProductImageData.GetNexOrder();

                        ProductImageData.AddImageItem(
                            imageFile.ThumbnailFilePath,
                            imageFile.RegularFilePath,
                            imageFile.LargeFilePath,
                            ProductImageFile.GetImageSize(new FileManager(), imageFile.LargeFilePath),
                            sortOrder,
                            IsZoomable(imageFile),
                            true,
                            imageFile.LargeImageWidth,
                            imageFile.LargeImageHeight,
                            StoreContext.Culture,
                            "",
                            ""
                            );

                        if (sortOrder == 0)
                        {
                            SaveSecondaryNoProduct(imageFile);
                        }
                    }
                    else
                    {
                        string       storeID      = new StoreRetriever().GetCurrentStoreID();
                        Product      product      = DataAccessContext.ProductRepository.GetOne(StoreContext.Culture, ProductID, storeID);
                        ProductImage productImage = new ProductImage();

                        productImage.RegularImage   = imageFile.RegularFilePath;
                        productImage.LargeImage     = imageFile.LargeFilePath;
                        productImage.ThumbnailImage = imageFile.ThumbnailFilePath;
                        productImage.IsZoom         = IsZoomable(imageFile);
                        productImage.IsEnlarge      = true;

                        if (product.ProductImages.Count == 0)
                        {
                            SaveSecondary(product, imageFile);
                        }

                        productImage.SortOrder = product.ProductImages.Count;

                        product.ProductImages.Add(productImage);

                        DataAccessContext.ProductRepository.Save(product);
                    }
                }
            }
            Response.StatusCode = 200;
            Response.Write("Success");
        }
        catch
        {
            // If any kind of error occurs return a 500 Internal Server error

            if (!errorDuplicate)
            {
                Response.StatusCode = 500;
                Response.Write("An error occured");
            }
            else
            {
                Response.StatusCode = 601;
                Response.Write("Upload Error Duplicated");
            }
            Response.End();
        }
        finally
        {
            // Clean up
            if (final_image != null)
            {
                final_image.Dispose();
            }
            if (graphic != null)
            {
                graphic.Dispose();
            }
            if (original_image != null)
            {
                original_image.Dispose();
            }
            if (thumbnail_image != null)
            {
                thumbnail_image.Dispose();
            }
            if (ms != null)
            {
                ms.Close();
            }
            Response.End();
        }
    }
Exemplo n.º 24
0
    private void UpdateEmailSubscriber(string email, string emailOld)
    {
        StoreRetriever storeRetriever = new StoreRetriever();
        Store          store          = storeRetriever.GetStore();
        string         emailHash      = SecurityUtilities.HashMD5(email + WebConfiguration.SecretKey);

        if (uxSubscribeCheckBox.Checked)
        {
            NewsLetter newsLetterOld = DataAccessContext.NewsLetterRepository.GetOne(emailOld, store);
            NewsLetter newsLetter    = DataAccessContext.NewsLetterRepository.GetOne(email, store);

            if (newsLetterOld.IsNull)
            {
                if (newsLetter.IsNull)
                {
                    newsLetter.Email     = email;
                    newsLetter.EmailHash = emailHash;
                    newsLetter.JoinDate  = DateTime.Now;
                    newsLetter.StoreID   = store.StoreID;
                    DataAccessContext.NewsLetterRepository.Create(newsLetter);
                }
            }
            else
            {
                if (MoreThanOneUserSubscribeWithEmail(emailOld))
                {
                    // No need to delete old email
                    if (newsLetter.IsNull)
                    {
                        newsLetter.Email     = email;
                        newsLetter.EmailHash = emailHash;
                        newsLetter.JoinDate  = DateTime.Now;
                        newsLetter.StoreID   = store.StoreID;
                        DataAccessContext.NewsLetterRepository.Create(newsLetter);
                    }
                }
                else
                {
                    if (String.Compare(email, emailOld) != 0)
                    {
                        // No need to keep old email
                        if (newsLetter.IsNull)
                        {
                            newsLetterOld.EmailHash = emailHash;
                            DataAccessContext.NewsLetterRepository.Update(newsLetterOld, email, store.StoreID);
                        }
                        else
                        {
                            DataAccessContext.NewsLetterRepository.DeleteEmailNoHash(emailOld, store);
                        }
                    }
                }
            }
        }
        else
        {
            if (!MoreThanOneUserSubscribeWithEmail(email))
            {
                DataAccessContext.NewsLetterRepository.DeleteEmail(emailHash, store);
            }
        }
    }
Exemplo n.º 25
0
    private bool CheckOutOfStock(IList <PromotionSelectedItem> items)
    {
        string storeID = new StoreRetriever().GetCurrentStoreID();

        foreach (PromotionSelectedItem item in items)
        {
            Product product = item.Product;
            int     currentStock;
            if (item.ProductOptionIDs.Count <= 0)
            {
                if (IsOutOfStock(product.ProductID, item.GetPromotionProduct.Quantity, out currentStock))
                {
                    //uxMessage.DisplayError( product.Name + " cannot be added to shopping cart because out of stock." );
                    return(false);
                }
            }
            else
            {
                IList <ProductOptionGroup> groups = DataAccessContext.ProductRepository.GetProductOptionGroups(StoreContext.Culture, product.ProductID);

                IList <ProductOptionGroup> optionGroupsInputList        = new List <ProductOptionGroup>();
                IList <ProductOptionGroup> optionGroupsWithoutInputList = new List <ProductOptionGroup>();
                foreach (ProductOptionGroup group in groups)
                {
                    if (!(group.OptionGroup.Type == OptionGroup.OptionGroupType.InputList))
                    {
                        optionGroupsWithoutInputList.Add(group);
                    }
                    else
                    {
                        optionGroupsInputList.Add(group);
                    }
                }
                if (optionGroupsInputList.Count <= 0)
                {
                    ArrayList optionsUseStock = item.GetUseStockOptionItems();
                    if (!VerifyStockOption(
                            product.ProductID, optionsUseStock, item.GetPromotionProduct.Quantity, out currentStock, storeID))
                    {
                        //uxMessage.DisplayError( product.Name + " cannot be added to shopping cart because out of stock." );
                        return(false);
                    }
                }
                else
                {
                    currentStock = 0;
                    ArrayList optionIDsWithStock = item.GetUseStockOptionItems();
                    if (optionIDsWithStock.Count > 0)
                    {
                        if (!VerifyStockOption(
                                product.ProductID,
                                optionIDsWithStock,
                                item.GetPromotionProduct.Quantity,
                                out currentStock, storeID))
                        {
                            //uxMessage.DisplayError( product.Name + " cannot be added to shopping cart because out of stock." );
                            return(false);
                        }
                    }
                }
            }
        }
        return(true);
    }