-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddSize.aspx.cs
161 lines (136 loc) · 5.78 KB
/
AddSize.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
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;
public partial class AddSize : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindBrand();
BindMainCategory();
BindGender();
BindrptrSize();
}
}
private void BindrptrSize()
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["EasyBuy123"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("select A.*,B.*,C.*,D.*,E.* from tblSizes A inner join tblCategory B on B.CatID =a.CategoryID inner join tblBrands C on C.BrandID =A.BrandID inner join tblSubCategory D on D.SubCatID =A.SubCategoryID inner join tblGender E on E.GenderID =A.GenderID ", con))
{
using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
{
DataTable dt = new DataTable();
sda.Fill(dt);
rptrSize .DataSource = dt;
rptrSize.DataBind();
}
}
}
}
private void BindMainCategory()
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["EasyBuy123"].ConnectionString))
{
con.Open();
SqlCommand cmd = new SqlCommand("Select * from tblCategory", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count != 0)
{
ddlCategory .DataSource = dt;
ddlCategory.DataTextField = "CatName";
ddlCategory.DataValueField = "CatID";
ddlCategory.DataBind();
ddlCategory.Items.Insert(0, new ListItem("-Select-", "0"));
}
}
}
private void BindBrand()
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["EasyBuy123"].ConnectionString))
{
con.Open();
SqlCommand cmd = new SqlCommand("Select * from tblBrands", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count != 0)
{
ddlBrand .DataSource = dt;
ddlBrand.DataTextField = "Name";
ddlBrand.DataValueField = "BrandID";
ddlBrand.DataBind();
ddlBrand.Items.Insert(0, new ListItem("-Select-", "0"));
}
}
}
private void BindGender()
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["EasyBuy123"].ConnectionString))
{
con.Open();
SqlCommand cmd = new SqlCommand("Select * from tblGender with(nolock)", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count != 0)
{
ddlGender .DataSource = dt;
ddlGender.DataTextField = "GenderName";
ddlGender.DataValueField = "GenderID";
ddlGender.DataBind();
ddlGender.Items.Insert(0, new ListItem("-Select-", "0"));
}
}
}
protected void btnAddSize_Click(object sender, EventArgs e)
{
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["EasyBuy123"].ConnectionString))
{
con.Open();
SqlCommand cmd = new SqlCommand("Insert into tblSizes(SizeName,BrandID,CategoryID,SubCategoryID,GenderID) Values('" + txtSize .Text + "','" + ddlBrand .SelectedItem.Value + "','" + ddlCategory .SelectedItem.Value + "','" + ddlSubCategory .SelectedItem.Value + "','" + ddlGender .SelectedItem.Value + "')", con);
cmd.ExecuteNonQuery();
Response.Write("<script> alert('Size Added Successfully '); </script>");
txtSize.Text = string.Empty;
con.Close();
ddlBrand .ClearSelection();
ddlBrand.Items.FindByValue("0").Selected = true;
ddlCategory .ClearSelection();
ddlCategory.Items.FindByValue("0").Selected = true;
ddlSubCategory.ClearSelection();
ddlSubCategory.Items.FindByValue("0").Selected = true;
ddlGender.ClearSelection();
ddlGender.Items.FindByValue("0").Selected = true;
}
BindrptrSize();
}
protected void ddlCategory_SelectedIndexChanged(object sender, EventArgs e)
{
int MainCategoryID = Convert .ToInt32 (ddlCategory.SelectedItem.Value);
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["EasyBuy123"].ConnectionString))
{
con.Open();
SqlCommand cmd = new SqlCommand("Select * from tblSubCategory where MainCatID='"+ ddlCategory .SelectedItem .Value +"'", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count != 0)
{
ddlSubCategory .DataSource = dt;
ddlSubCategory.DataTextField = "SubCatName";
ddlSubCategory.DataValueField = "SubCatID";
ddlSubCategory.DataBind();
ddlSubCategory.Items.Insert(0, new ListItem("-Select-", "0"));
}
}
}
}