Hello:),
I am returning to a theatre ticket booking project after about three months and trying to get my head around how to show the prices in a list box (lstTotal).
I have three radio buttons three for three ticket types.
Adult Full
Concession
Friend
When one of these is selected and a seat button is clicked on the seating plan it turns the colour of the corresponding ticket type.
I want to be able to do this for a number of tickets in turn, for them to show in the lstTotal list box and then add up the running total. To do this I know I need to loop through the data base for the correct pricing which depends on the theatre and event but haven’t got a clue which is the best way to go about it … so any pointers will be gratefully received. Thank you.
Below is the code for the booking system and the database for events.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;
using BucksNetPaymentModule;
using NWTG_TicketBookingSystem;//Lots of Using statements to call the various classes

//this is the main test form that should bring the other forms together

namespace NWTG_TicketBookingSystem
{
    public partial class MainTest : Form
    {
        Customer oCust;//declare variables
        SortedList custList = new SortedList();
        ScheduledEvent currentEvent;
        ScheduledEvent eventPrice;
        SortedList allEvents = new SortedList(); //the event sorted list
        private DataSet dsTickets;
        Ticket oTicket = new Ticket();

        int llandudnoAvailableSeats = 0;
        int denbighAvailableSeats = 0;
        int CaernarfonAvailableSeats = 0;
        
        public MainTest()
        {
            InitializeComponent();
        }

        //TEST FORM BUTTONS

        private void btnCustomerTest_Click(object sender, EventArgs e)
        {
           
            FrmTestCustomer mynewform = new FrmTestCustomer(); //declared new form 
            mynewform.Show();
        }

        private void btnBookingTest_Click(object sender, EventArgs e)
        {
            Form mynewform = new BookingsTestForm(); //declared new form 
            mynewform.Show();
        }

        private void btnTicketTest_Click(object sender, EventArgs e)
        {
            FrmTestTicket mynewform = new FrmTestTicket(); //declared new form 
            mynewform.Show();
        }

        private void btnScheduledEvent_Click(object sender, EventArgs e)
        {
            FrmTestScheduledEvent mynewform = new FrmTestScheduledEvent(); //declared new form 
            mynewform.Show();
        }


        private void btnSearchPostcode_Click(object sender, EventArgs e)//ListCustomerByPostcode
        {     
            Customer Cust = new Customer();//creates or instantiate customer object
            custList = Cust.ListCustomerByPostcode(txtECenterPostcode.Text);//custList should have customer data
            //uses the sql statement and method in the class
           
            if (txtECenterPostcode.Text == string.Empty)//If textbox is empty
            {
                PostcodeEP.SetError(txtECenterPostcode, "Please enter a Postcode");//error prompt
            }
            else
            {
                PostcodeEP.Clear();//clears if nothing returned
            }

            if (custList.Count == 0)//If no returns on serch
            {
                lstCustomerSelect.Items.Add("No records available");//this is actually bypassed
            }
            else
            {
                lstCustomerSelect.Items.Clear();//clear list box

                foreach (DictionaryEntry cust in custList) //loop through list one at a time
                {
                    lstCustomerSelect.Items.Add(cust.Value); // adds to list those that match SQL statement in the  class- hopefully         
                }
                lstCustomerSelect.SelectedIndex = 0; // selects the first name in the list box
            }  
        }



        private void lstCustomerSelect_SelectedIndexChanged(object sender, EventArgs e)//select for customer details
        {
            oCust = new Customer(); //(lstCustomerSelect.Items[0].ToString() == "No records"); return; // error code

            string selectedCust = custList.GetKey(lstCustomerSelect.SelectedIndex).ToString();
            oCust.GetCustomersByCustomerNumber(selectedCust);

            ECNameTextBox.Text = oCust.CustomerName; //oCust. = click oCust then options come up to do things with very nice
            txtFullPostCode.Text = oCust.PostCode;//show selected customer object postcode
            txtECustomerNumber.Text = oCust.CustomerNumber;//show selected customer's number

            if (oCust.FriendMarker == "Y")// if the customer object is a friend
            {
                txtFriend.Text = " Friend";//show friend text in the box
            }
            else
            {
                txtFriend.Text = "";//if not don't show friend in the box
            } 
        }


        private void tpDateFrom_ValueChanged(object sender, EventArgs e)//List events by date
        {
            ScheduledEvent Event = new ScheduledEvent();//instantate Event
            currentEvent = new ScheduledEvent();
            allEvents = currentEvent.ListEventsByDateOfEvent(tpDateFrom.Value);

            foreach (DictionaryEntry anEvent in allEvents) //loop through list one at a time
            {
                lstEvents.Items.Add(anEvent.Value); // adds to list - hopefully
            }
        }



        private void UpdateTickets(int BookingReference)
        {
          //Adding BookingReference to DataSet Rows for sold tickets

            foreach (DataRow drTickets in dsTickets.Tables[0].Rows)//loop through Tickets Dataset
            {
                if (drTickets.RowState == DataRowState.Modified)// if modified - finds sold seats
                {
                    drTickets["BookingReference"] = BookingReference;//add Booking Reference to seats sold
                }

            }

            //Then update the tickets from DataSet
            Ticket oTicket = new Ticket();//take this created ticket object
            oTicket.UpdateTicketsToSold(dsTickets);// and call UpdateTicketsToSold 
                                                   //method for the ticket class and 
                                                   //pass in the updated Dataset

        }



        private void lstTotal_SelectedIndexChanged(object sender, EventArgs e)
        {
            ScheduledEvent eventPrice = new ScheduledEvent(); //Create price object to show in list total

       
        }



        private void lstEvents_SelectedIndexChanged(object sender, EventArgs e)//select event and show info
        {                                                                      //GetEventBy ID
            ScheduledEvent showEvent = new ScheduledEvent();//create show event
            
            if (allEvents.Count > 0)//if there are any events or more than none
            {
                string selectedEvent = allEvents.GetKey(lstEvents.SelectedIndex).ToString();//Find the selectedEvent int from ID
                showEvent.GetEventByID(int.Parse(selectedEvent));//find by ID
                dsTickets = oTicket.GetAllTicketsByScheduledEvent(int.Parse(selectedEvent));//Get the tickets and represent them as seats
                seatBox.Controls.Clear();//clear seat Box panel first

                if (showEvent.Confirmed == "Y")// if one of the theatres
                {

                    if (showEvent.Location == "Llandudno")
                    {
                        Seating(dsTickets);//generate seating from the tickets data set
                        lblNWTG.Visible = false;//move the Logo from the information panel so that info can be seen   
                        lblTheatre.Text = " Llandudno Theatre";//show theatre represented by the plan
                        lblSeating.Text = "Seating";// title shows
                        lblPrices.Text = "Ticket prices";// title shows
                        lblAvailableSeats.Text = "Available seats:";// label for available seats
                       // lblSeatsAvailNum.Text = " ";//Variable label for available seats to show the number
                        lblSeatingPlan.Text = "" + "\r\n" + "15 Rows X 30 Seats per Row" + "\r\n" + "Total Seats: 450";//show seating details
                        lblAprice.Text = "Adult full: £14.00"; //price in this theatre                                                        //for event
                        lblCprice.Text = "Concession: £11.00";
                        lblFprice.Text = "Friend:     £ 9.00";
                    }

                    else if (showEvent.Location == "Caernarfon")
                    {
                        lblNWTG.Visible = false;
                        Seating(dsTickets);
                        lblTheatre.Text = "Caernarfon Theatre";
                        lblSeating.Text = "Seating";
                        lblPrices.Text = "Ticket prices";
                        lblAvailableSeats.Text = "Available seats:";
                       // lblSeatsAvailNum.Text = " ";
                        lblSeatingPlan.Text = "" + "\r\n" + "12 Rows X 20 Seats per Row" + "\r\n" + "Total Seats: 240";
                        lblAprice.Text = "Adult full: £10.00";
                        lblCprice.Text = "Concession: £ 7.50";
                        lblFprice.Text = "Friend:     £ 7.00";
                    }

                    else if (showEvent.Location == "Denbigh")
                    {
                        lblNWTG.Visible = false;
                        Seating(dsTickets);
                        lblTheatre.Text = " Denbigh Theatre";
                        lblSeating.Text = "Seating";
                        lblPrices.Text = "Ticket prices";
                        lblAvailableSeats.Text = "Available seats:";
                      //  lblSeatsAvailNum.Text = " ";
                        lblSeatingPlan.Text = "" + "\r\n" + "10 Rows X 20 Seats per Row" + "\r\n" + "Total Seats: 450";
                        lblAprice.Text = "Adult full: £12.50";
                        lblCprice.Text = "Concession: £10.00";
                        lblFprice.Text = "Friend:     £ 9.50";
                    }
            }

            else// else if no shows say this
            {
                lstEvents.Items.Add("Sorry now shows on that date" + "\r\n" + "Please try again");
            }

       }

           
  }


        private void Seating(DataSet dsTickets)// create button seats - this could have been in the SelectedIndex above
        {
            llandudnoAvailableSeats = 0;
            int R = 30;
            int S = 30;
            Button[,] seatButton = new Button[30, 30];//multidimensional array
            seatBox.Controls.Clear();//clear panel to display
           
            for (int y = 0; y < R; y++)//loop for seats
            {
                for (int x = 0; x < S; x++)//loop for rows
                {
                   

                

                    string seatNumber = Convert.ToChar(x + 65).ToString() + (y + 1).ToString();//convert numbers to letters starting at A which is 65 (ASCII numbers)

                    foreach (DataRow drTickets in dsTickets.Tables[0].Rows)// loop through rows / seats and check 
                    {

                        if (drTickets["SeatNumber"].ToString().TrimEnd() == seatNumber)// if the seat numbers in the database match the button I am about to create
                        {
                            if (y == 0)
                            {
                                Label RowLabel = new Label();
                                //this.BackColor = Color.Transparent;
                                RowLabel.Font = new Font("Arial", 8f);
                                RowLabel.Text = Convert.ToChar(x + 65).ToString();
                                RowLabel.Location = new Point(0, (x * 20));
                                RowLabel.Size = new Size(20, 20);
                                seatBox.Controls.Add(RowLabel);

                            }      

                   
                            seatButton[x, y] = new Button();//Create the Buttons
                            seatButton[x, y].Name = "seatButton" + seatNumber;//name and coordinates and set up number to show        
                            seatButton[x, y].Name = "seatButton" + x + ", " + y;
                            seatButton[x, y].Width = 20;//sizing
                            seatButton[x, y].Height = 20;//sizing
                            seatButton[x, y].Left = seatButton[x, y].Left + seatButton[x, y].Width + (y * 20);
                            seatButton[x, y].Top = seatButton[x, y].Top + seatButton[x, y].Top + (x * 20);//Centre the button
                           // seatButton[x, y].Location = new Point(y * 20, x * 20);                    
                            seatButton[x, y].Text = (x+1).ToString();
                            //seatButton[x, y].Tag = drTickets;
                            seatButton[x, y].Tag = seatNumber; //Did this after - not my work 
                            seatButton[x, y].Text = " ";//declares text variable
                            seatButton[x, y].BackColor = Color.SlateGray;
                            seatButton[x, y].ForeColor = Color.AntiqueWhite;//set initial text colour to white
                            seatButton[x, y].Text = "A";//Set initial text A for available
                            seatBox.Controls.Add(seatButton[x, y]);//Add them to the panel
                            seatButton[x, y].Click += new System.EventHandler(Button_Click);

                            string toolTipText = Convert.ToChar(x + 65).ToString() + (y + 1).ToString();//shows seat array number as letters
                            ToolTip buttonTooltip = new ToolTip();
                            buttonTooltip.SetToolTip(seatButton[x, y], toolTipText);// too clever for me ;o]


                            if (drTickets["AvailableOrsold"].ToString().TrimEnd() == "S")// if sold
                            {
                                seatButton [x, y].Enabled = false;

                                if (drTickets["TicketType"].ToString() == "A")//Adult tickets 
                                {
                                    seatButton[x, y].BackColor = Color.Orange;//are orange
                                    seatButton[x, y].ForeColor = Color.Black;//and text turns black
                                    seatButton[x, y].Text = "S";//and text shows as for Sold
                                }

                                else if (drTickets["TicketType"].ToString() == "C")
                                {
                                    seatButton[x, y].BackColor = Color.SpringGreen;
                                    seatButton[x, y].ForeColor = Color.Black;
                                    seatButton[x, y].Text = "S";
                                }

                                else if (drTickets["TicketType"].ToString() == "F")
                                {
                                    seatButton[x, y].BackColor = Color.PaleGoldenrod;
                                    seatButton[x, y].ForeColor = Color.Black;
                                    seatButton[x, y].Text = "S";
                                }

                                seatBox.Controls.Add(seatButton[x, y]);//Add them to the panel
    
                                //ADD ROW LABELS

                              
                            }
                                else
                                {
                                    llandudnoAvailableSeats = llandudnoAvailableSeats + 1;
                                    label1.Text = llandudnoAvailableSeats.ToString();
                                   // lblSeatsAvailNum.Text = llandudnoAvailableSeats.ToString(); // add one
                                    //not working yet - but I'm trying to show the number of seats available s
                                }



                            
                        }

                    }
                }




            }
        } 




        private void Button_Click(object sender, EventArgs e)// for clicked button event
        {

            //UPDATE HERE


            Button seatButton = (Button)sender;//instantaite clickedButton

            foreach (DataRow drTickets in dsTickets.Tables[0].Rows)// loop through rows / seats and check 
            {

                if (drTickets["SeatNumber"].ToString().TrimEnd() == seatButton.Tag.ToString())// if the seat numbers in the database match the button I am about to create
                {



                    decimal AdultPrice = 0; //{0:C}
                    decimal ConcessionPrice = 0;
                    decimal FriendPrice = 0;
                    //decimal TotalPrice = AdultPrice + ConcessionPrice + FriendPrice;
                    decimal TotalPrice = 0;
                    ScheduledEvent showEvent = new ScheduledEvent();
                    lblTotalPrice.Text = (String.Format("{0:c}", (System.Decimal)TotalPrice + AdultPrice));

                    if (rbtnAdultFull.Checked)// if adult back coulour, fore colour and text set
                    {
                        seatButton.BackColor = Color.Orange;
                        seatButton.ForeColor = Color.Black;
                        seatButton.Text = "S";

                        if (showEvent.Location == "Llandudno")
                        {
                            AdultPrice = 14; //price in this theatre                                                                             
                        }
                        if (showEvent.Location == "Caernarfon")
                        {
                            AdultPrice = 10; //price in this theatre                                                        

                        }
                        if (showEvent.Location == "Denbigh")
                        {
                            AdultPrice = 12.50m; //price in this theatre                                                        

                        }


                        if (llandudnoAvailableSeats == 0)
                        {
                            label1.Text = " Fully Booked";//Indicates fully booked event
                            //could put this into lst box possibly
                        }

                        llandudnoAvailableSeats = llandudnoAvailableSeats - 1; //Takes one from seats total
                        label1.Text = llandudnoAvailableSeats.ToString();
                    }



                    else if (rbtnConcession.Checked)// if concession back coulour, fore colour and text set
                    {
                        seatButton.BackColor = Color.SpringGreen;
                        seatButton.ForeColor = Color.Black;
                        seatButton.Text = "S";
                    }

                    if (showEvent.Location == "Llandudno")
                    {
                        ConcessionPrice = 11; //price in this theatre                                                                              
                    }
                    if (showEvent.Location == "Caernarfon")
                    {
                        ConcessionPrice = 7.5m; //price in this theatre                                                                              
                    }
                    if (showEvent.Location == "Denbigh")
                    {
                        ConcessionPrice = 10; //price in this theatre                                                                           
                    }


                    else if (rbtnFriend.Checked)// if friend back coulour, fore colour and text set
                    {
                        seatButton.BackColor = Color.PaleGoldenrod;
                        seatButton.ForeColor = Color.Black;
                        seatButton.Text = "S";
                    }
                    if (showEvent.Location == "Llandudno")
                    {
                        FriendPrice = 9; //price in this theatre                                                                       
                    }
                    if (showEvent.Location == "Caernarfon")
                    {
                        FriendPrice = 7; //price in this theatre                                                                         
                    }
                    if (showEvent.Location == "Denbigh")
                    {
                        FriendPrice = 9.5m; //price in this theatre                                                     
                    }

                }
            }

        }

        private void btnClearSeating_Click(object sender, EventArgs e)//clearing and resetting
        {
           seatBox.Controls.Clear();//Clear existing
           lstEvents.Items.Clear();// clear info
           lblNWTG.Visible = true;// put the logo back
           lblShow.Visible = true;// put the lyrics back
           lblTheatre.Text = "";//clear text boxes and prices
           lblSeating.Text = "";
           lblPrices.Text = "";
           lblAvailableSeats.Text = "";
           label1.Text = "0";
           lblSeatingPlan.Text = "";
           lblAprice.Text = "";
           lblCprice.Text = "";
           lblFprice.Text = "";


        }




        public int CreateBooking(string custNumber, DateTime bookDate, string bookTime, int payConfirmNumber)// variables passed in method brackets
        {
            Booking myBooking = new Booking();// myBooking = new booking object

            myBooking.CustomerNumber = "HU001"; //method set to expect values as objects with corrosponding variable names
            myBooking.DateOfBooking = DateTime.Today;
            myBooking.TimeOfBooking = bookTime;
            myBooking.PaymentConfirmationNumber = payConfirmNumber;
            myBooking.TicketsPrinted = "N";

            myBooking.AddNewBooking();// invoke add Booking method
            MessageBox.Show(" Customer number:  " + custNumber + "\r\n" + " Booking date: " + bookDate + "\r\n" + " Payment confirmation number:  " + payConfirmNumber, "BOOKING DETAILS");
            return myBooking.BookingReference;
        }




        private void btnExecutePayment_Click(object sender, EventArgs e)//pay button
        {         
            Customer oCust = new Customer();// instatiate customer
            BucksNetCardPayment BucksPay = new BucksNetCardPayment();// instatiate payment
            int BucksPayReturnValue = BucksPay.MakePayment("AXC72937402", txtCardNumber.Text, txtStartDate.Text,  txtEndDate.Text, txtNamOnCard.Text, txtSecurityCode.Text, oCust.Address1, oCust.Address2,oCust.Town, oCust.County, oCust.PostCode);
            string StartDate = txtStartDate.Text.Substring(3,5);
            string EndDate = txtEndDate.Text.Substring(3, 5);
            //Note some of the data you are sending is from the card entry text boxes, the rest is picked up from the customer class object that you have already set.(oCust in this case)

            bool errorIndicator = false;
            try
            {
                //Success?
                if (string.IsNullOrEmpty(txtNamOnCard.Text)) //if (txtCustomerNumber.Text == string.Empty)
                {
                    NamOnCardEP.SetError(txtNamOnCard, "Please enter a customer number");// if empty
                    errorIndicator = true;
                }
                else
                {
                    txtECustomerNumber.Clear();//if empty clear
                }
                if (string.IsNullOrEmpty(txtCardNumber.Text)) //if (txtCardNumber.Text == string.Empty)
                {//CARD NUMBER
                    CardNumberEP.SetError(txtCardNumber, "Please enter a card number");
                    errorIndicator = true;
                }
                else
                {//CARD NUMBER CLEAR
                    CardNumberEP.Clear();
                }
                if (txtCardNumber.Text.Length < 16 || txtCardNumber.Text.Length > 16)//has to be 16
                {//CARD NUMBER LENGTH
                    MessageBox.Show("The card number must be sixteen digits long ", "CARD NUMBER ERROR ");
                    errorIndicator = true;
                }

                if (string.IsNullOrEmpty(txtStartDate.Text)) //if (txtStartDate.Text == string.Empty)
                {
                    StartDateEP.SetError(txtStartDate, "Please enter a start date");
                }
                else
                {
                    txtStartDate.Clear();
                }
                if (string.IsNullOrEmpty(txtEndDate.Text)) //if (EtxtEndDate.Text == string.Empty)
                {
                    EndDateEP.SetError(txtEndDate, "Please enter an end date");
                    errorIndicator = true;
                }
                else
                {
                    EndDateEP.Clear();
                }
                //if ((StartDate) >= (EndDate)) //if (ECenterPostcodeTextBox.Text == string.Empty)
                //{
                //    MessageBox.Show("The card start date can not be more than the card end date ", "CARD DATE ERROR ");
                //    errorIndicator = true;
                //}
                if ((string.IsNullOrEmpty(txtSecurityCode.Text)) || (txtSecurityCode.Text.Length < 3 || txtSecurityCode.Text.Length > 3)) //if (ECenterPostcodeTextBox.Text == string.Empty)
                {
                    SecurityCodeEP.SetError(txtSecurityCode, "Please enter a 3 digit security code");
                    errorIndicator = true;
                }
                else
                {
                    SecurityCodeEP.Clear();
                }
            }

            catch (FormatException ex)// slowly slowly catchy monkey - I hope this explains what is happening
            {
                MessageBox.Show("Enter three digits please", ex.Message);
                MessageBox.Show("Incorrect Date Format - Enter dd/mm/yyyy please ", ex.Message);
            }




            if (errorIndicator == false)// if all the card 'stuff' is OK  & BucksPayReturnValue > 0
            {


                //After all that lot is done and you are fed up of verification



                try
                {

                    if (BucksPayReturnValue > 0)
                    {
                        //Create the booking record and update the Ticket records
                        int BookingRef = 0;
                        MessageBox.Show("Payment Reference: " + BucksPayReturnValue);
                        BookingRef = CreateBooking(oCust.CustomerNumber, DateTime.Today, DateTime.Now.ToShortTimeString(),
                        BucksPayReturnValue);

                        UpdateTickets(BookingRef);
                    }


                    else
                    {
                        MessageBox.Show("Payment Failed!  Error Code is: " + BucksPayReturnValue.ToString());
                    }

                }
                catch
                {
                }


             }


            ResetDisplay();//invoke the reset method below that I made earlier


        }

        private void ResetDisplay()// clear the payment details method
        {
            txtNamOnCard.Clear();
            txtCardNumber.Clear();
            txtStartDate.Clear();
            txtEndDate.Clear();
            txtSecurityCode.Clear();
        }

        private void btnClose_Click(object sender, EventArgs e)
        {                      
            this.Close();// close
          
        }

        private void btnCancelPayment_Click(object sender, EventArgs e)
        {
            ResetDisplay();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            lblTime.Text = DateTime.Now.ToString("HH:mm:ss tt");
            timer1.Interval = 5000;
            timer1.Start();
        }     

           

    }             
}

SceduledEvent EventName DateOfEvent TimeOfEvent AdultTicketPrice ConcessionTicketPrice FriendTicketPrice Confirmed ArtistName Location

3 Dancing at Springtime 12/05/2010 00:00:00 19:30 14.0000 11.0000 9.0000 Y Rambert Dance Company Llandudno
4 An Evening of Jazz 12/05/2010 00:00:00 20:00 10.0000 7.5000 7.0000 Y Just Four Fun Caernarfon
5 Dancing at Springtime 13/05/2010 00:00:00 19:30 12.5000 10.0000 9.5000 Y Rambert Dance Company Denbigh
NULL NULL NULL NULL NULL NULL NULL NULL NULL NULL

Holy crap. Post way less code.

Holy crap. Post way less code.

Hello - sorry if it is too much code. Whilst in hindsight I agree with you there is nothing that I can do about it because I cannot edit it.

Because I was a aware that my question may seem a little vague I was attempting to show how what I was trying to do related to what had already been done and show evidence that I had been working on this even though I was getting nowhere with the part that I am attempting now. Also I had been asked to show more code in the past.

If there is a way that I can edit the post, please let me know and I will reduce it.

John.

No I think you only have about half an hour to edit a post. Instead, you can post the specific parts that you are having problems with in this thread and I would be happy to help.

Tell us your problem, and paste the (necessary) code!! (not all of it :) ) that there is an issue in here.
And we`ll try to help you out.

Thanks skatamatic and Mitja for your offers of help.

What I have at the moment shown below is on the button click as I want the prices to show in the list box when I select (click) a seat on the plan. Even if this did work - which it doesn't I know this isn't the right way of going about it. I am not sure whether I should be putting a method for this at the class level and even if that was the way forward how to relate it to the button click!

I have this code in the ScheduledEvents class ...

public decimal AdultPrice// Declare an AdultPrice property of type decimal:
        {
            get
            {
                return m_AdultPrice;
            }
            set
            {
                m_AdultPrice = value;
            }
        }

        public decimal ConcessionPrice// Declare a ConcessionPrice property of type decimal:
        {
            get
            {
                return m_ConcessionPrice;
            }
            set
            {
                m_ConcessionPrice = value;
            }
        }

        public decimal FriendPrice// Declare a FriendPrice property of type decimal:
        {
            get
            {
                return m_FriendPrice;
            }
            set
            {
                m_FriendPrice = value;
            }
        }

This is my code on the button click for selecting seats

private void Button_Click(object sender, EventArgs e)// for clicked button event
        {

            Button seatButton = (Button)sender;//instantaite clickedButton

            foreach (DataRow drTickets in dsTickets.Tables[0].Rows)// loop through rows / seats and check 
            {

                if (drTickets["SeatNumber"].ToString().TrimEnd() == seatButton.Tag.ToString())// if the seat numbers in the database match the button I am about to create
                {


                    decimal AdultPrice = 0; //{0:C}
                    decimal ConcessionPrice = 0;
                    decimal FriendPrice = 0;
                    //decimal TotalPrice = AdultPrice + ConcessionPrice + FriendPrice;
                    decimal TotalPrice = 0;
                    ScheduledEvent showEvent = new ScheduledEvent();
                    lblTotalPrice.Text = (String.Format("{0:c}", (System.Decimal)TotalPrice + AdultPrice));

                    if (rbtnAdultFull.Checked)// if adult back coulour, fore colour and text set
                    {
                        seatButton.BackColor = Color.Orange;
                        seatButton.ForeColor = Color.Black;
                        seatButton.Text = "S";

                        if (showEvent.Location == "Llandudno")
                        {
                            AdultPrice = 14; //price in this theatre
                            lstTotal.Text = "Adult £14";
                            lstTotal.Text = AdultPrice.ToString();
                        }
                        if (showEvent.Location == "Caernarfon")
                        {
                            AdultPrice = 10; //price in this theatre
                            lstTotal.Text = "Adult £10";
                            lstTotal.Text = AdultPrice.ToString();                            

                        }
                        if (showEvent.Location == "Denbigh")
                        {
                            AdultPrice = 12.50m; //price in this theatre  
                            lstTotal.Text = "Adult £12.50";
                            lstTotal.Text = AdultPrice.ToString();                          

                        }


                        if (llandudnoAvailableSeats == 0)
                        {
                            label1.Text = " Fully Booked";//Indicates fully booked event
                            //could put this into lst box possibly
                        }

                        llandudnoAvailableSeats = llandudnoAvailableSeats - 1; //Takes one from seats total
                        label1.Text = llandudnoAvailableSeats.ToString();
                    }



                    else if (rbtnConcession.Checked)// if concession back coulour, fore colour and text set
                    {
                        seatButton.BackColor = Color.SpringGreen;
                        seatButton.ForeColor = Color.Black;
                        seatButton.Text = "S";
                    }

                    if (showEvent.Location == "Llandudno")
                    {
                        ConcessionPrice = 11; //price in this theatre
                        lstTotal.Text = "Concession £11";
                        lstTotal.Text = ConcessionPrice.ToString();                                                      
                    }
                    if (showEvent.Location == "Caernarfon")
                    {
                        ConcessionPrice = 7.5m; //price in this theatre  
                        lstTotal.Text = "Concession £7.50";
                        lstTotal.Text = ConcessionPrice.ToString();                                                        
                    }
                    if (showEvent.Location == "Denbigh")
                    {
                        ConcessionPrice = 10; //price in this theatre
                        lstTotal.Text = "Concession £11";
                        lstTotal.Text = ConcessionPrice.ToString();                                                       
                    }


                    else if (rbtnFriend.Checked)// if friend back coulour, fore colour and text set
                    {
                        seatButton.BackColor = Color.PaleGoldenrod;
                        seatButton.ForeColor = Color.Black;
                        seatButton.Text = "S";
                    }
                    if (showEvent.Location == "Llandudno")
                    {
                        FriendPrice = 9; //price in this theatre 
                        lstTotal.Text = "Friend £9";
                        lstTotal.Text = FriendPrice.ToString();                                                
                    }
                    if (showEvent.Location == "Caernarfon")
                    {
                        FriendPrice = 7; //price in this theatre  
                        lstTotal.Text = "Friend £7";
                        lstTotal.Text = FriendPrice.ToString();                                               
                    }
                    if (showEvent.Location == "Denbigh")
                    {
                        FriendPrice = 9.5m; //price in this theatre
                        lstTotal.Text = "Friend £9.50";
                        lstTotal.Text = FriendPrice.ToString();                             
                    }

                }
            }

        }
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.