protected void BtnAddValue_Click(object sender, EventArgs e) { LblErr.Text = ""; LblOk.Text = ""; // conrollo che non tutti i valori siano vuoti bool allEmpty = true; foreach (KeyValuePair<string, string> item in Config.CultureList) { TextBox t1 = new TextBox(); t1 = (TextBox)PanelTitle.FindControl("TxtTitle" + item.Value); if (!string.IsNullOrEmpty(t1.Text)) { allEmpty = false; break; } } if (allEmpty) { return; } try { var o1 = new AttributeValue(); if (string.IsNullOrEmpty(base.CurrentKey)) { values2obj(o1); o1 = new AttributeValuesManager().Insert(o1); } else { o1 = new AttributeValuesManager().GetByKey(Convert.ToInt32(base.CurrentKey)); //precarico i campi esistenti e nn gestiti dal form o1.ValueTranslations.Clear(); values2obj(o1); new AttributeValuesManager().Update(o1); } clearValues(); Grid1.DataBind(); GridValues.DataBind(); LblOk.Text = RenderSuccess(Utility.GetLabel("RECORD_SAVED_MSG")); } catch (Exception e1) { LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString()); } finally { } }
private void deleteValue(int recordId) { LblOk.Text = ""; LblErr.Text = ""; try { // have to check if is used by some products var ifilter = new ItemAttributeValueFilter(); var iman = new ItemAttributesValuesManager(); var vman = new AttributeValuesManager(); ifilter.AttributeValueId = recordId; bool isUsed = (iman.GetByFilter(ifilter, "").Count > 0); if (!isUsed) { vman.DeleteById(recordId); } else { LblErr.Text = RenderError("value assigned to a product. delete the product before the attribute."); } } catch (Exception e) { LblErr.Text = RenderError(e.Message); } GridValues.DataBind(); }
protected void Grid1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { PigeonCms.Attribute item = new PigeonCms.Attribute(); item = (PigeonCms.Attribute)e.Row.DataItem; LinkButton LnkTitle = (LinkButton)e.Row.FindControl("LnkTitle"); LnkTitle.Text = "<i class='fa fa-pgn_edit fa-fw'></i>"; LnkTitle.Text += Utility.Html.GetTextPreview(item.Name, 50, ""); if (string.IsNullOrEmpty(LnkTitle.Text)) LnkTitle.Text += Utility.GetLabel("NO_VALUE", "<no value>"); if (Roles.IsUserInRole("debug") || Roles.IsUserInRole("admin")) LnkTitle.Text += " [" + item.Id.ToString() + "]"; if (!item.AllowCustomValue) { var filter = new AttributeValueFilter(); filter.AttributeId = item.Id; filter.NumOfRecords = 10; var values = new AttributeValuesManager().GetByFilter(filter, ""); Literal ValuesPreview = (Literal)e.Row.FindControl("ValuesPreview"); string records = ""; foreach (var value in values) { records += " - " + Utility.Html.GetTextPreview(value.Value, 50, ""); } if (records.Length > 2) ValuesPreview.Text = "[" + records.Substring(2) + " ]"; } if (item.AllowCustomValue) { var img1 = e.Row.FindControl("ImgEnabledOk"); img1.Visible = true; } else { var img1 = e.Row.FindControl("ImgEnabledKo"); img1.Visible = true; } } }