Imports System.IO
Imports System.Runtime.Serialization.Formatters.Binary
Public Class Principal

    Public objStudenti As New ColectieStudent

    Private Sub IntroducereDateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IntroducereDateToolStripMenuItem.Click
        IntroducereDate.ShowDialog()
    End Sub

    Private Sub AfisareDateToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AfisareDateToolStripMenuItem.Click
        Afisare.ShowDialog()
    End Sub

    Private Sub SalvareFisierToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalvareFisierToolStripMenuItem.Click
        ' salvarea datelor in fisier
        Dim s As New FileStream("Studenti.txt", FileMode.Create)
        Dim f As New BinaryFormatter
        f.Serialize(s, objStudenti)
        s.Close()

    End Sub

    Private Sub CitireFisierToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CitireFisierToolStripMenuItem.Click
        ' citirea datelor din fisier
        Dim s = New FileStream("Studenti.txt", FileMode.Open)
        Dim f As BinaryFormatter = New BinaryFormatter
        objStudenti = CType(f.Deserialize(s), ColectieStudent)
        s.close()
    End Sub
End Class