private void LoadProjectsToList()
        {
            //gets all the projects stored in the DB and puts them in a list
            //this will now populate multiple lists (for now it will have all projects
            // named 'userprojects' (projects the logged in user made) and 'projects' (all projects)
            // THESE ARE EXAMPLES, WE SHOULD FIGURE OUT WHAT PROJECTS PEOPLE WILL WANT TO SEE
            // this is also written as dashboard will employ similar methods of panel drawings


            DataTable userProjects = Connection.GetDbConn().GetDataTable(SqlProject.GetUserProjects(UserObject.loggedUser.iduser));

            foreach (DataRow userProject in userProjects.Rows)
            {
                ProjectObject up = new ProjectObject(userProject["idproject"].ToString(),
                                                     userProject["projName"].ToString(), userProject["user"].ToString(), userProject["description"].ToString(),
                                                     Convert.ToInt32(userProject["isPrivate"]));
                ProjectObject.UserProjects.Add(up);
            }
            //projectLists.Add(ProjectObject.UserProjects);

            DataTable projects = Connection.GetDbConn().GetDataTable(SqlProject.GetProjects());

            foreach (DataRow project in projects.Rows)
            {
                ProjectObject up1 = new ProjectObject(project["idproject"].ToString(),
                                                      project["projName"].ToString(), project["user"].ToString(), project["description"].ToString(),
                                                      Convert.ToInt32(project["isPrivate"]));
                ProjectObject.Projects.Add(up1);
            }
            projectLists.Add(ProjectObject.Projects);
            projectLists.Add(ProjectObject.UserProjects);
        }
Esempio n. 2
0
        private void RequestAccess(object sender, EventArgs e, ProjectObject project)
        {
            // create a follow project object which will notify the project poster that a user wants access
            try
            { // creates follow table row, as this is a private project (public projects are followed on bugsform)
                // sends a notification to the poster of the project to advise the user wants access.
                DateTime         now         = DateTime.Now;
                string           timestamp   = now.ToString("yyyy-MM-dd HH:mm:ss");
                string           timestampTo = now.AddSeconds(5).ToString("yyyy-MM-dd HH:mm:ss");
                SqlProject       sq          = new SqlProject();
                SqlNotifications notif       = new SqlNotifications();

                Connection.GetDbConn().CreateCommand(SqlFollow.FollowProject(UserObject.loggedUser.iduser, project.idproject));

                notif.InsertNotification(UserObject.loggedUser.iduser, project.idproject, "", "", "request access", "", now);

                DataSet getNotifId = Connection.GetDbConn().GetDataSet($"SELECT idnotification FROM notification" +
                                                                       $" WHERE usernotif = {UserObject.loggedUser.iduser} AND project = {project.idproject} AND timestamp BETWEEN '{timestamp}' AND '{timestampTo}'");
                string notifId = getNotifId.Tables[0].Rows[0].ItemArray.GetValue(0).ToString();

                DataSet getProjectOwner = Connection.GetDbConn().GetDataSet($"SELECT user FROM project WHERE idproject = { project.idproject}");
                string  projOwner       = getProjectOwner.Tables[0].Rows[0].ItemArray.GetValue(0).ToString();

                notif.InsertToNotify(notifId, projOwner, "0");
                MessageBox.Show("Request sent to project creator");
            }
            catch (Exception)
            {
                MessageBox.Show("Request already sent");
            }
        }
Esempio n. 3
0
        private void ProjectClicked(object sender, EventArgs e, ProjectObject project)
        {
            // check if project is private, if it is then
            // if(project.isPrivate == 1)

            /* if ((project.user != UserObject.loggedUser.iduser) && project.isPrivate == 1) // if the user isn't the project owner
             * {
             *   // go to db, try to return a row from allowedusers which has this project id and this userid
             *   // formname. showdialouge
             *
             *   DataTable isUserAllowed = Connection.GetDbConn().GetDataTable(SqlProject.CheckUserAccess(UserObject.loggedUser.iduser, project.idproject));
             *
             *  if (isUserAllowed.Rows.Count == 0) // if no result
             *  {
             *
             *  }
             *
             * } */
            // checked if user is in this project's 'allowUsers' table
            // if so, open displaybugsform, if not then show message box advising of no access
            // post project - poster is added to allowedaccess table + project is created
            ProjectObject.Projects.Clear(); //clear the list, we will need to clear all lists when more are added
            // i dont want to have to pass the display instance all the way to here
            ProjectObject.UserProjects.Clear();
            display.DisplayBugsForm(project.idproject.ToString());
        }
Esempio n. 4
0
        private Label CreateDescriptionLabel(ProjectObject project, Panel toAddTo)
        {
            Label Label_ProjectDescription = new Label
            {
                Location    = new Point(16, (toAddTo.Height / 4) + 16),
                Font        = new Font("Arial", 8f, FontStyle.Bold),
                ForeColor   = Color.FromArgb(82, 82, 82),
                MaximumSize = new Size(toAddTo.Width - 32, toAddTo.Height / 2),
                AutoSize    = true,
                Text        = project.description
            };

            return(Label_ProjectDescription);
        }
Esempio n. 5
0
        private Label CreateNameLabel(ProjectObject project, Panel toAddTo)
        {
            Label Label_ProjectName = new Label
            {
                Location    = new Point(16, 16),
                Font        = new Font("Arial", 14f, FontStyle.Bold),
                ForeColor   = Color.FromArgb(82, 82, 82),
                MaximumSize = new Size(toAddTo.Width - 32, toAddTo.Height / 4),
                AutoSize    = true,
                Text        = project.projName
            };

            return(Label_ProjectName);
        }