I have this windows app Cafe that allows the user to make their selection and then it displays the cost of the items chosen, subtotal, tax, total, number of transactions made that day, and I need it to display the total sales tax collected as well. I figured calculating this would be similar to how I calculated # of transactions, but I have yet to figure it out. Any ideas?
public partial class Form1 : Form
{
int clicks = 0;
double totalSalesTaxCollected = 0;
public Form1()
{
InitializeComponent();
InitializeControls();
}
private void button1_Click(object sender, EventArgs e)
{
clicks++;
displayBill();
}
private void displayBill()
{
// int[] listArray = listBox1.getSelectedIndices();
// SelectedIndexCollection listArray = listBox1.SelectedIndices;
double localTax = 0.01;
double stateTax = 0.06;
double tax;
double subTotal = 0;
double total;
//Set the text area to non-edit mode and start
//with an empty string.
textBox1.ReadOnly = true;
textBox1.Text = "";
textBox1.AppendText(" C# KIOSK A LA CARTE\n\n");
textBox1.AppendText("--------------- Welcome ----------------\n\n");
//Calculate the cost of the items ordered.
for (int index = 0; index < listBox1.SelectedIndices.Count; index++)
{
subTotal = subTotal + yourChoicesPrices[listBox1.SelectedIndices[index]];
}
tax = (localTax + stateTax) * subTotal;
total = subTotal + tax;
//Display the costs.
for (int index = 0; index < listBox1.SelectedIndices.Count; index++)
{
textBox1.AppendText(yourChoicesItems[listBox1.SelectedIndices[index]] +"\n");
}
textBox1.AppendText("\n");
textBox1.AppendText("SUB TOTAL\t\t" + String.Format("{0:C}", subTotal) + "\n");
textBox1.AppendText("TAX \t\t"+ String.Format("{0:C}" , tax) + "\n");
textBox1.AppendText("TOTAL \t\t"+ String.Format("{0:C}" , total) + "\n\n");
textBox1.AppendText("\n");
textBox1.AppendText("Thank you - Have a Nice Day\n\n");
textBox1.AppendText("\n");
textBox1.AppendText("Total sales: \t\t" + clicks + "\n" );
textBox1.AppendText("Total sales tax collected: \t\t" + totalSalesTaxCollected);
//Reset list array.
listBox1.ClearSelected();
}
After
tax = (localTax + stateTax) * subTotal;
total = subTotal + tax;
Add
totalSalesTaxCollected += tax;