MS Parameter

This commit is contained in:
2020-09-11 13:52:51 +02:00
parent c075475cdc
commit 3e687df072
7 changed files with 78 additions and 63 deletions

View File

@@ -3,6 +3,7 @@ Imports DigitalData.Modules.Database
Imports System.IO
Imports System.ComponentModel
Imports GdPicture14
Imports DevExpress.DataAccess.Sql
Public Class Form1
Dim MyLogger As LogConfig
@@ -65,7 +66,7 @@ Public Class Form1
oDocID = oRow.Item(0).ToString
Dim oSQL = $"select count(*) from VWCUST_RPTPM_INV_RPT_STAMP_CHECK WHERE docID = {oDocID.ToString}"
If MySQLSDB.GetScalarValue(oSQL) >= 1 Then
Create_Report(oDocID.ToString, 0)
Create_EB_Report(oDocID.ToString, 0)
Else
Logger.Info($"ATTENTION - No FinalFreigabe for DocID: {oDocID.ToString}")
Dim oDELETE = $"DELETE FROM TBCUST_PM_RPT_2BCREATED WHERE DocID = {oDocID} AND GEN_ID = '{My.Settings.GEN_ID}'"
@@ -86,11 +87,11 @@ Public Class Form1
End Sub
Sub Create_Report(pDocID As String, ReportOption As Integer)
Sub Create_EB_Report(pDocID As String, ReportOption As Integer)
MyFreigabebericht = ""
MyStempel = ""
MyOriginStamped = ""
Logger.Info($"Trying to create report for DocID: {pDocID}...")
Logger.Info($"#### Trying to Create_Report for DocID: {pDocID}... ####")
Dim errortext As String
Try
If DEBUG = True Then
@@ -105,14 +106,29 @@ Public Class Form1
Exit Sub
End Try
Try
Dim report As New XtraReport2()
report.ReportPrintOptions.PrintOnEmptyDataSource = False
report.FilterString = "DocID = " + pDocID
'report.ObjectDataSource1.Parameters(0).Value = Convert.ToInt64(TextBox1.Text)
report.CreateDocument(False)
If DEBUG = True Then
DocumentViewer1.DocumentSource = report
End If
Dim oReport As New XtraReport2()
Dim oDatasource As SqlDataSource = oReport.DataSource
Dim oSelectQuery As CustomSqlQuery = oDatasource.Queries(0)
Dim oParameter As QueryParameter = oSelectQuery.Parameters(0)
oParameter.Value = pDocID
Try
oReport.ReportPrintOptions.PrintOnEmptyDataSource = False
oReport.FilterString = "DocID = " + pDocID
'report.ObjectDataSource1.Parameters(0).Value = Convert.ToInt64(TextBox1.Text)
oReport.CreateDocument(False)
If DEBUG = True Then
DocumentViewer1.DocumentSource = oReport
End If
Catch ex As Exception
Dim oUpdate = $"DELETE FROM TBCUST_PM_RPT_2BCREATED WHERE DocID = {pDocID} AND GEN_ID = '{My.Settings.GEN_ID}'"
MySQLSDB.ExecuteNonQuery(oUpdate)
If DEBUG = True Then
MsgBox("Unexpected error in XtraReport2 Create", MsgBoxStyle.Critical, "Error in XtraReport2:")
End If
Logger.Warn($"Unexpected Error in XtraReport2 Create for DocID: {pDocID} - ERROR: {ex.Message}")
Exit Sub
End Try
Dim oMyErgebnisbericht As String = Path.Combine(My.Settings.CONCAT_TEMPFolder, pDocID & "_ERPT.pdf")
If File.Exists(oMyErgebnisbericht) Then
@@ -125,7 +141,7 @@ Public Class Form1
Exit Sub
End Try
End If
report.ExportToPdf(oMyErgebnisbericht)
oReport.ExportToPdf(oMyErgebnisbericht)
If File.Exists(oMyErgebnisbericht) Then
If ReportOption = 1 Then
@@ -142,7 +158,6 @@ Public Class Form1
If Not IsNothing(oOriginFile) Then
If File.Exists(My.Settings.Path2PDFTK) Then
If Create_MyStempel(DEBUG, pDocID) = True Then
'Jetzt Stempeln des OriginakBeleges mit dem Stamp-Report
Dim oStampedResult = CreateStampedPDF(oOriginFile, pDocID)
@@ -156,10 +171,15 @@ Public Class Form1
Dim oInsert = $"INSERT INTO TBCUST_PM_RPT_CREATED (DocID) VALUES ({Convert.ToInt64(pDocID)})"
MySQLSDB.ExecuteNonQuery(oInsert)
End If
Logger.Info($"Concatted file [{oStampedResult}] created!")
Logger.Info($"#### Created Ergebnisbericht for [{pDocID}]! #####")
Logger.Info($"")
End If
Else
Logger.Info("!!CreateStampedPDF = False or ""!!")
End If
Else
Logger.Info("!!Create_MyStempel = False!!")
End If
End If
Else
@@ -182,7 +202,8 @@ Public Class Form1
MsgBox(errortext, MsgBoxStyle.Critical, "Error in 2:")
Clipboard.SetText(errortext)
End If
Logger.Error(ex)
Logger.Warn($"Unexpected Error in Create_Report for DocID: {pDocID} - ERROR: {ex.Message}")
End Try
End Sub
Private Function Create_MyStempel(istest As Boolean, pDocID As String)
@@ -204,8 +225,14 @@ Public Class Form1
End Try
Try
Dim myReport As New RptStampIcon()
Dim oDatasource As SqlDataSource = myReport.DataSource
Dim oSelectQuery As CustomSqlQuery = oDatasource.Queries(0)
Dim oParameter As QueryParameter = oSelectQuery.Parameters(0)
oParameter.Value = pDocID
myReport.ReportPrintOptions.PrintOnEmptyDataSource = False
myReport.FilterString = "DocID = " + pDocID
'report.ObjectDataSource1.Parameters(0).Value = Convert.ToInt64(TextBox1.Text)
myReport.CreateDocument(False)
If istest = True Then
@@ -233,7 +260,7 @@ Public Class Form1
If File.Exists(oTempStempel) Then
MyStempel = oTempStempel
Logger.Info($"Stampreport created for DocID: {pDocID}!")
Logger.Info($"...Stampreport created for DocID: {pDocID}!")
If istest = True Then
MsgBox($"Stampreport [{oTempStempel}] created for DocID [{pDocID}]!", MsgBoxStyle.Information)
End If
@@ -257,7 +284,7 @@ Public Class Form1
End Function
Private Function CreateStampedPDF(oOriginFile As String, pDocID As Integer)
Try
Logger.Info($"Trying to create stamp on OriginWMFile for DocID: {pDocID}...")
Logger.Info($"Trying to CreateStampedPDF for DocID: {pDocID}...")
Logger.Debug($"Now in CreateStampedPDF")
Dim myProcess As New Process
Dim ProcID
@@ -396,7 +423,7 @@ Public Class Form1
If txtDocID.Text = "" Then Exit Sub
DEBUG = True
MyLogger.Debug = True
Create_Report(txtDocID.Text, 0)
Create_EB_Report(txtDocID.Text, 0)
End Sub
Private Function Concat_Files(DocID As String, oOriginFile As String)
@@ -554,7 +581,7 @@ Public Class Form1
My.Settings.Save()
DEBUG = True
MyLogger.Debug = True
Create_Report(txtDocID.Text, 1)
Create_EB_Report(txtDocID.Text, 1)
End Sub
Private Sub ToolStripButton5_Click(sender As Object, e As EventArgs)
@@ -571,6 +598,10 @@ Public Class Form1
Private Sub ToolStripButton6_Click(sender As Object, e As EventArgs) Handles ToolStripButton6.Click
Dim report As New RptStampIcon()
Dim oDatasource As SqlDataSource = report.DataSource
Dim oSelectQuery As CustomSqlQuery = oDatasource.Queries(0)
Dim oParameter As QueryParameter = oSelectQuery.Parameters(0)
oParameter.Value = txtDocID.Text
report.ReportPrintOptions.PrintOnEmptyDataSource = False
report.FilterString = "DocID = " + txtDocID.Text
'report.DocID.Value = txtDocID.Text