示例#1
0
        public static List <Lista_Invitados> obtenerTodos()
        {
            List <Lista_Invitados> lista = new List <Lista_Invitados>();
            Servidor oservidor           = new Servidor();

            try
            {
                SqlCommand command = new SqlCommand("SP_lista_invitados_SelectAll", oservidor.Conectar());
                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())
                {
                    Lista_Invitados listaInv = new Lista_Invitados();
                    listaInv.Id     = Convert.ToInt32(reader["id"].ToString());
                    listaInv.Correo = reader["Correos"].ToString();

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

            return(lista);
        }
示例#2
0
        public void Guardar(Lista_Invitados invitados)
        {
            try
            {
                SqlCommand command = new SqlCommand("SP_lista_invitados_Insert", servidor.Conectar());

                command.CommandType = CommandType.StoredProcedure;

                SqlParameter[] parameters = new SqlParameter[]
                {
                    new SqlParameter("id", invitados.Id),
                    new SqlParameter("Correos", invitados.Correo)
                };
                command.Parameters.AddRange(parameters);
                cargar = command.ExecuteReader();
            }
            catch
            {
                throw;
            }
            finally
            {
                servidor.Desconectar();
            }
        }
示例#3
0
        public static Lista_Invitados ObtenerPorId(int id)
        {
            Servidor oservidor = new Servidor();

            try
            {
                SqlCommand command = new SqlCommand("SP_lista_invitados_SelectRow", oservidor.Conectar());
                command.CommandType = System.Data.CommandType.StoredProcedure;


                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())
                {
                    Lista_Invitados invitado = new Lista_Invitados();
                    invitado.Id     = Convert.ToInt32(reader["Id"]);
                    invitado.Correo = reader["Correos"].ToString();

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

            return(null);
        }
示例#4
0
        //Evento_Datos eDados;

        public void Guardar(Lista_Invitados l_Invidatos)
        {
            if (l_Invidatos == null)
            {
                throw new ArgumentException("No se tiene Invidatos");
            }
            if (l_Invidatos.Id <= -1)
            {
                throw new ArgumentException("El codigo No corresponde");
            }

            datos = new ListaInv_Datos();

            datos.Guardar(l_Invidatos);
        }
        private void btnVerificar_Click(object sender, EventArgs e)
        {
            string correo = txtCorreo.Text;

            if (logica.ComprobarFormatoEmail(correo) == false)
            {
                txtCorreo.Text      = "Dirección no valida";
                txtCorreo.ForeColor = Color.Red;
            }
            else
            {
                txtCorreo.Text      = "Dirección valida";
                txtCorreo.ForeColor = Color.Green;

                Lista_Invitados invitados = new Lista_Invitados();

                invitados.Id     = logica.ultimo();
                invitados.Correo = correo;
                logica.Guardar(invitados);
            }
            tmr_txtCorreo.Start();
            Refrescar();
        }
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvInvitaciones.SelectedRows.Count > 0)
                {
                    Lista_Invitados invidato = (Lista_Invitados)dgvInvitaciones.SelectedRows[0].DataBoundItem;

                    var result = MessageBox.Show("Seguro?", "Elminar Invitación", MessageBoxButtons.YesNo,
                                                 MessageBoxIcon.Question);

                    if (result == DialogResult.Yes)
                    {
                        logica.Eliminar(invidato.Id);

                        Refrescar();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }