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 _10A_2dnm1snvahazirlik { public partial class Form1 : Form { public Form1() { InitializeComponent(); } SaveFileDialog sfd = new SaveFileDialog(); PrintDialog pd = new PrintDialog(); ErrorProvider ep = new ErrorProvider(); private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { e.Graphics.DrawString(richTextBox1.Text, richTextBox1.Font,Brushes.Black, new Point(100, 100)); } private void button1_Click(object sender, EventArgs e) { int sonuc; string adSoyad = textBox1.Text; int not1 = Convert.ToInt32(textBox2.Text); int not2 = Convert.ToInt32(textBox3.Text); int not3 = Convert.ToInt32(textBox4.Text); int not4 = Convert.ToInt32(textBox5.Text); sonuc = not1 + not2 + not3 + not4; sonuc = sonuc / 4; richTextBox1.Text = "Ad Soyad " + adSoyad + " Not " + sonuc.ToString(); } private void button2_Click(object sender, EventArgs e) { sfd.Filter = "Yazı Dosyaları|*.txt*"; sfd.ShowDialog(); } private void button3_Click(object sender, EventArgs e) { DialogResult cevap = pd.ShowDialog(); if (cevap == DialogResult.OK) { printDocument1.Print(); } } private void textBox2_Validating(object sender, CancelEventArgs e) { int dersnotu; if (int.TryParse(textBox2.Text, out dersnotu)) { if (dersnotu < 0 || dersnotu > 100) { ep.SetError(textBox2, "0-100 arasında değer giriniz"); } else { ep.SetError(textBox2, ""); } } else { ep.SetError(textBox2, "Sayısal değer giriniz."); } } private void textBox3_Validating(object sender, CancelEventArgs e) { int dersnotu; if (int.TryParse(textBox3.Text, out dersnotu)) { if (dersnotu < 0 || dersnotu > 100) { ep.SetError(textBox3, "0-100 arasında değer giriniz"); } else { ep.SetError(textBox3, ""); } } else { ep.SetError(textBox3, "Sayısal değer giriniz."); } } private void textBox4_Validating(object sender, CancelEventArgs e) { int dersnotu; if (int.TryParse(textBox4.Text, out dersnotu)) { if (dersnotu < 0 || dersnotu > 100) { ep.SetError(textBox4, "0-100 arasında değer giriniz"); } else { ep.SetError(textBox4, ""); } } else { ep.SetError(textBox4, "Sayısal değer giriniz."); } } private void textBox5_Validating(object sender, CancelEventArgs e) { int dersnotu; if (int.TryParse(textBox5.Text, out dersnotu)) { if (dersnotu < 0 || dersnotu > 100) { ep.SetError(textBox4, "0-100 arasında değer giriniz"); } else { ep.SetError(textBox5, ""); } } else { ep.SetError(textBox5, "Sayısal değer giriniz."); } } } }