Exemplo n.º 1
0
        /// <summary>
        /// 錯誤或警告事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void docValidate_ErrorCaptured(object sender, ErrorCapturedEventArgs e)
        {
            string Description = e.Description;
            List<string> Fields = new List<string>() { e.FieldName };
            ErrorType ErrorType = (e.ErrorType == EMBA.DocumentValidator.ErrorType.Error) ? ErrorType.Error : ErrorType.Warning;
            ValidatorType ValidationType = ValidatorType.Field;

            MessageItem item = new MessageItem(ErrorType, ValidationType, Description, Fields);

            RowMessages[e.Row.Position].MessageItems.Add(item);

            if (e.ErrorType == EMBA.DocumentValidator.ErrorType.Error)
                ErrorCount++;
            else
                WarningCount++;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 自動修正事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void docValidate_AutoCorrect(object sender, AutoCorrectEventArgs e)
        {
            #region 將修正後的值寫入該欄位
            SheetRowSource row = e.Row as SheetRowSource;
            SheetHelper sheetHelper = row.Sheet;

            int FieldIndex = sheetHelper.GetFieldIndex(e.FieldName);
            if (FieldIndex != -1) //當自動修正,Excel-Sheet內卻沒有欄位
            {
                sheetHelper.Sheet.Cells[row.Position, sheetHelper.GetFieldIndex(e.FieldName)].PutValue(e.NewValue);

                string Description = string.Format("「{0}」值由『{1}』改為『{2}』。", e.FieldName, e.OldValue, e.NewValue);
                List<string> Fields = new List<string>() { e.FieldName };
                ErrorType ErrorType = ErrorType.Correct;
                ValidatorType ValidatorType = ValidatorType.Field;

                MessageItem item = new MessageItem(ErrorType, ValidatorType, Description, Fields);

                RowMessages[e.Row.Position].MessageItems.Add(item);

                AutoCorrectCount++;
            }
            else //就不處理
            {

            }
            #endregion
        }