295 lines
10 KiB
VB.net
295 lines
10 KiB
VB.net
Imports System.IO
|
|
Imports VERAG_PROG_ALLGEMEIN
|
|
|
|
Public Class frmKundenSicherheiten_Details
|
|
|
|
Private Sicherheit As cKundenSicherheiten = Nothing
|
|
Private loadedScId As Integer = -1
|
|
|
|
Public kdnr As Integer = -1
|
|
Private DSID As Integer = -1 ' Datenarchiv-ID (PDF)
|
|
|
|
Sub New()
|
|
InitializeComponent()
|
|
End Sub
|
|
|
|
Sub New(sc_id As Integer)
|
|
InitializeComponent()
|
|
If sc_id > 0 Then
|
|
Sicherheit = New cKundenSicherheiten(sc_id)
|
|
loadedScId = sc_id
|
|
If Sicherheit.hasEntry Then
|
|
DSID = Sicherheit.sc_dsId
|
|
End If
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub frm_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
|
|
txtKunde.initKdBox(Me)
|
|
|
|
cboSicherheitsart.Items.Clear()
|
|
cboSicherheitsart.Items.Add(New MyListItem("", ""))
|
|
cboSicherheitsart.Items.Add(New MyListItem("BANKGARANTIE", "BANKGARANTIE"))
|
|
cboSicherheitsart.Items.Add(New MyListItem("WECHSEL", "WECHSEL"))
|
|
cboSicherheitsart.Items.Add(New MyListItem("BARDEPOT", "BARDEPOT"))
|
|
|
|
cboSicherheitsgeberLand.DropDownWidth = 300
|
|
cboSicherheitsgeberLand.fillWithSQL("SELECT [Code],[Description] FROM [tbl_DY_ZollDE_C0008_LaenderFull] WHERE (StartDate IS NULL OR StartDate <= GETDATE() ) AND (EndDate IS NULL OR EndDate >= GETDATE()) ORDER BY Code",
|
|
True, "FMZOLL", True)
|
|
|
|
If Sicherheit IsNot Nothing AndAlso Sicherheit.hasEntry Then
|
|
loadValues()
|
|
kdnr = Sicherheit.sc_kundenNr
|
|
txtKunde.Enabled = False
|
|
End If
|
|
|
|
togglePDFPic()
|
|
End Sub
|
|
|
|
Private Sub frmKundenSicherheiten_Details_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
|
If kdnr > 0 Then
|
|
txtKunde.KdNr = kdnr
|
|
txtKunde.Enabled = False
|
|
End If
|
|
|
|
End Sub
|
|
|
|
'========================
|
|
' Laden / Speichern
|
|
'========================
|
|
|
|
Sub loadValues()
|
|
txtKunde.KdNr = Sicherheit.sc_kundenNr
|
|
txtDatumVon._value = Sicherheit.sc_gueltigVon
|
|
txtDatumBis._value = Sicherheit.sc_gueltigBis
|
|
cboSicherheitsart._value = Sicherheit.sc_Art
|
|
txtSicherheitsgeber._value = Sicherheit.sc_Sicherheitsgeber
|
|
cboSicherheitsgeberLand._value = Sicherheit.sc_SicherheitsgeberLand
|
|
txtBetrag._value = Sicherheit.sc_Betrag
|
|
MyTextBox3._value = Sicherheit.sc_Waehrung
|
|
txtInfo.Text = If(Sicherheit.sc_Bemerkung, "")
|
|
End Sub
|
|
|
|
Sub getValues()
|
|
Sicherheit.sc_kundenNr = txtKunde.KdNr
|
|
Sicherheit.sc_datum = Now
|
|
Sicherheit.sc_gueltigVon = txtDatumVon._value
|
|
Sicherheit.sc_gueltigBis = txtDatumBis._value
|
|
Sicherheit.sc_Art = cboSicherheitsart._value
|
|
Sicherheit.sc_Sicherheitsgeber = txtSicherheitsgeber._value
|
|
Sicherheit.sc_SicherheitsgeberLand = cboSicherheitsgeberLand._value
|
|
Sicherheit.sc_Betrag = txtBetrag._value
|
|
Sicherheit.sc_Waehrung = MyTextBox3._value
|
|
Sicherheit.sc_dsId = DSID
|
|
Sicherheit.sc_Bemerkung = txtInfo.Text
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click
|
|
|
|
If Not doValidation() Then
|
|
Me.DialogResult = DialogResult.None
|
|
Exit Sub
|
|
End If
|
|
|
|
If Sicherheit Is Nothing Then
|
|
Sicherheit = New cKundenSicherheiten(0)
|
|
End If
|
|
|
|
getValues()
|
|
|
|
If Sicherheit.SAVE() Then
|
|
Me.Close()
|
|
Else
|
|
MsgBox("Fehler beim Speichern der Kundensicherheit.")
|
|
Me.DialogResult = DialogResult.None
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Function doValidation() As Boolean
|
|
|
|
Label4.Visible = False
|
|
lblErr_Ausstellungsdatum.Visible = False
|
|
Label13.Visible = False
|
|
Label7.Visible = False
|
|
Label6.Visible = False
|
|
lblErr_DocNr.Visible = False
|
|
|
|
If txtKunde.KdNr <= 0 Then
|
|
Label4.Visible = True
|
|
Return False
|
|
End If
|
|
|
|
If txtDatumVon._value = "" Then
|
|
lblErr_Ausstellungsdatum.Visible = True
|
|
Return False
|
|
End If
|
|
|
|
If cboSicherheitsart.Text = "" Then
|
|
lblErr_DocNr.Visible = True
|
|
Return False
|
|
End If
|
|
|
|
If txtSicherheitsgeber.Text = "" Then
|
|
Label6.Visible = True
|
|
Return False
|
|
End If
|
|
|
|
|
|
If txtDatumBis._value = "" Then
|
|
Label13.Visible = True
|
|
Return False
|
|
End If
|
|
|
|
If Not IsNumeric(txtBetrag._value) Then
|
|
Label7.Visible = True
|
|
Return False
|
|
End If
|
|
|
|
Return True
|
|
End Function
|
|
|
|
'========================
|
|
' Dokumentenhandling (dsId)
|
|
'========================
|
|
|
|
Sub togglePDFPic()
|
|
PictureBox1.BackgroundImage =
|
|
If(DSID > 0, My.Resources.pdf, My.Resources.pdf_gray)
|
|
End Sub
|
|
|
|
Private Sub btnUpload_Click(sender As Object, e As EventArgs) Handles btnUpload.Click
|
|
addData_Anhang()
|
|
togglePDFPic()
|
|
End Sub
|
|
|
|
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
|
|
If DSID > 0 Then
|
|
Dim path = cDATENSERVER.GET_PDFPath_BY_DocID(DSID)
|
|
If path <> "" Then Process.Start(path)
|
|
End If
|
|
End Sub
|
|
|
|
Sub addData_Anhang()
|
|
|
|
Dim fd As New OpenFileDialog With {.Multiselect = False}
|
|
|
|
If fd.ShowDialog <> DialogResult.OK Then Exit Sub
|
|
|
|
Dim fi As New FileInfo(fd.FileName)
|
|
Dim Typ As String = ""
|
|
|
|
If Not getFileTypeValid(fi.Extension.Replace(".", ""), Typ) Then Exit Sub
|
|
|
|
Dim anhId = -1
|
|
Dim destPath = ""
|
|
|
|
If saveToDS(fi.Name, fd.FileName, "KUNDENSICHERHEIT", Typ, DSID, anhId, destPath) Then
|
|
togglePDFPic()
|
|
End If
|
|
|
|
End Sub
|
|
|
|
'========================
|
|
' Buttons
|
|
'========================
|
|
|
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
Me.Close()
|
|
End Sub
|
|
|
|
Public Shared Function getFileTypeValid(extension, ByRef Typ) As Boolean
|
|
Select Case extension.ToString.Replace(".", "").ToUpper
|
|
Case "PDF" : Typ = "PDF"
|
|
Case "XLS", "XLM", "XLSM", "XLSX", "CSV" : Typ = "EXCEL"
|
|
Case "DOC", "DOCX" : Typ = "WORD"
|
|
Case "TXT" : Typ = "TEXT"
|
|
Case "JPEG", "JPG", "GIF", "TFF" : Typ = "BILD"
|
|
Case "EXE" : MsgBox("Aviso-Anhänge: Ungültiges Datei-Format!") : Return False
|
|
Case Else : Typ = "SONSTIGES"
|
|
End Select
|
|
Return True
|
|
End Function
|
|
|
|
Public Shared Function saveToDS(ByRef fileName, sourcePath, Art, Typ, Optional ByRef da_id = -1, Optional ByRef anhId = -1, Optional ByRef destPath = "", Optional SendungsId = Nothing) As Boolean
|
|
fileName = VERAG_PROG_ALLGEMEIN.cDATENSERVER.replaceInvalidCahr(fileName)
|
|
|
|
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "KUNDEN_SICHERHEITEN", Now.Year, Now.ToString("ddMMyy"), "", Now.ToString("ddMMyyHHmmss") & fileName, -1, False)
|
|
If Not DS.uploadDataToDATENSERVER(sourcePath) Then MsgBox("Fehler beim Speichern: Datenserver!") : Return False
|
|
If DS.da_id <= 0 Then MsgBox("Keine DocId!") : Return False
|
|
|
|
da_id = DS.da_id
|
|
destPath = DS.GET_TOP1_PATH
|
|
Dim fi As New FileInfo(sourcePath)
|
|
Return True
|
|
End Function
|
|
|
|
Private Sub btnScan_Click(sender As Object, e As EventArgs) Handles btnScan.Click
|
|
quickScan()
|
|
togglePDFPic()
|
|
End Sub
|
|
Public Function quickScan(Optional SendungsId = Nothing) As Boolean
|
|
Try
|
|
'If KdNr < 0 Then Exit Sub
|
|
Dim frmScan As New VERAG_PROG_ALLGEMEIN.frmScan("QuickScan")
|
|
frmScan.DefaultFileName = "ScanKUNDEN_SICHERHEITEN" & Now.ToString("ddMMyyyy_HHmmss") ' Me._TEXT_PDF
|
|
|
|
If frmScan.ShowDialog() = DialogResult.OK Then
|
|
If frmScan.ReturnValue IsNot Nothing Then
|
|
Dim Filename = frmScan.fileName
|
|
Dim TMP_Path = VERAG_PROG_ALLGEMEIN.DATENVERVER_OPTIONS.getTMPPath(Filename, ".pdf",, False, "SendungsAnhaenge")
|
|
File.WriteAllBytes(TMP_Path, frmScan.ReturnValue)
|
|
|
|
Dim anhId = -1
|
|
Dim destPath = ""
|
|
If saveToDS(Filename, TMP_Path, "KUNDEN_SICHERHEITEN", "PDF", DSID, anhId, destPath, SendungsId) Then
|
|
Return True
|
|
End If
|
|
'addUsrcnlToPnl(TMP_Path)
|
|
End If
|
|
End If
|
|
|
|
Catch ex As Exception
|
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name,, "Fehler QuickScan")
|
|
End Try
|
|
Return False
|
|
End Function
|
|
|
|
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
|
Dim data As IDataObject = Clipboard.GetDataObject
|
|
If True Then 'data.GetDataPresent(DataFormats.FileDrop) Then
|
|
For Each s As String In My.Computer.Clipboard.GetFileDropList() 'GetData(DataFormats.) 'data.GetData(DataFormats.FileDrop) 'DataFormats.FileDrop)
|
|
' Dim F_listItem As String = Path.Combine("c:\mynewpath", Path.GetFileName(s))
|
|
' File.Copy(s, newFile)
|
|
' MsgBox(s)
|
|
If System.IO.File.Exists(s) Then
|
|
|
|
Dim fi As New FileInfo(s)
|
|
Dim filename = fi.Name
|
|
If filename = "" Then
|
|
MsgBox("Dateiname konnte nicht ermittelt werden." & vbNewLine & s)
|
|
Else
|
|
|
|
Dim anhId = -1
|
|
Dim destPath = ""
|
|
|
|
Dim Typ = ""
|
|
If getFileTypeValid(fi.Extension.Replace(".", ""), Typ) Then
|
|
If saveToDS(filename, s, "KUNDEN_SICHERHEITEN", Typ, DSID, anhId, destPath) Then
|
|
MsgBox("Dokument wurde hochgeladen.")
|
|
End If
|
|
End If
|
|
End If
|
|
End If
|
|
Next
|
|
|
|
End If
|
|
togglePDFPic()
|
|
End Sub
|
|
|
|
|
|
End Class
|