Imports System.Data.SqlClient Imports System.Data.SqlDbType Imports System.IO Public Class clsdb 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 Public dsdaten As New DataSet Public dadaten As SqlDataAdapter Dim sql As String Sub New() Dim ConnectionFilename As String = "edokaconn.cfg" Dim path As String = "" Dim fc As Integer = 0 Dim ofile As System.IO.File Dim oread As System.IO.StreamReader Dim sConnectionstring As String oread = ofile.OpenText(ApplicationPath() + "\" + ConnectionFilename) sConnectionstring = oread.ReadLine sConnectionstring = Crypto.DecryptText(sConnectionstring, "HutterundMueller") sConnectionstring = Left(sConnectionstring, Len(sConnectionstring) - 1) sConnectionstring = sConnectionstring oread.Close() Me.Connectionstring = sConnectionstring End Sub Public Function Get_Parameter(valuenr As Integer) As String Return exec_sp_vorlagenuebernahme(10, valuenr) End Function Public Function Save_Parameter(valuenr As Integer, value As String) As String Return exec_sp_vorlagenuebernahme(11, valuenr, value) End Function Public Function get_rundaten(ByRef lb As System.Windows.Forms.ListBox) lb.Items.Clear() dsdaten.Tables.Clear() exec_sp_vorlagenuebernahme(12) For Each r As DataRow In dsdaten.Tables(0).Rows lb.Items.Add(r.Item(0).ToString + ":" + r.Item(1).ToString) Next End Function Public Function Get_Journal(ByVal nr As String) As String Return exec_sp_vorlagenuebernahme(13, nr) End Function Public Function Get_Uebernahmejournal(ByVal nr As String) As String Return exec_sp_vorlagenuebernahme(14, nr) End Function Public Function exec_sp_vorlagenuebernahme(fnkt As Integer, Optional param1 As String = "", Optional param2 As String = "", Optional param3 As String = "", Optional param4 As String = "") As String Dim scmCmdToExecute As SqlCommand = New SqlCommand() Dim conn As New SqlConnection(Connectionstring) scmCmdToExecute.CommandText = "dbo.sp_vorlagenuebernahme" scmCmdToExecute.CommandType = CommandType.StoredProcedure Dim dtToReturn As DataTable = New DataTable() Dim sdaAdapter As SqlDataAdapter = New SqlDataAdapter(scmCmdToExecute) scmCmdToExecute.Connection = conn Try scmCmdToExecute.Parameters.Add(New SqlParameter("@fnkt", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, fnkt)) scmCmdToExecute.Parameters.Add(New SqlParameter("@param1", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, param1)) scmCmdToExecute.Parameters.Add(New SqlParameter("@param2", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, param2)) scmCmdToExecute.Parameters.Add(New SqlParameter("@param3", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, param3)) scmCmdToExecute.Parameters.Add(New SqlParameter("@param4", SqlDbType.VarChar, 255, ParameterDirection.Input, True, 10, 0, "", DataRowVersion.Proposed, param4)) scmCmdToExecute.Parameters.Add(New SqlParameter("@Result", SqlDbType.VarChar, 8000, ParameterDirection.Output, True, 10, 0, "", DataRowVersion.Proposed, "")) conn.Open() Select Case fnkt Case 10, 13, 14 scmCmdToExecute.ExecuteNonQuery() Return scmCmdToExecute.Parameters("@result").Value.ToString Case 11 scmCmdToExecute.ExecuteNonQuery() Case 12 sdaAdapter.Fill(dsdaten, "Jobs") End Select Catch ex As Exception MsgBox("sp_vorlagenuebernahme::" & scmCmdToExecute.CommandText + "::" + ex.Message) Return "" Finally conn.Close() scmCmdToExecute.Dispose() sdaAdapter.Dispose() dtToReturn.Dispose() End Try End Function End Class