2015-06-25

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 WindowsFormsApplication1

{

public partial class Form1 : Form

{

public Form1()

{

InitializeComponent();

}

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

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

List<int> Quantity = new List<int>();

List<double> Price = new List<double>();

private void Click_Change(object sender, EventArgs e)

{

if (rbFruit.Checked == true)

{

int Fsmall = 10;

int Fmedium = 20;

int Flarge = 30;

if (rbSmall.Checked == true)

{

tbQuantity.Text = "1";

tbPrice.Text = Fsmall.ToString();

}

if (rbMedium.Checked == true)

{

tbQuantity.Text = "1";

tbPrice.Text = Fmedium.ToString();

}

if (rbLarge.Checked == true)

{

tbQuantity.Text = "1";

tbPrice.Text = Flarge.ToString();

}

}

if (rbVeggies.Checked == true)

{

int Vsmall = 25;

int Vmedium = 35;

int Vlarge = 45;

if (rbSmall.Checked == true)

{

tbQuantity.Text = "1";

tbPrice.Text = Vsmall.ToString();

}

if (rbMedium.Checked == true)

{

tbQuantity.Text = "1";

tbPrice.Text = Vmedium.ToString();

}

if (rbLarge.Checked == true)

{

tbQuantity.Text = "1";

tbPrice.Text = Vlarge.ToString();

}

}

if (rbSmoothie.Checked == true)

{

int Ssmall = 5;

int Smedium = 10;

int Slarge = 15;

if (rbSmall.Checked == true)

{

tbQuantity.Text = "1";

tbPrice.Text = Ssmall.ToString();

}

if (rbMedium.Checked == true)

{

tbQuantity.Text = "1";

tbPrice.Text = Smedium.ToString();

}

if (rbLarge.Checked == true)

{

tbQuantity.Text = "1";

tbPrice.Text = Slarge.ToString();

}

}

}

private void Total_Change(object sender, EventArgs e)

{

if (rbFruit.Checked == true)

{

if (rbSmall.Checked == true)

{

int price = 10;

int quantity = int.Parse(tbQuantity.Text);

int total = price * quantity;

tbPrice.Text = total.ToString();

}

if (rbMedium.Checked == true)

{

int price = 20;

int quantity = int.Parse(tbQuantity.Text);

int total = price * quantity;

tbPrice.Text = total.ToString();

}

if (rbLarge.Checked == true)

{

int price = 30;

int quantity = int.Parse(tbQuantity.Text);

int total = price * quantity;

tbPrice.Text = total.ToString();

}

}

//--------------------------------------------------------------------------------------------------//

//--------------------------------------------------------------------------------------------------//

if (rbVeggies.Checked == true)

{

if (rbSmall.Checked == true)

{

int price = 25;

int quantity = int.Parse(tbQuantity.Text);

int total = price * quantity;

tbPrice.Text = total.ToString();

}

if (rbMedium.Checked == true)

{

int price = 35;

int quantity = int.Parse(tbQuantity.Text);

int total = price * quantity;

tbPrice.Text = total.ToString();

}

if (rbLarge.Checked == true)

{

int price = 45;

int quantity = int.Parse(tbQuantity.Text);

int total = price * quantity;

tbPrice.Text = total.ToString();

}

}

//--------------------------------------------------------------------------------------------------//

//--------------------------------------------------------------------------------------------------//

if (rbSmoothie.Checked == true)

{

if (rbSmall.Checked == true)

{

int price = 5;

int quantity = int.Parse(tbQuantity.Text);

int total = price * quantity;

tbPrice.Text = total.ToString();

}

if (rbMedium.Checked == true)

{

int price = 10;

int quantity = int.Parse(tbQuantity.Text);

int total = price * quantity;

tbPrice.Text = total.ToString();

}

if (rbLarge.Checked == true)

{

int price = 15;

int quantity = int.Parse(tbQuantity.Text);

int total = price * quantity;

tbPrice.Text = total.ToString();

}

}

//--------------------------------------------------------------------------------------------------//

}

private void btnAddtoOrder_Click(object sender, EventArgs e)

{

//--------------------------------------------------------------------------------------//

if (rbFruit.Checked == true)

{

if (rbSmall.Checked == true)

{

string small = rbSmall.Text;

string fruit = rbFruit.Text;

int quantity = int.Parse(tbQuantity.Text);

double price = double.Parse(tbPrice.Text);

Quantity.Add(quantity);

Price.Add(int.Parse(tbPrice.Text));

Sizes.Add(small);

Fruits.Add(fruit);

}

if (rbMedium.Checked == true)

{

string medium = rbMedium.Text;

string fruit = rbFruit.Text;

int quantity = int.Parse(tbQuantity.Text);

double price = double.Parse(tbPrice.Text);

Quantity.Add(quantity);

Price.Add(int.Parse(tbPrice.Text));

Sizes.Add(medium);

Fruits.Add(fruit);

}

if (rbLarge.Checked == true)

{

string large = rbLarge.Text;

string fruit = rbFruit.Text;

int quantity = int.Parse(tbQuantity.Text);

double price = double.Parse(tbPrice.Text);

Quantity.Add(quantity);

Price.Add(int.Parse(tbPrice.Text));

Sizes.Add(large);

Fruits.Add(fruit);

}

}

//--------------------------------------------------------------------------------------//

//--------------------------------------------------------------------------------------//

if (rbVeggies.Checked == true)

{

if (rbSmall.Checked == true)

{

string small = rbSmall.Text;

string veggies = rbVeggies.Text;

int quantity = int.Parse(tbQuantity.Text);

double price = double.Parse(tbPrice.Text);

Quantity.Add(quantity);

Price.Add(int.Parse(tbPrice.Text));

Sizes.Add(small);

Fruits.Add(veggies);

}

if (rbMedium.Checked == true)

{

string medium = rbMedium.Text;

string veggies = rbVeggies.Text;

int quantity = int.Parse(tbQuantity.Text);

double price = double.Parse(tbPrice.Text);

Quantity.Add(quantity);

Price.Add(int.Parse(tbPrice.Text));

Sizes.Add(medium);

Fruits.Add(veggies);

}

if (rbLarge.Checked == true)

{

string large = rbLarge.Text;

string veggies = rbVeggies.Text;

int quantity = int.Parse(tbQuantity.Text);

double price = double.Parse(tbPrice.Text);

Quantity.Add(quantity);

Price.Add(int.Parse(tbPrice.Text));

Sizes.Add(large);

Fruits.Add(veggies);

}

}

//--------------------------------------------------------------------------------------//

//--------------------------------------------------------------------------------------//

if (rbSmoothie.Checked == true)

{

if (rbSmall.Checked == true)

{

string small = rbSmall.Text;

string smoothie = rbSmoothie.Text;

int quantity = int.Parse(tbQuantity.Text);

double price = double.Parse(tbPrice.Text);

Quantity.Add(quantity);

Price.Add(int.Parse(tbPrice.Text));

Sizes.Add(small);

Fruits.Add(smoothie);

}

if (rbMedium.Checked == true)

{

string medium = rbMedium.Text;

string smoothie = rbSmoothie.Text;

int quantity = int.Parse(tbQuantity.Text);

double price = double.Parse(tbPrice.Text);

Quantity.Add(quantity);

Price.Add(int.Parse(tbPrice.Text));

Sizes.Add(medium);

Fruits.Add(smoothie);

}

if (rbLarge.Checked == true)

{

string large = rbLarge.Text;

string smoothie = rbSmoothie.Text;

int quantity = int.Parse(tbQuantity.Text);

double price = double.Parse(tbPrice.Text);

Quantity.Add(quantity);

Price.Add(int.Parse(tbPrice.Text));

Sizes.Add(large);

Fruits.Add(smoothie);

}

}

//--------------------------------------------------------------------------------------//

}

private void btnCompleteOrder_Click(object sender, EventArgs e)

{

btnAddtoOrder.Enabled = false;

double total = Price.Sum();

string fruits = string.Join<string>("\n", Fruits);

string sizes = string.Join<string>("\n", Sizes);

string quantity = string.Join("\n", Quantity.Select(x => x.ToString()).ToArray());

string prices = string.Join("\n", Price.Select(x => x.ToString("0.00")).ToArray());

MessageBox.Show(sizes + "\n" + fruits + "\n" + quantity + "\n" + prices + "\n" + "Total Purchase: " + Decimal.Parse(total.ToString("0.00")));

}

}

}

this is my codes and i cant arrange my list in the MessageBox it is horizontal i want to arrange it in order as shown in the picture i attached how can i do that i have included the correct sample format.

Attached Images

 

Show more