Click here to Skip to main content
13,258,238 members (53,141 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MoviTicketDemo.aspx.cs" Inherits="OnlineMoviesticketBooking.MoviTicketDemo" %>
 
<!DOCTYPE html>
 

 
    <title>
    
        .auto-style1 {
            width: 98%;
        }
        .auto-style2 {
            font-size: x-large;
            background-color: #00FF99;
        }
        .auto-style3 {
            height: 91px;
            background-color: #00FF99;
            text-align: center;
        }
        .auto-style4 {
            height: 46px;
            text-align: center;
            color: #800000;
            font-size: xx-large;
            background-color: #00FF99;
        }
        .auto-style5 {
            font-size: x-large;
            height: 39px;
            text-align: center;
            background-color: #00FF99;
        }
        .auto-style8 {
            font-size: small;
        }
        .auto-style9 {
            font-size: x-large;
            height: 331px;
            text-align: center;
            background-color: #00FF99;
        }
        .auto-style10 {
            font-size: x-large;
            height: 331px;
            text-align: left;
            background-color: #00FF99;
        }
        .auto-style12 {
            width: 100%;
            height: 326px;
        }
        .auto-style13 {
            height: 273px;
            text-align: center;
        }
        .auto-style14 {
            text-align: center;
        }
        .auto-style15 {
            font-size: xx-large;
        }
        .auto-style16 {
            margin-top: 0px;
        }
        .auto-style17 {
            width: 882px;
            height: 75px;
            float: left;
            margin-bottom: 0px;
        }
        .auto-style18 {
            width: 100%;
        }
        .auto-style19 {
            text-align: left;
        }
    
 

    
    <div>
    
    </div>
        
            <table class="auto-style1"><tbody><tr>                <td class="auto-style3" colspan="6">                    </td>            </tr>            <tr>                <td class="auto-style4" colspan="6">ONLINE MOVIES TICKET BOOKING</td>            </tr>            <tr>                <td class="auto-style5">                    <asp:DropDownList ID="lstCity" runat="server" AutoPostBack="True" CssClass="auto-style8" OnSelectedIndexChanged="lstCity_SelectedIndexChanged" width="126px">
                    
                </td>                <td class="auto-style5">                    <asp:DropDownList ID="lstCinema" runat="server" AutoPostBack="True" CssClass="auto-style8" height="22px" OnSelectedIndexChanged="lstCinema_SelectedIndexChanged" width="126px">
                    
                </td>                <td class="auto-style5">                    <asp:DropDownList ID="lstMovie" runat="server" AutoPostBack="True" CssClass="auto-style8" height="22px" OnSelectedIndexChanged="lstMovies_SelectedIndexChanged" width="126px">
                    
                </td>                <td class="auto-style5">                    <asp:DropDownList ID="lstTimings" runat="server" AutoPostBack="True" CssClass="auto-style8" height="22px" OnSelectedIndexChanged="lstTimings_SelectedIndexChanged" width="126px">
                    
                </td>                <td class="auto-style5">                    <asp:DropDownList ID="lstSeats" runat="server" AutoPostBack="True" CssClass="auto-style8" height="22px" OnSelectedIndexChanged="lstSeats_SelectedIndexChanged" width="126px">
                    
                </td>                <td class="auto-style5">                    <asp:DropDownList ID="lstClass" runat="server" CssClass="auto-style8" height="22px" width="126px">
                    
                </td>            </tr>            <tr>                <td class="auto-style10" colspan="3">                    
                        <table class="auto-style12"><tbody><tr>                            <td class="auto-style13">                                <asp:Image ID="imgMovi" runat="server" CssClass="auto-style16" Height="254px" Width="371px" />
                            </td>                        </tr>                        <tr>                            <td class="auto-style14">
                                <asp:ImageButton ID="btnBook" runat="server" CssClass="auto-style15" Height="59px" ImageUrl="~/Images/book.jpg" OnClick="btnBook_Click" Width="275px" />
                                </td>                        </tr>                    </tbody></table>
                </td>                <td class="auto-style9" colspan="3">                    <asp:Panel ID="pnlDetails" runat="server" Height="314px">
                        
                            <table class="auto-style18"><tbody><tr>                                <td colspan="2">Invoice</td>                            </tr>                            <tr>                                <td class="auto-style19"> City :        </td>                                <td class="auto-style19">                                    <asp:Label ID="lblCity" runat="server">
                                </td>                            </tr>                            <tr>                                <td class="auto-style19"> Cinema :       </td>                                <td class="auto-style19">                                    <asp:Label ID="lblCinema" runat="server">
                                </td>                            </tr>                            <tr>                                <td class="auto-style19"> Movie Name :</td>                                <td class="auto-style19">                                    <asp:Label ID="lblMovie" runat="server">
                                </td>                            </tr>                            <tr>                                <td class="auto-style19"> Show Time :</td>                                <td class="auto-style19">                                    <asp:Label ID="lblTime" runat="server">
                                </td>                            </tr>                            <tr>                                <td class="auto-style19"> Number of Seats :</td>                                <td class="auto-style19">                                    <asp:Label ID="lblSeats" runat="server">
                                </td>                            </tr>                            <tr>                                <td class="auto-style19">Tptal Amount :</td>                                <td class="auto-style19">                                    <asp:Label ID="lblTotal" runat="server">
                                </td>                            </tr>                        </tbody></table>
                    
                </td>            </tr>            <tr>                <td class="auto-style2" colspan="6"> </td>            </tr>        </tbody></table>
    
 

 
What I have tried:
 
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace OnlineMoviesticketBooking
{
    public partial class MoviTicketDemo : System.Web.UI.Page
    {
        List<string> city = new List<string>()
        {
            "Select a City",
            "Hyderabad",
            "Delhi"
        };
        List<string> Hyderabadcinema = new List<string>()
        {
            "Select a Cinema",
            "HI-Tech Cinema",
            "Satyam Theater"
        };
 
        List<string> Delhicinema = new List<string>()
        {
            "Select a Cinema",
            "PVR NCR",
            "Milan Cinema"
        };
        List<listitem> hiTechCinema = new List<listitem>()
        {
            new ListItem {Text="Select a Movie ",Value="-1" },
            new ListItem {Text="Jack & Jones",Value="200" },
           new ListItem {Text="Fast & Furious8",Value="200" }
        };
        List<listitem> sathyamTheater = new List<listitem>()
        {
            new ListItem {Text="Select a Movie ",Value="-1" },
            new ListItem {Text="HolyDay",Value="150" },
           new ListItem {Text="Jusney",Value="150" }
        };
        List<listitem> pvrNcr = new List<listitem>()
        {
            new ListItem {Text="Select a Movie ",Value="-1" },
            new ListItem {Text="GolMaal Again",Value="200" },
           new ListItem {Text="Avatar",Value="200" }
        };
        List<listitem> milanCinema = new List<listitem>()
        {
            new ListItem {Text="Select a Movie ",Value="-1" },
            new ListItem {Text="Jolly LLB 2",Value="180" },
           new ListItem {Text="Bahubali-2",Value="180" }
        };
        List<string> tymhitechmovi1 = new List<string>()
        {
            "Show Timing",
            "9:45AM",
            "5:00PM"
        };
        List<string> tymhitechmovi2 = new List<string>()
        {
            "Show Timing",
            "11:10AM",
            "6:45PM"
        };
        List<string> tymsatyammovi1 = new List<string>()
        {
            "Show Timing",
            "8:00AM",
            "10:45PM"
        };
        List<string> tymsatyammovi2 = new List<string>()
        {
            "Show Timing",
            "10:30AM",
            "2:00PM"
        };
        List<string> tympvrNcrmovi1 = new List<string>()
        {
            "Show Timing",
            "9:15AM",
            "6:45PM"
        };
        List<string> tympvrNcrmovi2 = new List<string>()
        {
            "Show Timing",
            "12:00PM",
            "6:10PM"
        };
        List<string> tymmilanmovi1 = new List<string>()
        {
            "Show Timing",
            "10:10AM",
            "8:50PM"
        };
        List<string> tymmilanmovi2 = new List<string>()
        {
            "Show Timing",
            "9:00AM",
            "11:30PM"
        };
        List<string> seats = new List<string>()
        {
            "Select Seat","1","2","3","4","5"
        };
        List<listitem> Mclass = new List<listitem>()
        {new ListItem {Text ="Select a class", Value="-1"  },
            new ListItem {Text="Normal 150/-",Value="150" },
            new ListItem {Text="Gold 200/-",Value="200" }
 
        };
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                foreach (var item in city)
                {
                    lstCity.Items.Add(item);
                }
            }
            pnlDetails.Visible = false;
        }
 
        protected void lstCity_SelectedIndexChanged(object sender, EventArgs e)
        {
            lstCinema.Items.Clear();
            switch (lstCity.SelectedIndex)
            {
 
                case 1:
 
                    foreach (var item in Hyderabadcinema)
                    {
 
                        lstCinema.Items.Add(item);
                    }
                    break;
                case 2:
 
                    foreach (var item in Delhicinema)
                    {
 
                        lstCinema.Items.Add(item);
                    }
                    break;
            }
        }
 
        protected void lstCinema_SelectedIndexChanged(object sender, EventArgs e)
        {
            lstMovie.Items.Clear();
            if (lstCity.SelectedIndex == 1||lstCity.SelectedIndex==2)
            {
                switch (lstCinema.SelectedItem.Text)
                {
                    case "HI-Tech Cinema":
                        foreach (var item in hiTechCinema)
                        {
                            lstMovie.Items.Add(item);
                        }
                        break;
                    case "Satyam Theater":
                        foreach (var item in sathyamTheater)
                        {
                            lstMovie.Items.Add(item);
                        }
                        break;
                    //}
                    //}
                    //if (lstCity.SelectedIndex == 2)
                    //{
                    //switch (lstCinema.SelectedIndex)
                    //{
                    case "PVR NCR":
                        foreach (var item in pvrNcr)
                        {
                            lstMovie.Items.Add(item);
                        }
                        break;
                    case "Milan Cinema":
                        foreach (var item in milanCinema)
                        {
                            lstMovie.Items.Add(item);
                        }
                        break;
                }
            }
        }
        protected void lstMovies_SelectedIndexChanged(object sender, EventArgs e)
        {
            lstTimings.Items.Clear();
            if (lstCinema.SelectedIndex == 1||lstCinema.SelectedIndex==2)
            {
                switch (lstMovie.SelectedItem.Text)
                {
                    case "Jack & Jones":
                        imgMovi.ImageUrl = "~/Images/jack and jones.jpg";
                        foreach (var item in tymhitechmovi1)
                        {
                            lstTimings.Items.Add(item);
 
                        }
                        break;
                    case "Fast & Furious8":
                        imgMovi.ImageUrl = "~/Images/Fast and Furious 8.jpg";
                        foreach (var item in tymhitechmovi2)
                        {
                            lstTimings.Items.Add(item);
                        }
                        break;
                    case "HolyDay":
                        imgMovi.ImageUrl = "~/Images/holyday.jpg";
                        foreach (var item in tymsatyammovi1)
                        {
                            lstTimings.Items.Add(item);
                        }
                        break;
                    case "Jusney":
                        imgMovi.ImageUrl = "~/Images/jusney 2.jpg";
                        foreach (var item in tymsatyammovi2)
                        {
                            lstTimings.Items.Add(item);
                        }
                        break;
                    //default:
                    //    imgMovi.ImageUrl = "~/Images/default1.jpg";
                    //    break;
                    //}
                    //}
 
                    //if (lstCity.SelectedIndex == 2)
                    //{
 
                    //    switch (lstMovie.SelectedItem.Text)
                    //    {
                    case "GolMaal Again":
                        imgMovi.ImageUrl = "~/Images/golmal.png";
                        foreach (var item in tympvrNcrmovi1)
                        {
                            lstTimings.Items.Add(item);
                        }
 
                        break;
                    case "Avatar":
                        imgMovi.ImageUrl = "~/Images/Avatar 2.jpg";
                        foreach (var item in tympvrNcrmovi2)
                        {
                            lstTimings.Items.Add(item);
                        }
                        break;
 
                    case "Jolly LLB 2":
                        imgMovi.ImageUrl = "~/Images/jolly llb 2.jpg";
                        foreach (var item in tymmilanmovi1)
                        {
                            lstTimings.Items.Add(item);
                        }
                        break;
                    case "Bahubali-2":
                        imgMovi.ImageUrl = "~/Images/bahubali.jpg";
                        foreach (var item in tymmilanmovi2)
                        {
                            lstTimings.Items.Add(item);
                        }
                        break;
                    default:
                        imgMovi.ImageUrl = "~/Images/default1.jpg";
                        break;
 
                }
            }
        }
 
        protected void lstTimings_SelectedIndexChanged(object sender, EventArgs e)
        {
            lstSeats.Items.Clear();
            foreach (var item in seats)
            {
                lstSeats.Items.Add(item);
            }
        }
        protected void lstSeats_SelectedIndexChanged(object sender, EventArgs e)
        {
            lstClass.Items.Clear();
 
            foreach (var item in Mclass)
            {
                lstClass.Items.Add(item);
            }
        }
        int bill;
        protected void btnBook_Click(object sender, ImageClickEventArgs e)
        {
            int sea = Convert.ToInt32(lstSeats.SelectedItem.Text);
            pnlDetails.Visible = true;
            lblCity.Text = lstCity.SelectedItem.Text;
            lblMovie.Text = lstMovie.SelectedItem.Text;
            lblTime.Text = lstTimings.SelectedItem.Text;
            lblSeats.Text = lstSeats.SelectedItem.Text;
 
            bill = bill + (Convert.ToInt32(lstClass.SelectedValue)) * sea;
            lblCinema.Text = lstCinema.SelectedItem.Text;
            lblTotal.Text = bill.ToString();
 
        }
 

    }
}
Posted 28-Oct-17 11:16am
Updated 12-Nov-17 23:01pm
Comments
Pankaj hyderabad 28-Oct-17 16:20pm
   
my requirement is if user select 2nd moive it will give 2nd movie detail. but according to my logic if i selected 2nd movi then it gives only first movi value??
where my logic is wrong ? anybody can tell me?
Pankaj hyderabad 28-Oct-17 16:28pm
   
plz give me answer i have tried too much..
Laxmidhar sahoo 13-Nov-17 7:57am
   
Hide Expand Copy Code
protected void lstCinema_SelectedIndexChanged(object sender, EventArgs e)
{
lstMovie.Items.Clear();
if (lstCity.SelectedIndex == 1 || lstCity.SelectedIndex == 2)
{
ListItem[] items = new ListItem[3];

switch (lstCinema.SelectedItem.Text)
{
case "HI-Tech Cinema":
int ii = 0;
foreach (var item in hiTechCinema)
{

items[ii] = new ListItem(item.Text, item.Text);

ii++;
}
break;
case "Satyam Theater":
int i = 0;
foreach (var item in sathyamTheater)
{

items[i] = new ListItem(item.Text, item.Text);

i++;

}
break;
//}
//}
//if (lstCity.SelectedIndex == 2)
//{
//switch (lstCinema.SelectedIndex)
//{
case "PVR NCR":
int pi = 0;
foreach (var item in pvrNcr)
{
items[pi] = new ListItem(item.Text, item.Text);

pi++;
}
break;
case "Milan Cinema":
int mi = 0;
foreach (var item in milanCinema)
{
items[mi] = new ListItem(item.Text, item.Text);

mi++;
}
break;
}
lstMovie.Items.AddRange(items);
lstMovie.DataBind();
}
}
Pankaj hyderabad 29-Oct-17 3:38am
   
anybody is here..
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

your switch case is not executed.Because the condition is not satisfy
due to your page is refreshed
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

The solved code Given billow for lstCinema selected index chandged event

 protected void lstCinema_SelectedIndexChanged(object sender, EventArgs e)
    {
        lstMovie.Items.Clear();
        if (lstCity.SelectedIndex == 1 || lstCity.SelectedIndex == 2)
        {
            ListItem[] items = new ListItem[3];
           
            switch (lstCinema.SelectedItem.Text)
            {
                case "HI-Tech Cinema":
                    int ii = 0;
                    foreach (var item in hiTechCinema)
                    {
 
                        items[ii] = new ListItem(item.Text, item.Text);
 
                        ii++;
                    }
                    break;
                case "Satyam Theater":
                    int i = 0;
                    foreach (var item in sathyamTheater)
                    {
 
                        items[i] = new ListItem(item.Text, item.Text);
 
                        i++;
                     
                    }
                    break;
                //}
                //}
                //if (lstCity.SelectedIndex == 2)
                //{
                //switch (lstCinema.SelectedIndex)
                //{
                case "PVR NCR":
                    int pi = 0;
                    foreach (var item in pvrNcr)
                    {
                        items[pi] = new ListItem(item.Text, item.Text);
 
                        pi++;
                    }
                    break;
                case "Milan Cinema":
                    int mi = 0;
                    foreach (var item in milanCinema)
                    {
                        items[mi] = new ListItem(item.Text, item.Text);
 
                        mi++;
                    }
                    break;
            }
            lstMovie.Items.AddRange(items);
            lstMovie.DataBind();
        }
    }
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web01 | 2.8.171114.1 | Last Updated 13 Nov 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100