You are on page 1of 61

Online movie ticket booking project In Asp Net

with c# (or) free download online cinema movie


ticket booking c# asp .net

Online movie ticket booking project In Asp


Net with c#
This project is basically aimed to provide the customers facility to book the
movie tickets online. The pain of standing in queue at cinema hall window will be
gone with help of this facility of online movie tickets booking. It is an automatic
system. The customers will get the extra benefit of selecting the seats of their
choice from seats layout. The customers will be able to make a choice of their
own by riding through the website. User friendliness of website will help attract
more customers to multiplex. Extra features of website like discounts, offers,
advertises , movie details etc will help people to know about different movies and
they will be attracted to the multiplex by seeing such facilities. Along with
customers the employees at window booking of the multiplex will get very user
friendly and smooth ride for booking process.

Code : asp.net and c#


Datebase : SQL

List of pages :

Admin panel pages differs from the normal web page.


Admin panels are for managing the entire site whcih consist of following
modules

1. Users
2. Contents
3. Permission of various pages.
4. Transactions (If website is performing any transaction)
5. Sending Newsletter ( If website has the provision for users to subscribe
news letter).
So basically admin panels are for managing the website. So build/arrange
your modules based on your actual website/webapplication.

Admin Pages :

AdminHome.aspx
AdminLogin.aspx
Create ddHallLayout.aspx
CreateTheatre.aspx
creatycity.aspx
InsertMovieInformation.aspx
ListOfBookedTickets.aspx
ListOfCancelledTicketd.aspx
DeleteUser.aspx
ListOfRegCandidates.aspx
ModifyRegUsers.aspx

UserLoginPages :

Index.aspx

Provided Login.aspx
Registration.aspx
Forgot password.aspx
Contactus.aspx
Change password.aspx
Update User Details..aspx
List of Posted Jobs.aspx

PrintTicket.aspx
SearchMovies.aspx

SelectedMovie.aspx

ListofBookedTickets.aspx
CancelTickets.aspx
Gateway.aspx
ConfirmationShow.aspx

Selected Movie :
In this page user has to choose movie , city , theatre, date and submit to next
page.

Hall Layout Screen

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Globalization;

namespace BookFilmTickets
{
public partial class Index : System.Web.UI.Page
{
SqlConnection con
= newSqlConnection(ConfigurationManager.ConnectionStrings[""].ConnectionString
);

protected void Page_Load(object sender, EventArgs e)


{
if (!IsPostBack)
{
string str = "select distinct

city from moviedata";

SqlDataAdapter adp = new SqlDataAdapter(str, con);


DataSet ds = new DataSet();
adp.Fill(ds);
Ddlcity.DataSource = ds;
Ddlcity.DataBind();
Ddlcity.Items.Insert(0, new ListItem("--Select city--","0"));
Ddlmovie.Items.Insert(0, new ListItem("--Select
movie--", "0"));
Ddltheatre.Items.Insert(0, new ListItem("--Select
theatre--", "0"));
}
}

protected void Ddlcity_SelectedIndexChanged(object sender, EventArgs e


)
{
Ddlmovie.Items.Clear();
string ct = Ddlcity.SelectedValue.ToString();

string str = "select movie from moviedata where city= '" + ct + "'
";
SqlDataAdapter adp = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
adp.Fill(ds);
Ddlmovie.DataSource = ds;
Ddlmovie.DataBind();
Ddlmovie.Items.Insert(0, new ListItem("--Select movie--", "0"));
}

protected void Ddlmovie_SelectedIndexChanged(object sender, EventArgs


e)
{
Ddltheatre.Items.Clear();
string mv = Ddlmovie.SelectedValue.ToString();
string str = "select theatre from moviedata where movie= '" + mv
+ "' ";
SqlDataAdapter adp = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
adp.Fill(ds);
Ddltheatre.DataSource = ds;
Ddltheatre.DataBind();

Ddltheatre.Items.Insert(0, new ListItem("--Select


Theatre--", "0"));
DdlDATE.Items.Clear();
ListItem lt = new ListItem();
lt.Text = "--Select Date--";
lt.Value = "0";
DdlDATE.Items.Add(lt);
String sDate = DateTime.UtcNow.ToString();
DateTime datevalue = (Convert.ToDateTime(sDate.ToString()));
string pattern
= CultureInfo.CurrentCulture.DateTimeFormat.MonthDayPattern;
pattern = pattern.Replace("MMMM", "MMM");
string formatted = "Today, " + datevalue.ToString(pattern);
string formatted1 = "Tomorrow, " +
datevalue.AddDays(1).ToString(pattern);
string formatted2 = datevalue.AddDays(2).ToString(pattern);
DdlDATE.Items.Add(formatted);
DdlDATE.Items.Add(formatted1);
DdlDATE.Items.Add(formatted2);
}

protected void Button1_Click(object sender, EventArgs e)


{

string cty = Ddlcity.SelectedValue.ToString();


string mve = Ddlmovie.SelectedValue.ToString();
string thr = Ddltheatre.SelectedValue.ToString();
string dte = DdlDATE.SelectedValue.ToString();
Response.Redirect("~/UserSelectedMovie.aspx?city=" + cty
+ "&movie=" + mve + " &thetre=" + thr + " &date=" + dte);

}
}

After selecting movie, you can see the hall lay out of your selected hall. Here you can select the
seats and user can selet 6 tickets only.
We use business o bjects and data access layers in this projects.

BOL.cs and DAL.cs

BOL.cs code :

using System;

using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.Sql;
using System.Data.SqlClient;

/// <summary>
/// Summary description for BOL
/// </summary>
public class BOL
{
SqlConnection con
= newSqlConnection(ConfigurationManager.ConnectionStrings[""].ConnectionString
);
public BOL()

{
//
// TODO: Add constructor logic here
//
}
public int AddScreen(string screenName)
{
try
{
SqlParameter[] p = new SqlParameter[1];
p[0] = new SqlParameter("@ScreenName", screenName);
return DAL.ExecuteNonQuery(DAL.GetConnectionString(),CommandType.S
toredProcedure, "sp_AddScreen", p);
}
catch (ArgumentException ex)
{
throw new ArgumentException(ex.Message);
}
}
public DataSet GetScreens()
{
try

{
SqlParameter[] p = new SqlParameter[0];
return DAL.ExecuteDataSet(DAL.GetConnectionString(),CommandType.St
oredProcedure, "sp_GetScreens", p);
}
catch (Exception)
{
throw;
}
}
public DataSet GetScreenLayout(int screenId)
{
try
{
SqlParameter[] p = new SqlParameter[1];
p[0] = new SqlParameter("@ScreenId", screenId);
return DAL.ExecuteDataSet(DAL.GetConnectionString(),CommandType.St
oredProcedure, "sp_GetScreenLayout", p);
}
catch (ArgumentException ex)
{
throw new ArgumentException(ex.Message);

}
}
public string AddScreenLayout(string rowName, int screenId,

string one, s

tring two,string three, string four, string five, string six, string seven, st
ring eight, stringnine, string ten, string eleven, string twelve, string thirt
een, string fourteen, stringfifteen, string sixteen, string seventeen, string
eighteen, string nineteen, stringtwenty, string twentyone, string twentytwo, s
tring twentythree, string twentyfour, stringtwentyfive, string twentysix, stri
ng twentyseven, string twentyeight, string twentynine,string thirty)
{
try
{
SqlParameter[] p = new SqlParameter[33];
p[0] = new SqlParameter("@RowName", rowName);
p[1] = new SqlParameter("@ScreenId", screenId);
p[3] = new SqlParameter("@1", one);
p[4] = new SqlParameter("@2", two);
p[5] = new SqlParameter("@3", three);
p[6] = new SqlParameter("@4", four);
p[7] = new SqlParameter("@5", five);
p[8] = new SqlParameter("@6", six);
p[9] = new SqlParameter("@7", seven);
p[10] = new SqlParameter("@8", eight);
p[11] = new SqlParameter("@9", nine);

p[12] = new SqlParameter("@10", ten);


p[13] = new SqlParameter("@11", eleven);
p[14] = new SqlParameter("@12", twelve);
p[15] = new SqlParameter("@13", thirteen);
p[16] = new SqlParameter("@14", fourteen);
p[17] = new SqlParameter("@15", fifteen);
p[18] = new SqlParameter("@16", sixteen);
p[19] = new SqlParameter("@17", seventeen);
p[20] = new SqlParameter("@18", eighteen);
p[21] = new SqlParameter("@19", nineteen);
p[22] = new SqlParameter("@20", twenty);
p[23] = new SqlParameter("@21", twentyone);
p[24] = new SqlParameter("@22", twentytwo);
p[25] = new SqlParameter("@23", twentythree);
p[26] = new SqlParameter("@24", twentyfour);
p[27] = new SqlParameter("@25", twentyfive);
p[28] = new SqlParameter("@26", twentysix);
p[29] = new SqlParameter("@27", twentyseven);
p[30] = new SqlParameter("@28", twentyeight);
p[31] = new SqlParameter("@29", twentynine);
p[32] = new SqlParameter("@30", thirty);

p[2] = new SqlParameter("@Message", SqlDbType.VarChar, 150);


p[2].Direction = ParameterDirection.Output;
DAL.ExecuteDataSet(DAL.GetConnectionString(), CommandType.StoredPr
ocedure,"sp_AddScreenLayout", p);
return Convert.ToString(p[2].Value);
}
catch (ArgumentException ex)
{
throw new ArgumentException(ex.Message);
}
}
}
===============================================================================
=============

DAL.cs code :

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;

using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

/// <summary>
/// Summary description for DAL
/// </summary>
public class DAL
{
public DAL()
{
//
// TODO: Add constructor logic here
//
}
static SqlConnection con;
static SqlCommand cmd;
static DataSet ds;

static SqlDataAdapter da;


public static string GetConnectionString()
{
SqlConnection con
= newSqlConnection(ConfigurationManager.ConnectionStrings[""].ConnectionString
);
string constr = con.ToString();
return constr;
}
public static int ExecuteNonQuery(string connectionString, CommandType com
mandType,string commandText, SqlParameter[] parameters)
{
try
{
SqlConnection con
= newSqlConnection(ConfigurationManager.ConnectionStrings[""].ConnectionString
);
cmd = new SqlCommand(commandText, con);
cmd.CommandType = commandType;
foreach (SqlParameter p in parameters)
{
if (p.Value == null)
{

}
cmd.Parameters.Add(p);
}
con.Open();
return cmd.ExecuteNonQuery();
}
catch (SqlException ex)
{
throw new ArgumentException(ex.Message);
}
finally { con.Close(); }
}
public static DataSet ExecuteDataSet(string connectionString, CommandType
commandType,string commandText, SqlParameter[] parameters)
{
try
{
SqlConnection con
= newSqlConnection(ConfigurationManager.ConnectionStrings[""].ConnectionString
);
cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandText = commandText;

cmd.CommandType = commandType;
if (parameters == null)
{
da = new SqlDataAdapter(cmd);
ds = new DataSet();
da.Fill(ds);
return ds;
}
else
{
foreach (SqlParameter p in parameters)
{
if ((p.Direction == ParameterDirection.InputOutput) &&
(p.Value ==null))
{
}
//if (p.Value != null)
//{
cmd.Parameters.Add(p);
//}
}
da = new SqlDataAdapter(cmd);

ds = new DataSet();
da.Fill(ds);
return ds;
}
}
catch (SqlException ex)
{
throw new ArgumentException(ex.Message);
}
}
}

================================================================================
============

AdminAddHallLayout.aspx

Admin can create different hall layouts, these layouts are used to any number of halls.

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

namespace BookFilmTickets.Admin
{
public partial class AddHallLayout1 : System.Web.UI.Page
{
int val;
BOL obj;

//Business Object Layer class

//Default Constructor
public AddHallLayout1()
{
obj = new BOL();
}
protected void Page_Load(object sender, EventArgs e)
{
if (Session["Admin"].ToString() == "")
{
Response.Redirect("AdminIndex.aspx");
}
if (!IsPostBack)
{
BindScreens();
}
}
void BindScreens()
{
try
{
ddlScreens.Items.Clear();

ddlScreens.DataSource = obj.GetScreens();
ddlScreens.DataTextField = "ScreenName";
ddlScreens.DataValueField = "ScreenId";
ddlScreens.DataBind();
ddlScreens.Items.Insert(0, "Select");
}
catch (Exception)
{
throw;
}
}

protected void btnSubmit_Click(object sender, EventArgs e)


{

int val = obj.AddScreen(Convert.ToString(txtScreenName.Text));


if (val >= 0)
{
Response.Write("Screen addeed successfully.");
BindScreens();
}

else
Response.Write("Screen you added is already existed.");

}
protected void chkSelectAll_CheckedChanged(object sender, EventArgs e)
{
if (chkSelectAll.Checked)
{
foreach (ListItem lt in chkbSeats.Items)
{
lt.Selected = true;
val += 1;
lt.Text = Convert.ToString(val);
}
}
else
{
foreach (ListItem lt in chkbSeats.Items)
{
lt.Selected = false;

lt.Text = "";
}
chkSelectAll.Checked = false;
}
}

protected void chkbSeats_SelectedIndexChanged(object sender, EventArgs


e)
{
foreach (ListItem lt in chkbSeats.Items)
{
if (lt.Selected)
{
val += 1;
lt.Text = Convert.ToString(val);
}
else { lt.Text = ""; }
}
}

/// <summary>
/// This is for adding screen layout

/// </summary>
protected void btnSubmitScreenLayout_Click(object sender, EventArgs e)
{
//try
//{
string one = chkbSeats.Items.FindByValue("1").Text.ToString();
string two = chkbSeats.Items.FindByValue("2").Text.ToString();
string three =
chkbSeats.Items.FindByValue("3").Text.ToString();
string four =
chkbSeats.Items.FindByValue("4").Text.ToString();
string five =
chkbSeats.Items.FindByValue("5").Text.ToString();
string six = chkbSeats.Items.FindByValue("6").Text.ToString();
string seven =
chkbSeats.Items.FindByValue("7").Text.ToString();
string eight =
chkbSeats.Items.FindByValue("8").Text.ToString();
string nine =
chkbSeats.Items.FindByValue("9").Text.ToString();
string ten =
chkbSeats.Items.FindByValue("10").Text.ToString();
string eleven =
chkbSeats.Items.FindByValue("11").Text.ToString();

string twelve =
chkbSeats.Items.FindByValue("12").Text.ToString();
string thirteen =
chkbSeats.Items.FindByValue("13").Text.ToString();
string fourteen =
chkbSeats.Items.FindByValue("14").Text.ToString();
string fifteen =
chkbSeats.Items.FindByValue("15").Text.ToString();
string sixteen =
chkbSeats.Items.FindByValue("16").Text.ToString();
string seventeen =
chkbSeats.Items.FindByValue("17").Text.ToString();
string eighteen =
chkbSeats.Items.FindByValue("18").Text.ToString();
string nineteen =
chkbSeats.Items.FindByValue("19").Text.ToString();
string twenty =
chkbSeats.Items.FindByValue("20").Text.ToString();
string twentyone =
chkbSeats.Items.FindByValue("21").Text.ToString();
string twentytwo =
chkbSeats.Items.FindByValue("22").Text.ToString();
string twentythree =
chkbSeats.Items.FindByValue("23").Text.ToString();
string twentyfour =
chkbSeats.Items.FindByValue("24").Text.ToString();
string twentyfive =
chkbSeats.Items.FindByValue("25").Text.ToString();

string twentysix =
chkbSeats.Items.FindByValue("26").Text.ToString();
string twentyseven =
chkbSeats.Items.FindByValue("27").Text.ToString();
string twentyeight =
chkbSeats.Items.FindByValue("28").Text.ToString();
string twentynine =
chkbSeats.Items.FindByValue("29").Text.ToString();
string thirty =
chkbSeats.Items.FindByValue("30").Text.ToString();
lblMsg.Text =
obj.AddScreenLayout(Convert.ToString(txtRowName.Text),Convert.ToInt32(ddlScree
ns.SelectedValue), one, two, three, four, five, six, seven, eight, nine, ten,
eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen,
nineteen, twenty, twentyone, twentytwo, twentythree, twentyfour, twentyfive,
twentysix, twentyseven, twentyeight, twentynine, thirty);
if (lblMsg.Text == "Added Successfully.")
{

GetScreenLayout(Convert.ToInt32(ddlScreens.SelectedValue));
}
//}
//catch (Exception)
//{ throw; }
}

/// <summary>
/// Binds the Screen Layout to gvScreenLayout GridView which is
present in Panel3(GroupingText="Screen Layout";)
/// </summary>
/// <param name="screenId"></param>
void GetScreenLayout(int screenId)
{
try
{
gvScreenLayout.DataSource = obj.GetScreenLayout(screenId);
gvScreenLayout.DataBind();
}
catch (ArgumentException ex)
{
Response.Write(ex.Message);
}
}

protected void ddlScreens_SelectedIndexChanged1(object sender, EventAr


gs e)
{
lblMsg.Text = "";

if (ddlScreens.SelectedIndex != 0)
{
gvScreenLayout.Visible = true;
GetScreenLayout(Convert.ToInt32(ddlScreens.SelectedValue));
}
else
{ gvScreenLayout.Visible = false; }
}

public bool MyVisible(string txt)


{
if (txt == "")
{ return false; }
else { return true; }
}

protected void ddlRowType_SelectedIndexChanged(object sender, EventArg


s e)
{
if (ddlRowType.Text == "Empty Line")
{
txtRowName.ReadOnly = true; txtRowName.Text = "Line";

chkbSeats.Visible = false;
chkSelectAll.Visible = false;
lblSeatsPostion.Visible = false;
Label6.Visible = false;
foreach (ListItem lt in chkbSeats.Items)
{
lt.Selected = false;
lt.Text = "";
}
}
else if (ddlRowType.Text == "Row")
{
txtRowName.ReadOnly = false; txtRowName.Text = "";
chkbSeats.Visible = true; chkSelectAll.Checked = false;
chkSelectAll.Visible = true; Label6.Visible = true;
lblSeatsPostion.Visible = true;
}
}

protected void gvScreenLayout_PageIndexChanging(object sender,GridView


PageEventArgs e)
{

gvScreenLayout.PageIndex = e.NewPageIndex;
GetScreenLayout(Convert.ToInt32(ddlScreens.SelectedValue));
}
}
}

UserSelectedMovie.aspx

In this page , page load event all the booked tickets shows red colour chairs and available tickets
are shown in green colour.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Xml.Linq;
using System.Data.SqlClient;
using System.Collections.Generic;

namespace BookFilmTickets
{
public partial class UserSelectedMovie : System.Web.UI.Page
{
string sr;
string ST, cost;
string S1, S2, S3, S4, S5, S6;
int sm;
int fc;
string[] words = new string[6];

int count = 0;
SqlConnection con
= newSqlConnection(ConfigurationManager.ConnectionStrings[""].ConnectionString
);

BOL obj = new BOL();


protected void Page_Load(object sender, EventArgs e)

{
if (!Page.IsPostBack)
{
pan1.Visible = false;
Panel1.Visible = false;
lblcity.Text = Request.QueryString["city"];
lblmovie.Text = Request.QueryString["movie"];
lblthtre.Text = Request.QueryString["thetre"];
lblshowtim.Text = Request.QueryString["date"];

DateTime dt1115AM
= new DateTime(DateTime.UtcNow.Year,DateTime.UtcNow.Month, DateTime.UtcNow.Day
, 11, 15, 0);
if (DateTime.UtcNow < dt1115AM)
{
LinkButton1.ForeColor = System.Drawing.Color.SeaGreen;
LinkButton1.Enabled = true;
}
else
{

LinkButton1.ForeColor = System.Drawing.Color.Red;
LinkButton1.Enabled = false;
}

DateTime dt215AM
= new DateTime(DateTime.UtcNow.Year,DateTime.UtcNow.Month, DateTime.UtcNow.Day
, 14, 15, 0);
if (DateTime.UtcNow < dt215AM)
{
LinkButton2.ForeColor = System.Drawing.Color.SeaGreen;
LinkButton2.Enabled = true;
}
else
{
LinkButton2.ForeColor = System.Drawing.Color.Red;
LinkButton2.Enabled = false;
}

DateTime dt615AM
= new DateTime(DateTime.UtcNow.Year,DateTime.UtcNow.Month, DateTime.UtcNow.Day
, 18, 15, 0);
if (DateTime.UtcNow < dt615AM)
{

LinkButton3.ForeColor = System.Drawing.Color.SeaGreen;
LinkButton3.Enabled = true;
}
else
{
LinkButton3.ForeColor = System.Drawing.Color.Red;
LinkButton3.Enabled = false;
}

DateTime dt915AM
= new DateTime(DateTime.UtcNow.Year,DateTime.UtcNow.Month, DateTime.UtcNow.Day
, 21, 15, 0);
if (DateTime.UtcNow < dt915AM)
{
LinkButton4.ForeColor = System.Drawing.Color.SeaGreen;
LinkButton4.Enabled = true;
}
else
{
LinkButton4.ForeColor = System.Drawing.Color.Red;
LinkButton4.Enabled = false;
}

int scr = 103;


gvScreenLayout.DataSource = obj.GetScreenLayout(scr);
gvScreenLayout.DataBind();

string str1 = "select


T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15

from moviedata where movie

='" + Request.QueryString["movie"] + "' and city = '" +


Request.QueryString["city"] + "' and

theatre = '" +

Request.QueryString["thetre"] + "'";
SqlDataAdapter adp1 = new SqlDataAdapter(str1, con);
DataSet ds1 = new DataSet();
adp1.Fill(ds1);
if (ds1.Tables[0].Rows.Count != 0)
{
ArrayList listp = new ArrayList();

foreach (DataRow drRow in ds1.Tables[0].Rows)


{
foreach (var itm in drRow.ItemArray)
{
listp.Add(itm);
foreach (string k in listp)

{
string category = k.Substring(0, 1);
string seno = k.Remove(0, 1);

for (int i = 0; i < gvScreenLayout.Rows.Count;


i++)
{

HyperLink Hyp =
gvScreenLayout.Rows[i].Cells[0].FindControl("HyperLink1") as HyperLink;

string cat1 = Hyp.Text;

if (category == cat1)
{
string ids1 = "ImageButton" +
seno.ToString();
ImageButton imgThumb = (ImageButton)
(gvScreenLayout.Rows[i].FindControl(ids1));
imgThumb.ImageUrl
= "~/Images/chair_green.jpg";

}
}
}
}
}
string str = "select Seat1,Seat2,Seat3,Seat4,Seat5,Seat6 from
TransactionMovie where MovieName ='" + Request.QueryString["movie"] + "' and
City = '" + Request.QueryString["city"] + "' and

TheatreName = '" +

Request.QueryString["thetre"] +"'";
SqlDataAdapter adp = new SqlDataAdapter(str, con);
DataSet ds = new DataSet();
adp.Fill(ds);
if (ds.Tables[0].Rows.Count != 0)
{
ArrayList listp = new ArrayList();

foreach (DataRow drRow in ds.Tables[0].Rows)


{
foreach (var itm in drRow.ItemArray)
{
listp.Add(itm);

foreach (string k in listp)


{
string category = k.Substring(0, 1);
string seno = k.Remove(0, 1);

for (int i = 0; i < gvScreenLayout.Rows.Count;


i++)
{

HyperLink Hyp =
gvScreenLayout.Rows[i].Cells[0].FindControl("HyperLink1") as HyperLink;

string cat1 = Hyp.Text;

if (category == cat1)
{
string ids1 = "ImageButton" +
seno.ToString();
ImageButton imgThumb = (ImageButton)
(gvScreenLayout.Rows[i].FindControl(ids1));
imgThumb.ImageUrl
= "~/Images/chair_red.jpg";

imgThumb.Enabled = false;
}

}
}
}
}
}

for (int i = 0; i < gvScreenLayout.Rows.Count; i++)


{
for (int j = 1; j < gvScreenLayout.Columns.Count; j++)
{
string idSlv = "ImageButton" + j.ToString();
ImageButton imgbtnSlv =
gvScreenLayout.Rows[i].Cells[j].FindControl(idSlv) as ImageButton;
if (imgbtnSlv.ImageUrl == "~/images/chair_silver.jpg")
{
imgbtnSlv.Enabled = false;
}

}
}

MultiView1.ActiveViewIndex = 0;
}

protected void Button3_Click1(object sender, EventArgs e)


{
pan1.Visible = true;
}

public bool MyVisible(string txt)


{
if (txt == "")
{ return false; }
else { return true; }
}

protected void LinkButton1_Click(object sender, EventArgs e)

{
Panel1.Visible = true;
lbltime.Text = "11:15 AM";
}

protected void LinkButton2_Click(object sender, EventArgs e)


{
Panel1.Visible = true;
lbltime.Text = "2:15 PM";
}

protected void LinkButton3_Click(object sender, EventArgs e)


{
Panel1.Visible = true;
lbltime.Text = "6:15 PM";
}

protected void LinkButton4_Click(object sender, EventArgs e)


{

Panel1.Visible = true;

lbltime.Text = "9:15 PM";


}

protected void ImageButton1_Click(object sender, ImageClickEventArgs e


)
{
string un = Convert.ToString(Session["username"]);
if (un.ToString() != "")
{

words = Label2.Text.Split(',');
int ln = words.Length - 1;
if (ln == 1)
{
S1 = words[0].ToString();
S2 = "0"; S3 = "0"; S4 = "0"; S5 = "0"; S6 = "0";

}
if (ln == 2)
{
S1 = words[0].ToString();
S2 = words[1].ToString();

S3 = "0"; S4 = "0"; S5 = "0"; S6 = "0";

}
if (ln == 3)
{
S1 = words[0].ToString();
S2 = words[1].ToString();
S3 = words[2].ToString();
S4 = "0"; S5 = "0"; S6 = "0";

}
if (ln == 4)
{
S1 = words[0].ToString();
S2 = words[1].ToString();
S3 = words[2].ToString();
S4 = words[3].ToString();
S5 = "0"; S6 = "0";

}
if (ln == 5)

{
S1 = words[0].ToString();
S2 = words[1].ToString();
S3 = words[2].ToString();
S4 = words[3].ToString();
S5 = words[4].ToString();
S6 = "0";

}
if (ln == 6)
{
S1 = words[0].ToString();
S2 = words[1].ToString();
S3 = words[2].ToString();
S4 = words[3].ToString();
S5 = words[4].ToString();
S6 = words[5].ToString();

string us = Convert.ToString(Session["username"]);
string trans = "INSERT INTO TransactionMovie(UserId,
MovieName, City , Date ,TheatreName,Showtime,Seat1,Seat2 ,Seat3
,Seat4,Seat5,Seat6,TotalCost,Flag,TransTime) VALUES ('" + us + "','" +
lblmovie.Text + "','" + lblcity.Text + "','" + lblshowtim.Text +"','" +
lblthtre.Text + "','" + lbltime.Text + "','" + S1 + "' , '" + S2 + "' ,'" + S3
+"','" + S4 + "','" + S5 + "','" + S6 + "','" + lblcost.Text + "', 'T',
'" +DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") + "')";

SqlCommand cmd3 = new SqlCommand(trans, con);


cmd3.CommandType = CommandType.Text;
con.Open();
cmd3.ExecuteNonQuery();
con.Close();

Response.Redirect("http://bookfilmtickets.com/payment/pay.aspx");

ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
"Ticket booking completed Succesfully ", "alert('
Succesfully')", true);

Ticket booking completed

// Response.Redirect("index.aspx");
}
else

{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(),
"Please Login to Book ticket ", "alert(' Please Login to Book
ticket')", true);
}
}

protected void gvScreenLayout_RowCommand(object sender, GridViewComman


dEventArgse)
{
if (e.CommandName == "ib1" || e.CommandName == "ib2" ||
e.CommandName == "ib3"|| e.CommandName == "ib4" || e.CommandName == "ib5" ||
e.CommandName == "ib6" || e.CommandName == "ib7" || e.CommandName == "ib8" ||
e.CommandName == "ib9" || e.CommandName == "ib10" || e.CommandName
== "ib11" || e.CommandName == "ib12" || e.CommandName == "ib13" ||
e.CommandName == "ib14" || e.CommandName == "ib15" || e.CommandName
== "ib16" || e.CommandName == "ib17" || e.CommandName == "ib18" ||
e.CommandName == "ib19" || e.CommandName == "ib20" || e.CommandName
== "ib21" || e.CommandName == "ib22" || e.CommandName == "ib23" ||
e.CommandName == "ib24" || e.CommandName == "ib25" || e.CommandName
== "ib26" || e.CommandName == "ib27" || e.CommandName == "ib28" ||
e.CommandName == "ib29" || e.CommandName == "ib30")
{

GridViewRow gvr = (GridViewRow)


(((ImageButton)e.CommandSource).NamingContainer);
HyperLink Hyp = gvr.FindControl("HyperLink1") as HyperLink;
int ind = gvr.RowIndex;

string cat = Hyp.Text;


int sno = Convert.ToInt32(e.CommandArgument);
string seat = cat + sno.ToString();
string ids = "ImageButton" + sno.ToString();
ImageButton imgThumb = (ImageButton)
(gvScreenLayout.Rows[ind].FindControl(ids));
if (imgThumb.ImageUrl == "~/Images/chair_green.jpg" && fc <=
6)
{
imgThumb.ImageUrl = "~/Images/chair_orange.jpg";

}
else
{
imgThumb.ImageUrl = "~/Images/chair_green.jpg";
}
for (int i = 0; i < gvScreenLayout.Rows.Count; i++)
{
for (int j = 1; j < gvScreenLayout.Columns.Count; j++)
{
string idsf = "ImageButton" + j.ToString();
ImageButton imgbtn =
gvScreenLayout.Rows[i].Cells[j].FindControl(idsf) as ImageButton;

if ("~/Images/chair_orange.jpg" == imgbtn.ImageUrl)
{
count = count + 1;
if (count <= 6)
{
HyperLink Hyp4 =
gvScreenLayout.Rows[i].FindControl("HyperLink1") asHyperLink;

ST = Hyp4.Text +
(imgbtn.CommandArgument).ToString();
sr += ST + ",";
Label2.Text = sr.ToString();
string str4 = "select
Range1,Range2,Range3,Range4,Range5,Range6,Range7,Range8,Range9,Range10,Range11
,Range12,Range13,Range14,Range15,Range16,Range17 from moviedata where movie
='" + Request.QueryString["movie"] + "' and city = '" +
Request.QueryString["city"] + "' and

theatre = '" +

Request.QueryString["thetre"] + "'";
SqlDataAdapter adp4 = new SqlDataAdapter(str4,
con);
DataSet ds4 = new DataSet();
adp4.Fill(ds4);
if (ds4.Tables[0].Rows.Count != 0)
{

//CATEGORY A
string CS1=ds4.Tables[0].Rows[0]
["Range1"].ToString();
string CostCat1 = CS1.Substring(0, 1);
if (CostCat1 == Hyp4.Text)
{
sm += 55;
}
//CATEGORY B
string CS2 = ds4.Tables[0].Rows[0]
["Range2"].ToString();
string CostCat2 = CS2.Substring(0, 1);
if (CostCat2 == Hyp4.Text)
{
sm += 55;
}
//CATEGORY C
string CS3 = ds4.Tables[0].Rows[0]
["Range3"].ToString();
string CostCat3 = CS3.Substring(0, 1);
if (CostCat3 == Hyp4.Text)
{
sm += 55;

}
//CATEGORY D
string CS4 = ds4.Tables[0].Rows[0]
["Range4"].ToString();
string CostCat4 = CS4.Substring(0, 1);
if (CostCat4 == Hyp4.Text)
{
sm += 55;
}
//CATEGORY E
string CS5 = ds4.Tables[0].Rows[0]
["Range5"].ToString();
string CostCat5 = CS5.Substring(0, 1);
if (CostCat5 == Hyp4.Text)
{
sm += 55;
}
//CATEGORY F
string CS6 = ds4.Tables[0].Rows[0]
["Range6"].ToString();
string CostCat6 = CS6.Substring(0, 1);
if (CostCat6 == Hyp4.Text)
{

sm += 45;
}
//CATEGORY G
string CS7 = ds4.Tables[0].Rows[0]
["Range7"].ToString();
string CostCat7 = CS7.Substring(0, 1);
if (CostCat7 == Hyp4.Text)
{
sm += 45;
}
//CATEGORY H
string CS8 = ds4.Tables[0].Rows[0]
["Range8"].ToString();
string CostCat8 = CS8.Substring(0, 1);
if (CostCat8 == Hyp4.Text)
{
sm += 45;
}
//CATEGORY I
string CS9 = ds4.Tables[0].Rows[0]
["Range9"].ToString();
string CostCat9 = CS9.Substring(0, 1);
if (CostCat9 == Hyp4.Text)

{
sm += 45;
}
//CATEGORY J
string CS10 = ds4.Tables[0].Rows[0]
["Range10"].ToString();
string CostCat10 = CS10.Substring(0, 1);
if (CostCat10 == Hyp4.Text)
{
sm += 45;
}
//CATEGORY K
string CS11 = ds4.Tables[0].Rows[0]
["Range11"].ToString();
string CostCat11 = CS11.Substring(0, 1);
if (CostCat11 == Hyp4.Text)
{
sm += 45;
}
//CATEGORY L
string CS12 = ds4.Tables[0].Rows[0]
["Range12"].ToString();
string CostCat12 = CS12.Substring(0, 1);

if (CostCat12 == Hyp4.Text)
{
sm += 45;
}
//CATEGORY M
string CS13 = ds4.Tables[0].Rows[0]
["Range13"].ToString();
string CostCat13 = CS13.Substring(0, 1);
if (CostCat13 == Hyp4.Text)
{
sm += 45;
}
//CATEGORY N
string CS14 = ds4.Tables[0].Rows[0]
["Range14"].ToString();
string CostCat14 = CS14.Substring(0, 1);
if (CostCat14 == Hyp4.Text)
{
sm += 20;
}
//CATEGORY O
string CS15 = ds4.Tables[0].Rows[0]
["Range15"].ToString();

string CostCat15 = CS15.Substring(0, 1);


if (CostCat15 == Hyp4.Text)
{
sm += 20;
}
//CATEGORY P
string CS16 = ds4.Tables[0].Rows[0]
["Range16"].ToString();
string CostCat16 = CS16.Substring(0, 1);
if (CostCat16 == Hyp4.Text)
{
sm += 20;
}
//CATEGORY Q
string CS17 = ds4.Tables[0].Rows[0]
["Range17"].ToString();
string CostCat17 = CS17.Substring(0, 1);
if (CostCat17 == Hyp4.Text)
{
sm += 20;
}
if (fc == 6)

{
fc = count + 1;
}
}
}
else
{
ScriptManager.RegisterClientScriptBlock(this,t
his.GetType(), "No

Code", "alert('Cannot Book more than 6 tickets')", true);


//gvScreenLayout.Enabled = false;
imgThumb.ImageUrl

= "~/Images/chair_green.jpg";
fc = count + 1;
}
}

}
}

if (sr != null)
{
Label2.Text = sr.ToString();
}
if (sm != 0)
{
lblcost.Text = sm.ToString();
}

protected void gvScreenLayout_SelectedIndexChanged(object sender, Even


tArgs e)
{

protected void btnsearch_Click(object sender, EventArgs e)


{
if (Label2.Text != "" && Session["username"].ToString() != "")

{
string un = Convert.ToString(Session["username"]);
string nameproof ="select * from UserRegistration where UEmail
= '"+ un +"'";
SqlDataAdapter ad = new SqlDataAdapter(nameproof,con);
DataSet ds = new DataSet();
ad.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
string uname = ds.Tables[0].Rows[0]["UName"].ToString();
string proof1 = ds.Tables[0].Rows[0]
["UIdproof"].ToString();
string proof2 = ds.Tables[0].Rows[0]
["UIdnumber"].ToString();
string proof = proof1 + proof2;
Response.Redirect("~/PrintTicket.aspx?name=" +uname +"&
theatre=" + lblthtre.Text + " &showtime=" + LinkButton2.Text + " & seats=" +
Label2.Text + " &movie="+ lblmovie.Text + " &amount =" + lblcost.Text + "
prooof=" + proof);

}
}
}

&

You might also like