/// <summary> /// Salva/Serializa o arquivo de configuração /// </summary> private void SaveDbParam() { sri.Serialize(FileName, cfg); while (CfgHistorico.Count > 200) { CfgHistorico.RemoveAt(0); } sri.Serialize(FileNameHistorico, CfgHistorico); }
private void apagarToolStripMenuItem_Click(object sender, EventArgs e) { if (lstConnections.SelectedIndex != -1) { string str = lstConnections.Items[lstConnections.SelectedIndex].ToString(); for (int i = 0; i < CfgHistorico.Count; i++) { if (str == CfgHistorico[i].ToString()) { CfgHistorico.RemoveAt(i); break; } } lstConnections.Items.RemoveAt(lstConnections.SelectedIndex); } }
private void textBox1_TextChanged(object sender, EventArgs e) { lstConnections.Items.Clear(); if (textBox1.Text.Length != 0) { lstConnections.Items.AddRange(CfgHistorico.Where(q => q.ToString().ToUpper().Contains(textBox1.Text.ToUpper())).ToArray()); /*for (int i = 0; i < lstConnections.Items.Count; i++) * { * if (lstConnections.Items[i].ToString().ToUpper().Contains(textBox1.Text.ToUpper())) * { * lstConnections.SelectedIndex = i; * } * }*/ } else { lstConnections.Items.AddRange(CfgHistorico.ToArray()); } }
protected override void OnConfirm() { cfg.DbType = ((enmConnection)this.cmbTipo.SelectedIndex); cfg.Info.UseWindowsAuthentication = this.cbWindowsAutenticate.Checked; cfg.Info.Server = this.txtServer.Text; cfg.Info.Database = this.txtBanco.Text; cfg.Info.User = this.txtUsuario.Text; cfg.Info.Password = this.txtSenha.Text; cfg.Info.ConnectionString = this.txtConnectionString.Text; for (int i = 0; i < CfgHistorico.Count; i++) { if (CfgHistorico[i].ToString() == cfg.ToString()) { CfgHistorico.RemoveAt(i); break; } } CfgHistorico.Add(cfg); SaveDbParam(); base.OnConfirm(); }
private void apagarHistóricoToolStripMenuItem_Click(object sender, EventArgs e) { CfgHistorico.Clear(); lstConnections.Items.Clear(); }