This repository has been archived by the owner on Dec 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
EditConnections.ascx.cs
136 lines (102 loc) · 3.19 KB
/
EditConnections.ascx.cs
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using DotNetNuke.Services.Localization;
using System.Web.UI.WebControls;
using System.Collections;
using DotNetNuke.Common;
using DotNetNuke.Entities.Modules;
namespace DNNStuff.SQLViewPro
{
public partial class EditConnections : PortalModuleBase
{
#region Web Form Designer Generated Code
//This call is required by the Web Form Designer.
[System.Diagnostics.DebuggerStepThrough()]private void InitializeComponent()
{
}
private void Page_Init(System.Object sender, System.EventArgs e)
{
//CODEGEN: This method call is required by the Web Form Designer
//Do not modify it using the code editor.
InitializeComponent();
}
#endregion
#region Page
private void Page_Load(System.Object sender, System.EventArgs e)
{
DNNUtilities.InjectCSS(Page, ResolveUrl("Resources/Support/edit.css"));
if (!Page.IsPostBack)
{
BindConnection();
}
}
#endregion
#region Data Connection
// connection
private void DeleteConnection(int ConnectionId)
{
var objConnectionController = new ConnectionController();
objConnectionController.DeleteConnection(ConnectionId);
}
private void BindConnection()
{
Localization.LocalizeDataGrid(ref dgConnection, LocalResourceFile);
var objConnectionList = default(ArrayList);
var objConnectionController = new ConnectionController();
objConnectionList = objConnectionController.ListConnection(PortalId, false, false);
// bind
dgConnection.DataSource = objConnectionList;
dgConnection.DataBind();
}
#endregion
#region Navigation
protected void cmdClose_Click(System.Object sender, System.EventArgs e)
{
Response.Redirect((string) (Globals.NavigateURL()));
}
private string NavigateConnection(int ConnectionId)
{
return EditUrl("ConnectionId", ConnectionId.ToString(), "EditConnection");
}
#endregion
#region Connection Grid
protected void cmdAddConnection_Click(object sender, System.EventArgs e)
{
Response.Redirect(NavigateConnection(-1));
}
protected void dgConnection_ItemCommand(object source, DataGridCommandEventArgs e)
{
var ConnectionId = int.Parse(dgConnection.DataKeys[e.Item.ItemIndex].ToString());
switch (e.CommandName.ToLower())
{
case "edit":
Response.Redirect(NavigateConnection(ConnectionId));
break;
case "delete":
DeleteConnection(ConnectionId);
BindConnection();
break;
}
}
protected void dgConnection_ItemDataBound(object sender, DataGridItemEventArgs e)
{
// process data rows only (skip the header, footer etc.)
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
// get a reference to the LinkButton of this row,
// and add the javascript confirmation
var lnkDelete = (LinkButton) (e.Item.FindControl("cmdDeleteConnection"));
if (lnkDelete != null)
{
if (lnkDelete.Enabled)
{
lnkDelete.Attributes.Add("onclick", "return confirm(\'Are you sure you want to delete this connection?\');");
}
else
{
lnkDelete.Attributes.Add("title", "This connection is used by other objects. It cannot be deleted.");
}
}
}
}
#endregion
}
}