kodlayamadikabi
Femtopat
- Katılım
- 28 Ekim 2020
- Mesajlar
- 38
Merhaba arkadaşlar, kodlarım aşağıdaki gibi görünürde bir hata yok. Çalıştırdığım zaman ad soyad veya diğer kısımları boş bırakıyorum ve hata veriyor nasıl düzeltebilirim. Hatam tam olarak nerde?
Kod:
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;
using System.IO;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
string[] dersler = { "NESNE TABANLI PROGRAMLAMA", "GÖRSEL PROGRAMLAMA", "YAZILIM MİMARİLERİ", "MULTİMEDYA UYGULAMALARI", "BİLGİSAYAR DONANIMI" };
comboBox1.Items.AddRange(dersler);
}
Int32 vize;
Int32 final;
DialogResult kayit;
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("LÜTFEN ADINIZI GİRİNİZ ! ");
textBox1.Focus();
textBox1.BackColor = Color.Yellow;
}
if (textBox2.Text == "")
{
MessageBox.Show("LÜTFEN SOYADINIZI GİRİNİZ ! ");
textBox2.Focus();
textBox2.BackColor = Color.Yellow;
}
if (comboBox1.SelectedIndex == -1)
{
MessageBox.Show("LÜTFEN DERS SEÇİMİ YAPINIZ ! ");
}
vize = Convert.ToInt32(textBox3.Text);
final = Convert.ToInt32(textBox4.Text);
Int32 ort = Convert.ToInt32(vize * 0.4 + final * 0.6);
if (textBox3.Text == "")
{
MessageBox.Show("LÜTFEN VİZE NOTUNUZU GİRİNİZ ! ");
textBox3.Focus();
textBox3.BackColor = Color.Yellow;
}
if (textBox4.Text == "")
{
MessageBox.Show("LÜTFEN FİNAL NOTUNUZU GİRİNİZ ! ");
textBox4.Focus();
textBox4.BackColor = Color.Yellow;
}
if (vize+final < 0 || vize+final > 100)
{
MessageBox.Show("VİZE VEYA FİNAL NOTUNUZU YANLIŞ GİRDİNİZ!! \n LÜTFEN 0-100 ARASINDA BİR DEĞER GİRİNİZ!");
textBox3.Clear();
textBox4.Clear();
textBox3.Focus();
}
else
{
label6.Text = "ORTALAMA = " + ort;
}
kayit = MessageBox.Show(textBox1.Text + " " + textBox2.Text + " İSİMLİ ÖĞRENCİNİN BİLGİLERİ KAYDEDİLSİN Mİ ?", "KAYIT",
MessageBoxButtons.YesNo);
if (kayit == DialogResult.Yes)
{
StreamWriter yazdir;
yazdir = File.AppendText("bilgiler.txt");
yazdir.Write(textBox1.Text + " ");
yazdir.Write(textBox2.Text + " ");
yazdir.Write(comboBox1.SelectedItem + " ");
yazdir.Write(textBox3.Text + " ");
yazdir.Write(textBox4.Text + " ");
yazdir.WriteLine(label6.Text);
yazdir.Close();
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
label6.Text = "";
comboBox1.SelectedItem =null;
}
else
{
MessageBox.Show("KAYIT İŞLEMİNDEN VAZGEÇİLDİ");
}
}
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar > 65 || e.KeyChar < 90 && e.KeyChar == 8)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
if (e.KeyChar == 13)
textBox2.Focus();
}
private void textBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar > 65 || e.KeyChar < 90 && e.KeyChar == 8)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
if (e.KeyChar == 13)
comboBox1.Focus();
}
private void comboBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 13)
textBox3.Focus();
}
private void textBox3_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar >= 45 && e.KeyChar <= 57 || e.KeyChar == 8)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
if (e.KeyChar == 13)
textBox4.Focus();
}
private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar >= 45 && e.KeyChar <= 57 || e.KeyChar == 8)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
if (e.KeyChar == 13)
button1.Focus();
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
}
}
Dosya Ekleri
Son düzenleyen: Moderatör: