-
Notifications
You must be signed in to change notification settings - Fork 0
/
excursions.aspx.cs
73 lines (48 loc) · 5.79 KB
/
excursions.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DW.Utilities;
public partial class excursions : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Hindrer at siden hopper til toppen ved 'autopostback'.
Page.MaintainScrollPositionOnPostBack = true;
// Viser totale påmeldinger, totalt aktive og fullførte.
totalLabel.Text = db.mcSqlCommand("SELECT COUNT(*) FROM excursions");
activeLabel.Text = db.mcSqlCommand("SELECT COUNT(*) FROM excursions WHERE excursion_date > GETDATE()");
finishLabel.Text = db.mcSqlCommand("SELECT COUNT(*) FROM excursions WHERE excursion_date < GETDATE()");
}
protected void search_button_Click(object sender, EventArgs e)
{
//Søk for aktive utflukter.
mcExcursions.SelectCommand = "SELECT * FROM excursions JOIN boats ON excursions.boat_ID = boats.boat_ID JOIN excursions_destinations ON excursions.excursion_ID = excursions_destinations.excursion_ID JOIN destinations ON excursions_destinations.destination_ID = destinations.destination_ID WHERE excursion_date > GETDATE() AND excursion_name LIKE '%" + searchText.Text + "%' OR destination LIKE '%" + searchText.Text + "%' ORDER BY excursion_date";
//Søk for inaktive utflukter.
mcComplete.SelectCommand = "SELECT * FROM excursions JOIN boats ON excursions.boat_ID = boats.boat_ID JOIN excursions_destinations ON excursions.excursion_ID = excursions_destinations.excursion_ID JOIN destinations ON excursions_destinations.destination_ID = destinations.destination_ID WHERE excursion_date < GETDATE() AND (excursion_name LIKE '%" + searchText.Text + "%' OR destination LIKE '%" + searchText.Text + "%')";
}
protected void all_entries_Click(object sender, EventArgs e)
{
// Henter ut alle utflukter som ikke har vært, sortert etter navn.
mcExcursions.SelectCommand = "SELECT excursions.excursion_ID, excursions.excursion_name, excursions.excursion_date, excursions.duration, excursions.price, excursions.excursion_description, excursions.url, boats.boat_name, boats.foot, boats.boat_year, boats.boat_owner, destinations.destination FROM excursions JOIN boats ON excursions.boat_ID = boats.boat_ID JOIN excursions_destinations ON excursions.excursion_ID = excursions_destinations.excursion_ID JOIN destinations ON excursions_destinations.destination_ID = destinations.destination_ID WHERE excursions.excursion_date > GETDATE() ORDER BY excursions.excursion_name";
}
protected void popular_entries_Click(object sender, EventArgs e)
{
// Henter ut utflukter med mest påmeldinger, sortert fra mest til minst.
mcExcursions.SelectCommand = "SELECT TOP 3 excursions.excursion_ID, excursions.excursion_name, COUNT(sign_ups.excursion_ID) AS 'count', excursions.excursion_date, excursions.duration, excursions.price, excursions.excursion_description, boats.boat_name, boats.foot, boats.boat_year, boats.boat_owner, destinations.destination FROM excursions JOIN boats ON excursions.boat_ID = boats.boat_ID JOIN sign_ups ON excursions.excursion_ID = sign_ups.excursion_ID JOIN excursions_destinations ON excursions.excursion_ID = excursions_destinations.excursion_ID JOIN destinations ON excursions_destinations.destination_ID = destinations.destination_ID WHERE excursions.excursion_date > GETDATE() GROUP BY excursions.excursion_name, sign_ups.excursion_ID,excursions.excursion_ID, excursions.excursion_date, excursions.duration, excursions.price, excursions.excursion_description, boats.boat_name, boats.foot, boats.boat_year, boats.boat_owner, destinations.destination ORDER BY 'count' DESC";
}
protected void sort_days_Click(object sender, EventArgs e)
{
mcExcursions.SelectCommand = "SELECT excursions.excursion_ID, excursions.excursion_name, excursions.excursion_date, excursions.duration, excursions.price, excursions.excursion_description, excursions.url, boats.boat_name, boats.foot, boats.boat_year, boats.boat_owner, destinations.destination FROM excursions JOIN boats ON excursions.boat_ID = boats.boat_ID JOIN excursions_destinations ON excursions.excursion_ID = excursions_destinations.excursion_ID JOIN destinations ON excursions_destinations.destination_ID = destinations.destination_ID WHERE excursions.excursion_date > GETDATE() ORDER BY excursions.duration DESC";
}
protected void sort_price_Click(object sender, EventArgs e)
{
mcExcursions.SelectCommand = "SELECT excursions.excursion_ID, excursions.excursion_name, excursions.excursion_date, excursions.duration, excursions.price, excursions.excursion_description, excursions.url, boats.boat_name, boats.foot, boats.boat_year, boats.boat_owner, destinations.destination FROM excursions JOIN boats ON excursions.boat_ID = boats.boat_ID JOIN excursions_destinations ON excursions.excursion_ID = excursions_destinations.excursion_ID JOIN destinations ON excursions_destinations.destination_ID = destinations.destination_ID WHERE excursions.excursion_date > GETDATE() ORDER BY excursions.price DESC";
}
protected void sort_date_Click(object sender, EventArgs e)
{
mcExcursions.SelectCommand = "SELECT excursions.excursion_ID, excursions.excursion_name, excursions.excursion_date, excursions.duration, excursions.price, excursions.excursion_description, excursions.url, boats.boat_name, boats.foot, boats.boat_year, boats.boat_owner, destinations.destination FROM excursions JOIN boats ON excursions.boat_ID = boats.boat_ID JOIN excursions_destinations ON excursions.excursion_ID = excursions_destinations.excursion_ID JOIN destinations ON excursions_destinations.destination_ID = destinations.destination_ID WHERE excursions.excursion_date > GETDATE() ORDER BY excursions.excursion_date ASC";
}
}