Database connect

This commit is contained in:
Mans 2021-02-05 09:40:54 +01:00
parent 73d92f9354
commit 27a464dd6a
2 changed files with 39 additions and 19 deletions

Binary file not shown.

View File

@ -2,8 +2,8 @@
Imports Excel = Microsoft.Office.Interop.Excel Imports Excel = Microsoft.Office.Interop.Excel
Public Class GUI Public Class GUI
Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb" 'Public Shared filepath As String = "C:\Users\Anton\Documents\Exjobb"
'Public Shared filepath As String = "C:\Users\xperd\OneDrive\Dokument\Exjobb" Public Shared filepath As String = "C:\Users\xperd\Documents"
Dim filesFolder As String = filepath ' Hämta från settings Dim filesFolder As String = filepath ' Hämta från settings
Dim HLCtFolder As String = filepath & "\X2021" ' Hämta från settings Dim HLCtFolder As String = filepath & "\X2021" ' Hämta från settings
@ -62,6 +62,7 @@ Public Class GUI
Create_StartPoints() Create_StartPoints()
Program.Load_XCC(filesFolder, HLCtFolder) Program.Load_XCC(filesFolder, HLCtFolder)
excelWB = excelApp.Workbooks.Open(HLCtFolder & "\Databas.xlsx")
End Sub End Sub
' --- Retrive parameters for the drawing box --- ' --- Retrive parameters for the drawing box ---
@ -318,19 +319,41 @@ Public Class GUI
gratingType = ComboBox_TypeChooser.Text gratingType = ComboBox_TypeChooser.Text
ComboBox_Material.Enabled = True ComboBox_Material.Enabled = True
ComboBox_Material.Items.Clear() ComboBox_Material.Items.Clear()
If gratingType = "Pressure Welded" Then
ComboBox_Material.Items.Add("Standard") Dim materialSheet As Excel.Worksheet
ComboBox_Material.Items.Add("Acid-proof") materialSheet = excelWB.Sheets("Material")
ComboBox_Material.Items.Add("Stainless Steel (Pickled)") Dim typeColumn As Integer = 0
ComboBox_Material.Items.Add("Stainless Steel (Untreated)") Dim columnCounter As Integer = 1
ComboBox_Material.Items.Add("Untreated") While typeColumn = 0
Else If materialSheet.Cells(1, columnCounter).value = "TYPE" Then
ComboBox_Material.Items.Add("Standard") typeColumn = materialSheet.Cells(1, columnCounter).column
ComboBox_Material.Items.Add("Stainless Steel (Pickled)")
ComboBox_Material.Items.Add("Stainless Steel (Untreated)")
ComboBox_Material.Items.Add("Aluminum")
ComboBox_Material.Items.Add("Untreated")
End If End If
columnCounter = columnCounter + 1
End While
Dim materialColumn As Integer = 0
columnCounter = 1
While materialColumn = 0
If materialSheet.Cells(1, columnCounter).value = "MATERIAL" Then
materialColumn = materialSheet.Cells(1, columnCounter).column
End If
columnCounter = columnCounter + 1
End While
Dim typeInExcel As String
Dim rowCounter As Integer = 2
typeInExcel = materialSheet.Cells(rowCounter, typeColumn).value
While typeInExcel <> ""
If gratingType = typeInExcel Then
ComboBox_Material.Items.Add(materialSheet.Cells(rowCounter, materialColumn).Value)
End If
rowCounter = rowCounter + 1
typeInExcel = materialSheet.Cells(rowCounter, typeColumn).value
End While
ComboBox_Material.Text = ComboBox_Material.Items(0) ComboBox_Material.Text = ComboBox_Material.Items(0)
End Sub End Sub
@ -459,9 +482,6 @@ Public Class GUI
End If End If
End Sub End Sub
' --- Check if width is a number --- ' --- Check if width is a number ---
Private Sub ComboBox_Width_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ComboBox_Width.KeyPress Private Sub ComboBox_Width_KeyPress(sender As Object, e As KeyPressEventArgs) Handles ComboBox_Width.KeyPress
Check_IfNumber(e) Check_IfNumber(e)
@ -682,7 +702,7 @@ Public Class GUI
Private Sub SettingsButton_Click(sender As Object, e As EventArgs) Handles SettingsButton.Click Private Sub SettingsButton_Click(sender As Object, e As EventArgs) Handles SettingsButton.Click
'Program.Update_KB() 'Program.Update_KB()
excelWB = excelApp.Workbooks.Open(HLCtFolder & "\Databas.xlsx")
excelSheet = excelWB.Sheets("Pressure_welded") 'Call sheet by name excelSheet = excelWB.Sheets("Pressure_welded") 'Call sheet by name
'excelSheet = excelWB.Sheets(1) 'Call sheet by number 'excelSheet = excelWB.Sheets(1) 'Call sheet by number