Mrb arkadaşlar, basit bir öğrenci otomasyon programında Rapor Ver diye bir form var. Ve bu forumda butona basıldığında Ogretmenler, Öğrenciler, Dersler, Sınıflar class'larındaki bilgilerin print edilmesi gerekiyor. Ama buna benzer bi kod örneği göremedim. Kodlar:
sing System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections;
namespace OgrenciTakip { [Serializable] class Ogrenci { public int OgrenciId { get; set; } public string Adi { get; set; } public string Soyadi { get; set; } public List<Ders> Dersleri { get; set; }
public static List<Ogrenci> TumOgrenciler = new List<Ogrenci>();
public override string ToString() { return Adi + " " + Soyadi; } }
[Serializable] class Ders { static int sayac = 0; public int DersId { get; set; } public string DersAdi { get; set; } public Sinif Sinifi { get; set; }
public static List<Ders> TumDersler = new List<Ders>();
[Serializable] class Sinif { static int sayac = 0; public int SinifId { get; set; } public string Adi { get; set; }
public static List<Sinif> TumSiniflar = new List<Sinif>();
public Sinif(string SinifAdi) { this.Adi = SinifAdi; this.SinifId = ++sayac; } public override string ToString() { return Adi; } }
[Serializable] class Ogretmen { static int sayac = 0; public int OgretmenId { get; set; } public string Adi { get; set; } public string Soyadi { get; set; } public Ders Dersi { get; set; }
public static List<Ogretmen> TumOgretmenler = new List<Ogretmen>();
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) { Font baslikFontu = new Font("Tahoma", 14); Font yaziFontu = new Font("Tahoma", 10);
float satirAdeti = e.MarginBounds.Height / yaziFontu.GetHeight(); int satir = 30; for (int i = sayac; i <Ders.TumDersler; i++) { Ders siradaki = Ders.TumDersler as Urun; e.Graphics.DrawString(siradaki.DersId, yaziFontu, Brushes.Black, 10, satir += Convert.ToInt32(yaziFontu.GetHeight())); e.Graphics.DrawString(siradaki.DersAdi, yaziFontu, Brushes.Blue, 240, satir); e.Graphics.DrawString(siradaki.Sinifi.Adi.ToString("C"), yaziFontu, Brushes.Black, 400, satir);
satir += Convert.ToInt32(yaziFontu.GetHeight());
if (i > 0 && i % (Convert.ToInt32(satirAdeti)) == 0) { satir = 30; sayac = i + 1; e.HasMorePages = true; break; } } }