608 lines
23 KiB
VB.net
608 lines
23 KiB
VB.net
Imports System.ComponentModel
|
|
Imports System.Data.SqlClient
|
|
Imports System.IO
|
|
Imports DevExpress.Export.Xl
|
|
Imports DevExpress.Utils.CommonDialogs
|
|
Imports DevExpress.Utils.Drawing
|
|
Imports DevExpress.Utils.Svg.CommonSvgImages
|
|
Imports DevExpress.XtraEditors
|
|
Imports DevExpress.XtraExport.Helpers
|
|
Imports DevExpress.XtraGrid
|
|
Imports DevExpress.XtraGrid.Columns
|
|
Imports DevExpress.XtraGrid.Views.Base
|
|
Imports DevExpress.XtraGrid.Views.Grid
|
|
Imports DevExpress.XtraSplashScreen
|
|
Imports DigitalData.Modules.Base
|
|
Imports DigitalData.Modules.Logging
|
|
Imports EnvelopeGenerator.Common
|
|
Imports EnvelopeGenerator.Common.Constants
|
|
Imports EnvelopeGenerator.Common.My
|
|
|
|
Partial Public Class frmEnvelopeEditor
|
|
Public Property Envelope As Envelope
|
|
Public Property Documents As New BindingList(Of EnvelopeDocument)
|
|
Public Property Receivers As New BindingList(Of EnvelopeReceiver)
|
|
|
|
Private AllReceiverEmails As New List(Of String)
|
|
|
|
Private Controller As EnvelopeEditorController
|
|
Private Logger As Logger
|
|
|
|
Private Const COL_NAME = "Name"
|
|
Private Const COL_EMAIL = "Email"
|
|
Private Const COL_CODE = "AccessCode"
|
|
|
|
Public Property State As State
|
|
Private TempFiles As TempFiles
|
|
|
|
Public Sub New()
|
|
InitializeComponent()
|
|
End Sub
|
|
|
|
Private Async Sub btnNewFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnNewFile.ItemClick
|
|
Dim oHandle = SplashScreenManager.ShowOverlayForm(Me)
|
|
'SaveEnvelopeWithValidation()
|
|
' If Not IsNothing(Envelope) Then
|
|
Try
|
|
' prüfen ob es schon eine Datei gibt
|
|
If Documents.Count > 0 Then
|
|
MsgBox(Resources.Envelope.Only_one_file_is_allowed, MsgBoxStyle.Information, Text)
|
|
Return
|
|
End If
|
|
|
|
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
|
|
Dim oDocument = Await Controller.CreateDocument(OpenFileDialog1.FileName)
|
|
|
|
If oDocument IsNot Nothing Then
|
|
Documents.Add(oDocument)
|
|
' Update_File_DB(OpenFileDialog1.FileName)
|
|
Else
|
|
MsgBox(Resources.Envelope.Document_Could_Not_Be_Saved, MsgBoxStyle.Critical, Text)
|
|
End If
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Finally
|
|
SplashScreenManager.CloseOverlayForm(oHandle)
|
|
|
|
RibbonPageGroupAddSignature_Enabled()
|
|
End Try
|
|
' Else
|
|
' SplashScreenManager.CloseOverlayForm(oHandle)
|
|
' End If
|
|
|
|
End Sub
|
|
Private Sub frmEditor_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
Logger = State.LogConfig.GetLogger()
|
|
Logger.Debug("Loading Configuration..")
|
|
TempFiles = New TempFiles(State.LogConfig)
|
|
TempFiles.Create()
|
|
If Envelope Is Nothing Then
|
|
Controller = New EnvelopeEditorController(State)
|
|
|
|
' Get additional data
|
|
Dim oDataForm As New frmEnvelopeMainData() With {
|
|
.State = State,
|
|
.Envelope = Controller.Envelope,
|
|
.NewEnvelopeMode = True
|
|
}
|
|
|
|
Dim oResult As DialogResult = oDataForm.ShowDialog()
|
|
If oResult = DialogResult.Cancel Then
|
|
Controller.DeleteEnvelopeFromDisk(Controller.Envelope)
|
|
Me.Close()
|
|
End If
|
|
Else
|
|
Controller = New EnvelopeEditorController(State, Envelope)
|
|
Documents = New BindingList(Of EnvelopeDocument)(Controller.Envelope.Documents)
|
|
Receivers = New BindingList(Of EnvelopeReceiver)(Controller.Envelope.Receivers)
|
|
|
|
For Each docItem As EnvelopeDocument In Documents
|
|
If Not File.Exists(docItem.Filepath) Then
|
|
Dim oTempFolder = TempFiles.TempPath
|
|
Dim oTempFilename = String.Concat(oTempFolder, "\", $"ViewEnvDoc_{Envelope.Id}.pdf")
|
|
If File.Exists(oTempFilename) Then
|
|
Try
|
|
File.OpenWrite(oTempFilename)
|
|
Catch ex As Exception
|
|
MsgBox("File might already be open?", MsgBoxStyle.Exclamation)
|
|
Me.Cursor = Cursors.Default
|
|
Exit Sub
|
|
End Try
|
|
|
|
|
|
File.Delete(oTempFilename)
|
|
End If
|
|
WriteBytetoPath(oTempFilename, docItem.Byte_Data)
|
|
docItem.Filepath = oTempFilename
|
|
End If
|
|
If docItem.Thumbnail Is Nothing Then
|
|
docItem.Thumbnail = Controller.CreateThumbnail(docItem.Filepath)
|
|
docItem.PageCount = Controller.GetPageCount(docItem.Filepath)
|
|
End If
|
|
Next
|
|
|
|
If Envelope.Status = Constants.EnvelopeStatus.EnvelopeSent Then
|
|
' TODO - Nach Testen
|
|
' SetFormReadonly()
|
|
End If
|
|
End If
|
|
|
|
txtMessage.EditValue = Controller.Envelope.Message
|
|
|
|
GridDocuments.DataSource = Documents
|
|
GridReceivers.DataSource = Receivers
|
|
|
|
AllReceiverEmails = Controller.GetEnvelopeReceiverAddresses(State.UserId)
|
|
RepositoryItemComboBox1.Items.Clear()
|
|
RepositoryItemComboBox1.Items.AddRange(AllReceiverEmails)
|
|
|
|
SetAccessCodeColumnVisible()
|
|
|
|
txtEnvelopeIdLabel2.Caption = String.Format(txtEnvelopeIdLabel2.Tag.ToString, Controller.Envelope.Id)
|
|
txtCreatorEmailLabel.Caption = String.Format(txtCreatorEmailLabel.Tag.ToString, Controller.Envelope.User.Email)
|
|
|
|
SetFormTitle(Controller.Envelope.Title)
|
|
End Sub
|
|
|
|
Private Sub SetAccessCodeColumnVisible()
|
|
If Controller.Envelope.UseAccessCode Then
|
|
colAccessCode.Visible = True
|
|
Else
|
|
colAccessCode.Visible = False
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnDeleteFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDeleteFile.ItemClick
|
|
If ViewDocuments.GetSelectedRows().Count > 0 Then
|
|
|
|
Dim oMessage = Resources.Envelope.Do_you_really_want_to_remove_this_document
|
|
If MsgBox(oMessage, MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text) = MsgBoxResult.No Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim oDocument As EnvelopeDocument = DirectCast(ViewDocuments.GetFocusedRow(), EnvelopeDocument)
|
|
If Controller.DeleteDocument(oDocument) Then
|
|
Documents.Remove(oDocument)
|
|
GridDocuments.DataSource = Nothing
|
|
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnSave_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnSave.ItemClick
|
|
Try
|
|
SaveEnvelopeWithOutValidation()
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub btnEditFields_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnEditFields.ItemClick
|
|
Dim oHandle = SplashScreenManager.ShowOverlayForm(Me)
|
|
|
|
Try
|
|
If SaveEnvelopeWithReceiverDocumentValidation() = False Then
|
|
Return
|
|
End If
|
|
|
|
If ViewDocuments.GetSelectedRows().Count > 0 Then
|
|
Dim oDocument As EnvelopeDocument = DirectCast(ViewDocuments.GetFocusedRow(), EnvelopeDocument)
|
|
Dim oEnvelope = Controller.Envelope
|
|
If Not IsNothing(oDocument.Byte_Data) Then
|
|
Dim oTempFolder = TempFiles.TempPath
|
|
Dim oTempFilename = String.Concat(oTempFolder, "\", $"ViewEnvDoc_{oEnvelope.Id}.pdf")
|
|
If Not File.Exists(oTempFilename) Then
|
|
WriteBytetoPath(oTempFilename, oDocument.Byte_Data)
|
|
oDocument.Filepath = oTempFilename
|
|
End If
|
|
|
|
End If
|
|
|
|
|
|
|
|
Dim oGDPictureKey As String = MS_GDPICTUREKEY
|
|
|
|
Dim oForm As New frmFieldEditor(State) With {
|
|
.Document = Controller.Envelope.Documents.
|
|
Where(Function(d) d.Filename = oDocument.Filename).
|
|
SingleOrDefault(),
|
|
.Receivers = Controller.Envelope.Receivers.ToList
|
|
}
|
|
oForm.ShowDialog()
|
|
|
|
End If
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Finally
|
|
SplashScreenManager.CloseOverlayForm(oHandle)
|
|
End Try
|
|
End Sub
|
|
Private Sub WriteBytetoPath(ByVal sFileName As String, pByte As Byte())
|
|
|
|
'For Document
|
|
Try
|
|
If Not pByte Is Nothing Then
|
|
'Read image data into a file stream
|
|
Using fs As New FileStream(sFileName, FileMode.OpenOrCreate, FileAccess.Write)
|
|
fs.Write(pByte, 0, pByte.Length)
|
|
'Set image variable value using memory stream.
|
|
fs.Flush()
|
|
fs.Close()
|
|
End Using
|
|
End If
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error in downloadFile")
|
|
End Try
|
|
End Sub
|
|
Private Function SaveEnvelopeWithValidation() As Boolean
|
|
Return SaveEnvelope(True)
|
|
End Function
|
|
|
|
Private Function SaveEnvelopeWithOutValidation() As Boolean
|
|
Return SaveEnvelope(False)
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Speichert den Envelope und prüft
|
|
''' ob Receiver und Dokument vorhanden ist.
|
|
''' </summary>
|
|
Private Function SaveEnvelopeWithReceiverDocumentValidation() As Boolean
|
|
|
|
If SaveEnvelope(False) = True Then
|
|
Dim oEnvelope = Controller.Envelope
|
|
Dim oErrors = oEnvelope.ValidateReceiverDocumentData()
|
|
If oErrors.Any Then
|
|
ShowValidationErrors(Resources.Envelope.Errors_when_saving_the_envelope, oErrors)
|
|
Return False
|
|
End If
|
|
Else
|
|
Return False
|
|
End If
|
|
|
|
Return True
|
|
End Function
|
|
|
|
Private Function ValidateEnvelope() As List(Of String)
|
|
Dim oMessage = GetEditValueFromTextControl(txtMessage)
|
|
|
|
Dim oErrors As New List(Of String)
|
|
|
|
If String.IsNullOrWhiteSpace(oMessage) Then
|
|
oErrors.Add(Resources.Envelope.Missing_Message)
|
|
End If
|
|
|
|
If Documents.Count = 0 Then
|
|
oErrors.Add(Resources.Envelope.Missing_Documents)
|
|
End If
|
|
|
|
If Receivers.Count = 0 Then
|
|
oErrors.Add(Resources.Envelope.Missing_Receivers)
|
|
End If
|
|
|
|
For Each Receiver In Receivers
|
|
If Helpers.IsValidEmailAddress(Receiver.Email) = False Then
|
|
oErrors.Add(String.Format(Resources.Envelope.Invalid_Email_Address, Receiver.Name))
|
|
End If
|
|
Next
|
|
|
|
Return oErrors
|
|
End Function
|
|
|
|
Private Function SaveEnvelope(pWithValidation As Boolean) As Boolean
|
|
Dim oMessage = GetEditValueFromTextControl(txtMessage)
|
|
|
|
' Ensure all receivers are saved
|
|
ViewReceivers.CloseEditor()
|
|
|
|
If pWithValidation = True Then
|
|
Dim oErrors = ValidateEnvelope()
|
|
If oErrors.Any Then
|
|
ShowValidationErrors(Resources.Envelope.Errors_when_saving_the_envelope, oErrors)
|
|
Return False
|
|
End If
|
|
End If
|
|
|
|
Dim oEnvelope = Controller.Envelope
|
|
oEnvelope.Message = oMessage
|
|
oEnvelope.Documents = Documents.ToList
|
|
|
|
|
|
|
|
If Controller.SaveReceivers(oEnvelope, Receivers.ToList) = False Then
|
|
MsgBox(Resources.Envelope.Error_when_saving_the_recipients, MsgBoxStyle.Critical, Text)
|
|
Return False
|
|
End If
|
|
|
|
If Controller.SaveEnvelope() = False Then
|
|
MsgBox(Resources.Envelope.Error_when_saving_the_envelope, MsgBoxStyle.Critical, Text)
|
|
Return False
|
|
Else
|
|
Return True
|
|
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)
|
|
End Sub
|
|
|
|
Private Sub btnDeleteReceiver_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnDeleteReceiver.ItemClick
|
|
If ViewReceivers.SelectedRowsCount = 0 Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim oReceiver As EnvelopeReceiver = ViewReceivers.GetFocusedRow()
|
|
|
|
If oReceiver Is Nothing Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim oMessage = Resources.Envelope.Do_you_want_to_delete_the_selected_recipient
|
|
If Controller.ElementsExist(oReceiver.Id) Then
|
|
oMessage = Resources.Envelope.There_are_already_elements_for_this_recipient
|
|
End If
|
|
|
|
If MsgBox(oMessage, MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text) = MsgBoxResult.No Then
|
|
Exit Sub
|
|
End If
|
|
|
|
If Controller.DeleteReceiver(oReceiver) Then
|
|
Receivers.Remove(oReceiver)
|
|
Else
|
|
MsgBox(Resources.Envelope.Recipient_could_not_be_deleted, MsgBoxStyle.Critical, Text)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Sub btnSendEnvelope_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnSendEnvelope.ItemClick
|
|
If Controller.Envelope.Status = Constants.EnvelopeStatus.EnvelopeSent Then
|
|
MsgBox(Resources.Envelope.Envelope_already_sent, MsgBoxStyle.Information, Text)
|
|
Exit Sub
|
|
End If
|
|
|
|
If SaveEnvelopeWithValidation() = False Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim oErrors = ValidateEnvelope()
|
|
oErrors = Controller.ValidateEnvelopeForSending(oErrors)
|
|
|
|
If oErrors.Any() Then
|
|
ShowValidationErrors(Resources.Envelope.Error_when_validating_the_envelope, oErrors)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim oMessage = Resources.Envelope.Do_you_want_to_start_the_signature_process_now
|
|
If MsgBox(oMessage, MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text) = MsgBoxResult.No Then
|
|
Exit Sub
|
|
End If
|
|
|
|
If Controller.SendEnvelope() = False Then
|
|
MsgBox(Resources.Envelope.Envelope_could_not_be_sent, MsgBoxStyle.Critical, Text)
|
|
Else
|
|
If MsgBox(Resources.Envelope.Envelope_Invitations_Sent, MsgBoxStyle.Information Or MsgBoxStyle.OkOnly, Text) = MsgBoxResult.Ok Then
|
|
'If DOCUMENT_PATH_MOVE_AFTSEND <> String.Empty Then
|
|
' If My.Settings.NetUse_PW <> String.Empty And My.Settings.NetUse_Usr <> String.Empty Then
|
|
' Dim oDecrypted = Decryption.Decrypt(My.Settings.NetUse_PW)
|
|
' For Each odoc In Controller.Envelope.Documents 'envelope ist leer!
|
|
' Directory2Delete = ""
|
|
' If CopyFileWithNetUse(odoc.Filepath, DOCUMENT_PATH_MOVE_AFTSEND, My.Settings.NetUse_Usr, My.Settings.NetUse_PW) = False Then
|
|
' BarStaticItem1.Caption = "ERROR while copying files to DMZ! Check Your log!"
|
|
' End If
|
|
' If Directory2Delete <> String.Empty Then
|
|
' Logger.Debug("Now Deleting SourcePath: {0} ...", Directory2Delete)
|
|
' Try
|
|
' System.IO.Directory.Delete(Directory2Delete, True)
|
|
' Logger.Debug("Successfully deleted Sourcepath!")
|
|
' Catch ex As Exception
|
|
' Logger.Warn("Unexpected Error while deleting SourcePath {0}", Directory2Delete)
|
|
' Logger.Warn("ErrorMessage: {0}", ex.Message)
|
|
' End Try
|
|
|
|
' End If
|
|
' Next
|
|
' End If
|
|
|
|
'End If
|
|
Me.Close()
|
|
End If
|
|
End If
|
|
End Sub
|
|
Private Sub btnCancel_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnCancel.ItemClick
|
|
' Speichern?
|
|
Dim oMessage = Resources.Envelope.Should_The_Envelope_Be_Saved
|
|
If MsgBox(oMessage, MsgBoxStyle.Question Or MsgBoxStyle.YesNo, Text) = MsgBoxResult.Yes Then
|
|
SaveEnvelope(False)
|
|
End If
|
|
|
|
' Schließen
|
|
Me.Close()
|
|
End Sub
|
|
|
|
Private Sub btnEditData_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnEditData.ItemClick
|
|
Dim oForm As New frmEnvelopeMainData() With
|
|
{
|
|
.State = State,
|
|
.Envelope = Controller.Envelope,
|
|
.NewEnvelopeMode = False
|
|
}
|
|
oForm.ShowDialog()
|
|
|
|
SetAccessCodeColumnVisible()
|
|
|
|
SetFormTitle(Controller.Envelope.Title)
|
|
End Sub
|
|
|
|
Private Sub GridReceivers_PaintEx(sender As Object, e As DevExpress.XtraGrid.PaintExEventArgs) Handles GridReceivers.PaintEx
|
|
Dim grid As GridControl = sender, view As GridView = Nothing
|
|
|
|
If TypeOf sender Is GridControl AndAlso TypeOf grid.MainView Is GridView Then
|
|
view = grid.MainView
|
|
Dim pen = New Pen(Color.Gainsboro, 2)
|
|
Dim info = view.GetViewInfo()
|
|
e.Cache.DrawRectangle(pen, info.Bounds)
|
|
pen.Dispose()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ViewReceivers_InitNewRow(sender As Object, e As InitNewRowEventArgs) Handles ViewReceivers.InitNewRow
|
|
Dim oReceiver As EnvelopeReceiver = ViewReceivers.GetRow(e.RowHandle)
|
|
|
|
Dim oUsedColors = Receivers.Select(Of Integer)(Function(r) r.ColorType).ToList()
|
|
Dim oAllColors = [Enum].GetValues(GetType(ColorType)).Cast(Of Integer).ToList()
|
|
Dim oUnusedColors = oAllColors.Except(oUsedColors)
|
|
If oUnusedColors.Any() Then
|
|
oReceiver.ColorType = oUnusedColors.Min()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub frmEnvelopeEditor_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
|
RibbonPageGroupAddSignature_Enabled()
|
|
RibbonPageGroupReceiver_Enable()
|
|
SendEnvelopeButton_Enable()
|
|
End Sub
|
|
Private Sub RibbonPageGroupAddSignature_Enabled()
|
|
If ViewDocuments.RowCount > 0 And
|
|
ViewReceivers.SelectedRowsCount > 0 Then
|
|
RibbonPageGroupAddSignature.Enabled = True
|
|
Else
|
|
RibbonPageGroupAddSignature.Enabled = False
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub RibbonPageGroupReceiver_Enable()
|
|
If ViewReceivers.SelectedRowsCount = 0 Then
|
|
RibbonPageGroupReceiver.Enabled = False
|
|
Else
|
|
RibbonPageGroupReceiver.Enabled = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub DocumentButtons_Enable()
|
|
If ViewDocuments.RowCount = 0 Then
|
|
btnNewFile.Enabled = True
|
|
btnDeleteFile.Enabled = False
|
|
Else
|
|
btnNewFile.Enabled = False
|
|
btnDeleteFile.Enabled = True
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub SendEnvelopeButton_Enable()
|
|
If ViewDocuments.RowCount > 0 And
|
|
ViewReceivers.SelectedRowsCount > 0 Then
|
|
btnSendEnvelope.Enabled = True
|
|
Else
|
|
btnSendEnvelope.Enabled = False
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub SetFormTitle(pTitle As String)
|
|
Dim oFormTitle As String = State.DbConfig.ExternalProgramName + " - " + Resources.Envelope.Envelope_Editor
|
|
If String.IsNullOrEmpty(pTitle) = False Then
|
|
oFormTitle += " - " + Controller.Envelope.Title.Truncate(30)
|
|
End If
|
|
|
|
Me.Text = oFormTitle
|
|
End Sub
|
|
|
|
Private Sub frmEnvelopeEditor_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
|
|
If Controller.Envelope?.Status = EnvelopeStatus.EnvelopeCreated Then
|
|
Controller.DeleteEnvelopeFromDisk(Controller.Envelope)
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub ViewReceivers_RowCountChanged(sender As Object, e As EventArgs) Handles ViewReceivers.RowCountChanged
|
|
RibbonPageGroupReceiver_Enable()
|
|
SendEnvelopeButton_Enable()
|
|
RibbonPageGroupAddSignature_Enabled()
|
|
End Sub
|
|
|
|
Private Sub ViewDocuments_RowCountChanged(sender As Object, e As EventArgs) Handles ViewDocuments.RowCountChanged
|
|
DocumentButtons_Enable()
|
|
SendEnvelopeButton_Enable()
|
|
RibbonPageGroupAddSignature_Enabled()
|
|
End Sub
|
|
Dim CellValueChanged As Boolean = False
|
|
Private Sub ViewReceivers_ColumnPositionChanged(sender As Object, e As EventArgs) Handles ViewReceivers.ColumnPositionChanged
|
|
|
|
|
|
End Sub
|
|
Private Sub ViewReceivers_CellValueChanged(sender As Object, e As Views.Base.CellValueChangedEventArgs) Handles ViewReceivers.CellValueChanged
|
|
|
|
If e.Column.FieldName = COL_EMAIL And CellValueChanged = False Then
|
|
If e.Value Is Nothing Then
|
|
' Keine E-Mail-Adresse, also weg damit
|
|
ViewReceivers.DeleteRow(ViewReceivers.FocusedRowHandle)
|
|
Else
|
|
' Doppelte E-Mail-Adresse? TODO
|
|
'Dim oReceivers = Controller.Envelope.Receivers
|
|
CellValueChanged = True
|
|
Dim oNameCellValue = ViewReceivers.GetRowCellValue(e.RowHandle, COL_NAME)
|
|
If oNameCellValue Is Nothing Then
|
|
Dim oEmailAdress As String = DirectCast(e.Value.ToString.ToLower, String)
|
|
oEmailAdress = Trim(oEmailAdress)
|
|
If IsValidEmailAddress(oEmailAdress) = True Then
|
|
Dim oLastName As String = Controller.GetLastNameByEmailAdress(oEmailAdress)
|
|
Dim oAccessCode As String = Helpers.GetAccessCode()
|
|
ViewReceivers.SetRowCellValue(e.RowHandle, ViewReceivers.Columns.Item(COL_EMAIL), oEmailAdress)
|
|
ViewReceivers.SetRowCellValue(e.RowHandle, ViewReceivers.Columns.Item(COL_NAME), oLastName)
|
|
ViewReceivers.SetRowCellValue(e.RowHandle, ViewReceivers.Columns.Item(COL_CODE), oAccessCode)
|
|
CellValueChanged = False
|
|
Else
|
|
Dim oMsg = Resources.Envelope.Error_email_Validation
|
|
oMsg = oMsg.Replace("@Mail", oEmailAdress)
|
|
MsgBox(oMsg, MsgBoxStyle.Exclamation, Text)
|
|
ViewReceivers.DeleteRow(ViewReceivers.FocusedRowHandle)
|
|
End If
|
|
|
|
End If
|
|
End If
|
|
End If
|
|
End Sub
|
|
Private Sub email_validation()
|
|
|
|
End Sub
|
|
|
|
Private Function IsValidEmailAddress(pEmailAddress As String) As Boolean
|
|
Try
|
|
If pEmailAddress.Contains("@") Then
|
|
Dim oAddress = New System.Net.Mail.MailAddress(pEmailAddress)
|
|
Return oAddress.Address = pEmailAddress
|
|
Else
|
|
Return False
|
|
End If
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Return False
|
|
End Try
|
|
End Function
|
|
Private Sub RibbonControl1_Click(sender As Object, e As EventArgs) Handles RibbonControl1.Click
|
|
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
|
|
frmChooseDocVariant.ShowDialog()
|
|
End Sub
|
|
|
|
Private Sub BarButtonItem4_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem4.ItemClick
|
|
|
|
End Sub
|
|
|
|
Private Sub ViewReceivers_CellValueChanging(sender As Object, e As CellValueChangedEventArgs) Handles ViewReceivers.CellValueChanging
|
|
|
|
End Sub
|
|
|
|
|
|
End Class
|