public RoomViewModel() { db = new RoomsDatabaseManager(); this.Rooms = new ObservableCollection <Room>(db.RetrieveRooms()); this.RoomsCollection = CollectionViewSource.GetDefaultView(this.Rooms); RoomsCollection.Filter = FilterRooms; }
//############################################### RETRIEVE ############################################### public List <Attendance> RetrieveCount() { List <Attendance> countList = new List <Attendance>(); using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { DataTable dt = new DataTable(); mysqlCon.Open(); MySqlCommand mySqlCmdNewRooom = new MySqlCommand("retrieve_count", mysqlCon); mySqlCmdNewRooom.CommandType = CommandType.StoredProcedure; MySqlDataAdapter da = new MySqlDataAdapter(mySqlCmdNewRooom); da.Fill(dt); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { Attendance count = new Attendance(); count.Id = Int16.Parse(dt.Rows[i]["count_id"].ToString()); count.Count_beg = Int16.Parse(dt.Rows[i]["count_beg"].ToString()); count.Count_mid = Int16.Parse(dt.Rows[i]["count_mid"].ToString()); count.Count_end = Int16.Parse(dt.Rows[i]["count_end"].ToString()); count.Session_id = Int16.Parse(dt.Rows[i]["session_id"].ToString()); SessionsDatabaseManager sdb = new SessionsDatabaseManager(); //Console.WriteLine("running here"); Session session = sdb.get_session_by_id(count.Session_id); RoomsDatabaseManager rdb = new RoomsDatabaseManager(); Room room = rdb.get_room_by_id(session.Room); SpeakerDatabaseManager spdb = new SpeakerDatabaseManager(); Speaker speaker = spdb.get_speaker_by_id(session.Speaker); TimeSlotsDatabaseManager tdb = new TimeSlotsDatabaseManager(); TimeSlot timeslot = tdb.get_timeslot_by_id(session.TimeSlots); count.Session_title = session.Title; count.Session_room = room.Name; count.Capacity = room.Capacity; count.Session_speaker = speaker.Name; count.Timeslot = timeslot.ConcatTimeSlot; //Console.WriteLine(count.Timeslot); count.Date = session.Date; countList.Add(count); } } mySqlCmdNewRooom.ExecuteNonQuery(); mysqlCon.Close(); return(countList); } }
/// <summary> /// ALL SESSIONS FROM SESSION TABLE /// </summary> /// <returns></returns> public List <Session> getSessions() { List <Session> sessionList = new List <Session>(); using (MySqlConnection mysqlCon = new MySqlConnection(connectionString)) { DataTable dt = new DataTable(); mysqlCon.Open(); MySqlCommand mySqlCmdNewRooom = new MySqlCommand("view_sessions", mysqlCon); mySqlCmdNewRooom.CommandType = CommandType.StoredProcedure; MySqlDataReader da = mySqlCmdNewRooom.ExecuteReader(); while (da.Read()) { Session session = new Session(); session.Id = Convert.ToInt32(da["session_id"]); session.Room = Convert.ToInt32(da["room_id"]); session.Speaker = Convert.ToInt32(da["speaker_id"]); session.TimeSlots = Convert.ToInt32(da["time_slots_id"]); DateTime dateTime = new DateTime(); dateTime = (DateTime)da["session_date"]; session.Date = dateTime.ToString("MM/dd/yyyy"); session.Title = Convert.ToString(da["title"]); RoomsDatabaseManager rdb = new RoomsDatabaseManager(); Room room = rdb.get_room_by_id(session.Room); SpeakerDatabaseManager spdb = new SpeakerDatabaseManager(); Speaker speaker = spdb.get_speaker_by_id(session.Speaker); TimeSlotsDatabaseManager tdb = new TimeSlotsDatabaseManager(); TimeSlot timeslot = tdb.get_timeslot_by_id(session.TimeSlots); session.Timeslot_1 = timeslot.ConcatTimeSlot; //Console.WriteLine(timeslot.ConcatTimeSlot); session.Room_1 = room.Name; session.Speaker_1 = speaker.Name; sessionList.Add(session); } // mySqlCmdNewRooom.ExecuteNonQuery(); mysqlCon.Close(); } return(sessionList); }