Example #1
0
 public Producto(int Codigo, string Nombre, double Precio, Categoria Cat, double PrecioOferta, Image FotoPath, int StockActual, int StockComprometido)
 {
     this._Codigo = Codigo;
     this._Nombre = Nombre;
     this._Precio = Precio ;
     this._Cat = Cat;
     this._PrecioOferta = PrecioOferta;
     this._StockActual = StockActual;
     this._StockComprometido = StockComprometido;
     this._FotoPath = FotoPath;
 }
Example #2
0
        public Categoria UnObjetoCategoria(int i)
        {
            Categoria Nueva=new Categoria();
            foreach (Categoria c in ListaCategorias)
            {
                if (c.Codigo == i)
                {
                    Nueva.Codigo = c.Codigo;

                    Nueva.Nombre = c.Nombre;
                    break;
                }
            }
            return Nueva;
        }
        public void agregar_categoria(Categoria cat)
        {
            try
            {

                connServ.Abrir();

                    using (SqlCommand command = new SqlCommand())
                    {
                        command.CommandText = "INSERT INTO Categorias (Id,Nombre) values ("+cat.Codigo+",'"+cat.Nombre+"')";
                        command.Connection = connServ.Conexion();

                        command.ExecuteNonQuery();
                    }
                    connServ.Cerrar();

            }
            catch(Exception ex)
            {
                throw new ArgumentException("Error Agregando Categoria",ex);
            }
        }
        public bool AgregarProducto(Categoria categoria, string codigo,Image Foto, string nombre, string precio, string preciooferta, string stockactual, string stockcomprometido)
        {
            bool Exito = false;

            try
            {

                double Precio = double.Parse(precio,this.cultura);
                int Codigo = Convert.ToInt32(codigo);
                Categoria Categoria = categoria;
                int StockActual = Convert.ToInt32(stockactual);
                int StockComprometido = Convert.ToInt32(stockcomprometido);
                double PrecioOferta = double.Parse(preciooferta,this.cultura);
                Producto Producto = new Producto(Codigo, nombre, Precio, Categoria, PrecioOferta, Foto, StockActual, StockComprometido);
                //this.miDao.agregar_producto(Producto);
                this.DaoProducto.Agregar_producto(Producto);
                Exito = true;
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Error Agregando Producto",ex);
            }
            return Exito;
        }
Example #5
0
        public void CargaInicial()
        {
            String path = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase).Substring(6);
            Control.ControlCategorias ControladoraCategorias = new Control.ControlCategorias();
            Control.ControlUsuarios ControladoraUser = new Control.ControlUsuarios();
            Control.ControlCarritos COntroladoraCarrito = new Control.ControlCarritos();
            Control.ControlProductos ControladoraProductos = new Control.ControlProductos();

            ControladoraUser.AgregarNuevoUsuario("Gustavo Emmanuel", "Sanchez Figueroa", "*****@*****.**", "admin", "1234", "14 de Julio 2182 6º B - Mar del Plata", 32395520, 2);
            ControladoraUser.AgregarNuevoUsuario("Gustavo Emmanuel", "Sanchez Figueroa", "*****@*****.**", "user", "1234", "14 de Julio 2182 6º B - Mar del Plata", 32395520, 1);
            ControladoraUser.AgregarNuevoUsuario("Francisco", "Pane", "*****@*****.**", "user2", "1234", "Alem 234 - Mar del Plata", 00000000, 1);
            ControladoraUser.AgregarNuevoUsuario("Cristina", "Kirchner", "*****@*****.**", "user3", "1234", "Edison 1948 - Mar Chiquita", 00000000, 1);

            ControladoraCategorias.InsertarCategoria("Lacteos", "1");
            ControladoraCategorias.InsertarCategoria("Fiambres", "2");
            ControladoraCategorias.InsertarCategoria("Limpieza", "3");
            ControladoraCategorias.InsertarCategoria("Supercongelados", "4");
            ControladoraCategorias.InsertarCategoria("Panaderia", "5");

            Categoria oCategoria = new Categoria();
            ControladoraCategorias.CargarCategorias(false);
            oCategoria = ControladoraCategorias.ObtenerUnaCategoria(1);
            ControladoraProductos.AgregarProducto(oCategoria, "1", Image.FromFile(path + "\\Imagenes\\PortSalut.jpg"), "Queso Port Salut Sancor", "100", "90", "10", "0");
            ControladoraProductos.AgregarProducto(oCategoria, "2", Image.FromFile(path + "\\Imagenes\\LecheConHierro.jpg"), "Leche con Hierro La Serenisima", "3", "2", "10", "0");
            ControladoraProductos.AgregarProducto(oCategoria, "3", Image.FromFile(path + "\\Imagenes\\Yogur.jpg"), "Yogurisimo Vainilla", "2", "2", "10", "0");
            oCategoria = ControladoraCategorias.ObtenerUnaCategoria(2);
            ControladoraProductos.AgregarProducto(oCategoria, "4", Image.FromFile(path + "\\Imagenes\\Mortadela.jpg"), "Mortadela Paladini", "70", "66", "10", "0");
            ControladoraProductos.AgregarProducto(oCategoria, "5", Image.FromFile(path + "\\Imagenes\\JamonCocido.jpg"), "Jamon Cocido Paladini", "70", "66", "10", "0");
            oCategoria = ControladoraCategorias.ObtenerUnaCategoria(3);
            ControladoraProductos.AgregarProducto(oCategoria, "6", Image.FromFile(path + "\\Imagenes\\Crema.jpg"), "Cif Crema", "7", "6", "10", "0");
            ControladoraProductos.AgregarProducto(oCategoria, "7", Image.FromFile(path + "\\Imagenes\\JabonEnPolvo.jpg"), "Javon en Polvo Ace", "10", "8", "10", "0");
            oCategoria = ControladoraCategorias.ObtenerUnaCategoria(4);
            ControladoraProductos.AgregarProducto(oCategoria, "8", Image.FromFile(path + "\\Imagenes\\Patitas.jpg"), "Patitas", "10", "8", "10", "0");
            ControladoraProductos.AgregarProducto(oCategoria, "9", Image.FromFile(path + "\\Imagenes\\HamburguesasPollo.jpg"), "Supremas con Jamon y queso Granja del Sol", "15", "13", "10", "0");
            ControladoraProductos.AgregarProducto(oCategoria, "10", Image.FromFile(path + "\\Imagenes\\Pizza.jpg"), "Pizza Especial Sivarita", "22", "19", "10", "0");
            oCategoria = ControladoraCategorias.ObtenerUnaCategoria(5);
            ControladoraProductos.AgregarProducto(oCategoria, "11", Image.FromFile(path + "\\Imagenes\\PanLactal.jpg"), "Pan Lactal Fargo", "5", "4", "10", "0");
            ControladoraProductos.AgregarProducto(oCategoria, "12", Image.FromFile(path + "\\Imagenes\\PanHamburguesas.jpg"), "Pan Hamburguesas Bimbo", "5", "4", "10", "0");

            this.session = ControladoraUser.LogIn("user", "1234");

            COntroladoraCarrito.AgregarItem(2, 2);
            COntroladoraCarrito.AgregarItem(3, 3);
            COntroladoraCarrito.AgregarItem(4, 4);
            COntroladoraCarrito.AgregarItem(5, 5);
            COntroladoraCarrito.AgregarItem(6, 6);
            COntroladoraCarrito.GenerarOrden(this.session);

            this.session = null;
            this.session = ControladoraUser.LogIn("user2", "1234");

            Control.ControlCarritos COntroladoraCarrito2 = new Control.ControlCarritos();
            COntroladoraCarrito2.AgregarItem(7, 7);
            COntroladoraCarrito2.AgregarItem(8, 8);
            COntroladoraCarrito2.AgregarItem(9, 9);
            COntroladoraCarrito2.AgregarItem(10, 10);
            COntroladoraCarrito2.AgregarItem(6, 6);
            COntroladoraCarrito2.GenerarOrden(this.session);

            //this.session = null;
            //this.session = ControladoraUser.LogIn("user3", "1234");

            //Control.ControlCarritos COntroladoraCarrito3 = new Control.ControlCarritos();
            //COntroladoraCarrito3.AgregarItem(7, 7);
            //COntroladoraCarrito3.AgregarItem(8, 8);
            //COntroladoraCarrito3.AgregarItem(9, 9);
            //COntroladoraCarrito3.AgregarItem(10, 10);
            //COntroladoraCarrito3.AgregarItem(6, 6);
            //OrdenCompra OC = COntroladoraCarrito3.GenerarOrden2(this.session);
            //OC.Estado = "CONFIRMADO";
        }
 private void listBox_listado_SelectedValueChanged(object sender, EventArgs e)
 {
     if (listBox_listado.SelectedIndex >= 0)
     {
         c = (Categoria)ListaCategorias[listBox_listado.SelectedIndex];
         label_nombre.Text = c.Nombre;
         label_id.Text = c.Codigo.ToString();
         txt_modif_id.Text = c.Codigo.ToString();
         txt_modif_nombre.Text = c.Nombre;
     }
 }
        public ArrayList leer_categorias(bool DesdeMemoria)
        {
            if (DesdeMemoria)
            {
                try
                {
                    if (ListaCategorias != null && ListaCategorias.Count > 0)
                    {
                        return ListaCategorias;
                    }
                    else
                        return null;
                }
                catch(Exception ex)
                {
                    throw new ArgumentException("Error",ex);
                }
            }
            else
            {
                try
                {
                    //ListaCategorias = new ArrayList();
                    ListaCategorias.Clear();

                        Categoria cat = null;
                        connServ.Abrir();

                        using (SqlCommand command = new SqlCommand())
                        {
                            command.CommandText = "SELECT Id,Nombre FROM Categorias";
                            command.Connection = connServ.Conexion();

                            SqlDataReader rdr = command.ExecuteReader();

                            while (rdr.Read())
                            {

                                cat = new Categoria(Convert.ToInt32(rdr.GetValue(0)), rdr.GetValue(1).ToString());
                                ListaCategorias.Add(cat);
                            }
                        }
                        connServ.Cerrar();

                }
                catch (Exception e)
                {
                    throw new ArgumentException("Error Cargando Categorias ",e);
                }
                return ListaCategorias;
            }
        }
        public Categoria UnObjetoCategoria(int i)
        {
            Categoria Nueva = new Categoria();
            try
            {
                if (ListaCategorias!=null)
                {
                    foreach (Categoria c in ListaCategorias)
                    {
                        if (c.Codigo == i)
                        {
                            Nueva.Codigo = c.Codigo;
                            Nueva.Nombre = c.Nombre;

                            break;
                        }
                    }
                }

                return Nueva;

            }
            catch(Exception ex)
            {
                throw new ArgumentException("Error Buscando Categoria [DAOSQL]",ex) ;
            }
        }
Example #9
0
 public void agregar_categoria(Categoria cat)
 {
     ListaCategorias.Add(cat);
 }