-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTrips.aspx.cs
312 lines (303 loc) · 14 KB
/
Trips.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
310
311
312
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;
public partial class Trips : System.Web.UI.Page
{
protected string trip;
public string GetConnectionString()
{
return System.Configuration.ConfigurationManager.ConnectionStrings["ConString"].ConnectionString;
}
protected void Page_Load(object sender, EventArgs e)
{
if (Request["Tripid"] != null)
{
SqlConnection con = new SqlConnection(GetConnectionString());
trip = Request["Tripid"].ToString();
string sql = "SELECT TripDetail.*,TravelAgency.Agencyname,TripType.Typename FROM TripDetail INNER JOIN TravelAgency ON TripDetail.Agencyid=TravelAgency.Agencyid INNER JOIN TripType ON TripType.Typeid=TripDetail.Type WHERE TripDetail.Tripid = '" + trip + "'";
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
SqlDataReader dr = null;
dr = cmd.ExecuteReader();
while (dr.Read())
{
HyperLink1.NavigateUrl = "AgencyDetail.aspx?Agencyid=" + dr["Agencyid"].ToString();
HyperLink1.Text = dr["Agencyname"].ToString();
Label1.Text = dr["Tripname"].ToString();
this.Title = dr["Tripname"].ToString();
Label2.Text = dr["Typename"].ToString();
Label4.Text = dr["Duration"].ToString();
if (dr["Cost"].ToString() != "Unknown")
{
Label5.Text = "BDT " + dr["Cost"].ToString();
}
else
{
Label5.Text = "Call agency for price";
}
Label3.Text = dr["Detail"].ToString();
if (dr["Disid1"].ToString() != "-1")
{
string sql1 = "SELECT Dis_name FROM District WHERE Dis_id = '" + dr["Disid1"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink2.NavigateUrl = "ContentPage.aspx?District=" + dr["Disid1"].ToString();
HyperLink2.Text = dr1["Dis_name"].ToString();
}
dr1.Close();
}
if (dr["Disid2"].ToString() != "-1")
{
string sql1 = "SELECT Dis_name FROM District WHERE Dis_id = '" + dr["Disid2"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink3.NavigateUrl = "ContentPage.aspx?District=" + dr["Disid2"].ToString();
HyperLink3.Text = dr1["Dis_name"].ToString();
}
dr1.Close();
}
if (dr["Disid3"].ToString() != "-1")
{
string sql1 = "SELECT Dis_name FROM District WHERE Dis_id = '" + dr["Disid3"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink4.NavigateUrl = "ContentPage.aspx?District=" + dr["Disid3"].ToString();
HyperLink4.Text = dr1["Dis_name"].ToString();
}
dr1.Close();
}
if (dr["Disid4"].ToString() != "-1")
{
string sql1 = "SELECT Dis_name FROM District WHERE Dis_id = '" + dr["Disid4"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink5.NavigateUrl = "ContentPage.aspx?District=" + dr["Disid4"].ToString();
HyperLink5.Text = dr1["Dis_name"].ToString();
}
dr1.Close();
}
if (dr["Disid5"].ToString() != "-1")
{
string sql1 = "SELECT Dis_name FROM District WHERE Dis_id = '" + dr["Disid5"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink6.NavigateUrl = "ContentPage.aspx?District=" + dr["Disid5"].ToString();
HyperLink6.Text = dr1["Dis_name"].ToString();
}
dr1.Close();
}
if (dr["Disid6"].ToString() != "-1")
{
string sql1 = "SELECT Dis_name FROM District WHERE Dis_id = '" + dr["Disid6"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink7.NavigateUrl = "ContentPage.aspx?District=" + dr["Disid6"].ToString();
HyperLink7.Text = dr1["Dis_name"].ToString();
}
dr1.Close();
}
if (dr["Placeid1"].ToString() != "-1")
{
string sql1 = "SELECT Place_name FROM Place WHERE Place_id = '" + dr["Placeid1"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink8.NavigateUrl = "Place.aspx?Place=" + dr["Placeid1"].ToString();
HyperLink8.Text = dr1["Place_name"].ToString();
}
dr1.Close();
}
if (dr["Placeid2"].ToString() != "-1")
{
string sql1 = "SELECT Place_name FROM Place WHERE Place_id = '" + dr["Placeid2"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink9.NavigateUrl = "Place.aspx?Place=" + dr["Placeid2"].ToString();
HyperLink9.Text = dr1["Place_name"].ToString();
}
dr1.Close();
}
if (dr["Placeid3"].ToString() != "-1")
{
string sql1 = "SELECT Place_name FROM Place WHERE Place_id = '" + dr["Placeid3"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink10.NavigateUrl = "Place.aspx?Place=" + dr["Placeid3"].ToString();
HyperLink10.Text = dr1["Place_name"].ToString();
}
dr1.Close();
}
if (dr["Placeid4"].ToString() != "-1")
{
string sql1 = "SELECT Place_name FROM Place WHERE Place_id = '" + dr["Placeid4"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink11.NavigateUrl = "Place.aspx?Place=" + dr["Placeid4"].ToString();
HyperLink11.Text = dr1["Place_name"].ToString();
}
dr1.Close();
}
if (dr["Placeid5"].ToString() != "-1")
{
string sql1 = "SELECT Place_name FROM Place WHERE Place_id = '" + dr["Placeid5"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink12.NavigateUrl = "Place.aspx?Place=" + dr["Placeid5"].ToString();
HyperLink12.Text = dr1["Place_name"].ToString();
}
dr1.Close();
}
if (dr["Placeid6"].ToString() != "-1")
{
string sql1 = "SELECT Place_name FROM Place WHERE Place_id = '" + dr["Placeid6"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink13.NavigateUrl = "Place.aspx?Place=" + dr["Placeid6"].ToString();
HyperLink13.Text = dr1["Place_name"].ToString();
}
dr1.Close();
}
if (dr["Placeid7"].ToString() != "-1")
{
string sql1 = "SELECT Place_name FROM Place WHERE Place_id = '" + dr["Placeid7"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink14.NavigateUrl = "Place.aspx?Place=" + dr["Placeid7"].ToString();
HyperLink14.Text = dr1["Place_name"].ToString();
}
dr1.Close();
}
if (dr["Placeid8"].ToString() != "-1")
{
string sql1 = "SELECT Place_name FROM Place WHERE Place_id = '" + dr["Placeid8"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink15.NavigateUrl = "Place.aspx?Place=" + dr["Placeid8"].ToString();
HyperLink15.Text = dr1["Place_name"].ToString();
}
dr1.Close();
}
if (dr["Placeid9"].ToString() != "-1")
{
string sql1 = "SELECT Place_name FROM Place WHERE Place_id = '" + dr["Placeid9"].ToString() + "'";
SqlCommand cmd1 = new SqlCommand(sql1, con);
SqlDataReader dr1 = null;
dr1 = cmd1.ExecuteReader();
while (dr1.Read())
{
HyperLink16.NavigateUrl = "Place.aspx?Place=" + dr["Placeid9"].ToString();
HyperLink16.Text = dr1["Place_name"].ToString();
}
dr1.Close();
}
}
con.Close();
}
}
protected void Recom_Friend(object sender, EventArgs e)
{
Panel5.Visible = true;
Drop1();
}
protected void Drop1()
{
if (Request["Tripid"] != null)
{
trip = Request["Tripid"].ToString();
}
SqlConnection con1 = new SqlConnection(GetConnectionString());
string sql5 = "SELECT Friends.Friendid,Users.Name FROM Friends INNER JOIN Users ON Friends.Friendid=Users.Userid WHERE Friends.Userid=(SELECT Userid FROM Users WHERE Username = '" + Page.User.Identity.Name + "') AND Friends.Friendid NOT IN (SELECT Req_to From Request WHERE Req_by=(SELECT Userid FROM Users WHERE Username = '" + Page.User.Identity.Name + "') AND Req_trip='" + trip + "')";
con1.Open();
SqlCommand cmd6 = new SqlCommand(sql5, con1);
cmd6 = new SqlCommand(sql5, con1);
DataSet ds5 = new DataSet();
SqlDataAdapter da5 = new SqlDataAdapter(cmd6);
da5.Fill(ds5);
DropDownList1.DataSource = ds5;
DropDownList1.DataTextField = "Name";
DropDownList1.DataValueField = "Friendid";
DropDownList1.DataBind();
DropDownList1.Items.Insert(0, new ListItem("Select friend", "-1"));
con1.Close();
}
protected void Recommend(object sender, EventArgs e)
{
if (Request["Tripid"] != null && DropDownList1.Items.Count != 0)
{
trip = Request["Tripid"].ToString();
SqlConnection con = new SqlConnection(GetConnectionString());
string sql = "INSERT INTO Request (Req_by,Req_to,Req_type,Req_trip) VALUES((SELECT Userid FROM Users WHERE Username = '" + Page.User.Identity.Name + "') , @to,@type, '" + trip + "')";
try
{
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
cmd.Parameters.AddWithValue("@to", DropDownList1.SelectedValue.ToString());
cmd.Parameters.AddWithValue("@type", "requested you to check out the trip ");
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Insert Error";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
con.Close();
Label12.Text = "Recommendation sent to " + DropDownList1.SelectedItem.ToString() + ".";
Drop1();
}
}
else
{
Label12.Text = "No friends to recommend.";
}
}
}