Пример #1
0
        //Saves the feedback from the user in the Feedback table
        protected void SubmitButton_Click(Object source, EventArgs args)
        {
            int counter = 1;

            foreach (FeedbackItem a in DatabaseUtilities.GetFeedback(role, title))
            {
                string          qID      = "Q" + (counter).ToString();
                string          rID      = "R" + (counter).ToString();
                string          rbrID    = "RBR" + (counter).ToString();
                string          rbID     = "RB" + (counter).ToString();
                TableRow        qRow     = FeedbackTable.FindControl(rID) as TableRow;
                Label           qLabel   = qRow.FindControl(qID) as Label;
                TableRow        rbrRow   = FeedbackTable.FindControl(rbrID) as TableRow;
                RadioButtonList rbList   = rbrRow.FindControl(rbID) as RadioButtonList;
                string          question = qLabel.Text.Substring(22, qLabel.Text.Length - 27);

                int feedbackCount = DatabaseUtilities.GetFeedbackCount(role, title, question);
                int feedbackTotal = DatabaseUtilities.GetFeedbackTotal(role, title, question);

                feedbackCount = feedbackCount + 1;
                feedbackTotal = feedbackTotal + Convert.ToInt32(rbList.SelectedValue);

                using (var _db = new MPAS.Models.ApplicationDbContext())
                {
                    _db.Database.ExecuteSqlCommand("UPDATE Feedback SET Count = @p0, Total = @p1 WHERE Role = @p2 AND Title = @p3 AND Question = @p4", feedbackCount, feedbackTotal, role, title, question);
                }
                counter++;
            }

            //Saves the mentor's additional comments in the database
            if (currentUser is Mentor && Comment_Textbox.Text != "")
            {
                SqlConnection conn            = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);
                SqlCommand    newFeedbackComm = new SqlCommand("INSERT INTO FeedbackComments (Comment, SNum, Title) " +
                                                               "VALUES(@comment, @snum, @title)");

                //parameterization
                newFeedbackComm.Parameters.Add("@comment", SqlDbType.VarChar);
                newFeedbackComm.Parameters.Add("@snum", SqlDbType.VarChar);
                newFeedbackComm.Parameters.Add("@title", SqlDbType.VarChar);

                //set parameter values
                newFeedbackComm.Parameters["@comment"].Value = Comment_Textbox.Text;
                newFeedbackComm.Parameters["@snum"].Value    = this.User.Identity.Name;
                newFeedbackComm.Parameters["@title"].Value   = title;

                newFeedbackComm.Connection = conn;
                conn.Open();
                using (conn)
                {
                    newFeedbackComm.ExecuteNonQuery();
                }
                conn.Close();
            }
            using (var _db = new MPAS.Models.ApplicationDbContext())
            {
                _db.Database.ExecuteSqlCommand("UPDATE ProfileDetails SET Feedback = 1 WHERE StudentNumber = @p0", this.User.Identity.Name);
            }
            Response.Redirect("~/Default");
        }
Пример #2
0
        //Removes the related question from the current feedback form
        protected void DeleteButton_Click(object sender, EventArgs e)
        {
            LinkButton delButton = sender as LinkButton;
            string     dID       = delButton.ID;
            string     qID       = "Q" + dID.Substring(1, dID.Length - 1);
            string     rID       = "R" + dID.Substring(1, dID.Length - 1);
            TableRow   qRow      = QuestionTable.FindControl(rID) as TableRow;
            Label      qLabel    = qRow.FindControl(qID) as Label;
            string     question  = qLabel.Text.Substring(22, qLabel.Text.Length - 27);

            title = Title_Textbox.Text;

            qRow.Visible = false;
            using (var _db = new MPAS.Models.ApplicationDbContext())
            {
                _db.Database.ExecuteSqlCommand("DELETE FROM Feedback WHERE Question = @p0 AND Role = @p1 AND Title = @p2", question, role, title);
            }

            //Enables the Question textbox and Add button if the maximum amount of questions had been reached before the deletion
            if (DatabaseUtilities.CountFeedback(role, title) == 9)
            {
                Question_Textbox.Enabled = true;
                Add_Button.Enabled       = true;
                Question_Textbox.Text    = "";
            }
        }
Пример #3
0
        //Makes the created feedback form available to the selected audience (mentees or mentors)
        protected void DoneButton_Click(Object source, EventArgs args)
        {
            int roleInt = 1;

            if (role == "Mentee")
            {
                roleInt = 0;
            }

            using (var _db = new MPAS.Models.ApplicationDbContext())
            {
                _db.Database.ExecuteSqlCommand("UPDATE ProfileDetails SET Feedback = 0 WHERE Role = @p0", roleInt);
            }

            Response.Redirect("~/Feedback.aspx");
        }