Пример #1
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        LblErr.Text = "";
        LblOk.Text = "";

        try
        {
            PigeonCms.Attribute o1 = new PigeonCms.Attribute();
            if (base.CurrentId == 0)
            {
                form2obj(o1);
                o1 = new AttributesManager().Insert(o1);
            }
            else
            {
                o1 = new AttributesManager().GetByKey(base.CurrentId);  //precarico i campi esistenti e nn gestiti dal form
                form2obj(o1);
                new AttributesManager().Update(o1);
            }
            Grid1.DataBind();
            LblOk.Text = RenderSuccess(Utility.GetLabel("RECORD_SAVED_MSG"));
            MultiView1.ActiveViewIndex = 0;
        }
        catch (Exception e1)
        {
            LblErr.Text = RenderError(Utility.GetLabel("RECORD_ERR_MSG") + "<br />" + e1.ToString());
        }
        finally
        {
        }
    }
Пример #2
0
    private void values2obj(PigeonCms.AttributeValue obj)
    {
        var valueTranslation = new Dictionary<string, string>();

        if (ChkInLang.Checked)
        {
            foreach (KeyValuePair<string, string> item in Config.CultureList)
            {
                TextBox t1 = new TextBox();
                t1 = (TextBox)PanelTitle.FindControl("TxtTitle" + item.Value);
                valueTranslation.Add(item.Key, t1.Text);
            }
        }
        else
        {
            TextBox t1 = new TextBox();
            string defaultLang = Config.CultureList.FirstOrDefault(x => x.Key == Config.CultureDefault).Value;
            t1 = (TextBox)PanelTitle.FindControl("TxtTitle" + defaultLang);
            foreach (KeyValuePair<string, string> item in Config.CultureList)
            {
                valueTranslation.Add(item.Key, t1.Text);
            }
        }

        obj.ValueString = toJson(valueTranslation);

        if (base.CurrentId == 0)
        {
            // have to save attribute before
            var a = new PigeonCms.Attribute();
            a.AllowCustomValue = ChkCustomValue.Checked;
            a.Name = TxtName.Text;
            a = new AttributesManager().Insert(a);
            base.CurrentId = a.Id;
        }

        obj.AttributeId = base.CurrentId;
    }
Пример #3
0
    private void editValues(int recordId, int attrValId)
    {
        LblOk.Text = "";
        LblErr.Text = "";

        base.CurrentKey = attrValId.ToString();
        base.CurrentId = recordId;

        if (recordId > 0)
        {
            PigeonCms.Attribute obj = new PigeonCms.Attribute();
            obj = new PigeonCms.AttributesManager().GetByKey(base.CurrentId);
        }
        if (attrValId > 0)
        {
            PigeonCms.AttributeValue obj = new PigeonCms.AttributeValue();
            obj = new PigeonCms.AttributeValuesManager().GetByKey(attrValId);
            values2form(obj);
        }
        GridValues.DataBind();
    }
Пример #4
0
    private void editRow(int recordId)
    {
        LblOk.Text = "";
        LblErr.Text = "";

        clearForm();
        base.CurrentId = recordId;
        if (base.CurrentId > 0)
        {
            PigeonCms.Attribute obj = new PigeonCms.Attribute();
            obj = new PigeonCms.AttributesManager().GetByKey(base.CurrentId);
            obj2form(obj);
        }
        GridValues.DataBind();
        MultiView1.ActiveViewIndex = 1;
    }
Пример #5
0
    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;
            }

        }
    }
Пример #6
0
 protected void Grid2_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         var item = new PigeonCms.Attribute();
         item = (PigeonCms.Attribute)e.Row.DataItem;
     }
 }