07-12-2024 Name vorschlagen

This commit is contained in:
PitzM 2023-12-07 09:58:57 +01:00
parent 1108fa47e0
commit 474bf89ee8
3 changed files with 52 additions and 9 deletions

View File

@ -1,5 +1,6 @@
Imports System.Data.SqlClient
Imports System.Net.Mail
Imports DevExpress.DataProcessing
Imports DigitalData.Modules.Base
Imports EnvelopeGenerator.Common.Constants
@ -25,7 +26,7 @@ Public Class ReceiverModel
End If
Return New EnvelopeReceiver() With {
.Id = pRow.ItemEx("GUID", 0),
.Id = pRow.ItemEx("RECEIVER_ID", 0),
.Email = pRow.ItemEx("EMAIL_ADDRESS", ""),
.Name = pRow.ItemEx("NAME", ""),
.Sequence = pRow.ItemEx("SEQUENCE", 0),
@ -212,16 +213,17 @@ Public Class ReceiverModel
End Function
Public Function GetById(pReceiverId As Integer) As EnvelopeReceiver
Try
Dim oSql = $"SELECT * FROM [dbo].[VWSIG_ENVELOPE_RECEIVERS] WHERE GUID = {pReceiverId}"
Dim oTable = Database.GetDatatable(oSql)
'Try
' Dim oSql = $"SELECT * FROM [dbo].[VWSIG_ENVELOPE_RECEIVERS] WHERE RECEIVER_ID = {pReceiverId}"
' Dim oTable = Database.GetDatatable(oSql)
Return ToReceiver(oTable)
' Return ToReceiver(oTable)
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
'Catch ex As Exception
' Logger.Error(ex)
' Return Nothing
'End Try
Return Nothing
End Function
Public Function GetReceiverIdBySignature(pSignature As String) As Integer
@ -233,6 +235,23 @@ Public Class ReceiverModel
End Try
End Function
Public Function GetLastUsedReceiverName(pEmailAddress As String, pUserId As Integer) As String
Try
Dim oSql As String
oSql = "SELECT TOP 1 [NAME] FROM dbo.VWSIG_ENVELOPE_RECEIVERS "
oSql += $" WHERE ENVELOPE_ID IN (SELECT GUID FROM dbo.TBSIG_ENVELOPE WHERE [USER_ID] = {pUserId}) "
oSql += $" AND EMAIL_ADDRESS = '{pEmailAddress}' "
oSql += " AND Len([NAME]) > 0 "
oSql += " ORDER BY [ADDED_WHEN] DESC"
Return Database.GetScalarValue(oSql)
Catch ex As Exception
Logger.Error(ex)
Return String.Empty
End Try
End Function
Private Function GetReceiverIdByEmail(pEmailAddress As String, pTransaction As SqlTransaction) As Integer
Try
Return Database.GetScalarValue($"SELECT GUID FROM TBSIG_RECEIVER WHERE EMAIL_ADDRESS = '{pEmailAddress}'", pTransaction)

View File

@ -365,4 +365,11 @@ Public Class EnvelopeEditorController
End If
End Function
Public Function GetLastNameByEmailAdress(pEmailAdress As String) As String
If (String.IsNullOrEmpty(pEmailAdress) = False) Then
Return ReceiverModel.GetLastUsedReceiverName(pEmailAdress, Envelope.UserId)
Else
Return String.Empty
End If
End Function
End Class

View File

@ -419,4 +419,21 @@ Partial Public Class frmEnvelopeEditor
RibbonPageGroupAddSignature_Enabled()
End Sub
Private Sub ViewReceivers_CellValueChanging(sender As Object, e As Views.Base.CellValueChangedEventArgs) Handles ViewReceivers.CellValueChanging
'If e.Column.FieldName = "Email" Then
' Dim oEmailAdress As String = DirectCast(e.Value, String)
' Dim oLastName As String = Controller.GetLastNameByEmailAdress(oEmailAdress)
'End If
End Sub
Private Sub ViewReceivers_CellValueChanged(sender As Object, e As Views.Base.CellValueChangedEventArgs) Handles ViewReceivers.CellValueChanged
If e.Column.FieldName = "Email" Then
Dim oLastCellValue = ViewReceivers.GetRowCellValue(e.RowHandle, "Name")
If oLastCellValue Is Nothing Then
Dim oEmailAdress As String = DirectCast(e.Value, String)
Dim oLastName As String = Controller.GetLastNameByEmailAdress(oEmailAdress)
ViewReceivers.SetRowCellValue(e.RowHandle, ViewReceivers.Columns("Name"), oLastName)
End If
End If
End Sub
End Class