Скачиваний:
24
Добавлен:
12.04.2025
Размер:
8.45 Mб
Скачать

Приложение б

Листинг – Файл Home.aspx.cs

using System;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace WebApplication3

{

public partial class WebForm1 : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void DiscoverButton_Click(object sender, EventArgs e)

{

Response.Redirect("Find.aspx");

}

}

}

Приложение в

Листинг – Файл About.aspx.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace WebApplication3

{

public partial class About : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

}

protected void ListView1_SelectedIndexChanged(object sender, EventArgs e)

{

}

}

}

Приложение г

Листинг – Файл Find.aspx.cs

using System;

using System.Data;

using System.Web.UI;

using System.Web.UI.WebControls;

namespace WebApplication3

{

public partial class WebForm2 : System.Web.UI.Page

{

protected void Button1_Click(object sender, EventArgs e)

{

string type = DropDownList1.SelectedValue;

SqlDataSource1.SelectCommand = GetSqlCommand(type, null);

GridView1.DataBind();

}

protected void Button2_Click(object sender, EventArgs e)

{

string country = DropDownList2.SelectedValue;

SqlDataSource1.SelectCommand = GetSqlCommand(null, country);

GridView1.DataBind();

}

protected void Button3_Click(object sender, EventArgs e)

{

string type = DropDownList1.SelectedValue;

string country = DropDownList2.SelectedValue;

SqlDataSource1.SelectCommand = GetSqlCommand(type, country);

GridView1.DataBind();

}

private string GetSqlCommand(string type, string country)

{

string sql = @"SELECT

Tour.Tour_ID AS 'TourID',

Tour.Name_T AS 'Tour Name',

Tour.Description_T AS 'Description',

Tour.Duration_T AS 'Duration',

Type_T.Name_T AS 'Tour Type',

Season.Name_Season AS 'Season',

Hotel.Name_H AS 'Hotel Name',

Locality.Name_L AS 'Route Locality',

Locality.Country AS 'Country',

Image.FilePath AS 'Image Path'

FROM

Tour

JOIN

Type_T ON Tour.TypeT_ID = Type_T.TypeT_ID

JOIN

TourSeason ON Tour.Tour_ID = TourSeason.Tour_ID

JOIN

Season ON TourSeason.Season_ID = Season.Season_ID

JOIN

TourHotel ON Tour.Tour_ID = TourHotel.Tour_ID

JOIN

Hotel ON TourHotel.Hotel_ID = Hotel.Hotel_ID

JOIN

Route ON Tour.Tour_ID = Route.Tour_ID

JOIN

Locality ON Route.Locality_ID = Locality.Locality_ID

LEFT JOIN

ImageTour ON Tour.Tour_ID = ImageTour.TourID

LEFT JOIN

Image ON ImageTour.ImageID = Image.ImageID";

SqlDataSource1.SelectParameters.Clear();

if (!string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(country))

{

sql += " WHERE Type_T.Name_T = @Type AND Locality.Country = @Country";

SqlDataSource1.SelectParameters.Add(new Parameter("Type", DbType.String, type));

SqlDataSource1.SelectParameters.Add(new Parameter("Country", DbType.String, country));

}

else if (!string.IsNullOrEmpty(type))

{

sql += " WHERE Type_T.Name_T = @Type";

SqlDataSource1.SelectParameters.Add(new Parameter("Type", DbType.String, type));

}

else if (!string.IsNullOrEmpty(country))

{

sql += " WHERE Locality.Country = @Country";

SqlDataSource1.SelectParameters.Add(new Parameter("Country", DbType.String, country));

}

return sql;

}

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)

{

int selectedTourID = Convert.ToInt32(GridView1.SelectedDataKey.Value);

Response.Redirect($"TourDetails.aspx?TourID={selectedTourID}");

}

}

}

Соседние файлы в предмете Проектирование информационных систем