使用对象VB.NET(WPFAplication)检索数据 [英] Retrieve data using objects VB.NET (WPFAplication)

查看:70
本文介绍了使用对象VB.NET(WPFAplication)检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我用VB.NET语言制作一个WPF应用程序。我的应用程序由几个Window托管不同的控件组成。现在我必须创建多个对象,这些对象允许我访问由控件操纵的数据。需要创建的对象应该很简单,即属性,属性的声明。我不能使用序列化或任何其他方法来保存数据。我唯一需要做的就是创建允许我访问数据然后解决它们的对象。



我的问题是:创建对象时,怎么做我知道我是否应该使用属性而不是方法,因为它不需要进行计算。以下是我为检索数据而创建的对象示例:



Currently, I make a WPF application in VB.NET language.My application is composed of several Window hosting different controls. Now I have to create multiple objects that allow me to have access to data manipulated by controls. The objects that need create should be simple,ie, the declaration of attributes, properties. I must no tuse serialization or any other method to save the data. The only thing that I need to dois to create objects that allow me to have access to data and then address them.

My question is: When creating objects, how do I know if I should just use "Properties" and not "methods" because it does not need to make a calculation for the moment. Here is an example of an object that I created to retrieve data:

Public Class DataResultats

    Private _NombAudit As String
    Private _DateAudit As String
    Private _NuOccupants As String
    Private _Eclairage As String
    Private _NuMachines As String
    Private _HOccupants As String
    Private _AgeBatiment As String
    Private _Surface As String
    Private _Volume As String


#Region "propiété"
 
    Public Property NombreAudit() As String
        Get
            Return _NombAudit
        End Get

        Set(ByVal value As String)
            _NombAudit = value
        End Set
    End Property


    Public Property FechaAudit() As String
        Get
            Return _DateAudit
        End Get

        Set(ByVal value As String)
            _DateAudit = value
        End Set
    End Property


    Public Property NumeroOccupants() As String
        Get
            Return _NuOccupants
        End Get

        Set(ByVal value As String)
            _NuOccupants = value
        End Set
    End Property

    Public Property LumierEclairage() As String
        Get
            Return _Eclairage
        End Get

        Set(ByVal value As String)
            _Eclairage = value
        End Set
    End Property

    Public Property NumeroMachines() As String
        Get
            Return _NuMachines
        End Get

        Set(ByVal value As String)
            _NuMachines = value
        End Set
    End Property

    Public Property HeureOccupant() As String
        Get
            Return _HOccupants
        End Get

        Set(ByVal value As String)
            _HOccupants = value
        End Set
    End Property

    Public Property AncianBatiment() As String
        Get
            Return _AgeBatiment
        End Get

        Set(ByVal value As String)
            _AgeBatiment = value
        End Set
    End Property

    Public Property SuperficieBatiment() As String
        Get
            Return _Surface
        End Get

        Set(ByVal value As String)
            _Surface = value
        End Set
    End Property

    Public Property VolumeBatiment() As String
        Get
            Return _Volume
        End Get

        Set(ByVal value As String)
            _Volume = value
        End Set
    End Property
#End Region



#Region "Méthodes"
 
    Public Sub New()

    End Sub



    Public Sub AllDonneesInstallation(ByVal nombreAudit As Date, ByVal fechaAudit As String, ByVal numeroOccupants As Date, ByVal lumierEclairage As String, ByVal numeroMachines As Date, ByVal heureOccupant As String, ByVal ancianBatiment As Date, ByVal superficieBatiment As String, ByVal volume As String)         Me.NombreAudit = nombreAudit
        Me.FechaAudit = fechaAudit
        Me.NumeroOccupants = numeroOccupants
        Me.LumierEclairage = lumierEclairage
        Me.NumeroMachines = numeroMachines
        Me.HeureOccupant = heureOccupant
        Me.AncianBatiment = ancianBatiment
        Me.SuperficieBatiment = superficieBatiment
        Me.VolumeBatiment = volume
    End Sub
#End Region

End Class





在上一堂课中,你可以看到我制作了一个Methode,但这是我的导师的建议。老实说,我不明白它提供的方法。





这里,我向你展示另一个对象,但是这个对象没有方法:





In the last class, you can see that i made an Methode but That was a suggestion of my tutor. Honestly I do not understand that it serves that method.


Here, i show you another object, but This object has no methods:

Public Class DataAcquisition
    Public Sub New()
        ' Rien à faire.
    End Sub
#Region "Déclaration"
    Public DateData As Date
    Public MesureCapteur As String

#End Region

#Region "Propiétés"
 
    Public Property Dates() As Date
        Get
            Return DateData
        End Get
        Set(ByVal value As Date)
            DateData = value
            'OnPropertyChanged("Modem")
        End Set
    End Property
    Public Property CapteurMesure() As String
        Get
            Return MesureCapteur
        End Get
        Set(ByVal value As String)
            MesureCapteur = value
            '  OnPropertyChanged("Satellite")
        End Set
    End Property
#End Region


End Class



所以,我想知道我是否使用方法或属性?

或许有足够的资产可以恢复数据?



谢谢


So, I wonderwhenI usemethods orproperties?
Perhapsit is enoughpropertiesto recover data?

Thanks

推荐答案

您想要使用属性有几个明显的原因:

1)你只能绑定到属性

2)属性有一个getter和setter。

3)你可以在本地等窗口看到属性在调试时。



方法给你的优点是有多个参数,一个返回值,或没有参数,没有返回值。
There are a couple of obvious reasons you want to use properties:
1) You can only bind to properties
2) Properties have a getter and setter.
3) You can see properties in the locals, etc windows when debugging.

Methods give you the advantage of having multiple arguments, and a return value, or no arguments and no return value.


这篇关于使用对象VB.NET(WPFAplication)检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆