C# Case Study

Bakery Shop — Order Form Calculator

A Windows Forms application that calculates order subtotals for bakery items, applies sales tax and an optional discount, and displays the final total. The form also supports clearing the order so a new transaction can be started quickly.

Screenshots

Code-Behind

Screenshot of Bakery order form C# code-behind.

Event handlers and calculation logic that respond to button clicks and input changes.

Form Designer

Screenshot of Bakery order form designer code in C#.

Designer-generated layout code defining labels, text boxes, buttons, and group boxes.

Completed Order Example

Bakery order form with example values showing subtotal, tax, discount and total.

An example test run showing the form filled out with sample items and a calculated total.

Project Overview

This assignment focused on building a basic point-of-sale style order form in C# Windows Forms. The user selects one or more bakery items, and the application calculates the subtotal based on quantity and price. A sales tax rate is applied, and an optional discount can be toggled on or off. The final total is then displayed for the customer.

In addition to the calculation logic, the form includes a clear/reset function. This makes it easy to reuse the same form for multiple customers without closing and reopening the application.

Key Logic (Subtotal, Tax & Discount)

A simplified example of how the cost calculation is handled:

private void btnCalculate_Click(object sender, EventArgs e)
{
    decimal subtotal = 0m;

    // Example of item checks (actual project uses specific controls and prices)
    if (chkDonut.Checked)
        subtotal += DONUT_PRICE * nudDonutQuantity.Value;

    if (chkCookie.Checked)
        subtotal += COOKIE_PRICE * nudCookieQuantity.Value;

    decimal tax = subtotal * TAX_RATE;

    decimal discount = 0m;
    if (chkDiscount.Checked)
        discount = subtotal * DISCOUNT_RATE;

    decimal total = subtotal + tax - discount;

    txtSubtotal.Text = subtotal.ToString("C");
    txtTax.Text      = tax.ToString("C");
    txtDiscount.Text = discount.ToString("C");
    txtTotal.Text    = total.ToString("C");
}

The real code uses the specific controls created for the project, but this snippet shows the core idea: gather selected items, calculate subtotal, apply tax and optional discount, then format the results as currency for display.

What I Learned

Explore the Code

You can review the full implementation, including all controls, events, and calculation logic, in the GitHub repository.