H
private void
add_rooms1(int p,string
room_name,int room_type_id,DateTime dateTime, DateTime
dateTime_2, string
p_2, string p_3)
{
try
{
DataTable dt = new DataTable();
if (Session["room_booking"]
== null)
{
dt.Columns.Add("Room_id", typeof(int));
dt.Columns.Add("Room_name", typeof(string));
dt.Columns.Add("room_type_id", typeof(int));
dt.Columns.Add("CheckInDate", typeof(DateTime));
dt.Columns.Add("CheckOutDate", typeof(DateTime));
dt.Columns.Add("Extra_bed", typeof(int));
dt.Columns.Add("Extra_charge", typeof(decimal));
dt.Rows.Add(p, room_name,
room_type_id,dateTime, dateTime_2, nvert.ToInt32(p_2),
Convert.ToDecimal(p_3));
Session["room_booking"] = dt;
grand_total = 0;
bind_booking_cart();
}
else
if
(Session["room_booking"] != null)
{
DataTable dt1 = new DataTable();
dt1 = Session["room_booking"] as
DataTable;
bool AlreadyExists=check_cart(p);
if (AlreadyExists == true)
{
lblerror.Visible = true;
lblerror.ForeColor = System.Drawing.Color.Red;
lblerror.Text = "Room alredy
added";
grand_total
= 0;
bind_booking_cart();
}
else
{
dt1.Rows.Add(p,room_name,room_type_id,
dateTime, dateTime_2, Convert.ToInt32(p_2), Convert.ToDecimal(p_3));
Session["room_booking"] = dt1;
grand_total
= 0;
bind_booking_cart();
}
}
}
catch (Exception
ex)
{
lblerror.Visible = true;
lblerror.ForeColor = System.Drawing.Color.Red;
lblerror.Text = ex.Message;
}
}
protected bool check_cart(int
id)
{
//try
//{
bool
AlreadyExists = false;
DataTable
dt1 = new DataTable();
dt1 = Session["room_booking"] as
DataTable;
foreach
(DataRow row1 in
dt1.Rows)
{
Int32
array1 = Convert.ToInt32(row1["Room_id"]);
if
(array1 == id)
{
AlreadyExists = true;
break;
}
else
{
AlreadyExists = false;
}
}
return
AlreadyExists;
//}
//catch
(Exception ex)
//{
// lblerror.Visible = true;
// lblerror.ForeColor =
System.Drawing.Color.Red;
// lblerror.Text = ex.Message;
//}
}
No comments:
Post a Comment