diff --git a/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb b/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb index dbe223860df5207772a49079e72a80c41dce0af9..d8c576107f663c5f46a82d6152256a360fc01536 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/SSMTOOL.vb @@ -3,14 +3,13 @@ Imports VectoAuxiliaries.Hvac Imports Newtonsoft.Json Imports System.IO Imports System.Reflection +Imports System.Text Namespace Hvac Public Class SSMTOOL Implements ISSMTOOL - - Private filePath As String Public genInputs As ISSMGenInputs Public techList As ISSMTechList @@ -52,14 +51,14 @@ Implements ISSMTOOL 'Constructors Sub New() - + End Sub Sub New(filePath As String) Me.filePath = filePath genInputs = New SSMGenInputs() - techList = New SSMTechList(filePath,genInputs) + techList = New SSMTechList(filePath, genInputs) End Sub @@ -120,15 +119,15 @@ End Function tmpAux = JsonConvert.DeserializeObject(Of SSMTOOL)(output, settings) - tmpAux.techList.SetSSMGeneralInputs( tmpAux.genInputs) + tmpAux.techList.SetSSMGeneralInputs(tmpAux.genInputs) For Each tll As TechListBenefitLine In tmpAux.techList.TechLines - tll.inputSheet= tmpAux.genInputs + tll.inputSheet = tmpAux.genInputs Next - + 'This is where we Assume values of loaded( Deserialized ) object. Clone(tmpAux) @@ -144,7 +143,6 @@ End Function End Function - 'Comparison Public Function IsEqualTo(source As ISSMTOOL) As Boolean Implements ISSMTOOL.IsEqualTo @@ -155,7 +153,6 @@ End Function End Function - Private Function compareGenUserInputs(source As ISSMTOOL) As Boolean Dim src As SSMTOOL = DirectCast(source, SSMTOOL) @@ -164,56 +161,54 @@ End Function Dim properties As PropertyInfo() = Me.genInputs.GetType.GetProperties - For Each prop As propertyinfo In properties - - If Not prop.GetAccessors.IsReadOnly - - if prop.GetValue(Me.genInputs,nothing)<> prop.GetValue(src.genInputs,nothing) then - returnValue=False + For Each prop As PropertyInfo In properties + + If Not prop.GetAccessors.IsReadOnly Then + + If prop.GetValue(Me.genInputs, Nothing) <> prop.GetValue(src.genInputs, Nothing) Then + returnValue = False End If - + End If - + Next Return returnValue End Function - Private Function compareTechListBenefitLines(source As ISSMTOOL) As Boolean - Dim src As SSMTOOL = DirectCast( source, SSMTOOL) + Dim src As SSMTOOL = DirectCast(source, SSMTOOL) 'Equal numbers of lines check - If Me.techList.TechLines.Count<> src.techList.TechLines.Count then return false + If Me.techList.TechLines.Count <> src.techList.TechLines.Count Then Return False - For Each tl As ITechListBenefitLine In Me.techList.TechLines.OrderBy( Function(o) o.Category).ThenBy( Function(n) n.BenefitName) + For Each tl As ITechListBenefitLine In Me.techList.TechLines.OrderBy(Function(o) o.Category).ThenBy(Function(n) n.BenefitName) 'First Check line exists in other - If src.techList.TechLines.Where( Function(w) w.BenefitName= tl.BenefitName AndAlso w.Category=tl.Category).Count<>1 then + If src.techList.TechLines.Where(Function(w) w.BenefitName = tl.BenefitName AndAlso w.Category = tl.Category).Count <> 1 Then Return False Else - + 'check are equal - If Not src.techList.TechLines.first( Function(w) w.BenefitName= tl.BenefitName AndAlso w.Category=tl.Category).IsEqualTo( tl ) then + If Not src.techList.TechLines.First(Function(w) w.BenefitName = tl.BenefitName AndAlso w.Category = tl.Category).IsEqualTo(tl) Then Return False End If End If - + Next 'All Looks OK - Return true + Return True End Function - End Class diff --git a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.Designer.vb b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.Designer.vb index 2e4f7eb8be0c8c7399beed55037f66c7a254a074..ad4679276affd67310874bdf042c783d5a75e5ef 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.Designer.vb +++ b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.Designer.vb @@ -200,6 +200,7 @@ Partial Class frmHVACTool Me.lblIndex = New System.Windows.Forms.Label() Me.btnSave = New System.Windows.Forms.Button() Me.btnCancel = New System.Windows.Forms.Button() + Me.btnClearForm = New System.Windows.Forms.Button() Me.tabMain.SuspendLayout Me.tabGeneralInputsBP.SuspendLayout Me.GroupBox1.SuspendLayout @@ -1759,6 +1760,7 @@ Partial Class frmHVACTool 'tabTechBenefits ' Me.tabTechBenefits.CausesValidation = false + Me.tabTechBenefits.Controls.Add(Me.btnClearForm) Me.tabTechBenefits.Controls.Add(Me.lblIndex) Me.tabTechBenefits.Controls.Add(Me.txtIndex) Me.tabTechBenefits.Controls.Add(Me.btnUpdate) @@ -1893,6 +1895,7 @@ Partial Class frmHVACTool 'cboLineType ' Me.cboLineType.AutoCompleteCustomSource.AddRange(New String() {"Normal", "Active Ventelation"}) + Me.cboLineType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.cboLineType.FormattingEnabled = true Me.cboLineType.Items.AddRange(New Object() {"Normal", "ActiveVentilation"}) Me.cboLineType.Location = New System.Drawing.Point(488, 71) @@ -2070,6 +2073,7 @@ Partial Class frmHVACTool 'cboUnits ' Me.cboUnits.AutoCompleteCustomSource.AddRange(New String() {"Fraction"}) + Me.cboUnits.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.cboUnits.FormattingEnabled = true Me.cboUnits.Items.AddRange(New Object() {"Fraction"}) Me.cboUnits.Location = New System.Drawing.Point(81, 44) @@ -2116,6 +2120,15 @@ Partial Class frmHVACTool Me.btnCancel.Text = "Cancel" Me.btnCancel.UseVisualStyleBackColor = true ' + 'btnClearForm + ' + Me.btnClearForm.Location = New System.Drawing.Point(814, 100) + Me.btnClearForm.Name = "btnClearForm" + Me.btnClearForm.Size = New System.Drawing.Size(75, 23) + Me.btnClearForm.TabIndex = 34 + Me.btnClearForm.Text = "Clear Form" + Me.btnClearForm.UseVisualStyleBackColor = true + ' 'frmHVACTool ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!) @@ -2334,4 +2347,5 @@ End Sub Friend WithEvents txtIndex As System.Windows.Forms.TextBox Friend WithEvents btnCancel As System.Windows.Forms.Button Friend WithEvents btnSave As System.Windows.Forms.Button + Friend WithEvents btnClearForm As System.Windows.Forms.Button End Class diff --git a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb index 6e082f3aa06f0ab0462be58bf70121c807009b64..57b9afc6eec6b3ed3b9aa1bcbd9097a7012cec26 100644 --- a/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb +++ b/VECTOAux/VectoAuxiliaries/UI/frmHVACTool.vb @@ -15,6 +15,25 @@ Public Class frmHVACTool Private gvTechListBinding As BindingList(Of ITechListBenefitLine) Private DefaultCategories As String() = {"Cooling","Heating","Insulation","Ventiliation"} + Public UD As String = "Hello" + + public Sub UpdateButtonText() + + + If txtIndex.Text=String.Empty then + + btnUpdate.Text = "Add" + + Else + + btnUpdate.Text = "Update" + + end if + + + end sub + + Private sub BindGrid( ) @@ -50,10 +69,6 @@ Public Class frmHVACTool End Function - - - - Public Sub New(busDatabasePath As String, ahsmFilePath As String) ' This call is required by the designer. @@ -191,12 +206,13 @@ End Sub End Sub Private Sub setupBindings() + UpdateButtonText() + 'TechBenefitLines BindGrid() - 'Bus Parameterisation - txtBusModel.DataBindings.Add("Text", ssmTOOL.genInputs, "BP_BusModel", False, DataSourceUpdateMode.OnPropertyChanged) + 'txtBusModel.DataBindings.Add("Text", ssmTOOL.genInputs, "BP_BusModel", False, DataSourceUpdateMode.OnPropertyChanged) txtRegisteredPassengers.DataBindings.Add("Text", ssmTOOL.genInputs, "BP_NumberOfPassengers", False, DataSourceUpdateMode.OnPropertyChanged) txtBusFloorType.DataBindings.Add("Text", ssmTOOL.genInputs, "BP_BusFloorType", False, DataSourceUpdateMode.OnPropertyChanged) txtBusFloorSurfaceArea.DataBindings.Add("Text", ssmTOOL.genInputs, "BP_BusFloorSurfaceArea", False, DataSourceUpdateMode.OnPropertyChanged) @@ -667,6 +683,9 @@ End Function AddHandler tabMain.DrawItem, New System.Windows.Forms.DrawItemEventHandler(AddressOf tabMain_DrawItem) gvTechBenefitLines.ClearSelection() + + + End Sub @@ -708,6 +727,9 @@ End Function Private Sub gvTechBenefitLines_DoubleClick( sender As Object, e As EventArgs) Handles gvTechBenefitLines.DoubleClick + If gvTechBenefitLines.SelectedCells.Count<1 then Return + + Dim row As Integer = gvTechBenefitLines.SelectedCells(0).OwningRow.Index Dim benefitName , category As String @@ -718,6 +740,8 @@ Private Sub gvTechBenefitLines_DoubleClick( sender As Object, e As EventArgs) H FillTechLineEditPanel( row ) + UpdateButtonText() + End Sub @@ -728,7 +752,7 @@ private function GetTechLineFromPanel() as ITechListBenefitLine Dim tl As ITechListBenefitLine = New TechListBenefitLine( ssmTOOL.genInputs) - tl.Category = cboCategory.Text + tl.Category = StrConv(cboCategory.Text, vbProperCase) tl.BenefitName = txtBenefitName.Text tl.Units = cboUnits.Text tl.LineType = If( cboLineType.Text= "Normal",0,3) @@ -754,10 +778,10 @@ End Function Private Sub ClearEditPanel() txtIndex.Text = String.Empty - cboCategory.Text = String.Empty + cboCategory.SelectedIndex=0 txtBenefitName.Text = String.Empty - cboUnits.Text = String.Empty - cboLineType.Text = String.Empty + cboUnits.SelectedIndex=0 + cboLineType.SelectedIndex=0 txtLowFloorH .Text = String.Empty txtLowFloorV .Text = String.Empty txtLowFloorC .Text = String.Empty @@ -790,6 +814,8 @@ Private Sub btnUpdate_Click( sender As Object, e As EventArgs) Handles btnUpdat cboCategory.DataSource= GetCategories() + UpdateButtonText() + End if Else @@ -799,6 +825,7 @@ Private Sub btnUpdate_Click( sender As Object, e As EventArgs) Handles btnUpdat Else gvTechBenefitLines.Refresh() ClearEditPanel() + UpdateButtonText() End If @@ -821,6 +848,8 @@ End Sub Private Sub gvTechBenefitLines_CellClick( sender As Object, e As DataGridViewCellEventArgs) Handles gvTechBenefitLines.CellClick + If e.ColumnIndex<0 OrElse e.RowIndex<0 then Return + If gvTechBenefitLines.Columns( e.ColumnIndex).Name="Delete" then @@ -849,4 +878,14 @@ End Sub +Private Sub btnClearForm_Click( sender As Object, e As EventArgs) Handles btnClearForm.Click + + ClearEditPanel() + UpdateButtonText() + + +End Sub + + + End Class