маленькое изменение

This commit is contained in:
ityurner02@mail.ru 2023-10-11 18:28:46 +04:00
parent 4ff7ba2931
commit 708c818336

View File

@ -25,9 +25,9 @@ namespace VisualCompLib.Components
public void CreateWordText(LargeText largeText) 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); _wordDocument = WordprocessingDocument.Create(largeText.FilePath, WordprocessingDocumentType.Document);
@ -119,5 +119,15 @@ namespace VisualCompLib.Components
doc.Save(); doc.Save();
} }
} }
bool CheckData(string[] data)
{
for (int i = 0; i < data.Length; i++)
{
if (string.IsNullOrEmpty(data[i])) return false;
}
return true;
}
} }
} }