Custom Paper Size Printing in VB.NET
Advance Printing using Ms-Access Database Setting with Schemes
For Custom Paper Size
Vb.net Source Code Part Two
Dim ImageValue As System.Drawing.Image
If PageNo = PageNos Then Dbf.Open("select * from PrintFieldLabels where schemename='" & PrintingScheme & "' ", Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) Else Dbf.Open("select * from PrintFieldLabels where schemename='" & PrintingScheme & "' and ltop<" & FooterTop, Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) End If ' Dbf.Open("select * from PrintFieldLabels where schemename='" & PrintingScheme & "' and ltop<" & FooterTop, Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) If Dbf.RecordCount > 0 Then Dim Sdbf As New ADODB.Recordset Sdbf.Open("select * from " & dbname & " where transcode=" & Transcode, Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) Dim Ldbf As New ADODB.Recordset Ldbf.Open("select * from ledgerdbf where sname='" & Sdbf.Fields("ledgername").Value & "'", Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) Dbf.MoveFirst() For i As Integer = 1 To Dbf.RecordCount Try Dbf.Fields("printtext").Value = Sdbf.Fields(Dbf.Fields("dbfield").Value).Value Dbf.Update() Catch ex As Exception Try Dbf.Fields("printtext").Value = Ldbf.Fields(Dbf.Fields("dbfield").Value).Value Dbf.Update() Catch ex2 As Exception End Try End Try Dbf.MoveNext() Next Sdbf.Close() Ldbf.Close() End If Dbf.Close() Dbf.Open("select * from printingsettings where schemename='" & PrintingScheme & "'", Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) If Dbf.RecordCount > 0 Then Try If Dbf.Fields("LeftLogoIsOn").Value = True Then ImageValue = Image.FromFile(Dbf.Fields("leftlogopath").Value) e.Graphics.DrawImage(ImageValue, CSng(Dbf.Fields("Leftlogoleft").Value), CSng(Dbf.Fields("leftlogotop").Value), CSng(Dbf.Fields("Leftlogowidth").Value), CSng(Dbf.Fields("Leftlogoheight").Value)) End If Catch ex As Exception End Try Try If Dbf.Fields("rightLogoIsOn").Value = True Then ImageValue = Image.FromFile(Dbf.Fields("rightlogopath").Value) e.Graphics.DrawImage(ImageValue, CSng(Dbf.Fields("rightlogoleft").Value), CSng(Dbf.Fields("rightlogotop").Value), CSng(Dbf.Fields("rightlogowidth").Value), CSng(Dbf.Fields("rightlogoheight").Value)) End If Catch ex As Exception End Try End If Dbf.Close() Dbf.Open("select * from PrintLables where schemename='" & PrintingScheme & "'", Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) If Dbf.RecordCount > 0 Then Dbf.MoveFirst() For i As Integer = 0 To Dbf.RecordCount - 1 If Dbf.Fields("IsVisible").Value = True Then Dim drawFormat As New StringFormat Dim drawFont As Font = New Font("arial", 10) Dim drawBrush As New SolidBrush(Color.FromName(Dbf.Fields("fontcolor").Value.ToString)) Select Case Dbf.Fields("fontstyle").Value Case 1 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Bold) Case 2 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Italic) Case 3 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Underline) Case 4 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Bold Or FontStyle.Italic) Case 5 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Bold Or FontStyle.Underline) Case 6 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Italic Or FontStyle.Underline) Case 7 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Bold Or FontStyle.Italic Or FontStyle.Underline) Case 8 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Regular) End Select If Dbf.Fields("align").Value = "Left" Then drawFormat.Alignment = StringAlignment.Near ElseIf Dbf.Fields("align").Value = "Right" Then drawFormat.Alignment = StringAlignment.Far Else drawFormat.Alignment = StringAlignment.Center End If e.Graphics.DrawString(Dbf.Fields("labletext").Value.ToString, drawFont, drawBrush, CSng(Dbf.Fields("left").Value), CSng(Dbf.Fields("top").Value), drawFormat) End If Dbf.MoveNext() Next End If Dbf.Close() Dbf.Open("select * from printheadings where schemename='" & PrintingScheme & "'", Conn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic) If Dbf.RecordCount > 0 Then Dbf.MoveFirst() For i As Integer = 0 To Dbf.RecordCount - 1 If Dbf.Fields("IsVisible").Value = True Then Dim drawFormat As New StringFormat Dim drawFont As Font = New Font("arial", 10) Dim drawBrush As New SolidBrush(Color.FromName(Dbf.Fields("fontcolor").Value.ToString)) Select Case Dbf.Fields("fontstyle").Value Case 1 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Bold) Case 2 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Italic) Case 3 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Underline) Case 4 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Bold Or FontStyle.Italic) Case 5 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Bold Or FontStyle.Underline) Case 6 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Italic Or FontStyle.Underline) Case 7 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Bold Or FontStyle.Italic Or FontStyle.Underline) Case 8 drawFont = New Font(Dbf.Fields("Fontname").Value.ToString, CSng(Dbf.Fields("fontsize").Value), FontStyle.Regular) End Select If Dbf.Fields("align").Value = "Left" Then drawFormat.Alignment = StringAlignment.Near ElseIf Dbf.Fields("align").Value = "Right" Then drawFormat.Alignment = StringAlignment.Far Else drawFormat.Alignment = StringAlignment.Center End If e.Graphics.DrawString(Dbf.Fields("HeadText").Value.ToString, drawFont, drawBrush, CSng(Dbf.Fields("left").Value), CSng(Dbf.Fields("top").Value), drawFormat) End If Dbf.MoveNext() Next End If Dbf.Close() |
For POS System in VB.NET Source Code: Please Contact :Sureshjyothijv@gmail.com |