示例#1
0
        protected void Page_Init(object sender, System.EventArgs e)
        {
            // locate group to delete
            _GroupId = AlwaysConvert.ToInt(Request.QueryString["GroupId"]);
            Group group = GroupDataSource.Load(_GroupId);

            if (group == null)
            {
                Response.Redirect("Default.aspx");
            }

            // groups managed by the application cannot be deleted
            if (group.IsReadOnly)
            {
                Response.Redirect("Default.aspx");
            }

            // ensure user has permission to edit this group
            IList <Group> managableGroups = SecurityUtility.GetManagableGroups();

            if (managableGroups.IndexOf(group) < 0)
            {
                Response.Redirect("Default.aspx");
            }

            Caption.Text         = string.Format(Caption.Text, group.Name);
            InstructionText.Text = string.Format(InstructionText.Text, group.Name);
            BindGroups(group);
        }
 public MyMusicPage()
 {
     rootpage = MainPage.Current;
     this.InitializeComponent();
     //InitializeDropShadow(ShadowHost, CircleImage);
     ArtistData = GroupDataSource.getGroupDataSource();
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            _EmailListId = AlwaysConvert.ToInt(Request.QueryString["EmailListId"]);
            _EmailList   = EmailListDataSource.Load(_EmailListId);
            if (_EmailList == null)
            {
                Response.Redirect("Default.aspx");
            }
            if (!Page.IsPostBack)
            {
                Caption.Text = string.Format(Caption.Text, _EmailList.Name);
                EmailListUsersCaption.Text = string.Format(EmailListUsersCaption.Text, _EmailList.Name);
                SearchUsersGrid.Visible    = false;
                if (Request.UrlReferrer.AbsolutePath.EndsWith("ManageList.aspx"))
                {
                    FinishLink.NavigateUrl = "ManageList.aspx?EmailListId=" + _EmailListId;
                }
            }

            AlphabetRepeater.DataSource = GetAlphabetDS();
            AlphabetRepeater.DataBind();
            AbleCommerce.Code.PageHelper.SetDefaultButton(SearchEmail, SearchButton.ClientID);
            IList <Group> storeGroups = GroupDataSource.LoadAll();

            SearchGroup.DataSource     = storeGroups;
            SearchGroup.DataTextField  = "Name";
            SearchGroup.DataValueField = "GroupId";
            SearchGroup.DataBind();
        }
示例#4
0
        private void BindSubscriptionGroup()
        {
            SubscriptionGroup.Items.Clear();
            SubscriptionGroup.Items.Add(new ListItem(string.Empty));
            IList <CommerceBuilder.Users.Group> groupCol = GroupDataSource.LoadAll("Name");

            CommerceBuilder.Users.Group group;
            for (int i = groupCol.Count - 1; i >= 0; i--)
            {
                group = groupCol[i];
                if (group.Roles.Count > 0)
                {
                    groupCol.RemoveAt(i);
                }
            }

            SubscriptionGroup.DataSource = groupCol;
            SubscriptionGroup.DataBind();

            // SELECT VALUE
            ListItem item = SubscriptionGroup.Items.FindByValue(_Subscription.GroupId.ToString());

            if (item != null)
            {
                item.Selected = true;
            }
        }
 protected void UpdateGroup()
 {
     if (Page.IsValid)
     {
         CommerceBuilder.Users.Group group = GroupDataSource.Load(this.GroupId);
         group.Name = Name.Text;
         group.Roles.Clear();
         group.Save();
         foreach (ListItem roleListItem in RoleList.Items)
         {
             if (roleListItem.Selected)
             {
                 Role role = RoleDataSource.Load(AlwaysConvert.ToInt(roleListItem.Value));
                 group.Roles.Add(role);
             }
         }
         group.Save();
         SavedMessage.Text    = string.Format(SavedMessage.Text, group.Name);
         SavedMessage.Visible = true;
         if (ItemUpdated != null)
         {
             ItemUpdated(this, new PersistentItemEventArgs(this.GroupId, group.Name));
         }
     }
 }
示例#6
0
 protected void SaveSpecial()
 {
     _Special.Price     = AlwaysConvert.ToDecimal(Price.Text);
     _Special.StartDate = StartDate.SelectedDate;
     _Special.EndDate   = EndDate.SelectedEndDate;
     _Special.Groups.Clear();
     _Special.Save();
     if (SelectedGroups.Checked)
     {
         foreach (ListItem item in Groups.Items)
         {
             CommerceBuilder.Users.Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value));
             if (item.Selected)
             {
                 _Special.Groups.Add(group);
             }
         }
         if (_Special.Groups.Count == 0)
         {
             SelectedGroups.Checked = false;
             AllGroups.Checked      = true;
         }
     }
     _Special.Save();
 }
示例#7
0
 protected void SaveButton_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         PaymentMethod _PaymentMethod = PaymentMethodDataSource.Load(PaymentMethodId);
         _PaymentMethod.Name = Name.Text;
         _PaymentMethod.PaymentInstrumentType = (PaymentInstrumentType)AlwaysConvert.ToInt16(PaymentInstrumentList.SelectedValue);
         _PaymentMethod.PaymentGateway        = PaymentGatewayDataSource.Load(AlwaysConvert.ToInt(GatewayList.SelectedValue));
         _PaymentMethod.AllowSubscriptions    = AllowSubscriptionPayments.Checked;
         //GROUP RESTRICTION
         _PaymentMethod.Groups.Clear();
         _PaymentMethod.Save();
         if (UseGroupRestriction.SelectedIndex > 0)
         {
             foreach (ListItem item in GroupList.Items)
             {
                 Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value));
                 if (item.Selected)
                 {
                     _PaymentMethod.Groups.Add(group);
                 }
             }
         }
         _PaymentMethod.Save();
         //TRIGER ANY EVENT ATTACHED TO THE UPDATE
         if (ItemUpdated != null)
         {
             ItemUpdated(this, new PersistentItemEventArgs(PaymentMethodId, _PaymentMethod.Name));
         }
     }
 }
示例#8
0
        /// <summary>
        /// Creates a new store object
        /// </summary>
        /// <param name="storeName">Name of the new store</param>
        /// <param name="adminEmail">Email address of initial super user account</param>
        /// <param name="adminPassword">Password for initial super user account</param>
        /// <param name="switchContext">If true, the token context is switched to the new store.  If false, the token
        /// context remains the same as it was before the method is called.</param>
        /// <returns>The created store object</returns>
        public static Store CreateStore(string storeName, string adminEmail, string adminPassword, bool switchContext)
        {
            //NEED TO SAVE THE CURRENT STORE CONTEXT
            Store masterStore = Token.Instance.Store;
            //CREATE THE STORE
            Store newStore = new Store();

            newStore.Name             = storeName;
            newStore.NextOrderId      = 1;
            newStore.OrderIdIncrement = 1;
            newStore.WeightUnit       = CommerceBuilder.Shipping.WeightUnit.Pounds;
            newStore.MeasurementUnit  = CommerceBuilder.Shipping.MeasurementUnit.Inches;
            newStore.Save();
            //NEED TO SWITCH OUR TOKEN CONTEXT TO THE NEW STORE
            Token.Instance.InitStoreContext(newStore);
            //INITIALIZE THE AUDIT LOGS
            Logger.Audit(AuditEventType.ApplicationStarted, true, string.Empty);
            //INITIALIZE ROLES AND GROUPS
            RoleDataSource.EnsureDefaultRoles();
            GroupDataSource.EnsureDefaultGroups();
            //CREATE THE SUPER USER
            User user = UserDataSource.CreateUser(adminEmail, adminPassword);

            //ASSIGN USER TO APPROPRIATE GROUP
            CommerceBuilder.Users.Group suGroup = GroupDataSource.LoadForName("Super Users");
            user.UserGroups.Add(new UserGroup(user.UserId, suGroup.GroupId));
            user.Save();
            //RESET THE ORIGINAL STORE CONTEXT
            if (!switchContext)
            {
                Token.Instance.InitStoreContext(masterStore);
            }
            //RETURN THE NEW STORE
            return(newStore);
        }
示例#9
0
        private void BindGroups(Group group)
        {
            IList <Group> groups = GroupDataSource.LoadAll("Name");

            groups.RemoveAt(groups.IndexOf(group));
            GroupList.DataSource = groups;
            GroupList.DataBind();
        }
示例#10
0
        protected void DeleteButton_Click(object sender, System.EventArgs e)
        {
            // GET NEW GROUP FOR USERS (IF SELECTED)
            int newGroupId = AlwaysConvert.ToInt(GroupList.SelectedValue);

            GroupDataSource.Delete(_GroupId, newGroupId);
            Response.Redirect("Default.aspx");
        }
 protected void BindGroups()
 {
     GroupListPanel.Visible = (UseGroupRestriction.SelectedIndex > 0);
     if (GroupListPanel.Visible)
     {
         GroupList.DataSource = GroupDataSource.LoadAll("Name");
         GroupList.DataBind();
     }
 }
示例#12
0
        /// <summary>
        /// Validates the password against the effective policy
        /// </summary>
        /// <returns>True if the password is valid, false if it does not meet the policy requirements.</returns>
        private bool ValidatePassword()
        {
            // GET THE INITIAL GROUP SO WE CAN DETERMINE PASSWORD POLICY TO EMPLOY
            int groupId = AlwaysConvert.ToInt(AddGroup.SelectedValue);

            CommerceBuilder.Users.Group group = GroupDataSource.Load(groupId);

            // LOAD THE APPROPRIATE PASSWORD POLICY
            PasswordPolicy policy;

            if (IsAdminGroup(group))
            {
                policy = new MerchantPasswordPolicy();
            }
            else
            {
                policy = new CustomerPasswordPolicy();
            }

            PasswordTestResult result = policy.TestPasswordWithFeedback(null, AddPassword.Text);

            if ((result & PasswordTestResult.Success) != PasswordTestResult.Success)
            {
                // THE PASSWORD DOES NOT MEET THE POLICY
                if ((result & PasswordTestResult.PasswordTooShort) == PasswordTestResult.PasswordTooShort)
                {
                    AddCustomValidationError(phPasswordValidation, AddPassword, "Password length must be at least " + policy.MinLength.ToString() + " characters.");
                }
                if ((result & PasswordTestResult.RequireUpper) == PasswordTestResult.RequireUpper)
                {
                    AddCustomValidationError(phPasswordValidation, AddPassword, "Password must contain at least one uppercase character.");
                }
                if ((result & PasswordTestResult.RequireLower) == PasswordTestResult.RequireLower)
                {
                    AddCustomValidationError(phPasswordValidation, AddPassword, "Password must contain at least one lowercase character.");
                }
                if ((result & PasswordTestResult.RequireNumber) == PasswordTestResult.RequireNumber)
                {
                    AddCustomValidationError(phPasswordValidation, AddPassword, "Password must contain at least one number.");
                }
                if ((result & PasswordTestResult.RequireSymbol) == PasswordTestResult.RequireSymbol)
                {
                    AddCustomValidationError(phPasswordValidation, AddPassword, "Password must contain at least one symbol (e.g. underscore or punctuation)");
                }
                if ((result & PasswordTestResult.RequireSymbol) == PasswordTestResult.RequireSymbol)
                {
                    AddCustomValidationError(phPasswordValidation, AddPassword, "Password must contain at least one symbol (e.g. underscore or punctuation)");
                }
                if ((result & PasswordTestResult.RequireNonAlpha) == PasswordTestResult.RequireNonAlpha)
                {
                    AddCustomValidationError(phPasswordValidation, AddPassword, "Password must contain at least one non-alphabetic character");
                }
                return(false);
            }
            return(true);
        }
        public static bool AssignAllProducts(ProductFilter filter, int[] groupIds, string groupRestrictions)
        {
            int totalCount   = ProductDataSource.FindProductsCount(filter.Name, filter.SearchDescriptions, filter.Sku, filter.CategoryId, filter.ManufacturerId, filter.VendorId, filter.Featured, 0, filter.FromPrice, filter.ToPrice, filter.DigitalGoodsOnly, filter.GiftCertificatesOnly, filter.KitsOnly, filter.SubscriptionsOnly);
            int currentIndex = 0;
            IDatabaseSessionManager database = AbleContext.Current.Database;

            database.BeginTransaction();
            List <Group> groups = new List <Group>();

            foreach (int gid in groupIds)
            {
                Group group = GroupDataSource.Load(gid);
                if (group != null)
                {
                    groups.Add(group);
                }
            }
            while (currentIndex < totalCount)
            {
                IList <Product> currentBatch = ProductDataSource.FindProducts(filter.Name, filter.SearchDescriptions, filter.Sku, filter.CategoryId, filter.ManufacturerId, filter.VendorId, filter.Featured, 0, filter.FromPrice, filter.ToPrice, filter.DigitalGoodsOnly, filter.GiftCertificatesOnly, filter.KitsOnly, filter.SubscriptionsOnly, 100, currentIndex);
                foreach (Product p in currentBatch)
                {
                    foreach (Group group in groups)
                    {
                        ProductGroup pg = ProductGroupDataSource.Load(p.Id, group.Id);
                        if (pg == null)
                        {
                            pg = new ProductGroup(p, group);
                            p.ProductGroups.Add(pg);
                        }
                    }

                    switch (groupRestrictions)
                    {
                    case "YES":
                        p.EnableGroups = true;
                        break;

                    case "NO":
                        p.EnableGroups = false;
                        break;

                    default:
                        break;
                    }

                    p.Save();
                }
                currentIndex += 100;
            }

            database.CommitTransaction();
            return(true);
        }
        private List <int> GetValidGroupIds()
        {
            List <int>    allGroupIds = new List <int>();
            IList <Group> allGroups   = GroupDataSource.LoadAll();

            foreach (Group c in allGroups)
            {
                allGroupIds.Add(c.Id);
            }
            return(allGroupIds);
        }
示例#15
0
        protected void SaveButton_Click(object sender, System.EventArgs e)
        {
            if (Page.IsValid)
            {
                _Affiliate.Name                = Name.Text;
                _Affiliate.ReferralDays        = AlwaysConvert.ToInt16(ReferralDays.Text);
                _Affiliate.CommissionRate      = AlwaysConvert.ToDecimal(CommissionRate.Text);
                _Affiliate.CommissionIsPercent = (CommissionType.SelectedIndex > 0);
                _Affiliate.CommissionOnTotal   = (CommissionType.SelectedIndex == 2);
                _Affiliate.WebsiteUrl          = WebsiteUrl.Text;
                _Affiliate.Email               = Email.Text;
                _Affiliate.Group               = GroupDataSource.Load(AlwaysConvert.ToInt(AffiliateGroup.SelectedValue));

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

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

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

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

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

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

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

            if (g != null)
            {
                return(g.Name);
            }
            else
            {
                return(string.Empty);
            }
        }
示例#18
0
        protected String GetGroupName(object id)
        {
            int   groupId = AlwaysConvert.ToInt(id);
            Group group   = GroupDataSource.Load(groupId);

            if (group != null)
            {
                return(group.Name);
            }
            else
            {
                return(string.Empty);
            }
        }
        public static bool AssignProducts(int[] productIds, int[] groupIds, string groupRestrictions)
        {
            List <string>           ids      = new List <string>();
            IDatabaseSessionManager database = AbleContext.Current.Database;

            database.BeginTransaction();
            List <Group> groups = new List <Group>();

            foreach (int gid in groupIds)
            {
                Group group = GroupDataSource.Load(gid);
                if (group != null)
                {
                    groups.Add(group);
                }
            }

            foreach (int pid in productIds)
            {
                Product product = ProductDataSource.Load(pid);
                foreach (Group group in groups)
                {
                    ProductGroup pg = ProductGroupDataSource.Load(pid, group.Id);
                    if (pg == null)
                    {
                        pg = new ProductGroup(product, group);
                        product.ProductGroups.Add(pg);
                    }
                }

                switch (groupRestrictions)
                {
                case "YES":
                    product.EnableGroups = true;
                    break;

                case "NO":
                    product.EnableGroups = false;
                    break;

                default:
                    break;
                }

                product.Save();
            }
            database.CommitTransaction();
            return(true);
        }
示例#20
0
 protected void BindGroups()
 {
     GroupListPanel.Visible = (UseGroupRestriction.SelectedIndex > 0);
     if (GroupListPanel.Visible)
     {
         GroupList.DataSource = GroupDataSource.LoadAll("Name");
         GroupList.DataBind();
         foreach (CommerceBuilder.Users.Group item in _ShipMethod.Groups)
         {
             ListItem listItem = GroupList.Items.FindByValue(item.Id.ToString());
             if (listItem != null)
             {
                 listItem.Selected = true;
             }
         }
     }
 }
 protected void BindGroups()
 {
     GroupListPanel.Visible = (UseGroupRestriction.SelectedIndex > 0);
     if (GroupListPanel.Visible)
     {
         GroupList.DataSource = GroupDataSource.LoadAll("Name");
         GroupList.DataBind();
         foreach (Group group in _VolumeDiscount.Groups)
         {
             ListItem listItem = GroupList.Items.FindByValue(group.Id.ToString());
             if (listItem != null)
             {
                 listItem.Selected = true;
             }
         }
     }
 }
示例#22
0
        protected void GroupGrid_RowEditing(object sender, GridViewEditEventArgs e)
        {
            int groupId = (int)GroupGrid.DataKeys[e.NewEditIndex].Value;

            CommerceBuilder.Users.Group group = GroupDataSource.Load(groupId);
            if (group != null)
            {
                AddPanel.Visible  = false;
                EditPanel.Visible = true;
                EditCaption.Text  = string.Format(EditCaption.Text, group.Name);
                EditGroupDialog editDialog = EditPanel.FindControl("EditGroupDialog1") as EditGroupDialog;
                if (editDialog != null)
                {
                    editDialog.GroupId = groupId;
                }
                AddEditAjax.Update();
            }
        }
示例#23
0
        private void BindGroup()
        {
            Groups.Items.Clear();
            IList <CommerceBuilder.Users.Group> groupCol = GroupDataSource.LoadAll("Name");

            CommerceBuilder.Users.Group group;
            for (int i = groupCol.Count - 1; i >= 0; i--)
            {
                group = groupCol[i];
                if (group.IsInRole(Role.AllAdminRoles))
                {
                    groupCol.RemoveAt(i);
                }
            }

            Groups.DataSource = groupCol;
            Groups.DataBind();
        }
示例#24
0
        private void BindSubscriptionGroup()
        {
            SubscriptionGroup.Items.Clear();
            SubscriptionGroup.Items.Add(new ListItem(string.Empty));
            IList <CommerceBuilder.Users.Group> groupCol = GroupDataSource.LoadAll("Name");

            CommerceBuilder.Users.Group group;
            for (int i = groupCol.Count - 1; i >= 0; i--)
            {
                group = groupCol[i];
                if (group.Roles.Count > 0 && group.IsInRole(Role.AllAdminRoles) || Group.DefaultUserGroupName.Equals(group.Name))
                {
                    groupCol.RemoveAt(i);
                }
            }

            SubscriptionGroup.DataSource = groupCol;
            SubscriptionGroup.DataBind();
        }
示例#25
0
        protected void BindGroups()
        {
            PaymentMethod _PaymentMethod = PaymentMethodDataSource.Load(PaymentMethodId);

            GroupListPanel.Visible = (UseGroupRestriction.SelectedIndex > 0);
            if (GroupListPanel.Visible)
            {
                GroupList.DataSource = GroupDataSource.LoadAll("Name");
                GroupList.DataBind();
                foreach (Group r in _PaymentMethod.Groups)
                {
                    ListItem item = GroupList.Items.FindByValue(r.Id.ToString());
                    if (item != null)
                    {
                        item.Selected = true;
                    }
                }
            }
        }
示例#26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _GroupId = AlwaysConvert.ToInt(Request.QueryString["GroupId"]);
            Group group = GroupDataSource.Load(_GroupId);

            if (group == null)
            {
                Response.Redirect("Default.aspx");
            }

            // ensure user has permission to manage this group
            IList <Group> managableGroups = SecurityUtility.GetManagableGroups();

            if (managableGroups.IndexOf(group) < 0)
            {
                Response.Redirect("Default.aspx");
            }

            _IsReadonlyGroup = group.IsReadOnly;
            _Subscriptions   = group.SubscriptionPlans.Count;

            AlphabetRepeater.DataSource = GetAlphabetDS();
            AlphabetRepeater.DataBind();

            if (!Page.IsPostBack)
            {
                SearchGroup.DataSource     = AbleContext.Current.Store.Groups;
                SearchGroup.DataTextField  = "Name";
                SearchGroup.DataValueField = "GroupId";
                SearchGroup.DataBind();

                Caption.Text = string.Format(Caption.Text, group.Name);
                ListItem item = SearchGroup.Items.FindByValue(_GroupId.ToString());
                if (item != null)
                {
                    Session.Remove("ManageUserSearchCriteria");
                    SearchGroup.ClearSelection();
                    item.Selected = true;
                }
                LoadLastSearch();
            }
        }
 protected void Page_PreRender(object sender, EventArgs e)
 {
     CommerceBuilder.Users.Group group = GroupDataSource.Load(this.GroupId);
     if (group != null)
     {
         Name.Text = group.Name;
         RoleList.SelectedIndex = -1;
         foreach (Role role in group.Roles)
         {
             ListItem item = RoleList.Items.FindByValue(role.Id.ToString());
             if (item != null)
             {
                 item.Selected = true;
             }
         }
     }
     else
     {
         this.Controls.Clear();
     }
 }
        protected void Page_Init()
        {
            IList <TaxCode> taxCodes = TaxCodeDataSource.LoadAll();

            TaxCodes.DataSource = taxCodes;
            TaxCodes.DataBind();
            TaxCode.Items.Clear();
            TaxCode.Items.Add("");
            TaxCode.DataSource = taxCodes;
            TaxCode.DataBind();
            ZoneList.DataSource = ShipZoneDataSource.LoadAll("Name");
            ZoneList.DataBind();
            GroupList.DataSource = GroupDataSource.LoadAll("Name");
            GroupList.DataBind();

            // ROUNDING RULE
            RoundingRule.Items.Clear();
            RoundingRule.Items.Add(new ListItem("Common Method", ((int)CommerceBuilder.Taxes.RoundingRule.Common).ToString()));
            RoundingRule.Items.Add(new ListItem("Round to Even", ((int)CommerceBuilder.Taxes.RoundingRule.RoundToEven).ToString()));
            RoundingRule.Items.Add(new ListItem("Always Round Up", ((int)CommerceBuilder.Taxes.RoundingRule.AlwaysRoundUp).ToString()));
        }
示例#29
0
        protected void IsInGroup_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox    isInGroup     = (CheckBox)sender;
            GridViewRow row           = (GridViewRow)isInGroup.NamingContainer;
            GridView    grid          = row.NamingContainer as GridView;
            int         dataItemIndex = (row.DataItemIndex - (grid.PageSize * grid.PageIndex));
            int         userId        = (int)grid.DataKeys[dataItemIndex].Value;

            User user = UserDataSource.Load(userId);

            CommerceBuilder.Users.Group group = GroupDataSource.Load(_GroupId);
            UserGroup userGroup = UserGroupDataSource.Load(user.Id, group.Id);

            if (userGroup == null)
            {
                userGroup = new UserGroup(user, group);
            }
            int index = user.UserGroups.IndexOf(userGroup);

            if (isInGroup.Checked)
            {
                //IN ROLE WAS CHECKED, ADD ROLE IF NOT FOUND
                if (index < 0)
                {
                    user.UserGroups.Add(userGroup);
                    user.UserGroups.Save();
                    AbleContext.Current.Database.FlushSession();
                }
            }
            else
            {
                //IN ROLE WAS UNCHECKED, DELETE ROLE IF FOUND
                if (index > -1)
                {
                    user.UserGroups.DeleteAt(index);
                }
            }
            //REBIND GRIDS
            BindSearchPanel();
        }
        protected void AddButton_Click(object sender, System.EventArgs e)
        {
            PaymentMethod method = new PaymentMethod();

            method.Name = Name.Text;
            method.PaymentInstrumentType = (PaymentInstrumentType)AlwaysConvert.ToInt16(PaymentInstrumentList.SelectedValue);
            method.PaymentGateway        = PaymentGatewayDataSource.Load(AlwaysConvert.ToInt(GatewayList.SelectedValue));
            method.AllowSubscriptions    = AllowSubscriptionPayments.Checked;
            //GROUP RESTRICTION
            if (UseGroupRestriction.SelectedIndex > 0)
            {
                foreach (ListItem item in GroupList.Items)
                {
                    Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value));
                    if (item.Selected)
                    {
                        method.Groups.Add(group);
                    }
                }
            }
            method.OrderBy = (short)PaymentMethodDataSource.GetNextOrderBy();
            method.Save();
            //UPDATE THE ADD MESSAGE
            AddedMessage.Text    = string.Format(AddedMessage.Text, method.Name);
            AddedMessage.Visible = true;
            //RESET THE ADD FORM
            PaymentInstrumentList.SelectedIndex = -1;
            Name.Text = string.Empty;
            GatewayList.SelectedIndex         = -1;
            AllowSubscriptionPayments.Checked = false;
            UseGroupRestriction.SelectedIndex = 0;
            BindGroups();
            //TRIGER ANY EVENT ATTACHED TO THE UPDATE
            if (ItemAdded != null)
            {
                ItemAdded(this, new PersistentItemEventArgs(method.Id, method.Name));
            }
        }