Ejemplo n.º 1
0
 /// <summary>
 /// voegd een review toe aan de database.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void PReviewButton_Click(object sender, EventArgs e)
 {
     if (CheckValid())
     {
         List <CheckBox> CBList = new List <CheckBox>()
         {
             Ster1CheckBox, Ster2CheckBox, Ster3CheckBox, Ster4CheckBox, Ster5CheckBox
         };
         int    CBcount   = 0;
         Review NewReview = new Review();
         NewReview.title      = RtitelTextBox.Text;
         NewReview.body       = RbodyTextBox.Text;
         NewReview.reviewedid = UserId;
         NewReview.reviewerid = ((Gebruiker)SessionManager.GetCurrentUser()).userid;
         foreach (var CB in CBList)
         {
             CBcount++;
             if (CB.Checked)
             {
                 NewReview.rating = CBcount;
                 break;
             }
         }
         ReviewManager.ReviewToevoegen(NewReview);
         ReviewLoad();
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// De Load die hij uitvoerd als je de form opent.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FormBekijkenprofiel_Load(object sender, EventArgs e)
        {
            var gebruiker = GebruikerManager.GebruikerOpvragen(UserId);

            Naam.Text  = gebruiker.voornaam + " " + gebruiker.achternaam;
            this.Text  = "Profiel van " + gebruiker.voornaam + " " + gebruiker.achternaam;
            Adres.Text = gebruiker.woonplaats;
            if (gebruiker.oppassen && gebruiker.uitlaten == false)
            {
                OppassenUitlatenLabel.Text = "Kan passen op:";
            }
            else if (gebruiker.oppassen == false && gebruiker.uitlaten)
            {
                OppassenUitlatenLabel.Text = "Kan de volgende dieren uitlaten:";
            }
            else if (gebruiker.oppassen && gebruiker.uitlaten)
            {
                OppassenUitlatenLabel.Text = "Kan op de volgende dieren passen en is bereid om ze uit te laten:";
            }
            Kanpassenop.Text = gebruiker.diertypes;
            Overmijinfo.Text = gebruiker.overmij;
            Prijs.Text       = "Prijs per dag: €" + gebruiker.vraagprijs;
            //Rating
            Bitmap[] Ster = new Bitmap[6]
            {
                Properties.Resources.ster0, Properties.Resources.ster1, Properties.Resources.ster2, Properties.Resources.ster3, Properties.Resources.ster4, Properties.Resources.ster5
            };
            RatingPictureBox.Image = Ster[ReviewManager.BerekenRating(UserId)];
            //Profielfoto
            Profielfoto.Image = ProfielfotoManager.getProfielfoto(gebruiker.userid);
            // LogedIn features weg halen
            if (!LoginCheck())
            {
                List <Control> ReviewPItems = new List <Control>()
                {
                    TitelLabel, BodyLabel, SchrijfhierLabel, OLijnLabel, ASterLabel, RtitelTextBox, RbodyTextBox,
                    Ster1CheckBox, Ster2CheckBox, Ster3CheckBox, Ster4CheckBox, Ster5CheckBox, PReviewButton, DiscardButton
                };

                foreach (var Item in ReviewPItems)
                {
                    Item.Visible = false;
                }
            }
            //reviews laden
            ReviewLoad();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// verwijderd een review van de database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DiscardButton_Click(object sender, EventArgs e)
        {
            var Lreviews   = ReviewManager.ReviewsOppasser(UserId).ToList <Review>();
            int reviewerid = ((Gebruiker)SessionManager.GetCurrentUser()).userid;

            foreach (var Item in Lreviews)
            {
                if (Item.reviewerid != reviewerid)
                {
                    continue;
                }
                ReviewManager.ReviewVerwijderen(Item.reviewid);
                break;
            }
            DiscardButton.Visible = false;
            ReviewLoad();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// checked of er een review bestaat van de persoon die ingelogd is.
        /// </summary>
        /// <returns></returns>
        public bool OwnReview()
        {
            //Als iemand niet is ingelogd, doe alsof hij een review heeft
            if (!LoginCheck())
            {
                return(true);
            }
            var Lreviews = ReviewManager.ReviewsOppasser(UserId).ToList <Review>();

            foreach (Review RV in Lreviews)
            {
                if (RV.reviewerid == ((Gebruiker)SessionManager.GetCurrentUser()).userid)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        private Gebruiker[] Buildquery()
        {
            string          dier = "", woonplaats;
            bool            Verified, uitlaat, oppas;
            List <CheckBox> CBList = new List <CheckBox>()
            {
                HondCheckBox, KatCheckBox, KnaagdierCheckBox, VogelCheckBox, ReptielCheckBox, AmfibieCheckBox, InsectCheckBox, VisCheckBox
            };

            foreach (CheckBox CB in CBList)
            {
                if (CB.Checked == true)
                {
                    dier = CB.Text;
                }
            }

            Verified   = VerifiedCheckBox.Checked;
            uitlaat    = UitlaatCheckBox.Checked;
            oppas      = OppasCheckBox.Checked;
            woonplaats = ZoektextBox.Text;
            Gebruiker[]      allegebruikers     = GebruikerManager.AlleGebruikers();
            List <Gebruiker> filteredgebruikers = new List <Gebruiker>();

            foreach (var gebruiker in allegebruikers)
            {
                if (!gebruiker.diertypes.Contains(dier))
                {
                    continue;
                }
                if (woonplaats != "" && gebruiker.woonplaats != woonplaats)
                {
                    continue;
                }
                if (PrijsTextBox.Text != "" && (gebruiker.vraagprijs > Convert.ToDouble(PrijsTextBox.Text)))
                {
                    continue;
                }
                if (VerifiedCheckBox.Checked && !gebruiker.verified)
                {
                    continue;
                }
                if (UitlaatCheckBox.Checked && !gebruiker.uitlaten)
                {
                    continue;
                }
                if (OppasCheckBox.Checked && !gebruiker.oppassen)
                {
                    continue;
                }
                filteredgebruikers.Add(gebruiker);
            }

            filteredgebruikers.Sort((Gebruiker a, Gebruiker b) =>
            {
                if (a.verified && !b.verified)
                {
                    return(-1);
                }
                if (b.verified && !a.verified)
                {
                    return(1);
                }
                int Arating = ReviewManager.BerekenRating(a.userid);
                int Brating = ReviewManager.BerekenRating(b.userid);
                return(Brating.CompareTo(Arating));
            });

            return(filteredgebruikers.ToArray());
        }
Ejemplo n.º 6
0
        /// <summary>
        /// laad de reviews, sorteerd ze en checked of het ingelogde account al een review heeft.
        /// </summary>
        private void ReviewLoad()
        {
            foreach (var Item in LoadedReviews)
            {
                Item.Dispose();
            }
            LoadedReviews.Clear();

            var Lreviews = ReviewManager.ReviewsOppasser(UserId).ToList <Review>();

            Lreviews.Sort((Review a, Review b) =>
            {
                if (LoginCheck())
                {
                    Gebruiker jezelf = (Gebruiker)SessionManager.GetCurrentUser();
                    if (a.reviewerid == jezelf.userid && b.reviewerid == jezelf.userid)
                    {
                        return(b.reviewid.CompareTo(a.reviewid));
                    }
                    if (a.reviewerid == jezelf.userid)
                    {
                        return(-1);
                    }
                    if (b.reviewerid == jezelf.userid)
                    {
                        return(1);
                    }
                }
                return(b.reviewid.CompareTo(a.reviewid));
            });

            int RVcount = 0;

            foreach (Review RV in Lreviews)
            {
                ReviewPlaatser(RV, RVcount);
                RVcount++;
            }
            if (SessionManager.IsLoggedIn() && OwnReview())
            {
                DiscardButton.Visible = true;
            }

            List <Control> ReviewPItems = new List <Control>()
            {
                TitelLabel, BodyLabel, SchrijfhierLabel, OLijnLabel, ASterLabel, RtitelTextBox, RbodyTextBox,
                Ster1CheckBox, Ster2CheckBox, Ster3CheckBox, Ster4CheckBox, Ster5CheckBox, PReviewButton, ErrorLabel
            };

            bool ownreview = OwnReview();

            foreach (var Item in ReviewPItems)
            {
                Item.Visible = !ownreview;
            }

            if (Lreviews.Count == 0)
            {
                ErrorLabel.Visible = true;
                ErrorLabel.Text    = "Er zijn geen reviews.";
            }
        }
Ejemplo n.º 7
0
        public void MaakResultaat(Gebruiker gebruiker, int pos)
        {
            //Globale variabelen
            int H       = 100;
            int W       = 400;
            int posX    = Convert.ToInt32(500 - 0.5 * W);
            int posY    = 0;
            int bufferY = 15;
            int bufferX = 10;

            //Per blok variabelen
            int blokX = posX;
            int blokY = posY + H * pos;

            //
            // ResultaatLabel
            //
            var ResultaatLabel = new Label();

            ResultaatLabel.Click += delegate
            {
                profiel_ClickEvent(gebruiker);
            };
            ResultaatLabel.AutoSize = true;
            ResultaatLabel.Font     = new Font("Microsoft Sans Serif", 12F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0)));
            ResultaatLabel.Location = new Point(blokX + 70 + bufferX, blokY + bufferY);
            ResultaatLabel.Name     = "ResultaatLabel";
            ResultaatLabel.Size     = new Size(180, 20);
            ResultaatLabel.TabIndex = 57;
            ResultaatLabel.Text     = gebruiker.voornaam + " " + gebruiker.achternaam;
            panel.Controls.Add(ResultaatLabel);
            ResultaatList.Add(ResultaatLabel);
            //
            // ProfielFotoPictureBox
            //
            var ProfielFotoPictureBox = new PictureBox();

            ProfielFotoPictureBox.Click += delegate
            {
                profiel_ClickEvent(gebruiker);
            };
            ProfielFotoPictureBox.Location = new Point(blokX, blokY + bufferY);
            ProfielFotoPictureBox.Name     = "ProfielFotoPictureBox";
            ProfielFotoPictureBox.Size     = new Size(70, 70);
            ProfielFotoPictureBox.TabIndex = 58;
            ProfielFotoPictureBox.TabStop  = false;
            ProfielFotoPictureBox.Image    = ProfielfotoManager.getProfielfoto(gebruiker.userid);
            ProfielFotoPictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
            panel.Controls.Add(ProfielFotoPictureBox);
            ResultaatList.Add(ProfielFotoPictureBox);
            //
            // OppassenUitlaten
            //
            string verzorgen        = "";
            var    OppassenUitlaten = new Label();

            OppassenUitlaten.Click += delegate
            {
                profiel_ClickEvent(gebruiker);
            };
            OppassenUitlaten.AutoSize = true;
            OppassenUitlaten.Location = new Point(blokX + 70 + bufferX, blokY + bufferY + 20);
            OppassenUitlaten.Name     = "OppassenUitlaten";
            OppassenUitlaten.Size     = new Size(136, 13);
            OppassenUitlaten.TabIndex = 59;
            if (gebruiker.oppassen && gebruiker.uitlaten == false)
            {
                verzorgen = " verzorgen.";
            }
            else if (gebruiker.oppassen == false && gebruiker.uitlaten)
            {
                verzorgen = " uitlaten.";
            }
            else if (gebruiker.oppassen && gebruiker.uitlaten)
            {
                verzorgen = " verzorgen en uitlaten.";
            }
            OppassenUitlaten.Text = "Kan een " + gebruiker.diertypes + verzorgen;
            panel.Controls.Add(OppassenUitlaten);
            ResultaatList.Add(OppassenUitlaten);
            //
            // RatingPictureBox
            //
            var RatingPictureBox = new PictureBox();

            RatingPictureBox.Click += delegate
            {
                profiel_ClickEvent(gebruiker);
            };
            RatingPictureBox.Location = new Point(blokX + 70 + bufferX, blokY + bufferY + 20 + 15 + 15);
            RatingPictureBox.Name     = "RatingPictureBox";
            RatingPictureBox.Size     = new Size(100, 20);
            RatingPictureBox.TabIndex = 60;
            RatingPictureBox.TabStop  = false;
            Bitmap[] images = new Bitmap[] { Properties.Resources.ster0, Properties.Resources.ster1,
                                             Properties.Resources.ster2, Properties.Resources.ster3, Properties.Resources.ster4, Properties.Resources.ster5 };
            RatingPictureBox.Image    = images[ReviewManager.BerekenRating(gebruiker.userid)];
            RatingPictureBox.SizeMode = PictureBoxSizeMode.StretchImage;
            panel.Controls.Add(RatingPictureBox);
            ResultaatList.Add(RatingPictureBox);
            //
            // VerifiedPicktureBox
            //
            if (gebruiker.verified)
            {
                var VerifiedPicktureBox = new PictureBox();
                VerifiedPicktureBox.Click += delegate
                {
                    profiel_ClickEvent(gebruiker);
                };
                VerifiedPicktureBox.Location = new Point(blokX + 70 + bufferX + ResultaatLabel.Width, blokY + bufferY);
                VerifiedPicktureBox.Name     = "VerifiedPicktureBox";
                VerifiedPicktureBox.Size     = new Size(20, 20);
                VerifiedPicktureBox.TabIndex = 61;
                VerifiedPicktureBox.TabStop  = false;
                VerifiedPicktureBox.Image    = Properties.Resources.checkbox;
                VerifiedPicktureBox.SizeMode = PictureBoxSizeMode.StretchImage;
                panel.Controls.Add(VerifiedPicktureBox);
                ResultaatList.Add(VerifiedPicktureBox);
            }
            //
            // Locatielabel
            //
            var Locatielabel = new Label();

            Locatielabel.Click += delegate
            {
                profiel_ClickEvent(gebruiker);
            };
            Locatielabel.AutoSize = true;
            Locatielabel.Location = new Point(blokX + 70 + bufferX, blokY + bufferY + 20 + 15);
            Locatielabel.Name     = "Locatielabel";
            Locatielabel.Size     = new Size(51, 13);
            Locatielabel.TabIndex = 62;
            Locatielabel.Text     = gebruiker.woonplaats + " - €" + gebruiker.vraagprijs + " per dag";
            panel.Controls.Add(Locatielabel);
            ResultaatList.Add(Locatielabel);
        }