Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Foto,Nombre,Descripcion,Cantidad,Estado,Categoria")] DataProductos dataProductos)
        {
            if (id != dataProductos.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dataProductos);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DataProductosExists(dataProductos.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dataProductos));
        }
Example #2
0
        public async Task <ActionResult> RenderImage(int id)
        {
            DataProductos item = await _context.Productos.FindAsync(id);

            byte[] photoBack = item.Foto;

            return(File(photoBack, "image/png"));
        }
Example #3
0
        private void Btnimprimir_Click(object sender, EventArgs e)
        {
            // Variable para guardar la consulta
            string qry = "";
            // Variable para extraer la configuracion del appconfig
            string cadenaconexion = ConfigurationManager.AppSettings.Get("cadenaconexion");
            //Variable para conectarnos a la BD
            SqlConnection sqlCNX = new SqlConnection(cadenaconexion);
            //Variable apra guardar el objeto o comando
            SqlCommand sqlCMD = new SqlCommand();

            try
            {
                //Consulta para extraer los datos de las personas
                qry = "Select * From VistaProductos";
                //Asignamos la consulta al comando
                sqlCMD.CommandText = qry;
                //Asignamos la conexion al comando
                sqlCMD.Connection = sqlCNX;
                //Abrimos la conexion
                sqlCNX.Open();
                //Variable para el adaptador
                SqlDataAdapter adaptador = new SqlDataAdapter(sqlCMD);
                //Variable para crear la tabla

                DataProductos datos = new DataProductos();
                //Llenamos la tabla
                adaptador.Fill(datos, "VistaProductos");

                foreach (DataRow row in datos.Tables[0].Rows)
                {
                    string pach = ".\\.\\";

                    var    webClient  = new WebClient();
                    byte[] imageBytes = webClient.DownloadData(pach + row["imagen"].ToString());

                    row["imapro"] = imageBytes;
                }



                //Cerramos la conexion
                sqlCNX.Close();
                //Creamos el objeto del reporte para las personas
                ReportePro reporte = new ReportePro();
                reporte.SetDataSource(datos.Tables["VistaUsuarios"]);
                //Pasamos la variable como parametro al vizualizador
                frmVisualizador formulario = new frmVisualizador(reporte);
                formulario.ShowDialog();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Error al imprimir!", "SI" + ex.Message.ToString());
            }
        }
Example #4
0
        public async Task <IActionResult> Create([Bind("Id,Foto,Nombre,Descripcion,Cantidad,Estado,Categoria")] DataProductos dataProductos)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dataProductos);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dataProductos));
        }
Example #5
0
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
 {
     app.UseStatusCodePages();
     app.UseStaticFiles();
     app.UseMvcWithDefaultRoute();
     app.UseDeveloperExceptionPage();
     DataUsuarios.AgregarData(app);
     DataClientes.AgregarDataClientes(app);
     DataProveedores.AgregarData(app);
     DataProductos.AgregarData(app);
 }
Example #6
0
        public async Task <IActionResult> Create([Bind("Id,Foto,Nombre,Descripcion,Cantidad,Estado,Categoria")] DataProductos datos)
        {
            foreach (var file in Request.Form.Files)
            {
                MemoryStream ms = new MemoryStream();
                file.CopyTo(ms);
                datos.Foto = ms.ToArray();
                ms.Close();
                ms.Dispose();

                _context.Add(datos);

                await _context.SaveChangesAsync();
            }
            return(RedirectToAction("Index", "Productos"));
        }
Example #7
0
 public async Task <IActionResult> Index(DataProductos dat)
 {
     ViewData["Id"] = dat.Id;
     return(View(await _context.Productos.ToListAsync()));
 }