如何将数据从一个类添加到另一个类

时间:2016-04-07 08:38:28

标签: vb.net vb.net-2010

我遇到了问题而且我不知道如何解决它。

我有两个不同的类,我需要获得一个拳头类的数据到另一个类。

我的第一堂课看起来像:

Public Class ZnrEk1Ospos


Private _sif_tvrtka As Integer
Private _sif_radnika As Integer
Private _red_broj As Integer
Private _sif_ovl_osobe As Integer
Private _datum_teorija As Date
Private _datum_praksa As Date
Private _prezime_ime As String
Private _strucna_sprema As String
Private _funkcija As String
Private _status_obrasca As Integer
Private _glavni_instruktor As Integer
Private _instruktor_prezime As String
Private _instruktor_sprema As String
Private _instruktor_funkcija As String
Private _evidencijski_broj As String
Private _potvrda As String

Public Sub New()
    'Do nothing as all private variables has been initiated
End Sub

Public Sub New(ByVal DataRow As DataRow)
    _sif_tvrtka = CInt(DataRow.Item("sif_tvrtka"))
    _sif_radnika = CInt(DataRow.Item("sif_radnika"))
    _red_broj = CInt(DataRow.Item("red_broj"))
    _sif_ovl_osobe = CInt(DataRow.Item("sif_ovl_osobe"))
    _datum_teorija = IIf(IsDBNull(DataRow.Item("datum_teorija")), Nothing, DataRow.Item("datum_teorija"))
    _datum_praksa = IIf(IsDBNull(DataRow.Item("datum_praksa")), Nothing, DataRow.Item("datum_praksa"))
    _prezime_ime = IIf(IsDBNull(DataRow.Item("prezime_ime")), "", Trim(DataRow.Item("prezime_ime")))
    _strucna_sprema = IIf(IsDBNull(DataRow.Item("strucna_sprema")), "", Trim(DataRow.Item("strucna_sprema")))
    _funkcija = IIf(IsDBNull(DataRow.Item("funkcija")), "", Trim(DataRow.Item("funkcija")))
    _status_obrasca = CInt(DataRow.Item("status_obrasca"))
    _glavni_instruktor = CInt(DataRow.Item("glavni_instruktor"))
    _instruktor_prezime = IIf(IsDBNull(DataRow.Item("instruktor_prezime")), "", Trim(DataRow.Item("instruktor_prezime")))
    _instruktor_sprema = IIf(IsDBNull(DataRow.Item("instruktor_sprema")), "", Trim(DataRow.Item("instruktor_sprema")))
    _instruktor_funkcija = IIf(IsDBNull(DataRow.Item("instruktor_funkcija")), "", Trim(DataRow.Item("instruktor_funkcija")))
    _evidencijski_broj = IIf(IsDBNull(DataRow.Item("evidencijski_broj")), "", Trim(DataRow.Item("evidencijski_broj")))
    _potvrda = IIf(IsDBNull(DataRow.Item("potvrda")), "", Trim(DataRow.Item("potvrda").ToString))
End Sub


Public Property sif_tvrtka() As Integer
    Get
        Return _sif_tvrtka
    End Get
    Set(ByVal value As Integer)
        _sif_tvrtka = value
    End Set
End Property
Public Property sif_radnika() As Integer
    Get
        Return _sif_radnika
    End Get
    Set(ByVal value As Integer)
        _sif_radnika = value
    End Set
End Property
Public Property red_broj() As Integer
    Get
        Return _red_broj
    End Get
    Set(ByVal value As Integer)
        _red_broj = value
    End Set
End Property
Public Property sif_ovl_osobe() As Integer
    Get
        Return _sif_ovl_osobe
    End Get
    Set(ByVal value As Integer)
        _sif_ovl_osobe = value
    End Set
End Property
Public Property datum_teorija() As Date
    Get
        Return _datum_teorija
    End Get
    Set(ByVal value As Date)
        _datum_teorija = value
    End Set
End Property
Public Property datum_praksa() As Date
    Get
        Return _datum_praksa
    End Get
    Set(ByVal value As Date)
        _datum_praksa = value
    End Set
End Property
Public Property prezime_ime() As String
    Get
        Return _prezime_ime
    End Get
    Set(ByVal value As String)
        _prezime_ime = value
    End Set
End Property
Public Property strucna_sprema() As String
    Get
        Return _strucna_sprema
    End Get
    Set(ByVal value As String)
        _strucna_sprema = value
    End Set
End Property
Public Property funkcija() As String
    Get
        Return _funkcija
    End Get
    Set(ByVal value As String)
        _funkcija = value
    End Set
End Property
Public Property status_obrasca() As Integer
    Get
        Return _status_obrasca
    End Get
    Set(ByVal value As Integer)
        _status_obrasca = value
    End Set
End Property
Public Property glavni_instruktor() As Integer
    Get
        Return _glavni_instruktor
    End Get
    Set(ByVal value As Integer)
        _glavni_instruktor = value
    End Set
End Property
Public Property instruktor_prezime() As String
    Get
        Return _instruktor_prezime
    End Get
    Set(ByVal value As String)
        _instruktor_prezime = value
    End Set
End Property
Public Property instruktor_sprema() As String
    Get
        Return _instruktor_sprema
    End Get
    Set(ByVal value As String)
        _instruktor_sprema = value
    End Set
End Property
Public Property instruktor_funkcija() As String
    Get
        Return _instruktor_funkcija
    End Get
    Set(ByVal value As String)
        _instruktor_funkcija = value
    End Set
End Property
Public Property evidencijski_broj() As String
    Get
        Return _evidencijski_broj
    End Get
    Set(ByVal value As String)
        _evidencijski_broj = value
    End Set
End Property

Public Property potvrda() As String
    Get
        Return _potvrda
    End Get
    Set(ByVal value As String)
        _potvrda = value
    End Set
End Property

我想要的第二堂课从我的第一堂课中获取数据:

Public Class TempEK1OsposTeorija

Private _sif_ovl_osobe As Integer
Private _datum_teorija As Date
Private _datum_praksa As Date
Private _prezime_ime As String
Private _strucna_sprema As String

现在我需要获取公共类TempEK1OsposTeorija表单类Public Class ZnrEk1Ospos中的数据。

有人知道怎么做吗?

1 个答案:

答案 0 :(得分:1)

您需要创建该类的新实例

$event.pageY