예제 #1
0
    public void Save()
    {
        Configuration      cfg        = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
        AppSettingsSection appSetting = cfg.AppSettings;
        WebConfigDescs     ens        = new WebConfigDescs();

        ens.RetrieveAll();
        foreach (System.Configuration.KeyValueConfigurationElement mycfg in appSetting.Settings)
        {
            WebConfigDesc en = ens.GetEnByKey("No", mycfg.Key) as WebConfigDesc;
            if (en == null)
            {
                en    = new WebConfigDesc();
                en.No = mycfg.Key;
            }

            this.UCSys1.AddTR();
            this.UCSys1.AddTD(en.No);
            this.UCSys1.AddTD(en.Name);
            switch (en.DBType)
            {
            case "Boolen":
                if (this.UCSys1.GetRadioButtonByID("rb1" + mycfg.Key).Checked)
                {
                    mycfg.Value = "1";
                }
                else
                {
                    mycfg.Value = "0";
                }
                break;

            case "Enum":
                mycfg.Value = this.UCSys1.GetDDLByID("DDL_" + mycfg.Key).Text;
                break;

            case "String":
            default:
                mycfg.Value = this.UCSys1.GetTextBoxByID("TB_" + mycfg.Key).Text;
                break;
            }
        }
        cfg.Save();
        this.Response.Redirect("EditWebconfig.aspx", true);
        // BP.PubClass.Alert("保存成功。");
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        this.UCSys1.AddTable();
        this.UCSys1.AddCaptionLeft("站点全局信息配置:(您也可以打开web.config中直接修改它)");
        this.UCSys1.AddTR();
        this.UCSys1.AddTDTitle("IDX");
        this.UCSys1.AddTDTitle("项目Key");
        this.UCSys1.AddTDTitle("名称");
        this.UCSys1.AddTDTitle("值");
        this.UCSys1.AddTDTitle("描述");
        this.UCSys1.AddTREnd();

        // BP.Web.WebUser.Style

        WebConfigDescs ens = new WebConfigDescs();

        ens.RetrieveAll();
        Configuration      cfg        = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath);
        AppSettingsSection appSetting = cfg.AppSettings;
        bool is1 = false;
        int  i   = 1;

        foreach (System.Configuration.KeyValueConfigurationElement mycfg in appSetting.Settings)
        {
            WebConfigDesc en = ens.GetEnByKey("No", mycfg.Key) as WebConfigDesc;
            if (en == null)
            {
                en    = new WebConfigDesc();
                en.No = mycfg.Key;
            }

            is1 = this.UCSys1.AddTR(is1);
            this.UCSys1.AddTDIdx(i++);
            this.UCSys1.AddTD(en.No);
            this.UCSys1.AddTD(en.Name);
            switch (en.DBType)
            {
            case "Boolen":

                RadioButton rb1 = new RadioButton();
                rb1.Text      = "是";
                rb1.GroupName = en.No;
                rb1.ID        = "rb1" + en.No;
                rb1.Enabled   = en.IsEnable;

                RadioButton rb0 = new RadioButton();
                rb0.Text      = "否";
                rb0.GroupName = en.No;
                rb0.ID        = "rb0" + en.No;
                rb0.Enabled   = en.IsEnable;


                if (System.Web.Configuration.WebConfigurationManager.AppSettings[en.No] == "1")
                {
                    rb1.Checked = true;
                }
                else
                {
                    rb0.Checked = true;
                }


                this.UCSys1.AddTDBegin();
                this.UCSys1.Add(rb1);
                this.UCSys1.Add(rb0);
                this.UCSys1.AddTDEnd();
                break;

            case "Enum":
                BP.Web.Controls.DDL ddl = new BP.Web.Controls.DDL();
                ddl.ID      = "DDL_" + en.No;
                ddl.Enabled = en.IsEnable;

                BP.Sys.SysEnums ses = new BP.Sys.SysEnums(en.No, en.Vals);
                ddl.BindSysEnum(en.No, int.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings[en.No]));
                this.UCSys1.AddTD(ddl);
                break;

            case "String":
            default:
                TextBox tb = new TextBox();
                tb.ID      = "TB_" + en.No;
                tb.Text    = System.Web.Configuration.WebConfigurationManager.AppSettings[en.No];
                tb.Columns = 80;
                tb.Enabled = en.IsEnable;
                this.UCSys1.AddTD(tb);
                break;
            }
            this.UCSys1.AddTD(en.Note);
            //    this.UCSys1.AddTDBigDoc(en.Note);

            this.UCSys1.AddTREnd();
        }
        this.UCSys1.AddTRSum();
        this.UCSys1.AddTD();
        this.UCSys1.AddTD();
        this.UCSys1.AddTD();

        Button btn = new Button();

        btn.ID       = "Btn_Save";
        btn.Text     = " 保存全局设置 ";
        btn.CssClass = "Btn";

        this.UCSys1.AddTD(btn);
        btn.Click += new EventHandler(btn_Click);
        this.UCSys1.AddTD();
        this.UCSys1.AddTREnd();
        this.UCSys1.AddTableEnd();
    }