Click here to Skip to main content
15,885,941 members

What is the logic for lstmovies.selected change event?

Pankaj hyderabad asked:

Open original thread
<%@ 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();

        }


    }
}
Tags: ASP.NET

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900