private void FormTest_Load(object sender, EventArgs e) { try { if (!Sources.Contains("(default)") && !string.IsNullOrWhiteSpace(AppSettingHelper.Default.SqlServer)) { DataSource ds = new DataSource(); ds.Name = "(default)"; ds.Server = AppSettingHelper.Default.SqlServer; ds.Database = AppSettingHelper.Default.Database; ds.User = AppSettingHelper.Default.DbUser; ds.Password = AppSettingHelper.Encrypt(AppSettingHelper.Default.DbPassword); Sources.Add("(default)", ds); Sources.SelectedIndex = 0; DataProvider.SaveObj(DataSources.XML_FILE_NAME, Sources); } if (Sources.Count > 0) { cmbdatasource.Items.Clear(); foreach (string s in Sources.Keys) { cmbdatasource.Items.Add(s); } cmbdatasource.SelectedIndex = Sources.SelectedIndex; } } catch (Exception ex) { Utility.Hata(ex); } }
private void FormDatasource_Load(object sender, EventArgs e) { if (DataSource != null) { textName.Text = DataSource.Name; textName.Enabled = false; textserver.Text = DataSource.Server; textDb.Text = DataSource.Database; textUser.Text = DataSource.User; textPassword.Text = AppSettingHelper.Decrypt(DataSource.Password); } }
private void btnok_Click(object sender, EventArgs e) { if (DataSource == null) { DataSource = new DataSource(); DataSource.Name = textName.Text; DataSource.Server = textserver.Text; DataSource.Database = textDb.Text; DataSource.User = textUser.Text; DataSource.Password = AppSettingHelper.Encrypt(textPassword.Text); Sources.Add(textName.Text, DataSource); } else { Sources[DataSource.Name].Name = textName.Text; Sources[DataSource.Name].Server = textserver.Text; Sources[DataSource.Name].Database = textDb.Text; Sources[DataSource.Name].User = textUser.Text; Sources[DataSource.Name].Password = AppSettingHelper.Encrypt(textPassword.Text); } DataProvider.SaveObj(DataSources.XML_FILE_NAME, Sources); DialogResult = DialogResult.OK; }
public override string ToString() { return(string.Format("data source={0};persist security info=False;initial catalog={1};Connect Timeout=50;User={2};Password={3};", this.Server, this.Database, this.User, AppSettingHelper.Decrypt(this.Password))); }