Beispiel #2
0
        public ParticipanteEntity Obter(string cpfUsu, int codAti)
        {
            ParticipanteEntity participante = new ParticipanteEntity();

            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("SELECT DISTINCT codPar, Participante.cpfUsu, Participante.codAti, nomUsu, codCli, datAti, horAti FROM Participante LEFT JOIN Usuario ON Participante.cpfUsu = Usuario.cpfUsu LEFT JOIN Atividade ON Participante.codAti = Atividade.codAti WHERE Participante.cpfUsu = @cpfUsu AND Participante.codAti = @codAti ORDER BY nomUsu", connection);
                command.Parameters.AddWithValue("@cpfUsu", cpfUsu);
                command.Parameters.AddWithValue("@codAti", codAti);
                IDataReader reader = command.ExecuteReader();

                reader.Read();

                participante.codPar = ExtraDAO.ObterValor<int>(reader, 0, 0);
                participante.cpfUsu = ExtraDAO.ObterValor<string>(reader, 1, null);
                participante.codAti = ExtraDAO.ObterValor<int>(reader, 2, 0);
                participante.nomUsu = ExtraDAO.ObterValor<string>(reader, 3, null);
                participante.codCli = ExtraDAO.ObterValor<int>(reader, 4, 0);
                participante.datAti = ExtraDAO.ObterValor<DateTime>(reader, 5, new DateTime()).ToShortDateString();
                participante.horAti = ExtraDAO.ObterValor<TimeSpan>(reader, 6, new TimeSpan()).ToString().Substring(0, 5);
            }
            finally
            {
                if (connection != null)
                    connection.Close();
            }

            return participante;
        }
Beispiel #3
0
        public ParticipanteEntity Obter(string cpfUsu, int codAti)
        {
            ParticipanteEntity participante = new ParticipanteEntity();

            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("SELECT DISTINCT codPar, Participante.cpfUsu, Participante.codAti, nomUsu, codCli, datAti, horAti FROM Participante LEFT JOIN Usuario ON Participante.cpfUsu = Usuario.cpfUsu LEFT JOIN Atividade ON Participante.codAti = Atividade.codAti WHERE Participante.cpfUsu = @cpfUsu AND Participante.codAti = @codAti ORDER BY nomUsu", connection);
                command.Parameters.AddWithValue("@cpfUsu", cpfUsu);
                command.Parameters.AddWithValue("@codAti", codAti);
                IDataReader reader = command.ExecuteReader();

                reader.Read();

                participante.codPar = ExtraDAO.ObterValor <int>(reader, 0, 0);
                participante.cpfUsu = ExtraDAO.ObterValor <string>(reader, 1, null);
                participante.codAti = ExtraDAO.ObterValor <int>(reader, 2, 0);
                participante.nomUsu = ExtraDAO.ObterValor <string>(reader, 3, null);
                participante.codCli = ExtraDAO.ObterValor <int>(reader, 4, 0);
                participante.datAti = ExtraDAO.ObterValor <DateTime>(reader, 5, new DateTime()).ToShortDateString();
                participante.horAti = ExtraDAO.ObterValor <TimeSpan>(reader, 6, new TimeSpan()).ToString().Substring(0, 5);
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }

            return(participante);
        }
Beispiel #4
0
        private void insereParticipantes(int codAti)
        {
            ParticipanteEntity     participante           = new ParticipanteEntity();
            ParticipanteController participanteController = new ParticipanteController();

            participante.codAti = codAti;
            participante.cpfUsu = Session["cpfUsu"].ToString();
            participanteController.Inserir(participante);

            for (int i = 0; i < lstParticipantes.Items.Count; i++)
            {
                if (lstParticipantes.Items[i].Selected)
                {
                    participante.cpfUsu = lstParticipantes.Items[i].Value;
                    participanteController.Inserir(participante);
                }
            }
        }
Beispiel #5
0
        public bool Inserir(ParticipanteEntity participante)
        {
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("INSERT INTO Participante VALUES (@cpfUsu, @codAti)", connection);
                command.Parameters.AddWithValue("@cpfUsu", participante.cpfUsu);
                command.Parameters.AddWithValue("@codAti", participante.codAti);
                command.ExecuteNonQuery();
            }
            catch
            {
                return false;
            }
            finally
            {
                if (connection != null)
                    connection.Close();
            }

            return true;
        }
Beispiel #6
0
        public bool Inserir(ParticipanteEntity participante)
        {
            try
            {
                connection.Open();
                SqlCommand command = new SqlCommand("INSERT INTO Participante VALUES (@cpfUsu, @codAti)", connection);
                command.Parameters.AddWithValue("@cpfUsu", participante.cpfUsu);
                command.Parameters.AddWithValue("@codAti", participante.codAti);
                command.ExecuteNonQuery();
            }
            catch
            {
                return(false);
            }
            finally
            {
                if (connection != null)
                {
                    connection.Close();
                }
            }

            return(true);
        }
 public bool Inserir(ParticipanteEntity participante)
 {
     IParticipanteDAO iParticipanteDAO = (IParticipanteDAO)DAOFactory.CreateDAO<IParticipanteDAO>();
     return iParticipanteDAO.Inserir(participante);
 }
        private void insereParticipantes(int codAti)
        {
            ParticipanteEntity participante = new ParticipanteEntity();
            ParticipanteController participanteController = new ParticipanteController();

            participante.codAti = codAti;
            participante.cpfUsu = Session["cpfUsu"].ToString();
            participanteController.Inserir(participante);

            for (int i = 0; i < lstParticipantes.Items.Count; i++)
            {
                if (lstParticipantes.Items[i].Selected)
                {
                    participante.cpfUsu = lstParticipantes.Items[i].Value;
                    participanteController.Inserir(participante);
                }
            }
        }
        public bool Inserir(ParticipanteEntity participante)
        {
            IParticipanteDAO iParticipanteDAO = (IParticipanteDAO)DAOFactory.CreateDAO <IParticipanteDAO>();

            return(iParticipanteDAO.Inserir(participante));
        }