-
Notifications
You must be signed in to change notification settings - Fork 9
/
Cancel.aspx.cs
128 lines (120 loc) · 4.68 KB
/
Cancel.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using System.Configuration;
using System.IO;
using System.Web.Configuration;
public partial class Cancel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void Bt_submit_Click(object sender, EventArgs e)
{
String text = "";
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=(local);Initial Catalog=Hotel;Integrated Security=True";
con.Open();
String q = "Select * from booking_master where booking_master.email='"+tb__email.Text+"' and booking_master.booking_id="+Tb_Booking_id.Text;
SqlCommand com = new SqlCommand(q, con);
SqlDataReader dr = com.ExecuteReader();
String text1 = "";
if (dr.Read())
{
DateTime dt = Convert.ToDateTime(dr["check_in"].ToString());
text1 = "<br/><br/> Check In Date:" + dt.ToShortDateString() + "<br/><br/> Total Amount:" + dr["total_amt"].ToString() + "<br/><br/> No of Rooms:" + dr["no_of_rooms"].ToString();
con.Close();
SqlConnection con2 = new SqlConnection();
con2.ConnectionString = "Data Source=(local);Initial Catalog=Hotel;Integrated Security=True";
con2.Open();
String q2 = "Select user_master.first_name, user_master.last_name, user_master.address , user_master.city from user_master where user_master.email='"+tb__email.Text+"'";
SqlCommand com2 = new SqlCommand(q2, con2);
SqlDataReader dr2 = com2.ExecuteReader();
if (dr2.Read())
{
text = " Customer Name:" + dr2["first_name"].ToString() + " " + dr2["last_name"].ToString() + "<br/><br/>" + "Address: " + dr2["address"].ToString() +
"<br/><br/> City:" + dr2["city"].ToString();
con2.Close();
text += text1;
MultiView1.ActiveViewIndex = 1;
Lb_details.Text = text;
}
else
{
con2.Close();
Lb_details.Text = "Invalid booking or email id. Eror=0.5";
tb__email.Text = "";
Tb_Booking_id.Text = "";
}
}
else
{
con.Close();
Lb_invalid.Visible = true;
Lb_invalid.Text = "Invalid booking or email id. Error=0";
tb__email.Text = "";
Tb_Booking_id.Text = "";
}
}
protected void Bt_Conf_Cancel_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 2;
}
protected void Bt_yes_canc_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=(local);Initial Catalog=Hotel;Integrated Security=True";
con.Open();
String q = "Delete from booking_master where booking_id='" + Tb_Booking_id.Text + "'";
SqlCommand com = new SqlCommand(q, con);
int i = com.ExecuteNonQuery();
con.Close();
if (i == 1)
{
SqlConnection con2 = new SqlConnection();
con2.ConnectionString = "Data Source=(local);Initial Catalog=Hotel;Integrated Security=True";
con2.Open();
String q2 = "Delete from user_master where email='" + tb__email.Text + "'";
SqlCommand com2 = new SqlCommand(q2, con2);
int j = com2.ExecuteNonQuery();
con2.Close();
if (j == 1)
{
Lb_invalid.Visible = true;
Lb_invalid.Text = "Your booking is successfully cancelled !";
tb__email.Text = "";
Tb_Booking_id.Text = "";
}
else
{
Lb_invalid.Visible = true;
Lb_invalid.Text = "Cannot cancel your booking. Error=0.5";
tb__email.Text = "";
Tb_Booking_id.Text = "";
}
}
else
{
Lb_invalid.Visible = true;
Lb_invalid.Text = "Unable to cancel your booking. Error=0";
tb__email.Text = "";
Tb_Booking_id.Text = "";
}
MultiView1.ActiveViewIndex = 0;
}
protected void Bt_no_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex=1;
}
protected void Bt_print_Click(object sender, EventArgs e)
{
Response.Redirect("report.aspx?bid=" + Tb_Booking_id.Text);
}
}