Public Class Principale
Private Sub Principale_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: questa riga di codice carica i dati nella tabella 'Empire1DataSet.TB_Materiali'. È possibile spostarla o rimuoverla se necessario.
Me.TB_MaterialiTableAdapter.Fill(Me.Empire1DataSet.TB_Materiali)
Me.TB_QuantitàTableAdapter.Fill(Me.Empire1DataSet.TB_Quantità)
Me.TB_OggettiTableAdapter.Fill(Me.Empire1DataSet.TB_Oggetti)
Me.TB_PossedutoTableAdapter.Fill(Me.Empire1DataSet.TB_Posseduto)
Me.Location = New Point(150, 85)
'queste sono righe provvisorie e servono per il popolamento dei datatable
If Me.Empire1DataSet.TB_Materiali.Count = 0 Then CaricaTB_Materiali(TB_MaterialiTableAdapter)
If Me.Empire1DataSet.TB_Quantità.Count = 0 Then CaricaTB_Quantità(TB_QuantitàTableAdapter)
If Me.Empire1DataSet.TB_Oggetti.Count = 0 Then CaricaTB_Oggetti(TB_OggettiTableAdapter)
If Me.Empire1DataSet.TB_Posseduto.Count = 0 Then CaricaTB_Posseduto(TB_PossedutoTableAdapter)
Modifica_DGV()
End Sub
Private Sub Modifica_DGV()
'Cambia allineamento/colori/carattere alle righe d'intestazione dei DataGridView
With DGV_Quantita.ColumnHeadersDefaultCellStyle
.Alignment = DataGridViewContentAlignment.MiddleCenter
.BackColor = Color.Navy
.ForeColor = Color.White
.Font = New Font(DGV_Quantita.Font, FontStyle.Bold)
End With
DGV_Quantita.EnableHeadersVisualStyles = False
With DGV_Posseduto.ColumnHeadersDefaultCellStyle
.Alignment = DataGridViewContentAlignment.MiddleCenter
.BackColor = Color.Navy
.ForeColor = Color.White
.Font = New Font(DGV_Posseduto.Font, FontStyle.Bold)
End With
DGV_Posseduto.EnableHeadersVisualStyles = False
'allinea i dati: 1° colonna al centro, le altre a destra
For Col As Integer = 1 To 7
If Col = 1 Then
DGV_Posseduto.Columns(Col).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
Else
DGV_Posseduto.Columns(Col).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
End If
Next
For Col As Integer = 1 To 8
If Col = 1 Then
DGV_Quantita.Columns(Col).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
Else
DGV_Quantita.Columns(Col).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight
End If
Next
'cambia testi intestazioni ai DataGridView
If Me.Empire1DataSet.TB_Posseduto.Count > 0 And Me.Empire1DataSet.TB_Quantità.Count > 0 Then
For col As Integer = 2 To 7
DGV_Posseduto.Columns(col).HeaderText = CType(Me.Empire1DataSet.TB_Materiali.Rows(Val(lbl_ID_Materiali.Text) - 1)(col), String)
DGV_Quantita.Columns(col + 1).HeaderText = CType(Me.Empire1DataSet.TB_Materiali.Rows(Val(lbl_ID_Materiali.Text) - 1)(col), String)
Next
End If
End Sub
Private Sub cmbOggetti_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbOggetti.Click
Modifica_DGV()
End Sub
Private Sub btnEsci_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEsci.Click
Application.Exit()
End Sub
Private Sub bntMateriali_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntMateriali.Click
FrmMateriali.Show()
End Sub
Private Sub bntOggetti_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntOggetti.Click
FrmOggetti.Show()
End Sub
Private Sub bntQuantità_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntQuantità.Click
FrmPosseduto.Show()
End Sub
Private Sub btnSalva_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalva.Click
Me.Validate()
Me.TB_PossedutoBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Empire1DataSet)
End Sub
'Private Sub cmbOggetti_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles _ cmbOggetti.SelectedIndexChanged
' Modifica_DGV()
'End Sub
End Class