Exemplo n.º 1
0
        //
        // GET: /Venta/Create
        public ActionResult Create()
        {
            //int rol = Convert.ToInt16(Session["Rol_id"]);
            //bool Validacion = SEG.ValidarAcceso(rol, "Venta", "Create");
            //if (Validacion)
            //{
            Session["M_V"] = null;

            ViewBag.TipoFacturacion = db.tipo_facturacion.ToList();
            ViewBag.Producto        = db.producto.ToList();

            m_venta MV = new m_venta();

            MV.fecha_venta = DateTime.Today;
            MV.EMPLEADO_id = Convert.ToInt16(Session["Empleado_id"]);
            MV.total       = 0;

            db.m_venta.Add(MV);
            db.SaveChanges();

            int MASTER = Convert.ToInt16(db.m_venta.Max(x => x.id));

            Session["M_V"] = MASTER;

            return(View());
            //}
            //else
            //{
            //    return RedirectToAction("Error");
            //}
        }
        public ActionResult Create(M_Nota_Credito_Venta MNCV)
        {
            //Obteniendo el valor del Master
            int                Maestro = Convert.ToInt16(Session["M_V"]);
            m_venta            MV      = db.m_venta.Where(p => p.id == Maestro).Single();
            nota_credito_venta NCV     = new nota_credito_venta();

            NCV.CLIENTE_id      = MNCV.cliente;
            NCV.plazo           = Convert.ToDateTime(MNCV.plazo);
            NCV.fecha_extendido = MV.fecha_venta;
            NCV.M_VENTA_id      = MV.id;
            NCV.estado          = true;

            db.nota_credito_venta.Add(NCV);
            db.SaveChanges();

            Session["M_V"] = null;
            return(RedirectToAction("Index"));
        }
        //
        // GET: /NotaCreditoVenta/Create
        public ActionResult Create()
        {
            int  rol        = Convert.ToInt16(Session["Rol_id"]);
            bool Validacion = SEG.ValidarAcceso(rol, "NotaCreditoVenta", "Create");

            if (Validacion)
            {
                //Obteniendo el valor del Master Compra
                int Maestro = Convert.ToInt16(Session["M_V"]);
                ViewBag.Cliente_id = db.cliente.ToList();
                m_venta MV = db.m_venta.Where(p => p.id == Maestro).Single();
                M_Nota_Credito_Venta MNCV = new M_Nota_Credito_Venta();
                MNCV.MV = MV;
                return(View(MNCV));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Exemplo n.º 4
0
        public ActionResult Create(M_D_Venta MDV)
        {
            //Obteniendo el valor del Master
            int   Maestro         = Convert.ToInt16(Session["M_V"]);
            int   TipoFacturacion = MDV.TipoFacturacion;
            float totalMaster     = 0;
            int   caja            = Convert.ToInt16(Session["Caja_id"]);

            //recorriendo Arrays
            for (int i = 0; i < MDV.Cant.Count(); i++)
            {
                //Obtener Valores de la clase
                string cantidad    = MDV.Cant[i];
                string producto    = MDV.id[i];
                int    producto_id = int.Parse(producto);
                float  precio      = db.producto.Where(x => x.id == producto_id).Select(x => x.precio_venta_u).Single();
                float  total       = int.Parse(cantidad) * precio;
                if (cantidad != "")
                {
                    d_venta DV = new d_venta();
                    DV.PRODUCTO_id       = int.Parse(producto);
                    DV.cantidad_producto = int.Parse(cantidad);
                    DV.total             = total;
                    DV.M_VENTA_id        = Maestro;
                    DV.precio_u          = precio;

                    db.d_venta.Add(DV);
                    db.SaveChanges();

                    totalMaster = totalMaster + DV.total;
                }
            }

            m_venta MV = db.m_venta.Where(p => p.id == Maestro).Select(p => p).Single();

            MV.total = totalMaster;
            try
            {
                db.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
            if (TipoFacturacion == 1)           //Nota de Credito Venta
            {
                return(RedirectToAction("Create", "NotaCreditoVenta"));
            }
            else if (TipoFacturacion == 2)       //tiquete
            {
                facturacion F = new facturacion();
                F.TIPO_FACTURACION_id = TipoFacturacion;
                F.M_VENTA_id          = MV.id;
                db.facturacion.Add(F);
                db.SaveChanges();

                CIC.Ingreso(caja, totalMaster, Maestro);
                return(Redirect("Index"));
            }
            else if (TipoFacturacion == 3)       //Consumidor
            {
                CIC.Ingreso(caja, totalMaster, Maestro);
                return(RedirectToAction("ConsumidorFinal"));
            }
            else if (TipoFacturacion == 4)       //Credito fiscal
            {
                CIC.Ingreso(caja, totalMaster, Maestro);
                return(RedirectToAction("CreditoFiscal"));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }