Exemplo n.º 1
0
        private void AddSetting_Click(object sender, EventArgs e)
        {
            Parameters Params = new Parameters();

            Params.Title          = "PHP general settings";
            Params.textBox        = "New";
            Params.textParameter1 = "New PHP general setting:";
            Params.textParameter2 = "New PHP value:";

            if (Params.ShowDialog() == DialogResult.OK)
            {
                PHPSetting newPHPSetting = new PHPSetting();
                newPHPSetting.Param  = Params.Parameter1;
                newPHPSetting.Value  = Params.Parameter2;
                newPHPSetting.Active = 1;

                this.PHPSettings.Settings.Add(newPHPSetting);
                this.checkedListSettings.Items.Add(newPHPSetting.Param, true);
                this.PHPSettings.SaveSetting(this.checkedListSettings.Items.Count - 1);
                this.PHPSettings.SaveSetting(this.checkedListSettings.Items.Count - 1, 1);
            }
            Params.Dispose();
        }
Exemplo n.º 2
0
        public void LoadSettings()
        {
            DataTable SettingsDB = Globals.dbConn.GetDataTable("SELECT * FROM PHPSettings");

            foreach (DataRow row in SettingsDB.Rows)
            {
                PHPSetting Set = new PHPSetting();

                foreach (DataColumn col in SettingsDB.Columns)
                {
                    try
                    {
                        PropertyInfo pi = Set.GetType().GetProperty(col.ToString());
                        pi.SetValue(Set, Convert.ChangeType(row[col], pi.PropertyType), null);
                    }
                    catch (Exception /*ex*/)
                    {
                        //Globals.Error.Show("Column: " + col.ToString() + "\r\nContent: " + row[col].ToString() + "\r\n" + ex.Message);
                    }
                }

                Settings.Add(Set);
            }
        }