Public Class User_Input Public Shared gratingType, gratingMaterial, gratingMesh, gratingName As String Public Shared gratingSerrated As Boolean = False Public Shared gratingLacquered As Boolean = False Public Shared loadBarSpacing, crossBarSpacing, gratingHeight, loadBarThickness As Integer Public Shared CBDiameter, CBHeight, CBThickness As Double Public Shared wholeMeshesColumn As String Private Shared serratedCheckBox As New CheckBox Private Shared serratedCheckBoxBol As Boolean = False Private Shared lacqueredCheckBox As New CheckBox Private Shared lacqueredCheckBoxBol As Boolean = False Public Shared add3DGrating As Boolean = False Public Shared addFrame As Boolean = False Public Shared addGratingDrawing As Boolean = False Public Shared addFrameDrawing As Boolean = False Public Shared addInstructions As Boolean = False Public Shared addQuote As Boolean = False Public Shared add3DStep As Boolean = False Public Shared preCutFrame As Boolean = False Public Shared frameSize As Integer Public Shared Sub TypeChanged(sender As Object, e As EventArgs) Grating_Configurator.ComboBox_Material.Enabled = True Grating_Configurator.ComboBox_Material.Items.Clear() gratingType = Grating_Configurator.ComboBox_Type.Text Dim materialDT As DataTable = Database.database.Tables("Material") Dim typeInDT As String = materialDT.Rows(0)("TYPE") For i = 0 To materialDT.Rows.Count - 1 If gratingType = typeInDT Then Grating_Configurator.ComboBox_Material.Items.Add(materialDT.Rows(i)("MATERIAL")) End If Try typeInDT = materialDT.Rows(i + 1)("TYPE") Catch ex As Exception End Try Next Grating_Configurator.ComboBox_Material.Text = Grating_Configurator.ComboBox_Material.Items(0) End Sub Public Shared Sub MaterialChanged(sender As Object, e As EventArgs) Grating_Configurator.ComboBox_Mesh.Enabled = True gratingMaterial = Grating_Configurator.ComboBox_Material.Text Dim serratedDT As DataTable = Database.database.Tables("Serrated") Dim removeCheckBox As Boolean = True Dim typeInDT As String = serratedDT.Rows(0)("TYPE") Dim materialInDT As String = serratedDT.Rows(0)("MATERIAL") If serratedCheckBoxBol = False Then For i = 0 To serratedDT.Rows.Count - 1 If gratingMaterial = materialInDT AndAlso gratingType = typeInDT Then serratedCheckBox.Name = "CheckBox_Serrated" serratedCheckBox.Text = "Serrated" serratedCheckBox.Left = Grating_Configurator.ComboBox_Material.Left serratedCheckBox.Top = Grating_Configurator.ComboBox_Material.Top + 25 serratedCheckBox.ForeColor = Color.White AddHandler serratedCheckBox.CheckedChanged, AddressOf CheckBox_Serrated_CheckedChanged Grating_Configurator.Panel_Data.Controls.Add(serratedCheckBox) serratedCheckBoxBol = True Exit For End If Try typeInDT = serratedDT.Rows(i + 1)("TYPE") materialInDT = serratedDT.Rows(i + 1)("MATERIAL") Catch ex As Exception End Try Next Else For i = 0 To serratedDT.Rows.Count - 1 If gratingMaterial = materialInDT AndAlso gratingType = typeInDT Then removeCheckBox = False Exit For End If Try typeInDT = serratedDT.Rows(i + 1)("TYPE") materialInDT = serratedDT.Rows(i + 1)("MATERIAL") Catch ex As Exception End Try Next If serratedCheckBoxBol = True AndAlso removeCheckBox = True Then RemoveHandler serratedCheckBox.CheckedChanged, AddressOf CheckBox_Serrated_CheckedChanged Grating_Configurator.Panel_Data.Controls.RemoveByKey("CheckBox_Serrated") serratedCheckBoxBol = False gratingSerrated = False End If End If If lacqueredCheckBoxBol = False AndAlso (gratingMaterial = "Hot dip galvanized steel" _ OrElse gratingMaterial = "Untreated") Then lacqueredCheckBox.Name = "CheckBox_Lacquered" lacqueredCheckBox.Text = "Lacquered" lacqueredCheckBox.Left = Grating_Configurator.ComboBox_Material.Left lacqueredCheckBox.Top = Grating_Configurator.ComboBox_Material.Top + 50 lacqueredCheckBox.ForeColor = Color.White AddHandler lacqueredCheckBox.CheckedChanged, AddressOf CheckBox_Lacquered_CheckedChanged Grating_Configurator.Panel_Data.Controls.Add(lacqueredCheckBox) lacqueredCheckBoxBol = True ElseIf lacqueredCheckBoxBol = True AndAlso gratingMaterial <> "Hot dip galvanized steel" _ AndAlso gratingMaterial <> "Untreated" Then RemoveHandler lacqueredCheckBox.CheckedChanged, AddressOf CheckBox_Lacquered_CheckedChanged Grating_Configurator.Panel_Data.Controls.RemoveByKey("CheckBox_Lacquered") lacqueredCheckBoxBol = False gratingLacquered = False End If Update_AvalaibleMeshes() End Sub Private Shared Sub CheckBox_Serrated_CheckedChanged(sender As Object, e As EventArgs) If sender.Checked Then gratingSerrated = True Update_AvalaibleMeshes() Else gratingSerrated = False Update_AvalaibleMeshes() End If End Sub Private Shared Sub CheckBox_Lacquered_CheckedChanged(sender As Object, e As EventArgs) If sender.Checked Then gratingLacquered = True Else gratingLacquered = False End If End Sub Private Shared Sub Update_AvalaibleMeshes() Grating_Configurator.ComboBox_Height.Items.Clear() Grating_Configurator.ComboBox_Height.Enabled = False Grating_Configurator.ComboBox_Thickness.Items.Clear() Grating_Configurator.ComboBox_Thickness.Enabled = False Grating_Configurator.ComboBox_Mesh.Items.Clear() Dim meshesDT As DataTable = Database.database.Tables("Meshes") Dim typeInDT As String = meshesDT.Rows(0)("TYPE") Dim materialInDT As String = meshesDT.Rows(0)("MATERIAL") Dim serratedInDT As Boolean = CBool(meshesDT.Rows(0)("SERRATED")) For i = 0 To meshesDT.Rows.Count - 1 If gratingSerrated = serratedInDT AndAlso gratingMaterial = materialInDT AndAlso gratingType = typeInDT Then Dim item As String item = meshesDT.Rows(i)("LB-SPACING") & "x" & meshesDT.Rows(i)("CB-SPACING") & " (" & meshesDT.Rows(i)("NAME") & ")" Dim addItem As Boolean = True For j = 0 To Grating_Configurator.ComboBox_Mesh.Items.Count - 1 If item = Grating_Configurator.ComboBox_Mesh.Items(j) Then addItem = False Exit For End If Next If addItem = True Then Grating_Configurator.ComboBox_Mesh.Items.Add(item) End If End If Try typeInDT = meshesDT.Rows(i + 1)("TYPE") materialInDT = meshesDT.Rows(i + 1)("MATERIAL") serratedInDT = meshesDT.Rows(i + 1)("SERRATED") Catch ex As Exception End Try Next If Grating_Configurator.ComboBox_Mesh.Items.Count = 0 Then Grating_Configurator.ComboBox_Mesh.Items.Add("") End If End Sub Public Shared Sub MeshChanged(sender As Object, e As EventArgs) Grating_Configurator.ComboBox_Thickness.Items.Clear() Grating_Configurator.ComboBox_Thickness.Enabled = False Grating_Configurator.ComboBox_Height.Enabled = True Grating_Configurator.ComboBox_Height.Items.Clear() gratingMesh = Grating_Configurator.ComboBox_Mesh.Text loadBarSpacing = CInt(gratingMesh.Split("x")(0)) crossBarSpacing = CInt(gratingMesh.Split("x")(1).Split(" ")(0)) gratingName = gratingMesh.Split("(")(1).Split(")")(0) ' Add heights Dim meshesDT As DataTable = Database.database.Tables("Meshes") Dim nameInDT As String = meshesDT.Rows(0)("NAME") Dim materialInDT As String = meshesDT.Rows(0)("MATERIAL") Dim serratedInDT As Boolean = CBool(meshesDT.Rows(0)("SERRATED")) Dim LBSpacingInDT As Integer = CInt(meshesDT.Rows(0)("LB-SPACING")) Dim CBSpacingInDT As Integer = CInt(meshesDT.Rows(0)("CB-SPACING")) Dim tempList As New List(Of Integer) For i = 0 To meshesDT.Rows.Count - 1 If gratingName = nameInDT AndAlso loadBarSpacing = LBSpacingInDT AndAlso crossBarSpacing = CBSpacingInDT _ AndAlso gratingSerrated = serratedInDT AndAlso gratingMaterial = materialInDT Then Dim addItem As Boolean = True For j = 0 To tempList.Count - 1 If meshesDT.Rows(i)("LB-HEIGHT") = tempList(j) Then addItem = False Exit For End If Next If addItem = True Then tempList.Add(CInt(meshesDT.Rows(i)("LB-HEIGHT"))) End If End If Try nameInDT = meshesDT.Rows(i + 1)("NAME") materialInDT = meshesDT.Rows(i + 1)("MATERIAL") serratedInDT = CBool(meshesDT.Rows(i + 1)("SERRATED")) LBSpacingInDT = CInt(meshesDT.Rows(i + 1)("LB-SPACING")) CBSpacingInDT = CInt(meshesDT.Rows(i + 1)("CB-SPACING")) Catch ex As Exception End Try Next tempList.Sort() For i = 0 To tempList.Count - 1 Grating_Configurator.ComboBox_Height.Items.Add(tempList(i)) Next End Sub Public Shared Sub HeightChanged(sender As Object, e As EventArgs) Grating_Configurator.ComboBox_Thickness.Enabled = True Grating_Configurator.ComboBox_Thickness.Items.Clear() gratingHeight = CInt(Grating_Configurator.ComboBox_Height.Text) Dim meshesDT As DataTable = Database.database.Tables("Meshes") Dim nameInDT As String = meshesDT.Rows(0)("NAME") Dim materialInDT As String = meshesDT.Rows(0)("MATERIAL") Dim serratedInDT As Boolean = CBool(meshesDT.Rows(0)("SERRATED")) Dim LBSpacingInDT As Integer = CInt(meshesDT.Rows(0)("LB-SPACING")) Dim CBSpacingInDT As Integer = CInt(meshesDT.Rows(0)("CB-SPACING")) Dim HeightInDT As Integer = CInt(meshesDT.Rows(0)("LB-HEIGHT")) Dim tempList As New List(Of Integer) For i = 0 To meshesDT.Rows.Count - 1 If gratingName = nameInDT AndAlso loadBarSpacing = LBSpacingInDT AndAlso crossBarSpacing = CBSpacingInDT _ AndAlso gratingSerrated = serratedInDT AndAlso gratingMaterial = materialInDT _ AndAlso gratingHeight = HeightInDT Then Dim addItem As Boolean = True For j = 0 To tempList.Count - 1 If meshesDT.Rows(i)("LB-THICKNESS") = tempList(j) Then addItem = False Exit For End If Next If addItem = True Then tempList.Add(CInt(meshesDT.Rows(i)("LB-THICKNESS"))) End If End If Try nameInDT = meshesDT.Rows(i + 1)("NAME") materialInDT = meshesDT.Rows(i + 1)("MATERIAL") serratedInDT = CBool(meshesDT.Rows(i + 1)("SERRATED")) LBSpacingInDT = CInt(meshesDT.Rows(i + 1)("LB-SPACING")) CBSpacingInDT = CInt(meshesDT.Rows(i + 1)("CB-SPACING")) HeightInDT = CInt(meshesDT.Rows(i + 1)("LB-HEIGHT")) Catch ex As Exception End Try Next tempList.Sort() For i = 0 To tempList.Count - 1 Grating_Configurator.ComboBox_Thickness.Items.Add(tempList(i)) Next For i = 0 To Grating_Configurator.ComboBox_Frame.Items.Count - 1 Dim item As String = Grating_Configurator.ComboBox_Frame.Items(i) If CInt(item.Split(" ")(0)) = gratingHeight + 5 Then Grating_Configurator.ComboBox_Frame.Text = Grating_Configurator.ComboBox_Frame.Items(i) Exit For End If Next End Sub Public Shared Sub ThicknessChanged(sender As Object, e As EventArgs) Grating_Configurator.ComboBox_Width.Enabled = True Grating_Configurator.ComboBox_Width.Items.Clear() Grating_Configurator.TextBox_Width.Enabled = True Grating_Configurator.TextBox_Length.Text = 1000 Grating_Configurator.TextBox_Length.Enabled = True If AppForm.fillMode = False Then Grating_Configurator.Panel_Data.Controls("CheckBox_Whole_Mesh").Enabled = True End If loadBarThickness = CInt(Grating_Configurator.ComboBox_Thickness.Text) Dim meshesDT As DataTable = Database.database.Tables("Meshes") Dim nameInDT As String = meshesDT.Rows(0)("NAME") Dim materialInDT As String = meshesDT.Rows(0)("MATERIAL") Dim serratedInDT As Boolean = CBool(meshesDT.Rows(0)("SERRATED")) Dim LBSpacingInDT As Integer = CInt(meshesDT.Rows(0)("LB-SPACING")) Dim CBSpacingInDT As Integer = CInt(meshesDT.Rows(0)("CB-SPACING")) Dim HeightInDT As Integer = CInt(meshesDT.Rows(0)("LB-HEIGHT")) Dim ThicknessInDT As Integer = CInt(meshesDT.Rows(0)("LB-THICKNESS")) For i = 0 To meshesDT.Rows.Count - 1 If gratingName = nameInDT AndAlso loadBarSpacing = LBSpacingInDT AndAlso crossBarSpacing = CBSpacingInDT _ AndAlso gratingSerrated = serratedInDT AndAlso gratingMaterial = materialInDT _ AndAlso gratingHeight = HeightInDT AndAlso loadBarThickness = ThicknessInDT Then wholeMeshesColumn = meshesDT.Rows(i)("WHOLE MESHES") If gratingType = "Pressure Welded" Then CBDiameter = meshesDT.Rows(i)("CB-DIAMETER") CBHeight = 0 CBThickness = 0 Else CBDiameter = 0 CBHeight = meshesDT.Rows(i)("CB-HEIGHT") CBThickness = meshesDT.Rows(i)("CB-THICKNESS") End If Exit For End If Try nameInDT = meshesDT.Rows(i + 1)("NAME") materialInDT = meshesDT.Rows(i + 1)("MATERIAL") serratedInDT = CBool(meshesDT.Rows(i + 1)("SERRATED")) LBSpacingInDT = CInt(meshesDT.Rows(i + 1)("LB-SPACING")) CBSpacingInDT = CInt(meshesDT.Rows(i + 1)("CB-SPACING")) HeightInDT = CInt(meshesDT.Rows(i + 1)("LB-HEIGHT")) ThicknessInDT = CInt(meshesDT.Rows(i + 1)("LB-THICKNESS")) Catch ex As Exception End Try Next Dim wholeMeshesDT As DataTable = Database.database.Tables("Whole Meshes") For i = 0 To wholeMeshesDT.Rows.Count - 1 If Not IsDBNull(wholeMeshesDT.Rows(i)(wholeMeshesColumn)) Then Grating_Configurator.ComboBox_Width.Items.Add(wholeMeshesDT.Rows(i)(wholeMeshesColumn)) End If Next Grating_Configurator.ComboBox_Width.Text = Grating_Configurator.ComboBox_Width.Items(0) Grating_Configurator.TextBox_Width.Text = 1000 End Sub Public Shared Sub WholeMeshWidthsChanged(sender As Object, e As EventArgs) If sender.Checked Then Grating_Configurator.ComboBox_Width.DropDownStyle = ComboBoxStyle.DropDownList Grating_Configurator.Panel_Data.Controls.RemoveByKey("CheckBox_Edge_Bar") Else Grating_Configurator.ComboBox_Width.DropDownStyle = ComboBoxStyle.DropDown Dim CheckTemp As New CheckBox With { .Name = "CheckBox_Edge_Bar", .Text = "Extra Edge Bar", .Left = 110, .Top = 495, .Font = New Font("Microsoft Sans Serif", 7.8), .Checked = True, .Enabled = True, .AutoSize = True, .BackColor = Color.Transparent, .ForeColor = Color.White } AddHandler CheckTemp.CheckedChanged, AddressOf CheckBox_Edge_Bar_CheckedChanged Grating_Configurator.Panel_Data.Controls.Add(CheckTemp) End If End Sub Public Shared Sub CheckBox_Edge_Bar_CheckedChanged(sender As Object, e As EventArgs) End Sub Public Shared Sub WidthChanged(sender As Object, e As EventArgs) If AppForm.fillMode Then If Grating_Configurator.TextBox_Width.Text <> "" Then If CInt(Grating_Configurator.TextBox_Width.Text) >= Grating_Configurator.ComboBox_Width.Items(Grating_Configurator.ComboBox_Width.Items.Count - 1) Then Data.gratingW = CInt(Grating_Configurator.TextBox_Width.Text) Draw_Grating.Update_GratingPoints() End If Enable_Buttons() End If Else If Grating_Configurator.ComboBox_Width.Text <> "" Then If CInt(Grating_Configurator.ComboBox_Width.Text) >= Grating_Configurator.ComboBox_Width.Items(Grating_Configurator.ComboBox_Width.Items.Count - 1) AndAlso CInt(Grating_Configurator.ComboBox_Width.Text) <= Grating_Configurator.ComboBox_Width.Items(0) Then Data.gratingW = CInt(Grating_Configurator.ComboBox_Width.Text) Draw_Grating.Update_GratingPoints() End If Enable_Buttons() End If End If End Sub Public Shared Sub LengthChanged(sender As Object, e As EventArgs) If Grating_Configurator.TextBox_Length.Text <> "" Then If AppForm.fillMode Then If CInt(Grating_Configurator.TextBox_Length.Text) >= 300 Then Data.gratingL = CInt(Grating_Configurator.TextBox_Length.Text) Draw_Grating.Update_GratingPoints() Enable_Buttons() End If Else If CInt(Grating_Configurator.TextBox_Length.Text) >= 300 AndAlso CInt(Grating_Configurator.TextBox_Length.Text) <= 6000 Then Data.gratingL = CInt(Grating_Configurator.TextBox_Length.Text) Draw_Grating.Update_GratingPoints() Enable_Buttons() End If End If End If End Sub Public Shared Sub FrameChanged(Sender As Object, e As EventArgs) If Grating_Configurator.ComboBox_Frame.Text <> "" Then frameSize = CInt(Grating_Configurator.ComboBox_Frame.Text.Split(" ")(0)) End If End Sub Private Shared Sub Enable_Buttons() If AppForm.fillMode Then If Grating_Configurator.TextBox_Width.Text <> "" AndAlso Grating_Configurator.TextBox_Length.Text <> "" Then Grating_Configurator.PictureBox_ExportMenu.Enabled = True Grating_Configurator.PictureBox_CalculateGrid.Enabled = True Grating_Configurator.Button_Angle_Corner.Enabled = True Grating_Configurator.Button_Angle_Side.Enabled = True Grating_Configurator.Button_Square_Corner.Enabled = True Grating_Configurator.Button_Square_Side.Enabled = True Grating_Configurator.Button_Square_Middle.Enabled = True Grating_Configurator.Panel_Data.Controls("TextBox_Max_Load").Enabled = True Grating_Configurator.Panel_Data.Controls("TextBox_Max_Weight").Enabled = True End If Else If Grating_Configurator.ComboBox_Width.Text <> "" AndAlso Grating_Configurator.TextBox_Length.Text <> "" Then Grating_Configurator.PictureBox_ExportMenu.Enabled = True Grating_Configurator.Button_Angle_Corner.Enabled = True Grating_Configurator.Button_Angle_Side.Enabled = True Grating_Configurator.Button_Square_Corner.Enabled = True Grating_Configurator.Button_Square_Side.Enabled = True Grating_Configurator.Button_Square_Middle.Enabled = True End If End If End Sub ' --- Creates the table with points data used in SW --- Public Shared Function Create_ExportTable() As DataTable Dim lSpacing As String = Grating_Configurator.ComboBox_Mesh.Text.Split("x")(0) Dim cSpacing As String = Grating_Configurator.ComboBox_Mesh.Text.Split("x")(1).Split(" ")(0) Dim gratingTable As New DataTable gratingTable.Columns.Add("TYPE", GetType(String)) gratingTable.Columns.Add("MATERIAL", GetType(String)) gratingTable.Columns.Add("NAME", GetType(String)) gratingTable.Columns.Add("SERRATED", GetType(Boolean)) gratingTable.Columns.Add("LACQUERED", GetType(Boolean)) gratingTable.Columns.Add("WIDTH", GetType(Integer)) gratingTable.Columns.Add("LENGTH", GetType(Integer)) gratingTable.Columns.Add("LOADBAR_THICKNESS", GetType(Integer)) gratingTable.Columns.Add("LOADBAR_HEIGHT", GetType(Integer)) gratingTable.Columns.Add("LOADBAR_SPACING", GetType(Integer)) gratingTable.Columns.Add("CROSSBAR_SPACING", GetType(Integer)) gratingTable.Columns.Add("CROSSBAR_DIAMETER", GetType(Integer)) gratingTable.Columns.Add("CROSSBAR_THICKNESS", GetType(Integer)) gratingTable.Columns.Add("CROSSBAR_HEIGHT", GetType(Integer)) gratingTable.Columns.Add("FRAME_SIZE", GetType(Integer)) gratingTable.Rows.Add() gratingTable.Rows(0)("MATERIAL") = gratingMaterial gratingTable.Rows(0)("NAME") = gratingName gratingTable.Rows(0)("SERRATED") = gratingSerrated gratingTable.Rows(0)("LACQUERED") = gratingLacquered gratingTable.Rows(0)("WIDTH") = CInt(Grating_Configurator.ComboBox_Width.Text) gratingTable.Rows(0)("LENGTH") = CInt(Grating_Configurator.TextBox_Length.Text) gratingTable.Rows(0)("LOADBAR_THICKNESS") = CInt(Grating_Configurator.ComboBox_Thickness.Text) gratingTable.Rows(0)("LOADBAR_HEIGHT") = CInt(Grating_Configurator.ComboBox_Height.Text) gratingTable.Rows(0)("LOADBAR_SPACING") = CInt(lSpacing) gratingTable.Rows(0)("CROSSBAR_SPACING") = CInt(cSpacing) gratingTable.Rows(0)("FRAME_SIZE") = frameSize If Grating_Configurator.ComboBox_Type.Text = "Pressure Welded" Then If gratingSerrated = True Then gratingTable.Rows(0)("TYPE") = "pressure_welded_serrated" Else gratingTable.Rows(0)("TYPE") = "pressure_welded" End If gratingTable.Rows(0)("CROSSBAR_DIAMETER") = CBDiameter gratingTable.Rows(0)("CROSSBAR_THICKNESS") = 0 gratingTable.Rows(0)("CROSSBAR_HEIGHT") = 0 Else If gratingSerrated = True Then gratingTable.Rows(0)("TYPE") = "type_a_serrated" Else gratingTable.Rows(0)("TYPE") = "type_a" End If gratingTable.Rows(0)("CROSSBAR_DIAMETER") = 0 gratingTable.Rows(0)("CROSSBAR_THICKNESS") = CBThickness gratingTable.Rows(0)("CROSSBAR_HEIGHT") = CBHeight End If Return gratingTable End Function ' --- Check if the key pressed is a number --- Public Shared Sub Check_IfNumber(e As KeyPressEventArgs) If Asc(e.KeyChar) <> 8 Then If Asc(e.KeyChar) < 48 Or Asc(e.KeyChar) > 57 Then e.Handled = True End If End If End Sub End Class