public static void create_ParentFeedbak_In_DB(ParentsFeedBack pf)
        {
            SqlCommand c = new SqlCommand();

            c.CommandText = "EXECUTE dbo.SP_create_ParentFeedbak @ID, @StudentId, @DT, @Description ";
            c.Parameters.AddWithValue("@ID", pf.getId());
            c.Parameters.AddWithValue("@StudentId", pf.getCreator().getId());
            c.Parameters.AddWithValue("@DT", pf.getDateTime());
            c.Parameters.AddWithValue("@Description", pf.getDescription());
            SQL_CON SC = new SQL_CON();

            SC.execute_non_query(c);
        }
        public static ParentsFeedBack getParentsFeedbackObject(int id)
        {
            ParentsFeedBack pfRes = null;

            foreach (ParentsFeedBack pf in parentsFeedback)
            {
                if (pf.getId() == id)
                {
                    pfRes = pf;
                }
            }

            return(pfRes);
        }
        public static void init_ParentFeedback()
        { //מילוי המערך מתוך בסיס הנתונים
            SqlCommand c = new SqlCommand();

            c.CommandText = "EXECUTE dbo.Get_All_ParentFeedback";
            SQL_CON       SC  = new SQL_CON();
            SqlDataReader rdr = SC.execute_query(c);

            parentsFeedback = new List <ParentsFeedBack>();

            while (rdr.Read())
            {
                ParentsFeedBack pf = new ParentsFeedBack(int.Parse(rdr.GetValue(0).ToString()), getStudentObject(rdr.GetValue(1).ToString()), DateTime.Parse((rdr.GetValue(2).ToString())),
                                                         rdr.GetValue(3).ToString());
                parentsFeedback.Add(pf);
                init_Grades(pf.getId());
            }
        }
 public void setParentFeedback(ParentsFeedBack pf)
 {
     this.parentFeedback = pf;
 }
        private void Submit_parentFeedback_Click(object sender, EventArgs e)
        {
            questionnaire.Refresh();

            List <Grade> collectGrades = new List <Grade>();

            for (int rows = 0; rows < questionnaire.Rows.Count; rows++)
            {
                int questionId = int.Parse(questionnaire.Rows[rows].Cells[0].Value.ToString());
                int count      = 0;
                int grade      = 0;
                questionnaire.UpdateCellValue(rows, 2);
                if (questionnaire.Rows[rows].Cells[2].Value != null)
                {
                    count = count + 1;
                    grade = 1;
                }
                if (questionnaire.Rows[rows].Cells[3].Value != null)
                {
                    count = count + 1;
                    grade = 2;
                }
                if (questionnaire.Rows[rows].Cells[4].Value != null)
                {
                    count = count + 1;
                    grade = 3;
                }
                if (questionnaire.Rows[rows].Cells[5].Value != null)
                {
                    count = count + 1;
                    grade = 4;
                }
                if (questionnaire.Rows[rows].Cells[6].Value != null)
                {
                    count = count + 1;
                    grade = 5;
                }
                if (count > 1 || count < 1)
                {
                    MessageBox.Show("Please make sure you are answering all questions", "Message", MessageBoxButtons.OK);
                    init();
                    break;
                }
                else
                {
                    Grade g = new Grade(Program.getQuestionObject(questionId), grade);
                    collectGrades.Add(g);
                }
            }
            if (collectGrades.Count == questionnaire.Rows.Count)
            {
                ParentsFeedBack pf = new ParentsFeedBack(Program.parentsFeedback.Count + 1, Program.studUser, DateTime.Now, pfdescription.Text);

                Program.parentsFeedback.Add(pf);
                Program.create_ParentFeedbak_In_DB(pf);
                pf.addGrades(collectGrades);
                foreach (Grade gr in collectGrades)
                {
                    gr.setParentFeedback(pf);
                    Program.create_Grade_In_DB(gr);
                }
            }
        }
Example #6
0
 public void addStudentParentFeedback(ParentsFeedBack p)
 {
     parentFeedbacks.Add(p);
 }