Gesamtsicherheiten: CSV Export

This commit is contained in:
2022-11-09 16:30:21 +01:00
parent e5d6b27caf
commit 06cb3c4599
3 changed files with 66 additions and 116 deletions

View File

@@ -117,6 +117,10 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\dll\ChillKat64\ChilkatDotNet47.dll</HintPath> <HintPath>..\..\..\dll\ChillKat64\ChilkatDotNet47.dll</HintPath>
</Reference> </Reference>
<Reference Include="ClosedXML, Version=0.95.4.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\ClosedXML.0.95.4\lib\net46\ClosedXML.dll</HintPath>
</Reference>
<Reference Include="com.esendex.sdk, Version=3.8.0.0, Culture=neutral, PublicKeyToken=9dceac28a20578e2, processorArchitecture=MSIL"> <Reference Include="com.esendex.sdk, Version=3.8.0.0, Culture=neutral, PublicKeyToken=9dceac28a20578e2, processorArchitecture=MSIL">
<HintPath>..\packages\esendex-dotnet-sdk.3.8.0\lib\net35\com.esendex.sdk.dll</HintPath> <HintPath>..\packages\esendex-dotnet-sdk.3.8.0\lib\net35\com.esendex.sdk.dll</HintPath>
</Reference> </Reference>

View File

@@ -1,5 +1,7 @@
Imports System.Reflection Imports System.Reflection
Imports SDL Imports SDL
Imports Spire.PdfViewer.Forms
Imports VERAG_PROG_ALLGEMEIN
Public Class frmGesamtsicherheitenMenuNEU Public Class frmGesamtsicherheitenMenuNEU
@@ -234,7 +236,7 @@ Public Class frmGesamtsicherheitenMenuNEU
csvexport(dgvListe) csvexport(dgvListe)
End Sub End Sub
Public Shared Function csvexport(quelldgv As DataGridView, Optional quelldgv2 As DataGridView = Nothing) Public Shared Function csvexport(quelldgv As DataGridView)
Dim savefiledialog As New SaveFileDialog Dim savefiledialog As New SaveFileDialog
Dim firstin As String Dim firstin As String
Dim out As String Dim out As String
@@ -245,62 +247,6 @@ Public Class frmGesamtsicherheitenMenuNEU
savefiledialog.InitialDirectory = "C:\Verag" savefiledialog.InitialDirectory = "C:\Verag"
savefiledialog.ShowDialog() savefiledialog.ShowDialog()
If quelldgv2 IsNot Nothing Then
Try
For r As Integer = 0 To quelldgv.Rows.Count - 1
For c As Integer = 0 To quelldgv.Columns.Count
'test &= r & c & vbCrLf
Try
'test &= Replace(quelldgv.Rows(r).Cells(c).Value.ToString, vbCrLf, "vbCrlLf")
firstin = quelldgv.Rows(r).Cells(c).Value.ToString
'in2 = """" & firstin & """" & ";"
in2 = firstin & ";"
out &= Replace(in2, vbCrLf, "##vbCrLf##")
out = Replace(out, "", "")
Catch ex As Exception
out &= ""
End Try
Next
For c As Integer = 0 To quelldgv2.Columns.Count
'test &= r & c & vbCrLf
Try
'test &= Replace(quelldgv.Rows(r).Cells(c).Value.ToString, vbCrLf, "vbCrlLf")
firstin = quelldgv2.Rows(r).Cells(c).Value.ToString
'in2 = """" & firstin & """" & ";"
in2 = firstin & ";"
out &= Replace(in2, vbCrLf, "##vbCrLf##")
out = Replace(out, "", "")
Catch ex As Exception
out &= ""
End Try
Next
out &= "nZ"
Next
For c As Integer = 0 To quelldgv.Columns.Count - 1
header &= quelldgv.Columns(c).Name & ";"
Next
For c As Integer = 0 To quelldgv2.Columns.Count - 1
header &= quelldgv2.Columns(c).Name & ";"
Next
out = Replace(out, "nZ", vbCrLf)
'MsgBox(out)
Using sw As New IO.StreamWriter(savefiledialog.FileName)
sw.WriteLine(header)
sw.WriteLine(out)
End Using
Catch ex As Exception
MsgBox(ex.Message)
End Try
Else
Try Try
For r As Integer = 0 To quelldgv.Rows.Count - 1 For r As Integer = 0 To quelldgv.Rows.Count - 1
For c As Integer = 0 To quelldgv.Columns.Count For c As Integer = 0 To quelldgv.Columns.Count
@@ -333,7 +279,6 @@ Public Class frmGesamtsicherheitenMenuNEU
Catch ex As Exception Catch ex As Exception
MsgBox(ex.Message) MsgBox(ex.Message)
End Try End Try
End If
End Function End Function
@@ -496,21 +441,20 @@ Public Class frmGesamtsicherheitenMenuNEU
Private Sub ExportCSV2ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExportCSV2ToolStripMenuItem.Click Private Sub ExportCSV2ToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ExportCSV2ToolStripMenuItem.Click
Dim frm As New frmGesamtsicherheitenNEU If dgvListe.SelectedRows.Count > 0 Then
With frm Dim list As New List(Of Integer)
.currentGesSichRef = GesSichRef
.gessicherheitID = dgvListe.CurrentRow.Cells("gs_gsnr").Value
.Standort = Me.Standort
.datum = dgvListe.CurrentRow.Cells("gs_datum").Value
.LKWKZ = dgvListe.CurrentRow.Cells("gs_LKWKZ").Value
.FilialNummer = dgvListe.CurrentRow.Cells("gs_filialenNr").Value
.Abfertigungsnummer = dgvListe.CurrentRow.Cells("gs_abfertigungsNr").Value
.warenortID = dgvListe.CurrentRow.Cells("gs_warenort").Value
.dataTable = Me.dataTable
End With
frm.LoadDGVSicherheitenForExport() For Each row As DataGridViewRow In dgvListe.SelectedRows
frm.LoadDGVSicherheitsPosForExport(frm.gessicherheitID) list.Add(CInt(row.Cells("gs_gsnr").Value))
csvexport(frm.dgvGesamtsicherheit, frm.dgvSicherheitsPos)
Next
Dim frm As New frmGesamtsicherheitenNEU
frm.LoadDGVSicherheitenForExport(list)
SDL.cProgramFunctions.genExcelFromDGV_NEW(frm.dgvGesamtsicherheit)
'csvexport(frm.dgvGesamtsicherheit)
End If
End Sub End Sub
End Class End Class

View File

@@ -1,6 +1,7 @@
 
Imports System.Linq.Expressions Imports System.Linq.Expressions
Imports GrapeCity.Viewer.Common.Model Imports GrapeCity.Viewer.Common.Model
Imports Org.BouncyCastle.Cms
Imports VERAG_PROG_ALLGEMEIN Imports VERAG_PROG_ALLGEMEIN
Public Class frmGesamtsicherheitenNEU Public Class frmGesamtsicherheitenNEU
@@ -148,11 +149,25 @@ Public Class frmGesamtsicherheitenNEU
End Sub End Sub
Public Sub LoadDGVSicherheitenForExport(Optional withFilterParam As Boolean = False) Public Sub LoadDGVSicherheitenForExport(list As List(Of Integer))
Dim gsnr As String
Dim counter = 0
For Each n In list
gsnr &= n.ToString()
counter = counter + 1
If (list.Count <> 0 And counter <> list.Count) Then
gsnr &= ","
End If
Next
Dim SQLStringSicherheit As String = "select [gs_gsId] as ID, [gs_ATBNr] as 'ATB Verwahrlager', CONVERT(VARCHAR(10),gs_datum, 120) as Datum, CONVERT(VARCHAR(5),gs_datum, 108) as Uhrzeit, [gs_warenwert] as Warenwert, [gs_sicherheitsbetrag] as Sicherheitbetrag, [gs_saldo] as Saldo, [gs_freitext] as Freitext, [gs_atr] as 'ATR ja/nein', [gs_ust] as '19% EUSt' from [tblGesamtsicherheit] where [gs_gsnr] = '" & gessicherheitID & "'" & "order by gs_gsId" Dim SQLStringSicherheit As String = "select [gs_gsId] as Id, [gs_ATBNr] as 'ATB Verwahrlager', CAST(gs_datum as Date) as Datum, CONVERT(VARCHAR(5),gs_datum, 108) as Uhrzeit, [gs_warenwert] as Warenwert, [gs_sicherheitsbetrag] as Sicherheitbetrag, [gs_freitext] as Freitext, [gs_atr] as 'ATR ja/nein', [gs_ust] as '19% EUSt',
[gsp_ATCNr] as 'ATCNr oder MRN eroeffnet', CAST(gsp_erstellungsdatum as Date) as Datum, CONVERT(VARCHAR(5),gsp_erstellungsdatum, 108) as Uhrzeit, [gsp_warenwert] as Warenwert, [gsp_sicherheitsbetrag] as Sicherheitsbetrag, [gsp_freitext] as Freitext, [gs_saldo] as Saldo
from [tblGesamtsicherheit]
inner join [tblGesamtsicherheitsPositionen] on [tblGesamtsicherheit].gs_gsId = [tblGesamtsicherheitsPositionen].gsp_gsId
where [gs_gsnr] IN (" & gsnr & ")
order by gs_gsId"
dgvGesamtsicherheit.SET_SQL(SQLStringSicherheit, "AVISO", ,) dgvGesamtsicherheit.SET_SQL(SQLStringSicherheit, "AVISO", ,)
dgvGesamtsicherheit.LOAD() dgvGesamtsicherheit.LOAD()
@@ -233,19 +248,6 @@ Public Class frmGesamtsicherheitenNEU
End Sub End Sub
Public Sub LoadDGVSicherheitsPosForExport(gsNr As Integer, Optional withFilterParam As Boolean = False)
Dim sqlSearchSting As String = ""
Dim SQLStringCRN As String =
"select [gsp_gsId] as IDPos, [gsp_ATCNr] as 'ATCNr oder MRN eroeffnet', CONVERT(VARCHAR(10),gsp_erstellungsdatum, 120) as Datum, CONVERT(VARCHAR(5),gsp_erstellungsdatum, 108) as Uhrzeit, [gsp_warenwert] as Warenwert, [gsp_sicherheitsbetrag] as Sicherheitsbetrag, [gsp_freitext] as Freitext" &' ,[gsp_avisoId] ,[gsp_ust] ,[gsp_filialenNr],[gsp_abfertigungsNr] ,[gsp_MRNNr], [gsp_art]
" From [tblGesamtsicherheitsPositionen] where [gsp_gsnr] = '" & gsNr & "' order by [gsp_gsId]"
dgvSicherheitsPos.SET_SQL(SQLStringCRN, "AVISO", ,)
dgvSicherheitsPos.LOAD()
End Sub
'Private Sub dgvSicherheitsPos_SelectionChanged(sender As Object, e As EventArgs) Handles dgvSicherheitsPos.SelectionChanged 'Private Sub dgvSicherheitsPos_SelectionChanged(sender As Object, e As EventArgs) Handles dgvSicherheitsPos.SelectionChanged
' If dgvSicherheitsPos.SelectedRows.Count > 0 Then ' If dgvSicherheitsPos.SelectedRows.Count > 0 Then