コード例 #1
0
        // GET: Cliente/Editar/5
        public ActionResult Detalles(int? id)
        {
            if (!LoginController.validaUsuario(Session))
                return RedirectToAction("Index", "Home");

            Cotizacion cotizacion = db.Cotizacion.Find(id);

            var ListaProductoCotizacionOrden = db.ProductoCotizacion.Where(s => s.IdCotizacion == id).ToList();
            var ListaMaterialCotizacionOrden = db.MaterialItemCotizacion.Where(s => s.IdCotizacion == id).ToList();
            if (ListaProductosOrden.Count() == 0)
            {
                foreach(var item in ListaProductoCotizacionOrden)
                {
                    ProductoCotizacion Produ = new ProductoCotizacion();
                    Produ.IdProducto = item.IdProducto;
                    Produ.IdCotizacion = item.IdCotizacion;
                    if (item.ColorVidrio != null)
                    {
                        Produ.ColorVidrio = item.ColorMat.Nombre;
                    }
                    Produ.ColorAluminio = item.ColorMat1.Nombre;
                    Produ.AnchoCelocia = item.AnchoCelocia;
                    Produ.Nombre = item.Producto.Nombre;
                    Produ.Alto = item.Alto;
                    Produ.Ancho = item.Ancho;
                    Produ.CantMat = item.CantProducto;
                    if (item.IdColorPaleta != null)
                    {
                        Produ.ColorPaleta = item.ColorMat2.Nombre;
                    }
                    Produ.Subtotal = item.Subtotal;
                    ListaProductosOrden.Add(Produ);
                }

                foreach (var item in ListaMaterialCotizacionOrden)
                {
                    ProductoCotizacion Produ = new ProductoCotizacion();
                    Produ.IdProducto = item.IdMaterial;
                    Produ.IdCotizacion = item.IdCotizacion;
                    Produ.Nombre = item.Material.Nombre;
                    if (item.Material.IdCatMat == 2)
                    {
                        Produ.ColorAluminio = item.ColorMat.Nombre;
                    }
                    if (item.Material.IdCatMat == 3)
                    {
                        Produ.ColorVidrio = item.ColorMat.Nombre;
                    }
                    Produ.CantMat = item.Cantidad;
                    Produ.Alto = (decimal)item.Alto;
                    Produ.Ancho = (decimal)item.Ancho;
                    Produ.Subtotal=item.Subtotal;
                    ListaProductosOrden.Add(Produ);
                }
            }
            TempData["ListaProductosOrden"] = ListaProductosOrden;
            Session["IdCotizacion"] = id;

            return View(cotizacion);
        }
コード例 #2
0
        public JsonResult AgregarMaterial(int Idpro, int IdColor, decimal Cant, decimal costo, decimal? Extra, decimal? Ancho, decimal? Alto)
        {
            var resultado = "Error al intentar agregar el material";
            if (TempData["ListaProductos"] != null)
            {
                ListaProductos = (List<ProductoCotizacion>)TempData["ListaProductos"];
                ListaMateriales = (List<MaterialCotizacion>)TempData["MateralCotizacion"];
            }
            try
            {
                if (Idpro == 1251)
                {
                    Material ListMat = db.Material.Find(Idpro);
                    ProductoCotizacion Produ = new ProductoCotizacion();
                    Produ.IdProducto = Idpro;
                    Produ.Tipo = "Mat";
                    Produ.Nombre = ListMat.Nombre;
                    Produ.CantMat = Cant;
                    Produ.IdColor = IdColor;
                    Produ.Subtotal = (decimal)Extra * Cant;
                    Produ.Subtotal = Math.Round((Decimal)Produ.Subtotal, 2);
                    ListaProductos.Add(Produ);
                }
                else
                {
                    decimal IV = 1 + db.Valor.Find(2).Porcentaje;
                    decimal Cargo = 1 + db.Valor.Find(5).Porcentaje;
                    Material ListMat = db.Material.Find(Idpro);
                    ProductoCotizacion Produ = new ProductoCotizacion();
                    Produ.IdProducto = Idpro;
                    Produ.Tipo = "Mat";
                    Produ.Nombre = ListMat.Nombre;
                    Produ.CantMat = Cant;
                    Produ.IdColor = IdColor;
                    if (Ancho != null)
                    {
                        Produ.Ancho = (decimal)Ancho;
                    }
                    if (Alto != null)
                    {
                        Produ.Alto = (decimal)Alto;
                    }

                    switch (ListMat.IdCatMat)
                    {
                        case 1:
                            {
                                Produ.Subtotal = ((costo * IV) * Cargo);
                                break;
                            }
                        case 2:
                            {
                                Produ.Subtotal = ((costo * IV) * Cargo);
                                break;
                            }
                        case 3:
                            {
                                if (ListMat.IdTipoMaterial == 55)
                                {
                                    Produ.Subtotal = (decimal)Ancho * ((costo * IV) * Cargo);
                                }
                                else if (ListMat.IdTipoMaterial == 53)
                                {
                                    Produ.Subtotal = ((decimal)Ancho * (decimal)Alto) * ((costo * IV) * Cargo);
                                }
                                else
                                {
                                    Produ.Subtotal = ((costo * IV) * Cargo);
                                }
                                break;
                            }
                    }

                    if (Extra != null)
                    {
                        Extra = (Extra / 100m) + 1;
                        Produ.Subtotal = (Produ.Subtotal * Cant) * (decimal)Extra;
                    }
                    else
                    {
                        Produ.Subtotal = Produ.Subtotal * Cant;
                    }
                    Produ.Subtotal = Math.Round((Decimal)Produ.Subtotal, 2);
                    ListaProductos.Add(Produ);
                }
            }
            catch (Exception e)
            {
                TempData["MateralCotizacion"] = ListaMateriales;
                TempData["ListaProductos"] = ListaProductos;
                return Json(resultado,
              JsonRequestBehavior.AllowGet);
            }
            TempData["MateralCotizacion"] = ListaMateriales;
            TempData["ListaProductos"] = ListaProductos;
            return Json(ListaProductos.ToList(),
                JsonRequestBehavior.AllowGet);
        }
コード例 #3
0
        // GET: Cotizacion/Edit/5
        public ActionResult Editar(int? id)
        {
            if (!LoginController.validaUsuario(Session))
                return RedirectToAction("Index", "Home");

            ViewBag.IdTipoProducto = new SelectList((from s in db.TipoProducto
                                                     where s.Estado == 1
                                                     select new
                                                     {
                                                         s.IdTipoProducto,
                                                         s.Nombre
                                                     }), "IdTipoProducto", "Nombre");
            ViewBag.Paletas = new SelectList((from s in db.Material
                                              where s.IdCatMat == 3 && s.IdTipoMaterial == 55 && s.Estado == 1
                                              select new
                                              {
                                                  s.IdMaterial,
                                                  s.Nombre
                                              }), "IdMaterial", "Nombre");
            ViewBag.ColoresVidrio = new SelectList((from s in db.ColorMat
                                                    where s.IdCatMaterial == 3 && s.Estado == 1
                                                    select new
                                                    {
                                                        IdColor = s.IdColor,
                                                        Nombre = s.Nombre
                                                    }), "IdColor", "Nombre");
            ViewData["ColoresPaleta"] = db.ColorMat.Where(s => s.IdCatMaterial == 3 && s.Estado == 1).ToList();
            ViewBag.ColoresAluminio = new SelectList((from s in db.ColorMat
                                                      where s.IdCatMaterial == 2 && s.Estado == 1
                                                      select new
                                                      {
                                                          IdColor = s.IdColor,
                                                          Nombre = s.Nombre
                                                      }), "IdColor", "Nombre");
            ViewBag.Instalacion = new SelectList((from s in db.Valor
                                                  where s.Tipo == "I" && s.Estado == 1
                                                  select new
                                                  {
                                                      IdValor = s.IdValor,
                                                      Nombre = s.Nombre
                                                  }), "IdValor", "Nombre");

            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }

            Cotizacion cotizacion = db.Cotizacion.Find(id);
            if (cotizacion == null)
            {
                return HttpNotFound();
            }

               var ListaProdu=(from s in db.ProductoCotizacion
                           where s.IdCotizacion==id
                            select s).ToList();
            var ListaProduMat = (from s in db.MaterialItemCotizacion
                              where s.IdCotizacion == id
                              select s).ToList();
            var listaMate= (from s in db.MaterialCotizacion
                            where s.IdCotizacion == id
                            select s).ToList();
            List<ProductoCotizacion> ListaP = new List<ProductoCotizacion>();
            foreach (var item in ListaProduMat)
            {
                ProductoCotizacion p = new ProductoCotizacion();
                p.IdConsecutivo = item.IdConsecutivo;
                p.IdProducto = item.IdMaterial;
                p.Nombre = item.Material.Nombre;
                p.CantMat = item.Cantidad;
                if (item.Ancho != null)
                {
                    p.Ancho = (decimal)item.Ancho;
                }
                if (item.Alto != null)
                {
                    p.Alto = (decimal)item.Alto;
                }
                p.Tipo = "Mat";
                p.IdColor = item.IdColor;
                p.Subtotal = item.Subtotal;

                ListaP.Add(p);
            }
            foreach (var item in ListaProdu)
            {
                ProductoCotizacion p = new ProductoCotizacion();
                p.IdConsecutivo = item.IdConsecutivo;
                p.IdProducto = item.IdProducto;
                p.Nombre = item.Producto.Nombre;
                p.CantMat = item.CantProducto;
                p.IdColorPaleta = item.IdColorPaleta;
                p.AnchoCelocia = item.AnchoCelocia;
                p.IdColorVidrio = item.IdColorVidrio;
                p.IdColorAluminio = item.IdColorAluminio;
                p.Instalacion = item.Instalacion;
                p.Ancho = item.Ancho;
                p.Alto = item.Alto;
                p.Tipo = "Prod";
                p.Subtotal = item.Subtotal;
                ListaP.Add(p);
            }
            List<MaterialCotizacion> ListaM = new List<MaterialCotizacion>();
            foreach (var item in listaMate)
            {
                MaterialCotizacion p = new MaterialCotizacion();
                p.IdProducto = item.IdProducto;
                p.IdMaterial = item.IdMaterial;
                p.CantMaterial = item.CantMaterial;
                p.Subtotal = item.Subtotal;
                ListaM.Add(p);
            }

            foreach (var itemProduct in ListaP)
            {
                ListaProductos.Add(itemProduct);
            }
            foreach (var itemMat in ListaM)
            {
                ListaMateriales.Add(itemMat);
            }

            TempData["MateralCotizacion"] = ListaMateriales;
            TempData["ListaProductos"] = ListaProductos;
            return View(cotizacion);
        }
コード例 #4
0
        public JsonResult AgregarProducto(int Idpro, int? Cvidrio,decimal? anchocelocia, int CAluminio, int Insta, int Cant, decimal Ancho, decimal Alto, int? vidrio, int? ColorPaleta, int? IdPaleta)
        {
            if(TempData["MateralCotizacion"]!= null)
            {
                ListaMateriales=(List<MaterialCotizacion>)TempData["MateralCotizacion"];
            }

            Calculos C = new Calculos();

            var resultado = "No se pudo agregar el Producto";
            var ValidarMat = C.ValidarMateriales(Idpro, Cvidrio, CAluminio, vidrio,ColorPaleta, IdPaleta);
            decimal instalacion = db.Valor.Find(Insta).Porcentaje;
            if (ValidarMat.Count()==0)
            {
                TempData["MateralCotizacion"] = C.calcularMonto(Idpro, Cvidrio, anchocelocia, CAluminio, instalacion, Cant, Ancho, Alto, vidrio, ColorPaleta, IdPaleta);
                ListaMateriales.AddRange((List<MaterialCotizacion>)TempData["MateralCotizacion"]);
            }
            else
            {
                return Json(ValidarMat,
                JsonRequestBehavior.AllowGet);
            }
            if (TempData["ListaProductos"] != null)
            {
                ListaProductos = (List<ProductoCotizacion>)TempData["ListaProductos"];

            }
            try
            {
                Producto ListPro = db.Producto.Find(Idpro);
                ProductoCotizacion Produ = new ProductoCotizacion();
                Produ.IdProducto = Idpro;
                Produ.Nombre = ListPro.Nombre;
                Produ.Tipo = "Prod";
                Produ.CantMat = Cant;
                Produ.IdColorPaleta =ColorPaleta;
                Produ.AnchoCelocia = anchocelocia;
                Produ.IdColorVidrio =Cvidrio;
                Produ.IdColorAluminio = CAluminio;
                Produ.Instalacion = instalacion;
                Produ.Ancho =Ancho;
                Produ.Alto = Alto;
                foreach (var item in ListaMateriales)
                {
                    if (Idpro == item.IdProducto)
                        Produ.Subtotal += (item.Subtotal* (1 + instalacion));
                }
                Produ.Subtotal = Produ.Subtotal * Cant;
                ListaProductos.Add(Produ);

            }
            catch
            {
                return Json(resultado,
              JsonRequestBehavior.AllowGet);
            }
            TempData["MateralCotizacion"] = ListaMateriales;
            TempData["ListaProductos"] = ListaProductos;
            return Json(ListaProductos.ToList(),
                JsonRequestBehavior.AllowGet);
        }
コード例 #5
0
        // GET: Factura/Create
        public ActionResult Facturar(int? id)
        {
            if (!LoginController.validaUsuario(Session))
                return RedirectToAction("Index", "Home");

            if (id != null)
            {
                Cotizacion cotizacion = db.Cotizacion.Find(id);
                if (cotizacion.Estado != "P") { cotizacion = null; }

                if (cotizacion == null)
                {
                    return HttpNotFound();
                }
                ViewData["Cliente"] = cotizacion.Cliente.Nombre;
                ViewData["IdCliente"] = cotizacion.Cliente.IdCliente;
                ViewData["IdCotizacion"] = cotizacion.IdCotizacion;
                var ListaProdu = (from s in db.ProductoCotizacion
                                  where s.IdCotizacion == id
                                  select s).ToList();
                var ListaPM = (from s in db.MaterialItemCotizacion
                               where s.IdCotizacion == id
                               select s).ToList();
                List<ProductoCotizacion> ListaP = new List<ProductoCotizacion>();
                foreach (var item in ListaProdu)
                {
                    ProductoCotizacion p = new ProductoCotizacion();
                    p.IdCotizacion = item.IdCotizacion;
                    p.IdProducto = item.IdProducto;
                    p.Nombre = item.Producto.Nombre;
                    p.CantMat = item.CantProducto;
                    p.IdColor = 21;
                    p.Subtotal = Math.Round((Decimal)item.Subtotal, 2);
                    ListaP.Add(p);
                }

                foreach (var item in ListaPM)
                {
                    ProductoCotizacion p = new ProductoCotizacion();
                    p.IdProducto = item.IdMaterial;
                    p.IdCotizacion = item.IdCotizacion;
                    p.Nombre = item.Material.Nombre;
                    p.CantMat = item.Cantidad;
                    p.IdColor = item.IdColor;
                    p.Subtotal = Math.Round((Decimal)item.Subtotal, 2);
                    ListaP.Add(p);
                }

                foreach (var itemProduct in ListaP)
                {
                    ListaProductos.Add(itemProduct);
                }
                TempData["ListaProductosFact"] = ListaProductos;
            }
            return View();
        }
コード例 #6
0
        public JsonResult AgregarProducto(int Idpro, int IdColor, decimal Cant, decimal costo, decimal?Extra, decimal?Ancho, decimal?Alto)
        {
            var resultado = "Error al intentar agregar el producto";

            if (TempData["ListaProductosFact"] != null)
            {
                ListaProductos = (List <ProductoCotizacion>)TempData["ListaProductosFact"];
            }
            try
            {
                if (Idpro == 1251)
                {
                    Material           ListMat = db.Material.Find(Idpro);
                    ProductoCotizacion Produ   = new ProductoCotizacion();
                    Produ.IdProducto = Idpro;
                    Produ.Nombre     = ListMat.Nombre;
                    Produ.CantMat    = Cant;
                    Produ.IdColor    = IdColor;
                    Produ.Subtotal   = (decimal)Extra * Cant;
                    Produ.Subtotal   = Math.Round((Decimal)Produ.Subtotal, 2);
                    ListaProductos.Add(Produ);
                }
                else
                {
                    decimal            IV      = 1 + db.Valor.Find(2).Porcentaje;
                    decimal            Cargo   = 1 + db.Valor.Find(5).Porcentaje;
                    Material           ListMat = db.Material.Find(Idpro);
                    ProductoCotizacion Produ   = new ProductoCotizacion();
                    Produ.IdProducto = Idpro;
                    Produ.Nombre     = ListMat.Nombre;
                    Produ.CantMat    = Cant;
                    Produ.IdColor    = IdColor;
                    if (Ancho != null)
                    {
                        Produ.Ancho = (decimal)Ancho;
                    }
                    if (Alto != null)
                    {
                        Produ.Alto = (decimal)Alto;
                    }
                    switch (ListMat.IdCatMat)
                    {
                    case 1:
                    {
                        Produ.Subtotal = ((costo * IV) * Cargo);
                        break;
                    }

                    case 2:
                    {
                        Produ.Subtotal = ((costo * IV) * Cargo);
                        break;
                    }

                    case 3:
                    {
                        if (ListMat.IdTipoMaterial == 55)
                        {
                            Produ.Subtotal = (decimal)Ancho * ((costo * IV) * Cargo);
                        }
                        else if (ListMat.IdTipoMaterial == 53)
                        {
                            Produ.Subtotal = ((decimal)Ancho * (decimal)Alto) * ((costo * IV) * Cargo);
                        }
                        else
                        {
                            Produ.Subtotal = ((costo * IV) * Cargo);
                        }
                        break;
                    }
                    }

                    if (Extra != null)
                    {
                        Extra          = (Extra / 100m) + 1;
                        Produ.Subtotal = (Produ.Subtotal * Cant) * (decimal)Extra;
                    }
                    else
                    {
                        Produ.Subtotal = Produ.Subtotal * Cant;
                    }
                    Produ.Subtotal = Math.Round((Decimal)Produ.Subtotal, 2);
                    ListaProductos.Add(Produ);
                }
            }
            catch (Exception e)
            {
                TempData["ListaProductosFact"] = ListaProductos;
                return(Json(resultado,
                            JsonRequestBehavior.AllowGet));
            }
            TempData["ListaProductosFact"] = ListaProductos;
            return(Json(ListaProductos.ToList(),
                        JsonRequestBehavior.AllowGet));
        }
コード例 #7
0
        // GET: Factura/Create
        public ActionResult Facturar(int?id)
        {
            if (!LoginController.validaUsuario(Session))
            {
                return(RedirectToAction("Index", "Home"));
            }

            if (id != null)
            {
                Cotizacion cotizacion = db.Cotizacion.Find(id);
                if (cotizacion.Estado != "P")
                {
                    cotizacion = null;
                }

                if (cotizacion == null)
                {
                    return(HttpNotFound());
                }
                ViewData["Cliente"]      = cotizacion.Cliente.Nombre;
                ViewData["IdCliente"]    = cotizacion.Cliente.IdCliente;
                ViewData["IdCotizacion"] = cotizacion.IdCotizacion;
                var ListaProdu = (from s in db.ProductoCotizacion
                                  where s.IdCotizacion == id
                                  select s).ToList();
                var ListaPM = (from s in db.MaterialItemCotizacion
                               where s.IdCotizacion == id
                               select s).ToList();
                List <ProductoCotizacion> ListaP = new List <ProductoCotizacion>();
                foreach (var item in ListaProdu)
                {
                    ProductoCotizacion p = new ProductoCotizacion();
                    p.IdCotizacion = item.IdCotizacion;
                    p.IdProducto   = item.IdProducto;
                    p.Nombre       = item.Producto.Nombre;
                    p.CantMat      = item.CantProducto;
                    p.IdColor      = 21;
                    p.Subtotal     = Math.Round((Decimal)item.Subtotal, 2);
                    ListaP.Add(p);
                }

                foreach (var item in ListaPM)
                {
                    ProductoCotizacion p = new ProductoCotizacion();
                    p.IdProducto   = item.IdMaterial;
                    p.IdCotizacion = item.IdCotizacion;
                    p.Nombre       = item.Material.Nombre;
                    p.CantMat      = item.Cantidad;
                    p.IdColor      = item.IdColor;
                    p.Subtotal     = Math.Round((Decimal)item.Subtotal, 2);
                    ListaP.Add(p);
                }

                foreach (var itemProduct in ListaP)
                {
                    ListaProductos.Add(itemProduct);
                }
                TempData["ListaProductosFact"] = ListaProductos;
            }
            return(View());
        }
コード例 #8
0
        // GET: Cliente/Editar/5
        public ActionResult Detalles(int?id)
        {
            if (!LoginController.validaUsuario(Session))
            {
                return(RedirectToAction("Index", "Home"));
            }

            Cotizacion cotizacion = db.Cotizacion.Find(id);

            var ListaProductoCotizacionOrden = db.ProductoCotizacion.Where(s => s.IdCotizacion == id).ToList();
            var ListaMaterialCotizacionOrden = db.MaterialItemCotizacion.Where(s => s.IdCotizacion == id).ToList();

            if (ListaProductosOrden.Count() == 0)
            {
                foreach (var item in ListaProductoCotizacionOrden)
                {
                    ProductoCotizacion Produ = new ProductoCotizacion();
                    Produ.IdProducto   = item.IdProducto;
                    Produ.IdCotizacion = item.IdCotizacion;
                    if (item.ColorVidrio != null)
                    {
                        Produ.ColorVidrio = item.ColorMat.Nombre;
                    }
                    Produ.ColorAluminio = item.ColorMat1.Nombre;
                    Produ.AnchoCelocia  = item.AnchoCelocia;
                    Produ.Nombre        = item.Producto.Nombre;
                    Produ.Alto          = item.Alto;
                    Produ.Ancho         = item.Ancho;
                    Produ.CantMat       = item.CantProducto;
                    if (item.IdColorPaleta != null)
                    {
                        Produ.ColorPaleta = item.ColorMat2.Nombre;
                    }
                    Produ.Subtotal = item.Subtotal;
                    ListaProductosOrden.Add(Produ);
                }

                foreach (var item in ListaMaterialCotizacionOrden)
                {
                    ProductoCotizacion Produ = new ProductoCotizacion();
                    Produ.IdProducto   = item.IdMaterial;
                    Produ.IdCotizacion = item.IdCotizacion;
                    Produ.Nombre       = item.Material.Nombre;
                    if (item.Material.IdCatMat == 2)
                    {
                        Produ.ColorAluminio = item.ColorMat.Nombre;
                    }
                    if (item.Material.IdCatMat == 3)
                    {
                        Produ.ColorVidrio = item.ColorMat.Nombre;
                    }
                    Produ.CantMat  = item.Cantidad;
                    Produ.Alto     = (decimal)item.Alto;
                    Produ.Ancho    = (decimal)item.Ancho;
                    Produ.Subtotal = item.Subtotal;
                    ListaProductosOrden.Add(Produ);
                }
            }
            TempData["ListaProductosOrden"] = ListaProductosOrden;
            Session["IdCotizacion"]         = id;

            return(View(cotizacion));
        }