-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDefault.aspx.cs
309 lines (294 loc) · 13.9 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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Collections;
using System.Configuration;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
this.Title = "Welcome to Banglar Pothik";
SqlConnection con = new SqlConnection(GetConnectionString());
if (!IsPostBack)
{
this.PopulateList1();
string sql3 = "SELECT Dis_name,Dis_id FROM District";
con.Open();
SqlCommand cmd3 = new SqlCommand(sql3, con);
DataSet ds3 = new DataSet();
SqlDataAdapter da3 = new SqlDataAdapter(cmd3);
da3.Fill(ds3);
DropDownList6.DataSource = ds3;
DropDownList6.DataTextField = "Dis_name";
DropDownList6.DataValueField = "Dis_id";
DropDownList6.DataBind();
DropDownList6.Items.Insert(0, new ListItem("All", "-1"));
DropDownList2.DataSource = ds3;
DropDownList2.DataTextField = "Dis_name";
DropDownList2.DataValueField = "Dis_id";
DropDownList2.DataBind();
DropDownList2.Items.Insert(0, new ListItem("All", "-1"));
con.Close();
string sql1 = "SELECT Cat_id,Cat_name FROM Category";
con.Open();
SqlCommand cmd1 = new SqlCommand(sql1, con);
DataSet ds1 = new DataSet();
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
da1.Fill(ds1);
DropDownList5.DataSource = ds1;
DropDownList5.DataTextField = "Cat_name";
DropDownList5.DataValueField = "Cat_id";
DropDownList5.DataBind();
DropDownList5.Items.Insert(0, new ListItem("All", "-1"));
con.Close();
string sql2 = "SELECT * FROM Place";
con.Open();
SqlCommand cmd2 = new SqlCommand(sql2, con);
DataSet ds2 = new DataSet();
SqlDataAdapter da2 = new SqlDataAdapter(cmd2);
da2.Fill(ds2);
DropDownList7.DataSource = ds2;
DropDownList7.DataTextField = "Place_name";
DropDownList7.DataValueField = "Place_id";
DropDownList7.DataBind();
DropDownList7.Items.Insert(0, new ListItem("All", "-1"));
con.Close();
string sql5 = "SELECT * FROM TripType";
con.Open();
SqlCommand cmd5 = new SqlCommand(sql5, con);
DataSet ds5 = new DataSet();
SqlDataAdapter da5 = new SqlDataAdapter(cmd5);
da5.Fill(ds5);
DropDownList8.DataSource = ds5;
DropDownList8.DataTextField = "Typename";
DropDownList8.DataValueField = "Typeid";
DropDownList8.DataBind();
DropDownList8.Items.Insert(0, new ListItem("All", "-1"));
con.Close();
string query = "SELECT Imagegrid.*,Place.Place_name FROM Imagegrid INNER JOIN Place ON Place.Place_id=Imagegrid.Placeid";
con.Open();
SqlCommand cmd4 = new SqlCommand(query, con);
DataSet ds4 = new DataSet();
SqlDataAdapter da4 = new SqlDataAdapter(cmd4);
da4.Fill(ds4);
cmd4.ExecuteNonQuery();
Repeater1.DataSource = ds4;
Repeater1.DataBind();
con.Close();
string query7 = "SELECT * FROM TravelAgency";
con.Open();
SqlCommand cmd7 = new SqlCommand(query7, con);
DataSet ds7 = new DataSet();
SqlDataAdapter da7 = new SqlDataAdapter(cmd7);
da7.Fill(ds7);
cmd7.ExecuteNonQuery();
Repeater3.DataSource = ds7;
Repeater3.DataBind();
con.Close();
string query6 = "SELECT * FROM (SELECT Friends.Friendid FROM Friends JOIN Users ON Users.Userid=Friends.Userid WHERE Users.Username = '"+ Page.User.Identity.Name +"') AS query1 " +
"INNER JOIN (SELECT DISTINCT(Comment.datetime),Comment.status,Users.Name,Users.Userid,Place.Place_id,Place.Place_name FROM Comment " +
"JOIN Users ON Users.Userid=Comment.Userid JOIN Place ON Comment.Placeid=Place.Place_id UNION ALL " +
"SELECT DISTINCT(Checkin.datetime),Checkin.status,Users.Name,Users.Userid,Place.Place_id,Place.Place_name FROM Checkin " +
"JOIN Users ON Users.Userid=Checkin.Userid JOIN Place ON Checkin.Place_id=Place.Place_id) AS query2 " +
"ON query2.Userid=query1.Friendid ORDER BY query2.datetime desc";
con.Open();
SqlCommand cmd6 = new SqlCommand(query6, con);
DataSet ds6 = new DataSet();
SqlDataAdapter da6 = new SqlDataAdapter(cmd6);
da6.Fill(ds6);
cmd6.ExecuteNonQuery();
Repeater2.DataSource = ds6;
Repeater2.DataBind();
con.Close();
if (Page.User.Identity.Name == String.Empty)
{
Label2.Text = "You must login to see friends update!";
}
else
{
string sql7 = "SELECT COUNT(*) FROM Friends WHERE Userid=(SELECT Userid FROM Users WHERE Username = '" + Page.User.Identity.Name + "')";
con.Open();
cmd6 = new SqlCommand(sql7, con);
int count = (Int32)cmd6.ExecuteScalar();
if (count == 0)
{
Label2.Text = "You must add one or more friends to get friends updates.";
}
}
}
Page.MaintainScrollPositionOnPostBack = true;
}
private void PopulateList1()
{
SqlConnection con = new SqlConnection(GetConnectionString());
string sql = "SELECT Div_name,Div_id FROM Division";
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
DataSet ds = new DataSet();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
DropDownList1.DataSource = ds;
DropDownList1.DataTextField = "Div_name";
DropDownList1.DataValueField = "Div_id";
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, new ListItem("All", "0"));
con.Close();
}
public string GetConnectionString()
{
return System.Configuration.ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
}
protected void Button1_Click(object sender, EventArgs e)
{
if (DropDownList1.SelectedItem.ToString() == "All" && DropDownList2.SelectedItem.ToString() == "All" && DropDownList5.SelectedItem.ToString() == "All")
{
Label1.Text = "You need to select at least 1 filter.";
}
else
{
Session["division"] = DropDownList1.SelectedItem.ToString();
Session["district"] = DropDownList2.SelectedItem.ToString();
Session["category"] = DropDownList5.SelectedItem.ToString();
Response.Redirect("SearchResult.aspx?division="+DropDownList1.SelectedItem.ToString()+"&district="+DropDownList2.SelectedItem.ToString()+"&category="+DropDownList5.SelectedItem.ToString());
}
}
protected void Button3_Click(object sender, EventArgs e)
{
if (DropDownList6.SelectedItem.ToString() == "All" && DropDownList7.SelectedItem.ToString() == "All" && DropDownList8.SelectedItem.ToString() == "All" && DropDownList3.SelectedValue.ToString() == "0" && DropDownList4.SelectedValue.ToString() == "0")
{
Label3.Text = "You need to select at least 1 filter.";
}
else
{
int min = Convert.ToInt32(DropDownList3.SelectedValue);
int max = Convert.ToInt32(DropDownList4.SelectedValue);
Session["district"] = DropDownList6.SelectedValue;
Session["place"] = DropDownList7.SelectedValue;
Session["type"] = DropDownList8.SelectedValue;
Response.Redirect("SearchResult.aspx?min="+ min +"&max="+ max);
}
}
protected void Max_Changed(object sender, EventArgs e)
{
int max = Convert.ToInt32(DropDownList4.SelectedValue);
if (max == 0)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("Select", "0"));
}
if (max == 500)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("Select", "0"));
}
if (max == 2000)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("Select", "0"));
DropDownList3.Items.Insert(1, new ListItem("500", "500"));
}
if (max == 4000)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("Select", "0"));
DropDownList3.Items.Insert(1, new ListItem("500", "500"));
DropDownList3.Items.Insert(2, new ListItem("2000", "2000"));
}
if (max == 6000)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("Select", "0"));
DropDownList3.Items.Insert(1, new ListItem("500", "500"));
DropDownList3.Items.Insert(2, new ListItem("2000", "2000"));
DropDownList3.Items.Insert(3, new ListItem("4000", "4000"));
}
if (max == 8000)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("Select", "0"));
DropDownList3.Items.Insert(1, new ListItem("500", "500"));
DropDownList3.Items.Insert(2, new ListItem("2000", "2000"));
DropDownList3.Items.Insert(3, new ListItem("4000", "4000"));
DropDownList3.Items.Insert(4, new ListItem("6000", "6000"));
}
if (max == 10000)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("Select", "0"));
DropDownList3.Items.Insert(1, new ListItem("500", "500"));
DropDownList3.Items.Insert(2, new ListItem("2000", "2000"));
DropDownList3.Items.Insert(3, new ListItem("4000", "4000"));
DropDownList3.Items.Insert(4, new ListItem("6000", "6000"));
DropDownList3.Items.Insert(5, new ListItem("8000", "8000"));
}
if (max == 12000)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("Select", "0"));
DropDownList3.Items.Insert(1, new ListItem("500", "500"));
DropDownList3.Items.Insert(2, new ListItem("2000", "2000"));
DropDownList3.Items.Insert(3, new ListItem("4000", "4000"));
DropDownList3.Items.Insert(4, new ListItem("6000", "6000"));
DropDownList3.Items.Insert(5, new ListItem("8000", "8000"));
DropDownList3.Items.Insert(6, new ListItem("10000", "10000"));
}
if (max == 14000)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("Select", "0"));
DropDownList3.Items.Insert(1, new ListItem("500", "500"));
DropDownList3.Items.Insert(2, new ListItem("2000", "2000"));
DropDownList3.Items.Insert(3, new ListItem("4000", "4000"));
DropDownList3.Items.Insert(4, new ListItem("6000", "6000"));
DropDownList3.Items.Insert(5, new ListItem("8000", "8000"));
DropDownList3.Items.Insert(6, new ListItem("10000", "10000"));
DropDownList3.Items.Insert(7, new ListItem("12000", "12000"));
}
if (max == 16000)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("Select", "0"));
DropDownList3.Items.Insert(1, new ListItem("500", "500"));
DropDownList3.Items.Insert(2, new ListItem("2000", "2000"));
DropDownList3.Items.Insert(3, new ListItem("4000", "4000"));
DropDownList3.Items.Insert(4, new ListItem("6000", "6000"));
DropDownList3.Items.Insert(5, new ListItem("8000", "8000"));
DropDownList3.Items.Insert(6, new ListItem("10000", "10000"));
DropDownList3.Items.Insert(7, new ListItem("12000", "12000"));
DropDownList3.Items.Insert(8, new ListItem("14000", "14000"));
}
if (max == 18000)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("Select", "0"));
DropDownList3.Items.Insert(1, new ListItem("500", "500"));
DropDownList3.Items.Insert(2, new ListItem("2000", "2000"));
DropDownList3.Items.Insert(3, new ListItem("4000", "4000"));
DropDownList3.Items.Insert(4, new ListItem("6000", "6000"));
DropDownList3.Items.Insert(5, new ListItem("8000", "8000"));
DropDownList3.Items.Insert(6, new ListItem("10000", "10000"));
DropDownList3.Items.Insert(7, new ListItem("12000", "12000"));
DropDownList3.Items.Insert(8, new ListItem("14000", "14000"));
DropDownList3.Items.Insert(9, new ListItem("16000", "16000"));
}
if (max == 20000)
{
DropDownList3.Items.Clear();
DropDownList3.Items.Insert(0, new ListItem("Select", "0"));
DropDownList3.Items.Insert(1, new ListItem("500", "500"));
DropDownList3.Items.Insert(2, new ListItem("2000", "2000"));
DropDownList3.Items.Insert(3, new ListItem("4000", "4000"));
DropDownList3.Items.Insert(4, new ListItem("6000", "6000"));
DropDownList3.Items.Insert(5, new ListItem("8000", "8000"));
DropDownList3.Items.Insert(6, new ListItem("10000", "10000"));
DropDownList3.Items.Insert(7, new ListItem("12000", "12000"));
DropDownList3.Items.Insert(8, new ListItem("14000", "14000"));
DropDownList3.Items.Insert(9, new ListItem("16000", "16000"));
}
}
}