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);
        }
Пример #2
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));
                }
            }
        }