public Contest(ContestPreview contest, List <Project> projects, List <JudgeMember> judgeMembers, List <Criteria> criterias, double[,] criteriaValues) { this.contest = contest; this.projects = projects; this.judgeMembers = judgeMembers; this.criterias = criterias; this.criteriaValues = criteriaValues; }
public bool refreshContests() { // Load the contest that the users has part in from the Database string query = "SELECT * FROM contest_table " + "WHERE id_contest IN (" + "SELECT id_contest FROM contest_juri_table " + "WHERE id_user = @id_user)"; SqlCommand cmd = DBSqlHelper._instance.conn.CreateCommand(); cmd.CommandText = query; SqlParameter sqlUserId = new SqlParameter("id_user", SqlDbType.Int); sqlUserId.Value = Data._instance.loggedInUser.id; cmd.Parameters.Add(sqlUserId); // Execute query using (DbDataReader reader = cmd.ExecuteReader()) { // Check if contest exists if (reader.HasRows) { contestPreviews.Clear(); while (reader.Read()) { ContestPreview contest = new ContestPreview(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetDateTime(3), reader.GetDateTime(4)); contestPreviews.Add(contest); } return(true); } else { return(false); } } }
private void criteriaValuesButton_Click(object sender, EventArgs e) { string contestName; // Check if there's any project if (projects.Count > 0) { // Check if there is a description if (description != "") { contestName = contestNameTextBox.Text; // Check if the contest has a name if (contestName != "") { // Check if contest's start date is after today if (contestStartDateTimePicker.Value.Date >= DateTime.Today) { // Check if contest's limit date is after today and after the start date if (contestLimitDateTimePicker.Value.Date > DateTime.Today && contestLimitDateTimePicker.Value.Date > contestStartDateTimePicker.Value.Date) { // Check if there's any judge member if (judgeMembers.Count > 0) { // Check if there's any criteria if (criterias.Count > 0) { ContestPreview contestPreview = new ContestPreview(0, contestName, description, contestStartDateTimePicker.Value, contestLimitDateTimePicker.Value); Contest contest = new Contest(contestPreview, projects, judgeMembers, criterias, new double[, ] { }); // Open criteria values form EditCriteriaValues editCriteriaValues = new EditCriteriaValues(mainJudgeDashboardForm, this, contest); editCriteriaValues.MdiParent = this.MdiParent; editCriteriaValues.Dock = DockStyle.Fill; editCriteriaValues.Show(); } else { MessageBox.Show(null, "There must be criterias assigned to the contest.", "Error"); } } else { MessageBox.Show(null, "There must be judges assigned to the contest.", "Error"); } } else { MessageBox.Show(null, "Limit date must be after today's date and after the start date.", "Error"); } } else { MessageBox.Show(null, "Start date must be after today's date and before the limit date.", "Error"); } } else { MessageBox.Show(null, "Contest name cannot be empty.", "Error"); } } else { MessageBox.Show(null, "There must be a description.", "Error"); } } else { MessageBox.Show(null, "There must be projects to add.", "Error"); } }