-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditProfile.aspx.cs
189 lines (155 loc) · 6 KB
/
EditProfile.aspx.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;
using System.Threading;
using System.Web.Mail;
using System.Net.Mime;
using System.Security.Cryptography;
using System.Text;
using System.Net.Mail;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data.Common;
using System.Globalization;
using System.Net;
using System.Drawing;
using System.Configuration;
using System.Data.Odbc;
using System.Web.Security;
using IMDLL;
public partial class EditProfile : System.Web.UI.Page
{
public string _userFullName = string.Empty,
_userProfile = string.Empty,
_userLastLogin = string.Empty,
StrToday = string.Empty,
StrMonth = string.Empty;
private static string usr;
Users objUsers = new Users();
AreaInterest objAreaInterest = new AreaInterest();
SectorInterest objSectorInterest = new SectorInterest();
protected void Page_Load(object sender, EventArgs e)
{
PagesAccess objPagesAccess = new PagesAccess();
if (objPagesAccess.CheckAccess(Path.GetFileNameWithoutExtension(Page.AppRelativeVirtualPath), Session[RunningCache.UserProfile].ToString()) == true)
{
try
{
CultureInfo ci = new CultureInfo("en-GB");
var format = "dd, MMMM yyyy";
ClientScript.GetPostBackEventReference(this, string.Empty);
if (Request.Form["__EVENTTARGET"] == "Disconnect")
{
Disconnect();
}
if (Session[RunningCache.UserLogin] == null)
{
Disconnect();
}
if (!IsPostBack)
{
if (HttpContext.Current.Session["AlertOn"] != null)
{
if ((Boolean)HttpContext.Current.Session["AlertOn"] == true)
{
if (this.global_error.Visible) this.global_error.Visible = false;
this.global_success.Visible = true;
this.global_success_msg.Text = Mains.Constant.SUCCESS_INSERT;
}
HttpContext.Current.Session["AlertOn"] = null;
}
var ss = Session[RunningCache.UserLogin];
if (ss != null)
{
if (!string.IsNullOrEmpty(Session[RunningCache.UserLogin].ToString()))
{
usr = Session[RunningCache.UserLogin].ToString();
_userFullName = Session[RunningCache.UserFullName].ToString();
_userProfile = Session[RunningCache.ProfileName].ToString();
filldata();
}
}
else
{
Disconnect();
}
}
}
catch (Exception ex)
{
}
}
}
private void Disconnect()
{
try
{
FormsAuthentication.SignOut();
usr = string.Empty;
Session[RunningCache.UserLogin] = null;
HttpContext.Current.Response.Redirect("login.aspx", false);
}
catch (Exception ex)
{
}
}
protected void filldata()
{
DataTable dt = objUsers.GetUsers(" where UserID=" + Session[RunningCache.UserID].ToString());
if (dt.Rows.Count > 0)
{
txtUserFullName.Text = dt.Rows[0]["UserFullName"].ToString();
txtUserOrganization.Text = dt.Rows[0]["UserOrganization"].ToString();
txtUserTitle.Text = dt.Rows[0]["UserTitle"].ToString();
txtUsername.Text = dt.Rows[0]["Username"].ToString();
txtUserMail.Text = dt.Rows[0]["UserMail"].ToString();
txtUserPhone.Text = dt.Rows[0]["UserPhone"].ToString();
txtUserAddress.Text = dt.Rows[0]["UserAddress"].ToString();
txtProfile.Text = dt.Rows[0]["ProfileName"].ToString();
txtUserNote.Text = dt.Rows[0]["UserNote"].ToString();
}
}
protected void BtnUpdate_Click(object sender, EventArgs e)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
try
{
string strmsg = "";
objUsers.UserFullName = txtUserFullName.Text.Trim();
objUsers.UserOrganization = txtUserOrganization.Text.Trim();
objUsers.UserTitle = txtUserTitle.Text.Trim();
objUsers.UserMail = txtUserMail.Text.Trim();
objUsers.UserPhone = txtUserPhone.Text.Trim();
objUsers.UserAddress = txtUserAddress.Text.Trim();
objUsers.UserNote = txtUserNote.Text.Trim();
objUsers.LastModifiedBy = int.Parse(Session[RunningCache.UserID].ToString());
objUsers.LastModifiedDate = DateTime.Now;
objUsers.UserID = int.Parse(Session[RunningCache.UserID].ToString());
objUsers.UserUpdateUsers(objUsers, out strmsg);
this.global_success.Visible = true;
this.global_success_msg.Text = "You have successfully updated your information into the system.";
UpdatePanel.Update();
}
catch (Exception ex)
{
}
}
protected void BtnChangePwd_Click(object sender, EventArgs e)
{
if (txtUserPasswordNew.Text.Trim() == txtUserPasswordConfirm.Text.Trim())
{
objUsers.CustomUpdateUsers(" UserPassword='" + txtUserPasswordConfirm.Text.Trim() + "' WHERE UserID=" + Session[RunningCache.UserID].ToString());
}
else
{
if (this.global_success.Visible) this.global_error.Visible = false;
this.global_error.Visible = true;
this.global_error_msg.Text = "Please type the same password.";
}
}
}