Home > C#, Programming > Tutorial #3 – Pizza Order in C#

Tutorial #3 – Pizza Order in C#

Here is my new pizza order tutorial for you. In this tutorial you are able to control checkboxes and radiobuttons together and show them into a message box window.

Codes below…

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 WindowsFormsApplication2
{
public partial class pizza : Form
{

//Some global strings to keep radiobutton and checkbox events text's.
private String a1 = null;
private String a2 = null;
private String a3 = null;
private String menu = null;

public pizza()
{
InitializeComponent();
}


private void button1_Click(object sender, EventArgs e)
{

// This event for new order button, so it makes everything null.
textBox1.Text = null;
textBox2.Text = null;
radioButton1.Checked = false;
radioButton2.Checked = false;
radioButton3.Checked = false;
checkBox1.Checked = false;
checkBox2.Checked = false;
checkBox3.Checked = false;
}

private void button3_Click(object sender, EventArgs e)
{
Application.Exit(); // it used for exit button
}

private void button2_Click(object sender, EventArgs e)
{
String name = textBox1.Text;
String surname = textBox2.Text;

MessageBox.Show("Name: " + name + "\nSurname: " + surname + "\nMenu: " + menu + "\nAdditions:" + a1 + a2 + a3, "Confirm Your Order!", MessageBoxButtons.YesNo ,MessageBoxIcon.Information);

}

private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
a1 = " Mushroom";
}
else
{
a1 = null;
}
}

private void checkBox2_CheckedChanged(object sender, EventArgs e)
{
if (checkBox2.Checked)
{
a2 = " Olive";
}
else
{
a2 = null;
}
}

private void checkBox3_CheckedChanged(object sender, EventArgs e)
{
if (checkBox3.Checked)
{
a3 = " Corn";
}
else
{
a3 = null;
}
}

private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
menu = "Classic";
}

private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
menu = "Full";
}

private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
menu = "Vegeterian";
}
}
}

Any questions ?

VN:F [1.9.22_1171]
Rating: 5.9/10 (9 votes cast)
VN:F [1.9.22_1171]
Rating: -1 (from 1 vote)
Tutorial #3 - Pizza Order in C#, 5.9 out of 10 based on 9 ratings
Categories: C#, Programming Tags: , , ,
  1. November 12th, 2008 at 21:59 | #1

    Bu linkteki sözlerini tutmanı istiyorum :) 1- lütfen türkçe olsun 2- microsoft’a ve teknolojilerine hayır :) :P blog yayını yaptığını bilmiyordum bundan sonra düzenli olarak uğrayacağım mekanlardan birtanesi seninkisi olacak..

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  1. No trackbacks yet.