private static FRENTE_MAPA_0002Entity FillEntityObject(ref FbDataReader DataReader) { FRENTE_MAPA_0002Entity entity = new FRENTE_MAPA_0002Entity(); FirebirdGetDbData getData = new FirebirdGetDbData(); entity.N_SERIE = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("N_SERIE")); entity.N_CAIXA = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("N_CAIXA")); entity.CONTADOR_REDUCAO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("CONTADOR_REDUCAO")); entity.CONTADOR_REINICIO = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("CONTADOR_REINICIO")); entity.DATA = getData.ConvertDBValueToDateTimeNullable(DataReader, DataReader.GetOrdinal("DATA")); entity.PRIMEIRO_CUPOM = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("PRIMEIRO_CUPOM")); entity.ULTIMO_CUPOM = getData.ConvertDBValueToStringNullable(DataReader, DataReader.GetOrdinal("ULTIMO_CUPOM")); entity.VENDA_BRUTA = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("VENDA_BRUTA")); entity.VALOR_INICIO_DIA = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("VALOR_INICIO_DIA")); entity.VALOR_FINAL_DIA = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("VALOR_FINAL_DIA")); entity.TRIBF = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("TRIBF")); entity.TRIBI = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("TRIBI")); entity.TRIBN = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("TRIBN")); entity.TRIBA = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("TRIBA")); entity.TRIBD = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("TRIBD")); entity.TRIBC = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("TRIBC")); entity.TRIBS = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("TRIBS")); entity.T0700 = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("T0700")); entity.T1200 = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("T1200")); entity.T1800 = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("T1800")); entity.T2500 = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("T2500")); entity.TRICS = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("TRICS")); entity.TRIAS = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("TRIAS")); entity.TRIDS = getData.ConvertDBValueToDecimalNullable(DataReader, DataReader.GetOrdinal("TRIDS")); //entity.SINCRONIZADO = getData.ConvertDBValueToInt32(DataReader, DataReader.GetOrdinal("SINCRONIZADO")); return(entity); }
public FRENTE_MAPA_0002Entity Read() { FbDataReader reader = null; try { //Verificando a existência de um transação aberta if (dbTransaction != null) { if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("Rea_FRENTE_MAPA_0002", dbCnn); dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = ((FbConnection)GetConnectionDB()); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("Rea_FRENTE_MAPA_0002", dbCnn); dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted); } dbCommand.CommandType = CommandType.StoredProcedure; reader = dbCommand.ExecuteReader(); FRENTE_MAPA_0002Entity entity = null; if (reader.HasRows) { while (reader.Read()) { entity = FillEntityObject(ref reader); } } // Deleta reader if (reader != null) { reader.Close(); reader.Dispose(); } // Fecha conexão if (dbTransaction == null) { dbCommand.Transaction.Commit(); if (dbCnn.State == ConnectionState.Open) { dbCnn.Close(); } } return(entity); } catch (Exception ex) { // Deleta reader if (reader != null) { reader.Close(); reader.Dispose(); } if (dbTransaction != null) { this.RollbackTransaction(); } else { if (dbCommand.Transaction != null) { dbCommand.Transaction.Rollback(); } if (dbCnn.State == ConnectionState.Open) { dbCnn.Close(); } } throw ex; } }
public int Save(FRENTE_MAPA_0002Entity Entity) { int result = 0; try { //Verificando a existência de um transação aberta if (dbTransaction != null) { if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("Sav_FRENTE_MAPA_0002", dbCnn); dbCommand.Transaction = ((FbTransaction)(dbTransaction)); } else { if (dbCnn == null) { dbCnn = ((FbConnection)GetConnectionDB()); } if (dbCnn.State == ConnectionState.Closed) { dbCnn.Open(); } dbCommand = new FbCommand("Sav_FRENTE_MAPA_0002", dbCnn); dbCommand.Transaction = dbCnn.BeginTransaction(IsolationLevel.ReadCommitted); } dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.Parameters.AddWithValue("@N_SERIE", Entity.N_SERIE); //Coluna dbCommand.Parameters.AddWithValue("@N_CAIXA", Entity.N_CAIXA); //Coluna dbCommand.Parameters.AddWithValue("@CONTADOR_REDUCAO", Entity.CONTADOR_REDUCAO); //Coluna dbCommand.Parameters.AddWithValue("@CONTADOR_REINICIO", Entity.CONTADOR_REINICIO); //Coluna dbCommand.Parameters.AddWithValue("@DATA", Entity.DATA); //Coluna dbCommand.Parameters.AddWithValue("@PRIMEIRO_CUPOM", Entity.PRIMEIRO_CUPOM); //Coluna dbCommand.Parameters.AddWithValue("@ULTIMO_CUPOM", Entity.ULTIMO_CUPOM); //Coluna dbCommand.Parameters.AddWithValue("@VENDA_BRUTA", Entity.VENDA_BRUTA); //Coluna dbCommand.Parameters.AddWithValue("@VALOR_INICIO_DIA", Entity.VALOR_INICIO_DIA); //Coluna dbCommand.Parameters.AddWithValue("@VALOR_FINAL_DIA", Entity.VALOR_FINAL_DIA); //Coluna dbCommand.Parameters.AddWithValue("@TRIBF", Entity.TRIBF); //Coluna dbCommand.Parameters.AddWithValue("@TRIBI", Entity.TRIBI); //Coluna dbCommand.Parameters.AddWithValue("@TRIBN", Entity.TRIBN); //Coluna dbCommand.Parameters.AddWithValue("@TRIBA", Entity.TRIBA); //Coluna dbCommand.Parameters.AddWithValue("@TRIBD", Entity.TRIBD); //Coluna dbCommand.Parameters.AddWithValue("@TRIBC", Entity.TRIBC); //Coluna dbCommand.Parameters.AddWithValue("@TRIBS", Entity.TRIBS); //Coluna dbCommand.Parameters.AddWithValue("@T0700", Entity.T0700); //Coluna dbCommand.Parameters.AddWithValue("@T1200", Entity.T1200); //Coluna dbCommand.Parameters.AddWithValue("@T1800", Entity.T1800); //Coluna dbCommand.Parameters.AddWithValue("@T2500", Entity.T2500); //Coluna dbCommand.Parameters.AddWithValue("@TRICS", Entity.TRICS); //Coluna dbCommand.Parameters.AddWithValue("@TRIAS", Entity.TRIAS); //Coluna dbCommand.Parameters.AddWithValue("@TRIDS", Entity.TRIDS); //Coluna dbCommand.Parameters.AddWithValue("@SINCRONIZADO", Entity.SINCRONIZADO); //Coluna //Retorno da Procedure FbParameter returnValue; returnValue = dbCommand.CreateParameter(); dbCommand.Parameters[""].Direction = ParameterDirection.InputOutput; //Executando consulta dbCommand.ExecuteNonQuery(); result = int.Parse(dbCommand.Parameters[""].Value.ToString()); if (dbTransaction == null) { dbCommand.Transaction.Commit(); dbCnn.Close(); } } catch (Exception ex) { if (dbTransaction != null) { this.RollbackTransaction(); } else { if (dbCommand.Transaction != null) { dbCommand.Transaction.Rollback(); } if (dbCnn.State == ConnectionState.Open) { dbCnn.Close(); } } throw ex; } return(result); }