Files
ADMIN/UID/frmAPIEinstellungen.vb

132 lines
4.5 KiB
VB.net

Imports VERAG_PROG_ALLGEMEIN
Public Class frmAPIEinstellungen
Dim APIBind 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 frmAPIEinstellungen_Load(sender As Object, e As EventArgs) Handles MyBase.Load
loadDGV()
btnOK.Visible = True
End Sub
Private Sub loadDGV(Optional sqlwhere As String = "")
Try
APIBind = New cEasyBinding(BIND_DB)
If sqlwhere = "" Then
APIBind.initBinding("SELECT [api_active],[api_productive], [api_program],[api_id],[api_url] ,[api_user],[api_password] ,[api_UseToken],[api_token] ,[api_description] FROM " & table, table)
Else
APIBind.initBinding("SELECT [api_active],[api_productive], [api_program], [api_id],[api_url] ,[api_user],[api_password] ,[api_useToken],[api_token] ,[api_description] FROM " & table & " WHERE " & sqlwhere, table)
End If
DataGridView.DataSource = APIBind.bindingdataTable
With DataGridView
If .Columns.Count > 0 Then
.Columns("api_id").Visible = False
.Columns("api_active").HeaderText = "Aktiv"
.Columns("api_active").Width = 50
.Columns("api_productive").HeaderText = "Produktiv"
.Columns("api_productive").Width = 70
.Columns("api_program").HeaderText = "Programm"
.Columns("api_program").Width = 80
.Columns("api_url").HeaderText = "URL"
.Columns("api_url").Width = 150
.Columns("api_user").HeaderText = "User"
.Columns("api_user").Width = 100
.Columns("api_password").HeaderText = "PW"
.Columns("api_password").Width = 100
.Columns("api_useToken").HeaderText = "Token"
.Columns("api_useToken").Width = 40
.Columns("api_Token").HeaderText = "Token-Key"
.Columns("api_Token").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
.Columns("api_description").HeaderText = "Beschreibung"
.Columns("api_description").AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
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 &= " [api_program] like '%" & txtSuche.Text & "%' or [api_url] 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("api_active").Value = True
e.Row.Cells("api_productive").Value = False
e.Row.Cells("api_token").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
APIBind.updateBinding()
Exit Sub
End If
If DataGridView.CurrentRow.Cells("api_url").ToString <> "" AndAlso DataGridView.CurrentRow.Cells("api_user").ToString <> "" AndAlso DataGridView.CurrentRow.Cells("api_password").ToString <> "" AndAlso EditRow >= 0 Then
APIBind.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
End Class