-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathGeneralLayout.master.cs
More file actions
97 lines (89 loc) · 3.11 KB
/
GeneralLayout.master.cs
File metadata and controls
97 lines (89 loc) · 3.11 KB
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
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class GeneralLayout : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
BindCartNumber();
BindCategories();
if (Session["USERNAME"] != null)
{
btnSignup.Visible = false;
btnSignin.Visible = false;
btnSignOut.Visible = true;
}
else
{
btnSignup.Visible = true;
btnSignin.Visible = true;
btnSignOut.Visible = false;
}
}
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 btnSignOut_Click(object sender, EventArgs e)
{
Session["USERNAME"] = null;
Response.Redirect("~/Default.aspx");
}
public void BindCategories()
{
String CS = ConfigurationManager.ConnectionStrings["MyDatabaseConnectionString1"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
using (SqlCommand cmd = new SqlCommand("select * from tblCategories", con))
{
cmd.CommandType = CommandType.Text;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dtBrands = new DataTable();
sda.Fill(dtBrands);
rptCategory.DataSource = dtBrands;
rptCategory.DataBind();
}
}
}
}
protected void OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
string catId = (e.Item.FindControl("hfCatId") as HiddenField).Value;
Repeater rptSubCategories = e.Item.FindControl("rptSubCategories") as Repeater;
String CS = ConfigurationManager.ConnectionStrings["MyDatabaseConnectionString1"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
using (SqlCommand cmd = new SqlCommand(string.Format("SELECT * FROM tblSubCategories WHERE MainCatID='{0}'", catId), con))
{
cmd.CommandType = CommandType.Text;
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dtBrands = new DataTable();
sda.Fill(dtBrands);
rptSubCategories.DataSource = dtBrands;
rptSubCategories.DataBind();
}
}
}
}
}
}