-
Notifications
You must be signed in to change notification settings - Fork 0
/
Default.aspx.cs
106 lines (95 loc) · 3.23 KB
/
Default.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
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 _Default : System.Web.UI.Page
{
public static String CS = ConfigurationManager.ConnectionStrings["EasyBuy123"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["UserLogin"] == "YES")
{
Response.Redirect("UserHome.aspx?UserLogin=YES");
}
if (Session["Username"] != null)
{
//lblSuccess.Text = "Login Success, Welcome <b>" + Session["Username"].ToString() + "</b>";
if(!this.IsPostBack)
{
BindProductRepeater();
btnSignUP.Visible = false;
btnSignIN.Visible = false;
btnlogout.Visible = true;
}
}
else
{
BindProductRepeater();
btnSignUP.Visible = true;
btnSignIN.Visible = true;
btnlogout.Visible = false;
//Response.Redirect("Default.aspx");
Response.Write("<script type='text/javascript'>alert('Login plz')</script>");
}
}
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();
}
}
protected void btnlogout_Click(object sender, EventArgs e)
{
Session["Username"] = null;
Session.RemoveAll();
Response.Redirect("Default.aspx");
}
private void BindProductRepeater()
{
using (SqlConnection con = new SqlConnection(CS))
{
using (SqlCommand cmd = new SqlCommand("procBindAllProducts", con))
{
cmd.CommandType = CommandType.StoredProcedure;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
sda.Fill(dt);
rptrProducts.DataSource = dt;
rptrProducts.DataBind();
if (dt.Rows.Count <= 0)
{
//Label1.Text = "Sorry! Currently no products in this category.";
pCount.InnerHtml = "0";
}
else
{
//Label1.Text = "Showing All Products";
}
}
}
}
}
protected override void InitializeCulture()
{
CultureInfo ci = new CultureInfo("en-IN");
ci.NumberFormat.CurrencySymbol = "₹";
Thread.CurrentThread.CurrentCulture = ci;
base.InitializeCulture();
}
}