private void btnConnect_Click(object sender, EventArgs e) { if( !string.IsNullOrEmpty(txtServerIP.Text )) { dbHelper db = new dbHelper(); bool status = false; if( chkUserWndAuth.Checked) status = db.SetupConnection(txtServerIP.Text); else status = db.SetupConnection(txtServerIP.Text, txtUsername.Text, txtPassword.Text); if (status) { Properties.Settings.Default.Server = txtServerIP.Text; Properties.Settings.Default.UseWndAuth = chkUserWndAuth.Checked; if (!chkUserWndAuth.Checked) { Properties.Settings.Default.Username = txtUsername.Text; Properties.Settings.Default.Password = txtPassword.Text; } Properties.Settings.Default.Save(); //everything fine close it DialogResult = DialogResult.OK; Close(); } else { MessageBox.Show("Fail to connect to DB Server"); } } }
public void Init() { db = new dbHelper(); Assert.True(db.SetupConnection("10.25.6.33")); }