Esempio n. 1
0
        public List <Notifications> SelectAllEventsEnd()
        {
            List <Notifications> notiList = new List <Notifications>();

            // Get date and time to see which event has ended already
            EventsStatus evSt = new EventsStatus();

            evStList = evSt.GetAllEventsByName();

            foreach (EventsStatus element in evStList)
            {
                int index = element.Date.IndexOf(" ");
                element.Date      = element.Date.Substring(0, index);
                element.StartTime = element.StartTime.Substring(0, 5);

                if (int.Parse(element.StartTime.Substring(0, 2)) >= 12)
                {
                    if (int.Parse(element.StartTime.Substring(0, 2)) == 12)
                    {
                        element.StartTime = (int.Parse(element.StartTime.Substring(0, 2))).ToString() + ":" + element.StartTime.Substring(3, 2) + " PM";
                    }
                    else
                    {
                        element.StartTime = (int.Parse(element.StartTime.Substring(0, 2)) - 12).ToString() + ":" + element.StartTime.Substring(3, 2) + " PM";
                    }
                }
                else
                {
                    element.StartTime = element.StartTime + " AM";
                }

                if (int.Parse(element.EndTime.Substring(0, 2)) >= 12)
                {
                    if (int.Parse(element.EndTime.Substring(0, 2)) == 12)
                    {
                        element.EndTime = (int.Parse(element.EndTime.Substring(0, 2))).ToString() + ":" + element.EndTime.Substring(3, 2) + " PM";
                    }
                    else
                    {
                        element.EndTime = (int.Parse(element.EndTime.Substring(0, 2)) - 12).ToString() + ":" + element.EndTime.Substring(3, 2) + " PM";
                    }
                }
                else
                {
                    element.EndTime = element.EndTime + " AM";
                }

                string   date = element.Date + " " + element.EndTime;
                DateTime dt1  = DateTime.Parse(date);
                DateTime dt2  = DateTime.Now;

                int result = DateTime.Compare(dt1, dt2);

                if (result <= 0)
                {
                    eventIds.Add(int.Parse(element.Id));
                }
            }
            string combinedInt = "";

            for (int i = 0; i < eventIds.Count; i++)
            {
                combinedInt = string.Join(",", eventIds);
            }

            System.Diagnostics.Debug.WriteLine("This is eventid: " + combinedInt);


            //Step 1 -  Define a connection to the database by getting
            //          the connection string from web.config
            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            //Step 2 -  Create a DataAdapter to retrieve data from the database table
            string         sqlStmt = "Select * from Attendance Where ','+@eventId+',' like '%,'+cast(Event_Id as varchar(50))+',%' and Attend = 1 and Feedback = 0";
            SqlDataAdapter da      = new SqlDataAdapter(sqlStmt, myConn);

            da.SelectCommand.Parameters.AddWithValue("@eventId", combinedInt);

            //Step 3 -  Create a DataSet to store the data to be retrieved
            DataSet ds = new DataSet();

            //Step 4 -  Use the DataAdapter to fill the DataSet with data retrieved
            da.Fill(ds);



            //Step 5 -  Read data from DataSet to List
            int rec_cnt = ds.Tables[0].Rows.Count;

            List <Events> evList = new List <Events>();
            Events        ev     = new Events();


            for (int i = 0; i < rec_cnt; i++)
            {
                DataRow row      = ds.Tables[0].Rows[i]; // Sql command returns only one record
                int     eventId  = int.Parse(row["Event_Id"].ToString());
                int     userId   = int.Parse(row["Users_Id"].ToString());
                int     attend   = int.Parse(row["Attend"].ToString());
                int     feedback = int.Parse(row["Feedback"].ToString());

                evList.Add(ev.getEventDetails(eventId));

                string eventName = evList[i].Title;

                Notifications obj = new Notifications(eventId, eventName, userId, attend, feedback);
                notiList.Add(obj);
            }


            for (int i = 0; i < notiList.Count; i++)
            {
                System.Diagnostics.Debug.WriteLine("This is user_id: " + notiList[i].User_id);
                System.Diagnostics.Debug.WriteLine("This is event Name: " + notiList[i].EventName);
                System.Diagnostics.Debug.WriteLine("This is event id: " + notiList[i].EventId);
            }

            return(notiList);
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            viewingUserId = Request.QueryString["userId"];

            EventsStatus evSt = new EventsStatus();
            Users        usr  = new Users();



            if (Session["user"] == null)
            {
                Response.Redirect("homepage.aspx");
            }
            else
            {
                if (radioButtonList.SelectedIndex == 0)
                {
                    msg.Visible = false;

                    if (viewingUserId != null)
                    {
                        // This is a counter
                        evStListEventCounter       = evSt.GetAllEventsByName();
                        counterId                  = evSt.GetAllEventsParticipate(int.Parse(viewingUserId));
                        evStListParticipateCounter = evSt.GetAllEventsEventId(counterId);

                        foreach (var element in evStListParticipateCounter)
                        {
                            participated += 1;
                        }

                        foreach (var element in evStListEventCounter)
                        {
                            if (element.Organiser == viewingUserId)
                            {
                                eventCount += 1;
                            }
                        }

                        if (eventCount == 0)
                        {
                            msg.Visible = true;
                        }

                        evStListTemp = evSt.GetAllEventsByName();
                        Users viewingUser = new Users();
                        usr = viewingUser.GetUserById(int.Parse(viewingUserId));

                        for (int i = 0; i < evStListTemp.Count; i++)
                        {
                            if (evStListTemp[i].Organiser == viewingUserId)
                            {
                                evStListTemp[i].OrganiserPic  = usr.DPimage;
                                evStListTemp[i].OrganiserName = usr.name;
                                evStListTemp[i].Attendee      = 0;
                                evStList.Add(evStListTemp[i]);
                            }
                        }

                        foreach (EventsStatus element in evStList)
                        {
                            element.NumCompleted = eventCount;

                            int index = element.Date.IndexOf(" ");
                            element.Date      = element.Date.Substring(0, index);
                            element.StartTime = element.StartTime.Substring(0, 5);

                            if (int.Parse(element.StartTime.Substring(0, 2)) >= 12)
                            {
                                if (int.Parse(element.StartTime.Substring(0, 2)) == 12)
                                {
                                    element.StartTime = (int.Parse(element.StartTime.Substring(0, 2))).ToString() + ":" + element.StartTime.Substring(3, 2) + " PM";
                                }
                                else
                                {
                                    element.StartTime = (int.Parse(element.StartTime.Substring(0, 2)) - 12).ToString() + ":" + element.StartTime.Substring(3, 2) + " PM";
                                }
                            }
                            else
                            {
                                element.StartTime = element.StartTime + " AM";
                            }

                            if (int.Parse(element.EndTime.Substring(0, 2)) >= 12)
                            {
                                if (int.Parse(element.EndTime.Substring(0, 2)) == 12)
                                {
                                    element.EndTime = (int.Parse(element.EndTime.Substring(0, 2))).ToString() + ":" + element.EndTime.Substring(3, 2) + " PM";
                                }
                                else
                                {
                                    element.EndTime = (int.Parse(element.EndTime.Substring(0, 2)) - 12).ToString() + ":" + element.EndTime.Substring(3, 2) + " PM";
                                }
                            }
                            else
                            {
                                element.EndTime = element.EndTime + " AM";
                            }


                            string   date = element.Date + " " + element.EndTime;
                            DateTime dt1  = DateTime.Parse(date);
                            DateTime dt2  = DateTime.Now;

                            int result = DateTime.Compare(dt1, dt2);

                            if (result < 0 || result == 0)
                            {
                                element.Completed = "Complete";
                            }

                            forCount += 1;
                        }
                    }
                    else
                    {
                        // This is a counter
                        evStListEventCounter       = evSt.GetAllEventsByName();
                        counterId                  = evSt.GetAllEventsParticipate(int.Parse(Session["id"].ToString()));
                        evStListParticipateCounter = evSt.GetAllEventsEventId(counterId);

                        foreach (var element in evStListParticipateCounter)
                        {
                            participated += 1;
                        }

                        foreach (var element in evStListEventCounter)
                        {
                            if (element.Organiser == Session["id"].ToString())
                            {
                                eventCount += 1;
                            }
                        }

                        if (eventCount == 0)
                        {
                            msg.Visible = true;
                        }

                        Users viewingUser = new Users();
                        usr = viewingUser.GetUserById(int.Parse(Session["id"].ToString()));

                        evStListTemp = evSt.GetAllEventsByName();

                        for (int i = 0; i < evStListTemp.Count; i++)
                        {
                            if (evStListTemp[i].Organiser == usr.id.ToString())
                            {
                                evStListTemp[i].OrganiserPic  = usr.DPimage;
                                evStListTemp[i].OrganiserName = usr.name;
                                evStList.Add(evStListTemp[i]);
                            }
                        }


                        foreach (EventsStatus element in evStList)
                        {
                            element.NumCompleted = eventCount;

                            int index = element.Date.IndexOf(" ");
                            element.Date      = element.Date.Substring(0, index);
                            element.StartTime = element.StartTime.Substring(0, 5);

                            if (int.Parse(element.StartTime.Substring(0, 2)) >= 12)
                            {
                                if (int.Parse(element.StartTime.Substring(0, 2)) == 12)
                                {
                                    element.StartTime = (int.Parse(element.StartTime.Substring(0, 2))).ToString() + ":" + element.StartTime.Substring(3, 2) + " PM";
                                }
                                else
                                {
                                    element.StartTime = (int.Parse(element.StartTime.Substring(0, 2)) - 12).ToString() + ":" + element.StartTime.Substring(3, 2) + " PM";
                                }
                            }
                            else
                            {
                                element.StartTime = element.StartTime + " AM";
                            }

                            if (int.Parse(element.EndTime.Substring(0, 2)) >= 12)
                            {
                                if (int.Parse(element.EndTime.Substring(0, 2)) == 12)
                                {
                                    element.EndTime = (int.Parse(element.EndTime.Substring(0, 2))).ToString() + ":" + element.EndTime.Substring(3, 2) + " PM";
                                }
                                else
                                {
                                    element.EndTime = (int.Parse(element.EndTime.Substring(0, 2)) - 12).ToString() + ":" + element.EndTime.Substring(3, 2) + " PM";
                                }
                            }
                            else
                            {
                                element.EndTime = element.EndTime + " AM";
                            }

                            string   date = element.Date + " " + element.EndTime;
                            DateTime dt1  = DateTime.Parse(date);
                            DateTime dt2  = DateTime.Now;

                            int result = DateTime.Compare(dt1, dt2);

                            if (result < 0 || result == 0)
                            {
                                element.Completed = "Complete";
                            }

                            forCount += 1;
                        }
                    }
                }
                if (radioButtonList.SelectedIndex == 1)
                {
                    msg.Visible = false;

                    if (viewingUserId != null)
                    {
                        Users viewingUser = new Users();

                        eventIds = evSt.GetAllEventsParticipate(int.Parse(viewingUserId));

                        evStListTemp = evSt.GetAllEventsEventId(eventIds);

                        //this is a counter
                        evStListEventCounter       = evSt.GetAllEventsByName();
                        counterId                  = evSt.GetAllEventsParticipate(int.Parse(viewingUserId));
                        evStListParticipateCounter = evSt.GetAllEventsEventId(counterId);

                        foreach (var element in evStListParticipateCounter)
                        {
                            participated += 1;
                        }

                        if (participated == 0)
                        {
                            msg.Visible = true;
                        }

                        foreach (var element in evStListEventCounter)
                        {
                            if (element.Organiser == viewingUserId)
                            {
                                eventCount += 1;
                            }
                        }

                        for (int i = 0; i < evStListTemp.Count; i++)
                        {
                            usr = viewingUser.GetUserById(int.Parse(evStListTemp[i].Organiser));

                            evStListTemp[i].Organiser     = usr.id.ToString();
                            evStListTemp[i].OrganiserPic  = usr.DPimage;
                            evStListTemp[i].OrganiserName = usr.name;
                            evStList.Add(evStListTemp[i]);
                        }

                        foreach (EventsStatus element in evStList)
                        {
                            element.NumCompleted = eventCount;

                            int index = element.Date.IndexOf(" ");
                            element.Date      = element.Date.Substring(0, index);
                            element.StartTime = element.StartTime.Substring(0, 5);

                            if (int.Parse(element.StartTime.Substring(0, 2)) >= 12)
                            {
                                if (int.Parse(element.StartTime.Substring(0, 2)) == 12)
                                {
                                    element.StartTime = (int.Parse(element.StartTime.Substring(0, 2))).ToString() + ":" + element.StartTime.Substring(3, 2) + " PM";
                                }
                                else
                                {
                                    element.StartTime = (int.Parse(element.StartTime.Substring(0, 2)) - 12).ToString() + ":" + element.StartTime.Substring(3, 2) + " PM";
                                }
                            }
                            else
                            {
                                element.StartTime = element.StartTime + " AM";
                            }

                            if (int.Parse(element.EndTime.Substring(0, 2)) >= 12)
                            {
                                if (int.Parse(element.EndTime.Substring(0, 2)) == 12)
                                {
                                    element.EndTime = (int.Parse(element.EndTime.Substring(0, 2))).ToString() + ":" + element.EndTime.Substring(3, 2) + " PM";
                                }
                                else
                                {
                                    element.EndTime = (int.Parse(element.EndTime.Substring(0, 2)) - 12).ToString() + ":" + element.EndTime.Substring(3, 2) + " PM";
                                }
                            }
                            else
                            {
                                element.EndTime = element.EndTime + " AM";
                            }


                            string   date = element.Date + " " + element.EndTime;
                            DateTime dt1  = DateTime.Parse(date);
                            DateTime dt2  = DateTime.Now;

                            int result = DateTime.Compare(dt1, dt2);

                            if (result < 0 || result == 0)
                            {
                                element.Completed = "Complete";
                            }

                            forCount += 1;
                        }
                    }
                    else
                    {
                        Users viewingUser = new Users();

                        eventIds     = evSt.GetAllEventsParticipate(int.Parse(Session["id"].ToString()));
                        evStListTemp = evSt.GetAllEventsEventId(eventIds);

                        // This is a counter
                        evStListEventCounter       = evSt.GetAllEventsByName();
                        counterId                  = evSt.GetAllEventsParticipate(int.Parse(Session["id"].ToString()));
                        evStListParticipateCounter = evSt.GetAllEventsEventId(counterId);

                        foreach (var element in evStListParticipateCounter)
                        {
                            participated += 1;
                        }

                        if (participated == 0)
                        {
                            msg.Visible = true;
                        }

                        foreach (var element in evStListEventCounter)
                        {
                            if (element.Organiser == Session["id"].ToString())
                            {
                                eventCount += 1;
                            }
                        }


                        for (int i = 0; i < evStListTemp.Count; i++)
                        {
                            usr = viewingUser.GetUserById(int.Parse(evStListTemp[i].Organiser));

                            evStListTemp[i].Organiser     = usr.id.ToString();
                            evStListTemp[i].OrganiserPic  = usr.DPimage;
                            evStListTemp[i].OrganiserName = usr.name;
                            evStList.Add(evStListTemp[i]);
                        }

                        foreach (EventsStatus element in evStList)
                        {
                            element.NumCompleted = eventCount;

                            int index = element.Date.IndexOf(" ");
                            element.Date      = element.Date.Substring(0, index);
                            element.StartTime = element.StartTime.Substring(0, 5);

                            if (int.Parse(element.StartTime.Substring(0, 2)) >= 12)
                            {
                                if (int.Parse(element.StartTime.Substring(0, 2)) == 12)
                                {
                                    element.StartTime = (int.Parse(element.StartTime.Substring(0, 2))).ToString() + ":" + element.StartTime.Substring(3, 2) + " PM";
                                }
                                else
                                {
                                    element.StartTime = (int.Parse(element.StartTime.Substring(0, 2)) - 12).ToString() + ":" + element.StartTime.Substring(3, 2) + " PM";
                                }
                            }
                            else
                            {
                                element.StartTime = element.StartTime + " AM";
                            }

                            if (int.Parse(element.EndTime.Substring(0, 2)) >= 12)
                            {
                                if (int.Parse(element.EndTime.Substring(0, 2)) == 12)
                                {
                                    element.EndTime = (int.Parse(element.EndTime.Substring(0, 2))).ToString() + ":" + element.EndTime.Substring(3, 2) + " PM";
                                }
                                else
                                {
                                    element.EndTime = (int.Parse(element.EndTime.Substring(0, 2)) - 12).ToString() + ":" + element.EndTime.Substring(3, 2) + " PM";
                                }
                            }
                            else
                            {
                                element.EndTime = element.EndTime + " AM";
                            }

                            string   date = element.Date + " " + element.EndTime;
                            DateTime dt1  = DateTime.Parse(date);
                            DateTime dt2  = DateTime.Now;

                            int result = DateTime.Compare(dt1, dt2);

                            if (result < 0 || result == 0)
                            {
                                element.Completed = "Complete";
                            }

                            forCount += 1;
                        }
                    }
                }
                total = eventCount + participated;
            }
        }
Esempio n. 3
0
        public void initializePPFields(Users userI)
        {
            if (userI == null)
            {
                Response.Redirect("homepage.aspx");
            }
            else
            {
                userI.UpdateRatingByID(userI.id);
                Users user  = userI.GetUserById(userI.id);
                Users sUser = (Users)Session["user"];
                if (sUser != null && user.id == sUser.id)  // i wanted to comment an explanation but was too lazy halfway.
                {
                    Session["user"] = user;
                }

                EventsStatus events     = new EventsStatus();
                var          eventList  = events.GetAllEventsByName();
                int          eventCount = 0;

                for (int i = 0; i < eventList.Count; i++)
                {
                    if (eventList[i].Organiser == user.id.ToString())
                    {
                        eventCount++;
                    }
                }

                if (user.verified == 1)
                {
                    bluetick.Visible = true;
                }

                if (eventCount == 0)
                {
                    lblEventCount.Visible = false;
                }
                else
                {
                    lblEventCount.Text = "(" + eventCount.ToString() + ")";
                }

                lblUserName.Text = user.name;
                if (user.facebook != "")
                {
                    hlFacebook.NavigateUrl = user.facebook;
                }
                if (user.instagram != "")
                {
                    hlInstagram.NavigateUrl = user.instagram;
                }
                if (user.twitter != "")
                {
                    hlTwitter.NavigateUrl = user.twitter;
                }
                hlInstagram.NavigateUrl = user.instagram;
                hlTwitter.NavigateUrl   = user.twitter;
                imgDP.ImageUrl          = user.DPimage;
                imgBP.ImageUrl          = user.BPimage;
                if (user.desc != "")
                {
                    lblDesc.Text = user.desc;
                }
                else
                {
                    lblDesc.Text = "This user has not added any description."; lblDesc.CssClass += "text-muted font-italic";
                }
                rating = user.rating;
            }
        }