-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserHome.aspx.cs
92 lines (86 loc) · 2.86 KB
/
UserHome.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
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.Data.SqlClient;
using System.Configuration;
using System.Globalization;
using System.Threading;
public partial class UserHome : System.Web.UI.Page
{
public static String CS = ConfigurationManager.ConnectionStrings["EasyBuy123"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
BindCartNumber22();
if (Session["Username"]!=null)
{
btnlogout.Visible = true;
btnLogin.Visible = false;
lblSuccess.Text = "Login Success, Welcome <b>" + Session["Username"].ToString()+"</b>";
Button1.Text ="Welcome: " + Session["Username"].ToString().ToUpper() ;
}
else
{
btnlogout.Visible = false;
btnLogin.Visible = true;
Response.Redirect("SignIn.aspx");
}
}
protected void btnlogout_Click(object sender, EventArgs e)
{
//Session.Abandon();
Session["Username"] = null;
Response.Redirect("~/Default.aspx");
}
protected void btnLogin_Click(object sender, EventArgs e)
{
Response.Redirect("~/SignIn.aspx");
}
public void BindCartNumber()
{
if (Request.Cookies["CartPID"] != null)
{
string CookiePID = Request.Cookies["CartPID"].Value.Split('=')[1];
string[] ProductArray = CookiePID.Split(',');
int ProductCount = ProductArray.Length;
pCount.InnerText = ProductCount.ToString();
}
else
{
pCount.InnerText = 0.ToString();
}
}
public void BindCartNumber22()
{
if (Session["USERID"] != null)
{
string UserIDD = Session["USERID"].ToString();
DataTable dt = new DataTable();
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("SP_BindCartNumberz", con)
{
CommandType = CommandType.StoredProcedure
};
cmd.Parameters.AddWithValue("@UserID", UserIDD);
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
sda.Fill(dt);
if (dt.Rows.Count > 0)
{
string CartQuantity = dt.Compute("Sum(Qty)", "").ToString();
pCount.InnerText = CartQuantity;
}
else
{
//_ = CartBadge.InnerText == 0.ToString();
pCount.InnerText ="0";
}
}
}
}
}
}