vermerke update
This commit is contained in:
@@ -6,9 +6,11 @@ Imports System.Text
|
||||
Imports Newtonsoft.Json
|
||||
Imports Newtonsoft.Json.Linq
|
||||
Imports VERAG_PROG_ALLGEMEIN
|
||||
Imports AVISO.AvisoStatusFunctions
|
||||
|
||||
Public Class frmSendungsDokumentanforderung
|
||||
Private ReadOnly AvisoDAL As New cAvisoDAL
|
||||
Private ReadOnly _admin As New cADMIN
|
||||
Public Property AvisoID As Integer
|
||||
Public Property SendungID As Integer
|
||||
|
||||
@@ -35,6 +37,7 @@ Public Class frmSendungsDokumentanforderung
|
||||
Private ReadOnly _kontaktEmailRows As New List(Of KontaktEmailRow)
|
||||
Private ReadOnly _kundenFirmaByNr As New Dictionary(Of Integer, String)
|
||||
Private _kontaktRolleTabs As TabControl
|
||||
Private _emailTemplates As DataTable
|
||||
|
||||
Public Sub New(ByVal avisoIdValue As Integer, ByVal sendungIdValue As Integer, state As DokumentanforderungState)
|
||||
InitializeComponent()
|
||||
@@ -60,11 +63,78 @@ Public Class frmSendungsDokumentanforderung
|
||||
|
||||
InitializeDocumentEditor()
|
||||
SetupDynamicAnforderungCheckboxes()
|
||||
LoadEmailTemplates()
|
||||
ApplyStateToUi(_stateToApply)
|
||||
InitializeKontaktEmailGrid()
|
||||
LoadKontaktEmails()
|
||||
End Sub
|
||||
|
||||
Private Sub LoadEmailTemplates()
|
||||
Try
|
||||
Dim sql As String = "SELECT [txt_Id], [txt_bezeichnung], [txt_sprache], [txt_text] FROM [tblTextkonserve] WHERE txt_kategorie = 'FRM_DOKUMENTANFORDERUNG_MailText' ORDER BY [txt_bezeichnung], [txt_sprache]"
|
||||
_emailTemplates = (New VERAG_PROG_ALLGEMEIN.SQL).loadDgvBySql(sql, "FMZOLL", 1000, True)
|
||||
|
||||
cmbCustomerUploadEmailTemplate.Items.Clear()
|
||||
If _emailTemplates IsNot Nothing AndAlso _emailTemplates.Rows.Count > 0 Then
|
||||
Dim bezeichnungen As New HashSet(Of String)()
|
||||
For Each row As DataRow In _emailTemplates.Rows
|
||||
Dim bezeichnung As String = If(IsDBNull(row("txt_bezeichnung")), "", CStr(row("txt_bezeichnung"))).Trim()
|
||||
If bezeichnung <> "" AndAlso Not bezeichnungen.Contains(bezeichnung) Then
|
||||
bezeichnungen.Add(bezeichnung)
|
||||
cmbCustomerUploadEmailTemplate.Items.Add(bezeichnung)
|
||||
End If
|
||||
Next
|
||||
End If
|
||||
|
||||
If cmbCustomerUploadEmailTemplate.Items.Count > 0 Then
|
||||
cmbCustomerUploadEmailTemplate.SelectedIndex = 0
|
||||
End If
|
||||
Catch ex As Exception
|
||||
' Fehler beim Laden ignorieren, Vorlagen bleiben leer
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub UpdateEmailText()
|
||||
If _emailTemplates Is Nothing OrElse _emailTemplates.Rows.Count = 0 Then Return
|
||||
|
||||
Dim selectedTemplate = If(cmbCustomerUploadEmailTemplate.SelectedItem, "").ToString()
|
||||
Dim selectedLang = If(cmbCustomerUploadLanguage.SelectedItem, "").ToString().ToLowerInvariant()
|
||||
If selectedLang = "" Then selectedLang = "de"
|
||||
|
||||
If selectedTemplate <> "" Then
|
||||
' Suche nach passender Vorlage und Sprache
|
||||
Dim foundText As String = ""
|
||||
For Each row As DataRow In _emailTemplates.Rows
|
||||
Dim bezeichnung = If(IsDBNull(row("txt_bezeichnung")), "", CStr(row("txt_bezeichnung"))).Trim()
|
||||
Dim sprache = If(IsDBNull(row("txt_sprache")), "", CStr(row("txt_sprache"))).Trim().ToLowerInvariant()
|
||||
|
||||
If String.Equals(bezeichnung, selectedTemplate, StringComparison.OrdinalIgnoreCase) Then
|
||||
' Wenn wir die genaue Sprache finden, nimm diese
|
||||
If String.Equals(sprache, selectedLang, StringComparison.OrdinalIgnoreCase) Then
|
||||
foundText = If(IsDBNull(row("txt_text")), "", CStr(row("txt_text")))
|
||||
Exit For
|
||||
End If
|
||||
' Fallback auf 'de' oder die erste gefundene Sprache, falls die gesuchte nicht existiert
|
||||
If foundText = "" OrElse String.Equals(sprache, "de", StringComparison.OrdinalIgnoreCase) Then
|
||||
foundText = If(IsDBNull(row("txt_text")), "", CStr(row("txt_text")))
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
If foundText <> "" Then
|
||||
txtCustomerUploadEmailText.Text = foundText.Replace("\n", vbCrLf)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub cmbCustomerUploadEmailTemplate_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbCustomerUploadEmailTemplate.SelectedIndexChanged
|
||||
UpdateEmailText()
|
||||
End Sub
|
||||
|
||||
Private Sub cmbCustomerUploadLanguage_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cmbCustomerUploadLanguage.SelectedIndexChanged
|
||||
UpdateEmailText()
|
||||
End Sub
|
||||
|
||||
Private Sub ResolveContextIds()
|
||||
If AvisoID > 0 AndAlso SendungID <> 0 Then Return
|
||||
|
||||
@@ -435,10 +505,10 @@ Public Class frmSendungsDokumentanforderung
|
||||
|
||||
Private Sub ConfigureAnforderungCheckbox(cb As CheckBox, container As Control)
|
||||
cb.AutoSize = False
|
||||
cb.Height = 18
|
||||
Dim usableWidth = Math.Max(120, container.Width - 20)
|
||||
Dim cbWidth = CInt(Math.Floor((usableWidth - 4) / 3))
|
||||
cb.Width = Math.Max(80, Math.Min(cbWidth, 220))
|
||||
cb.Height = 24
|
||||
Dim usableWidth = Math.Max(180, container.Width - 24)
|
||||
Dim cbWidth = CInt(Math.Floor((usableWidth - 12) / 4))
|
||||
cb.Width = Math.Max(120, Math.Min(cbWidth, 320))
|
||||
End Sub
|
||||
|
||||
Private Sub DocumentEditorInputChanged(sender As Object, e As EventArgs)
|
||||
@@ -788,10 +858,95 @@ Public Class frmSendungsDokumentanforderung
|
||||
txtSonstigesDokumentFehlt.Focus()
|
||||
Exit Sub
|
||||
End If
|
||||
If Not SaveSelectedVermerke() Then
|
||||
Exit Sub
|
||||
End If
|
||||
DialogResult = DialogResult.OK
|
||||
Close()
|
||||
End Sub
|
||||
|
||||
Private Function SaveSelectedVermerke() As Boolean
|
||||
Try
|
||||
If AvisoID <= 0 Then
|
||||
MsgBox("Aviso konnte nicht ermittelt werden.", vbExclamation)
|
||||
Return False
|
||||
End If
|
||||
|
||||
Dim sendungsText = GetSendungsAnzeigeText()
|
||||
|
||||
For Each cb In _anforderungCheckboxes
|
||||
If cb Is Nothing OrElse Not cb.Checked Then Continue For
|
||||
|
||||
Dim codeId As Integer = 0
|
||||
If Not Integer.TryParse(If(cb.Tag, "").ToString(), codeId) Then Continue For
|
||||
If codeId <= 0 Then Continue For
|
||||
|
||||
Dim text = GetBackendVermerkText(codeId, If(cb.Text, "").Trim())
|
||||
If text = "" Then Continue For
|
||||
text = AppendSendungIfMissing(text, sendungsText)
|
||||
|
||||
insertSendungsVermerk(SendungID, AvisoID, text, codeId)
|
||||
Next
|
||||
|
||||
If cbxSonstDok.Checked Then
|
||||
Dim customDocName = If(txtSonstigesDokumentFehlt.Text, "").Trim()
|
||||
If customDocName <> "" Then
|
||||
Dim text = GetBackendVermerkText(25, "")
|
||||
If text = "" Then
|
||||
text = customDocName
|
||||
Else
|
||||
text = text.Replace("''", "'" & customDocName & "'")
|
||||
If InStr(text, customDocName, CompareMethod.Text) = 0 Then
|
||||
text &= " [" & customDocName & "]"
|
||||
End If
|
||||
End If
|
||||
text = AppendSendungIfMissing(text, sendungsText)
|
||||
insertSendungsVermerk(SendungID, AvisoID, text, 25)
|
||||
End If
|
||||
End If
|
||||
|
||||
If cbxNichtLeserlich.Checked Then
|
||||
Dim text = GetBackendVermerkText(42, If(cbxNichtLeserlich.Text, "").Trim())
|
||||
text = AppendSendungIfMissing(text, sendungsText)
|
||||
If text <> "" Then
|
||||
insertSendungsVermerk(SendungID, AvisoID, text, 42)
|
||||
End If
|
||||
End If
|
||||
|
||||
Return True
|
||||
Catch ex As Exception
|
||||
MsgBox("Vermerk konnte nicht gespeichert werden: " & ex.Message, vbExclamation)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetSendungsAnzeigeText() As String
|
||||
If SendungID <= 0 Then Return "KOMPLETT"
|
||||
Try
|
||||
Return _admin.getValueTxtBySql(" SELECT convert(varchar(2),[tblSnd_PosUnterNr]) +' - ' +isnull([tblSnd_Empfaenger],'') FROM tblSendungen WHERE [tblSnd_SendungID]=" & SendungID, "AVISO").Trim()
|
||||
Catch
|
||||
Return SendungID.ToString()
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function GetBackendVermerkText(codeId As Integer, fallback As String) As String
|
||||
If _backendBezeichnungByCodeId.ContainsKey(codeId) Then
|
||||
Dim value = If(_backendBezeichnungByCodeId(codeId), "").Trim()
|
||||
If value <> "" Then
|
||||
Return value
|
||||
End If
|
||||
End If
|
||||
Return If(fallback, "").Trim()
|
||||
End Function
|
||||
|
||||
Private Function AppendSendungIfMissing(text As String, sendungsText As String) As String
|
||||
Dim value = If(text, "").Trim()
|
||||
Dim snd = If(sendungsText, "").Trim()
|
||||
If value = "" OrElse snd = "" Then Return value
|
||||
If InStr(value, "sendung", CompareMethod.Text) > 0 Then Return value
|
||||
Return value & " bei Sendung '" & snd & "'"
|
||||
End Function
|
||||
|
||||
Private Sub btnCustomerUploadLink_Click(sender As Object, e As EventArgs) Handles btnCustomerUploadLink.Click
|
||||
Dim validityHours = CInt(nudCustomerUploadValidityHours.Value)
|
||||
Dim config = GetCustomerPortalApiConfig()
|
||||
@@ -1275,7 +1430,7 @@ Public Class frmSendungsDokumentanforderung
|
||||
Public Property NichtLeserlichChecked As Boolean
|
||||
Public Property CustomerUploadEmail As String
|
||||
Public Property CustomerUploadLanguage As String = "de"
|
||||
Public Property CustomerUploadEmailText As String = "Bitte laden Sie die angeforderten Dokumente über den Link hoch."
|
||||
Public Property CustomerUploadEmailText As String = ""
|
||||
Public Property CustomerUploadValidityHours As Integer = 168
|
||||
End Class
|
||||
End Class
|
||||
|
||||
Reference in New Issue
Block a user