Example #1
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;
     }
 }
Example #2
0
        private void btnYoutube_Click(object sender, EventArgs e)
        {
            var youtubeForm = new YoutubeForm();

            youtubeForm.ShowDialog();
        }