You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
849 lines
33 KiB
849 lines
33 KiB
Imports System.IO
|
|
Imports MySql.Data.MySqlClient
|
|
Imports MySql.Data.Types
|
|
|
|
|
|
#Const dbtype = "SQL"
|
|
|
|
#If dbtype = "MySQL" Then
|
|
Public Class clsDB
|
|
#Else
|
|
Public Class clsMySQKDB
|
|
#End If
|
|
|
|
#Region "Deklarationen"
|
|
Dim m_connectionstring As String
|
|
|
|
Property Connectionstring As String
|
|
Get
|
|
Return m_connectionstring
|
|
End Get
|
|
Set(value As String)
|
|
m_connectionstring = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
|
|
Sub New()
|
|
Me.Connectionstring = My.Settings.ConnectionString
|
|
End Sub
|
|
|
|
Public dsDaten As New DataSet
|
|
Public dssql As New DataSet
|
|
Public dadaten As MySqlDataAdapter
|
|
|
|
#End Region
|
|
|
|
#Region "Allgemein Get / Save"
|
|
Public Sub Dispose()
|
|
dsDaten.Dispose()
|
|
dssql.Dispose()
|
|
|
|
End Sub
|
|
|
|
Public Function Get_Option(ByVal nr As Integer) As String
|
|
|
|
Try
|
|
|
|
|
|
Dim dad As New MySqlDataAdapter
|
|
|
|
|
|
Dim sql As String = "Select Inhalt from options where nroption=" + nr.ToString + " and mandant=" + Globals.Mandant.ToString + " and aktiv=1"
|
|
Dim data As New DataTable
|
|
|
|
dad = New MySqlDataAdapter(sql, Me.Connectionstring)
|
|
|
|
dad.Fill(data)
|
|
Dim s As String
|
|
s = data.Rows(0).Item(0).ToString.Replace("&Startup&", Application.StartupPath + Globals.Auswertungsverzeicnis)
|
|
Return s
|
|
dad.Dispose()
|
|
data.Dispose()
|
|
Catch ex As Exception
|
|
Dim a As Integer = 1
|
|
End Try
|
|
|
|
End Function
|
|
Public Function Get_Datavalue(sql As String, Optional args As String = "") As String
|
|
Try
|
|
Try
|
|
dsDaten.Clear()
|
|
dsDaten.Tables.Clear()
|
|
If sql <> "" Then
|
|
sql = sql.Replace("&ARGS&", args)
|
|
|
|
dadaten = New MySqlDataAdapter(sql, Me.Connectionstring)
|
|
|
|
|
|
End If
|
|
Dim dt As New DataTable
|
|
dadaten.Fill(dt)
|
|
Return dt.Rows(0).Item(0)
|
|
Catch ex As Exception
|
|
Dim a As Integer = 1
|
|
End Try
|
|
|
|
Catch ex As Exception
|
|
Dim a As Integer = 1
|
|
End Try
|
|
End Function
|
|
Public Sub Get_Tabledata(ByVal tablename As String, Optional wherestatement As String = "", Optional SQL As String = "", Optional args As String = "", Optional SP As Boolean = False, Optional SP_Params As DataTable = Nothing)
|
|
If SP = True Then
|
|
|
|
End If
|
|
Try
|
|
dsDaten.Clear()
|
|
dsDaten.Tables.Clear()
|
|
dadaten = New MySqlDataAdapter(SQL, Me.Connectionstring)
|
|
If SP = True Then
|
|
Dim sqlcmd As New MySqlCommand
|
|
Dim sqlconnect As New MySqlConnection
|
|
sqlconnect.ConnectionString = Me.Connectionstring
|
|
sqlcmd.CommandType = CommandType.StoredProcedure
|
|
sqlcmd.CommandText = tablename
|
|
For Each r As DataRow In SP_Params.Rows
|
|
sqlcmd.Parameters.Add(r("Paramname"), SqlDbType.VarChar)
|
|
sqlcmd.Parameters(sqlcmd.Parameters.Count - 1).Value = r("Paramvalue")
|
|
Next
|
|
sqlcmd.Connection = sqlconnect
|
|
Try
|
|
dadaten.SelectCommand = sqlcmd
|
|
dadaten.Fill(dsDaten, tablename)
|
|
|
|
Exit Sub
|
|
Catch ex As Exception
|
|
sqlconnect.Open()
|
|
sqlcmd.ExecuteNonQuery()
|
|
sqlconnect.Close()
|
|
End Try
|
|
|
|
End If
|
|
If SQL <> "" Then
|
|
SQL = SQL.Replace("&ARGS&", args)
|
|
SQL = SQL.Replace("[", "")
|
|
SQL = SQL.Replace("]", "")
|
|
SQL = SQL.Replace("'", "`")
|
|
SQL = SQL.Replace("dbo.", "")
|
|
dadaten = New MySqlDataAdapter(SQL, Me.Connectionstring)
|
|
Else
|
|
Dim statement As String = "select * from " + tablename + " " + wherestatement
|
|
statement = statement.Replace("[", "")
|
|
statement = statement.Replace("[", "")
|
|
statement = statement.Replace("'", "`")
|
|
statement = statement.Replace("dbo.", "")
|
|
dadaten = New MySqlDataAdapter(statement, Me.Connectionstring)
|
|
End If
|
|
'dadaten = New MySQLDataadapter("select * from " + tablename + " " + wherestatement, Me.Connectionstring)
|
|
dadaten.Fill(dsDaten, tablename)
|
|
If encrypted = True Then
|
|
For Each r As DataRow In dsDaten.Tables(0).Rows
|
|
For Each c As DataColumn In dsDaten.Tables(0).Columns
|
|
Select Case UCase(c.ColumnName)
|
|
Case "NAME", "VORNAME", "STRASSE", "PLZ", "ORT", "TELP", "PATIENT", "BEHANDLER"
|
|
r(c.ColumnName) = Crypto.DecryptText(r(c.ColumnName), Globals.encryptkey)
|
|
End Select
|
|
Next
|
|
Next
|
|
End If
|
|
Catch ex As Exception
|
|
Dim a As Integer = 1
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
|
|
Public Sub Update_Data()
|
|
Dim cb As New MySqlCommandBuilder(dadaten)
|
|
dadaten.Update(dsDaten, dsDaten.Tables(0).TableName)
|
|
End Sub
|
|
|
|
Dim da As MySqlDataAdapter
|
|
Dim qb As New MySqlCommandBuilder
|
|
Public daten As New DataSet
|
|
Public Function Get_Tabledata_for_Update(ByVal Tablename As String, Optional StoredProc As Boolean = False, Optional is_SQL_String As Boolean = False) As DataTable
|
|
Dim sqlconnect As New MySqlConnection
|
|
Dim ds As New DataSet
|
|
ds.Tables.Clear()
|
|
sqlconnect.ConnectionString = Me.Connectionstring
|
|
sqlconnect.Open()
|
|
da = New MySqlDataAdapter("", sqlconnect)
|
|
Dim sqlcmd As New MySqlCommand
|
|
sqlcmd.Connection = sqlconnect
|
|
If StoredProc = True Then
|
|
sqlcmd.CommandType = CommandType.StoredProcedure
|
|
sqlcmd.CommandText = Tablename
|
|
Else
|
|
sqlcmd.CommandType = CommandType.Text
|
|
sqlcmd.CommandText = "Select * from " + Tablename
|
|
End If
|
|
If is_SQL_String = True Then
|
|
sqlcmd.CommandText = Tablename
|
|
End If
|
|
' sqlcmd.CommandType = CommandType.StoredProcedure
|
|
' sqlcmd.CommandText = "Berufsliste"
|
|
da.SelectCommand = sqlcmd
|
|
da.Fill(daten, "Daten")
|
|
qb = New MySqlCommandBuilder(da)
|
|
End Function
|
|
|
|
Public Sub Update_Tabeldata()
|
|
da.Update(daten, "Daten")
|
|
End Sub
|
|
|
|
Public Sub Exec_Prod(ByVal Procedure As String)
|
|
Dim scmCmdToExecute As MySqlCommand = New MySqlCommand()
|
|
|
|
scmCmdToExecute.CommandText = Procedure
|
|
Dim conn As New MySqlConnection(My.Settings.ConnectionString)
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
scmCmdToExecute.Connection = conn
|
|
Try
|
|
scmCmdToExecute.Connection.Open()
|
|
scmCmdToExecute.ExecuteNonQuery()
|
|
Return
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
scmCmdToExecute.Connection.Close()
|
|
End Try
|
|
End Sub
|
|
|
|
Public Sub Exec_SQL(ByVal SQL As String)
|
|
Dim scmCmdToExecute As MySqlCommand = New MySqlCommand()
|
|
|
|
scmCmdToExecute.CommandText = SQL
|
|
Dim conn As New MySqlConnection(My.Settings.ConnectionString)
|
|
scmCmdToExecute.CommandType = CommandType.Text
|
|
scmCmdToExecute.Connection = conn
|
|
Try
|
|
scmCmdToExecute.Connection.Open()
|
|
scmCmdToExecute.ExecuteNonQuery()
|
|
Return
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
scmCmdToExecute.Connection.Close()
|
|
End Try
|
|
End Sub
|
|
|
|
Public Function updatedata(ByVal Tablename As String, ByVal sourcetable As DataTable, Optional StoredProc As Boolean = False, Optional is_SQL_String As Boolean = False) As DataSet
|
|
Dim sqlconnect As New MySqlConnection
|
|
Dim ds As New DataSet
|
|
Dim qb As New MySqlCommandBuilder
|
|
ds.Tables.Clear()
|
|
sqlconnect.ConnectionString = Me.Connectionstring
|
|
sqlconnect.Open()
|
|
Dim da As New MySqlDataAdapter("", sqlconnect)
|
|
Dim sqlcmd As New MySqlCommand
|
|
sqlcmd.Connection = sqlconnect
|
|
If StoredProc = True Then
|
|
sqlcmd.CommandType = CommandType.StoredProcedure
|
|
sqlcmd.CommandText = Tablename
|
|
Else
|
|
sqlcmd.CommandType = CommandType.Text
|
|
sqlcmd.CommandText = "Select * from " + Tablename
|
|
End If
|
|
If is_SQL_String = True Then
|
|
sqlcmd.CommandText = Tablename
|
|
End If
|
|
' sqlcmd.CommandType = CommandType.StoredProcedure
|
|
' sqlcmd.CommandText = "Berufsliste"
|
|
da.SelectCommand = sqlcmd
|
|
da.Fill(ds, "Daten")
|
|
qb = New MySqlCommandBuilder(da)
|
|
For Each c As DataColumn In sourcetable.Columns
|
|
ds.Tables(0).Rows(0).Item(c.ColumnName) = sourcetable.Rows(0).Item(c.ColumnName)
|
|
Next
|
|
da.Update(ds, "Daten")
|
|
End Function
|
|
|
|
Public Function Insert_New_Entry(Table As String, Optional KeyName As String = "", Optional getdbkey As Boolean = False, Optional sqlstring As String = "") As DataTable
|
|
Dim dbkey As Integer = 0
|
|
If getdbkey Then
|
|
dsDaten.Tables.Clear()
|
|
|
|
Get_Tabledata("firmaap", "", sqlstring, "", False)
|
|
dbkey = dsDaten.Tables(0).Rows(0).Item(0) + 1
|
|
End If
|
|
Dim sqlconnect As New MySqlConnection
|
|
Dim ds As New DataSet
|
|
ds.Tables.Clear()
|
|
sqlconnect.ConnectionString = Me.Connectionstring
|
|
Dim da As New MySqlDataAdapter("", sqlconnect)
|
|
Dim sqlcmd As New MySqlCommand
|
|
sqlcmd.Connection = sqlconnect
|
|
Dim sql As String
|
|
sqlcmd.CommandText = "Insert into " + Table + " (" + KeyName + ",aktiv,erstellt_am,mutiert_am,mutierer) values(" + dbkey.ToString + ",1,getdate(),getdate()," + Globals.ActUser.ToString + ")"
|
|
sqlconnect.Open()
|
|
sqlcmd.ExecuteNonQuery()
|
|
sqlconnect.Close()
|
|
Dim data As New DataTable
|
|
dsDaten.Tables.Clear()
|
|
Get_Tabledata(Table, "", "Select top 1 * from " + Table + " order by " + KeyName + " desc")
|
|
|
|
|
|
Return dsDaten.Tables(0)
|
|
|
|
End Function
|
|
|
|
Public Function Insert_New_Entry_autokey(Table As String, Optional KeyName As String = "", Optional getdbkey As Boolean = False, Optional sqlstring As String = "") As DataTable
|
|
Dim dbkey As Integer = 0
|
|
If getdbkey Then
|
|
dsDaten.Tables.Clear()
|
|
|
|
Get_Tabledata("firmaap", "", sqlstring, "", False)
|
|
dbkey = dsDaten.Tables(0).Rows(0).Item(0) + 1
|
|
End If
|
|
Dim sqlconnect As New MySqlConnection
|
|
Dim ds As New DataSet
|
|
ds.Tables.Clear()
|
|
sqlconnect.ConnectionString = Me.Connectionstring
|
|
Dim da As New MySqlDataAdapter("", sqlconnect)
|
|
Dim sqlcmd As New MySqlCommand
|
|
sqlcmd.Connection = sqlconnect
|
|
Dim sql As String
|
|
sqlcmd.CommandText = "Insert into " + Table + " (aktiv,erstellt_am,mutiert_am,mutierer) values(1,getdate(),getdate()," + Globals.ActUser.ToString + ")"
|
|
sqlconnect.Open()
|
|
sqlcmd.ExecuteNonQuery()
|
|
sqlconnect.Close()
|
|
Dim data As New DataTable
|
|
dsDaten.Tables.Clear()
|
|
Get_Tabledata(Table, "", "Select top 1 * from " + Table + " order by " + KeyName + " desc")
|
|
|
|
|
|
Return dsDaten.Tables(0)
|
|
|
|
End Function
|
|
|
|
Public Sub Copy_Behandlung(ByVal behandlugnsnr As String, typ As String)
|
|
Dim scmCmdToExecute As MySqlCommand = New MySqlCommand()
|
|
scmCmdToExecute.CommandText = "dbo.[sp_copy_behandlung]"
|
|
Dim conn As New MySqlConnection(My.Settings.ConnectionString)
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
scmCmdToExecute.Connection = conn
|
|
Try
|
|
scmCmdToExecute.Parameters.Add(New MySqlParameter("@behandlungsnr", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, behandlugnsnr))
|
|
scmCmdToExecute.Parameters.Add(New MySqlParameter("@typ", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, typ))
|
|
|
|
scmCmdToExecute.Connection.Open()
|
|
scmCmdToExecute.ExecuteNonQuery()
|
|
Return
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
scmCmdToExecute.Connection.Close()
|
|
End Try
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "Spalten"
|
|
Public Sub Generate_SpaltenData(ByVal tablename As String)
|
|
Dim scmCmdToExecute As MySqlCommand = New MySqlCommand()
|
|
Dim dttable As New DataTable(tablename)
|
|
scmCmdToExecute.CommandText = "dbo.[sp_update_spalten]"
|
|
Dim conn As New MySqlConnection(My.Settings.ConnectionString)
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
scmCmdToExecute.Connection = conn
|
|
Try
|
|
scmCmdToExecute.Parameters.Add(New MySqlParameter("@Tablename", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, tablename))
|
|
scmCmdToExecute.Connection.Open()
|
|
scmCmdToExecute.ExecuteNonQuery()
|
|
Return
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
scmCmdToExecute.Connection.Close()
|
|
End Try
|
|
End Sub
|
|
|
|
Public Function Get_Spaltendata()
|
|
Try
|
|
Dim dbRow As DataRow
|
|
Dim dsPartner As New DataSet
|
|
dadaten = New MySqlDataAdapter("select * from Spalten where aktiv=1", Me.Connectionstring)
|
|
dadaten.Fill(dsDaten, "Daten")
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
End Function
|
|
|
|
Public Function Get_SQL(ByVal nr As Integer) As String
|
|
Try
|
|
If Globals.SQLStatements.Rows.Count = 0 Then
|
|
dssql.Clear()
|
|
dadaten = New MySqlDataAdapter("select * from sql_statements", Me.Connectionstring)
|
|
dadaten.Fill(dssql, "SQLStatements")
|
|
Globals.SQLStatements = dssql.Tables(0).Copy
|
|
End If
|
|
For Each r As DataRow In Globals.SQLStatements.Rows
|
|
If r(0) = nr Then
|
|
Return r(1)
|
|
Exit Function
|
|
|
|
End If
|
|
Next
|
|
Catch
|
|
End Try
|
|
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
#Region "Suche"
|
|
Public Function Search(ByVal Type As String, ByVal Searchstring As String) As Integer
|
|
Select Case Type
|
|
Case "Patient"
|
|
|
|
If IsNumeric(Searchstring) Then
|
|
Get_Tabledata("privat", " where nrprivat=" + Searchstring + " order by name, vorname, ort")
|
|
If dsDaten.Tables(0).Rows.Count = 0 Then
|
|
MsgBox("Keine Daten mit der Nr. " + Searchstring + " gefunden.", vbExclamation)
|
|
Return -1
|
|
End If
|
|
Else
|
|
Get_Tabledata("privat", " where name like '" + Searchstring + "%'" + " order by name, vorname, ort")
|
|
If dsDaten.Tables(0).Rows.Count = 0 Then
|
|
MsgBox("Keine Daten mit dem Suchbegriff " + Searchstring + " gefunden.", vbExclamation)
|
|
Return -1
|
|
End If
|
|
End If
|
|
If dsDaten.Tables(0).Rows.Count = 1 Then
|
|
Return (dsDaten.Tables(0).Rows(0).Item("nrprivat"))
|
|
Else
|
|
Dim f As New frmPrivatSelect
|
|
f.Text = "Patient-Suche"
|
|
f.TreeView1.Nodes.Clear()
|
|
|
|
For Each r As DataRow In dsDaten.Tables(0).Rows
|
|
Dim tn As New TreeNode
|
|
tn.Text = r("nrprivat").ToString + " " + r("Name") + " " + r("vorname") + ", " + r("PLZ") + " " + r("ort")
|
|
tn.Tag = r("nrprivat")
|
|
f.TreeView1.Nodes.Add(tn)
|
|
Next
|
|
f.TreeView1.SelectedNode = f.TreeView1.Nodes(0)
|
|
f.StartPosition = FormStartPosition.CenterParent
|
|
f.ShowDialog()
|
|
If f.DialogResult = DialogResult.OK Then
|
|
Return f.TreeView1.SelectedNode.Tag
|
|
Else
|
|
Return -1
|
|
End If
|
|
End If
|
|
Return -1
|
|
Case "Firma"
|
|
If IsNumeric(Searchstring) Then
|
|
Get_Tabledata("firma", " where nrfirma=" + Searchstring + " order by name1, name2, ort")
|
|
If dsDaten.Tables(0).Rows.Count = 0 Then
|
|
MsgBox("Keine Daten mit der Nr. " + Searchstring + " gefunden.", vbExclamation)
|
|
Return -1
|
|
End If
|
|
Else
|
|
Get_Tabledata("firma", " where name1 like '" + Searchstring + "%'" + " order by name1, name2, ort")
|
|
If dsDaten.Tables(0).Rows.Count = 0 Then
|
|
MsgBox("Keine Daten mit dem Suchbegriff " + Searchstring + " gefunden.", vbExclamation)
|
|
Return -1
|
|
End If
|
|
End If
|
|
If dsDaten.Tables(0).Rows.Count = 1 Then
|
|
Return (dsDaten.Tables(0).Rows(0).Item("nrfirma"))
|
|
Else
|
|
Dim f As New frmPrivatSelect
|
|
f.Text = "Firmensuche"
|
|
f.TreeView1.Nodes.Clear()
|
|
|
|
For Each r As DataRow In dsDaten.Tables(0).Rows
|
|
Dim tn As New TreeNode
|
|
tn.Text = r("nrfirma").ToString + " " + r("Name1") + " " + r("name2") + ", " + r("PLZ") + " " + r("ort")
|
|
tn.Tag = r("nrfirma")
|
|
f.TreeView1.Nodes.Add(tn)
|
|
Next
|
|
f.TreeView1.SelectedNode = f.TreeView1.Nodes(0)
|
|
f.StartPosition = FormStartPosition.CenterParent
|
|
f.ShowDialog()
|
|
If f.DialogResult = DialogResult.OK Then
|
|
Return f.TreeView1.SelectedNode.Tag
|
|
Else
|
|
Return -1
|
|
End If
|
|
End If
|
|
Return -1
|
|
|
|
|
|
End Select
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "Log"
|
|
Public Function WriteLog(ByVal Entry As String, ByVal logtype As Integer)
|
|
Try
|
|
Dim conn As New MySqlConnection(Me.Connectionstring)
|
|
Dim sql As String
|
|
sql = "Insert Log (Eintrag,logtype ) values('" + Entry + "'," + logtype.ToString + ")"
|
|
Dim cm As New MySqlCommand(sql, conn)
|
|
conn.Open()
|
|
cm.ExecuteNonQuery()
|
|
conn.Close()
|
|
conn.Dispose()
|
|
cm.Dispose()
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
End Try
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "Utils"
|
|
Public Function Get_DBKey(ByVal Tablename As String) As Integer
|
|
Select Case Tablename
|
|
Case "Privat"
|
|
Me.Get_Tabledata("NewKeyPrivat", "", Me.Get_SQL(15))
|
|
Case "Firma"
|
|
Me.Get_Tabledata("NewKeyFirma", "", Me.Get_SQL(28))
|
|
Case "Leistung"
|
|
Me.Get_Tabledata("NewKeyLeistung", "", Me.Get_SQL(17))
|
|
Case "Behandlung"
|
|
Me.Get_Tabledata("NewKeyBehandlung", "", Me.Get_SQL(18))
|
|
Case "Zahlung"
|
|
Me.Get_Tabledata("NewKeyZahlung", "", Me.Get_SQL(20))
|
|
Case "Recall"
|
|
Me.Get_Tabledata("NewKeyRecall", "", Me.Get_SQL(31))
|
|
Case "Tarif"
|
|
Me.Get_Tabledata("Tarif", "", "Select top 1 nrtarif+1 from tarif order by nrtarif desc")
|
|
|
|
End Select
|
|
Return Me.dsDaten.Tables(0).Rows(0).Item(0)
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "Tarife / Leistungen"
|
|
Public Function Get_Tarife() As DataTable
|
|
Dim found As Boolean = False
|
|
For Each t As DataTable In IntTables.Inttables.Tables
|
|
If t.TableName = "Tarife" Then
|
|
found = True
|
|
End If
|
|
Next
|
|
If Not found Then
|
|
Me.Get_Tabledata("Tarife", "order by nummervon")
|
|
IntTables.Inttables.Tables.Add(dsDaten.Tables(0).Copy)
|
|
End If
|
|
|
|
found = False
|
|
For Each t As DataTable In IntTables.Inttables.Tables
|
|
If t.TableName = "Tarifgrp" Then
|
|
found = True
|
|
|
|
End If
|
|
Next
|
|
|
|
If Not found Then
|
|
Me.Get_Tabledata("Tarifgrp", "order by tarifvon")
|
|
IntTables.Inttables.Tables.Add(dsDaten.Tables(0).Copy)
|
|
End If
|
|
|
|
found = False
|
|
For Each t As DataTable In IntTables.Inttables.Tables
|
|
If t.TableName = "Tarpaket" Then
|
|
found = True
|
|
End If
|
|
Next
|
|
If Not found Then
|
|
Me.Get_Tabledata("Tarpaket", "order by paketbezeichnung")
|
|
IntTables.Inttables.Tables.Add(dsDaten.Tables(0).Copy)
|
|
End If
|
|
If Not found Then
|
|
|
|
End If
|
|
|
|
found = False
|
|
For Each t As DataTable In IntTables.Inttables.Tables
|
|
If t.TableName = "paketpos" Then
|
|
found = True
|
|
End If
|
|
Next
|
|
If Not found Then
|
|
Me.Get_Tabledata("paketpos", "order by nrpaket")
|
|
IntTables.Inttables.Tables.Add(dsDaten.Tables(0).Copy)
|
|
End If
|
|
|
|
found = False
|
|
For Each t As DataTable In IntTables.Inttables.Tables
|
|
If t.TableName = "Dentotar" Then
|
|
found = True
|
|
End If
|
|
Next
|
|
If Not found Then
|
|
Me.Get_Tabledata("Dentotar", "", Get_SQL(23))
|
|
IntTables.Inttables.Tables.Add(dsDaten.Tables(0).Copy)
|
|
End If
|
|
|
|
End Function
|
|
|
|
Public Function Get_Tarif() As DataTable
|
|
Dim found As Boolean = False
|
|
For Each t As DataTable In IntTables.Inttables.Tables
|
|
If t.TableName = "Tarif" Then
|
|
found = True
|
|
Exit Function
|
|
End If
|
|
Next
|
|
If Not found Then
|
|
Me.Get_Tabledata("Tarif", "", Get_SQL(16))
|
|
IntTables.Inttables.Tables.Add(dsDaten.Tables(0).Copy)
|
|
End If
|
|
End Function
|
|
|
|
|
|
Public Sub Recalc_Leistungen(ByVal nrbehandlung As Integer, taxpunktwert As Double)
|
|
Dim scmCmdToExecute As MySqlCommand = New MySqlCommand()
|
|
|
|
scmCmdToExecute.CommandText = "dbo.[sp_recalc_leistungen]"
|
|
Dim conn As New MySqlConnection(My.Settings.ConnectionString)
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
scmCmdToExecute.Connection = conn
|
|
Try
|
|
scmCmdToExecute.Parameters.Add(New MySqlParameter("@nrbehandlung", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, nrbehandlung))
|
|
scmCmdToExecute.Parameters.Add(New MySqlParameter("@taxpunktwert", SqlDbType.Float, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, taxpunktwert))
|
|
scmCmdToExecute.Connection.Open()
|
|
scmCmdToExecute.ExecuteNonQuery()
|
|
Return
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
scmCmdToExecute.Connection.Close()
|
|
End Try
|
|
End Sub
|
|
|
|
|
|
|
|
#End Region
|
|
|
|
#Region "Leistung"
|
|
Public Function delete_leistung(ByVal nrleistung As Integer)
|
|
Get_Tabledata("Leistung", "where nrleistung=" + nrleistung.ToString, "")
|
|
dsDaten.Tables(0).Rows(0).Item("Aktiv") = 0
|
|
dsDaten.Tables(0).Rows(0).Item("mutiert_am") = Now
|
|
dsDaten.Tables(0).Rows(0).Item("mutierer") = Globals.ActUser
|
|
Update_Data()
|
|
End Function
|
|
|
|
Public Function Get_Leistung(ByVal nrleistung As Integer)
|
|
Get_Tabledata("Leistung", "where nrleistung=" + nrleistung.ToString, "")
|
|
|
|
End Function
|
|
#End Region
|
|
|
|
#Region "Auswertungen"
|
|
Public Function get_reportdata(ByVal Reportnr As Integer, ByVal Parameter As String) As String
|
|
Get_Tabledata("Auswertung", "where Auswertungnr=" + Reportnr.ToString, "", "")
|
|
Dim sql As String
|
|
Dim typ As String
|
|
sql = dsDaten.Tables(0).Rows(0).Item("sql")
|
|
typ = dsDaten.Tables(0).Rows(0).Item("sqltype")
|
|
If Parameter <> "" Then sql = sql + " " + Parameter
|
|
|
|
Dim Filename As String = My.Settings.TempPath + "\" + dsDaten.Tables(0).Rows(0).Item("BEZEICHNUNG") + ".FRX"
|
|
dsDaten.Clear()
|
|
Select Case UCase(typ)
|
|
Case "SQL"
|
|
Get_Tabledata("Auswertungsdaten", "", sql, "")
|
|
Return Filename
|
|
End Select
|
|
End Function
|
|
|
|
Public Function Get_ReportNr(ByVal Report As String) As Integer
|
|
Try
|
|
Get_Tabledata("Auswertung", "where es_typ='" + Report + "'")
|
|
Return dsDaten.Tables(0).Rows(0).Item(0)
|
|
Catch ex As Exception
|
|
Return 0
|
|
End Try
|
|
|
|
End Function
|
|
|
|
Public Function Get_ReportNr_by_ESTypnr(ByVal ESTypNr As String) As Integer
|
|
Try
|
|
Get_Tabledata("ESTyp", "where nrestyp=" + ESTypNr)
|
|
|
|
Get_Tabledata("Auswertung", "where es_typ='" + dsDaten.Tables(0).Rows(0).Item("estyp") + "'")
|
|
Return dsDaten.Tables(0).Rows(0).Item(0)
|
|
Catch ex As Exception
|
|
Return 0
|
|
End Try
|
|
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
#Region "Fakturierung"
|
|
Public Sub Rechnung_buchen(ByVal Type As Integer, ByVal Rechnungsnummer As String, rate As String, behandlungsnummer As String, ByVal Betrag As Decimal)
|
|
Dim scmCmdToExecute As MySqlCommand = New MySqlCommand()
|
|
scmCmdToExecute.CommandText = "dbo.sp_Rechnung_Buchen"
|
|
Dim conn As New MySqlConnection(My.Settings.ConnectionString)
|
|
scmCmdToExecute.CommandType = CommandType.StoredProcedure
|
|
scmCmdToExecute.Connection = conn
|
|
Try
|
|
scmCmdToExecute.Parameters.Add(New MySqlParameter("@Type", SqlDbType.Int, 4, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, Type))
|
|
scmCmdToExecute.Parameters.Add(New MySqlParameter("@Fakturanr", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, Rechnungsnummer))
|
|
scmCmdToExecute.Parameters.Add(New MySqlParameter("@Hauptfaktura", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, Rechnungsnummer))
|
|
scmCmdToExecute.Parameters.Add(New MySqlParameter("@Rate", SqlDbType.Int, 4, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, rate))
|
|
scmCmdToExecute.Parameters.Add(New MySqlParameter("@behandlungsnummer", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, behandlungsnummer))
|
|
scmCmdToExecute.Parameters.Add(New MySqlParameter("@Betrag", SqlDbType.Float, 255, ParameterDirection.Input, True, 0, 0, "", DataRowVersion.Proposed, Betrag))
|
|
scmCmdToExecute.Connection.Open()
|
|
'scmCmdToExecute.Connection.Open()
|
|
scmCmdToExecute.ExecuteNonQuery()
|
|
Return
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
Finally
|
|
scmCmdToExecute.Connection.Close()
|
|
End Try
|
|
|
|
End Sub
|
|
|
|
Public Sub Mahnung_Buchen(ByVal nrfaktura As Integer, ByVal Stufe As Integer, ByVal daten As DataTable)
|
|
Dim db As New clsDB
|
|
Dim mahndatum As Date
|
|
Dim faelligkeit As Date
|
|
Dim mahngebuehr As Double
|
|
|
|
mahndatum = daten.Rows(0).Item("Mahndatum")
|
|
faelligkeit = daten.Rows(0).Item("Mahnfaelligkeit")
|
|
mahngebuehr = daten.Rows(0).Item("mahnzuschlag")
|
|
Select Case Stufe
|
|
Case 1
|
|
db.Exec_SQL("Update faktura set mutiert_am=getdate(), mutierer=" + Globals.ActUser.ToString + ",mahndatum1='" + mahndatum + "', mahnfaelligkeit1='" + faelligkeit + "', mahngebuehr1='" + mahngebuehr.ToString + "' where nrfaktura=" + FakturaNr.ToString)
|
|
Case 2
|
|
db.Exec_SQL("Update faktura set mutiert_am=getdate(), mutierer=" + Globals.ActUser.ToString + ",mahndatum2='" + mahndatum + "', mahnfaelligkeit2='" + faelligkeit + "', mahngebuehr2='" + mahngebuehr.ToString + "' where nrfaktura=" + FakturaNr.ToString)
|
|
Case 3
|
|
db.Exec_SQL("Update faktura set mutiert_am=getdate(), mutierer=" + Globals.ActUser.ToString + ",mahndatum3='" + mahndatum + "', mahnfaelligkeit3='" + faelligkeit + "',mahngebuehr3='" + mahngebuehr.ToString + "' where nrfaktura=" + FakturaNr.ToString)
|
|
End Select
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "Documenthandling"
|
|
|
|
Public Function Save_CAMT_File_RUN(ByVal Key As Integer, Filename As String)
|
|
Return Save_File("Select * from camt_run where nreintrag=" + Key.ToString, Filename, "SourceFIle")
|
|
End Function
|
|
|
|
Public Function Save_CAMT_File(ByVal Key As Integer, Filename As String)
|
|
Return Save_File("Select * from camt_file where nreintrag=" + Key.ToString, Filename, "camt_file")
|
|
End Function
|
|
Public Function Save_RptDatei(ByVal Auswertungnr As Integer, ByVal Auswertungname As String) As String
|
|
Return Save_File("Select * from auswertung where auswertungnr=" + Auswertungnr.ToString, Auswertungname, "Reportdatei")
|
|
End Function
|
|
|
|
Public Function Get_RptDatei(ByVal Auswertungnr As Integer, ByVal Auswertungname As String) As String
|
|
Return Get_file("Select * from auswertung where auswertungnr=" + Auswertungnr.ToString, Auswertungname, "Reportdatei")
|
|
End Function
|
|
|
|
Public Function Save_File(ByVal sql As String, ByVal filename As String, ByVal DBAttribut As String) As String
|
|
Dim Connection As New MySqlConnection()
|
|
Dim DA As New MySqlDataAdapter(sql, Connection)
|
|
Dim cb As MySqlCommandBuilder = New MySqlCommandBuilder(DA)
|
|
Dim ds As New DataSet()
|
|
Dim fs As New System.IO.FileStream(filename, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.Read)
|
|
Dim mydata(fs.Length) As Byte
|
|
fs.Read(mydata, 0, fs.Length)
|
|
fs.Close()
|
|
Try
|
|
Connection.ConnectionString = My.Settings.ConnectionString
|
|
Connection.Open()
|
|
DA.Fill(ds, "RptFile")
|
|
Dim myRow As DataRow
|
|
If ds.Tables(0).Rows.Count = 0 Then
|
|
MsgBox("Datei kann nicht gespeichert werden.", MsgBoxStyle.Critical)
|
|
Exit Function
|
|
Else
|
|
myRow = ds.Tables(0).Rows(0)
|
|
myRow.Item(DBAttribut) = mydata
|
|
DA.Update(ds, "RptFile")
|
|
End If
|
|
Return filename
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
filename = ""
|
|
Return filename
|
|
Finally
|
|
fs = Nothing
|
|
cb = Nothing
|
|
ds = Nothing
|
|
DA = Nothing
|
|
Connection.Close()
|
|
Connection = Nothing
|
|
End Try
|
|
End Function
|
|
|
|
Public Function Get_file(ByVal sql As String, filename As String, DBAttribut As String) As String
|
|
Dim connection As New MySqlConnection()
|
|
Dim DA As New MySqlDataAdapter(sql, connection)
|
|
Dim CB As MySqlCommandBuilder = New MySqlCommandBuilder(DA)
|
|
Dim ds As New DataSet()
|
|
Try
|
|
connection.ConnectionString = My.Settings.ConnectionString
|
|
connection.Open()
|
|
DA.Fill(ds, "RptFile")
|
|
Dim myRow As DataRow
|
|
myRow = ds.Tables(0).Rows(0)
|
|
Dim MyData() As Byte
|
|
MyData = myRow.Item(DBAttribut)
|
|
Dim K As Long
|
|
K = UBound(MyData)
|
|
Dim fs As New FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write)
|
|
fs.Write(MyData, 0, K)
|
|
fs.Close()
|
|
fs = Nothing
|
|
Return filename
|
|
Catch ex As Exception
|
|
Return ""
|
|
Finally
|
|
CB = Nothing
|
|
ds = Nothing
|
|
DA = Nothing
|
|
connection.Close()
|
|
connection = Nothing
|
|
End Try
|
|
End Function
|
|
|
|
#End Region
|
|
|
|
#Region "Zahlungen"
|
|
|
|
Public Sub Insert_ZJournal(fakturanr As String, ByVal debitor As String, ByVal debitortext As String, ByVal betrag As Decimal, ByVal konto As String, ByVal vz As String, ByVal storno As String)
|
|
Get_Tabledata("Zahlung", "", "Select top 1 * from zjournal order by pk desc")
|
|
Dim dr As DataRow = dsDaten.Tables(0).NewRow
|
|
dr.Item("nreintrag") = 0
|
|
dr.Item("Mandant") = Globals.Mandant
|
|
dr.Item("Datum") = Now
|
|
dr.Item("nrfaktura") = fakturanr
|
|
dr.Item("nrdebitor") = debitor
|
|
dr.Item("debitor") = debitortext
|
|
dr.Item("Konto") = konto
|
|
dr.Item("betrag") = betrag
|
|
If vz = "False" Then vz = ""
|
|
If vz = "True" Then vz = "J"
|
|
dr.Item("vz") = vz
|
|
dr.Item("storno") = storno
|
|
dr.Item("erstellt_am") = Now
|
|
dr.Item("mutiert_am") = Now
|
|
dr.Item("mutierer") = Globals.ActUser
|
|
dr.Item("aktiv") = True
|
|
dsDaten.Tables(0).Rows.Add(dr)
|
|
Update_Data()
|
|
End Sub
|
|
|
|
#End Region
|
|
|
|
#Region "Security"
|
|
Public Function Objexists(ByVal securityform As String, ByVal securityobjecttype As String, ByVal securityobject As String, ByVal securityobjectitem As String) As Boolean
|
|
Get_Tabledata("SecurityObject", "SecurityForm='" + securityform + "' and securityobjecttype='" + securityobjecttype + "' and securityobject='" + securityobject + "' and securityobjectitem='" + securityobjectitem + "? and aktiv=1")
|
|
If dsDaten.Tables(0).Rows.Count > 0 Then Return True Else Return False
|
|
End Function
|
|
|
|
#End Region
|
|
End Class
|