Exemplo n.º 1
0
        public string AgregarProducto(ProductoCLS oProductoCLS, string titulo)
        {
            string resp = "0";

            using (BDGolososEntities bd = new BDGolososEntities())
            {
                if (titulo.Equals("1"))
                {
                    string nombreImagen = Path.GetFileNameWithoutExtension(oProductoCLS.archivo.FileName);
                    string extension    = Path.GetExtension(oProductoCLS.archivo.FileName);

                    nombreImagen       += DateTime.Now.ToString("dMMyyyy-ff") + extension;
                    oProductoCLS.imagen = "~/theme/productos/" + nombreImagen;

                    string rutaGuardar = Path.Combine(Server.MapPath("~/theme/productos/"), nombreImagen);

                    oProductoCLS.archivo.SaveAs(rutaGuardar);

                    Productos oProducto = new Productos();
                    oProducto.idCategoria = oProductoCLS.idCategoria;
                    oProducto.nombre      = oProductoCLS.nombre;
                    oProducto.imagen      = oProductoCLS.imagen;
                    oProducto.detalle     = oProductoCLS.detalle;
                    oProducto.stock       = oProductoCLS.stock;
                    oProducto.precio      = oProductoCLS.precio;

                    bd.Productos.Add(oProducto);
                    resp = bd.SaveChanges().ToString();
                }
            }

            return(resp);
        }
Exemplo n.º 2
0
        public string Registrar(EmployeesCLS oEmployeesCLS, string titulo)
        {
            string resp = "0";

            using (BDGolososEntities bd = new BDGolososEntities())
            {
                if (titulo.Equals("1"))
                {
                    Personas oPersona = new Personas();
                    oPersona.nombre   = oEmployeesCLS.nombre;
                    oPersona.apellido = oEmployeesCLS.apellido;
                    oPersona.dir      = oEmployeesCLS.dir;
                    oPersona.tel      = oEmployeesCLS.tel;
                    oPersona.correo   = oEmployeesCLS.correo;

                    bd.Personas.Add(oPersona);
                    bd.SaveChanges();

                    Empleados oEmpleado = new Empleados();

                    oEmpleado.dui = oEmployeesCLS.dui;

                    int idPersona = bd.Personas.Where(p => p.correo.Equals(oEmployeesCLS.correo)).First().idPersona;

                    oEmpleado.idPersona = idPersona;
                    oEmpleado.idCargo   = oEmployeesCLS.idCargo;
                    oEmpleado.sexo      = oEmployeesCLS.sexo;
                    oEmpleado.idEstado  = 1;

                    bd.Empleados.Add(oEmpleado);
                    bd.SaveChanges();

                    Usuarios oUsuarios = new Usuarios();

                    oUsuarios.idPersona = idPersona;
                    oUsuarios.usuario   = oEmployeesCLS.user;
                    oUsuarios.clave     = oEmployeesCLS.pass;

                    bd.Usuarios.Add(oUsuarios);
                    resp = bd.SaveChanges().ToString();
                }
            }

            return(resp);
        }
Exemplo n.º 3
0
        public string Registrar(ClienteCLS oClienteCLS, string titulo)
        {
            string resp = "0";

            using (BDGolososEntities bd = new BDGolososEntities())
            {
                if (titulo.Equals("1"))
                {
                    Personas oPersona = new Personas();
                    oPersona.nombre   = oClienteCLS.nombre;
                    oPersona.apellido = oClienteCLS.apellido;
                    oPersona.dir      = oClienteCLS.dir;
                    oPersona.tel      = oClienteCLS.tel;
                    oPersona.correo   = oClienteCLS.correo;

                    bd.Personas.Add(oPersona);
                    bd.SaveChanges();

                    Clientes oCliente = new Clientes();

                    int idPersona = bd.Personas.Where(p => p.correo.Equals(oClienteCLS.correo)).First().idPersona;
                    oCliente.idPersona = idPersona;

                    oCliente.registro = DateTime.Now;

                    bd.Clientes.Add(oCliente);
                    bd.SaveChanges();

                    Usuarios oUsuarios = new Usuarios();

                    oUsuarios.idPersona = idPersona;
                    oUsuarios.usuario   = oClienteCLS.user;
                    oUsuarios.clave     = oClienteCLS.pass;

                    bd.Usuarios.Add(oUsuarios);
                    resp = bd.SaveChanges().ToString();
                }
            }

            return(resp);
        }
Exemplo n.º 4
0
        public ActionResult FiltroVentas(string nombre, int idVenta)
        {
            List <VentaCLS> list = null;

            using (BDGolososEntities bd = new BDGolososEntities())
            {
                if (idVenta > 0)
                {
                    Ventas oVenta = bd.Ventas.Find(idVenta);
                    oVenta.estado = false;
                    bd.SaveChanges();
                }

                if (nombre == null)
                {
                    list = (from venta in bd.Ventas
                            join cliente in bd.Clientes
                            on venta.idCliente equals cliente.idCliente
                            join person in bd.Personas
                            on cliente.idPersona equals person.idPersona
                            where venta.estado == true
                            select new VentaCLS
                    {
                        id = (int)venta.idVenta,
                        nombre = person.nombre,
                        apellido = person.apellido,
                        tel = person.tel,
                        fecha = (DateTime)venta.fecha
                    }).ToList();
                }
                else
                {
                    list = (from venta in bd.Ventas
                            join cliente in bd.Clientes
                            on venta.idCliente equals cliente.idCliente
                            join person in bd.Personas
                            on cliente.idPersona equals person.idPersona
                            where venta.estado == true && (person.nombre.Contains(nombre) || person.apellido.Contains(nombre))
                            select new VentaCLS
                    {
                        id = (int)venta.idVenta,
                        nombre = person.nombre,
                        apellido = person.apellido,
                        tel = person.tel,
                        fecha = (DateTime)venta.fecha
                    }).ToList();
                }
            }

            return(PartialView("_TablaVentas", list));
        }
Exemplo n.º 5
0
        public ActionResult ProcesarCarrito(int idCarrito)
        {
            int        filas = 0;
            UsuarioCLS user  = (UsuarioCLS)Session["User"];

            if (idCarrito == 1)
            {
                using (BDGolososEntities bd = new BDGolososEntities())
                {
                    int idPersona = (from person in bd.Personas
                                     join usuario in bd.Usuarios
                                     on person.idPersona equals usuario.idPersona
                                     where usuario.usuario == user.user
                                     select person).First().idPersona;

                    int idCliente = (int)(bd.Clientes.Where(p => p.idPersona.Value.Equals(idPersona)).First().idCliente);

                    Ventas oVentas = new Ventas();
                    oVentas.idCliente = idCliente;
                    oVentas.fecha     = DateTime.Now;
                    oVentas.estado    = true;

                    bd.Ventas.Add(oVentas);
                    filas = bd.SaveChanges();


                    if (filas > 0)
                    {
                        string mail = (from person in bd.Personas
                                       join usuario in bd.Usuarios
                                       on person.idPersona equals usuario.idPersona
                                       where usuario.usuario == user.user
                                       select person).First().correo;

                        int nOrden = bd.Ventas.OrderByDescending(p => p.fecha).First().idVenta;

                        EnviarTicket(mail, (List <ProductoCLS>)Session["Carrito"], nOrden);
                    }
                }
            }

            List <ProductoCLS> listaVacia = new List <ProductoCLS>();

            Session.Remove("Carrito");

            return(PartialView("_TableCart", listaVacia));
        }