コード例 #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Application.Run(new Form1());

            ListaProfesores lp = new ListaProfesores();

            //

            if (File.Exists("Profesores.bin"))
            {
                using (Stream stream = File.Open("Profesores.bin", FileMode.Open))
                {
                    var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    lp = (ListaProfesores)bformatter.Deserialize(stream);
                }
            }
            else
            {
                ///datos de prueba
                lp.Add(new Profesor("100001", "Alex", "Gutierrez", "Santillan", "holi"));
                lp.Add(new Profesor("100002", "juan", "Rodriguez", "Martinez", "xd"));
                lp.contraseñaAdmin = "12345";
                //

                using (Stream sw = File.Open("Profesores.bin", FileMode.Create))
                {
                    var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    bformatter.Serialize(sw, lp);
                    sw.Close();
                }
            }
            //


            Form_Loging loging = new Form_Loging(lp, lp.contraseñaAdmin);

            loging.ShowDialog();


            File.Delete("Profesores.bin");
            using (Stream sw = File.Create("Profesores.bin"))
            {
                var bformatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                bformatter.Serialize(sw, lp);
                sw.Close();
            }
        }
コード例 #2
0
        private void buttonAgregar_Click(object sender, EventArgs e)
        {
            if (textBoxContraseña.Text != "" && textBoxNombre.Text != "")
            {
                lp.Add(new Profesor(textBoxCodigo.Text, textBoxNombre.Text, textBoxApellidoP.Text, textBoxApellidoM.Text, textBoxContraseña.Text));

                textBoxCodigo.Text = CodigoDisponible().ToString();
            }
            CargarLista();
            textBoxCodigo.Text     = CodigoDisponible().ToString();
            textBoxContraseña.Text = "";
            textBoxNombre.Text     = "";
            textBoxApellidoP.Text  = "";
            textBoxApellidoM.Text  = "";
            buttonAgregar.Enabled  = false;
        }