public Chamada_TO GetByCode(Chamada_TO pTO) { try { return(new Chamada_DAO().GetByCode(pTO)); } catch (Exception) { throw; } }
public bool Delete(Chamada_TO pTO) { bool retorno = false; try { retorno = new Chamada_DAO().Delete(pTO); } catch (Exception) { throw; } return(retorno); }
public List <Chamada_TO> SearchAll(Chamada_TO pTO) { string condicao = ""; try { // implementa a condição de procura condicao += ""; return(new Chamada_DAO().SearchAll(condicao, pTO)); } catch (Exception) { throw; } }
internal bool Save(Chamada_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 chamada" + " ( mat_codigo " + ", tpr_codigo " + ", cha_presenca) " + "VALUES " + "( @mat_codigo " + " , @tpr_codigo " + " , @cha_presenca ) "; try { command = new SqlCommand(sql, connection); command.Parameters.AddWithValue("@mat_codigo", pTO.MatriculaTO.mat_codigo); command.Parameters.AddWithValue("@tpr_codigo", pTO.TurmaProgramacaoTO.tpr_codigo); command.Parameters.AddWithValue("@cha_presenca", pTO.cha_presenca); command.ExecuteNonQuery(); retorno = true; } catch (Exception) { throw; } finally { command.Dispose(); connection.Close(); connection.Dispose(); } return(retorno); }
internal Chamada_TO GetByCode(Chamada_TO pTO) { SqlConnection connection = null; try { connection = new SqlConnection(ConfigurationManager.ConnectionStrings["conn_bdvveasycomp"].ConnectionString); connection.Open(); } catch (Exception) { throw; } SqlCommand command = null; SqlDataReader reader = null; string sql = " SELECT * FROM chamada "; try { command = new SqlCommand(sql, connection); reader = command.ExecuteReader(); if (reader.Read()) { pTO.MatriculaTO = new Matricula_TO(); pTO.MatriculaTO.mat_codigo = Convert.ToInt32(reader["mat_codigo"]); pTO.TurmaProgramacaoTO = new TurmaProgramacao_TO(); pTO.TurmaProgramacaoTO.tpr_codigo = Convert.ToInt32(reader["tpr_codigo"]); pTO.cha_presenca = Convert.ToInt32(reader["cha_presenca"]); } } catch (Exception) { throw; } finally { reader.Close(); command.Dispose(); connection.Close(); connection.Dispose(); } return(pTO); }
public bool Save(TurmaProgramacao_TO pTO, bool novo) { bool retorno = false; try { using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required)) { if (novo) { if (new TurmaProgramacao_DAO().Save(pTO)) { string condicao = string.Format(" AND turma.tur_codigo = {0}", pTO.TurmaTO.tur_codigo); List <Matricula_TO> ListMatriculaTO = new Matricula_DAO().SearchAll(condicao); foreach (Matricula_TO mat in ListMatriculaTO) { Chamada_TO ChamadaTO = new Chamada_TO(); ChamadaTO.MatriculaTO = mat; ChamadaTO.TurmaProgramacaoTO = pTO; retorno = new Chamada_DAO().Save(ChamadaTO); } } } else { retorno = new TurmaProgramacao_DAO().Update(pTO); } if (retorno) { ts.Complete(); } else { ts.Dispose(); } } } catch (Exception) { throw; } return(retorno); }
internal bool Delete(Chamada_TO pTO) { SqlConnection connection = null; try { connection = new SqlConnection(ConfigurationManager.ConnectionStrings["conn_bdvveasycomp"].ConnectionString); connection.Open(); } catch (Exception) { throw; } SqlCommand command = null; bool retorno = false; string sql = "DELETE FROM chamada" + "WHERE ... "; try { command = new SqlCommand(sql, connection); command.ExecuteNonQuery(); retorno = true; } catch (Exception) { throw; } finally { command.Dispose(); connection.Close(); connection.Dispose(); } return(retorno); }
internal List <Chamada_TO> SearchAll(string pCondicao, Chamada_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 m.mat_codigo " + " ,alu_nome " + " ,tp.tpr_codigo " + " ,cha_presenca " + " FROM chamada c INNER JOIN " + " matricula m on m.mat_codigo = c.mat_codigo INNER JOIN " + " aluno a on a.alu_codigo = m.alu_codigo INNER JOIN " + " turma_programacao tp on tp.tpr_codigo = c.tpr_codigo INNER JOIN " + " turma t on t.tur_codigo = tp.tur_codigo " + " WHERE tpr_data_aula = CONVERT(DATE, GETDATE()) AND t.tur_codigo = @turma_codigo"; List <Chamada_TO> collection = new List <Chamada_TO>(); try { command = new SqlCommand(sql, connection); command.Parameters.AddWithValue("@turma_codigo", pTO.MatriculaTO.TurmaTO.tur_codigo); reader = command.ExecuteReader(); while (reader.Read()) { Chamada_TO ChamadaTO = new Chamada_TO(); ChamadaTO.MatriculaTO = new Matricula_TO(); ChamadaTO.MatriculaTO.AlunoTO = new Aluno_TO(); ChamadaTO.TurmaProgramacaoTO = new TurmaProgramacao_TO(); ChamadaTO.MatriculaTO.mat_codigo = Convert.ToInt32(reader["mat_codigo"]); ChamadaTO.MatriculaTO.AlunoTO.alu_nome = Convert.ToString(reader["alu_nome"]); ChamadaTO.cha_presenca = Convert.ToInt32(reader["cha_presenca"]); ChamadaTO.TurmaProgramacaoTO.tpr_codigo = Convert.ToInt16(reader["tpr_codigo"]); collection.Add(ChamadaTO); } } catch (Exception) { throw; } finally { reader.Close(); command.Dispose(); connection.Close(); connection.Dispose(); } return(collection); }