protected void lvGroups_OnItemCommand(object sender, ListViewCommandEventArgs e) { if (string.Equals("DeleteGroup", e.CommandName)) { PropertyGroupService.Delete(Convert.ToInt32(e.CommandArgument)); } }
protected void Page_Load(object sender, EventArgs e) { SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_Properties_Header)); if (IsPostBack) { return; } ddlGroup.DataSource = PropertyGroupService.GetList(); ddlGroup.DataBind(); ddlGroup.Items.Insert(0, Resource.Admin_m_Property_None); foreach (PropertyType item in Enum.GetValues(typeof(PropertyType))) { ddlTypes.Items.Add(new ListItem(item.GetLocalizedName(), ((int)item).ToString())); } if (PropertyId != 0) { btnOK.Text = Resource.Admin_m_News_Save; LoadProperty(PropertyId); } else { btnOK.Text = Resource.Admin_m_News_Add; txtName.Text = string.Empty; if (GroupId != 0 && ddlGroup.Items.FindByValue(GroupId.ToString()) != null) { ddlGroup.SelectedValue = GroupId.ToString(); } } }
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "DeleteGroup") { PropertyGroupService.DeleteGroupFromCategory(Convert.ToInt32(e.CommandArgument), _categoryId); } if (e.CommandName == "AddGroup") { var footer = grid.FooterRow; var groupId = ((DropDownList)footer.FindControl("ddlNewGroupName")).SelectedValue.TryParseInt(); if (groupId == 0) { grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ffcccc"); return; } PropertyGroupService.AddGroupToCategory(groupId, _categoryId); grid.ShowFooter = false; } if (e.CommandName == "CancelAdd") { grid.FooterStyle.BackColor = System.Drawing.Color.FromName("#ccffcc"); grid.ShowFooter = false; } }
protected void grid_DataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Footer) { var ddlNewGroups = ((DropDownList)e.Row.FindControl("ddlNewGroupName")); if (ddlNewGroups != null) { ddlNewGroups.DataSource = PropertyGroupService.GetList(); ddlNewGroups.DataBind(); } } }
private void LoadGroups() { var groups = PropertyGroupService.GetList(); groups.Insert(0, new PropertyGroup() { Name = Resource.Admin_Properties_UngroupedProperties, PropertyGroupId = 0 }); lvGroups.DataSource = groups; lvGroups.DataBind(); ddlAllGroups.DataSource = groups; ddlAllGroups.DataBind(); }
protected void LoadGroup(int groupId) { var group = PropertyGroupService.Get(groupId); if (group == null) { MsgErr(Resource.Admin_m_PropertyGroup_ErrorLoading); return; } txtName.Text = group.Name; txtSortOrder.Text = group.SortOrder.ToString(); var categories = PropertyGroupService.GetGroupCategories(groupId); liCategories.Text = categories.Count > 0 ? string.Join(", ", categories) : Resource.Admin_m_PropertyGroup_NoCategories; }
protected void SaveGroup() { if (!Valid()) { return; } try { PropertyGroupService.Update(new PropertyGroup() { PropertyGroupId = GroupId, Name = txtName.Text.Trim(), SortOrder = txtSortOrder.Text.TryParseInt() }); } catch (Exception ex) { Debug.LogError(ex); } }
protected void Page_PreRender(object sender, EventArgs e) { grid.DataSource = PropertyGroupService.GetListByCategory(_categoryId); grid.DataBind(); }
private void LoadDataGrid() { FillcboPropertyValue(); _properties = PropertyService.GetPropertyValuesByProductId(ProductId); var propertyGroups = PropertyGroupService.GetGroupsByCategory(CategoryId); var groups = propertyGroups.Select(g => new UsedPropertyGroupView() { PropertyGroupId = g.PropertyGroupId, GroupName = g.GroupName, Properties = propertyGroups.Where(p => p.PropertyGroupId == g.PropertyGroupId).Select(p => new Property { PropertyId = p.PropertyId, Name = p.PropertyName, Type = p.Type }).ToList() }).Distinct(new PropertyGroupComparer()); var prodPropertyValues = PropertyService.GetPropertyValuesByProductId(ProductId); var propInGroups = new List <int>(); var result = new StringBuilder(); foreach (var group in groups) { if (group.Properties.Count > 0) { result.AppendFormat("<div class='group-header' data-group='{0}'>{1}</div>", group.PropertyGroupId, group.GroupName); foreach (var property in group.Properties) { result.Append(RenderPropertyItem(property, prodPropertyValues.Where(p => p.PropertyId == property.PropertyId).ToList())); propInGroups.Add(property.PropertyId); } } } var propsWithoutCategory = prodPropertyValues.Where(p => !propInGroups.Contains(p.PropertyId)).ToList(); if (propsWithoutCategory.Count > 0) { result.AppendFormat("<div class='group-header' data-group='{0}'>{1}</div>", 0, Resource.Admin_Properties_UngroupedProperties); var propIds = new List <int>(); foreach (var propWitoutGroup in propsWithoutCategory) { if (propIds.Contains(propWitoutGroup.PropertyId)) { continue; } result.Append(RenderPropertyItem(propWitoutGroup.Property, prodPropertyValues.Where(p => p.PropertyId == propWitoutGroup.Property.PropertyId).ToList())); propIds.Add(propWitoutGroup.PropertyId); } } hfpropselected.Value = string.Join(",", prodPropertyValues.Select(x => x.PropertyValueId)); RenderingProperties = result.ToString(); }