Files
Emmanuele Sassi d3e9474417 - migliorie grafiche stile crm
- correzzioni varie
2025-03-21 11:22:58 +01:00

123 lines
3.3 KiB
VB.net

Imports System.Collections.ObjectModel
Imports System.IO
Imports Newtonsoft.Json
Public Class Estimation
Private m_nId As Integer
Public Property nId As Integer
Get
Return m_nId
End Get
Set(value As Integer)
m_nId = value
End Set
End Property
Private m_Profile As String
Public Property Profile As String
Get
Return m_Profile
End Get
Set(value As String)
m_Profile = value
End Set
End Property
Private m_WoodType As String
Public Property WoodType As String
Get
Return m_WoodType
End Get
Set(value As String)
m_WoodType = value
End Set
End Property
Private m_Color As String
Public Property Color As String
Get
Return m_Color
End Get
Set(value As String)
m_Color = value
End Set
End Property
Private m_Glass As String
Public Property Glass As String
Get
Return m_Glass
End Get
Set(value As String)
m_Glass = value
End Set
End Property
Private m_FrameConfiguration As String
Public Property FrameConfiguration As String
Get
Return m_FrameConfiguration
End Get
Set(value As String)
m_FrameConfiguration = value
End Set
End Property
Private m_SashConfiguration As String
Public Property SashConfiguration As String
Get
Return m_SashConfiguration
End Get
Set(value As String)
m_SashConfiguration = value
End Set
End Property
Private m_WindowList As New ObservableCollection(Of WindowRow)
Public ReadOnly Property WindowList As ObservableCollection(Of WindowRow)
Get
Return m_WindowList
End Get
End Property
Sub New(nId As Integer)
m_nId = nId
End Sub
<JsonConstructor>
Sub New(nId As Integer, Profile As String, WoodType As String, Color As String, Glass As String, FrameConfiguration As String, SashConfiguration As String, WindowList As ObservableCollection(Of WindowRow))
m_nId = nId
m_Profile = Profile
m_WoodType = WoodType
m_Color = Color
m_Glass = Glass
m_FrameConfiguration = FrameConfiguration
m_SashConfiguration = SashConfiguration
m_WindowList = WindowList
End Sub
Friend Shared Function WriteEstimation(Estimation As Estimation) As Boolean
Dim FilePath As String = Map.refMainWindowVM.MainWindowM.sEstimationDir & "\" & Estimation.nId & "\Estimation.json"
Dim JsonFromWindow As String = JsonConvert.SerializeObject(Estimation, Formatting.Indented)
If File.Exists(FilePath) Then
Try
File.Delete(FilePath)
Catch ex As Exception
Return False
End Try
End If
File.WriteAllText(FilePath, JsonFromWindow)
Return True
End Function
Friend Shared Function ReadEstimation(nId As Integer, ByRef Estimation As Estimation) As Boolean
Dim FilePath As String = Map.refMainWindowVM.MainWindowM.sEstimationDir & "\" & nId & "\Estimation.json"
If Not File.Exists(FilePath) Then Return False
Dim sReadedFile As String = File.ReadAllText(FilePath)
Estimation = JsonConvert.DeserializeObject(Of Estimation)(sReadedFile)
Return True
End Function
End Class