JavaScript
kod tam olarak bu
string dukkanAdi, dukkanAdresi, ilIlce, telNo, ePosta;
string tarih, MusteriTCKimlikNumarasi, MusteriAdisoyadi, TelefonNumarasi, EPostaAdresi, UrunAdi, Fiyat, Adres;
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
//tarih
System.Drawing.Font font = new System.Drawing.Font("Arial", 14);
SolidBrush firca = new SolidBrush(Color.Black);
e.Graphics.DrawString(DateTime.Now.ToShortDateString(), font, firca, 677, 168);
//dükkan adı
Baglan();
OleDbCommand cmd = new OleDbCommand("select * from tblDukkan", bagla);
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
dukkanAdi = Convert.ToString(dr["DukkanAdi"]);
dukkanAdresi = Convert.ToString(dr["DukkanAdresi"]);
ilIlce = Convert.ToString(dr["DukkanIlIlce"]);
ePosta = Convert.ToString(dr["DukkanEPosta"]);
telNo = Convert.ToString(dr["DukkanTelefonNumarasi"]);
}
dr.Close();
//----------------------------------
string musteri = cmbMusteriAdiSoyadi.Text;
OleDbCommand cmd2 = new OleDbCommand("select * from tblSatisYap where MusteriAdisoyadi= '" + cmbMusteriAdiSoyadi.Text + "'", bagla);
OleDbDataReader dr2 = cmd2.ExecuteReader();
while (dr2.Read())
{
tarih = Convert.ToString(dr2["Tarih"]);
MusteriAdisoyadi = Convert.ToString(dr2["MusteriAdisoyadi"]);
MusteriTCKimlikNumarasi = Convert.ToString(dr2["MusteriTCKimlikNumarasi"]);
Adres = Convert.ToString(dr2["Adres"]);
TelefonNumarasi = Convert.ToString(dr2["TelefonNumarasi"]);
EPostaAdresi = Convert.ToString(dr2["EPostaAdresi"]);
UrunAdi = Convert.ToString(dr2["UrunAdi"]);
Fiyat = Convert.ToString(dr2["Fiyat"]);
}
dr2.Close();
bagla.Close();
Pen kalem = new Pen(Color.Black);
font = new System.Drawing.Font("Segoe UI", 20, FontStyle.Bold);
#region başlık
/* //dikey çizgiler
e.Graphics.DrawLine(kalem, 50, 90, 780, 90);
e.Graphics.DrawLine(kalem, 50, 180, 780, 180);
//yatay çizgiler
e.Graphics.DrawLine(kalem, 50, 90, 50, 180);
e.Graphics.DrawLine(kalem, 780, 90, 780, 180);*/
#endregion
#region dükkan bilgileri
//dikey çizgiler
e.Graphics.DrawLine(kalem, 50, 190, 780, 190);
e.Graphics.DrawLine(kalem, 50, 550, 780, 550);
//yatay çizgiler
e.Graphics.DrawLine(kalem, 50, 190, 50, 550);
e.Graphics.DrawLine(kalem, 780, 190, 780, 550);
#endregion
#region Müşteri bilgileri
//dikey çizgiler
e.Graphics.DrawLine(kalem, 50, 560, 780, 560);
e.Graphics.DrawLine(kalem, 50, 845, 780, 845);
//yatay çizgiler
e.Graphics.DrawLine(kalem, 50, 560, 50, 845);
e.Graphics.DrawLine(kalem, 780, 560, 780, 845);
#endregion
#region Fatura bilgileri
//dikey çizgiler
e.Graphics.DrawLine(kalem, 50, 855, 780, 855);
e.Graphics.DrawLine(kalem, 50, 1080, 780, 1080);
//yatay çizgiler
e.Graphics.DrawLine(kalem, 50, 855, 50, 1080);
e.Graphics.DrawLine(kalem, 780, 855, 780, 1080);
#endregion
e.Graphics.DrawString(dukkanAdi, font, firca, 250, 100);
e.Graphics.DrawImage(Image.FromFile("logo.png"), 60, 70, 90, 90);
font = new System.Drawing.Font("Segoe UI", 18);
e.Graphics.DrawString(telNo, font, firca, 340, 135);
font = new System.Drawing.Font("Arial", 15, FontStyle.Bold);
e.Graphics.DrawString("Dükkan Adı:", font, firca, 60, 200);
e.Graphics.DrawString("Dükkan Telefon Numarası:", font, firca, 60, 270);
e.Graphics.DrawString("Dükkan E - Posta:", font, firca, 60, 340);
e.Graphics.DrawString("Dükkan Adres:", font, firca, 60, 410);
e.Graphics.DrawString("Dükkan İl İlçe:", font, firca, 60, 480);
e.Graphics.DrawString("Müşteri TC Kimlik Numarası:", font, firca, 60, 570);
e.Graphics.DrawString("Müşteri Adı Soyadı:", font, firca, 60, 640);
e.Graphics.DrawString("Müşteri Adres:", font, firca, 60, 710);
e.Graphics.DrawString("Müşteri Telefon Numarası:", font, firca, 60, 780);
e.Graphics.DrawString("Fatura Tarihi:", font, firca, 60, 870);
e.Graphics.DrawString("Ürün Adı:", font, firca, 60, 940);
e.Graphics.DrawString("Fiyatı:", font, firca, 60, 1010);
//------------------------
if (tarih == "") { }
DateTime dtarih = Convert.ToDateTime(tarih);
font = new System.Drawing.Font("Arial", 15);
e.Graphics.DrawString(dukkanAdi, font, firca, 75, 235);
e.Graphics.DrawString(telNo, font, firca, 75, 305);
e.Graphics.DrawString(ePosta, font, firca, 75, 375);
e.Graphics.DrawString(dukkanAdresi, font, firca, 75, 445);
e.Graphics.DrawString(ilIlce, font, firca, 75, 515);
e.Graphics.DrawString(MusteriTCKimlikNumarasi, font, firca, 75, 605);
e.Graphics.DrawString(MusteriAdisoyadi, font, firca, 75, 675);
e.Graphics.DrawString(Adres, font, firca, 75, 745);
e.Graphics.DrawString(TelefonNumarasi, font, firca, 75, 815);
e.Graphics.DrawString(dtarih.ToShortDateString(), font, firca, 75, 905);
e.Graphics.DrawString(UrunAdi, font, firca, 75, 975);
e.Graphics.DrawString(Fiyat + " Türk Lirası", font, firca, 75, 1045);
}
private void btnFaturaAl_Click(object sender, EventArgs e, string _name)
{
try
{
printPreviewDialog1.Show();
}
catch (Exception hata)
{
MessageBox.Show(hata.Message, "Hata!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
printDocument1.Dispose();
}
}