19 Ekim 2011 Çarşamba

Sinema Programı örnek C#.Net

Sinema Programı örnek C#.Net

Koltuklar için 18 button,perde için 1 buton, rezervasyon iptali için 1 buton,dolu boş göstergesi için 2 picturebox, 4 label,3 textbox ekliyoruz.Koltuk için bilet almak için isim ve soyisim yazdıktan sonra koltuk üzerine tıklamak gerekmektedir.



 Sinema Programı
Koltuklar için 18 button,perde için 1 buton, rezervasyon iptali için 1 buton,dolu boş göstergesi için 2 picturebox, 4 label,3 textbox ekliyoruz.Koltuk için bilet almak için isim ve soyisim yazdıktan sonra koltuk üzerine tıklamak gerekmektedir.
Picturebox ın properties penceresinden arka rengini yeşil yapıyoruz
Diğer Pictureboxın rengini kırmızı yapıyoruz
Perdenin flatsylenı flat yapıyoruz textine perde yazıyoruz

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
//boş koltuk sayısı için x,dolu koltuk sayısı için i tanımlıyoruz
int i, x=18;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
//bütün koltukların renklerini yeşil yapıyoruz
this.button1.BackColor = System.Drawing.Color.Green;
this.button2.BackColor = System.Drawing.Color.Green;
this.button3.BackColor = System.Drawing.Color.Green;
this.button4.BackColor = System.Drawing.Color.Green;
this.button5.BackColor = System.Drawing.Color.Green;
this.button6.BackColor = System.Drawing.Color.Green;
this.button7.BackColor = System.Drawing.Color.Green;
this.button8.BackColor = System.Drawing.Color.Green;
this.button9.BackColor = System.Drawing.Color.Green;
this.button10.BackColor = System.Drawing.Color.Green;
this.button11.BackColor = System.Drawing.Color.Green;
this.button12.BackColor = System.Drawing.Color.Green;
this.button13.BackColor = System.Drawing.Color.Green;
this.button14.BackColor = System.Drawing.Color.Green;
this.button15.BackColor = System.Drawing.Color.Green;
this.button16.BackColor = System.Drawing.Color.Green;
this.button17.BackColor = System.Drawing.Color.Green;
this.button18.BackColor = System.Drawing.Color.Green;
}
private void button1_Click(object sender, EventArgs e)
{//eğer isim ve soyad dolu ise işlem yapmasını sağlıyoruz
if (textBox1.Text != "" && textBox2.Text != "")
{
//girilen ismi ve soyadı butonun textine atıyoruz
button1.Text = textBox1.Text + " " + textBox2.Text;
//koltuk dolduğu için koltuğun rengini kırmızı yapıyoruz
this.button1.BackColor = System.Drawing.Color.Red;
//birdaha tıklanmaması için enableını false yapıyoruz
button1.Enabled = false;
//isim ve soyad kutularının içini boşaltıyoruz
textBox1.Text = "";
textBox2.Text = "";
//dolu koltuk sayısını 1 arttırıyoruz
i++;
//boş koltuk sayısını 1 azaltıyoruz
x--;
//dolu koltuk sayısını stringe çevirip labelin içine atıyoruz
label3.Text = "Dolu: " + i.ToString();
//boş koltuk sayısını stringe çevirip labelin içine atıyoruz
label4.Text = "Boş: " + x.ToString();
}
//eğer isim yada soyaddan biri girilmemiş ise uyarı vermesini sağlıyoruz
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
//diğer butonlar için aynı işlemleri uyguluyoruz
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button2.Text = textBox1.Text + " " + textBox2.Text;
this.button2.BackColor = System.Drawing.Color.Red;
button2.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button3.Text = textBox1.Text + " " + textBox2.Text;
this.button3.BackColor = System.Drawing.Color.Red;
button3.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button4_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button4.Text = textBox1.Text + " " + textBox2.Text;
this.button4.BackColor = System.Drawing.Color.Red;
button4.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button5_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button5.Text = textBox1.Text + " " + textBox2.Text;
this.button5.BackColor = System.Drawing.Color.Red;
button5.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button6_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button6.Text = textBox1.Text + " " + textBox2.Text;
this.button6.BackColor = System.Drawing.Color.Red;
button6.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button7_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button7.Text = textBox1.Text + " " + textBox2.Text;
this.button7.BackColor = System.Drawing.Color.Red;
button7.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button8_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button8.Text = textBox1.Text + " " + textBox2.Text;
this.button8.BackColor = System.Drawing.Color.Red;
button8.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button9_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button9.Text = textBox1.Text + " " + textBox2.Text;
this.button9.BackColor = System.Drawing.Color.Red;
button9.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button10_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button10.Text = textBox1.Text + " " + textBox2.Text;
this.button10.BackColor = System.Drawing.Color.Red;
button10.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button12_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button12.Text = textBox1.Text + " " + textBox2.Text;
this.button12.BackColor = System.Drawing.Color.Red;
button12.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button13_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button13.Text = textBox1.Text + " " + textBox2.Text;
this.button13.BackColor = System.Drawing.Color.Red;
button13.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button14_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button14.Text = textBox1.Text + " " + textBox2.Text;
this.button14.BackColor = System.Drawing.Color.Red;
button14.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button15_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button15.Text = textBox1.Text + " " + textBox2.Text;
this.button15.BackColor = System.Drawing.Color.Red;
button15.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button17_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button17.Text = textBox1.Text + " " + textBox2.Text;
this.button17.BackColor = System.Drawing.Color.Red;
button17.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button11_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button11.Text = textBox1.Text + " " + textBox2.Text;
this.button11.BackColor = System.Drawing.Color.Red;
button11.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button16_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button16.Text = textBox1.Text + " " + textBox2.Text;
this.button16.BackColor = System.Drawing.Color.Red;
button16.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
private void button18_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "")
{
button18.Text = textBox1.Text + " " + textBox2.Text;
this.button18.BackColor = System.Drawing.Color.Red;
button18.Enabled = false;
textBox1.Text = "";
textBox2.Text = "";
i++;
x--;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
else
{ MessageBox.Show("isim yada soyadınız tam değil"); }
}
//rezarvasyon iptali
private void button20_Click(object sender, EventArgs e)
{
//eğer iptal etmek istediğimiz kişinin adı ile koltuğu alan kişi aynı kişiyse şartını veriyoruz
if (textBox3.Text == button1.Text)
{
//butonun textini boşaltıyoruz
button1.Text = "";
//butonun rengini yeşil yapıyoruz
this.button1.BackColor = System.Drawing.Color.Green;
// butonu aktif hale getiriyoruz
button1.Enabled = true;
//dolu koltuk sayısını 1 azaltıyoruz
i--;
//boş koltuk sayısını 1 arttırıyoruz
x++;
//dolu koltuk sayısını stringe çevirip labela atıyoruz
label3.Text = "Dolu: " + i.ToString();
//boş koltuk sayısını stringe çevirip labela atıyoruz
label4.Text = "Boş: " + x.ToString();
}
//aynı işlemleri diğerleri içinde yapıyoruz
if (textBox3.Text == button2.Text)
{
button2.Text = "";
this.button2.BackColor = System.Drawing.Color.Green;
button2.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button3.Text)
{
button3.Text = "";
this.button3.BackColor = System.Drawing.Color.Green;
button3.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button4.Text)
{
button4.Text = "";
this.button4.BackColor = System.Drawing.Color.Green;
button4.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button5.Text)
{
button5.Text = "";
this.button5.BackColor = System.Drawing.Color.Green;
button5.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button6.Text)
{
button6.Text = "";
this.button6.BackColor = System.Drawing.Color.Green;
button6.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button7.Text)
{
button7.Text = "";
this.button7.BackColor = System.Drawing.Color.Green;
button7.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button8.Text)
{
button8.Text = "";
this.button8.BackColor = System.Drawing.Color.Green;
button8.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button9.Text)
{
button9.Text = "";
this.button9.BackColor = System.Drawing.Color.Green;
button9.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button10.Text)
{
button10.Text = "";
this.button10.BackColor = System.Drawing.Color.Green;
button10.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button11.Text)
{
button11.Text = "";
this.button11.BackColor = System.Drawing.Color.Green;
button11.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button12.Text)
{
button12.Text = "";
this.button12.BackColor = System.Drawing.Color.Green;
button12.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button13.Text)
{
button13.Text = "";
this.button13.BackColor = System.Drawing.Color.Green;
button13.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button14.Text)
{
button14.Text = "";
this.button14.BackColor = System.Drawing.Color.Green;
button14.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button15.Text)
{
button15.Text = "";
this.button15.BackColor = System.Drawing.Color.Green;
button15.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button16.Text)
{
button16.Text = "";
this.button1.BackColor = System.Drawing.Color.Green;
button16.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button17.Text)
{
button17.Text = "";
this.button17.BackColor = System.Drawing.Color.Green;
button17.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}
if (textBox3.Text == button18.Text)
{
button18.Text = "";
this.button18.BackColor = System.Drawing.Color.Green;
button18.Enabled = true;
i--;
x++;
label3.Text = "Dolu: " + i.ToString();
label4.Text = "Boş: " + x.ToString();
}

}
}
}



PROJEYİ İNDİRMEK İÇİN TIKLAYINIZ !!

3 yorum:

  1. hoca eline sağlık ama çok uzun olmuş 3-4 for döngüsüyle bitirebilirdin olayı neyse

    YanıtlaSil
  2. hocam sımdı elımde bır otomasyon var ve formda olusturdugum grpupbax ıcındekı elemanlarından bırını daha once sectım dıyelım . Istedıgım form yuklendıgınde daha once sectıgım o eleman secılebılır olmasın. Program c # dılınde ve verıtabanına baglandıgım ıcın zorlanıyorum ,yardım edersenız muhtesem olur ,saygılar :)

    YanıtlaSil
  3. Error 1 The type or namespace name 'Form1' could not be found (are you missing a using directive or an assembly reference?) c:\users\user\documents\visual studio 2012\Projects\WindowsFormsApplication20\WindowsFormsApplication20\Program.cs 19 33 WindowsFormsApplication20
    hatası veriyo ne yapmalıyım

    YanıtlaSil