Files
AVISO/Aviso/frmAvisoAnhangsarten.vb

181 lines
5.8 KiB
VB.net

Imports DocumentFormat.OpenXml.Wordprocessing
Imports iText.Forms.Xfdf
Imports iText.Kernel.Pdf
Imports System.Runtime.Remoting
Imports System.Web.UI
Public Class frmAvisoAnhangsarten
Dim SPRACHENBind As cEasyBinding
Public table
Public BIND_DB
Private EditRow As Integer = -1
Sub New(table, BIND_DB)
Me.table = table
Me.BIND_DB = BIND_DB
InitializeComponent()
End Sub
Private Sub frmSprachen_Load(sender As Object, e As EventArgs) Handles MyBase.Load
loadDGV()
' btnOK.Visible = True
End Sub
Private Sub loadDGV(Optional sqlwhere As String = "")
Try
SPRACHENBind = New cEasyBinding(BIND_DB)
If sqlwhere = "" Then
SPRACHENBind.initBinding("SELECT [aa_aktiv], [aa_id],[aa_bezeichnung] ,[aa_name],[aa_sort] ,[aa_isBrexti] ,[aa_firma],[aa_filiale] FROM " & table, table)
Else
SPRACHENBind.initBinding("SELECT [aa_aktiv],[aa_id],[aa_bezeichnung] ,[aa_name],[aa_sort] ,[aa_isBrexti] ,[aa_firma],[aa_filiale] FROM " & table & " WHERE " & sqlwhere, table)
End If
DataGridView.DataSource = SPRACHENBind.bindingdataTable
With DataGridView
If .Columns.Count > 0 Then
.Columns("aa_id").Visible = False
.Columns("aa_name").HeaderText = "Name"
.Columns("aa_name").Width = 150
.Columns("aa_sort").HeaderText = "Sort."
.Columns("aa_sort").Width = 40
.Columns("aa_isBrexti").HeaderText = "Brexit"
.Columns("aa_isBrexti").Width = 40
.Columns("aa_aktiv").HeaderText = "Aktiv"
.Columns("aa_aktiv").Width = 40
.Columns("aa_bezeichnung").HeaderText = "Bezeichnung"
.Columns("aa_bezeichnung").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
.Columns("aa_firma").HeaderText = "nur für Firma"
.Columns("aa_firma").Width = 100
.Columns("aa_filiale").HeaderText = "nur für Filiale"
.Columns("aa_filiale").Width = 100
End If
End With
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub TextBox1_PreviewKeyDown(sender As Object, e As PreviewKeyDownEventArgs) Handles txtSuche.PreviewKeyDown
Dim sqladdon As String = ""
If e.KeyCode = Keys.Enter Then
If txtSuche.Text <> "" Then
sqladdon &= " [aa_name] like '%" & txtSuche.Text & "%' or [aa_bezeichnung] like '%" & txtSuche.Text & "%'"
End If
loadDGV(sqladdon)
End If
End Sub
Private Sub DataGridView_DefaultValuesNeeded(sender As Object, e As DataGridViewRowEventArgs) Handles DataGridView.DefaultValuesNeeded
Try
e.Row.Cells("aa_aktiv").Value = True
e.Row.Cells("aa_isBrexti").Value = False
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
If DataGridView.Columns.Count = 0 Or DataGridView.SelectedRows.Count = 0 Then 'alles gelöscht oder markierte Zeile gelöscht
SPRACHENBind.updateBinding()
Exit Sub
End If
If DataGridView.CurrentRow.Cells("aa_name").ToString <> "" AndAlso DataGridView.CurrentRow.Cells("aa_sort").ToString <> "" AndAlso DataGridView.CurrentRow.Cells("aa_bezeichnung").ToString <> "" AndAlso EditRow >= 0 Then
SPRACHENBind.updateBinding()
End If
End Sub
Private Sub DataGridView_EditingControlShowing(sender As Object, e As DataGridViewEditingControlShowingEventArgs) Handles DataGridView.EditingControlShowing
EditRow = DataGridView.CurrentRow.Index
End Sub
Private Sub DataGridView_SelectionChanged(sender As Object, e As EventArgs) Handles DataGridView.SelectionChanged
If EditRow >= 0 Then
Dim new_row As Integer = EditRow
EditRow = -1
DataGridView.CurrentCell = DataGridView.Rows(new_row).Cells(
DataGridView.CurrentCell.ColumnIndex)
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim sql As New VERAG_PROG_ALLGEMEIN.SQL
Dim dtAnhaenge As DataTable = sql.loadDgvBySql("SELECT distinct([anh_Art]) as bezeichnung FROM [tblAvisoAnhaenge]", "AVISO")
Dim dtAnhangsarten As DataTable = sql.loadDgvBySql("SELECT distinct([aa_bezeichnung]) as bezeichnung FROM " & table, "AVISO")
If dtAnhaenge.Rows.Count = 0 Or dtAnhangsarten.Rows.Count = 0 Then Exit Sub
Dim resultsTable As New DataTable
resultsTable.Columns.Add("bezeichnung", GetType(String))
For Each rowAnhang As DataRow In dtAnhaenge.Rows
If rowAnhang(0) <> "" Then
Dim isExisting As Boolean = False
For Each rowArt As DataRow In dtAnhangsarten.Rows
If rowArt(0) = rowAnhang(0) Then
isExisting = True
Exit For
End If
Next
If Not isExisting Then
Dim R As DataRow = resultsTable.NewRow
R(0) = rowAnhang(0)
resultsTable.Rows.Add(R)
End If
End If
Next
If resultsTable.Rows.Count > 0 Then
Dim b = New System.Text.StringBuilder()
For Each resultRow In resultsTable.Rows
b.Append(resultRow(0) & vbNewLine)
Next
MsgBox(resultsTable.Rows.Count & " fehlende Anhangsarten:" & vbNewLine & b.ToString)
Else
MsgBox("keine fehlenden Anhangsarten")
End If
End Sub
End Class