private void SaveMarksAmdOutcomesBtn_Click(object sender, RoutedEventArgs e)
 {
     foreach (UIElement Child in answersOutcomesMatrix.Children)
     {
         if (Child is TextBox)
         {
             QuestionModel question      = (QuestionModel)answersOutcomesMatrix.RowDefinitions[Grid.GetRow(Child)].Tag;
             int           questionIndex = MyExam.ExamGroups[GroupIndex].Questions.FindIndex(q => q.Name == question.Name);
             decimal       mark          = decimal.Parse(((TextBox)Child).Text);
             MyExam.ExamGroups[GroupIndex].Questions[questionIndex].Mark = mark;
         }
         else if (Child is CheckBox)
         {
             if (((CheckBox)Child).IsChecked == true)
             {
                 CourseOutcomeModel outcome  = (CourseOutcomeModel)answersOutcomesMatrix.ColumnDefinitions[Grid.GetColumn(Child)].Tag;
                 QuestionModel      question = (QuestionModel)answersOutcomesMatrix.RowDefinitions[Grid.GetRow(Child)].Tag;
                 int questionIndex           = MyExam.ExamGroups[GroupIndex].Questions.FindIndex(q => q.Name == question.Name);
                 MyExam.ExamGroups[GroupIndex].Questions[questionIndex].QuestionOutcomes.Add(outcome);
             }
         }
     }
     saveMarksAmdOutcomesBtn.IsEnabled = false;
     answersOutcomesMatrix.IsEnabled   = false;
 }
Exemplo n.º 2
0
        private void CreateCourseBtn_Click(object sender, RoutedEventArgs e)
        {
            if (ValidForm())
            {
                if (!update)
                {
                    CourseModel model = new CourseModel
                    {
                        Name    = nameText.Text,
                        Code    = codeText.Text,
                        EduYear = (EducationalYearModel)eduYearCombobox.SelectedItem
                    };
                    foreach (OutcomeUserControl outcome in outcomesList.Children)
                    {
                        CourseOutcomeModel cO = new CourseOutcomeModel
                        {
                            Name        = outcome.nameText.Text,
                            Description = outcome.descriptionText.Text
                        };
                        model.CourseOutcomes.Add(cO);
                    }
                    GlobalConfig.Connection.CreateCourse(model);
                    CallingWindow.CourseComplete(model);
                }
                else
                {
                    course.Name    = nameText.Text;
                    course.Code    = codeText.Text;
                    course.EduYear = (EducationalYearModel)eduYearCombobox.SelectedItem;
                    foreach (OutcomeUserControl outcome in outcomesList.Children)
                    {
                        TagData td = (TagData)outcome.Tag;

                        CourseOutcomeModel cO = new CourseOutcomeModel
                        {
                            Id          = td.Id,
                            Name        = outcome.nameText.Text,
                            Description = outcome.descriptionText.Text,
                            CourseId    = course.Id
                        };
                        if (td.IsNew == true)
                        {
                            GlobalConfig.Connection.CreateCourseOutcome(cO);
                        }
                        else
                        {
                            GlobalConfig.Connection.UpdateCourseOutcome(cO);
                        }
                    }
                    foreach (var delete in outcomesToDelete)
                    {
                        GlobalConfig.Connection.CourseOutcome_Delete(delete);
                    }
                    GlobalConfig.Connection.UpdateCourse(course);
                    CallingWindow.CourseUpdateComplete(course);
                }
                this.Close();
            }
        }
Exemplo n.º 3
0
 public void CreateCourseOutcome(CourseOutcomeModel model)
 {
     using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(databaseName)))
     {
         var p = new DynamicParameters();
         p.Add("@Name", model.Name);
         p.Add("@Description", model.Description);
         p.Add("@CourseId", model.CourseId);
         p.Add("@id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);
         connection.Execute("dbo.spCourseOutcomes_Insert", p, commandType: CommandType.StoredProcedure);
         model.Id = p.Get <int>("@id");
     }
 }
Exemplo n.º 4
0
        public void UpdateCourseOutcome(CourseOutcomeModel model)
        {
            using (IDbConnection connection = new SqlConnection(GlobalConfig.CnnString(databaseName)))
            {
                var p = new DynamicParameters();
                p.Add("@Id", model.Id);
                p.Add("@Name", model.Name);
                p.Add("@Description", model.Description);
                p.Add("@CourseId", model.CourseId);

                connection.Execute("dbo.spCourseOutcomes_UpdateByCourseOutcomesId", p, commandType: CommandType.StoredProcedure);
            }
        }