Пример #1
0
        /// <summary>
        /// Btn02
        /// </summary>
        private void CreoPerro(object sender, EventArgs e)
        {
            Perro b = new Perro("Spiderman");

            this._listaMascotas += b;
            this.btn03.Click    += new EventHandler(this.GuardarBinario);
        }
Пример #2
0
        /// <summary>
        /// Btn01
        /// </summary>
        private void CreoMascota(object sender, EventArgs e)
        {
            Mascota a = new Mascota("Conejo");

            this._listaMascotas += a;
            this.btn02.Click    += new EventHandler(this.CreoPerro);
        }
Пример #3
0
        /// <summary>
        /// Btn09 Traigo Base
        /// </summary>
        private void FuncionLeerSQL(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();

            this._listaMascotas = new Mascotera <Mascota>();

            try
            {
                this._command.Connection  = this._connection;
                this._command.CommandType = CommandType.Text;
                this._command.CommandText = "SELECT * FROM Mascotas";
                this._connection.Open();

                SqlDataReader sr = this._command.ExecuteReader();
                while (sr.Read())
                {
                    this._listaMascotas.Lista.Add(new Mascota(sr[1].ToString()));
                }
                sr.Close();
            }
            catch (Exception error)
            {
                MessageBox.Show("Error: " + error.Message);
            }
            finally{
                this._connection.Close();
            }
        }
Пример #4
0
 public Form1()
 {
     InitializeComponent();
     this._listaMascotas = new Mascotera <Mascota>();
     this._connection    = new SqlConnection(Properties.Settings.Default.Setting);
     this._command       = new SqlCommand();
     this.btn01.Click   += new EventHandler(this.CreoMascota);
     this.btn12.Click   += new EventHandler(this.CerrarFormulario);
 }
Пример #5
0
        /// <summary>
        /// Btn04
        /// </summary>
        private void TraerArchivoBinario(object sender, EventArgs e)
        {
            Mascota    aux = new Mascota();
            FileStream fs  = new FileStream("Mascotas.dat", FileMode.Open);

            try
            {
                BinaryFormatter formatter = new BinaryFormatter();
                aux = (Mascota)formatter.Deserialize(fs);
                this._listaMascotas += aux;
            }
            catch (SerializationException)
            {
                MessageBox.Show("No se pudo deserializar");
            }
            finally
            {
                fs.Close();
                this.btn06.Click += new EventHandler(this.FuncionMostar);
            }
        }