<file_sep>﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SCI_PLT.Models;
using System.Diagnostics;

namespace SCI_PLT.Controllers
{
    public class MaterialAuxController : Controller
    {
        private bd_sci_pltEntities4 db = new bd_sci_pltEntities4();

        //
        // GET: /MaterialAux/

        public ActionResult Index()
        {
            return View(db.material_aux.ToList());
        }

        //
        // GET: /MaterialAux/Details/5

        public ActionResult Details(int id = 0)
        {
            material_aux material_aux = db.material_aux.Find(id);
            if (material_aux == null)
            {
                return HttpNotFound();
            }
            return View(material_aux);
        }

        //
        // GET: /MaterialAux/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /MaterialAux/Create

        [HttpPost]
        public ActionResult Create(material_aux material_aux)
        {
            
            if (ModelState.IsValid)
            {

                int c = db.material_aux.Count();
                material_aux.mat_aux_cod = c;
                db.material_aux.Add(material_aux);
                Debug.WriteLine("Entreeeeeeeeeeeeeeeeeeeeeeee");
                Debug.WriteLine(c);
                //Debug.WriteLine("Entreeeeeeeeeeeeeeeeeeeeeeee22222222222");
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(material_aux);
        }

        //
        // GET: /MaterialAux/Edit/5

        public ActionResult Edit(int id = 0)
        {
            material_aux material_aux = db.material_aux.Find(id);
            if (material_aux == null)
            {
                return HttpNotFound();
            }
            return View(material_aux);
        }

        //
        // POST: /MaterialAux/Edit/5

        [HttpPost]
        public ActionResult Edit(material_aux material_aux)
        {
            if (ModelState.IsValid)
            {
                db.Entry(material_aux).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(material_aux);
        }

        //
        // GET: /MaterialAux/Delete/5

        public ActionResult Delete(int id = 0)
        {
            material_aux material_aux = db.material_aux.Find(id);
            if (material_aux == null)
            {
                return HttpNotFound();
            }
            return View(material_aux);
        }

        //
        // POST: /MaterialAux/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {
            material_aux material_aux = db.material_aux.Find(id);
            db.material_aux.Remove(material_aux);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}<file_sep>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SCI_PLT.Models;

namespace SCI_PLT.Controllers
{
    public class MaterialController : Controller
    {
        

        bd_sci_pltEntities4 entidad = new bd_sci_pltEntities4();

        //
        // GET: /Material/

        public ActionResult Index()
        {   
            var listaMateriales = entidad.material;
            return View(listaMateriales.ToList());
        }

        //
        // GET: /Material/Create
        public ActionResult Create() {
            return View();
        }

        //
        // POST: /Material/Create
        [HttpPost]
        public ActionResult Create(material material)
        {
            if (ModelState.IsValid) {
                int c = entidad.material_aux.Count();
                material.mat_aux_cod = c;
                entidad.material.Add(material);
                entidad.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(material);
        }

         public ActionResult ListadoMaterial()
        {
            var listaMateriales = entidad.material;
            return View(listaMateriales.ToList());
        }

         public ActionResult BuscarMaterial(string descripcion)
         {
             var objeto = from i in entidad.material where i.mat_descripcion == descripcion select i;
             return View(objeto.ToList());
     
         }

         public ActionResult BuscarMaterialconMatAux()
         {
             var objeto = from i in entidad.material
                          join c in entidad.material_aux
                          on i.mat_cod equals c.mat_aux_cod

                          select new bdMaterial
                          {
                              id = i.mat_cod,
                              descripcion = i.mat_descripcion,
                              existencia = i.mat_existencia
                          };
             return View(objeto.ToList());

         }


    }
}
<file_sep><h1>SCI_PLT</h1>

- Descripción: SCI_PLT es un sistema de control de inventarios para una planta de producción. Elaborado con ASP .NET MVC 4 Web Application
