public FrmVerSorteos()
 {
     InitializeComponent();
     result = new DataTable();
     sorteo = new Sorteo();
     cargarCombo();
 }
Пример #2
0
 public bool InscripcionASorteoPostulante(string idPostulante, int idSorteo)
 {
     using (Context.AdjudicacionContext db = new Context.AdjudicacionContext())
     {
         try
         {
             if (db.Sorteos.Where(c => c.Ganador.Cedula == idPostulante).FirstOrDefault() != null)
             {
                 return(false);
             }
             else
             {
                 Sorteo     unS = db.Sorteos.Find(idSorteo);
                 Postulante unP = db.Postulantes.Find(idPostulante);
                 unS.PostulantesIns.Add(unP);
                 unP.SorteosIns.Add(unS);
                 db.SaveChanges();
                 return(true);
             }
         }
         catch (Exception ex)
         {
             Debug.WriteLine(ex.Message + "Otro error");
             return(false);
         }
     }
 }
Пример #3
0
        public void Actualizar(Sorteo sorteo)
        {
            try
            {
                // Ejecuta la sentencia sql en la conexion indicada
                SqlCommand command = new SqlCommand("SP_Sorteo_Update", servidor.Conectar());
                command.CommandType = CommandType.StoredProcedure;

                SqlParameter[] parameters = new SqlParameter[]
                {
                    new SqlParameter("id", sorteo.Id),
                    new SqlParameter("id_Grupo", sorteo.Id_Grupo)
                };
                command.Parameters.AddRange(parameters);
                command.ExecuteNonQuery();
            }
            catch
            {
                throw;
            }
            finally
            {
                servidor.Desconectar();
            }
        }
Пример #4
0
        // Si se agrega el sorteo devuelve el id de ese sorteo, si no te devuelvo -1
        public int addSorteo()
        {
            Sorteo sorteo = new Sorteo();

            sorteo.IdPremio  = this.IdPremio;
            sorteo.Clienteid = this.Clienteid;
            sorteo.IdVoucher = this.IdVoucher;
            using (db)
            {
                db.Sorteo.Add(sorteo);
                db.SaveChanges();
                var query = from dir in db.Sorteo
                            orderby dir.IdSorteo descending
                            where  dir.IdPremio == sorteo.IdPremio &&
                            dir.Clienteid == sorteo.Clienteid &&
                            dir.IdVoucher == sorteo.IdVoucher
                            select dir;
                sorteo = query.FirstOrDefault <Sorteo>();

                if (sorteo.IdPremio == this.IdPremio &&
                    sorteo.Clienteid == this.Clienteid &&
                    sorteo.IdVoucher == this.IdVoucher)
                {
                    return(sorteo.IdSorteo);
                }
                else
                {
                    return(-1);
                }
            }
        }
Пример #5
0
 public bool AddSorteo(Sorteo S)
 {
     if (S.Validar() && S != null)
     {
         using (Context.AdjudicacionContext db = new Context.AdjudicacionContext())
         {
             try
             {
                 db.Viviendas.Attach(S.Vivienda);
                 db.Sorteos.Add(S);
                 db.SaveChanges();
                 return(true);
             }
             catch (Exception ex)
             {
                 Debug.WriteLine(ex.Message + "Otro error");
                 return(false);
             }
         }
     }
     else
     {
         return(false);
     }
 }
Пример #6
0
        public EstadoAsistenciaDTO ConsultarInvitacionUsuario(string usuario)
        {
            using (var db = this.dbContext)
            {
                db.Configuration.LazyLoadingEnabled = false;

                Sorteo sorteoUsuario = db.Sorteo
                                       .Include("Participantes")
                                       .Where(s => s.Participantes.IdUsuario == usuario)
                                       .FirstOrDefault();
                if (sorteoUsuario == null)
                {
                    Asistencia asistencia = db.Asistencia.
                                            Where(aa => aa.Participantes.IdUsuario == usuario).FirstOrDefault();

                    Reglas regla = db.Reglas.FirstOrDefault();

                    EstadoAsistenciaDTO estadoAsistencia = new EstadoAsistenciaDTO(regla);
                    estadoAsistencia.confirmacion = asistencia != null ? asistencia.Afirmacion : null;

                    return(estadoAsistencia);
                }
                return(null);
            }
        }
Пример #7
0
        private bool validarFechas2()
        {
            DataTable dtSorteos = ControladorGeneral.RecuperarTodosSorteos();

            for (int i = 0; i < dtSorteos.Rows.Count; i++)
            {
                DateTime iFechaDesde = Convert.ToDateTime(dtSorteos.Rows[i]["fechaDesde"]);
                DateTime iFechaHasta = Convert.ToDateTime(dtSorteos.Rows[i]["fechaHasta"]);
                if (deFechaDesde.Date < iFechaDesde && deFechaHasta.Date > iFechaHasta)
                {
                    return(false);
                }
                if (Session["codigoOperacion"] == null)  //es una edicion
                {
                    if ((iFechaDesde <= deFechaDesde.Date && deFechaDesde.Date <= iFechaHasta) || (iFechaDesde <= deFechaHasta.Date && deFechaHasta.Date <= iFechaHasta))
                    {
                        //return false;
                        if (Session["codigoOperacion"] == null)
                        {
                            oSorteoActual = (Sorteo)Session["sorteoActual"];
                            if (oSorteoActual.Codigo == Convert.ToInt32(dtSorteos.Rows[i]["codigoSorteo"]))
                            {
                                return(true);
                            }
                        }
                    }
                }
                if ((iFechaDesde <= deFechaDesde.Date && deFechaDesde.Date <= iFechaHasta) || (iFechaDesde <= deFechaHasta.Date && deFechaHasta.Date <= iFechaHasta))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #8
0
        public static void InsertarParticipante(int codigoUsuario, int codigoSorteo, int codigoPremio)
        {
            ISession nhSesion = ManejoNHibernate.IniciarSesion();

            try
            {
                Sorteo sorteo = CatalogoSorteo.RecuperarPorCodigo(codigoSorteo, nhSesion);

                Participante participante = new Participante();
                participante.FechaParticipacion = DateTime.Now;
                participante.Premio             = CatalogoPremio.RecuperarPorCodigo(codigoPremio, nhSesion);
                participante.Usuario            = CatalogoUsuario.RecuperarPorCodigo(codigoUsuario, nhSesion);

                sorteo.Participantes.Add(participante);

                CatalogoSorteo.InsertarActualizar(sorteo, nhSesion);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                nhSesion.Close();
                nhSesion.Dispose();
            }
        }
        public ActionResult Index(string id)
        {
            Models.Boleto boleto = Models.TalonarioService.VerificarBoleto(id);
            if (boleto == null)
            {
                return(RedirectToAction("Invalido"));
            }

            ViewBag.CuentaBancaria = null;
            if (boleto.clave_sorteo.HasValue)
            {
                Sorteo sorteo = SorteoService.Obtener(boleto.clave_sorteo.Value);
                if (sorteo != null)
                {
                    ViewBag.CuentaBancaria = sorteo.cuenta_bancaria;
                }
            }

            ViewBag.ReferenciaBancaria = null;
            if (boleto.clave_colaborador.HasValue)
            {
                Colaborador colaborador = ColaboradorService.ObtienePorClave(boleto.clave_colaborador.Value);
                if (colaborador != null)
                {
                    ViewBag.ReferenciaBancaria = colaborador.referencia_bancaria;
                }
            }
            ViewBag.Boleto = boleto;
            ViewBag.QrCode = Convert.ToBase64String(Models.TalonarioService.GenerateQRCode(string.Format("{0}/boleto/{1}", ConfigurationManager.AppSettings["App.Url.Base"], boleto.token)).ToArray());
            return(View());
        }
Пример #10
0
        public static Sorteo ObtenerPorId(int id)
        {
            Servidor oservidor = new Servidor();

            try
            {
                SqlCommand command = new SqlCommand("SP_Sorteo_SelectRow", oservidor.Conectar());
                command.Parameters.AddWithValue("@Id", id);
                command.CommandType = System.Data.CommandType.StoredProcedure;
                // Ejecuta la sentencia sql en la conexion indicada
                SqlDataReader reader = command.ExecuteReader();
                // Cada Read lee un registro de la consulta
                while (reader.Read())
                {
                    Sorteo sorteo = new Sorteo();
                    sorteo.Id       = Convert.ToInt32(reader["id"].ToString());
                    sorteo.Id_Grupo = Convert.ToInt32(reader["id_Grupo"].ToString());



                    return(sorteo);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                oservidor.Desconectar();
            }

            return(null);
        }
Пример #11
0
        public static List <Sorteo> ObtenerTodos()
        {
            List <Sorteo> lista     = new List <Sorteo>();
            Servidor      oservidor = new Servidor();

            try
            {
                // Ejecuta la sentencia sql en la conexion indicada
                SqlCommand command = new SqlCommand("SP_Sorteo_SelectAll", oservidor.Conectar());
                command.CommandType = System.Data.CommandType.StoredProcedure;

                SqlDataReader reader = command.ExecuteReader();
                // Cada Read lee un registro de la consulta
                while (reader.Read())
                {
                    Sorteo sorteo = new Sorteo();
                    sorteo.Id       = Convert.ToInt32(reader["id"].ToString());
                    sorteo.Id_Grupo = Convert.ToInt32(reader["id_Grupo"].ToString());

                    lista.Add(sorteo);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                oservidor.Desconectar();
            }

            return(lista);
        }
Пример #12
0
        public ActionResult DeleteConfirmed(int id)
        {
            Sorteo sorteo = db.Sorteos.Find(id);

            db.Sorteos.Remove(sorteo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #13
0
 public FrmCrearSorteo()
 {
     InitializeComponent();
     serial = new Serial();
     sorteo = new Sorteo();
     log    = new Logica();
     Refrescar();
 }
Пример #14
0
 public FrmGanadores()
 {
     InitializeComponent();
     notificacion = new Notificacion();
     log          = new Logica();
     sorteo       = new Sorteo();
     cargarCombo();
     //cbSorteo = log.cargarCombo();
 }
 public FrmNumerosPremiados()
 {
     InitializeComponent();
     //result = new DataTable();
     sorPre = new SorteoPremiado();
     sorteo = new Sorteo();
     log    = new Logica();
     refrecar();
 }
Пример #16
0
 public Logica()
 {
     sorteo  = new Sorteo();
     sorPre  = new SorteoPremiado();
     lista   = new List <Modelo.Sorteo>();
     apuesta = new Modelo.Apuesta();
     persona = new Modelo.Persona();
     not     = new Notificacion();
 }
Пример #17
0
 public FrmJugar()
 {
     InitializeComponent();
     sorteo = new Sorteo();
     result = new DataTable();
     cargarCombo();
     apuesta = new Apuesta();
     casa    = new Casa();
 }
Пример #18
0
        public ActionResult InscripcionSorteo(long idSorteo, int edadMinima)
        {
            MvcModel mvc = new MvcModel();

            mvc.usuario = (Usuario)Session["usuario"];             //recibe el usuario que viene del Home a traves de la Session

            if (edadMinima <= conversor.calcularEdad(mvc.usuario.fechaNacimiento))
            {
                //se guardan los ids para hacer el insert
                Session["idUsuario"] = mvc.usuario.idUsuario;
                Session["idSorteo"]  = idSorteo;

                if (mvc.usuario.logueado)
                {
                    List <Sorteo> lstSorteos = (List <Sorteo>)Session["lstSorteos"];
                    if (lstSorteos.Count > 0 && lstSorteos != null)                     // se valida que la lista de sorteos no este vacia
                    {
                        Sorteo s = lstSorteos.Where(x => x.idSorteo == idSorteo).FirstOrDefault();
                        mvc.sorteo = s;

                        return(View(mvc));
                    }


                    if (mvc.usuario != null)
                    {
                        //se llenan las listas para rellenar los combos
                        AccesoDatos datos = new AccesoDatos();
                        mvc.lstPlataformas    = datos.getListaPlataformas();
                        mvc.lstProvincias     = datos.getListaProvincias();
                        mvc.lstEntradas       = datos.getListaEntradas();
                        mvc.lstSorteos        = datos.getListaSorteosActivos(0, EstadosEnum.En_Curso);                  // 0 porque no se requiere un filtro
                        Session["lstSorteos"] = mvc.lstSorteos;

                        return(View("SorteosActivos", mvc));
                    }
                }
            }
            else
            {
                //se llenan las listas para rellenar los combos
                AccesoDatos datos = new AccesoDatos();
                mvc.lstPlataformas            = datos.getListaPlataformas();
                mvc.lstProvincias             = datos.getListaProvincias();
                mvc.lstEntradas               = datos.getListaEntradas();
                mvc.lstSorteos                = datos.getListaSorteosActivos(0, EstadosEnum.En_Curso);  // 0 porque no se requiere un filtro
                Session["lstSorteos"]         = mvc.lstSorteos;
                TempData["error-inscribirse"] = "error";

                return(View("SorteosActivos", mvc));
            }



            return(RedirectToAction("Index", "Home"));
        }
Пример #19
0
 public FrmJugar(Modelo.Persona persona)
 {
     InitializeComponent();
     sorteo = new Sorteo();
     result = new DataTable();
     cargarCombo();
     this.persona = persona;
     apuesta      = new Apuesta();
     casa         = new Casa();
 }
        public FrmGanadores()
        {
            InitializeComponent();
            notificacion = new Notificacion();
            sorPre       = new SorteoPremiado();
            log          = new Logica();
            sorteo       = new Sorteo();

            cbSorteo.DataSource = log.cargarCombo();
        }
Пример #21
0
 private void CargarDatosParaEditar(Sorteo oSorteoActual)
 {
     codigoOperacion               = oSorteoActual.Codigo;
     txtDescripcionSorteo.Text     = oSorteoActual.Descripcion;
     txtCantidadOportunidades.Text = oSorteoActual.CantidadTirosPorUsuario.ToString();
     txtCantidadVictorias.Text     = oSorteoActual.CantidadPremiosPorUsuario.ToString();
     txtCantidadTotalPremios.Text  = oSorteoActual.CantidadPremiosTotales.ToString();
     deFechaDesde.Date             = oSorteoActual.FechaDesde;
     deFechaHasta.Date             = oSorteoActual.FechaHasta;
 }
Пример #22
0
 public ActionResult Edit([Bind(Include = "IdSorteo,Nombre,NumeroSorteo,HoraInicio,FechaInicio,HoraFinal,FechaIFinal,Estado")] Sorteo sorteo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sorteo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sorteo));
 }
Пример #23
0
 public FrmJugar()
 {
     InitializeComponent();
     sorteo = new Sorteo();
     result = new DataTable();
     log    = new Logica();
     cbSorteo.DataSource = log.cargarComboxSorteosNoPremiados();
     apuesta             = new Apuesta();
     casa = new Casa();
 }
 void IServicioProyectoFinal.RealizarSorteo(Sorteo sorteo)
 {
     try
     {
         FabricaLogica.GetLogicaSorteo().RealizarSorteo(sorteo);
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
 List <Jugada> IServicioProyectoFinal.ListarJugadasPremiadasPorSorteo(Sorteo sorteo)
 {
     try
     {
         return(FabricaLogica.GetLogicaJugada().ListarJugadasPremiadasPorSorteo(sorteo));
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Пример #26
0
 public FrmPrincipal(Boolean privilegios, Modelo.Persona person)
 {
     InitializeComponent();
     this.privilegios      = privilegios;
     configuracion.Visible = privilegios;
     this.person           = person;
     lblJugador.Text       = person.nombre + " " + person.apellido;
     log    = new Utils.Logica();
     sorteo = new Sorteo();
     sorteosVencidos();
 }
Пример #27
0
        public ActionResult Create([Bind(Include = "IdSorteo,Nombre,NumeroSorteo,HoraInicio,FechaInicio,HoraFinal,FechaIFinal,Estado")] Sorteo sorteo)
        {
            if (ModelState.IsValid)
            {
                db.Sorteos.Add(sorteo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sorteo));
        }
Пример #28
0
 public List <Jugada> ListarJugadasPremiadasPorSorteo(Sorteo sorteo)
 {
     try
     {
         return(FabricaPersistencia.GetPersistenciaJugada().ListarJugadasPremiadasPorSorteo(sorteo));
     }
     catch (Exception ex)
     {
         throw new Exception("Error al listar las jugadas: " + ex.Message);
     }
 }
Пример #29
0
 public ActionResult Edit([Bind(Include = "id,numeroDeSorteo,numero,fecha,loteriaId")] Sorteo sorteo)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sorteo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.loteriaId = new SelectList(db.loterias, "id", "nombre", sorteo.loteriaId);
     return(View(sorteo));
 }
Пример #30
0
 public Logica()
 {
     sorteo  = new Sorteo();
     sorPre  = new SorteoPremiado();
     lista   = new List <Modelo.Sorteo>();
     apuesta = new Modelo.Apuesta();
     persona = new Modelo.Persona();
     not     = new Notificacion();
     apues   = new Apuesta();
     casa    = new Casa();
     sor     = new Controladores.Sorteo();
 }