private void submit(object sender, RoutedEventArgs e)
        {
            string commt = commentBT.Text;

            dbms.commentActivity(userID, actID, commt);
            ActivityDetail actDetail = new ActivityDetail(userID, actID);

            actDetail.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
            actDetail.Show();
            this.Close();
        }
示例#2
0
        private void loadActivities(List <Activity> activities)
        {
            showActivity.RowDefinitions.Clear();
            showActivity.ColumnDefinitions.Clear();
            showActivity.Children.Clear();


            if (activities.Count == 0)
            {
                //to be implemented
            }
            else
            {
                foreach (Activity a in activities)
                {
                    ColumnDefinition c1 = new ColumnDefinition();
                    c1.Width = new GridLength(130);
                    showActivity.ColumnDefinitions.Add(c1);

                    ColumnDefinition c2 = new ColumnDefinition();
                    c2.Width = new GridLength(460);
                    showActivity.ColumnDefinitions.Add(c2);

                    ColumnDefinition c3 = new ColumnDefinition();
                    c3.Width = new GridLength(60);
                    showActivity.ColumnDefinitions.Add(c3);

                    Image       activityPhoto = new Image();
                    ImageSource imageSource2  = new BitmapImage(new Uri(a.actPicURL));
                    activityPhoto.Source = imageSource2;
                    activityPhoto.Margin = new Thickness(0, 0, 0, 0);
                    activityPhoto.HorizontalAlignment = HorizontalAlignment.Left;
                    activityPhoto.VerticalAlignment   = VerticalAlignment.Top;

                    Label lTitle = new Label();
                    lTitle.FontSize            = 14;
                    lTitle.Content             = "Title: " + a.name;
                    lTitle.HorizontalAlignment = HorizontalAlignment.Left;
                    lTitle.VerticalAlignment   = VerticalAlignment.Center;
                    lTitle.Margin      = new Thickness(0, 0, 0, 0);
                    lTitle.MouseEnter += (sender, eventArgs) =>
                    {
                        lTitle.Foreground = new SolidColorBrush(Colors.Blue);
                        this.Cursor       = Cursors.Hand;
                    };
                    lTitle.MouseLeave += (sender, eventArgs) =>
                    {
                        lTitle.Foreground = new SolidColorBrush(Colors.Black);
                        this.Cursor       = null;
                    };

                    lTitle.MouseLeftButtonDown += (sender, eventArgs) =>
                    {
                        ActivityDetail activityDetail = new ActivityDetail(userID, a.Id);
                        activityDetail.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
                        activityDetail.Show();
                        this.Close();
                    };


                    Label lTime = new Label();
                    lTime.FontSize            = 14;
                    lTime.Content             = "Date: " + a.start_date.ToString("dd-MM-yyyy") + " Start at:" + a.start_time + " End at:" + a.end_time;
                    lTime.HorizontalAlignment = HorizontalAlignment.Left;
                    lTime.VerticalAlignment   = VerticalAlignment.Center;
                    lTime.Margin = new Thickness(0, 0, 0, 0);

                    Label lLocation = new Label();
                    lLocation.FontSize            = 14;
                    lLocation.Content             = "Location: " + a.location;
                    lLocation.HorizontalAlignment = HorizontalAlignment.Left;
                    lLocation.VerticalAlignment   = VerticalAlignment.Center;
                    lLocation.Margin = new Thickness(0, 0, 0, 0);

                    Label lMoney = new Label();
                    lMoney.FontSize            = 14;
                    lMoney.Content             = "Budget: " + a.budget;
                    lMoney.HorizontalAlignment = HorizontalAlignment.Left;
                    lMoney.VerticalAlignment   = VerticalAlignment.Center;
                    lMoney.Margin = new Thickness(0, 0, 0, 0);

                    User  u        = dbms.getUserByID(a.created_userID);
                    Label lSponsor = new Label();
                    lSponsor.FontSize            = 14;
                    lSponsor.Content             = "Sponser: " + u.name;
                    lSponsor.HorizontalAlignment = HorizontalAlignment.Left;
                    lSponsor.VerticalAlignment   = VerticalAlignment.Center;
                    lSponsor.Margin = new Thickness(0, 0, 0, 0);


                    Button btLike = new Button();
                    btLike.Content             = "Like";
                    btLike.Width               = 25;
                    btLike.Background          = Brushes.LightPink;
                    btLike.Foreground          = Brushes.White;
                    btLike.HorizontalAlignment = HorizontalAlignment.Center;
                    btLike.VerticalAlignment   = VerticalAlignment.Center;
                    //check if the current activity is liked or not
                    if (dbms.hasLiked(userID, a.Id))
                    {
                        btLike.IsEnabled = false;
                    }
                    else
                    {
                        btLike.Click += (sender, eventArgs) =>
                        {
                            dbms.likeActivity(userID, a.Id);
                            btLike.IsEnabled = false;
                        };
                    }

                    Button btJoin = new Button();
                    btJoin.Content             = "Join";
                    btJoin.Width               = 25;
                    btJoin.Background          = Brushes.LightBlue;
                    btJoin.Foreground          = Brushes.White;
                    btJoin.HorizontalAlignment = HorizontalAlignment.Center;
                    btJoin.VerticalAlignment   = VerticalAlignment.Center;
                    //check if the current activity is joined or not
                    if (dbms.hasJoined(userID, a.Id))
                    {
                        btJoin.IsEnabled = false;
                    }
                    else
                    {
                        btJoin.Click += (sender, eventArgs) =>
                        {
                            dbms.joinActivity(userID, a.Id);
                            btJoin.IsEnabled = false;
                        };
                    }

                    Grid.SetRow(activityPhoto, showActivity.RowDefinitions.Count);
                    Grid.SetRowSpan(activityPhoto, 5);
                    Grid.SetColumn(activityPhoto, 0);

                    Grid.SetRow(lTitle, showActivity.RowDefinitions.Count);
                    Grid.SetColumn(lTitle, 1);
                    RowDefinition r1 = new RowDefinition();
                    r1.Height = new GridLength(30);
                    showActivity.RowDefinitions.Add(r1);

                    Grid.SetRow(lTime, showActivity.RowDefinitions.Count);
                    Grid.SetColumn(lTime, 1);
                    RowDefinition r2 = new RowDefinition();
                    r2.Height = new GridLength(30);
                    showActivity.RowDefinitions.Add(r2);

                    Grid.SetRow(lLocation, showActivity.RowDefinitions.Count);
                    Grid.SetColumn(lLocation, 1);
                    RowDefinition r3 = new RowDefinition();
                    r3.Height = new GridLength(30);
                    showActivity.RowDefinitions.Add(r3);

                    Grid.SetRow(lMoney, showActivity.RowDefinitions.Count);
                    Grid.SetColumn(lMoney, 1);

                    Grid.SetRow(btLike, showActivity.RowDefinitions.Count);
                    Grid.SetColumn(btLike, 2);
                    RowDefinition r4 = new RowDefinition();
                    r4.Height = new GridLength(30);
                    showActivity.RowDefinitions.Add(r4);

                    Grid.SetRow(lSponsor, showActivity.RowDefinitions.Count);
                    Grid.SetColumn(lSponsor, 1);

                    Grid.SetRow(btJoin, showActivity.RowDefinitions.Count);
                    Grid.SetColumn(btJoin, 2);

                    RowDefinition r5 = new RowDefinition();
                    r5.Height = new GridLength(30);
                    showActivity.RowDefinitions.Add(r5);


                    RowDefinition r6 = new RowDefinition();
                    r6.Height = new GridLength(10);
                    showActivity.RowDefinitions.Add(r6);

                    showActivity.Children.Add(lTitle);
                    showActivity.Children.Add(lTime);
                    showActivity.Children.Add(lLocation);
                    showActivity.Children.Add(lMoney);
                    showActivity.Children.Add(lSponsor);
                    showActivity.Children.Add(btLike);
                    showActivity.Children.Add(btJoin);
                    showActivity.Children.Add(activityPhoto);
                }
            }
        }
示例#3
0
        public ActivityManagement_Page(int uid)
        {
            InitializeComponent();
            userID = uid;
            string imageURI = dbms.getUserImage(uid);


            Image       userPhoto   = new Image();
            ImageSource imageSource = new BitmapImage(new Uri(imageURI));

            userPhoto.Source = imageSource;
            userPhoto.Height = 55;
            userPhoto.Margin = new Thickness(30, 4, 0, 10);
            userPhoto.HorizontalAlignment = HorizontalAlignment.Left;
            userPhoto.VerticalAlignment   = VerticalAlignment.Center;

            Grid.SetRow(userPhoto, 0);
            Grid.SetColumn(userPhoto, 4);
            bar.Children.Add(userPhoto);

            List <Activity> activities = dbms.getMyActivities(userID);

            foreach (Activity activity in activities)
            {
                ColumnDefinition c1 = new ColumnDefinition();
                c1.Width = new GridLength(130);
                showActivity.ColumnDefinitions.Add(c1);

                ColumnDefinition c2 = new ColumnDefinition();
                c2.Width = new GridLength(460);
                showActivity.ColumnDefinitions.Add(c2);

                ColumnDefinition c3 = new ColumnDefinition();
                c3.Width = new GridLength(60);
                showActivity.ColumnDefinitions.Add(c3);

                Image       activityPhoto = new Image();
                ImageSource imageSource2  = new BitmapImage(new Uri(activity.actPicURL));
                activityPhoto.Source = imageSource2;
                activityPhoto.Margin = new Thickness(0, 0, 0, 0);
                activityPhoto.HorizontalAlignment = HorizontalAlignment.Left;
                activityPhoto.VerticalAlignment   = VerticalAlignment.Top;

                Label lTitle = new Label();
                lTitle.FontSize            = 14;
                lTitle.Content             = "Title: " + activity.name;
                lTitle.HorizontalAlignment = HorizontalAlignment.Left;
                lTitle.VerticalAlignment   = VerticalAlignment.Center;
                lTitle.Margin = new Thickness(0, 0, 0, 0);

                lTitle.MouseEnter += (sender, eventArgs) =>
                {
                    lTitle.Foreground = new SolidColorBrush(Colors.Blue);
                    this.Cursor       = Cursors.Hand;
                };
                lTitle.MouseLeave += (sender, eventArgs) =>
                {
                    lTitle.Foreground = new SolidColorBrush(Colors.Black);
                    this.Cursor       = null;
                };

                lTitle.MouseLeftButtonDown += (sender, eventArgs) =>
                {
                    ActivityDetail activityDetail = new ActivityDetail(userID, activity.Id);
                    activityDetail.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
                    activityDetail.Show();
                    this.Close();
                };

                Label lTime = new Label();
                lTime.FontSize            = 14;
                lTime.Content             = "Time: " + activity.start_time;
                lTime.HorizontalAlignment = HorizontalAlignment.Left;
                lTime.VerticalAlignment   = VerticalAlignment.Center;
                lTime.Margin = new Thickness(0, 0, 0, 0);

                Label lLocation = new Label();
                lLocation.FontSize            = 14;
                lLocation.Content             = "Location: " + activity.location;
                lLocation.HorizontalAlignment = HorizontalAlignment.Left;
                lLocation.VerticalAlignment   = VerticalAlignment.Center;
                lLocation.Margin = new Thickness(0, 0, 0, 0);

                Label lMoney = new Label();
                lMoney.FontSize            = 14;
                lMoney.Content             = "Budget: " + activity.budget;
                lMoney.HorizontalAlignment = HorizontalAlignment.Left;
                lMoney.VerticalAlignment   = VerticalAlignment.Center;
                lMoney.Margin = new Thickness(0, 0, 0, 0);

                int   createdUID = activity.created_userID;
                User  u          = dbms.getUserByID(createdUID);
                Label lSponsor   = new Label();
                lSponsor.FontSize            = 14;
                lSponsor.Content             = "Sponser: " + u.name;
                lSponsor.HorizontalAlignment = HorizontalAlignment.Left;
                lSponsor.VerticalAlignment   = VerticalAlignment.Center;
                lSponsor.Margin = new Thickness(0, 0, 0, 0);

                Button btDelete = new Button();
                btDelete.Content             = "Delete";
                btDelete.HorizontalAlignment = HorizontalAlignment.Center;
                btDelete.VerticalAlignment   = VerticalAlignment.Center;
                btDelete.Click += (sender, eventArg) =>
                {
                    dbms.deleteActivity(activity.Id);
                    ActivityManagement_Page actmpage = new ActivityManagement_Page(userID);
                    actmpage.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen;
                    actmpage.Show();
                    this.Close();
                };


                Grid.SetRow(activityPhoto, showActivity.RowDefinitions.Count);
                Grid.SetRowSpan(activityPhoto, 5);
                Grid.SetColumn(activityPhoto, 0);

                Grid.SetRow(lTitle, showActivity.RowDefinitions.Count);
                Grid.SetColumn(lTitle, 1);
                RowDefinition r1 = new RowDefinition();
                r1.Height = new GridLength(30);
                showActivity.RowDefinitions.Add(r1);

                Grid.SetRow(lTime, showActivity.RowDefinitions.Count);
                Grid.SetColumn(lTime, 1);
                RowDefinition r2 = new RowDefinition();
                r2.Height = new GridLength(30);
                showActivity.RowDefinitions.Add(r2);

                Grid.SetRow(lLocation, showActivity.RowDefinitions.Count);
                Grid.SetColumn(lLocation, 1);
                RowDefinition r3 = new RowDefinition();
                r3.Height = new GridLength(30);
                showActivity.RowDefinitions.Add(r3);

                Grid.SetRow(lMoney, showActivity.RowDefinitions.Count);
                Grid.SetColumn(lMoney, 1);

                RowDefinition r4 = new RowDefinition();
                r4.Height = new GridLength(30);
                showActivity.RowDefinitions.Add(r4);

                Grid.SetRow(lSponsor, showActivity.RowDefinitions.Count);
                Grid.SetColumn(lSponsor, 1);

                Grid.SetRow(btDelete, showActivity.RowDefinitions.Count);
                Grid.SetColumn(btDelete, 2);


                RowDefinition r5 = new RowDefinition();
                r5.Height = new GridLength(30);
                showActivity.RowDefinitions.Add(r5);

                RowDefinition r6 = new RowDefinition();
                r6.Height = new GridLength(20);
                showActivity.RowDefinitions.Add(r6);

                showActivity.Children.Add(lTitle);
                showActivity.Children.Add(lTime);
                showActivity.Children.Add(lLocation);
                showActivity.Children.Add(lMoney);
                showActivity.Children.Add(lSponsor);
                showActivity.Children.Add(btDelete);
                showActivity.Children.Add(activityPhoto);
            }
        }