public void PopulateComments()
 {
     if (State.CurrUser.Role.IsTechnician)
     {
         lstBxComments.DataSource = CommentDB.GetAllCommentsByTickID(CurrTicket);
     }
     else
     {
         lstBxComments.DataSource = CommentDB.GetAllPublicCommentsByTickID(CurrTicket);
     }
 }
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txtBxNewComent.Text))
     {
         bool x = CheckBoxInternal.Checked;
         CommentDB.addComment(CurrTicket.TicketID, State.CurrUser.UserID, txtBxNewComent.Text, x);
         MessageBox.Show("success");
         this.Close();
     }
     else
     {
         MessageBox.Show("Please add something to the text box");
     }
 }
        // Allows users to update their ticket comments, but denies users who try to edit technician comments. NOTE: technicians may edit users tickets
        private void btnEditComment_Click(object sender, EventArgs e)
        {
            Comment commentToEdit = CurrComment();

//            if (State.CurrUser.Username != CurrComment().User.Username && !State.CurrUser.Role.IsTechnician)
//            {
//                MessageBox.Show("You may only edit your own comments");
//            }
//            else
//            {
//
//                if (commentToEdit != null && !(string.IsNullOrWhiteSpace(lstBxComments.Text)))
//                {
//                    commentToEdit.Text = txtBxComment.Text;
//                    CommentDB.UpdateComment(commentToEdit);
//                    MessageBox.Show("Success!");
//                    PopulateComments();
//                }
//                else
//                {
//                    MessageBox.Show(
//                        "Please select an comment to edit, if there are no comments to select from then use the new button to create one.");
//                }
//            }

            if (CurrComment() != null && !(string.IsNullOrWhiteSpace(txtBxComment.Text)))
            {
                if (State.CurrUser.Username != CurrComment().User.Username&& !State.CurrUser.Role.IsTechnician)
                {
                    MessageBox.Show("You may only edit your own comments");
                }
                else
                {
                    commentToEdit.Text = txtBxComment.Text;
                    CommentDB.UpdateComment(commentToEdit);
                    MessageBox.Show("Success!");
                    PopulateComments();
                }
            }
            else
            {
                MessageBox.Show(
                    "Please select an comment to edit, if there are no comments to select from then use the new button to create one.");
                PopulateComments();
            }
        }
        private void btnDeleteComment_Click(object sender, EventArgs e)
        {
            if (CurrComment() != null)
            {
                // This will disallow deleting of comments only if they belong to the user or if the current logged in user is a tech
                if (State.CurrUser.Username != CurrComment().User.Username&& !State.CurrUser.Role.IsTechnician)
                {
                    MessageBox.Show("Access Denied");
                }

                else
                {
                    CommentDB.DeleteComment(CurrComment());
                    PopulateComments();
                }
            }
            else
            {
                MessageBox.Show(
                    "No Comment selected");
                PopulateComments();
            }
        }