Exemple #1
0
        /// <summary>
        /// Binds the form.
        /// </summary>
        private void BindForm()
        {
            BindLists();
            if (CatalogEntryId > 0)
            {
                CatalogDto catalogDto = CatalogContext.Current.GetCatalogDto(_CatalogEntryDto.CatalogEntry[0].CatalogId);
                if (_CatalogEntryDto.CatalogEntry.Count > 0)
                {
                    if (_CatalogEntryDto.Variation.Count != 0)
                    {
                        CatalogEntryDto.VariationRow variationRow = _CatalogEntryDto.Variation[0];

                        ListPrice.Text            = variationRow.ListPrice.ToString("#0.00");              //"N2");
                        DisplayPriceCurrency.Text = catalogDto.Catalog[0].DefaultCurrency;
                        MinQty.Text = variationRow.MinQuantity.ToString();
                        MaxQty.Text = variationRow.MaxQuantity.ToString();
                        Weight.Text = variationRow.Weight.ToString();

                        if (!variationRow.IsMerchantIdNull())
                        {
                            ManagementHelper.SelectListItem(MerchantList, variationRow.MerchantId);
                        }

                        ManagementHelper.SelectListItem(PackageList, variationRow.PackageId);
                        ManagementHelper.SelectListItem(WarehouseList, variationRow.WarehouseId);
                        ManagementHelper.SelectListItem(TaxList, variationRow.TaxCategoryId);

                        TrackInventory.IsSelected = variationRow.TrackInventory;
                    }

                    if (_CatalogEntryDto.Inventory.Count != 0)
                    {
                        CatalogEntryDto.InventoryRow inventoryRow = _CatalogEntryDto.Inventory[0];

                        ManagementHelper.SelectListItem(InventoryStatusList, inventoryRow.InventoryStatus);
                        InStockQty.Text           = inventoryRow.InStockQuantity.ToString();
                        ReservedQty.Text          = inventoryRow.ReservedQuantity.ToString();
                        ReorderMinQty.Text        = inventoryRow.ReorderMinQuantity.ToString();
                        AllowPreorder.IsSelected  = inventoryRow.AllowPreorder;
                        PreorderQty.Text          = inventoryRow.PreorderQuantity.ToString();
                        PreorderAvail.Value       = ManagementHelper.GetUserDateTime(inventoryRow.PreorderAvailabilityDate);
                        AllowBackorder.IsSelected = inventoryRow.AllowBackorder;
                        BackorderQty.Text         = inventoryRow.BackorderQuantity.ToString();
                        BackorderAvail.Value      = ManagementHelper.GetUserDateTime(inventoryRow.BackorderAvailabilityDate);
                    }

                    // Bind SalePrices
                    GridHelper.BindGrid(SalePricesGrid, "Catalog", "EntrySalePrice");
                    BindSalePricesGrid();
                }
            }
            else // set defaults
            {
                InStockQty.Text           = "10";
                ReservedQty.Text          = "2";
                ReorderMinQty.Text        = "1";
                AllowPreorder.IsSelected  = false;
                PreorderQty.Text          = "10";
                PreorderAvail.Value       = ManagementHelper.GetUserDateTime(DateTime.Now.ToUniversalTime());
                AllowBackorder.IsSelected = false;
                BackorderQty.Text         = "10";
                BackorderAvail.Value      = ManagementHelper.GetUserDateTime(DateTime.Now.ToUniversalTime());
                MinQty.Text = "1";
                MaxQty.Text = "100";
                Weight.Text = Decimal.Parse("1.0", System.Globalization.CultureInfo.InvariantCulture).ToString();

                GridHelper.BindGrid(SalePricesGrid, "Catalog", "EntrySalePrice");
            }
        }
        /// <summary>
        /// Binds the membership form.
        /// </summary>
        /// <param name="id">The id.</param>
        private void BindMembershipForm(object id)
        {
            RolesList.DataSource = Roles.GetAllRoles();
            RolesList.DataBind();

            // Always enable everyone role
            ListItem item = RolesList.Items.FindByValue(AppRoles.EveryoneRole);

            if (item != null)
            {
                item.Selected = true;
                item.Enabled  = false;
            }

            // Always enable registered role
            item = RolesList.Items.FindByValue(AppRoles.RegisteredRole);
            if (item != null)
            {
                item.Selected = true;
                item.Enabled  = false;
            }

            MembershipUser user = null;

            if (id != null)
            {
                user = Membership.GetUser((Guid)id);
            }
            if (user != null)
            {
                ActionTd.Visible             = true;
                PasswordTr.Visible           = false;
                RecoveryCtrl.UserName        = user.UserName;
                PasswordCtrl.UserName        = user.UserName;
                IsApproved.IsSelected        = user.IsApproved;
                IsLockedOut.IsSelected       = user.IsLockedOut;
                LastActivityDate.Text        = ManagementHelper.GetUserDateTime(user.LastActivityDate).ToString();
                LastLockoutDate.Text         = ManagementHelper.GetUserDateTime(user.LastLockoutDate).ToString();
                LastLoginDate.Text           = ManagementHelper.GetUserDateTime(user.LastLoginDate).ToString();
                LastPasswordChangedDate.Text = ManagementHelper.GetUserDateTime(user.LastPasswordChangedDate).ToString();
                UserNameTextBox.Text         = user.UserName;
                UserNameTextBox.Enabled      = false;
                EmailText.Text      = user.Email;
                IsLockedOut.Enabled = false;
                CommentTextBox.Text = user.Comment;
                string[] roles = Roles.GetRolesForUser(user.UserName);
                if (roles != null)
                {
                    foreach (string role in roles)
                    {
                        ListItem listItem = RolesList.Items.FindByValue(role);
                        if (listItem != null)
                        {
                            listItem.Selected = true;
                        }
                    }
                }

                // Bind Login on behalf
                // Find out site url
                SiteDto.SiteDataTable sites = CMSContext.Current.GetSitesDto(CmsConfiguration.Instance.ApplicationId).Site;
                SiteDto.SiteRow       site  = null;
                if (sites != null && sites.Rows.Count > 0)
                {
                    foreach (SiteDto.SiteRow siteRow in sites.Rows)
                    {
                        if (site == null && siteRow.IsActive)
                        {
                            site = siteRow;
                        }

                        if (siteRow.IsDefault && siteRow.IsActive)
                        {
                            site = siteRow;
                        }
                    }
                }

                if (site != null)
                {
                    LoginOnBehalf.Visible     = true;
                    LoginOnBehalf.NavigateUrl = String.Format("{0}/login.aspx?customer={1}", GlobalVariable.GetVariable("url", site.SiteId), user.UserName);
                }
                else
                {
                    LoginOnBehalf.Visible = false;
                }
            }
            else
            {
                UserNameTextBox.Enabled = true;
                IsLockedOut.Enabled     = false;
            }
        }