void _worker_DoWork(object sender, DoWorkEventArgs e)
 {
     _StudQuizDataList = _UDTTransfer.GetStudQuizDataByStudentID(PrimaryKey);
 }
예제 #2
0
        private void StudQuizDataForm_Load(object sender, EventArgs e)
        {
            // 取得學生資料
            StudentRecord studRec = Student.SelectByID(_StudentID);

            _StudQuizDataList = _UDTTransfer.GetStudQuizDataByStudentID(studRec.ID);

            // log 學生資訊用
            _LogStudentName = Utility.ConvertString1(studRec);


            if (_StudQuizData == null)
            {
                _StudQuizData = new DAO.UDT_StudQuizDataDef();
            }

            if (_EditMode == EditMode.Edit)
            {
                // 取得測驗名稱
                foreach (DAO.UDT_QuizDef data in _AllQuiz.Where(x => x.UID == _StudQuizData.QuizID.ToString()))
                {
                    _qdd = data;
                }

                if (_qdd == null)
                {
                    FISCA.Presentation.Controls.MsgBox.Show("無法解析測驗內容.");
                    return;
                }
            }

            if (studRec != null)
            {
                string str = "";
                if (studRec.Class != null)
                {
                    str += studRec.Class.Name + " ";
                }

                str += studRec.Name + " ";
                str += studRec.StudentNumber;
                str  = " (" + str + ")";
                if (_EditMode == EditMode.Edit)
                {
                    this.Text = _qdd.QuizName + str;
                }
                else
                {
                    this.Text = str;
                }
            }

            // 當編輯模式,測驗名稱,不能修改
            if (_EditMode == EditMode.Edit)
            {
                cbxQuizName.Text    = _qdd.QuizName;
                cbxQuizName.Enabled = false;

                if (_StudQuizData.ImplementationDate.HasValue)
                {
                    dtImplementationDate.Value = _StudQuizData.ImplementationDate.Value;
                }

                if (_StudQuizData.AnalysisDate.HasValue)
                {
                    dtAnalysisDate.Value = _StudQuizData.AnalysisDate.Value;
                }

                dgQuizData.Rows.Clear();

                int rowIdx = 0;
                dgQuizData.Columns[colDataField.Index].ReadOnly = false;

                XElement elmContent = Utility.ConvertStringToXelm1(_StudQuizData.Content);
                if (elmContent != null)
                {
                    // 沒有在試別欄位加入
                    List <string> fieldList = (from data in elmContent.Elements("Item") select data.Attribute("name").Value).ToList();
                    foreach (string str in fieldList)
                    {
                        if (!_RowNameList.Contains(str))
                        {
                            _RowNameList.Add(str);
                        }
                    }
                    // 依試別欄位順序排序
                    foreach (string str in _RowNameList)
                    {
                        foreach (XElement elm in elmContent.Elements("Item").Where(x => x.Attribute("name").Value == str))
                        {
                            rowIdx = dgQuizData.Rows.Add();
                            if (elm.Attribute("name") != null)
                            {
                                dgQuizData.Rows[rowIdx].Cells[colDataField.Index].Value = elm.Attribute("name").Value;
                            }
                            if (elm.Attribute("value") != null)
                            {
                                dgQuizData.Rows[rowIdx].Cells[colDataValue.Index].Value = elm.Attribute("value").Value;
                            }
                        }
                    }
                }
                dgQuizData.Columns[colDataField.Index].ReadOnly = true;
            }
            _LogTransfer.Clear();
            LogData();
        }