Exemplo n.º 1
0
 public bool checkGradeThemeData(GradeTheme newGradetheme,
                                 List <GradeTheme> oldGradeThemes)
 {
     if (newGradetheme.Contains(oldGradeThemes) | newGradetheme.GthName == null)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemplo n.º 2
0
 public bool chechIfGthExistsByName(GradeTheme newGradeTheme,
                                    List <GradeTheme> gradeThemes)
 {
     foreach (GradeTheme gradeTheme in gradeThemes)
     {
         if (gradeTheme.GthName == newGradeTheme.GthName)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 3
0
 public bool checkIfGradeThemeReferenceExists(GradeTheme newGradeTheme,
                                              List <GradeTheme> gradeThemes)
 {
     foreach (GradeTheme gradeTheme in gradeThemes)
     {
         if (gradeTheme.GthRetake_GthId == newGradeTheme.GthRetake_GthId &
             gradeTheme.GthRetake_GthId != null & newGradeTheme.GthRetake_GthId != null)
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 4
0
        public bool createNewGradeTheme(GradeTheme gradeTheme)
        {
            if (!(correction.checkGradeThemeData(gradeTheme, getAllGradeThemes())))
            {
                Console.WriteLine("Grade's theme is incorrect or exists in database."); return(false);
            }

            string sqlCreateNewGradeTheme;

            if (gradeTheme.GthRetake_GthId == null)
            {
                sqlCreateNewGradeTheme = $"INSERT INTO GradeThemes " +
                                         $"(GthName, Gth_SubId, Gth_TeaId, Gth_ClaId, Gth_DepCSTid) " +
                                         $"VALUES ('{gradeTheme.GthName}',{gradeTheme.GthDepClaSubTea._SubId},{gradeTheme.GthDepClaSubTea._TeaId}, " +
                                         $"{gradeTheme.GthDepClaSubTea._ClaId}, {gradeTheme.GthDepClaSubTea.DepCSTid})";
            }
            else
            {
                sqlCreateNewGradeTheme = $"INSERT INTO GradeThemes " +
                                         $"(GthName, Gth_SubId, Gth_TeaId, Gth_ClaId, GthRetake_GthId, Gth_DepCSTid) " +
                                         $"VALUES ('{gradeTheme.GthName}',{gradeTheme.GthDepClaSubTea._SubId},{gradeTheme.GthDepClaSubTea._TeaId}, " +
                                         $"{gradeTheme.GthDepClaSubTea._ClaId}, {gradeTheme.GthRetake_GthId}, {gradeTheme.GthDepClaSubTea.DepCSTid})";
            }
            SqlCommand comCreateNewGradeTheme = new SqlCommand(sqlCreateNewGradeTheme, connection);

            try
            {
                connection.Open();
                comCreateNewGradeTheme.ExecuteNonQuery();
            }
            catch (SqlException)
            {
                Console.WriteLine("DATABASE createnewgradetheme ERROR");
            }
            finally
            {
                connection.Close();
            }
            return(true);
        }