public void LoadModules() { DataTable ModulesDB = Globals.dbConn.GetDataTable("SELECT * FROM PHPModules"); foreach (DataRow row in ModulesDB.Rows) { PHPModule Mod = new PHPModule(); foreach (DataColumn col in ModulesDB.Columns) { try { PropertyInfo pi = Mod.GetType().GetProperty(col.ToString()); pi.SetValue(Mod, 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); } } Modules.Add(Mod); } LoadModulesDescription(); }
private void checkedListModules_SelectedIndexChanged(object sender, EventArgs e) { int index = -1; if (!String.IsNullOrEmpty(SelModName) && SelModName != "" && SelModName != this.checkedListModules.SelectedItem.ToString()) { index = this.PHPSettings.FindModule(SelModName); if (index >= 0) { if (this.ModulesConfig.Text != "") { this.PHPSettings.Modules[index].Value = this.ModulesConfig.Text; this.PHPSettings.SaveModuleData(index); } else { this.PHPSettings.SaveModuleData(index, 3); this.PHPSettings.Modules.RemoveAt(index); } } else if (this.ModulesConfig.Text != "") { PHPModule NewMod = new PHPModule(); NewMod.Module = SelModName; NewMod.Value = this.ModulesConfig.Text; this.PHPSettings.Modules.Add(NewMod); this.PHPSettings.SaveModuleData(this.PHPSettings.Modules.Count - 1, 1); } } // Ahora se cargan los nuevos datos. if (SelModule != this.checkedListModules.SelectedIndex) { SelModule = this.checkedListModules.SelectedIndex; SelModName = this.checkedListModules.SelectedItem.ToString(); index = this.PHPSettings.FindModule(SelModName); this.ModuleTag.Text = "[" + SelModName.ToString().Replace("php_", "").Replace(".dll", "") + "]"; if (index >= 0) { string[] lines = this.PHPSettings.Modules[index].Value.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None); this.ModulesConfig.Lines = lines; } else { this.ModulesConfig.Text = ""; } //if (this.PHPSettings.Settings[SelModule].Active == 1) if (this.checkedListModules.GetItemChecked(this.checkedListModules.SelectedIndex)) { this.ModulesConfig.Enabled = true; } else { this.ModulesConfig.Enabled = false; } } if (this.checkedListModules.SelectedIndex >= 0) { this.ModulesInfo.Text = PHPSettings.GetModuleDescription(this.checkedListModules.SelectedItem.ToString()); LinkLabel.Link link = new LinkLabel.Link(); String URL = PHPSettings.GetModuleURL(this.checkedListModules.SelectedItem.ToString()); link.LinkData = URL; ModulesLink.Text = URL; ModulesLink.Links.Clear(); ModulesLink.Links.Add(link); } }