Пример #1
0
        public Boolean InsertarResultadosSorteos(Sorteo sorteo)
        {
            Boolean          retorno    = true;
            List <Resultado> resultados = sorteo.PlanPremios.Resultados;
            SqlConnection    conexion   = new SqlConnection(cadenaConexion);
            SqlCommand       cmd        = new SqlCommand("InsertarResultado", conexion)
            {
                CommandType = CommandType.StoredProcedure
            };

            try
            {
                conexion.Open();
                foreach (Resultado resultado in resultados)
                {
                    cmd.Parameters.Add("@IdSorteo", SqlDbType.Int).Value      = sorteo.IdSorteo;
                    cmd.Parameters.Add("@MontoGanado", SqlDbType.Int).Value   = resultado.MontoGanado;
                    cmd.Parameters.Add("@NumeroGanador", SqlDbType.Int).Value = resultado.NumeroGanador;
                    cmd.Parameters.Add("@SerieGanadora", SqlDbType.Int).Value = resultado.SerieGanadora;
                    cmd.ExecuteNonQuery();

                    cmd.Parameters.Clear();
                }
            }
            catch (Exception)
            {
                retorno = false;
            }
            finally
            {
                conexion.Close();
            }
            return(retorno);
        }
Пример #2
0
        private void BtConsultar_Click(object sender, EventArgs e)
        {
            String tipo               = (rbLoteria.Checked) ? "Lotería" : "Chances";
            int    numeroSorteo       = (int)nudNumeroSorteo.Value;
            int    numeroFraccion     = (int)nudNumeroFraccion.Value;
            int    serieFraccion      = (int)nudSerieFraccion.Value;
            int    cantidadFracciones = (int)nudCantidadFracciones.Value;
            Sorteo sorteo             = sistemaLoteriaChances.ObtenerSorteoSeleccionado(tipo, numeroSorteo);

            lbFelicidades.Visible = false;
            lbMontoGanado.Text    = "0";
            lbPremiosGanados.Text = "0";
            if (sorteo != null)
            {
                List <Resultado> resultados = sorteo.PlanPremios.Resultados;
                if (sorteo.Estado)
                {
                    CalcularMontoGanado(resultados, numeroFraccion, serieFraccion,
                                        cantidadFracciones, sorteo.CantidadFracciones);
                }
                else
                {
                    MessageBox.Show("El sorteo no se ha jugado",
                                    "Consultar resultado", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("El número de sorteo ingresado no existe",
                                "Consultar resultado", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #3
0
        public Boolean EstablecerSorteoJugado(Sorteo sorteo)
        {
            Boolean       retorno  = true;
            SqlConnection conexion = new SqlConnection(cadenaConexion);
            SqlCommand    cmd      = new SqlCommand("EstablecerSorteoJugado", conexion)
            {
                CommandType = CommandType.StoredProcedure
            };

            try
            {
                conexion.Open();
                cmd.Parameters.Add("@Id", SqlDbType.Int).Value = sorteo.IdSorteo;
                cmd.ExecuteNonQuery();
            }
            catch (Exception)
            {
                retorno = false;
            }
            finally
            {
                conexion.Close();
            }
            return(retorno);
        }
Пример #4
0
        private void ManejarEventoEliminarSorteo(DataGridViewCellEventArgs e)
        {
            String       tipoSorteo   = dtSorteos.DefaultView[e.RowIndex]["Tipo"].ToString();
            int          numeroSorteo = Convert.ToInt32(dtSorteos.DefaultView[e.RowIndex]["Número"].ToString());
            DialogResult dr           = MessageBox.Show($"¿Desea eliminar el sorteo {numeroSorteo} de {tipoSorteo}?",
                                                        "Eliminar sorteo", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            if (dr == DialogResult.Yes)
            {
                Sorteo sorteo = sistemaLoteriaChances.ObtenerSorteoSeleccionado(tipoSorteo, numeroSorteo);
                if (!sorteo.Estado)
                {
                    if (enEdicion && sorteoEditando.IdSorteo.Equals(sorteo.IdSorteo))
                    {
                        DialogResult drEliminar = MessageBox.Show("Es el mismo sorteo que está editando, ¿desea eliminarlo?", "Eliminar sorteo", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                        if (drEliminar == DialogResult.Yes)
                        {
                            EliminarSorteo(sorteo);
                        }
                    }
                    else
                    {
                        EliminarSorteo(sorteo);
                    }
                }
                else
                {
                    MessageBox.Show("El sorteo no se puede eliminar, ya se jugó",
                                    "Eliminar sorteo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
        }
Пример #5
0
 public FormReporteResultados(SistemaLoteriaChances sistemaLoteriaChances, Sorteo sorteo)
 {
     InitializeComponent();
     this.sorteo = sorteo;
     this.sistemaLoteriaChances = sistemaLoteriaChances;
     lbTitulo.Text = $"Resultados del sorteo {sorteo.NumeroSorteo} de {sorteo.TipoSorteo}";
     EstablecerValoresTablaResultadosSorteo();
     CargarResultados();
 }
Пример #6
0
        /*
         * E: El nombre y la contrasenia del usuario/admin
         * S: El objeto usuario con los datos correspondientes.
         * R: Debe recibir solo dos parámetros
         */
        public Boolean InsertarSorteo(Sorteo nuevoSorteo)
        {
            Boolean       retorno  = true;
            SqlConnection conexion = new SqlConnection(cadenaConexion);
            List <Premio> premios;

            try
            {
                premios = nuevoSorteo.PlanPremios.Premios;
                conexion.Open();
                SqlCommand cmd = new SqlCommand("InsertarSorteo", conexion);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Numero", SqlDbType.Int).Value             = nuevoSorteo.NumeroSorteo;
                cmd.Parameters.Add("@Tipo", SqlDbType.NVarChar).Value          = nuevoSorteo.TipoSorteo;
                cmd.Parameters.Add("@Fecha", SqlDbType.DateTime).Value         = nuevoSorteo.Fecha;
                cmd.Parameters.Add("@CantidadFracciones", SqlDbType.Int).Value = nuevoSorteo.CantidadFracciones;
                cmd.Parameters.Add("@PrecioFraccion", SqlDbType.Int).Value     = nuevoSorteo.PrecioFraccion;
                cmd.Parameters.Add("@Leyenda", SqlDbType.NVarChar).Value       = nuevoSorteo.LeyendaBillete;
                cmd.Parameters.Add("@Estado", SqlDbType.Bit).Value             = nuevoSorteo.Estado;
                cmd.ExecuteNonQuery();
                if (premios != null)
                {
                    cmd             = new SqlCommand("SELECT MAX(Id) FROM ObtenerSorteos", conexion);
                    cmd.CommandType = CommandType.Text;
                    SqlDataReader lectorDatos = cmd.ExecuteReader();
                    int           idSorteo    = 0;
                    while (lectorDatos.Read())
                    {
                        idSorteo = (int)lectorDatos[0];
                    }
                    conexion.Close();
                    conexion.Open();
                    cmd             = new SqlCommand("InsertarPlanDePremios", conexion);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    foreach (Premio premio in premios)
                    {
                        cmd.Parameters.Add("@IdSorteo", SqlDbType.Int).Value = idSorteo;
                        cmd.Parameters.Add("@Monto", SqlDbType.Int).Value    = premio.MontoPremio;
                        cmd.Parameters.Add("@Cantidad", SqlDbType.Int).Value = premio.CantidadPremio;
                        cmd.ExecuteNonQuery();
                        cmd.Parameters.Clear();
                    }
                }
            }
            catch (Exception)
            {
                retorno = false;
            }
            finally
            {
                conexion.Close();
            }
            return(retorno);
        }
Пример #7
0
 public FormMantenimientoSorteos(SistemaLoteriaChances sistemaLoteriaChances)
 {
     InitializeComponent();
     this.sistemaLoteriaChances = sistemaLoteriaChances;
     this.filtroTipoSorteos     = "";
     this.enEdicion             = false;
     this.sorteoEditando        = new Sorteo();
     ConfigurarTablaPremiosAdicionales();
     ConfigurarComponentesPanelSorteos();
     EstablecerValoresTablaSorteos();
 }
Пример #8
0
        public Boolean ModificarSorteo(Sorteo sorteo)
        {
            Boolean       retorno  = true;
            SqlConnection conexion = new SqlConnection(cadenaConexion);
            List <Premio> premios;

            premios = sorteo.PlanPremios.Premios;
            try
            {
                conexion.Open();
                SqlCommand cmd = new SqlCommand("ActualizarSorteo", conexion);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@Tipo", SqlDbType.NVarChar).Value          = sorteo.TipoSorteo;
                cmd.Parameters.Add("@Fecha", SqlDbType.DateTime).Value         = sorteo.Fecha;
                cmd.Parameters.Add("@Numero", SqlDbType.Int).Value             = sorteo.NumeroSorteo;
                cmd.Parameters.Add("@CantidadFracciones", SqlDbType.Int).Value = sorteo.CantidadFracciones;
                cmd.Parameters.Add("@PrecioFraccion", SqlDbType.Int).Value     = sorteo.PrecioFraccion;
                cmd.Parameters.Add("@Leyenda", SqlDbType.NVarChar).Value       = sorteo.LeyendaBillete;
                cmd.Parameters.Add("@Id", SqlDbType.Int).Value = sorteo.IdSorteo;
                cmd.ExecuteNonQuery();
                conexion.Close();
                conexion.Open();
                cmd             = new SqlCommand("EliminarPlanDePremios", conexion);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@IdSorteo", SqlDbType.Int).Value = sorteo.IdSorteo;
                cmd.ExecuteNonQuery();
                if (premios != null)
                {
                    conexion.Close();
                    conexion.Open();
                    cmd             = new SqlCommand("InsertarPlanDePremios", conexion);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Clear();
                    foreach (Premio premio in premios)
                    {
                        cmd.Parameters.Add("@IdSorteo", SqlDbType.Int).Value = sorteo.IdSorteo;
                        cmd.Parameters.Add("@Monto", SqlDbType.Int).Value    = premio.MontoPremio;
                        cmd.Parameters.Add("@Cantidad", SqlDbType.Int).Value = premio.CantidadPremio;
                        cmd.ExecuteNonQuery();
                        cmd.Parameters.Clear();
                    }
                }
            }
            catch (Exception)
            {
                retorno = false;
            }
            finally
            {
                conexion.Close();
            }
            return(retorno);
        }
Пример #9
0
 private void CrearSorteo(Sorteo sorteo)
 {
     if (sistemaLoteriaChances.CrearSorteo(sorteo))
     {
         MessageBox.Show("¡¡¡Se insertó con éxito!!!", "Crear sorteo",
                         MessageBoxButtons.OK, MessageBoxIcon.Information);
         CargarSorteos();
     }
     else
     {
         MessageBox.Show("Error al guardar el sorteo", "Crear sorteo",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #10
0
        private void ManejarReportePlanPremios(DataGridViewCellEventArgs e)
        {
            String tipoSorteo   = dtSorteos.DefaultView[e.RowIndex]["Tipo"].ToString();
            int    numeroSorteo = Convert.ToInt32(dtSorteos.DefaultView[e.RowIndex]["Número"].ToString());
            Sorteo sorteo       = sistemaLoteriaChances.ObtenerSorteoSeleccionado(tipoSorteo, numeroSorteo);

            if (sorteo.PlanPremios.Premios.Count > 0)
            {
                FormReportePlanPremios reportePlanPremios = new FormReportePlanPremios(sistemaLoteriaChances, sorteo);
                reportePlanPremios.ShowDialog();
            }
            else
            {
                MessageBox.Show("El sorteo no tiene plan de premios. No hay premios para mostrar",
                                "Reporte plan de premios", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Пример #11
0
        private void InicializarSorteoParaCrear(int numeroSorteo, string tipoSorteo, DateTime fecha, PlanPremios planPremios)
        {
            Sorteo sorteo = new Sorteo()
            {
                IdSorteo           = 1,
                NumeroSorteo       = numeroSorteo,
                TipoSorteo         = tipoSorteo,
                Fecha              = fecha,
                CantidadFracciones = Convert.ToInt32(nudFracciones.Value),
                PrecioFraccion     = Convert.ToInt32(nudCostoFraccion.Value),
                LeyendaBillete     = tbLeyenda.Text.Equals("") ? "Sin leyenda" : tbLeyenda.Text,
                Estado             = false,
                PlanPremios        = planPremios
            };

            CrearSorteo(sorteo);
        }
Пример #12
0
        private void CargarDatosEdicion(Sorteo sorteo)
        {
            String        tipoSorteo = sorteo.TipoSorteo;
            List <Premio> premios    = sorteo.PlanPremios.Premios;

            rbChances.Enabled = false;
            rbLoteria.Enabled = false;
            dtFecha.Enabled   = false;
            dtFecha.Value     = sorteo.Fecha;

            if (tipoSorteo.Equals("Lotería"))
            {
                rbLoteria.Checked = true;
            }
            else
            {
                rbChances.Checked = true; btAgregarPremioAdicional.Visible = false;
            }
            nudCostoFraccion.Value = sorteo.PrecioFraccion;
            nudFracciones.Value    = sorteo.CantidadFracciones;
            tbLeyenda.Text         = sorteo.LeyendaBillete;
            int largoPremios = premios.Count;

            PlanPremiosEstado(cbConPlan.Checked);
            //Por si es null,no va a tener plan de premios
            nudPremio1.Value = 1;
            nudPremio2.Value = 1;
            nudPremio3.Value = 1;
            if (largoPremios != 0)
            {
                nudPremio1.Value = premios[0].MontoPremio;
                nudPremio2.Value = premios[1].MontoPremio;
                nudPremio3.Value = premios[2].MontoPremio;
                //obtengo el resto de los premios adicionales y limpio los dt y datagridview
                cbConPlan.Checked = true;
                dtPremiosAdicionales.Clear();

                for (int i = 3; i < largoPremios; i++)
                {
                    int montoPremio    = premios[i].MontoPremio;
                    int cantidadPremio = premios[i].CantidadPremio;
                    dtPremiosAdicionales.Rows.Add(new object[] { montoPremio, cantidadPremio });
                }
            }
        }
Пример #13
0
        private void GuardarSorteo(PlanPremios planPremios)
        {
            Sorteo sorteo = new Sorteo()
            {
                IdSorteo           = sorteoEditando.IdSorteo,
                NumeroSorteo       = sorteoEditando.NumeroSorteo,
                TipoSorteo         = sorteoEditando.TipoSorteo,
                Fecha              = sorteoEditando.Fecha,
                CantidadFracciones = Convert.ToInt32(nudFracciones.Value),
                PrecioFraccion     = Convert.ToInt32(nudCostoFraccion.Value),
                LeyendaBillete     = tbLeyenda.Text.Equals("") ? "Sin leyenda" : tbLeyenda.Text,
                Estado             = false,
                PlanPremios        = planPremios
            };

            sorteoEditando = sorteo;
            ModificarSorteo(sorteoEditando);
        }
Пример #14
0
 private void ManejarEventoEditarSorteo(object sender, DataGridViewCellEventArgs e)
 {
     if (!enEdicion)
     {
         String tipoSorteo   = dtSorteos.DefaultView[e.RowIndex]["Tipo"].ToString();
         int    numeroSorteo = Convert.ToInt32(dtSorteos.DefaultView[e.RowIndex]["Número"].ToString());
         Sorteo sorteo       = sistemaLoteriaChances.ObtenerSorteoSeleccionado(tipoSorteo, numeroSorteo);
         if (!sorteo.Estado)
         {
             enEdicion      = true;
             sorteoEditando = sorteo;
             EstablecerInterfazEditando();
             if (!panelCrearSorteo.Visible)
             {
                 AjustarPanelSorteo();
             }
             panelCrearSorteo.Visible = true;
             CargarDatosEdicion(sorteo);
         }
         else
         {
             MessageBox.Show("El sorteo no se puede editar, ya se jugó",
                             "Editar sorteo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
     else
     {
         DialogResult dr = MessageBox.Show("¿Desea guardar el sorteo que está editando?", "Editar sorteo", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         if (dr == DialogResult.Yes)
         {
             BtGuardar_Click(sender, e);
             enEdicion = false;
             DataGridViewSorteos_CellClick(sender, e);
         }
         else if (dr == DialogResult.No)
         {
             enEdicion = false;
             DataGridViewSorteos_CellClick(sender, e);
         }
         //Está editando uno, aqui pregunto si desea guardarlo antes de editar otro
     }
 }
Пример #15
0
 private void ModificarSorteo(Sorteo sorteo)
 {
     if (sistemaLoteriaChances.ModificarSorteo(sorteo))
     {
         MessageBox.Show("¡¡¡Se Modificó con éxito!!!", "Modificar sorteo",
                         MessageBoxButtons.OK, MessageBoxIcon.Information);
         SalirInterfazEditando();
         dtPremiosAdicionales.Clear();
         rbChances.Enabled = true;
         rbLoteria.Enabled = true;
         dtFecha.Enabled   = true;
         enEdicion         = false;
         CargarSorteos();
         AjustarPanelSorteo();
         panelCrearSorteo.Visible = !panelCrearSorteo.Visible;
     }
     else
     {
         MessageBox.Show("Error al modificar el sorteo", "Modificar sorteo",
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #16
0
        private void DgvSorteos_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0 && e.RowIndex >= 0)
            {
                String tipoSorteo   = dtSorteos.DefaultView[e.RowIndex]["Tipo"].ToString();
                int    numeroSorteo = Convert.ToInt32(dtSorteos.DefaultView[e.RowIndex]["Número"].ToString());

                DialogResult dr = MessageBox.Show($"¿Desea jugar el sorteo {numeroSorteo} de {tipoSorteo}?",
                                                  "Jugar sorteo", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                if (dr == DialogResult.Yes)
                {
                    sorteoSeleccionado = sistemaLoteriaChances.ObtenerSorteoSeleccionado(tipoSorteo, numeroSorteo);
                    CambiarEstadoGifs(true);
                    hiloJugar = new Thread(new ThreadStart(JugarSorteo))
                    {
                        IsBackground = false
                    };
                    hiloJugar.Start();
                }
            }
        }
Пример #17
0
        private Resultado[] ObtenerPremiosMayores(Sorteo sorteo)
        {
            Resultado[]      premiosMayores = new Resultado[3];
            List <Resultado> resultados     = sorteo.PlanPremios.Resultados;

            foreach (Resultado resultado in resultados)
            {
                if (sorteo.PlanPremios.Premios[0].MontoPremio == resultado.MontoGanado)
                {
                    premiosMayores[0] = resultado;
                }
                if (sorteo.PlanPremios.Premios[1].MontoPremio == resultado.MontoGanado)
                {
                    premiosMayores[1] = resultado;
                }
                if (sorteo.PlanPremios.Premios[2].MontoPremio == resultado.MontoGanado)
                {
                    premiosMayores[2] = resultado;
                }
            }

            return(premiosMayores);
        }
Пример #18
0
 private void EliminarSorteo(Sorteo sorteo)
 {
     if (sistemaLoteriaChances.EliminarSorteo(sorteo))
     {
         if (enEdicion && sorteo.IdSorteo.Equals(sorteoEditando.IdSorteo))
         {
             rbChances.Enabled = true;
             rbLoteria.Enabled = true;
             dtFecha.Enabled   = true;
             enEdicion         = false;
             SalirInterfazEditando();
             AjustarPanelSorteo();
             panelCrearSorteo.Visible = !panelCrearSorteo.Visible;
         }
         CargarSorteos();
         MessageBox.Show("El sorteo se eliminó con éxito",
                         "Eliminar sorteo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("El sorteo no se pudo eliminar",
                         "Eliminar sorteo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #19
0
        private Boolean GenerarReporteCorrespondiente(Sorteo sorteo, String tituloDocumento,
                                                      String tituloTabla, Boolean reporteResultado)
        {
            Boolean  retorno  = true;
            Document document = null;

            try
            {
                // Se establecen las varibales y textos por utilizar en el PDF
                System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter();
                List <Resultado> resultados             = sorteo.PlanPremios.Resultados;
                List <Premio>    premios     = sorteo.PlanPremios.Premios;
                String           datosSorteo =
                    $"Tipo: {sorteo.TipoSorteo}\n" +
                    $"Número: {sorteo.NumeroSorteo}\n" +
                    $"Realizado: {sorteo.Fecha.ToShortDateString()}";
                String finalDocumento = $"\n--- Final del documento - " +
                                        $"Junta de Protección Social - Reporte generado el {DateTime.Now.ToString()} ---";

                // Se genera la ruta del archivo pdf: Escritorio + "Resultados - " + tipo + numero + ".pdf"
                String rutaCreacionPDF = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) +
                                         $"\\{tituloTabla} - " + sorteo.TipoSorteo + sorteo.NumeroSorteo + ".pdf";

                // Se inicializan las variables para manipular el pdf.
                PdfWriter   writer = new PdfWriter(rutaCreacionPDF);
                PdfDocument pdf    = new PdfDocument(writer);
                document = new Document(pdf);

                PdfFont font = PdfFontFactory.CreateFont(StandardFonts.HELVETICA_BOLD);// Fuente en negrita(bold)
                // Se crea el logo del documento.
                Image logo = new Image(ImageDataFactory.Create(
                                           (byte[])converter.ConvertTo(Properties.Resources.LogoHorizontalJPS, typeof(byte[]))));
                logo.SetWidth(170);
                logo.SetHeight(80);
                logo.SetFixedPosition(400, 730);// Se establece la posición fija dentro de la página.

                // Se crea la tabla correspondiente con el reporte de sorteo.
                Table table;
                if (reporteResultado)
                {
                    table = GenerarTablaResultados(premios, resultados, font);
                }
                else
                {
                    table = GenerarTablaPlanPremios(premios, font);
                }

                // Se agregan todos los componentes del archivo pdf
                document.Add(logo);
                document.Add(new Paragraph(tituloDocumento).SetFont(font).SetFontSize(14));
                document.Add(new Paragraph(datosSorteo));
                document.Add(new Paragraph(tituloTabla + ":").SetFont(font));
                document.Add(table);
                document.Add(new Paragraph(finalDocumento).SetFontSize(10).SetTextAlignment(TextAlignment.CENTER));
            }
            catch (Exception)
            {
                retorno = false;
            }
            finally
            {
                // Se cierra el archivo
                if (document != null)
                {
                    document.Close();
                }
            }
            return(retorno);
        }
Пример #20
0
 public Boolean GenerarReportePlanPremiosSorteo(Sorteo sorteo)
 {
     return(GenerarReporteCorrespondiente(sorteo, "Reporte de plan de premios de sorteo", "Plan de premios", false));
 }
Пример #21
0
 public Boolean CrearSorteo(Sorteo nuevoSorteo)
 {
     return(conexionBD.InsertarSorteo(nuevoSorteo));
 }
Пример #22
0
 public Boolean EliminarSorteo(Sorteo sorteo)
 {
     return(conexionBD.EliminarSorteo(sorteo));
 }
Пример #23
0
 public Boolean ModificarSorteo(Sorteo sorteo)
 {
     return(conexionBD.ModificarSorteo(sorteo));
 }
Пример #24
0
 public Boolean JugarSorteo(Sorteo sorteo)
 {
     return(conexionBD.InsertarResultadosSorteos(sorteo) &&
            conexionBD.EstablecerSorteoJugado(sorteo));
 }
Пример #25
0
        public List <Sorteo> ObtenerSorteos()
        {
            List <Sorteo>    sorteos = new List <Sorteo>();
            List <Premio>    premiosDelPlan;
            List <Resultado> resultadosSorteo;
            SqlConnection    conexion  = new SqlConnection(cadenaConexion);
            SqlConnection    conexion2 = new SqlConnection(cadenaConexion);
            SqlConnection    conexion3 = new SqlConnection(cadenaConexion);
            SqlCommand       cmd       = new SqlCommand("SELECT * FROM ObtenerSorteos", conexion)
            {
                CommandType = CommandType.Text
            };

            try
            {
                conexion.Open();
                conexion2.Open();
                conexion3.Open();
                SqlDataReader lectorDatos = cmd.ExecuteReader();
                Sorteo        sorteo;
                SqlCommand    cmdPremios, cmdResultados;
                SqlDataReader lectorPremios = null, lectorResultados = null;
                while (lectorDatos.Read())
                {
                    // Preparo las variables para obtener los premios del sorteo
                    premiosDelPlan = new List <Premio>();
                    cmdPremios     = new SqlCommand("ObtenerPlanDePremios", conexion2)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    // Agrego el id del sorteo como parámetro para el procedimiento
                    cmdPremios.Parameters.Clear();
                    cmdPremios.Parameters.Add("@IdSorteo", SqlDbType.Int).Value = (int)lectorDatos[0];// IdSorteo
                    // Ejecuto y obtengo los premios
                    lectorPremios = cmdPremios.ExecuteReader();
                    while (lectorPremios.Read())
                    {
                        premiosDelPlan.Add(new Premio((int)lectorPremios[2], (int)lectorPremios[3]));
                    }
                    lectorPremios.Close();

                    // Preparo las variables para obtener los resultados del sorteo
                    resultadosSorteo = new List <Resultado>();
                    cmdResultados    = new SqlCommand("ObtenerResultados", conexion3)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    // Agrego el id del sorteo como parámetro para el procedimiento
                    cmdResultados.Parameters.Clear();
                    cmdResultados.Parameters.Add("@IdSorteo", SqlDbType.Int).Value = (int)lectorDatos[0];// IdSorteo
                    // Ejecuto y obtengo los resultados
                    lectorResultados = cmdResultados.ExecuteReader();
                    while (lectorResultados.Read())
                    {
                        resultadosSorteo.Add(new Resultado((int)lectorResultados[1],
                                                           (int)lectorResultados[2], (int)lectorResultados[0]));
                    }
                    lectorResultados.Close();

                    sorteo = new Sorteo()
                    {
                        IdSorteo           = (int)lectorDatos[0],
                        NumeroSorteo       = (int)lectorDatos[1],
                        TipoSorteo         = (String)lectorDatos[2],
                        Fecha              = (DateTime)lectorDatos[3],
                        CantidadFracciones = (int)lectorDatos[4],
                        PrecioFraccion     = (int)lectorDatos[5],
                        LeyendaBillete     = (String)lectorDatos[6],
                        Estado             = (Boolean)lectorDatos[7],
                        PlanPremios        = new PlanPremios()
                        {
                            IdSorteo   = (int)lectorDatos[0],
                            Premios    = premiosDelPlan,
                            Resultados = resultadosSorteo
                        }
                    };
                    sorteos.Add(sorteo);
                }
            }
            catch (Exception)
            {
                // Representa error de conexión
                sorteos = null;
            }
            finally
            {
                conexion.Close();
                conexion2.Close();
                conexion3.Close();
            }
            return(sorteos);
        }
Пример #26
0
        private void CargarUltimosSorteos(SistemaLoteriaChances sistemaLoteriaChances)
        {
            Sorteo sorteoLoteria = sistemaLoteriaChances.ObtenerUltimoSorteoTipo("Lotería");
            Sorteo sorteoChances = sistemaLoteriaChances.ObtenerUltimoSorteoTipo("Chances");

            if (sorteoLoteria != null)
            {
                Resultado[] resultados = ObtenerPremiosMayores(sorteoLoteria);
                lbNumeroLoteria.Text = $"Sorteo {sorteoLoteria.NumeroSorteo} - " +
                                       $"{sorteoLoteria.Fecha.ToShortDateString()}";
                // Se establecen los valores del primer premio.
                lbLP1Num.Text   = $"{resultados[0].NumeroGanador}";
                lbLP1Serie.Text = $"Serie:{resultados[0].SerieGanadora}";
                lbLP1Monto.Text = $"Monto:{resultados[0].MontoGanado}";
                // Se establecen los valores del segundo premio.
                lbLP2Num.Text   = $"{resultados[1].NumeroGanador}";
                lbLP2Serie.Text = $"Serie:{resultados[1].SerieGanadora}";
                lbLP2Monto.Text = $"Monto:{resultados[1].MontoGanado}";
                // Se establecen los valores del tercer premio.
                lbLP3Num.Text   = $"{resultados[2].NumeroGanador}";
                lbLP3Serie.Text = $"Serie:{resultados[2].SerieGanadora}";
                lbLP3Monto.Text = $"Monto:{resultados[2].MontoGanado}";
            }
            else
            {
                lbNumeroLoteria.Text = $"No hay datos de sorteos jugados.";
                // Se ocultan los labels
                lbLP1Num.Visible   = false;
                lbLP1Serie.Visible = false;
                lbLP1Monto.Visible = false;
                lbLP2Num.Visible   = false;
                lbLP2Serie.Visible = false;
                lbLP2Monto.Visible = false;
                lbLP3Num.Visible   = false;
                lbLP3Serie.Visible = false;
                lbLP3Monto.Visible = false;
            }
            if (sorteoChances != null)
            {
                Resultado[] resultados = ObtenerPremiosMayores(sorteoChances);
                lbNumeroChances.Text = $"Sorteo {sorteoChances.NumeroSorteo} - " +
                                       $"{sorteoChances.Fecha.ToShortDateString()}";
                // Se establecen los valores del primer premio.
                lbCP1Num.Text   = $"{resultados[0].NumeroGanador}";
                lbCP1Serie.Text = $"Serie:{resultados[0].SerieGanadora}";
                lbCP1Monto.Text = $"Monto:{resultados[0].MontoGanado}";
                // Se establecen los valores del segundo premio.
                lbCP2Num.Text   = $"{resultados[1].NumeroGanador}";
                lbCP2Serie.Text = $"Serie:{resultados[1].SerieGanadora}";
                lbCP2Monto.Text = $"Monto:{resultados[1].MontoGanado}";
                // Se establecen los valores del tercer premio.
                lbCP3Num.Text   = $"{resultados[2].NumeroGanador}";
                lbCP3Serie.Text = $"Serie:{resultados[2].SerieGanadora}";
                lbCP3Monto.Text = $"Monto:{resultados[2].MontoGanado}";
            }
            else
            {
                lbNumeroChances.Text = $"No hay datos de sorteos jugados.";
                // Se ocultan los labels
                lbCP1Num.Visible   = false;
                lbCP1Serie.Visible = false;
                lbCP1Monto.Visible = false;
                lbCP2Num.Visible   = false;
                lbCP2Serie.Visible = false;
                lbCP2Monto.Visible = false;
                lbCP3Num.Visible   = false;
                lbCP3Serie.Visible = false;
                lbCP3Monto.Visible = false;
            }
        }
Пример #27
0
 public Boolean GenerarReporteResultadosSorteo(Sorteo sorteo)
 {
     return(GenerarReporteCorrespondiente(sorteo, "Reporte de resultados de sorteo", "Resultados", true));
 }