private bool checkQuickAdd() { LblErr.Text = RenderError(""); LblOk.Text = RenderSuccess(""); bool res = true; string err = ""; var pfilter = new ProductItemFilter(); var filter = new ItemAttributeValueFilter(); pfilter.ThreadId = CurrentId; pfilter.ShowOnlyRootItems = false; var pChilds = new ProductItemsManager(true, true).GetByFilter(pfilter, ""); foreach (var pChild in pChilds) { int pId = pChild.Id; filter.ItemId = pId; var values = man.GetByFilter(filter, ""); int foundIn = 0, presentAttributes = 0; // QUI salvo gli attributi quick edit foreach (var attribute in attributes) { if (!attribute.AllowCustomValue) { DropDownList d1 = new DropDownList(); d1 = (DropDownList)PanelAttributes.FindControl("DropAttributeValuesQuick" + attribute.Name); int attributeValueId = 0; int.TryParse(d1.SelectedValue, out attributeValueId); if (attributeValueId > 0) { presentAttributes++; var exist = values.Exists(x => x.AttributeId == attribute.Id && x.AttributeValueId == attributeValueId); if (exist) { foundIn++; } } } } if (foundIn == presentAttributes) { res = false; err += "Existing variant<br />"; } } LblErr.Text = RenderError(err); return res; }
private bool checkForm() { LblErr.Text = RenderError(""); LblOk.Text = RenderSuccess(""); bool res = true; string err = ""; if (!string.IsNullOrEmpty(TxtAlias.Text)) { var filter = new ProductItemFilter(); var list = new List<PigeonCms.Shop.ProductItem>(); filter.Alias = TxtAlias.Text; list = new ProductItemsManager().GetByFilter(filter, ""); if (list.Count > 0) { if (this.CurrentId == 0) { res = false; err += "alias in use<br />"; } else { if (list[0].Id != this.CurrentId && this.CurrentId == list[0].Id) { res = false; err += "alias in use<br />"; } } } } LblErr.Text = RenderError(err); return res; }
protected void ObjDs2_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { //see http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx //for use generics with ObjDs TypeName var filter = new ProductItemFilter(); filter.Enabled = Utility.TristateBool.NotSet; switch (DropEnabledFilter.SelectedValue) { case "1": filter.Enabled = Utility.TristateBool.True; break; case "0": filter.Enabled = Utility.TristateBool.False; break; default: filter.Enabled = Utility.TristateBool.NotSet; break; } filter.ShowOnlyRootItems = false; var main = new ProductItemsManager(true, true).GetByKey(base.CurrentId); int setDrop = 0; int.TryParse(DropSets.SelectedValue, out setDrop); int setId = (main.AttributeSet > 0) ? main.AttributeSet : setDrop; filter.ProductType = (int)ProductItem.ProductTypeEnum.Simple; filter.AttributeSet = setId; e.InputParameters["filter"] = filter; e.InputParameters["sort"] = ""; }
protected void ObjDs3_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { //see http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx //for use generics with ObjDs TypeName var filter = new ProductItemFilter(); filter.Enabled = Utility.TristateBool.NotSet; switch (DropEnabledFilter.SelectedValue) { case "1": filter.Enabled = Utility.TristateBool.True; break; case "0": filter.Enabled = Utility.TristateBool.False; break; default: filter.Enabled = Utility.TristateBool.NotSet; break; } filter.ShowOnlyRootItems = true; e.InputParameters["filter"] = filter; e.InputParameters["sort"] = ""; }
protected void ObjDs1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e) { //see http://msdn.microsoft.com/en-us/library/w3f99sx1.aspx //for use generics with ObjDs TypeName var filter = new ProductItemFilter(); filter.Enabled = Utility.TristateBool.NotSet; switch (DropEnabledFilter.SelectedValue) { case "1": filter.Enabled = Utility.TristateBool.True; break; case "0": filter.Enabled = Utility.TristateBool.False; break; default: filter.Enabled = Utility.TristateBool.NotSet; break; } int threadId = 0; int.TryParse(base.CurrentKey, out threadId); if (threadId > 0) { filter.ShowOnlyRootItems = false; filter.ThreadId = threadId; } int catId = -1; int.TryParse(DropCategoriesFilter.SelectedValue, out catId); int prodType = -1; int.TryParse(DropProductTypeFilter.SelectedValue, out prodType); if (base.SectionId > 0) filter.SectionId = base.SectionId; else filter.SectionId = PRODUCT_SECTION; //TODO with settings; filter.CategoryId = catId; if (prodType > 0) filter.ProductType = prodType; e.InputParameters["filter"] = filter; e.InputParameters["sort"] = ""; }