Beispiel #1
0
 private void BugClicked(object sender, EventArgs e, BugObject selectedBug)
 {
     //BugObject.Bugs.Clear();
     // if a bug is referenced, should be able to find that bug object in this list so
     // that the label showing that bug's id is clickable in the info form
     display.DisplayBugInfoForm(selectedBug);
 }
Beispiel #2
0
 private void BugClicked(object sender, EventArgs e, BugObject id)
 {
     BugObject.followedBugs.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
     BugObject.recentBugs.Clear();
     BugObject.toDoBugs.Clear();
     display.DisplayBugInfoForm(id);
 }
        private BugObject GetBug(string bugId) // this should be a public function in bugobject class
        {
            DataTable followset = Connection.GetDbConn().GetDataTable(SqlBug.GetOneBug(bugId));
            BugObject followbug = new BugObject(followset.Rows[0]["idbug"].ToString(),
                                                followset.Rows[0]["title"].ToString(), followset.Rows[0]["description"].ToString(), followset.Rows[0]["location"].ToString(),
                                                followset.Rows[0]["status"].ToString(),
                                                followset.Rows[0]["poster"].ToString(), followset.Rows[0]["project"].ToString(), followset.Rows[0]["priority"].ToString(),
                                                followset.Rows[0]["referencedBug"].ToString(), Convert.ToDateTime(followset.Rows[0]["timePosted"]));

            return(followbug);
        }
 public PostUpdateForm(Window window, BugObject selectedBug)
 {
     InitializeComponent();
     display    = window;
     Size       = new Size(display.Width, display.Height);
     currentBug = selectedBug;
     //if the bug's current status is solved, and the logged in user didnt post the bug, only display solved
     // this is to only allow the user who reported a bug to re-open a bug (and post an update saying why they did this)
     // stops anyone from being able to change any bug's status from solved to in prog
     ComboBoxOptions(currentBug);
 }
Beispiel #5
0
 public void DisplayPostUpdateForm(BugObject selectedBug)
 {
     currentForm = "DisplayPostUpdateForm";
     Panel_FormContent.Controls.Clear();
     //Controls.Clear();
     postUpdateForm = new PostUpdateForm(this, selectedBug) //,id
     {
         TopLevel = false
     };
     Panel_FormContent.Controls.Add(postUpdateForm);
     ResetButtons();
     //Controls.Add(bugReportForm);
     postUpdateForm.Show();
 }
Beispiel #6
0
 public void DisplayBugInfoForm(BugObject selectedBug)
 {
     currentForm = "DisplayBugInfoForm";
     Panel_FormContent.Controls.Clear();
     //Controls.Clear();
     bugInfoForm = new BugInfoForm(this, selectedBug)
     {
         TopLevel = false
     };
     Panel_FormContent.Controls.Add(bugInfoForm);
     ResetButtons();
     //Controls.Add(bugReportForm);
     bugInfoForm.Show();
 }
Beispiel #7
0
        private void LoadBugsToList(string projectId)
        {
            //gets all the projects stored in the DB and puts them in a list
            DataTable bugs = Connection.GetDbConn().GetDataTable(SqlBug.GetBugs(projectId));

            foreach (DataRow bug in bugs.Rows)
            {
                BugObject up = new BugObject(bug["idbug"].ToString(),
                                             bug["title"].ToString(), bug["description"].ToString(), bug["location"].ToString(), bug["status"].ToString(),
                                             bug["poster"].ToString(), bug["project"].ToString(), bug["priority"].ToString(),
                                             bug["referencedBug"].ToString(), Convert.ToDateTime(bug["timePosted"]));
                BugObject.Bugs.Add(up);
            }
        }
 private void ComboBoxOptions(BugObject selectedBug)
 {
     if (selectedBug.status == "Solved" && selectedBug.poster != UserObject.loggedUser.iduser)
     {
         // if the bug is marked as solved and you didn;t post it,
         ComboBox_Status.Items.Add("Solved");
         // you cant change its status
     }
     else
     {
         ComboBox_Status.Items.Add("in progress");
         ComboBox_Status.Items.Add("Solved");
     }
 }
        private void LoadProfileInfo(string userId)
        { //going to load user's projects, projects they're following and bugs they are following
          //bugs the user has posted on that aren't yet solved
          //bugs the user posted that have new posts


            //statistics: users posted, fixed, in progress
            //in progress, get all bugs with in progress status that user either made or posted on
            DataTable bugsPosted = Connection.GetDbConn().GetDataTable(SqlUser.GetNumberBugs(userId));

            foreach (DataRow result in bugsPosted.Rows)
            {
                postedBugNo     = result["total"].ToString();
                solvedBugNo     = result["solved"].ToString();
                inProgressBugNo = result["progress"].ToString();
            }
            Label_ProgressBugs.Text = inProgressBugNo;
            Label_SolvedBugs.Text   = solvedBugNo;
            Label_TotalBugs.Text    = postedBugNo;


            //to do list is 5 bugs user posted of high imprtance and oldest at the top
            DataTable toDoList = Connection.GetDbConn().GetDataTable(SqlBug.ToDoList(userId));

            foreach (DataRow toDo in toDoList.Rows)
            {
                BugObject up = new BugObject(toDo["idbug"].ToString(),
                                             toDo["title"].ToString(), toDo["description"].ToString(), toDo["location"].ToString(),
                                             toDo["status"].ToString(), toDo["poster"].ToString(),
                                             toDo["project"].ToString(), toDo["priority"].ToString(), toDo["referencedBug"].ToString(),
                                             Convert.ToDateTime(toDo["timePosted"]));
                BugObject.toDoBugs.Add(up);
            }

            // the most recent bugs this user has posted, not ones they have updates on as notification bar does this
            DataTable recentList = Connection.GetDbConn().GetDataTable(SqlBug.RecentList(userId));

            foreach (DataRow recent in recentList.Rows)
            {
                BugObject up = new BugObject(recent["idbug"].ToString(),
                                             recent["title"].ToString(), recent["description"].ToString(), recent["location"].ToString(),
                                             recent["status"].ToString(), recent["poster"].ToString(),
                                             recent["project"].ToString(), recent["priority"].ToString(), recent["referencedBug"].ToString(),
                                             Convert.ToDateTime(recent["timePosted"]));
                BugObject.recentBugs.Add(up);
            }
            //adds these 2 lists into a list
            bugLists.Add(BugObject.toDoBugs);
            bugLists.Add(BugObject.recentBugs);
        }
Beispiel #10
0
        //how to go back to the correct project after a bug has been selected?
        //bug info loaded so we can use the project section of it
        public BugInfoForm(Window window, BugObject selectedBug)
        {
            //this form should show info on the bug such as title, description AND updates
            //this form should show the user a button to add an update on the bug

            InitializeComponent();
            display           = window;
            Label_RefBug.Text = "";
            LoadUpdatesToList(selectedBug.idbug);
            Size       = new Size(display.Width, display.Height);
            currentBug = selectedBug;
            //label1.Text = this.Size.ToString();
            LoadInfo();
            DoResize();
            FollowButton();
        }
Beispiel #11
0
        /// <summary>
        /// on page load, get info about the selected bug from the DB, changes labels to display info
        /// </summary>
        /// <param name="bugId"></param>
        private void LoadInfo()
        {
            //needs to populate labels and rich text box

            /*DataTable bugInfo = Connection.GetDbConn().GetDataTable(SqlBug.GetOneBug(bugId));
             * DataRow row = bugInfo.Rows[0];
             *
             * Label_Title.Text = row["title"].ToString();
             * RichText_Description.Text = row["description"].ToString();
             * Label_Poster.Text = row["poster"].ToString(); //this will show id, either use FK to get name or translate */

            Label_Title.Text          = currentBug.title;
            RichText_Description.Text = currentBug.description;
            Label_Poster.Text         = currentBug.poster;
            Label_Priority.Text       = currentBug.priority;
            Label_Status.Text         = currentBug.status;
            // as bug list is no longer cleared when going into the bug info form, we can use the referenced
            // bug's id to find the ref'd bug in the list so we have a bug to pass into the bugclicked
            // method. we can also get its title to display as label text.
            if (currentBug.referencedBug == "0" || currentBug.referencedBug == "")
            {
                Label_RefBug.Text = "";
            }
            else
            { // going to a bug with a referenced bug from the notification screen means there's no bug list to check
                // to get around this, catch an exception by using the ref'd bug's id to make a bug object
                BugObject refBug = BugObject.Bugs.Find(i => i.idbug == currentBug.referencedBug);
                try
                {
                    Label_RefBug.Text = refBug.title;

                    Label_RefBug.Click += new System.EventHandler((sender, e) => BugClicked(sender, e, refBug));
                }
                catch (System.NullReferenceException)
                {
                    DataTable followset = Connection.GetDbConn().GetDataTable(SqlBug.GetOneBug(currentBug.referencedBug));
                    BugObject followbug = new BugObject(followset.Rows[0]["idbug"].ToString(),
                                                        followset.Rows[0]["title"].ToString(), followset.Rows[0]["description"].ToString(), followset.Rows[0]["location"].ToString(),
                                                        followset.Rows[0]["status"].ToString(),
                                                        followset.Rows[0]["poster"].ToString(), followset.Rows[0]["project"].ToString(), followset.Rows[0]["priority"].ToString(),
                                                        followset.Rows[0]["referencedBug"].ToString(), Convert.ToDateTime(followset.Rows[0]["timePosted"]));
                    Label_RefBug.Text = followbug.title;

                    Label_RefBug.Click += new System.EventHandler((sender, e) => BugClicked(sender, e, followbug));
                }
            }
        }
        private void LoadNotifications(string userid)
        {
            // get all results from notification table where user = userid
            // join notiftype AND notification tables where notification.idnotification = notiftype.toNotifyId
            // order by unread first and timestamp
            // depending on notif type, do something with related id
            // types are: reqUserAccess, newBug, newPost, newFollowProj, newFollowBug, bugStatus, projStatus
            // may need type to advise user of a comment written on their update
            ///// ///// ///// ///// ///// ///// ///// ///// ///// ///// ///// ///// ///// /////
            // example: if notifType == reqUserAccess: panelText = USER foo HAS REQUESTED ACCESS TO PROJECT bar
            // foo = SELECT user.username WHERE iduser = notiftype.relatedId
            // bar = notification.project
            // example: if notifType == newBug: panelText = USER foo HAS POSTED NEW BUG bar IN PROJECT wiz
            // foo = SELECT user.username FROM user WHERE userid = notiftype.relatedid
            // bar = notification.bug
            // wiz = notification.project
            ///// ///// ///// ///// ///// ///// ///// ///// ///// ///// ///// ///// ///// /////
            // inserting a new bug needs to create a new line for all userids
            // users = select users, isfollow, isallow, idnotification from notification where project == thisProject AND follow == 1
            // for each user in users
            // INSERT INTO notiftype VALUES toNotify, type, relatedId, bug, timestamp, read (default as false)
            // idnotification, newBug, newbug.poster, bug'sID (will have to insert then deref id), datetime.now
            //  ///// ///// ///// ///// ///// ///// ///// ///// ///// ///// ///// ///// /////
            // a new update on a bug will need to notify all users who are following the bug
            // INSERT INTO update (postedBy, comment, bug, status, timestamp)
            // usersToNotify = SELECT * FROM notifications WHERE project == thisProject
            // for user in usersToNotify
            // INSERT INTO notiftype VALUES toNotify, type, relatedId, bug, timestamp, read
            // user.idnotification, newPost, update's.id, bug, timestamp
            // if it's a new post then user will want to see the bug's updated status - can deref relatedid for status

            DataTable table = Connection.GetDbConn().GetDataTable($"SELECT * FROM tonotify INNER JOIN notification as n " +
                                                                  $"on n.idnotification = tonotify.notifid WHERE tonotify.userid = {UserObject.loggedUser.iduser} " +
                                                                  $"ORDER BY n.timestamp ASC");
            int panelYpos = 16;

            foreach (DataRow row in table.Rows)
            {
                string labeltext     = "";
                string userNotifFrom = row[4].ToString();
                string projId        = row[5].ToString();
                string bugId         = row[6].ToString();
                string timestamp     = row[10].ToString();
                string status        = row[9].ToString();
                // display the notification differently depending on type, add on click to show related info
                // on click function will differ for each notification however the .click function
                // has to be defined when the label text is created
                switch (row[8])
                {
                case "new bug":
                    labeltext = "New bug: " + bugId + " on project: " + projId + " from user: "******" at: " + timestamp + ".";
                    BugObject newbug     = GetBug(bugId);
                    Label     notifLabel = new Label
                    {
                        Location  = new Point(16, panelYpos),
                        Font      = new Font("Arial", 8f, FontStyle.Bold),
                        ForeColor = Color.FromArgb(82, 82, 82),
                        //MaximumSize = new Size(Panel_BugPanel.Width - 32, Panel_BugPanel.Height / 4),
                        AutoSize = true,
                        Text     = labeltext
                    };
                    notifLabel.Click += new System.EventHandler((sender, e) => BugClicked(sender, e, newbug));
                    Panel_MasterPanel.Controls.Add(notifLabel);
                    break;

                case "follow":
                    labeltext = "New follower: " + userNotifFrom + " on project: " + projId + " at: " + timestamp;
                    Label followLabel = new Label
                    {
                        Location  = new Point(16, panelYpos),
                        Font      = new Font("Arial", 8f, FontStyle.Bold),
                        ForeColor = Color.FromArgb(82, 82, 82),
                        //MaximumSize = new Size(Panel_BugPanel.Width - 32, Panel_BugPanel.Height / 4),
                        AutoSize = true,
                        Text     = labeltext
                    };
                    followLabel.Click += new System.EventHandler((sender, e) => ProjectClicked(sender, e, projId));
                    Panel_MasterPanel.Controls.Add(followLabel);

                    break;

                case "request access":

                    BugObject accessbug = GetBug(bugId);
                    labeltext = "User: "******" has requested access to private project: "
                                + projId + " at: " + timestamp;
                    Label requestLabel = new Label
                    {
                        Location  = new Point(16, panelYpos),
                        Font      = new Font("Arial", 8f, FontStyle.Bold),
                        ForeColor = Color.FromArgb(82, 82, 82),
                        //MaximumSize = new Size(Panel_BugPanel.Width - 32, Panel_BugPanel.Height / 4),
                        AutoSize = true,
                        Text     = labeltext
                    };
                    // needs to make 2 buttons, accept/ decline / click for user profile
                    requestLabel.Click += new System.EventHandler((sender, e) => BugClicked(sender, e, accessbug));
                    Panel_MasterPanel.Controls.Add(requestLabel);
                    break;

                case "bugfollow":
                    labeltext = "User: "******" has followed bug: "
                                + bugId + " at: " + timestamp;
                    BugObject followBug      = GetBug(bugId);
                    Label     bugFollowLabel = new Label
                    {
                        Location  = new Point(16, panelYpos),
                        Font      = new Font("Arial", 8f, FontStyle.Bold),
                        ForeColor = Color.FromArgb(82, 82, 82),
                        //MaximumSize = new Size(Panel_BugPanel.Width - 32, Panel_BugPanel.Height / 4),
                        AutoSize = true,
                        Text     = labeltext
                    };
                    // needs to make 2 buttons, accept/ decline / click for user profile
                    bugFollowLabel.Click += new System.EventHandler((sender, e) => BugClicked(sender, e, followBug));
                    Panel_MasterPanel.Controls.Add(bugFollowLabel);

                    break;

                case "new update":

                    labeltext = "User: "******" has posted an update on bug: "
                                + bugId + " at: " + timestamp + ", its new status is: " + status;
                    BugObject updateBug   = GetBug(bugId);
                    Label     updateLabel = new Label
                    {
                        Location  = new Point(16, panelYpos),
                        Font      = new Font("Arial", 8f, FontStyle.Bold),
                        ForeColor = Color.FromArgb(82, 82, 82),
                        //MaximumSize = new Size(Panel_BugPanel.Width - 32, Panel_BugPanel.Height / 4),
                        AutoSize = true,
                        Text     = labeltext
                    };
                    // needs to make 2 buttons, accept/ decline / click for user profile
                    updateLabel.Click += new System.EventHandler((sender, e) => BugClicked(sender, e, updateBug));
                    Panel_MasterPanel.Controls.Add(updateLabel);

                    break;
                }

                //add height of panel plus 10 pixel gap
                panelYpos += 56;
            }
        }
 private void BugClicked(object sender, EventArgs e, BugObject bug)
 {
     display.DisplayBugInfoForm(bug);
 }