diff --git a/COP/VisualCompLib/Components/WordText.cs b/COP/VisualCompLib/Components/WordText.cs index 0bb53c9..479307f 100644 --- a/COP/VisualCompLib/Components/WordText.cs +++ b/COP/VisualCompLib/Components/WordText.cs @@ -25,9 +25,9 @@ namespace VisualCompLib.Components public void CreateWordText(LargeText largeText) { - if (string.IsNullOrEmpty(largeText.FilePath) || string.IsNullOrEmpty(largeText.DocumentTitle) || largeText.TextData.Length == 0) + if (string.IsNullOrEmpty(largeText.FilePath) || string.IsNullOrEmpty(largeText.DocumentTitle) || !CheckData(largeText.TextData)) { - return; + throw new Exception("Не все данные заполнены"); } _wordDocument = WordprocessingDocument.Create(largeText.FilePath, WordprocessingDocumentType.Document); @@ -119,5 +119,15 @@ namespace VisualCompLib.Components doc.Save(); } } + + bool CheckData(string[] data) + { + for (int i = 0; i < data.Length; i++) + { + if (string.IsNullOrEmpty(data[i])) return false; + } + + return true; + } } }