private void dataGridView_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            ExamInformation exam = e.Row.Tag as ExamInformation;

            try
            {
                if (exam != null)
                {
                    int templateCount = QueryExam.GetExamTemplateUseCount(exam.Identity);
                    int textCount     = QueryExam.GetTextScoreUseCount(exam.Identity);
                    int numberCount   = QueryExam.GetNumberScoreUseCount(exam.Identity);

                    if (templateCount > 0 || textCount > 0 || numberCount > 0)
                    {
                        //string msg = "已有其他資料使用【{3}】,無法刪除。\n\n評量樣版使用數:{0}\n數字評量使用數:{1}\n文字評量使用數:{2}";
                        string msg = "已有其他資料使用【{0}】,無法刪除。";
                        //msg = string.Format(msg, templateCount, numberCount, textCount, exam.ExamName);
                        msg = string.Format(msg, exam.ExamName);
                        MsgBox.Show(msg, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        e.Cancel = true;
                    }
                }
            }
            catch (Exception ex)
            {
                //CurrentUser current = CurrentUser.Instance;
                //BugReporter.ReportException(current.SystemName, current.SystemVersion, ex, false);
                MsgBox.Show(ex.Message, Application.ProductName);
            }
        }
        public ExamManager()
        {
            InitializeComponent();
            List <int> cols = new List <int>()
            {
                1
            };

            Campus.Windows.DataGridViewImeDecorator dec = new Campus.Windows.DataGridViewImeDecorator(this.dataGridView, cols);

            try
            {
                _exam_list = new Dictionary <string, ExamInformation>();
                XmlElement list = QueryExam.GetAbstractList();
                foreach (XmlElement node in list.SelectNodes("Exam"))
                {
                    ExamInformation exam = new ExamInformation(node);

                    int             index = dataGridView.Rows.Add();
                    DataGridViewRow row   = dataGridView.Rows[index];
                    row.Cells[0].Value = exam.ExamName;
                    row.Cells[1].Value = exam.DisplayOrder;
                    row.Tag            = exam;
                    _exam_list.Add(exam.Identity, exam);
                }
            }
            catch (Exception ex)
            {
                MsgBox.Show("載入評量資訊錯誤。");
                btnSave.Enabled = false;
            }
        }
Exemple #3
0
        protected override Dictionary <string, ExamRecord> GetData(IEnumerable <string> primaryKeys)
        {
            Dictionary <string, ExamRecord> records = new Dictionary <string, ExamRecord>();

            foreach (ExamRecord each in QueryExam.GetExams(primaryKeys))
            {
                records.Add(each.ID, each);
            }

            return(records);
        }
Exemple #4
0
        protected override Dictionary <string, ExamRecord> GetAllData()
        {
            Dictionary <string, ExamRecord> records = new Dictionary <string, ExamRecord>();

            foreach (ExamRecord each in QueryExam.GetAllExams())
            {
                records.Add(each.ID, each);
            }

            return(records);
        }