Imports C1.Win.C1TrueDBGrid Imports System Imports System.Data Imports System.Data.SqlTypes Imports System.Data.SqlClient Namespace TKB.VV.Lifecycle Public Class clsProduktCopy Inherits TKB.VV.DB.clsLC_Produkt_Copy Dim mMutierer As String Property MutiererText() As String Get Return mMutierer End Get Set(ByVal value As String) mMutierer = value End Set End Property Public Function Get_Produkt(ByVal Nr As Integer) Me.cpMainConnectionProvider = Globals.conn Me.iLc_produkt_copynr = New SqlInt32(CType(Nr, Int32)) Globals.conn.OpenConnection() Me.SelectOne() Me.MutiererText = Get_Mutierer(Me.iMutierer.Value) Globals.conn.CloseConnection(True) End Function Public Function Save_Data() As Integer Me.cpMainConnectionProvider = Globals.conn Me.daMutiert_am = New SqlDateTime(CType(Now, DateTime)) Me.iMutierer = New SqlInt32(CType(Globals.clsmitarbeiter.iMitarbeiternr.Value, Int32)) Globals.conn.OpenConnection() Me.Update() Globals.conn.CloseConnection(True) Return Me.iLC_ProduktNr.Value End Function ''' ''' Mutierer auslesen ''' ''' ''' Public Function Get_Mutierer(ByVal nr As Integer) As String Dim ma As New TKB.VV.DB.clsMitarbeiter Dim dt As New DataTable Dim Retvalue As String ma.cpMainConnectionProvider = Globals.conn ma.iMitarbeiternr = New SqlInt32(CType(nr, Int32)) dt = ma.SelectOne() If dt.Rows.Count = 0 Then Retvalue = ("{" + nr.ToString + "}") Else Retvalue = ma.sName.ToString + " " + ma.sVorname.ToString + ", " + ma.sTgnummer.ToString End If ma.Dispose() dt.Dispose() Return Retvalue End Function ''' ''' Löschen eines Datensatzes erstellen. ''' ''' ''' ''' Public Function Delete_Produkt(Optional ByVal Basenr As Integer = 0) As Integer If Basenr <> 0 Then Get_Produkt(Basenr) End If Me.cpMainConnectionProvider = Globals.conn Me.bAktiv = New SqlBoolean(CType(False, Boolean)) Me.daMutiert_am = New SqlDateTime(CType(Now, DateTime)) Me.iMutierer = New SqlInt32(CType(Globals.clsmitarbeiter.iMitarbeiternr.Value, Int32)) Globals.conn.OpenConnection() Me.Update() Globals.conn.CloseConnection(True) End Function ''' ''' Löschen eines Datensatzes . ''' ''' ''' ''' Public Overloads Function Delete(Optional ByVal Basenr As Integer = 0) As Integer If Basenr <> 0 Then Get_Produkt(Basenr) End If Me.cpMainConnectionProvider = Globals.conn Globals.conn.OpenConnection() MyBase.Delete() Globals.conn.CloseConnection(True) End Function ''' ''' Neue Kuendigungsfrist einfügen ''' ''' ''' Public Function Add_New(Optional ByVal Produktnr As Integer = 0, Optional ByVal Parentid As Integer = 0) As Integer Dim db As New TKB.VV.DB.clsMyKey_Tabelle db.cpMainConnectionProvider = Globals.conn Dim newkey = db.get_dbkey("LC_Produkt_Copy") db.Dispose() Me.iLc_produkt_copynr = New SqlInt32(CType(newkey, Int32)) Me.iLc_produktnr = New SqlInt32(CType(Produktnr, Int32)) Me.iLc_produkt_parentnr = New SqlInt32(CType(Parentid, Int32)) Me.bAktiv = New SqlBoolean(CType(True, Boolean)) Me.daErstellt_am = New SqlDateTime(CType(Now, DateTime)) Me.daMutiert_am = New SqlDateTime(CType(Now, DateTime)) Me.iMutierer = New SqlInt32(CType(Globals.clsmitarbeiter.iMitarbeiternr.Value, Int32)) Me.cpMainConnectionProvider = Globals.conn Globals.conn.OpenConnection() Me.Insert() Globals.conn.CloseConnection(True) Return newkey End Function Public Function Get_Copies(ByVal Key As Integer) As DataTable Dim Prodlist As New DataTable Dim selectcommand As New SqlCommand Dim connection As New SqlConnection() Dim s As String = "" Dim da As New SqlDataAdapter("", connection) selectcommand.CommandText = "[sp_lc_get_kopien]" selectcommand.CommandType = CommandType.StoredProcedure selectcommand.Connection = connection selectcommand.Parameters.Add("@original", SqlDbType.Int, 4) selectcommand.Parameters.Add("@fnkt", SqlDbType.Int, 4) selectcommand.Parameters.Add("@result", SqlDbType.Int, 4) selectcommand.Parameters(0).Value = Key selectcommand.Parameters(1).Value = 0 selectcommand.Parameters(2).Value = 0 Try connection.ConnectionString = Globals.sConnectionString connection.Open() da.SelectCommand = selectcommand da.Fill(Prodlist) Return Prodlist Catch ex As Exception MsgBox(ex.Message) Finally connection.Close() da.Dispose() selectcommand.Dispose() Prodlist.Dispose() End Try End Function Public Function Count_Copies(ByVal key As Integer) As Integer Dim selectcommand As New SqlCommand Dim connection As New SqlConnection() Dim s As String = "" Dim da As New SqlDataAdapter("", connection) selectcommand.CommandText = "[sp_lc_get_kopien]" selectcommand.CommandType = CommandType.StoredProcedure selectcommand.Connection = connection selectcommand.Parameters.Add("@original", SqlDbType.Int, 4) selectcommand.Parameters.Add("@fnkt", SqlDbType.Int, 4) selectcommand.Parameters.Add("@result", SqlDbType.Int, 4) selectcommand.Parameters(2).Direction = ParameterDirection.Output selectcommand.Parameters(0).Value = Key selectcommand.Parameters(1).Value = 1 selectcommand.Parameters(2).Value = 0 Try connection.ConnectionString = Globals.sConnectionString connection.Open() selectcommand.ExecuteNonQuery() Return selectcommand.Parameters(2).Value Catch ex As Exception MsgBox(ex.Message) Finally connection.Close() da.Dispose() selectcommand.Dispose() End Try End Function End Class End Namespace