-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPackages.aspx.cs
123 lines (91 loc) · 3.67 KB
/
Packages.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
using System.Configuration;
namespace TourAndTravel2
{
public partial class WebForm4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Session["UniqueName"] != null)
{
userUserLabel.Text = "" + "" + Session["UniqueName"].ToString();
}
MySqlConnection connection = new MySqlConnection("server=localhost;user id=root;database=awp;password=root");
MySqlCommand cmd = connection.CreateCommand();
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = "SELECT * FROM packages";
connection.Open();
MySqlDataAdapter sda = new MySqlDataAdapter();
sda.SelectCommand = cmd;
DataSet ds = new DataSet();
sda.Fill(ds);
DataList1.DataSource = ds;
DataList1.DataBind();
connection.Close();
}
}
protected void ChooseButton_Click(object sender, EventArgs e)
{
MySqlConnection connection = new MySqlConnection("server=localhost;user id=root;database=awp;password=root");
connection.Open();
MySqlCommand cmd1 = connection.CreateCommand();
cmd1.CommandType = System.Data.CommandType.Text;
//Label label = new Label();
//foreach (DataListItem item in DataList1.Items)
//{
// label = item.FindControl("nameLabel") as Label;
//}
Button b = (Button)sender;
DataListItem row = (DataListItem)b.NamingContainer;
Label label = (Label)DataList1.Items[row.ItemIndex].FindControl("nameLabel");
Label packageIdLabel = new Label();
MySqlCommand cmd2 = connection.CreateCommand();
cmd2.CommandType = System.Data.CommandType.Text;
cmd2.CommandText = "SELECT * FROM packages WHERE name = '" + label.Text + "'";
cmd2.ExecuteNonQuery();
MySqlDataReader read = cmd2.ExecuteReader();
while(read.Read())
{
packageIdLabel.Text = read["id"].ToString();
}
connection.Close();
cmd1.CommandText = "INSERT INTO checkout(userid, packageid, packagename) values('" + Session["ID"].ToString() + "', '" + packageIdLabel.Text + "', '" + label.Text + "')";
connection.Open();
cmd1.ExecuteNonQuery();
connection.Close();
Response.Redirect("checkout.aspx");
}
protected void functionCheckout(object sender, EventArgs e)
{
Response.Redirect("Checkout.aspx");
}
protected void BookingButton_Click(object sender, EventArgs e)
{
Response.Redirect("Bookings.aspx");
}
protected void CheckButtonHome_Click(object sender, EventArgs e)
{
Response.Redirect("Packages.aspx");
}
protected void LogOutButtonHome_Click(object sender, EventArgs e)
{
Session.Abandon();
Session.Remove("UserName");
Session.Remove("ID");
Session.Remove("Email");
Session.Remove("Phone");
Session.Remove("UniqueName");
Session.Remove("Password");
Response.Redirect("Home.aspx");
}
}
}