protected int CountUsers(object dataItem) { CommerceBuilder.Users.Group group = (CommerceBuilder.Users.Group)dataItem; return(UserDataSource.CountForGroup(group.Id)); }
protected void SaveButton_Click(object sender, System.EventArgs e) { if (Page.IsValid) { //UPDATE NAME _ShipMethod.Name = Name.Text; //UPDATE RATE _ShipMethod.ServiceCode = ServiceCode.SelectedValue; //UPDATE SURCHARGE _ShipMethod.Surcharge = AlwaysConvert.ToDecimal(Surcharge.Text); if (_ShipMethod.Surcharge < 0) { _ShipMethod.Surcharge = 0; } if (_ShipMethod.Surcharge > 0) { _ShipMethod.SurchargeMode = (SurchargeMode)AlwaysConvert.ToByte(SurchargeMode.SelectedValue); _ShipMethod.SurchargeIsVisible = (SurchargeIsVisible.SelectedIndex > 0); } else { _ShipMethod.SurchargeMode = 0; _ShipMethod.SurchargeIsVisible = false; } if (_ShipMethod.SurchargeIsVisible) { _ShipMethod.SurchargeTaxCodeId = AlwaysConvert.ToInt(SurchargeTaxCode.SelectedValue); } else { _ShipMethod.SurchargeTaxCodeId = 0; } //UPDATE WAREHOUSES _ShipMethod.Warehouses.Clear(); _ShipMethod.Save(); if (UseWarehouseRestriction.SelectedIndex > 0) { foreach (ListItem item in WarehouseList.Items) { Warehouse warehouse = WarehouseDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { _ShipMethod.Warehouses.Add(warehouse); } } } //UPDATE ZONES _ShipMethod.ShipZones.Clear(); _ShipMethod.Save(); if (UseZoneRestriction.SelectedIndex > 0) { foreach (ListItem item in ZoneList.Items) { ShipZone shipZone = ShipZoneDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { _ShipMethod.ShipZones.Add(shipZone); } } } //UPDATE ROLES _ShipMethod.Groups.Clear(); if (UseGroupRestriction.SelectedIndex > 0) { foreach (ListItem item in GroupList.Items) { CommerceBuilder.Users.Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { _ShipMethod.Groups.Add(group); } } } //UPDATE MIN PURCHASE _ShipMethod.MinPurchase = AlwaysConvert.ToDecimal(MinPurchase.Text); //UPDATE MIN PURCHASE _ShipMethod.MaxPurchase = AlwaysConvert.ToDecimal(MaxPurchase.Text); //UPDATE TAX CODES _ShipMethod.TaxCode = TaxCodeDataSource.Load(AlwaysConvert.ToInt(TaxCode.SelectedValue)); //SAVE METHOD AND REDIRECT TO LIST _ShipMethod.Save(); RedirectMe(); } }
private void SaveShipMethod() { //UPDATE NAME _ShipMethod.Name = Name.Text; //UPDATE RATE ShipRateMatrix shipRateMatrixItem; if (_ShipMethod.ShipRateMatrices.Count != 1) { _ShipMethod.ShipRateMatrices.DeleteAll(); shipRateMatrixItem = new ShipRateMatrix(); shipRateMatrixItem.ShipMethod = _ShipMethod; _ShipMethod.ShipRateMatrices.Add(shipRateMatrixItem); } else { shipRateMatrixItem = _ShipMethod.ShipRateMatrices[0]; } shipRateMatrixItem.RangeStart = 0; shipRateMatrixItem.RangeEnd = 0; shipRateMatrixItem.Rate = AlwaysConvert.ToDecimal(Rate.Text); shipRateMatrixItem.IsPercent = false; //UPDATE SURCHARGE _ShipMethod.Surcharge = AlwaysConvert.ToDecimal(Surcharge.Text); if (_ShipMethod.Surcharge < 0) { _ShipMethod.Surcharge = 0; } if (_ShipMethod.Surcharge > 0) { _ShipMethod.SurchargeMode = (SurchargeMode)AlwaysConvert.ToByte(SurchargeMode.SelectedValue); _ShipMethod.SurchargeIsVisible = (SurchargeIsVisible.SelectedIndex > 0); } else { _ShipMethod.SurchargeMode = 0; _ShipMethod.SurchargeIsVisible = false; } if (_ShipMethod.SurchargeIsVisible) { _ShipMethod.SurchargeTaxCodeId = AlwaysConvert.ToInt(SurchargeTaxCode.SelectedValue); } else { _ShipMethod.SurchargeTaxCodeId = 0; } //UPDATE WAREHOUSES _ShipMethod.Warehouses.Clear(); _ShipMethod.Save(); if (UseWarehouseRestriction.SelectedIndex > 0) { foreach (ListItem item in WarehouseList.Items) { Warehouse warehouse = WarehouseDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { _ShipMethod.Warehouses.Add(warehouse); } } } //UPDATE ZONES _ShipMethod.ShipZones.Clear(); _ShipMethod.Save(); if (UseZoneRestriction.SelectedIndex > 0) { foreach (ListItem item in ZoneList.Items) { ShipZone shipZone = ShipZoneDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { _ShipMethod.ShipZones.Add(shipZone); } } } //UPDATE ROLES _ShipMethod.Groups.Clear(); _ShipMethod.Save(); if (UseGroupRestriction.SelectedIndex > 0) { foreach (ListItem item in GroupList.Items) { CommerceBuilder.Users.Group group = GroupDataSource.Load(AlwaysConvert.ToInt(item.Value)); if (item.Selected) { _ShipMethod.Groups.Add(group); } } } //UPDATE MIN PURCHASE _ShipMethod.MinPurchase = AlwaysConvert.ToDecimal(MinPurchase.Text); //UPDATE MAX PURCHASE _ShipMethod.MaxPurchase = AlwaysConvert.ToDecimal(MaxPurchase.Text); //UPDATE TAX CODES _ShipMethod.TaxCode = TaxCodeDataSource.Load(AlwaysConvert.ToInt(TaxCode.SelectedValue)); //SAVE METHOD AND REDIRECT TO LIST _ShipMethod.Save(); }
protected void InstallButton_Click(object sender, EventArgs e) { if (Page.IsValid) { // update some settings that we can determine from the script Store store = AbleContext.Current.Store; store.Name = StoreName.Text; store.Save(); store.StoreUrl = GetStoreUrl(); store.Settings.TimeZoneOffset = GetDefaultTzOffset(); store.Settings.TimeZoneCode = store.Settings.TimeZoneOffset.ToString(); // update default store email string defaultEmailAddress = StoreEmail.Text.Trim(); // use admin email if store email is not available if (string.IsNullOrEmpty(defaultEmailAddress)) { defaultEmailAddress = Email.Text.Trim(); } store.Settings.DefaultEmailAddress = defaultEmailAddress; store.Settings.Save(); // update the store address Warehouse warehouse = store.DefaultWarehouse; warehouse.Name = store.Name; warehouse.Address1 = Address1.Text; warehouse.Address2 = Address2.Text; warehouse.City = City.Text; warehouse.Province = Province.Text; warehouse.PostalCode = PostalCode.Text; warehouse.CountryCode = Country.Text; warehouse.Phone = Phone.Text; warehouse.Fax = Fax.Text; warehouse.Email = StoreEmail.Text; warehouse.Save(); // update the admin user User admin = UserDataSource.Load(1); admin.UserName = Email.Text; admin.Email = Email.Text; admin.Save(); admin.SetPassword(Password.Text); // add admin user to default group CommerceBuilder.Users.Group defaultGroup = AbleContext.Container.Resolve <IGroupRepository>() .LoadForName(CommerceBuilder.Users.Group.DefaultUserGroupName); if (defaultGroup != null) { admin.UserGroups.Add(new UserGroup(admin, defaultGroup)); admin.Save(); } Address address = admin.PrimaryAddress; address.Email = Email.Text; address.Address1 = Address1.Text; address.Address2 = Address2.Text; address.City = City.Text; address.Province = Province.Text; address.PostalCode = PostalCode.Text; address.CountryCode = Country.Text; address.Phone = Phone.Text; address.Fax = Fax.Text; address.Save(); // copy email templates string sourceDir = Server.MapPath("~/App_Data/EmailTemplates/Default"); string targetDir = Server.MapPath("~/App_Data/EmailTemplates/1"); Directory.CreateDirectory(targetDir); foreach (var file in Directory.GetFiles(sourceDir)) { File.Copy(file, Path.Combine(targetDir, Path.GetFileName(file)), true); } if (IncludeSampleData.Checked) { // add the sample data to the database string connectionString = ConfigurationManager.ConnectionStrings["AbleCommerce"].ConnectionString; List <string> errorList = RunScript(connectionString, Server.MapPath("~/Install/SampleData.sql")); // extract the sample image and email files CompressionHelper.ExtractArchive(Server.MapPath("~/install/ProductImages.zip"), Server.MapPath("~/Assets/ProductImages")); // generate a sample digital good File.WriteAllText(Server.MapPath("~/App_Data/DigitalGoods/sample.txt"), "This is a sample text file for use with digital delivery."); // check for errors in script if (errorList.Count > 0) { InstallSucceededPanel.Visible = false; InstallErrorPanel.Visible = true; InstallErrorList.Text = "<p>" + string.Join("</p><p>", errorList.ToArray()) + "</p>"; } } // Make SQL the default search provider on new installs (JIRA ISSUE # AC8-1998) ApplicationSettings.Instance.SearchProvider = "SqlSearchProvider"; ApplicationSettings.Instance.Save(); // display complete message FormPanel.Visible = false; InstallCompletePanel.Visible = true; } }