Esempio n. 1
0
        /// <summary>
        /// Guardar en formato xml botines
        /// </summary>
        /// <param name="botin"></param>
        /// <param name="nombreArchivo"></param>
        /// <returns></returns>
        public static bool GuardarXml(Botin botin, string nombreArchivo)
        {
            bool        auxSeGuardo = false;
            Xml <Botin> xml         = new Xml <Botin>();

            auxSeGuardo = xml.Guardar(nombreArchivo, botin);

            return(auxSeGuardo);
        }
Esempio n. 2
0
        /// <summary>
        /// Lista botines por ID cargados de la BD y devuelve una empresa con esos botines ingresados.
        /// </summary>
        /// <returns></returns>
        public Empresa ListarBotines()
        {
            try
            {
                Botin.EOrigen    origen;
                Botin.EMarca     marca;
                Botin.ETipoBotin tipoBotin;
                using (SqlConnection sqlConnection = new SqlConnection(this.connectionString))
                {
                    string command = "SELECT * FROM Botines where BotinesID=BotinesID";

                    SqlCommand sqlCommand = new SqlCommand(command, sqlConnection);
                    sqlConnection.Open();
                    SqlDataReader reader = sqlCommand.ExecuteReader();

                    List <Botin> botines = new List <Botin>();
                    Empresa      empresa = new Empresa("Botines BD", 200);

                    while (reader.Read())
                    {
                        int id = (int)reader["BotinesID"];
                        origen = CalzadosDAO.EnumOrigen((string)reader["Origen"]);
                        double precioCompra = (float)Convert.ToDouble(reader["PrecioCompra"]);
                        int    talle        = (int)reader["Talle"];
                        string descripcion  = null;
                        if (reader["Descripcion"] != DBNull.Value)
                        {
                            descripcion = (string)reader["Descripcion"];
                        }
                        marca     = CalzadosDAO.EnumMarca((string)reader["Marca"]);
                        tipoBotin = CalzadosDAO.EnumTipoBotin((string)reader["Tipo"]);

                        Botin botin = new Botin(id, origen, precioCompra, talle, descripcion, marca, tipoBotin);
                        empresa.SumarCalzado <Botin>(empresa, botin);
                    }

                    return(empresa);
                }
            }
            catch (Exception ex)
            {
                throw new LeerBDException("No se pudo leer la BD", ex);
            }
        }