-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectionStringEditor.cs
More file actions
76 lines (62 loc) · 2.24 KB
/
ConnectionStringEditor.cs
File metadata and controls
76 lines (62 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace ConnectionStringManager
{
public partial class ConnectionStringEditor : Form, IGenericView
{
private List<SavedConnection> _savedConnections;
public IList<SavedConnection> SavedConnections
{
get { return _savedConnections; }
set { _savedConnections = value.ToList(); }
}
public string ConnectionString { get { return txtConnStr.Text; } }
public string ConnectionName { get { return txtConnectionName.Text; } }
private bool _isSaving = false;
public ConnectionStringEditor()
{
InitializeComponent();
}
public DialogResult ShowDialog(string connectionName, string connectionString)
{
this.txtConnectionName.Text = connectionName;
this.txtConnStr.Text = connectionString;
return this.ShowDialog();
}
private void ConnectionStringEditor_FormClosing(object sender, FormClosingEventArgs e)
{
if (!_isSaving) { this.DialogResult = System.Windows.Forms.DialogResult.Cancel; }
}
public event ConnectionAction TestConnection;
public IList<ConnectionStringEntry> ConnectionStrings { get; set; }
public void RefreshView()
{
}
public void SetError(string message)
{
MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public void SetMessage(string message)
{
MessageBox.Show(message, "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void tsSave_Click(object sender, EventArgs e)
{
_isSaving = true;
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
private void tsTestConnection_Click(object sender, EventArgs e)
{
if (this.TestConnection != null)
{
this.TestConnection(new ConnectionStringEntry() { ConnectionString = txtConnStr.Text }, true);
}
}
}
}