22-07-13, 06:31 AM
السلام عليكم ورحمة الله
هذا الكود يعمل كويس جدا وتظهر الداتا كما اريد وعند عمل معلينة قبل الطباعة يتم عرض الفاتورة كويس جدا جدا ولكن عند الضغط على طباعة لا يتم طباعة سوى اخر صفحة فى الفواتير بالرغم من ظهور الصفحات كاملة امامى فى المعاينة
برجاء مراجعة الكود
هذا الكود يعمل كويس جدا وتظهر الداتا كما اريد وعند عمل معلينة قبل الطباعة يتم عرض الفاتورة كويس جدا جدا ولكن عند الضغط على طباعة لا يتم طباعة سوى اخر صفحة فى الفواتير بالرغم من ظهور الصفحات كاملة امامى فى المعاينة
برجاء مراجعة الكود
كود :
'اتجاة النص يمين
Dim fr As New StringFormat(StringFormatFlags.DirectionRightToLeft)
'نوع الخط وحجم الخط واللون
Dim f88 As Font = New System.Drawing.Font("Arial", 9, FontStyle.Bold)
Dim f12 As Font = New System.Drawing.Font("Arial", 12, FontStyle.Bold)
Dim f As Font = New System.Drawing.Font("Arial", 13, FontStyle.Bold)
Dim f18 As Font = New System.Drawing.Font("Arial", 18, FontStyle.Bold)
Dim f182 As Font = New System.Drawing.Font("Blackadder ITC", 18, FontStyle.Bold)
Dim f22 As Font = New System.Drawing.Font("Times New Roman", 22, FontStyle.Bold, FontStyle.Italic, FontStyle.Underline)
Dim f28 As Font = New System.Drawing.Font("Arial", 24, FontStyle.Bold)
Dim f282 As Font = New System.Drawing.Font("Algerian", 24, FontStyle.Bold)
e.Graphics.DrawImage(Form1.PictureBox2.Image, 110, 250, 600, 600)
'البيانات الاساسية للمدرسة أعلى الصفحة
e.Graphics.DrawString("جمعية تحسين الصحة بشربين", f28, Brushes.Black, 790, 40, fr)
e.Graphics.DrawString("(معمل التحاليل الطبية)", f28, Brushes.Black, 750, 80, fr)
e.Graphics.DrawImage(Form1.PictureBox1.Image, 50, 30, 150, 120)
e.Graphics.DrawLine(Pens.Black, 50, 150, 777, 150)
e.Graphics.DrawLine(Pens.Black, 50, 153, 777, 153)
e.Graphics.DrawString("الاســـــــم" + " /" + name_pat.Text, f, Brushes.Black, 790, 160, fr)
If name_dr.Text = "----------" Then
e.Graphics.DrawString("" + "", f, Brushes.Black, 790, 180, fr)
Else
e.Graphics.DrawString("اسم الطبيب " + " " + name_dr.Text, f, Brushes.Black, 790, 180, fr)
End If
e.Graphics.DrawString("الكود" + " " + id_pp.Text, f, Brushes.Black, 200, 160, fr)
e.Graphics.DrawString("التاريخ" + " " + dates.Text, f, Brushes.Black, 200, 180, fr)
e.Graphics.DrawString(" رقم الزيارة" + " " + "/ " + no1s.Text, f, Brushes.Black, 450, 170, fr)
Dim mypen As New Pen(Color.Black, 4)
e.Graphics.DrawLine(mypen, 50, 220, 777, 220)
e.Graphics.DrawString(ComboBox1.Text, f282, Brushes.Black, 250, 250)
'رسم جدول
e.Graphics.DrawRectangle(mypen, 50, 312, 727, 617)
e.Graphics.DrawRectangle(mypen, 50, 312, 727, 50)
e.Graphics.DrawString("Thanks", f22, Brushes.Black, 550, 960)
e.Graphics.DrawString("Dr." + " " + Form1.User_labdata1.tx_2.Text, f18, Brushes.Black, 500, 990)
e.Graphics.DrawLine(Pens.Black, 50, 1030, 777, 1030)
e.Graphics.DrawLine(Pens.Black, 50, 1033, 777, 1033)
e.Graphics.DrawString(Form1.User_labdata1.tx_3.Text, f18, Brushes.Black, 660, 1050, fr)
' رسم الصفوف وتحديد بداية الصفوف ونهايتها من قسم ارتفاع الجدول على عدد الصفوف
' رسم الاعمدة
'Cplams
e.Graphics.DrawLine(mypen, 530, 312, 530, 930)
e.Graphics.DrawLine(mypen, 400, 312, 400, 930)
'رؤوس الاعمدة
e.Graphics.DrawString("Normal Range", f18, Brushes.Blue, 550, 330)
e.Graphics.DrawString("Result", f18, Brushes.Blue, 430, 330)
e.Graphics.DrawString("Test name", f18, Brushes.Blue, 200, 330)
Dim y As Integer = 362
For x As Integer = RowNo To DGV.Rows.Count
Dim yElement As Integer = 375 + y - 375
Dim x4 As Integer
Dim xl As Long
xl = Len(DGV.Rows(x - 1).Cells(2).Value.ToString())
x4 = xl / 37
x4 = x4 + 1
x4 = x4 * 20
Dim yE As Integer = x4 + yElement - y
Dim ye2 As Integer = yE / 3
If x4 >= "50" Then
e.Graphics.DrawString(DGV.Rows(x - 1).Cells(0).Value.ToString(), f18, Brushes.Black, 65, yElement)
e.Graphics.DrawString(DGV.Rows(x - 1).Cells(1).Value.ToString(), f18, Brushes.Black, 420, yElement)
e.Graphics.DrawString(DGV.Rows(x - 1).Cells(2).Value.ToString(), f88, Brushes.Black, 535, yElement)
e.Graphics.DrawLine(Pens.Black, 50, yElement, 777, yElement)
y += x4
Else
e.Graphics.DrawString(DGV.Rows(x - 1).Cells(0).Value.ToString(), f18, Brushes.Black, 65, yElement + ye2)
e.Graphics.DrawString(DGV.Rows(x - 1).Cells(1).Value.ToString(), f18, Brushes.Black, 420, yElement + ye2)
e.Graphics.DrawString(DGV.Rows(x - 1).Cells(2).Value.ToString(), f88, Brushes.Black, 535, yElement + 5)
e.Graphics.DrawLine(Pens.Black, 50, yElement, 777, yElement)
y += 40
End If
If yElement >= "700" Then
RowNo += 1
e.HasMorePages = True
Exit For
Else
RowNo += 1
End If
x += 1
y += 40
Next