-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard.aspx.cs
69 lines (61 loc) · 2.51 KB
/
dashboard.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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class dashboard : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["PTGcnn"].ConnectionString);
public static string uimage="";
public static string uaddress = "";
protected void Page_Load(object sender, EventArgs e)
{
if (HttpContext.Current.Session["UserId"] != null && HttpContext.Current.Session["UserName"] != null)
{
string UserId = Session["UserId"].ToString();
string UserName = Session["UserName"].ToString();
if (!IsPostBack)
{
BindListView();
}
}
else
{
Response.Redirect("login.aspx");
}
}
public void BindListView()
{
con.Open();
SqlCommand cmdimg = new SqlCommand("select uimage from UserTable where uid = '" + Session["UserId"] + "'", con);
uimage = "<img src='assets/Images/User/" + cmdimg.ExecuteScalar().ToString() + "' class='img-fluid avater' style=''>";
SqlCommand cmdaddress = new SqlCommand("select ucity, ucountry from UserTable where uid = '" + Session["UserId"] + "'", con);
uaddress = cmdaddress.ExecuteScalar().ToString();
SqlCommand cmdappoveblog = new SqlCommand("select COUNT(*) from Blog_Table where blogAuthorId='" + Session["UserId"] + "' and status = 1", con);
lblapprove.Text = cmdappoveblog.ExecuteScalar().ToString();
SqlCommand cmdpending = new SqlCommand("select COUNT(*) from Blog_Table where blogAuthorId='" + Session["UserId"] + "' and status = 0", con);
lblpending.Text = cmdpending.ExecuteScalar().ToString();
con.Close();
}
protected void BtnLogOut_Click(object sender, EventArgs e)
{
FormsAuthentication.SignOut();
Session.Abandon();
HttpCookie cookie1 = new HttpCookie(FormsAuthentication.FormsCookieName, "");
cookie1.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie1);
HttpCookie cookie2 = new HttpCookie("ASP.NET_SessionId", "");
cookie2.Expires = DateTime.Now.AddYears(-1);
Response.Cookies.Add(cookie2);
Response.Redirect("index.aspx");
}
}