public bool ChangeCalendarEvent(CalendarEvent oldCalendarEvent, string titel, string notes, DateTime startdate, DateTime enddate, string subject, string assignment, string gamename)
        {
            CalendarEvent calendarEvent = new CalendarEvent(oldCalendarEvent.ID, titel, notes, startdate, enddate, oldCalendarEvent.AccountEmail);

            if (subject != null && assignment != null)
            {
                calendarEvent = new SchoolEvent(oldCalendarEvent.ID, titel, notes, startdate, enddate, subject, assignment, oldCalendarEvent.AccountEmail);
            }
            else if (gamename != null)
            {
                calendarEvent = new GameEvent(oldCalendarEvent.ID, titel, notes, startdate, enddate, gamename, oldCalendarEvent.AccountEmail);
            }
            if (Agenda.Contains(oldCalendarEvent))
            {
                if (Agenda.Contains(calendarEvent) == false)
                {
                    if (oldCalendarEvent.AccountEmail != "")
                    {
                        CalendarEventDatabase.UpdateCalendarEvent(calendarEvent);
                    }
                    oldCalendarEvent.Update(calendarEvent);
                    return(true);
                }
                else
                {
                    throw new PlannerExceptions("The new appiontment already exist in the agenda");
                }
            }
            else
            {
                throw new PlannerExceptions("The old appointment doesn't exist in the agenda");
            }
        }
 public void EmptyCalendarToUser(Account user)
 {
     foreach (CalendarEvent calendarEvent in Agenda.ToList())
     {
         if (calendarEvent.AccountEmail == "")
         {
             if (calendarEvent.GetType() == typeof(SchoolEvent))
             {
                 SchoolEvent schoolEvent = (SchoolEvent)calendarEvent;
                 CalendarEventDatabase.InsertCalendarEvent(new SchoolEvent(schoolEvent.Titel, schoolEvent.Notes, schoolEvent.StartDate,
                                                                           schoolEvent.EndDate, schoolEvent.Subject, schoolEvent.Assignment, user.EmailAdress));
                 Agenda.Remove(schoolEvent);
                 Agenda.Add(CalendarEventDatabase.CheckCalendarDatabase(schoolEvent.Titel, schoolEvent.StartDate,
                                                                        schoolEvent.EndDate, user.EmailAdress));
             }
             else if (calendarEvent.GetType() == typeof(GameEvent))
             {
                 GameEvent GameEvent = (GameEvent)calendarEvent;
                 CalendarEventDatabase.InsertCalendarEvent(new GameEvent(GameEvent.Titel, GameEvent.Notes, GameEvent.StartDate,
                                                                         GameEvent.EndDate, GameEvent.GameName, user.EmailAdress));
                 Agenda.Remove(GameEvent);
                 Agenda.Add(CalendarEventDatabase.CheckCalendarDatabase(GameEvent.Titel, GameEvent.StartDate,
                                                                        GameEvent.EndDate, user.EmailAdress));
             }
             else
             {
                 CalendarEventDatabase.InsertCalendarEvent(new CalendarEvent(calendarEvent.Titel, calendarEvent.Notes, calendarEvent.StartDate, calendarEvent.EndDate, user.EmailAdress));
                 Agenda.Remove(calendarEvent);
                 Agenda.Add(CalendarEventDatabase.CheckCalendarDatabase(calendarEvent.Titel, calendarEvent.StartDate,
                                                                        calendarEvent.EndDate, user.EmailAdress));
             }
         }
     }
 }
 public void UploadCalendar(Account user)
 {
     if (user != null)
     {
         foreach (CalendarEvent c in Agenda)
         {
             if (c.AccountEmail != "")
             {
                 if (CalendarEventDatabase.CheckCalendarDatabase(c.Titel, c.StartDate, c.EndDate, c.AccountEmail) == null)
                 {
                     if (c.GetType() == typeof(SchoolEvent))
                     {
                         SchoolEvent schoolEvent = (SchoolEvent)c;
                         CalendarEventDatabase.InsertCalendarEvent(schoolEvent);
                     }
                     else if (c.GetType() == typeof(GameEvent))
                     {
                         GameEvent gameEvent = (GameEvent)c;
                         CalendarEventDatabase.InsertCalendarEvent(gameEvent);
                     }
                     else
                     {
                         CalendarEventDatabase.InsertCalendarEvent(c);
                     }
                 }
             }
         }
     }
 }
Example #4
0
        public CalendarEvent CheckCalendarDatabase(string titel, DateTime startdate, DateTime enddate, string email)
        {
            CalendarEvent calendarEvent = null;

            try
            {
                OracleParameter[] checkParameter =
                {
                    new OracleParameter("titel",     titel),
                    new OracleParameter("startdate", startdate.ToString("dd/MM/yyyy HH:mm:ss")),
                    new OracleParameter("enddate",   enddate.ToString("dd/MM/yyyy HH:mm:ss")),
                    new OracleParameter("mail",      email)
                };
                DataTable dt = DatabaseManager.ExecuteReadQuery(DatabaseQuerys.Query["GetCalendarEvent"],
                                                                checkParameter);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow reader in dt.Rows)
                    {
                        int      id        = Convert.ToInt32(reader["ID"]);
                        string   Titel     = (String)reader["TITEL"];
                        string   notes     = (String)reader["NOTE"];
                        DateTime startDate = (DateTime)reader["STARTDATE"];
                        DateTime endDate   = (DateTime)reader["ENDDATE"];
                        string   Email     = (String)reader["EMAILADDRESS"];
                        if (reader["SUBJECT"] != DBNull.Value && reader["ASSIGNMENT"] != DBNull.Value)
                        {
                            string subject    = (String)reader["SUBJECT"];
                            string assignment = (String)reader["ASSIGNMENT"];
                            calendarEvent = new SchoolEvent(id, Titel, notes, startDate, endDate, subject, assignment,
                                                            Email);
                        }
                        else if (reader["GAMENAME"] != DBNull.Value)
                        {
                            string gameName = (String)reader["GAMENAME"];
                            calendarEvent = new GameEvent(id, Titel, notes, startDate, endDate, gameName, Email);
                        }
                        else
                        {
                            calendarEvent = new CalendarEvent(id, Titel, notes, startDate, endDate, Email);
                        }
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(calendarEvent);
        }
        public override bool Update(CalendarEvent calendarEvent)
        {
            SchoolEvent schoolEvent = (SchoolEvent)calendarEvent;

            if (Titel != schoolEvent.Titel || Notes != schoolEvent.Notes || StartDate != schoolEvent.StartDate || EndDate != schoolEvent.EndDate ||
                Subject != schoolEvent.Subject || Assignment != schoolEvent.Assignment || AccountEmail != schoolEvent.AccountEmail)
            {
                Subject    = schoolEvent.Subject;
                Assignment = schoolEvent.Assignment;
                return(base.Update(schoolEvent));
            }
            else
            {
                return(false);
            }
        }
        public bool AddCalendarEvent(string titel, string notes, DateTime startdate, DateTime enddate, string subject, string assignment, string gamename, string email)
        {
            CalendarEvent calendarEvent = new CalendarEvent(titel, notes, startdate, enddate, email);

            if (subject != null && assignment != null)
            {
                calendarEvent = new SchoolEvent(titel, notes, startdate, enddate, subject, assignment, email);
            }
            else if (gamename != null)
            {
                calendarEvent = new GameEvent(titel, notes, startdate, enddate, gamename, email);
            }
            if (Agenda.Contains(calendarEvent) == false)
            {
                if (calendarEvent.AccountEmail != "")
                {
                    try
                    {
                        if (CalendarEventDatabase.CheckCalendarDatabase(titel, startdate, enddate, email) == null)
                        {
                            CalendarEventDatabase.InsertCalendarEvent(calendarEvent);
                            Agenda.Add(CalendarEventDatabase.CheckCalendarDatabase(titel, startdate, enddate, email));
                            return(true);
                        }
                        else
                        {
                            throw new PlannerExceptions("Event already exist");
                        }
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
                else
                {
                    Agenda.Add(calendarEvent);
                    return(true);
                }
            }
            else
            {
                throw new PlannerExceptions("Appiontment already exist in agenda");
            }
        }
 public override bool Equals(object obj)
 {
     if (obj is SchoolEvent)
     {
         SchoolEvent other = ((SchoolEvent)obj);
         return(this.Titel == other.Titel &&
                this.StartDate == other.StartDate &&
                this.EndDate == other.EndDate &&
                this.Notes == other.Notes &&
                this.Subject == other.Subject &&
                this.Assignment == other.Assignment &&
                this.AccountEmail == other.AccountEmail);
     }
     else
     {
         return(false);
     }
 }
Example #8
0
        List <CalendarEvent> GetCalendarEvents(string mail)
        {
            List <CalendarEvent> loaded = new List <CalendarEvent>();

            OracleParameter[] checkParameter =
            {
                new OracleParameter("mail", mail)
            };
            DataTable dt = DatabaseManager.ExecuteReadQuery(DatabaseQuerys.Query["GetAllCalendarEvent"],
                                                            checkParameter);

            foreach (DataRow reader in dt.Rows)
            {
                CalendarEvent calendarEvent = null;
                int           id            = Convert.ToInt32(reader["ID"]);
                string        titel         = (String)reader["TITEL"];
                string        notes         = (String)reader["NOTE"];
                DateTime      startDate     = (DateTime)reader["STARTDATE"];
                DateTime      endDate       = (DateTime)reader["ENDDATE"];
                string        email         = (String)reader["EMAILADDRESS"];
                if (reader["SUBJECT"] != DBNull.Value && reader["ASSIGNMENT"] != DBNull.Value)
                {
                    string subject    = (String)reader["SUBJECT"];
                    string assignment = (String)reader["ASSIGNMENT"];
                    calendarEvent = new SchoolEvent(id, titel, notes, startDate, endDate, subject, assignment, email);
                }
                else if (reader["GAMENAME"] != DBNull.Value)
                {
                    string gameName = (String)reader["GAMENAME"];
                    calendarEvent = new GameEvent(id, titel, notes, startDate, endDate, gameName, email);
                }
                else
                {
                    calendarEvent = new CalendarEvent(id, titel, notes, startDate, endDate, email);
                }
                loaded.Add(calendarEvent);
            }
            return(loaded);
        }
        public void UpdateCalendarEvent(CalendarEvent calendarEvent)
        {
            if (calendarEvent is SchoolEvent)
            {
                SchoolEvent schoolEvent = (SchoolEvent)calendarEvent;
                try
                {
                    OracleParameter[] updateSchoolParameter =
                    {
                        new OracleParameter("oldID",       schoolEvent.ID),

                        new OracleParameter("nSUBJECT",    schoolEvent.Subject),
                        new OracleParameter("nASSIGNMENT", schoolEvent.Assignment)
                    };
                    DatabaseManager.ExecuteInsertQuery("UpdateSchoolEvent", updateSchoolParameter);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
 public void InsertCalendarEvent(CalendarEvent calendarEvent)
 {
     if (calendarEvent is SchoolEvent)
     {
         SchoolEvent schoolEvent = (SchoolEvent)calendarEvent;
         try
         {
             CalendarEvent CEvent = calendarEventDatabase.CheckCalendarDatabase(schoolEvent.Titel,
                                                                                schoolEvent.StartDate, schoolEvent.EndDate, schoolEvent.AccountEmail);
             OracleParameter[] insertSchoolParameter =
             {
                 new OracleParameter("iSUBJECT",    schoolEvent.Subject),
                 new OracleParameter("iASSIGNMENT", schoolEvent.Assignment),
                 new OracleParameter("iID",         CEvent.ID)
             };
             DatabaseManager.ExecuteInsertQuery("InsertSchoolEvent", insertSchoolParameter);
         }
         catch (Exception)
         {
             throw;
         }
     }
 }