Ejemplo n.º 1
0
    /// <summary>
    /// Creates an object with data from the databas
    /// </summary>
    /// <param name="id">Country Id</param>
    public Beer(int id)
    {
        //query
        string query = "select be_id, be_grd_alcoh,be_presentation, be_level_ferm,be_unitMeas,be_content,br_code,cla_code,be_price from beer where be_id = @ID";
        //command
        MySqlCommand command = new MySqlCommand(query);

        //parameters
        command.Parameters.AddWithValue("@ID", id);
        //execute query
        DataTable table = MySqlConnection.ExecuteQuery(command);

        //check if rows were found
        if (table.Rows.Count > 0)
        {
            //read first and only row
            DataRow row = table.Rows[0];
            //read data
            _id              = (int)row["be_id"];
            _gradoAlcohol    = (double)row["be_grd_alcoh"];
            _presentation    = (PresentationType)(int)row["be_presentation"];
            _fermentation    = (Fermentation)row["be_nicel_ferm"];
            _measurementUnit = (MeasurementUnit)row["be_unitMeas"];
            _content         = (double)row["be_content"];
            _brand           = (Brand)row["br_code"];
            _clasification   = (Clasification)row["cla_code"];
            _price           = (double)row["be_price"];
        }
    }
Ejemplo n.º 2
0
    public static List <Beer> GetBeers(Country co)
    {
        //list
        List <Beer> list = new List <Beer>();
        //query
        string query = "select be_id, be_grd_alcoh,be_presentation,be_level_ferm,be_unitMeas,be_content,beer.br_code,cla_code,be_price,be_image from beer join brand on beer.br_code= brand.br_code join country on country.cn_code = brand.cn_code where country.cn_code=@CON";
        //command
        MySqlCommand command = new MySqlCommand(query);

        command.Parameters.AddWithValue("@CON", co.Id);
        //execute query
        DataTable table = MySqlConnection.ExecuteQuery(command);

        //iterate rows
        foreach (DataRow row in table.Rows)
        {
            //read fields
            int              id              = (int)row["be_id"];
            double           gradoalcohol    = (double)row["be_grd_alcoh"];
            PresentationType presentation    = (PresentationType)(int)row["be_presentation"];
            Fermentation     fermentation    = (Fermentation)(int)row["be_level_ferm"];
            MeasurementUnit  measurementUnit = (MeasurementUnit)row["be_unitMeas"];
            double           content         = (double)row["be_content"];
            Brand            brand           = new Brand((string)row["br_code"]);
            Clasification    clasification   = new Clasification((string)row["cla_code"]);
            double           price           = (double)row["be_price"];
            string           image           = (string)row["be_image"];
            //add country to list
            list.Add(new Beer(id, gradoalcohol, presentation, fermentation, measurementUnit, content, brand, clasification, price, image));
        }
        //return list
        return(list);
    }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("ClasificationId,ItemType")] Clasification clasification)
        {
            if (id != clasification.ClasificationId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(clasification);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ClasificationExists(clasification.ClasificationId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(clasification));
        }
Ejemplo n.º 4
0
    //creates a instance method for get the clasification of the a brand
    public List <Clasification> GetClasifications()
    {
        //list
        List <Clasification> list = new List <Clasification>();
        //query
        string query = "select cla_code from clasification_brand where br_code=@ID";
        //command
        MySqlCommand command = new MySqlCommand(query);

        command.Parameters.AddWithValue("@ID", _id);
        //execute query
        DataTable table = MySqlConnection.ExecuteQuery(command);

        //iterate rows
        foreach (DataRow row in table.Rows)
        {
            //read fields
            Clasification id = new Clasification((string)row["cla_code"]);
            //add country to list
            list.Add(id);
        }


        //return list
        return(list);
    }
Ejemplo n.º 5
0
 //-----------------------------------------------------------
 public LocalSymbol(int Position, Type LocalType)
 {
     this.Kind      = Clasification.PARAM;
     this.LocalType = LocalType;
     this.Position  = Position;
     setDefaultValues(LocalType);
 }
Ejemplo n.º 6
0
        public void Editar()
        {
            EditarClasificacionViewModel editarClasicacion = new EditarClasificacionViewModel(ClasificacionSeleccionada);
            IWindowManager manejador2 = new WindowManager();

            manejador2.ShowDialog(editarClasicacion, null, null);
            Clasificaciones = null;
            Clasificaciones = new BindableCollection <Clasification>(Clasification.GetAll());
            NotifyOfPropertyChange(() => Clasificaciones);
        }
Ejemplo n.º 7
0
        public void Agregar()
        {
            AgregarClasificacionViewModel agregarClasificacion = new AgregarClasificacionViewModel();
            IWindowManager manejador1 = new WindowManager();

            manejador1.ShowDialog(agregarClasificacion, null, null);
            Clasificaciones = null;
            Clasificaciones = new BindableCollection <Clasification>(Clasification.GetAll());
            NotifyOfPropertyChange(() => Clasificaciones);
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("ClasificationId,ItemType")] Clasification clasification)
        {
            if (ModelState.IsValid)
            {
                _context.Add(clasification);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(clasification));
        }
Ejemplo n.º 9
0
 public Beer()
 {
     _id              = 0;
     _gradoAlcohol    = 0;
     _presentation    = new PresentationType();
     _fermentation    = new Fermentation();
     _measurementUnit = new MeasurementUnit();
     _content         = 0;
     _brand           = new Brand();
     _clasification   = new Clasification();
     _price           = 0;
 }
Ejemplo n.º 10
0
        public void Borrar()
        {
            MessageBoxResult resultado = MessageBox.Show("¿Estas seguro de eliminar el elemento?", "Eliminando", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (resultado == MessageBoxResult.Yes)
            {
                ClasificacionSeleccionada.Delete();
                Clasificaciones = null;
                Clasificaciones = new BindableCollection <Clasification>(Clasification.GetAll());
                NotifyOfPropertyChange(() => Clasificaciones);
            }
        }
Ejemplo n.º 11
0
        public void Editar()
        {
            MessageBoxResult resultado = MessageBox.Show("Estas seguro de editar esta clasificacion?", "Guardando", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (resultado == MessageBoxResult.Yes)
            {
                Clasification clasificacion = new Clasification();
                clasificacion.Name     = Nombre;
                clasificacion.Code     = Codigo;
                clasificacion.BeerType = TipoSeleccionado;
                clasificacion.Edit();
            }
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Creates an object with data from the arguments
 /// </summary>
 /// <param name="id"></param>
 /// <param name="name"></param>
 public Beer(int id, double gradoalcohol, PresentationType presentation, Fermentation fermentation, MeasurementUnit measurementUnit, double content, Brand brand, Clasification clasification, double price, string image)
 {
     _id              = id;
     _gradoAlcohol    = gradoalcohol;
     _presentation    = presentation;
     _fermentation    = fermentation;
     _measurementUnit = measurementUnit;
     _content         = content;
     _brand           = brand;
     _clasification   = clasification;
     _price           = price;
     _image           = image;
 }
Ejemplo n.º 13
0
    public Order(int id)
    {
        //query
        string query = @"SELECT ord_id,ord_request_date,ord_delivery_date,cus_id from Orders where ord_id=@ID";

        //command
        MySqlCommand command = new MySqlCommand(query);
        //parameter 
        command.Parameters.AddWithValue("@ID", id);
        //execute command
        DataTable table = MySqlConnection.ExecuteQuery(command);
        //check if rows found 
        if (table.Rows.Count > 0)
        {

            //get first(and only) found row
            DataRow row = table.Rows[0];
            //read the values of the the field
            _id = id;
            _requestdate = (DateTime)row["ord_request_date"];
            _deliverydate = (DateTime)row["ord_delivery_date"];
            _customer = new Customer((int)row["cus_id"]);
        }

        query = @"select be.be_id,br.br_code,cl.cla_code,br.br_name,cl.cla_name, be.be_grd_alcoh, be.be_presentation,be.be_level_ferm,be.be_unitMeas,be.be_content,od.ordDet_quantity,be.be_price,od.ordDet_UnitPrice, be.be_image
                    from beer be join brand br on br.br_code=be.br_code join clasification cl on cl.cla_code = be.cla_code join orderdetail od on
                    od.be_id = be.be_id join orders ord on ord.ord_id = od.ord_id where od.ord_id=@ID";
        command = new MySqlCommand(query);
        command.Parameters.AddWithValue("@ID", id);
        //execute again command        
        table = MySqlConnection.ExecuteQuery(command);

        //get values of this sale
        _detail = new List<OrderDetail>();

        foreach (DataRow row in table.Rows) {
            Brand brand = new Brand((string)row["br_code"],(string)row["br_name"]);
            Clasification clasification = new Clasification((string)row["cla_code"], (string)row["cla_name"]);
            Beer beer = new Beer((int)row["be_id"], (double)row["be_grd_alcoh"], (PresentationType)(int)row["be_presentation"], (Fermentation)(int)row["be_level_ferm"], (MeasurementUnit)(int)row["be_unitMeas"], (double)row["be_content"],brand,clasification,(double)row["be_price"],(string)row["be_image"]);
            OrderDetail detail = new OrderDetail(beer,(int)row["ordDet_quantity"], (double)row["ordDet_UnitPrice"]);
            _detail.Add(detail);
        }

        

    }
Ejemplo n.º 14
0
        public EditarClasificacionViewModel(Clasification seleccion)
        {
            Nombre = seleccion.Name;
            int indice = Tipos.IndexOf(seleccion.BeerType);

            // no me gusta mucho, pero funciona
            // busca el elemento de la lista que sea igual al que escogiste
            // anteriormente y lo pone como seleccionado
            for (int i = 0; i < Tipos.Count; i++)
            {
                if (seleccion.BeerType.Id == Tipos[i].Id)
                {
                    TipoSeleccionado = Tipos[i];
                    break;
                }
            }
            Codigo = seleccion.Code;
        }
Ejemplo n.º 15
0
    /// <summary>
    /// Crea un objeto cerveza a partir de sus registro de la base datos, filtrado
    /// por su ID.
    /// </summary>
    /// <param name="id">Beer Id</param>
    public Beer(int id)
    {
        // Cadena de Consulta
        string query = "select be_id, be_grd_alcoh,be_presentation, be_level_ferm,"
                       + "be_unitMeas,be_content,br_code,cla_code,be_price, be_image, be_level_ferm"
                       + " from beer where be_id = @ID";

        // Comando MySQL
        MySqlCommand command = new MySqlCommand(query);

        // Parametros Preparados
        command.Parameters.AddWithValue("@ID", id);

        // Ejecutamos Consulta
        MySqlConnection connection = new MySqlConnection();

        connection.ConnectionSource = new AppSettings();

        // Guardamos la consulta en una tabla
        DataTable table = connection.ExecuteQuery(command);

        // Mostramos si la tabla tiene filas (no esta vacia)
        if (table.Rows.Count > 0)
        {
            // Guardamos la primera fila que guarda la informacion
            // de este objeto
            DataRow row = table.Rows[0];

            // Asignamos los datos de la fila a propiedades del objeto
            // a crear
            _id              = (int)row["be_id"];
            _gradoAlcohol    = (double)row["be_grd_alcoh"];
            _presentation    = (PresentationType)(int)row["be_presentation"];
            _fermentation    = (Fermentation)(int)row["be_level_ferm"];
            _measurementUnit = (MeasurementUnit)row["be_unitMeas"];
            _content         = (double)row["be_content"];
            _image           = (byte[])row["be_image"];
            _brand           = (new Brand((string)row["br_code"]));
            _clasification   = (new Clasification((string)row["cla_code"]));
            _price           = (double)row["be_price"];
        }
    }
Ejemplo n.º 16
0
    /// <summary>
    /// Obtener Cervezas
    /// </summary>
    /// <returns>Lista de todos los objetos cervezas que hay en la base de datos</returns>
    public static List <Beer> GetAll()
    {
        // Lista para guardar las cervezas de la base de datos
        List <Beer> list = new List <Beer>();

        // Consulta
        string query = "select be_id, be_grd_alcoh,be_presentation,be_level_ferm,be_unitMeas,be_content,br_code,cla_code,be_price,be_image from beer";

        // Comando
        MySqlCommand command = new MySqlCommand(query);

        // Ejecutar Consulta
        MySqlConnection connection = new MySqlConnection();

        connection.ConnectionSource = new AppSettings();

        // Tabla
        DataTable table = connection.ExecuteQuery(command);

        // Iteramos filas de la consulta para asignar valores
        foreach (DataRow row in table.Rows)
        {
            // Asignamos valores
            int              id              = (int)row["be_id"];
            double           gradoalcohol    = (double)row["be_grd_alcoh"];
            PresentationType presentation    = (PresentationType)(int)row["be_presentation"];
            Fermentation     fermentation    = (Fermentation)(int)row["be_level_ferm"];
            MeasurementUnit  measurementUnit = (MeasurementUnit)row["be_unitMeas"];
            double           content         = (double)row["be_content"];
            Brand            brand           = new Brand((string)row["br_code"]);
            Clasification    clasification   = new Clasification((string)row["cla_code"]);
            double           price           = (double)row["be_price"];
            byte[]           image           = (byte[])row["be_image"];
            // Agregar Cerveza a la lista
            list.Add(new Beer(id, gradoalcohol, presentation, fermentation, measurementUnit, content, brand, clasification, price, image));
        }

        // Regresamos lista de cerveza
        return(list);
    }
Ejemplo n.º 17
0
    public static List <Beer> GetBeers(Brand br)
    {
        //list
        List <Beer> list = new List <Beer>();
        //query
        string query = "select be_id, be_grd_alcoh,be_presentation,be_level_ferm,be_unitMeas,be_content,br_code,cla_code,be_price from beer where br_code=@BRD";
        //command
        MySqlCommand command = new MySqlCommand(query);

        command.Parameters.AddWithValue("@BRD", br.Id);
        //execute query
        MySqlConnection connection = new MySqlConnection();

        connection.ConnectionSource = new AppSettings();
        DataTable table = connection.ExecuteQuery(command);

        //iterate rows
        foreach (DataRow row in table.Rows)
        {
            //read fields
            int              id              = (int)row["be_id"];
            double           gradoalcohol    = (double)row["be_grd_alcoh"];
            PresentationType presentation    = (PresentationType)(int)row["be_presentation"];
            Fermentation     fermentation    = (Fermentation)(int)row["be_level_ferm"];
            MeasurementUnit  measurementUnit = (MeasurementUnit)row["be_unitMeas"];
            double           content         = (double)row["be_content"];
            Brand            brand           = new Brand((string)row["br_code"]);
            Clasification    clasification   = new Clasification((string)row["cla_code"]);
            double           price           = (double)row["be_price"];
            byte[]           image           = (byte[])row["be_image"];
            //add beer to list
            list.Add(new Beer(id, gradoalcohol, presentation, fermentation, measurementUnit, content, brand, clasification, price, image));
        }
        //return list
        return(list);
    }
Ejemplo n.º 18
0
 public Toy(string _name)
 {
     name     = _name;
     provider = "undefined";
     c        = Clasification.TECHMODEL;
 }
Ejemplo n.º 19
0
 public Toy(string _name, string _provider)
 {
     name     = _name;
     provider = _provider;
     c        = Clasification.TECHMODEL;
 }
Ejemplo n.º 20
0
 /*
  * Constructors by default, with several params
  */
 public Toy()
 {
     name     = "undefined";
     provider = "undefined";
     c        = Clasification.TECHMODEL;
 }
Ejemplo n.º 21
0
 //-----------------------------------------------------------
 public LocalSymbol(Type LocalType)
 {
     this.LocalType = LocalType;
     this.Kind      = Clasification.VAR;
     setDefaultValues(LocalType);
 }
Ejemplo n.º 22
0
 public Toy(string _name, string _provider, Clasification _c)
 {
     name     = _name;
     provider = _provider;
     c        = _c;
 }
Ejemplo n.º 23
0
 //-----------------------------------------------------------
 public LocalSymbol(Type LocalType, dynamic Value)
 {
     this.LocalType = LocalType;
     this.Kind      = Clasification.CONST;
     this.Value     = Value;
 }