From fecf98344efa1fd64c1bba59fbcb2d222bf22b1e Mon Sep 17 00:00:00 2001 From: Andreas Luxbauer Date: Mon, 20 Mar 2023 17:09:50 +0100 Subject: [PATCH] Printer Auswahl, ACtive Reports 15, .NET 4.8 + 64 Bit --- BONManager.sln | 13 +- BONManager/App.config | 10 +- BONManager/BONManager.vbproj | 102 ++++++++++-- BONManager/My Project/Application.Designer.vb | 6 +- BONManager/My Project/Application.myapp | 4 +- BONManager/My Project/Resources.Designer.vb | 47 +++--- BONManager/My Project/Settings.Designer.vb | 6 +- BONManager/My Project/app.manifest | 73 +++++++++ BONManager/My Project/licenses.licx | 4 +- BONManager/frmMain.Designer.vb | 70 +++++---- BONManager/frmMain.vb | 148 +++++++++++++----- 11 files changed, 360 insertions(+), 123 deletions(-) create mode 100644 BONManager/My Project/app.manifest diff --git a/BONManager.sln b/BONManager.sln index 8bf9ae0..eb58ddc 100644 --- a/BONManager.sln +++ b/BONManager.sln @@ -1,22 +1,31 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.40629.0 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "BONManager", "BONManager\BONManager.vbproj", "{9F3DB1DA-A40F-41AD-8B92-97692B1EFB28}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {9F3DB1DA-A40F-41AD-8B92-97692B1EFB28}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {9F3DB1DA-A40F-41AD-8B92-97692B1EFB28}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9F3DB1DA-A40F-41AD-8B92-97692B1EFB28}.Debug|x64.ActiveCfg = Debug|x64 + {9F3DB1DA-A40F-41AD-8B92-97692B1EFB28}.Debug|x64.Build.0 = Debug|x64 {9F3DB1DA-A40F-41AD-8B92-97692B1EFB28}.Release|Any CPU.ActiveCfg = Release|Any CPU {9F3DB1DA-A40F-41AD-8B92-97692B1EFB28}.Release|Any CPU.Build.0 = Release|Any CPU + {9F3DB1DA-A40F-41AD-8B92-97692B1EFB28}.Release|x64.ActiveCfg = Release|x64 + {9F3DB1DA-A40F-41AD-8B92-97692B1EFB28}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {287155E2-5E91-4D19-8CD4-3933A6A3C410} + EndGlobalSection EndGlobal diff --git a/BONManager/App.config b/BONManager/App.config index c0528be..bc4784e 100644 --- a/BONManager/App.config +++ b/BONManager/App.config @@ -1,12 +1,12 @@ - + - - + + - + - \ No newline at end of file + diff --git a/BONManager/BONManager.vbproj b/BONManager/BONManager.vbproj index b0e351c..b7cb986 100644 --- a/BONManager/BONManager.vbproj +++ b/BONManager/BONManager.vbproj @@ -11,10 +11,26 @@ BONManager 512 WindowsForms - v4.5 + v4.8 + + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true - AnyCPU + x64 true full true @@ -22,6 +38,7 @@ bin\Debug\ BONManager.xml 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + false AnyCPU @@ -48,23 +65,62 @@ bon.ico + + true + true + true + bin\Debug\ + BONManager.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + full + x64 + + + true + bin\x64\Release\ + BONManager.xml + true + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + pdbonly + x64 + true + + + true + + + 5A6BD29D23A7643243CD6EFA1FEF21BAF955E653 + + + LocalIntranet + + + true + + + My Project\app.manifest + - - - - True + + C:\Program Files (x86)\GrapeCity\ActiveReports 15\Tools\GrapeCity.ActiveReports.dll - - True + + C:\Program Files (x86)\GrapeCity\ActiveReports 15\Tools\GrapeCity.ActiveReports.Chart.dll - - True + + C:\Program Files (x86)\GrapeCity\ActiveReports 15\Tools\GrapeCity.ActiveReports.Core.Document.dll - - True + + C:\Program Files (x86)\GrapeCity\ActiveReports 15\Tools\GrapeCity.ActiveReports.Document.dll - - True + + C:\Program Files (x86)\GrapeCity\ActiveReports 15\Tools\GrapeCity.ActiveReports.Export.Image.dll + + + C:\Program Files (x86)\GrapeCity\ActiveReports 15\Tools\GrapeCity.ActiveReports.Viewer.Common.dll + + + C:\Program Files (x86)\GrapeCity\ActiveReports 15\Tools\GrapeCity.ActiveReports.Viewer.Win.dll @@ -139,6 +195,7 @@ True Application.myapp + True True @@ -179,7 +236,9 @@ frmMain.vb - + + Always + VbMyResourcesResXFileCodeGenerator Resources.Designer.vb @@ -191,6 +250,7 @@ + MyApplicationCodeGenerator Application.Designer.vb @@ -205,6 +265,18 @@ + + + False + Microsoft .NET Framework 4.8 %28x86 und x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/BONManager/My Project/licenses.licx b/BONManager/My Project/licenses.licx index 98d441c..5b6d191 100644 --- a/BONManager/My Project/licenses.licx +++ b/BONManager/My Project/licenses.licx @@ -1,2 +1,2 @@ -GrapeCity.ActiveReports.Viewer.Win.Viewer, GrapeCity.ActiveReports.Viewer.Win.v9, Version=9.1.2302.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff -GrapeCity.ActiveReports.SectionReport, GrapeCity.ActiveReports.v9, Version=9.1.2302.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff +GrapeCity.ActiveReports.SectionReport, GrapeCity.ActiveReports, Version=15.2.3.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff +GrapeCity.ActiveReports.Viewer.Win.Viewer, GrapeCity.ActiveReports.Viewer.Win, Version=15.2.3.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff diff --git a/BONManager/frmMain.Designer.vb b/BONManager/frmMain.Designer.vb index 28a6ca6..f5c0acc 100644 --- a/BONManager/frmMain.Designer.vb +++ b/BONManager/frmMain.Designer.vb @@ -24,7 +24,7 @@ Partial Class frmMain Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMain)) Me.pnl = New System.Windows.Forms.Panel() - Me.Label5 = New System.Windows.Forms.Label() + Me.Button3 = New System.Windows.Forms.Button() Me.txtRgId = New System.Windows.Forms.TextBox() Me.Button2 = New System.Windows.Forms.Button() Me.Button1 = New System.Windows.Forms.Button() @@ -41,7 +41,8 @@ Partial Class frmMain Me.lblErr_RgIdLeer = New System.Windows.Forms.Label() Me.lblErr_BtrgLeer = New System.Windows.Forms.Label() Me.lblErr_BonBetrag = New System.Windows.Forms.Label() - Me.Button3 = New System.Windows.Forms.Button() + Me.ComboBox1 = New System.Windows.Forms.ComboBox() + Me.Label5 = New System.Windows.Forms.Label() Me.pnl.SuspendLayout() Me.Panel1.SuspendLayout() Me.SuspendLayout() @@ -50,6 +51,7 @@ Partial Class frmMain ' Me.pnl.BackColor = System.Drawing.Color.White Me.pnl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle + Me.pnl.Controls.Add(Me.ComboBox1) Me.pnl.Controls.Add(Me.Button3) Me.pnl.Controls.Add(Me.Label5) Me.pnl.Controls.Add(Me.txtRgId) @@ -72,21 +74,22 @@ Partial Class frmMain Me.pnl.Size = New System.Drawing.Size(453, 208) Me.pnl.TabIndex = 0 ' - 'Label5 + 'Button3 ' - Me.Label5.AutoSize = True - Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.Label5.Location = New System.Drawing.Point(-32, 74) - Me.Label5.Name = "Label5" - Me.Label5.Size = New System.Drawing.Size(206, 31) - Me.Label5.TabIndex = 1 - Me.Label5.Text = "Rechnungs-Nr.:" - Me.Label5.Visible = False + Me.Button3.BackColor = System.Drawing.Color.WhiteSmoke + Me.Button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat + Me.Button3.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!) + Me.Button3.Location = New System.Drawing.Point(155, 136) + Me.Button3.Name = "Button3" + Me.Button3.Size = New System.Drawing.Size(79, 28) + Me.Button3.TabIndex = 15 + Me.Button3.Text = "ADMIN" + Me.Button3.UseVisualStyleBackColor = False ' 'txtRgId ' Me.txtRgId.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.txtRgId.Location = New System.Drawing.Point(180, 71) + Me.txtRgId.Location = New System.Drawing.Point(216, 28) Me.txtRgId.Name = "txtRgId" Me.txtRgId.Size = New System.Drawing.Size(100, 38) Me.txtRgId.TabIndex = 2 @@ -97,9 +100,9 @@ Partial Class frmMain Me.Button2.BackColor = System.Drawing.Color.WhiteSmoke Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.Button2.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!) - Me.Button2.Location = New System.Drawing.Point(6, 168) + Me.Button2.Location = New System.Drawing.Point(6, 136) Me.Button2.Name = "Button2" - Me.Button2.Size = New System.Drawing.Size(145, 28) + Me.Button2.Size = New System.Drawing.Size(143, 28) Me.Button2.TabIndex = 13 Me.Button2.Text = "Liste ausg. Bons" Me.Button2.UseVisualStyleBackColor = False @@ -109,10 +112,10 @@ Partial Class frmMain Me.Button1.BackColor = System.Drawing.Color.WhiteSmoke Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.Flat Me.Button1.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!) - Me.Button1.Location = New System.Drawing.Point(6, 136) + Me.Button1.Location = New System.Drawing.Point(6, 104) Me.Button1.Margin = New System.Windows.Forms.Padding(0) Me.Button1.Name = "Button1" - Me.Button1.Size = New System.Drawing.Size(145, 28) + Me.Button1.Size = New System.Drawing.Size(143, 28) Me.Button1.TabIndex = 12 Me.Button1.Text = "Bon Storno" Me.Button1.UseVisualStyleBackColor = False @@ -143,7 +146,7 @@ Partial Class frmMain ' Me.Label3.AutoSize = True Me.Label3.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.Label3.Location = New System.Drawing.Point(152, 80) + Me.Label3.Location = New System.Drawing.Point(156, 80) Me.Label3.Name = "Label3" Me.Label3.Size = New System.Drawing.Size(147, 31) Me.Label3.TabIndex = 6 @@ -153,7 +156,7 @@ Partial Class frmMain ' Me.Label2.AutoSize = True Me.Label2.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) - Me.Label2.Location = New System.Drawing.Point(62, 37) + Me.Label2.Location = New System.Drawing.Point(66, 37) Me.Label2.Name = "Label2" Me.Label2.Size = New System.Drawing.Size(237, 31) Me.Label2.TabIndex = 3 @@ -263,17 +266,24 @@ Partial Class frmMain Me.lblErr_BonBetrag.Text = "Der Bon-Betrag muss größer 0 sein!" Me.lblErr_BonBetrag.Visible = False ' - 'Button3 + 'ComboBox1 ' - Me.Button3.BackColor = System.Drawing.Color.WhiteSmoke - Me.Button3.FlatStyle = System.Windows.Forms.FlatStyle.Flat - Me.Button3.Font = New System.Drawing.Font("Microsoft Sans Serif", 10.0!) - Me.Button3.Location = New System.Drawing.Point(158, 168) - Me.Button3.Name = "Button3" - Me.Button3.Size = New System.Drawing.Size(76, 28) - Me.Button3.TabIndex = 15 - Me.Button3.Text = "ADMIN" - Me.Button3.UseVisualStyleBackColor = False + Me.ComboBox1.FormattingEnabled = True + Me.ComboBox1.Location = New System.Drawing.Point(6, 175) + Me.ComboBox1.Name = "ComboBox1" + Me.ComboBox1.Size = New System.Drawing.Size(228, 21) + Me.ComboBox1.TabIndex = 16 + ' + 'Label5 + ' + Me.Label5.AutoSize = True + Me.Label5.Font = New System.Drawing.Font("Microsoft Sans Serif", 20.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) + Me.Label5.Location = New System.Drawing.Point(4, 31) + Me.Label5.Name = "Label5" + Me.Label5.Size = New System.Drawing.Size(206, 31) + Me.Label5.TabIndex = 1 + Me.Label5.Text = "Rechnungs-Nr.:" + Me.Label5.Visible = False ' 'frmMain ' @@ -308,9 +318,9 @@ Partial Class frmMain Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents Label4 As System.Windows.Forms.Label Friend WithEvents Panel1 As System.Windows.Forms.Panel - Friend WithEvents Label5 As System.Windows.Forms.Label Friend WithEvents txtRgId As System.Windows.Forms.TextBox Friend WithEvents lblErr_RgIdLeer As System.Windows.Forms.Label Friend WithEvents Button3 As System.Windows.Forms.Button - + Friend WithEvents ComboBox1 As ComboBox + Friend WithEvents Label5 As Label End Class diff --git a/BONManager/frmMain.vb b/BONManager/frmMain.vb index 6290b09..a95564e 100644 --- a/BONManager/frmMain.vb +++ b/BONManager/frmMain.vb @@ -1,4 +1,5 @@ Imports System.Drawing.Printing +Imports GrapeCity.ActiveReports Public Class frmMain Public TESTSYSTEM As Boolean = False @@ -40,31 +41,56 @@ Public Class frmMain Me.Cursor = Cursors.WaitCursor Dim rpt As New rptBeleg - rpt.lblBetrag.Text = CDbl(bon.bon_betrag_Bon).ToString("C") rpt.lblAusstelldatum.Text = CDate(bon.bon_datum).ToShortDateString rpt.lblGueltigBis.Text = CDate(bon.bon_gueltigBis).ToShortDateString rpt.lblBonId.Text = bon.bon_Id rpt.lblRgId.Text = bon.bon_RgId - If printername = "" Then - initPrinterName() + printername = ComboBox1.Text + 'If printername = "" Then + ' MsgBox("Kein Drucker") + ' Exit Sub + ' ' initPrinterName() + 'End If + + If printername <> "" Then + rpt.Document.Printer.PrinterName = printername + Else + Dim p As New PrintDialog + If p.ShowDialog() = DialogResult.OK Then + printername = p.PrinterSettings.PrinterName + Else + rpt.Dispose() + End If End If - Dim print As New frmPrint - print.WindowState = FormWindowState.Minimized - print.Visible = False - AddHandler print.Viewer.LoadCompleted, Sub() - If printername <> "" Then print.Viewer.Document.Printer.PrinterName = printername - If Not print.Viewer.Print(False) Then - MsgBox("Problem beim Drucken.") - End If - print.Close() - End Sub + rpt.Run(False) + rpt.Document.Printer.PrinterSettings.Copies = 1 - print.Viewer.LoadDocument(rpt) - print.Viewer.ViewType = GrapeCity.Viewer.Common.Model.ViewType.Continuous - print.Show() + If Not rpt.Document.Print(False, False) Then + MsgBox("Problem beim Drucken.") + End If + rpt.Dispose() + + 'Dim print As New frmPrint + 'print.WindowState = FormWindowState.Minimized + 'print.Visible = False + 'AddHandler print.Viewer.LoadCompleted, Sub() + ' If printername <> "" Then + ' rpt.Document.Printer.PrinterName = printername + ' 'print.Viewer.Document.Printer.PrinterName = printername + ' End If + + ' If Not print.Viewer.Print(False) Then + ' MsgBox("Problem beim Drucken.") + ' End If + ' print.Close() + ' End Sub + + 'print.Viewer.LoadDocument(rpt) + 'print.Viewer.ViewType = GrapeCity.Viewer.Common.Model.ViewType.Continuous + 'print.Show() @@ -76,31 +102,32 @@ Public Class frmMain Me.WindowState = FormWindowState.Minimized End Sub - Sub initPrinterName() - Dim sPrinters As New ArrayList - For Each sPrinter As String In PrinterSettings.InstalledPrinters - sPrinters.Add(sPrinter) - 'MsgBox(sPrinter) - Next - ' Array sortieren - sPrinters.Sort() - Dim oPS As New System.Drawing.Printing.PrinterSettings - For i As Integer = 0 To sPrinters.Count - 1 - If sPrinters(i).ToString.Contains("EPSON") Then - 'MsgBox("EPSON!!!!") - printername = sPrinters(i) - End If - Next + 'Sub initPrinterName() + ' Dim sPrinters As New ArrayList + ' For Each sPrinter As String In PrinterSettings.InstalledPrinters + ' sPrinters.Add(sPrinter) + ' 'MsgBox(sPrinter) + ' Next + ' ' Array sortieren + ' sPrinters.Sort() + ' Dim oPS As New System.Drawing.Printing.PrinterSettings + ' For i As Integer = 0 To sPrinters.Count - 1 + ' If sPrinters(i).ToString.Contains("EPSON") Then + ' 'MsgBox("EPSON!!!!") + ' printername = sPrinters(i) + ' End If + ' Next - ' For Each printer In PrinterSettings.InstalledPrinters - 'If printer.ToString.Contains("EPSON") Then - 'print.Viewer.Document.Printer.PrinterName = printer - 'End If - ' Next - End Sub + ' ' For Each printer In PrinterSettings.InstalledPrinters + ' 'If printer.ToString.Contains("EPSON") Then + ' 'print.Viewer.Document.Printer.PrinterName = printer + ' 'End If + ' ' Next + 'End Sub Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles Me.Load - initPrinterName() + ' initPrinterName() + initDrucker(ComboBox1, "EPSON") Me.Location = New Point(My.Computer.Screen.WorkingArea.Width / 2 - (Me.Width / 2) - 100, My.Computer.Screen.WorkingArea.Height - Me.Height) End Sub @@ -128,4 +155,49 @@ Public Class frmMain frmAdminFunc.ShowDialog(Me) End If End Sub + + + Public Shared Sub initDrucker(cboPrinter As ComboBox, Optional srch As String = "", Optional usePRINTER_LIST As Boolean = True) + ' alle installierten Drucker ermitteln und + ' in in ein ArrayList-Objekt speichern + Dim sPrinters As ArrayList + sPrinters = New ArrayList + For Each sPrinter As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters + sPrinters.Add(sPrinter) + Next + + ' Array sortieren + sPrinters.Sort() + + ' jetzt alle Drucker in sortierter Reihenfolge in einer + ' ComboBox zur Auswahl anbieten + For i As Integer = 0 To sPrinters.Count - 1 + cboPrinter.Items.Add(sPrinters(i)) + Next + + If sPrinters.Count > 0 Then + cboPrinter.SelectedIndex = 0 + If srch <> "" Then + For Each i In cboPrinter.Items + If i.ToString.ToUpper.Contains(srch.ToUpper) Then + cboPrinter.SelectedItem = i + Exit Sub + End If + Next + End If + + + 'Standard-Drucker: + Dim oPS As New System.Drawing.Printing.PrinterSettings + For Each i In cboPrinter.Items + If i.ToString.ToUpper.Contains(oPS.PrinterName.ToUpper) Then ' If i.ToString = srchPrinter Then ' Contains, weil sonst \\dc02\ stört + cboPrinter.SelectedItem = i + Exit Sub + End If + Next + + End If + End Sub + + End Class