Beispiel #1
0
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        LblErr.Text = "";
        LblOk.Text = "";

        try
        {
            WebConfigEntry o1 = new WebConfigEntry();
            if (base.CurrentKey == "")
            {
                form2obj(o1);
                new WebConfigManager().Insert(o1);
            }
            else
            {
                o1 = new WebConfigManager().GetByKey(base.CurrentKey);  //precarico i campi esistenti e nn gestiti dal form
                form2obj(o1);
                new WebConfigManager().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
        {
        }
    }
Beispiel #2
0
    protected void Grid1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            PigeonCms.WebConfigEntry item = new PigeonCms.WebConfigEntry();
            item = (PigeonCms.WebConfigEntry)e.Row.DataItem;

            LinkButton LnkSel = (LinkButton)e.Row.FindControl("LnkSel");
            LnkSel.Text = "<i class='fa fa-pgn_edit fa-fw'></i>";
            LnkSel.Text += item.Key;
        }
    }
 public int Update(WebConfigEntry theObj)
 {
     int result = 0;
     Configuration configuration = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
     AppSettingsSection appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings");
     if (appSettingsSection != null)
     {
         appSettingsSection.Settings[theObj.Key].Value = theObj.Value;
         configuration.Save();
         result = 1;
     }
     return result;
 }
 public void Insert(WebConfigEntry newObj)
 {
     Configuration configuration = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
     AppSettingsSection appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings");
     if (appSettingsSection != null)
     {
         appSettingsSection.Settings.Add(newObj.Key, newObj.Value);
         configuration.Save();
     }
 }
 public WebConfigEntry GetByKey(string key)
 {
     WebConfigEntry result = new WebConfigEntry();
     Configuration configuration = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
     AppSettingsSection appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings");
     if (appSettingsSection != null)
     {
         if (!string.IsNullOrEmpty(key))
         {
             result.Key = key;
             result.Value = appSettingsSection.Settings[key].Value;
         }
     }
     return result;
 }
 public List<WebConfigEntry> GetByFilter(WebConfigEntryFilter filter)
 {
     List<WebConfigEntry> result = new List<WebConfigEntry>();
     Configuration configuration = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
     AppSettingsSection appSettingsSection = (AppSettingsSection)configuration.GetSection("appSettings");
     if (appSettingsSection != null)
     {
         if (!string.IsNullOrEmpty(filter.Key))
         {
             result.Add(GetByKey(filter.Key));
         }
         else
         {
             foreach (string key in appSettingsSection.Settings.AllKeys)
             {
                 WebConfigEntry item = new WebConfigEntry();
                 item.Key = key;
                 item.Value = appSettingsSection.Settings[key].Value;
                 result.Add(item);
             }
         }
     }
     return result;
 }
Beispiel #7
0
    private void obj2form(WebConfigEntry obj)
    {
        TxtKey.Enabled = string.IsNullOrEmpty(obj.Key);

        TxtKey.Text = obj.Key;
        TxtValue.Text = obj.Value;
    }
Beispiel #8
0
 private void form2obj(WebConfigEntry obj)
 {
     obj.Key = TxtKey.Text;
     obj.Value = TxtValue.Text;
 }
Beispiel #9
0
    private void editRow(string recordId)
    {
        LblOk.Text = "";
        LblErr.Text = "";

        clearForm();
        base.CurrentKey = recordId;
        if (!string.IsNullOrEmpty(base.CurrentKey))
        {
            WebConfigEntry obj = new WebConfigEntry();
            obj = new WebConfigManager().GetByKey(base.CurrentKey);
            obj2form(obj);
        }
        MultiView1.ActiveViewIndex = 1;
    }