Пример #1
0
        internal List <Matricula_TO> SearchAll(string pCondicao)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(ConfigurationSettings.AppSettings["conn_bdvveasycomp"]);
                connection.Open();
            }
            catch (Exception)
            {
                throw;
            }

            SqlCommand    command = null;
            SqlDataReader reader  = null;

            string sql = "SELECT mat_codigo " +
                         ",turma.tur_nome " +
                         ",aluno.alu_nome " +
                         ",mat_data_matricula " +
                         "FROM matricula " +
                         "INNER JOIN aluno ON " +
                         "aluno.alu_codigo = matricula.alu_codigo " +
                         "INNER JOIN turma ON " +
                         "turma.tur_codigo = matricula.tur_codigo " +
                         "WHERE mat_codigo > 0 " + pCondicao;

            List <Matricula_TO> collection = new List <Matricula_TO>();

            try
            {
                command = new SqlCommand(sql, connection);
                reader  = command.ExecuteReader();

                while (reader.Read())
                {
                    Matricula_TO MatriculaTO = new Matricula_TO();
                    MatriculaTO.mat_codigo         = Convert.ToInt32(reader["mat_codigo"]);
                    MatriculaTO.TurmaTO            = new Turma_TO();
                    MatriculaTO.TurmaTO.tur_nome   = Convert.ToString(reader["tur_nome"]);
                    MatriculaTO.AlunoTO            = new Aluno_TO();
                    MatriculaTO.AlunoTO.alu_nome   = Convert.ToString(reader["alu_nome"]);
                    MatriculaTO.mat_data_matricula = Convert.ToDateTime(reader["mat_data_matricula"]);
                    collection.Add(MatriculaTO);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }
            return(collection);
        }
Пример #2
0
 public Matricula_TO GetByCode(Matricula_TO pTO)
 {
     try
     {
         return(new Matricula_DAO().GetByCode(pTO));
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #3
0
        public bool Delete(Matricula_TO pTO)
        {
            bool retorno = false;

            try
            {
                retorno = new Matricula_DAO().Delete(pTO);
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
Пример #4
0
        internal bool Save(Matricula_TO pTO)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(ConfigurationSettings.AppSettings["conn_bdvveasycomp"]);
                connection.Open();
            }
            catch (Exception)
            {
                throw;
            }

            SqlCommand command = null;
            bool       retorno = false;

            string sql = "INSERT INTO matricula" +
                         "( tur_codigo " +
                         ", alu_codigo " +
                         ", mat_data_matricula) " +
                         "VALUES " +
                         "(  @tur_codigo " +
                         " , @alu_codigo " +
                         " , @mat_data_matricula ) ";

            try
            {
                command = new SqlCommand(sql, connection);
                command.Parameters.AddWithValue("@mat_codigo", pTO.mat_codigo);
                command.Parameters.AddWithValue("@tur_codigo", pTO.TurmaTO.tur_codigo);
                command.Parameters.AddWithValue("@alu_codigo", pTO.AlunoTO.alu_codigo);
                command.Parameters.AddWithValue("@mat_data_matricula", pTO.mat_data_matricula);
                command.ExecuteNonQuery();
                retorno = true;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }

            return(retorno);
        }
Пример #5
0
        public List <Matricula_TO> SearchAll(Matricula_TO pTO)
        {
            string condicao = "";

            try
            {
                // implementa a condição de procura
                condicao += "";
                return(new Matricula_DAO().SearchAll(condicao));
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #6
0
        public bool Save(Matricula_TO pTO, bool save)
        {
            bool retorno = false;

            try
            {
                if (save)
                {
                    retorno = new Matricula_DAO().Save(pTO);
                }
                else
                {
                    retorno = new Matricula_DAO().Update(pTO);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(retorno);
        }
Пример #7
0
        internal bool Delete(Matricula_TO pTO)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(ConfigurationSettings.AppSettings["conn_bdvveasycomp"]);
                connection.Open();
            }
            catch (Exception)
            {
                throw;
            }

            SqlCommand command = null;
            bool       retorno = false;

            string sql = "DELETE FROM matricula WHERE  mat_codigo = @mat_codigo ";

            try
            {
                command = new SqlCommand(sql, connection);
                command.Parameters.AddWithValue("@mat_codigo", pTO.mat_codigo);
                command.ExecuteNonQuery();
                retorno = true;
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }

            return(retorno);
        }
Пример #8
0
        internal Matricula_TO GetByCode(Matricula_TO pTO)
        {
            SqlConnection connection = null;

            try
            {
                connection = new SqlConnection(ConfigurationSettings.AppSettings["conn_bdvveasycomp"]);
                connection.Open();
            }
            catch (Exception)
            {
                throw;
            }
            SqlCommand    command = null;
            SqlDataReader reader  = null;

            string sql = "SELECT MAT_CODIGO " +
                         "   , MAT_DATA_MATRICULA " +
                         "   , TUR.TUR_CODIGO " +
                         "   , TUR_NOME " +
                         "   , ALU.ALU_CODIGO " +
                         "   , ALU_NOME " +
                         "   , CUR.CUR_CODIGO " +
                         "   , CUR_NOME " +
                         "FROM MATRICULA MAT INNER JOIN " +
                         "TURMA TUR ON TUR.TUR_CODIGO = MAT.TUR_CODIGO INNER JOIN " +
                         "ALUNO ALU ON ALU.ALU_CODIGO = MAT.ALU_CODIGO INNER JOIN " +
                         "CURSO CUR ON CUR.CUR_CODIGO = TUR.CUR_CODIGO ";

            try
            {
                command = new SqlCommand(sql, connection);

                command.Parameters.AddWithValue("@mat_codigo", pTO.mat_codigo);
                reader = command.ExecuteReader();

                if (reader.Read())
                {
                    pTO.mat_codigo                 = Convert.ToInt32(reader["mat_codigo"]);
                    pTO.TurmaTO                    = new Turma_TO();
                    pTO.TurmaTO.tur_codigo         = Convert.ToInt32(reader["tur_codigo"]);
                    pTO.AlunoTO                    = new Aluno_TO();
                    pTO.AlunoTO.alu_codigo         = Convert.ToInt32(reader["alu_codigo"]);
                    pTO.TurmaTO.CursoTO            = new Curso_TO();
                    pTO.TurmaTO.CursoTO.cur_codigo = Convert.ToInt32(reader["cur_codigo"]);
                    pTO.mat_data_matricula         = Convert.ToDateTime(reader["mat_data_matricula"]);
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                reader.Close();
                command.Dispose();
                connection.Close();
                connection.Dispose();
            }

            return(pTO);
        }