Exemple #1
0
        private void btnPunto1_Click(object sender, EventArgs e)
        {
            Base        derUno1 = new DerivadaUno(10, 11, 12); //103
            DerivadaUno derUno2 = new DerivadaUno(1, 2, 3);    //103
            Base        derDos1 = new DerivadaDos();           //2

            listaElementos.Add(derUno1);
            listaElementos.Add(derUno2);
            listaElementos.Add(derDos1);

            StringBuilder sb = new StringBuilder();

            foreach (Base b in listaElementos)
            {
                sb.AppendLine(b.VersionFull);
            }
            CargarRichTextBox(sb.ToString());
        }
Exemple #2
0
        public static Queue <T> LeerDatos <T>() where T : Base
        {
            Queue <Base> myQ = new Queue <Base>();

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

                SqlDataReader sr = _command.ExecuteReader();

                while (sr.Read())
                {
                    if (sr["derivada"].ToString() == "1")
                    {
                        DerivadaUno b = new DerivadaUno(int.Parse(sr[0].ToString()), int.Parse(sr[1].ToString()), int.Parse(sr[2].ToString()));
                        myQ.Enqueue(b);
                    }
                    else
                    {
                        Base b = new DerivadaDos(int.Parse(sr[0].ToString()), int.Parse(sr[1].ToString()));
                        myQ.Enqueue(b);
                    }
                }
                sr.Close();
                _connection.Close();
            }
            catch (Exception e)
            {
                Test lectura = new Test();
                lectura.richTest.AppendText(e.Message);
                lectura.ShowDialog();
            }

            Queue <T> retorno = (Queue <T>)Convert.ChangeType(myQ, typeof(Queue <T>));


            return(retorno);
        }