• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 391
  • Last Modified:

Visual Studio C# Application

I seem to have everything defined with no errors but am unable to get the program to respond when entering data into the form.  The form looks like this http://screencast.com/t/aO3aCrcvH and the code is pasted below.  Is there anything obvious that I have I missed?
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;

namespace _304_PennerT_Lab03
{
    public partial class stadiumSeatingForm : Form
    {
        public stadiumSeatingForm()
        {
            InitializeComponent();
        }

        private void calculateRevenueButton_Click(object sender, EventArgs e)
        {
            // Declare Named Constants
               
                const decimal CLASS_A_SEATS = 15.00m; const decimal CLASS_B_SEATS = 12.00m; const decimal CLASS_C_SEATS = 9.00m;
            
            // Declare Varialbles
               
                decimal classATickets; decimal classBTickets; decimal classCTickets;
                decimal classARevenue; decimal classBRevenue; decimal classCRevenue;
            
            // Convert Text Box Values (which are string values) to the appropriate data type using a Parse method and assign to related variable.
               
                classATickets = decimal.Parse(classATicketsSalesBox.Text); classBTickets = decimal.Parse(classATicketsSalesBox.Text); classCTickets = decimal.Parse(classCTicketsSalesBox.Text);
            
            // Process Calculations
               
                classARevenue = classATickets * CLASS_A_SEATS; classBRevenue = classBTickets * CLASS_B_SEATS; classCRevenue = classCTickets * CLASS_C_SEATS;
            
            // Display Numeric Output to appropriate control by converting the numeric value to a string using the ToString method.
               
                classARevenueBox.Text = classARevenue.ToString("c"); classBRevenueBox.Text = classBRevenue.ToString("c"); classCRevenueBox.Text = classCRevenue.ToString("c");
        }
        private void clearButton_Click(object sender, EventArgs e)
        {
            // Clear form and set focus
               
                classATicketsSalesBox.Text = " "; classBTicketsSalesBox.Text = " "; classCTicketsSalesBox.Text = " ";
                classARevenueBox.Text = " "; classBRevenueBox.Text = " "; classCTicketsSalesBox.Text = " ";
                totalRevenueBox.Text = " ";
        }

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

        private void classATicketsSalesBox_TextChanged(object sender, EventArgs e)
        {

        }

        private void calculateRevenueButton_Click_1(object sender, EventArgs e)
        {

        }
    }
}

Open in new window

0
rtod2
Asked:
rtod2
  • 5
  • 4
  • 3
1 Solution
 
Daniel ReynoldsSoftware Applications Developer / IntegratorCommented:
Double-check that your button_click events are hooked up to the button.
0
 
rtod2Author Commented:
Can you be more specific?
0
 
Daniel ReynoldsSoftware Applications Developer / IntegratorCommented:
I have created button click events and thought they were hooked up as the event to call when the button is pressed, but then I go and check by looking at the properties of the button and event methods and they are not there. Just be sure the events are assigned to the button. That is the first check I would do.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
rtod2Author Commented:
How do I make sure the events are assigned to the button?
0
 
Daniel ReynoldsSoftware Applications Developer / IntegratorCommented:
select the button
press F4 to see the properties of the button.
Select the little lightning bolt (event part of the properties)
scroll the properties to find the click event.
verify that your button click method is assigned to the click event.
See the screenshot to get an idea of how to check. button_click_event_property assigned
0
 
NorieData ProcessorCommented:
What happens if you double click on the buttons when you have the form in design view?

Does focus goto the existing event of the button you clicked?

eg if you double click calculateRevenueButton does it go to calculateRevenueButton_Click?
0
 
rtod2Author Commented:
imnorie, thank you

Therein must lie the problem.  When I double click on the so named calculateRevenueButton, it puts me into the section of code below named caculateRevenueButton_Click_1 instead of where it should put me.  I have attached the resulting code.  Please advise further
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;

namespace _304_PennerT_Lab03
{
    public partial class stadiumSeatingForm : Form
    {
        public stadiumSeatingForm()
        {
            InitializeComponent();
        }

        private void calculateRevenueButton_Click(object sender, EventArgs e)
        {
            // Declare Named Constants
               
                const decimal CLASS_A_SEATS = 15.00m; const decimal CLASS_B_SEATS = 12.00m; const decimal CLASS_C_SEATS = 9.00m;
            
            // Declare Varialbles
               
                decimal classATickets; decimal classBTickets; decimal classCTickets;
                decimal classARevenue; decimal classBRevenue; decimal classCRevenue;
            
            // Convert Text Box Values (which are string values) to the appropriate data type using a Parse method and assign to related variable.
               
                classATickets = decimal.Parse(classATicketsSalesBox.Text); classBTickets = decimal.Parse(classATicketsSalesBox.Text); classCTickets = decimal.Parse(classCTicketsSalesBox.Text);
            
            // Process Calculations
               
                classARevenue = classATickets * CLASS_A_SEATS; classBRevenue = classBTickets * CLASS_B_SEATS; classCRevenue = classCTickets * CLASS_C_SEATS;
            
            // Display Numeric Output to appropriate control by converting the numeric value to a string using the ToString method.
               
                classARevenueBox.Text = classARevenue.ToString("c"); classBRevenueBox.Text = classBRevenue.ToString("c"); classCRevenueBox.Text = classCRevenue.ToString("c");
        }
        private void clearButton_Click(object sender, EventArgs e)
        {
            // Clear form and set focus
               
                classATicketsSalesBox.Text = " "; classBTicketsSalesBox.Text = " "; classCTicketsSalesBox.Text = " ";
                classARevenueBox.Text = " "; classBRevenueBox.Text = " "; classCTicketsSalesBox.Text = " ";
                totalRevenueBox.Text = " ";
        }
        private void exitButton_Click(object sender, EventArgs e)
        {
            // Close application
                
                this.Close();
        }

        private void calculateRevenueButton_Click_1(object sender, EventArgs e)
        {

        }
    }
}

Open in new window

0
 
NorieData ProcessorCommented:
Try doing what xdJR1875 but also click the dropdown button.

That should give you a list which should include clearButton_Click, which obviously you should select.

Do the same for the other buttons.
0
 
rtod2Author Commented:
He sees a Click property which I do not.  I click the button and press F4.  I get properties but not a Click property.  I am using the latest version of Visual Studio.  Is there a way to upload the files here?
0
 
NorieData ProcessorCommented:
At the bottom(or top) of the property sheet you should see a small lightning strike.

Click that to see the events.
0
 
Daniel ReynoldsSoftware Applications Developer / IntegratorCommented:
Step 3 of my post above shows how to get to the click event and do those things.
0
 
rtod2Author Commented:
Lightning bolt.  Got it.  Thank you
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now