Example #1
0
 private void dtTeams_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.ColumnIndex == DeleteTeamClnIndex && e.RowIndex >= 0)
     {
         var dialog = new AreYouSurePopup("Da li ste sigurni da želite da obrišete tim?");
         dialog.ShowDialog(this);
         if (dialog.Success)
         {
             var teamToDelete = dtTeams.Rows[e.RowIndex].DataBoundItem as team_round;
             teamToDelete.deleted = 1;
             teamToDelete.round.season.season_has_team.First(t => t.team_id == teamToDelete.team_id).total -=
                 (double)teamToDelete.total;
             database.SaveChanges();
             if (database.team_round.FirstOrDefault(t => t.team_id == teamToDelete.team_id && t.deleted == 0) ==
                 null)
             {
                 database.season_has_team.First(t => t.team_id == teamToDelete.team_id).deleted = 1;
                 database.SaveChanges();
             }
             else
             {
             }
             btnTeams_Click(null, null);
         }
     }
 }
Example #2
0
 private void dtQuestions_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < 0)
     {
         return;
     }
     if (e.ColumnIndex == YoutubeClnIndex)
     {
         var roundQuestion = dtQuestions.Rows[e.RowIndex].DataBoundItem as round_question;
         if (!String.IsNullOrEmpty(roundQuestion.question.youtube_link))
         {
             var form = new YoutubeForm(roundQuestion.question.youtube_link);
             form.ShowDialog(this);
         }
     }
     else if (e.ColumnIndex == DeleteQuestionClnIndex)
     {
         var dialog = new AreYouSurePopup("Da li ste sigurni da želite da obrišete pitanje?");
         dialog.ShowDialog(this);
         if (dialog.Success)
         {
             var roundQuestion = dtQuestions.Rows[e.RowIndex].DataBoundItem as round_question;
             roundQuestion.deleted = 1;
             foreach (DataGridViewRow row in dtQuestions.Rows)
             {
                 var question = row.DataBoundItem as round_question;
                 if (question.question_number > roundQuestion.question_number)
                 {
                     question.question_number--;
                 }
             }
             database.SaveChanges();
             btnQuestions_Click(null, null);
         }
     }
     else if (e.ColumnIndex == UpClnIndex && e.RowIndex > 0)
     {
         var roundQuestion = dtQuestions.Rows[e.RowIndex].DataBoundItem as round_question;
         var nextQuestion  = dtQuestions.Rows[e.RowIndex - 1].DataBoundItem as round_question;
         var oldNumber     = roundQuestion.question_number;
         roundQuestion.question_number = nextQuestion.question_number;
         nextQuestion.question_number  = oldNumber;
         database.SaveChanges();
         btnQuestions_Click(null, null);
         dtQuestions.Rows[e.RowIndex - 1].Selected = true;
     }
     else if (e.ColumnIndex == DownClnIndex && e.RowIndex + 1 < dtQuestions.RowCount)
     {
         var roundQuestion = dtQuestions.Rows[e.RowIndex].DataBoundItem as round_question;
         var nextQuestion  = dtQuestions.Rows[e.RowIndex + 1].DataBoundItem as round_question;
         var oldNumber     = roundQuestion.question_number;
         roundQuestion.question_number = nextQuestion.question_number;
         nextQuestion.question_number  = oldNumber;
         database.SaveChanges();
         btnQuestions_Click(null, null);
         dtQuestions.Rows[e.RowIndex + 1].Selected = true;
     }
 }