public void OpenResultsGUI(SportsFestival pSportsFestival)
        {
            ResultsGUIForm = new ResultsGUI(this, pSportsFestival);

            ResultsGUIForm.updateSubscriptions();

            ResultsGUIForm.ShowDialog();
        }
 public static void deleteSportsFestival(SportsFestival sportsFestival)
 {
     executeSql(""
         + "DELETE FROM "
             + "`" + tableName + "` "
         + "WHERE "
             + "`" + field_sportsFestivalId + " = " + sportsFestival.SportsFestivalId + " "
         + "LIMIT 1"
     );
 }
 public static void deleteSportsFestival(SportsFestival sportsFestival, Competition competition)
 {
     executeSql(""
         + "DELETE FROM "
             + "`" + tableName + "` "
         + "WHERE "
             + "`" + field_sportsFestivalId + " = " + sportsFestival.SportsFestivalId + " "
             + "AND `" + field_competitionId + " = " + competition.CompetitionId + " "
         + "LIMIT 1"
     );
 }
Exemplo n.º 4
0
 public SportsFestivalSubscription(
     int sportsFestivalSubscriptionId,
     SportsFestival sportsFestival,
     Student student,
     string classShortcut
     )
 {
     this.sportsFestivalSubscriptionId = sportsFestivalSubscriptionId;
     this.sportsFestival = sportsFestival;
     this.student        = student;
     this.classShortcut  = classShortcut;
 }
 public SportsFestivalSubscription(
     int sportsFestivalSubscriptionId,
     SportsFestival sportsFestival,
     Student student,
     string classShortcut
 )
 {
     this.sportsFestivalSubscriptionId = sportsFestivalSubscriptionId;
     this.sportsFestival = sportsFestival;
     this.student = student;
     this.classShortcut = classShortcut;
 }
 public static void createSportsFestivalCompetitionRelation(SportsFestival sportsFestival, Competition competition)
 {
     executeSql(""
         + "INSERT INTO `" + tableName + "` "
         + "("
             + "`" + field_sportsFestivalId + "`,"
             + "`" + field_competitionId + "`"
         + ") VALUES ("
             + sportsFestival.SportsFestivalId + ","
             + competition.CompetitionId
         + ")"
     );
 }
        public static bool relationExists(SportsFestival sportsFestival, Competition competition)
        {
            Dictionary<string, object> result = querySingleSql(""
                + "SELECT "
                    + "* "
                + "FROM "
                    + "`" + tableName + "` "
                + "WHERE "
                    + "`" + field_sportsFestivalId + "` = " + sportsFestival.SportsFestivalId + " "
                    + "AND `" + field_competitionId + "` = " + competition.CompetitionId
            );

            if (result.Count == 1)
            {
                return true;
            }

            return false;
        }
        public static List<SportsFestivalSubscription> getSportsFestivalSubscriptionsBySportsFestival(SportsFestival sportsFestival)
        {
            List<Dictionary<string, object>> results = querySql(""
                + "SELECT "
                    + "* "
                + "FROM "
                    + "`" + tableName + "` "
                + "WHERE "
                    + "`" + field_sportsFestivalId + "` = " + sportsFestival.SportsFestivalId
            );

            List<SportsFestivalSubscription> sportsFestivalSubscriptions = new List<SportsFestivalSubscription>();

            foreach (var row in results)
            {
                sportsFestivalSubscriptions.Add(getSportsFestivalSubscriptionById(Convert.ToInt32(row[field_sportsFestivalSubscriptionId])));
            }

            return sportsFestivalSubscriptions;
        }
        public static int createSportsFestivalSubscription(
            SportsFestival sportsFestival,
            Student student
        )
        {
            executeSql(""
                + "INSERT INTO `" + tableName + "` "
                + "("
                    + "`" + field_sportsFestivalId + "`, "
                    + "`" + field_studentId + "`, "
                    + "`" + field_classShortcut + "`"
                + ") VALUES ("
                    + sportsFestival.SportsFestivalId + ", "
                    + student.StudentId + ", "
                    + "'" + student.ClassObject.Shortcut + "'"
                + ")"
            );

            Dictionary<string, object> result = querySingleSql("SELECT MAX(`" + field_sportsFestivalSubscriptionId + "`) AS `insertionId` FROM `" + tableName + "`");

            int insertionId = Convert.ToInt32(result["insertionId"]);

            return insertionId;
        }
        public static List<Class> getClassesBySportsFestival(SportsFestival sportsFestival)
        {
            List<Dictionary<string, object>> results = querySql(""
                + "SELECT "
                    + "* "
                + "FROM "
                    + "`sportsfestivalSubscription` "
                + "WHERE "
                    + "`" + field_sportsFestivalId + "` = " + sportsFestival.SportsFestivalId
            );

            List<Class> classes = new List<Class>();

            foreach (var row in results)
            {
                classes.Add(ClassProvider.getClassByShortcutSimplified(row["classShortcut"].ToString()));
            }

            return classes;
        }
 internal ResultsGUI(ResultsController controller, SportsFestival curSportsFestival)
 {
     m_SportsFestivalRef = curSportsFestival;
     InitializeComponent();
 }
 public static List<Competition> getCompetitionsBySportsFestival(SportsFestival sportsFestival)
 {
     return SportsFestivalCompetitionProvider.getCompetitionsBySportsFestival(sportsFestival);
 }
        public static List<Student> getStudentsBySportsFestival(SportsFestival sportsFestival)
        {
            List<Dictionary<string, object>> results = querySql(""
                + "SELECT "
                    + "* "
                + "FROM "
                    + "`" + tableName + "` "
                + "WHERE "
                    + "`" + field_sportsFestivalId + "` = " + sportsFestival.SportsFestivalId
            );

            List<Student> students = new List<Student>();

            foreach (var row in results)
            {
                students.Add(StudentProvider.getStudentById((int)row[field_studentId]));
            }

            return students;
        }
        public static SportsFestival getSportsFestivalById(int sportsFestivalId)
        {
            Dictionary<string, object> result = querySingleSql(""
                + "SELECT "
                    + "* "
                + "FROM "
                    + "`" + tableName + "` "
                + "WHERE "
                    + "`" + field_sportsFestivalId + "` = " + sportsFestivalId
            );

            if (result == null)
            {
                return null;
            }

            SportsFestival sportsFestival = new SportsFestival(
                Convert.ToInt32(result[field_sportsFestivalId]),
                Convert.ToDateTime(result[field_sportsFestivalDate])
            );

            foreach (Competition competition in CompetitionProvider.getCompetitionsBySportsFestival(sportsFestival))
            {
                sportsFestival.addCompetition(competition);
            }

            return sportsFestival;
        }
        public static void updateSportsFestival(SportsFestival sportsFestival)
        {
            executeSql(""
                + "UPDATE "
                    + "`" + tableName + "` "
                + "SET "
                    + "`" + field_sportsFestivalDate + "` = '" + sportsFestival.Date.ToString("yyyy-MM-dd") + "' "
                + "WHERE "
                    + "`" + field_sportsFestivalId + "` = " + sportsFestival.SportsFestivalId
            );

            foreach (Competition competition in sportsFestival.getCompetitions())
            {
                if (SportsFestivalCompetitionProvider.relationExists(sportsFestival, competition) == false)
                {
                    SportsFestivalCompetitionProvider.createSportsFestivalCompetitionRelation(sportsFestival, competition);
                }
            }
        }