public List <MeetModel> loadAllMeetingsFromDataBase(int ID, String tableName) { List <MeetModel> meetingList = new List <MeetModel>(); try { using (OracleConnection connection = new OracleConnection(OracleSQLConnector.GetConnectionString())) { connection.Open(); OracleCommand cmd; string sql = String.Format("select * from meet_table WHERE {1}_table_id = {0}", ID, tableName); cmd = new OracleCommand(sql, connection); cmd.CommandType = CommandType.Text; OracleDataReader reader = cmd.ExecuteReader(); try { while (reader.Read()) { MeetModel meeting = new MeetModel( reader.GetInt32(0), reader.GetInt32(5), reader.GetInt32(6), reader.GetInt32(7), reader.GetDateTime(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetInt32(4)); if (meeting.DateAndHour > DateTime.Now) { meetingList.Add(meeting); } } } finally { reader.Close(); } } } catch { } return(meetingList); }
public bool insertMeetingToDBReturnItsID(MeetModel meet) { try { using (OracleConnection connection = new OracleConnection(OracleSQLConnector.GetConnectionString())) { try { connection.Open(); OracleCommand cmd = new OracleCommand(); String sql = String.Format("INSERT INTO meet_table (date_and_time, duration, accepted, isnew, user_table_id, trainer_table_id, place_table_id) VALUES (TO_DATE('{0}', 'DD/MM/YYYY HH24:MI:SS'), {1}, {2}, {3}, {4}, {5}, {6})", meet.DateAndHour, meet.Duration, meet.Accepted, meet.New, meet.IDUser, meet.IDTrainer, meet.IDPlace); cmd = new OracleCommand(sql, connection); cmd.CommandType = CommandType.Text; cmd.ExecuteNonQuery(); //Console.WriteLine("1213231"); } catch (Exception e) { // Extract some information from this exception, and then // throw it to the parent method. if (e.Source != null) { Console.WriteLine("IOException source: {0}", e.Source); } return(false); } finally { connection.Close(); } } return(true); }catch { return(false); } }