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); }
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 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); }
private void Button_PostUpdate_Click(object sender, EventArgs e) { string comment, status, postedBy, bug, timeString, timeStringTo; DateTime now = DateTime.Now; timeString = now.ToString("yyyy-MM-dd HH:mm:ss"); timeStringTo = now.AddSeconds(5).ToString("yyyy-MM-dd HH:mm:ss"); comment = RichText_Update.Text; status = ComboBox_Status.Text; postedBy = UserObject.loggedUser.username; //comment bug = currentBug.idbug; SqlBug updateStatus = new SqlBug(); updateStatus.UpdateStatus(bug, status); SqlUpdate newUpdate = new SqlUpdate(); newUpdate.InsertUpdate(postedBy, comment, bug, status, timeString); Thread.Sleep(1000); // to try and allow status update to reflect when form reloaded DataSet toGetUpdateId = Connection.GetDbConn().GetDataSet($"SELECT idupdate FROM `update`" + $" WHERE postedBy = '{postedBy}' AND timestamp BETWEEN '{timeString}' AND '{timeStringTo}'"); //DataSet ds = Connection.GetDbConn().GetDataSet($"SELECT @@identity"); string newUpdateId = toGetUpdateId.Tables[0].Rows[0].ItemArray.GetValue(0).ToString(); //i dont there's there's enough time inbetween this update and the form displaying for the // status change to register on the db, changed so that bug's status is changed first to see if this helps. SqlNotifications notif = new SqlNotifications(); notif.InsertNotification(UserObject.loggedUser.iduser, currentBug.project, currentBug.idbug, newUpdateId, "new update", status, now); DataSet getNotifId = Connection.GetDbConn().GetDataSet($"SELECT idnotification FROM notification" + $" WHERE usernotif = {UserObject.loggedUser.iduser} AND project = {currentBug.project} AND timestamp BETWEEN '{timeString}' AND '{timeStringTo}'"); string notifId = getNotifId.Tables[0].Rows[0].ItemArray.GetValue(0).ToString(); DataTable getBugFollowers = Connection.GetDbConn().GetDataTable($"SELECT user FROM followbug WHERE bug = { currentBug.idbug}"); foreach (DataRow follower in getBugFollowers.Rows) { notif.InsertToNotify(notifId, follower["user"].ToString(), "0"); } //string projOwner = getProjectOwner.Tables[0].Rows[0].ItemArray.GetValue(0).ToString(); display.DisplayBugInfoForm(currentBug); }
/// <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)); } } }
/// <summary> /// this logic generates the clickable panels that display projects /// </summary> /// <param name="toDrawTo"></param> /// <param name="dataset"></param> /// <param name="window"></param> public void BugPanels(Panel containerPanel, List <BugObject> dataset, Window window) { bugPanelList.Clear(); // clear panel list display = window; containerPanel.Controls.Clear(); foreach (BugObject bug in dataset) { //For each project object in the database, make a panel, display elements, give it an on click method // maybe have a count of how many updates there are on a bug DataTable updates = Connection.GetDbConn().GetDataTable(SqlBug.UpdateCount(bug.idbug)); foreach (DataRow result in updates.Rows) { updateCount = result["count"].ToString(); } Panel Panel_BugPanel = new Panel { //Name = "ProjectPanel_" + bug.idproject, BackColor = Color.White, Width = containerPanel.Width - 32, Height = 32, }; Label Label_BugTitle = new Label { //Name = "ProjectName_" + bug.idproject, Location = new Point(16, Panel_BugPanel.Height / 2 - 4), 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 = bug.title }; Label Label_BugUpdates = new Label { //Name = "ProjectDescription_" + bug.idproject, Location = new Point(Panel_BugPanel.Width / 3, Panel_BugPanel.Height / 2 - 4), Font = new Font("Arial", 8f, FontStyle.Bold), ForeColor = Color.FromArgb(82, 82, 82), //MaximumSize = new Size(Panel_BugPanel.Width - 32, Panel_BugPanel.Height / 2), //AutoSize = true, Text = updateCount }; //on click method is applied on each panel generated as dataset list is iterated over //we can move logic into drawpanels class Panel_BugPanel.Click += new EventHandler((sender, e) => BugClicked(sender, e, bug)); Label_BugTitle.Click += new EventHandler((sender, e) => BugClicked(sender, e, bug)); Label_BugUpdates.Click += new EventHandler((sender, e) => BugClicked(sender, e, bug)); //Controls.Add(Panel_DisplayProjects); isn't the base panel added as a control from the design form? containerPanel.Controls.Add(Panel_BugPanel); Panel_BugPanel.Controls.Add(Label_BugTitle); Panel_BugPanel.Controls.Add(Label_BugUpdates); //problem is here, how would you take this outside of the loop? //GridDraw(toDrawTo, Panel_ProjectPanel, i); //could use .Count of the dataset (to get how many projects need to be made) //list of panels? bugPanelList.Add(Panel_BugPanel); } PlacePanelYaxis(containerPanel, bugPanelList); bugPanelList.Clear(); //needs to clear the panel list once projects are drawn to their panels so master panels can be //located afterwards }
/// <summary> /// Save button clicked, makes a new bug in the database with entered information /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Save_Click(object sender, EventArgs e) { string title, description, location, status, poster, project, referencedBug, priority; DateTime timePosted; //var referencedBug = ""; title = TextBox_Title.Text; description = RichText_Description.Text; location = TextBox_Location.Text; timePosted = System.DateTime.Now; status = "In Progress"; //maybe on log in have a class (loggedUser) which stores the logged in user's ID, then go to that class //for this info, for now we're using 41 as test user in DB poster = UserObject.loggedUser.iduser; project = currentProject; var prior = (Item)ComboBox_Priority.SelectedItem; priority = prior.Value; if (Combo_RefExistBug.SelectedItem == null) { referencedBug = "0"; } else { referencedBug = Combo_RefExistBug.SelectedValue.ToString(); } SqlBug newBug = new SqlBug(); newBug.InsertBug(title, description, location, timePosted, status, poster, project, priority, referencedBug); // now we need to get the bug's id Thread.Sleep(2000); //string time = timePosted.ToString("yyyy-MM-dd HH:mm:ss"); DataSet ds = Connection.GetDbConn().GetDataSet($"SELECT idbug FROM bug WHERE poster = {poster} AND " + $"title = '{title}' AND project = {project}"); //DataSet ds = Connection.GetDbConn().GetDataSet($"SELECT @@identity"); string newBugId = ds.Tables[0].Rows[0].ItemArray.GetValue(0).ToString(); // not we make a notification for the new bug SqlNotifications notif = new SqlNotifications(); notif.InsertNotification(poster, project, newBugId, "", "new bug", status, timePosted); Thread.Sleep(2000); // get the notification's id DataSet getNotifId = Connection.GetDbConn().GetDataSet($"SELECT idnotification FROM notification" + $" WHERE usernotif = {poster} AND project = {project} AND bug = {newBugId} AND `update` = '{"new bug"}'"); string newNotifId = getNotifId.Tables[0].Rows[0].ItemArray.GetValue(0).ToString(); // now we can make a line to notify each user of this new bug // creates a line for each user where the user is following this project DataTable toNotify = Connection.GetDbConn().GetDataTable($"SELECT user FROM followproject " + $"WHERE project = {project}"); Connection.connToDb.Close(); // advising conn already open for query below foreach (DataRow follower in toNotify.Rows) { notif.InsertToNotify(newNotifId, follower["user"].ToString(), "0"); } //InsertBug(string title, int description, string location, DateTime timePosted, string status, //string poster, string project, string priority) display.DisplayBugsForm(currentProject); }