17.07.2023

This commit is contained in:
Jonathan Jenne
2023-07-17 12:59:36 +02:00
parent b63655b212
commit 9a3c3c2706
23 changed files with 1121 additions and 176 deletions

View File

@@ -0,0 +1,97 @@
Imports System.ComponentModel
Imports System.IO
Imports DigitalData.Modules.Logging
Partial Public Class frmEnvelopeEditor
Public Property Documents As New BindingList(Of EnvelopeDocument)
Public Property Receivers As New BindingList(Of EnvelopeReceiver)
Private Controller As EnvelopeEditorController
Private Logger As Logger
Public Property State As State
Public Sub New()
InitializeComponent()
End Sub
Private Sub btnNewFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnNewFile.ItemClick
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim oFileInfo = New FileInfo(OpenFileDialog1.FileName)
Documents.Add(New EnvelopeDocument() With {.FileInfo = oFileInfo})
End If
End Sub
Private Sub frmEditor_Load(sender As Object, e As EventArgs) Handles Me.Load
Logger = State.LogConfig.GetLogger()
Controller = New EnvelopeEditorController(State)
GridDocuments.DataSource = Documents
GridReceivers.DataSource = Receivers
End Sub
Private Sub frmEnvelopeEditor_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Controller.CleanupEnvelope()
End Sub
Private Sub btnDeleteFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDeleteFile.ItemClick
If ViewDocuments.GetSelectedRows().Count > 0 Then
Dim oDocument As EnvelopeDocument = DirectCast(ViewDocuments.GetFocusedRow(), EnvelopeDocument)
If Controller.DeleteDocument(oDocument) Then
Documents.Remove(oDocument)
End If
End If
End Sub
Private Sub btnSave_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnSave.ItemClick
Try
SaveEnvelope()
Catch ex As Exception
Logger.Error(ex)
End Try
End Sub
Private Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
If ViewDocuments.GetSelectedRows().Count > 0 Then
Dim oDocument As EnvelopeDocument = DirectCast(ViewDocuments.GetFocusedRow(), EnvelopeDocument)
Dim oGDPictureKey As String = "21182889975216572111813147150675976632"
If SaveEnvelope() Then
Dim oForm As New frmFieldEditor() With {
.Document = Controller.Envelope.Documents.
Where(Function(d) d.Filename = oDocument.Filename).
SingleOrDefault(),
.GDPictureKey = oGDPictureKey,
.Receivers = Receivers.ToList,
.State = State
}
oForm.ShowDialog()
End If
End If
End Sub
Private Function SaveEnvelope() As Boolean
Dim oSubject = txtSubject.EditValue?.ToString
Dim oMessage = txtMessage.EditValue?.ToString
Dim oEnvelope = Controller.Envelope
oEnvelope.Subject = oSubject
oEnvelope.Message = oMessage
oEnvelope.Receivers = Receivers.ToList
oEnvelope.Documents = Documents.ToList
Dim oErrors = oEnvelope.Validate()
If oErrors.Any Then
Dim oError = "Fehler beim Speichern des Umschlags:" & vbNewLine & vbNewLine & String.Join(vbNewLine, oErrors)
MsgBox(oError, MsgBoxStyle.Exclamation, Text)
Return False
ElseIf Controller.SaveEnvelope(oEnvelope) = False Then
MsgBox("Fehler beim Speichern des Umschlags!", MsgBoxStyle.Critical, Text)
Return False
Else
Return True
End If
End Function
End Class