Scusami pensavo fosse sufficiente la spigazione, dato che pensavo fosse un problema circoscritto all'oggetto pdf chiuso nel modo scorretto.
Ecco il codice.
codice:
Public Class ListProfile
Dim db As New Database
Private Sub ListProfile_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AggiornaProfili()
End Sub
Private Sub ListProfile_Activated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Activated
ModelView.Focus()
ModelView.Items(0).Selected = True
'CaricaDatiFigurini()
End Sub
Private Sub CaricaDatiFigurini()
If ModelView.SelectedItems.Count <> 0 Then
Dim FilePdf As String
PictureBoxFigurini.Image = Image.FromFile(System.Environment.CurrentDirectory + "\images\figurini\" + ModelView.SelectedItems(0).SubItems(0).Text + ".jpg")
FilePdf = System.Environment.CurrentDirectory + "\doc\doc_tecnica\" + GeneralModel.language + "\" + ModelView.SelectedItems(0).SubItems(0).Text + ".pdf"
If System.IO.File.Exists(FilePdf) Then
TecDocPDF.src = FilePdf
Else
If GeneralModel.language = "ITA" Then
MessageBox.Show("Il file richiesto non è valido." & vbCrLf & "Contattare il supporto tecnico per correggere il problema", "Errore!")
ElseIf GeneralModel.language = "ENG" Then
MessageBox.Show("The requested file is not valid." & vbCrLf & "Contact technical support", "Error!")
End If
End If
End If
End Sub
Private Sub AggiornaProfili() Handles NameSearch.KeyUp
db.Connetti()
Dim Sql As String
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Sql = "SELECT * FROM modelli WHERE modello_nome LIKE '%" & NameSearch.Text & "%'"
Dim da As New OleDb.OleDbDataAdapter(Sql, db.istance)
da.Fill(dt)
ModelView.Items.Clear()
For Each myRows In dt.Rows
Sql = "SELECT COUNT(*) FROM Allegati WHERE modello_id = " & CInt(myRows.Item("modello_id"))
Dim command As New OleDb.OleDbCommand(Sql, db.istance)
Dim reader As OleDb.OleDbDataReader = command.ExecuteReader()
reader.Read()
If reader(0).ToString() > 0 Then
ModelView.Items.Add(myRows.Item("modello_id"), 0)
Else
ModelView.Items.Add(myRows.Item("modello_id"), 1)
End If
ModelView.Items(ModelView.Items.Count - 1).SubItems.Add(myRows.Item("modello_nome"))
ModelView.Items(ModelView.Items.Count - 1).SubItems.Add(myRows.Item("modello_anno"))
Next
db.Disconnetti()
End Sub
Private Sub ResetDescButton(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImgClose.MouseLeave, BeforeForm.MouseLeave
DescButton.Text = " "
End Sub
Private Sub ImgClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImgClose.Click
TecDocPDF.Dispose()
Application.Exit()
End Sub
Private Sub ImgClose_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImgClose.MouseHover
If GeneralModel.language = "ITA" Then
DescButton.Text = "Chiudi Programma"
ElseIf GeneralModel.language = "ENG" Then
DescButton.Text = "Exit Program"
End If
End Sub
Private Sub BeforeForm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeforeForm.Click
TecDocPDF.Dispose()
Me.Close()
MainMenu.Show()
End Sub
Private Sub BeforeForm_MouseHover(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeforeForm.MouseHover
If GeneralModel.language = "ITA" Then
DescButton.Text = "Torna all' indice precedente"
ElseIf GeneralModel.language = "ENG" Then
DescButton.Text = "GoTo previous index"
End If
End Sub
Private Sub ModelView_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ModelView.SelectedIndexChanged
CaricaDatiFigurini()
ModelView.Focus()
End Sub
Private Sub TecDocPDF_OnError(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TecDocPDF.OnError
End Sub
Private Sub Confirm_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Confirm.Click
'Apri Lista Documentazione Tecnica
DocTec.idmodel = ModelView.SelectedItems(0).SubItems(0).Text
DocTec.NameModel = ModelView.SelectedItems(0).SubItems(1).Text
Me.Close()
DocTec.Show()
'Dim IdModel As Integer
'IdModel = CInt(ModelView.SelectedItems(0).SubItems(0).Text)
'Dim Sql
'ModelView.Items.Clear()
'ModelView.Columns.Clear()
'ModelView.Columns.Add("Tipologia")
'ModelView.Columns.Add("File")
'ModelView.Columns.Add("Language")
'db.Connetti()
'Sql = "SELECT Allegati.allegato_file, Allegati.allegato_lang, Allegati_Tipo.allegatotipo_desc FROM Allegati "
'Sql = Sql & "INNER JOIN Allegati_Tipo ON Allegati.allegatotipo_id = Allegati_Tipo.allegatotipo_id "
'Sql = Sql & "WHERE modello_id = " & IdModel
'Dim command As New OleDb.OleDbCommand(Sql, db.istance)
'Dim reader As OleDb.OleDbDataReader = command.ExecuteReader()
'While reader.Read()
' ModelView.Items.Add(reader("allegatotipo_desc").ToString)
' ModelView.Items(ModelView.Items.Count - 1).SubItems.Add(reader("allegato_file").ToString)
' ModelView.Items(ModelView.Items.Count - 1).SubItems.Add(reader("allegato_lang").ToString)
'End While
'db.Disconnetti()
End Sub
End Class