2023-10-11

This commit is contained in:
2023-10-11 11:51:59 +02:00
parent 603ee5a1fc
commit 8613b11f70
7 changed files with 64 additions and 17 deletions

View File

@@ -95,9 +95,9 @@ Public Class EnvelopeEditorController
Dim newHistoryEntry As New EnvelopeHistoryEntry With {
.EnvelopeId = oEnvelope.Id,
.ActionType = ActionType.Created,
.ActionType = EnvelopeHistoryActionType.Created,
.ActionDescription = "Envelope wurde neu erstellt",
.UserEmailAddress = oEnvelope.User.Email
.UserReference = oEnvelope.User.Email
}
HistoryModel.Insert(newHistoryEntry)
@@ -272,6 +272,14 @@ Public Class EnvelopeEditorController
oReceiver.Id = 0
Next
For Each oCurrentReceiver In pCurrentReceivers
If oCurrentReceiver.Id = 0 Then
Dim oExistingReceiver As EnvelopeReceiver = oExistingReceivers.Where(Function(r) r.Email = oCurrentReceiver.Email).First()
oCurrentReceiver.Id = oExistingReceiver.Id
End If
Next
Dim oConnection = Database.GetConnection()
Dim oTransaction = oConnection.BeginTransaction()

View File

@@ -1,4 +1,5 @@
Imports System.ComponentModel
Imports DevExpress.XtraEditors
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraSplashScreen
@@ -98,9 +99,7 @@ Partial Public Class frmEnvelopeEditor
Private Sub btnSave_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnSave.ItemClick
Try
If SaveEnvelope() Then
End If
SaveEnvelopeWithOutValidation()
Catch ex As Exception
Logger.Error(ex)
End Try
@@ -114,7 +113,7 @@ Partial Public Class frmEnvelopeEditor
Dim oDocument As EnvelopeDocument = DirectCast(ViewDocuments.GetFocusedRow(), EnvelopeDocument)
Dim oGDPictureKey As String = "21182889975216572111813147150675976632"
If SaveEnvelope() Then
If SaveEnvelopeWithOutValidation() Then
Dim oForm As New frmFieldEditor() With {
.Document = Controller.Envelope.Documents.
Where(Function(d) d.Filename = oDocument.Filename).
@@ -133,9 +132,17 @@ Partial Public Class frmEnvelopeEditor
End Try
End Sub
Private Function SaveEnvelope() As Boolean
Dim oSubject = txtSubject.EditValue?.ToString
Dim oMessage = txtMessage.EditValue?.ToString
Private Function SaveEnvelopeWithValidation() As Boolean
Return SaveEnvelope(True)
End Function
Private Function SaveEnvelopeWithOutValidation() As Boolean
Return SaveEnvelope(False)
End Function
Private Function SaveEnvelope(pWithValidation As Boolean) As Boolean
Dim oSubject = GetEditValueFromTextControl(txtSubject)
Dim oMessage = GetEditValueFromTextControl(txtMessage)
' Ensure all receivers are saved
ViewReceivers.CloseEditor()
@@ -146,10 +153,12 @@ Partial Public Class frmEnvelopeEditor
oEnvelope.Receivers = Receivers.ToList
oEnvelope.Documents = Documents.ToList
Dim oErrors = oEnvelope.Validate()
If oErrors.Any Then
ShowValidationErrors(Resources.Envelope.Errors_when_saving_the_envelope, oErrors)
Return False
If pWithValidation = True Then
Dim oErrors = oEnvelope.Validate()
If oErrors.Any Then
ShowValidationErrors(Resources.Envelope.Errors_when_saving_the_envelope, oErrors)
Return False
End If
End If
If Controller.CreateEnvelopeReceivers(oEnvelope.Receivers) = False Then
@@ -165,6 +174,14 @@ Partial Public Class frmEnvelopeEditor
End If
End Function
Private Function GetEditValueFromTextControl(pControl As TextEdit) As String
If pControl.EditValue Is Nothing Then
Return String.Empty
Else
Return pControl.EditValue.ToString
End If
End Function
Private Sub ShowValidationErrors(pErrorTitle As String, pErrors As List(Of String))
Dim oError = pErrorTitle & vbNewLine & vbNewLine & String.Join(vbNewLine, pErrors)
MsgBox(oError, MsgBoxStyle.Exclamation, Text)
@@ -199,7 +216,12 @@ Partial Public Class frmEnvelopeEditor
End Sub
Private Sub btnSendEnvelope_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnSendEnvelope.ItemClick
If SaveEnvelope() = False Then
If Controller.Envelope.Status = Constants.EnvelopeStatus.Sent Then
MsgBox(Resources.Envelope.Envelope_already_sent, MsgBoxStyle.Information, Text)
Exit Sub
End If
If SaveEnvelopeWithValidation() = False Then
Exit Sub
End If