Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7591181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:35:21+00:00 2026-05-30T20:35:21+00:00

THIS IS HOMEWORK: I have a program that consists of two winforms and three

  • 0

THIS IS HOMEWORK: I have a program that consists of two winforms and three classes. The program does the work it is supposed to do for the main form and displays it appropriately onto the textbox of the main form. In addition to displaying the information, it is also saved to a string list. The data consists of order information.

The string list passes that information along to a method in another class and stores it in a list as it is supposed to do. After this is done, I press a button which opens up another form. In this form I enter an order number. What is supposed to happen is that a method compares the order number entered with the row number of the list and return that information, whereupon it is displayed in the textbox of the second form.

That is what is supposed to happen. Instead, when it is time to compare the order number with the row number of the list, the list data is gone and I cannot figure out why. Here is my code that pertains:

 private void btnPaymentButton_Click(object sender, EventArgs e)
    {            
        amountPaid = double.Parse(this.txtAmountPaid.Text);
        orderObject.GetChangeDue(orderObject.TotalAmountDue, amountPaid);                   

        this.txtNumberOfPizzaOrdered.Clear();
        this.txtNumberOfCokesOrdered.Clear();
        this.txtAmountDue.Clear();
        this.txtAmountPaid.Clear();
        this.lblYourOrder.Visible = true;
        this.rtxtYourOrder.Visible = true;
        this.rtxtYourOrder.Text = orderObject.OrderSummary(amountPaid);

        //storeOrderObject = new DailySummary(orderObject.OrderSummary(amountPaid));

        storeOrderObject = new DailySummary(this.rtxtYourOrder.Text);           
    }     

private void btnDailySummary_Click(object sender, EventArgs e)
    {
        DailySummaryForm form = new DailySummaryForm();
       // this.Visible = false;
        form.Show();
    }

........

public class DailySummary
{
    //declare variables
    int numberOfCokes = 0,
        numberOfPizzas = 0,
        totalOfCokes = 0,
        totalOfPizzas = 0,            
        orderNumberRequest = 0;        

    string orderFromForm1 = "",
           getAllTheOrders = "",
           getAnOrder = "";

    List<string> pizzaOrderList = new List<string>();

    public DailySummary(string orderForm)
    {
        orderFromForm1 = orderForm;
        StoreOrder(orderFromForm1);
    }

    public DailySummary(int orderRequest)
    {
        orderNumberRequest = orderRequest;
        GetOrder(OrderNumberRequest);
    }

public int OrderNumberRequest
    {
        get
        {
            return this.orderNumberRequest;
        }
    }        

//store order
    public void StoreOrder(string orderFromForm1)
    {
        pizzaOrderList.Add(orderFromForm1);
    }

    //get the order
    public string GetOrder(int OrderNumberRequest)
    {
        for (int row = 0; row < pizzaOrderList.Count; row++)
        {
            if (row == (OrderNumberRequest - 1))
            {
                getAnOrder = pizzaOrderList[row];
            }
        }
        return getAnOrder;
    }

........

public partial class DailySummaryForm : Form
{
    int orderNumberRequest = 0;
    //instantiate a from object
    OrderForm formObject;
    DailySummary summaryObject;

    public DailySummaryForm()
    {
        InitializeComponent();
    }

    private void btnOrderNumberButton_Click(object sender, EventArgs e)
    {
        orderNumberRequest = int.Parse(this.txtOrderNumber.Text);
        summaryObject = new DailySummary(orderNumberRequest);

        this.rtxtDisplayOutput.Visible = true;
        this.rtxtDisplayOutput.Text = summaryObject.GetAnOrder;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:35:23+00:00Added an answer on May 30, 2026 at 8:35 pm

    In your method btnPaymentButton_Click you create an instance of the DailySummary class, then later on when your in the DailySummaryForm you create a new instance of the DailySummary Class.

    These instances are separate and therefore do not share the same values.

    As your not persisting values to the DB you’ll probably want to:

    1. look into making your DailySummary Static (which will make it accessable throughout your
      winform application). (It’s not typically good practice to have too many global (static) variables hanging around, but without a persistence engine where you can store your Daily Summary you need a common place to look it up.
    2. Pass the initialized instance of the DailySummary class to your DailySummaryForm. (The DailySummaryForm could expose a public property. The drawback of this method is if your switching between both forms and each form modified your summary class, your going to constantly have to pass it back and forth between the forms.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So for Homework I have to create this program that reads from a text
I have a homework problem where I have to make an inheritance program that
I have this homework. And I am beginner C# program, and now learn the
I've been asked (as part of homework) to design a Java program that does
I have a program that read urls in a file and does a gethostbyname()
I have a Java program that I must do for homework, and here's the
(this is indirectly a part of a much larger homework assignment) I have something
I'm working on this homework that's kind of confusing me... I am provided with
(This is no homework and no work issue. It's just my personal interest/occupation and
This is not homework, I need this for my program :) I ask this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.