Beispiel #1
0
        private void dgEditor_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            _dirty = true;
            DataGridViewRow  row   = dgEditor.Rows[e.RowIndex];
            DataGridViewCell cell  = row.Cells[e.ColumnIndex];
            string           value = string.Empty;

            if (cell.Value != null)
            {
                value = cell.Value.ToString();
            }

            row.Tag       = null;
            row.ErrorText = string.Empty;

            if (e.ColumnIndex == colSeatNo.Index)
            {
                StudentRecord student = ActivityRecordDAL.GetStudent(cboClass.Text, value);
                FillStudentRow(row, student);
            }
            else if (e.ColumnIndex == colStudentNumber.Index)
            {
                StudentRecord student = ActivityRecordDAL.GetStudent(value);
                FillStudentRow(row, student);
            }
        }
Beispiel #2
0
        private void dgEditor_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            _dirty = true;
            DataGridViewRow  row   = dgEditor.Rows[e.RowIndex];
            DataGridViewCell cell  = row.Cells[e.ColumnIndex];
            string           value = string.Empty;

            if (cell.Value != null)
            {
                value = cell.Value.ToString();
            }

            row.ErrorText = string.Empty;

            if (e.ColumnIndex == colSeatNo.Index || e.ColumnIndex == colClass.Index)
            {
                string className = string.Empty;
                if (row.Cells[colClass.Name].Value != null)
                {
                    className = row.Cells[colClass.Name].Value.ToString();
                }

                string seatNo = string.Empty;
                if (row.Cells[colSeatNo.Name].Value != null)
                {
                    seatNo = row.Cells[colSeatNo.Name].Value.ToString();
                }

                if (string.IsNullOrEmpty(className) || string.IsNullOrEmpty(seatNo))
                {
                    row.ErrorText = "請輸入完整的班級與座號";
                    return;
                }

                StudentRecord student = ActivityRecordDAL.GetStudent(className, seatNo);
                FillStudentRow(row, student);
            }
            else if (e.ColumnIndex == colItem.Index)
            {
                if (string.IsNullOrEmpty(value))
                {
                    cell.ErrorText = "內容不可空白";
                }
                else
                {
                    cell.ErrorText = string.Empty;
                }
            }
            else if (e.ColumnIndex == colStudentNumber.Index)
            {
                StudentRecord student = ActivityRecordDAL.GetStudent(value);
                FillStudentRow(row, student);
            }
        }