You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
3.7 KiB
142 lines
3.7 KiB
|
|
Imports System.Data.SqlClient
|
|
Imports System.Data.SqlDbType
|
|
|
|
Public Class clsprinter
|
|
|
|
Dim m_Defaultprintername As String
|
|
Property DefaultPrinterName As String
|
|
Get
|
|
Return m_Defaultprintername
|
|
End Get
|
|
Set(value As String)
|
|
m_Defaultprintername = value
|
|
End Set
|
|
End Property
|
|
|
|
Dim m_duplexmode As String
|
|
Property DuplexMode As String
|
|
Get
|
|
Return m_duplexmode
|
|
End Get
|
|
Set(value As String)
|
|
m_duplexmode = value
|
|
End Set
|
|
End Property
|
|
|
|
Dim m_color As String
|
|
Property Color As String
|
|
Get
|
|
Return m_color
|
|
End Get
|
|
Set(value As String)
|
|
m_color = value
|
|
End Set
|
|
End Property
|
|
|
|
Sub New()
|
|
Get_Default_Printer()
|
|
Get_Duplex_Mode()
|
|
Get_Colormode()
|
|
End Sub
|
|
|
|
Public Sub Restore_Defaults()
|
|
'Get_Duplex_Mode()
|
|
Set_Duplex_Mode()
|
|
'Set_Colormode()
|
|
|
|
End Sub
|
|
Public Function Get_Default_Printer() As String
|
|
Dim oPS As New System.Drawing.Printing.PrinterSettings
|
|
|
|
Try
|
|
Me.DefaultPrinterName = oPS.PrinterName
|
|
Return oPS.PrinterName
|
|
|
|
Catch ex As System.Exception
|
|
Return ""
|
|
Finally
|
|
oPS = Nothing
|
|
End Try
|
|
End Function
|
|
|
|
Public Function Get_Colormode()
|
|
Dim printdoc As New System.Drawing.Printing.PrintDocument
|
|
printdoc.PrinterSettings.PrinterName = Me.DefaultPrinterName
|
|
Me.Color = printdoc.DefaultPageSettings.Color
|
|
End Function
|
|
|
|
Public Function Set_Colormode()
|
|
Dim printdoc As New System.Drawing.Printing.PrintDocument
|
|
printdoc.PrinterSettings.PrinterName = Me.DefaultPrinterName
|
|
printdoc.DefaultPageSettings.Color = Me.Color
|
|
|
|
End Function
|
|
Public Function Get_Duplex_Mode() As String
|
|
Dim oPS As New System.Drawing.Printing.PrinterSettings
|
|
oPS.PrinterName = Me.DefaultPrinterName
|
|
Try
|
|
Globals.Duplexmode = oPS.Duplex
|
|
Me.DuplexMode = oPS.Duplex
|
|
Return oPS.Duplex
|
|
|
|
Catch ex As Exception
|
|
Return Nothing
|
|
Finally
|
|
oPS = Nothing
|
|
End Try
|
|
|
|
End Function
|
|
|
|
Public Function Set_Duplex_Mode()
|
|
Dim Printdoc As New Printing.PrintDocument
|
|
|
|
Dim SetPage As New System.Drawing.Printing.PageSettings
|
|
|
|
With SetPage
|
|
|
|
|
|
|
|
.PrinterSettings.Duplex = Me.DuplexMode
|
|
|
|
|
|
End With
|
|
|
|
Printdoc.DefaultPageSettings = SetPage
|
|
|
|
|
|
End Function
|
|
|
|
Public Function Reset_Douplex_Settings()
|
|
If Globals.Reset_Printer_Duplex_Settings = 0 Then Globals.Reset_Printer_Duplex_Settings = Get_Reset_Duplex_Settings()
|
|
If Globals.Reset_Printer_Duplex_Settings = 1 Then Set_Duplex_Mode()
|
|
End Function
|
|
|
|
Public Function Get_Reset_Duplex_Settings() As Integer
|
|
Dim scmCmdToExecute As SqlCommand = New SqlCommand()
|
|
Dim i As Integer
|
|
Dim connopen As Boolean = False
|
|
scmCmdToExecute.CommandText = "dbo.[sp_get_reset_duplex_settings]"
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
scmCmdToExecute.Connection = conn.scoDBConnection
|
|
Try
|
|
scmCmdToExecute.Parameters.Add(New SqlParameter("@Resultat", SqlDbType.Int, 4, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, 0))
|
|
Try
|
|
scmCmdToExecute.Connection.Open()
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
scmCmdToExecute.ExecuteNonQuery()
|
|
Return scmCmdToExecute.Parameters("@Resultat").Value
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
|
|
scmCmdToExecute.Connection.Close()
|
|
scmCmdToExecute.Dispose()
|
|
End Try
|
|
End Function
|
|
|
|
End Class
|
|
|