Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Storing a value then clearing a text box.

$
0
0

Hey Guys Im having a little trouble with an assignment. 

Heres my code that I have so far.  This is for the Submit order button. I have it stored in the labels, but once the text fields are cleared the labels lose the values once another input in filled into the text boxes. What I need to do is keep storing the values and adding them to the total order. 

1. Store the quantity (number of movies) into a local variable of type integer
2. Store the price into a local variable of type decimal
3. Declare a local variable of type decimal to be used for the extended price
4. Calculate the extended price (number of movies * price)
5. Add the number of movies (the value stored in the integer you created in step 1) 
to the quantity stored in the Total Number of Movies Label 
(you will need to Convert the value stored in the Label, add it to the current 
number of movies variable, assign this new value to the number of movies 
variable, and then store it back in the label)
6. Add the extended price to the quantity stored in the Total Movie Price Label 
(similar to the previous step)
7. Set focus to the quantity text box
8. Clear both text boxes
9. Enable the Checkout button
10. Clear the Invoice Label (the same way you clear a TextBox) and make in invisible

Code that I have. 

 protected void btnSubmitOrder_Click(object sender, EventArgs e)
    {
        int numberMovies = 0;
        decimal decprice = 0M;

        decprice = Convert.ToDecimal(txtMoviePrice.Text);
        numberMovies = Convert.ToInt16(txtQuntMovies.Text);

        decimal decextendedprice = numberMovies * decprice;
        string strMovies ="";
        string strMoviePrice ="";
        strMovies = Convert.ToString(txtQuntMovies.Text);
        strMoviePrice = Convert.ToString(decextendedprice);
        lblMovies.Text = strMovies;
        lblPrice.Text = strMoviePrice;

        txtMoviePrice.Text = "";
        txtQuntMovies.Text = "";

        btnCheckOut.Enabled = true;
        

        
        



    }


Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>