public bool checkDuplicate()
        {
            Phase phase = new Phase();
            phase.IDContest = idContest;
            PhaseQuestionBL PhaseQuestionBL = new PhaseQuestionBL();
            List<Phase> ListPhase;
            ListPhase = PhaseQuestionBL.getquestionByIDContest(phase);

            int count = 0;
            foreach (DataGridViewRow row in dgv_Question.Rows)
            {
                if (row.Cells["Check"].Value != null && (bool)row.Cells["Check"].Value == true)
                {
                    if (ListPhase != null)
                    {
                        for (int i = 0; i < ListPhase.Count; i++)
                        {
                            if (ListPhase.ElementAt(i).IDQuestion == Convert.ToInt32(row.Cells["IDQuestion"].Value))
                            {
                                row.DefaultCellStyle.BackColor = Color.LightCoral;
                                count++;
                            }
                        }
                    }
                }
            }

            if (count == 0)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
Beispiel #2
0
        private void deleteSetupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Bạn muốn xóa cuộc thi này không?", "Xóa Thiết Đặt", MessageBoxButtons.YesNo);
            if (dialogResult == DialogResult.Yes)
            {
                Contest Contest = new Contest();
                Phase Phase = new Phase();
                Player Player = new Player();
                Record Record = new Record();

                ContestBL ContestBL = new ContestBL();
                PhaseBL PhaseBl = new PhaseBL();
                PlayerBL PlayerBL = new PlayerBL();
                PhaseQuestionBL PhaseQuestionBL = new PhaseQuestionBL();
                RecordBL RecordBL = new RecordBL();

                Contest.IDContest = Convert.ToInt32(lbl_IDContest.Text);
                Phase.IDContest = Convert.ToInt32(lbl_IDContest.Text);
                Player.IDContest = Convert.ToInt32(lbl_IDContest.Text);
                Record.IDContest = Convert.ToInt32(lbl_IDContest.Text);

                RecordBL.DeleteRecordByIDContest(Record);
                PhaseQuestionBL.DeletePhaseQuestionbyIDContest(Phase);
                PlayerBL.DeletePlayerbyIDContest(Player);
                PhaseBl.DeletePhasebyIDContest(Phase);
                ContestBL.DeleteContestbyID(Contest);
                LoadAll();

                EventHandler delete = onDelete;

                if (delete != null)
                {
                    MyEventArgs args = new MyEventArgs();
                    args.IDNewGame = iD_NewGame;
                    delete(this, args);
                }
            }
        }
 //Copy Question
 public void CopyQuestion()
 {
     Phase Phase = new Phase();
     PhaseQuestionBL PhaseQuestionBL = new PhaseQuestionBL();
     foreach (DataGridViewRow row in dgv_Question.Rows)
     {
         if (row.Cells["Check"].Value != null && (bool)row.Cells["Check"].Value == true)
         {
             Phase.IDPhase = idPhase;
             Phase.IDContest = idContest;
             //Phase.Question.IDQuestion = Convert.ToInt32(row.Cells["IDQuestion"].Value);
             Phase.IDQuestion = Convert.ToInt32(row.Cells["IDQuestion"].Value);
             Phase.Status = 1;
             PhaseQuestionBL.AddPhaseQuestion(Phase);
         }
     }
 }