private void SetCaseQuestionOptions()
        {
            List<UDT.Case> Cases = Access.Select<UDT.Case>();
            List<UDT.CaseUsage> CaseUsages = Access.Select<UDT.CaseUsage>();
            dicCases = new Dictionary<string, UDT.Case>();
            Dictionary<string, UDT.CaseUsage> dicCaseUsages = new Dictionary<string, UDT.CaseUsage>();
            dicQuestionOptions_QuestionIdAndCaseID = new Dictionary<string, List<UDT.QuestionOption>>();

            if (Cases.Count == 0)
                return;
            if (CaseUsages.Count == 0)
                return;
            if (dicAssignedSurveys.Count == 0)
                return;
            if (dicQuestions_SurveyID.Count == 0)
                return;

            dicCases = Cases.ToDictionary(x => x.UID);
            foreach (UDT.CaseUsage CU in CaseUsages)
            {
                if (!dicCaseUsages.ContainsKey(CU.CourseID + "-" + CU.TeacherID))
                    dicCaseUsages.Add(CU.CourseID + "-" + CU.TeacherID, CU);
            }

            foreach (string key in dicAssignedSurveys.Keys)
            {
                UDT.AssignedSurvey assignedSurvey = dicAssignedSurveys[key];

                int CourseID = assignedSurvey.CourseID;
                int TeacherID = assignedSurvey.TeacherID;
                int SurveyID = assignedSurvey.SurveyID;

                UDT.CaseUsage CU = new UDT.CaseUsage();
                if (dicCaseUsages.ContainsKey(CourseID + "-" + TeacherID))
                    CU = dicCaseUsages[CourseID + "-" + TeacherID];
                else
                    continue;

                List<UDT.Question> Qs = new List<UDT.Question>();
                if (dicQuestions_SurveyID.ContainsKey(SurveyID.ToString()))
                    Qs = dicQuestions_SurveyID[SurveyID.ToString()];
                foreach (UDT.Question Q in Qs)
                {
                    if (!Q.IsCase)
                        continue;

                    if (Q.Type != "單選題" || Q.Type != "複選題")
                        continue;

                    List<UDT.QuestionOption> Qos = new List<UDT.QuestionOption>();
                    if (dicQuestionOptions_QuestionID.ContainsKey(Q.UID))
                        Qos = dicQuestionOptions_QuestionID[Q.UID];

                    if (!dicQuestionOptions_QuestionIdAndCaseID.ContainsKey(Q.UID + "-" + CU.CaseID))
                        dicQuestionOptions_QuestionIdAndCaseID.Add(Q.UID + "-" + CU.CaseID, Qos);
                }
            }
        }
        protected override void OnSaveData()
        {
            if (!this.ValidateData())
                return;

            this.Records.ForEach(x => x.Deleted = true);
            this.Records.SaveAll();

            foreach (DataGridViewRow row in this.dgvData.Rows)
            {
                if (row.IsNewRow)
                    continue;

                UDT.CaseUsage CaseUsage = new UDT.CaseUsage();

                CaseUsage.CourseID = int.Parse(PrimaryKey);
                CaseUsage.CaseID = int.Parse(row.Cells[0].Value + "");
                CaseUsage.TeacherID = int.Parse(row.Cells[1].Value + "");

                this.Records.Add(CaseUsage);
            }
            this.Records.SaveAll();

            this.OnPrimaryKeyChanged(EventArgs.Empty);

            ResetDirtyStatus();
        }