Programlama öğrenmek için her zaman yeni örnekler denemelisiniz. Bunun için bugün sizlere C# ile Pizza Sipariş-Takip Programı Uygulamasını aktaracağız. C# ile Pizza Sipariş-Takip Programı Uygulaması örneği nasıl kodlanır? Gibi sorularınızın cevabını bu içeriğimizde bulabilirsiniz.
Formumuzun görünümü aşağıdaki gibidir:
Kullanılması Gerekenler
C# ile Pizza Sipariş-Takip Programı Uygulaması için kullanılması gereken sırası ile aşağıdaki gibidir:
17 adet label, 3 adet textbox, 3 adet button, 7 adet listbox, 8 adet checkbox, 2 adet combobox ve 2 numericupdowm.
Kod Alanı
Uygulamamız da kullanıcı tarafından girilen bilgilere göre pizza siparişi oluşturmaktadır. Textboxlardan aldığımız veriler ve combobox ve numericupdown verileri ile siparişi detaylaştırıyoruz. Ekstra olarak istenilen bir durum var ise checkboxlarımızdan seçili olan ekstraları ekliyoruz. Son olarak her şeyi seçili listboxlara atıyoruz. Bu programın kod metni içerisindeki aşamalar sırası ile şunlardır:
1) Temizle butonumuza tıkladığımız anda ilk önce textbox değerlerimizin içini temizliyoruz.
2) Sonraki aşama olarak combobox, numericupdown ve checkbox değerlerimizin içlerini sırası ile temizliyoruz.
3) Sipariş Al butonuna tıkladığımız anda ilk önce ucret ve ekstra isimli değişkenler tanımlıyoruz.
4) Seçili ekstra bilgilerini ekliyoruz.
5) Seçili olan değerimizi ücret değişkenini ve adet bilgisini çarparak fiyatını hesaplıyoruz.
6) Bütün değerlerimizi ilgili Listboxlarımızın içerisine yazdırıyoruz.
7) Siparişleri Temizle butonuna tıkladığımız anda ise son aşamamız olan listboxları temizleme aşamasını tamamlayıp programımızı sonlandırıyoruz.
Bu uygulamamızın kod metni aşağıdaki gibidir:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Pizza
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void buttonTemizle_Click(object sender, EventArgs e)
{
textBoxAdSoyad.Text = "";
textBoxTelefon.Text = "";
textBoxAdres.Text = "";
comboBoxIcecek.Text = "";
comboBoxPizzaBoy.Text = "";
numericUpDownPizza.Value = 0;
numericUpDownIcecek.Value = 0;
checkBoxSucuk.Checked = false;
checkBoxSosis.Checked = false;
checkBoxMantar.Checked = false;
checkBoxKasar.Checked = false;
checkBoxPeynir.Checked = false;
checkBoxSebze.Checked = false;
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void buttonSiparisAl_Click(object sender, EventArgs e)
{
decimal ucret = 0;
string ekstra = "";
if (checkBoxSucuk.Checked == true)
{ ekstra += "Sucuk";}
if (checkBoxSosis.Checked == true)
{ ekstra += " - " + "Sosis";}
if (checkBoxMantar.Checked == true)
{ ekstra += " - " + "Mantar" ; }
if (checkBoxKasar.Checked == true)
{ ekstra += " - " + "Kaşar" ; }
if (checkBoxPeynir.Checked == true)
{ ekstra += " - " + "Peynir" ; }
if (checkBoxSebze.Checked == true)
{ ekstra += " - " + "Sebze" ; }
if (comboBoxPizzaBoy.Text =="Küçük")
{ucret = numericUpDownPizza.Value * 10;}
else if (comboBoxPizzaBoy.Text == "Orta")
{ucret = numericUpDownPizza.Value * 15;}
else if (comboBoxPizzaBoy.Text == "Büyük")
{ucret = numericUpDownPizza.Value * 20;}
if(comboBoxIcecek.Text=="2,5lt Coca Cola")
{ucret += numericUpDownIcecek.Value * 5;}
else if(comboBoxIcecek.Text=="1lt Fanta")
{ucret += numericUpDownIcecek.Value * 3;}
else if (comboBoxIcecek.Text == "1lt Sprite")
{ucret += numericUpDownIcecek.Value * 3;}
listBoxAdSoyad.Items.Add(textBoxAdSoyad.Text);
listBoxTelefon.Items.Add(textBoxTelefon.Text);
listBoxAdres.Items.Add(textBoxAdres.Text);
listBoxPizza.Items.Add(numericUpDownPizza.Value + " adet " + comboBoxPizzaBoy.Text);
listBoxIcecek.Items.Add(numericUpDownIcecek.Value + " adet " + comboBoxIcecek.Text);
listBoxEkstra.Items.Add(ekstra);
listBoxUcret.Items.Add(ucret + "TL");
}
private void buttonSiparisTemizle_Click(object sender, EventArgs e)
{
listBoxAdSoyad.Items.Clear();
listBoxTelefon.Items.Clear();
listBoxAdres.Items.Clear();
listBoxPizza.Items.Clear();
listBoxIcecek.Items.Clear();
listBoxEkstra.Items.Clear();
listBoxUcret.Items.Clear();
}
}
}
Bu uygulamada herhangi bir sorun yaşarsanız aşağıya yorum olarak bırakabilirsiniz. Bunun yanı sıra web sitemizdeki diğer hazır C# programlama örneklerine ulaşmak için bu linke tıklayabilirsiniz.