Edit Open File Dialogs

This commit is contained in:
Sergey Chebotar 2022-02-02 18:26:04 +03:00
parent 94b7c4a52b
commit 9018d7d504
2 changed files with 7 additions and 14 deletions

View File

@ -8,25 +8,21 @@ namespace RehauSku.Interface
{
public static string GetFilePath()
{
string filePath = string.Empty;
using (OpenFileDialog dialog = new OpenFileDialog())
{
dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
if (dialog.ShowDialog() == DialogResult.OK)
{
filePath = dialog.FileName;
return dialog.FileName;
}
}
return filePath;
return string.Empty;
}
public static string[] GetMultiplyFiles()
{
List<string> fileNames = new List<string>();
using (OpenFileDialog dialog = new OpenFileDialog())
{
dialog.Filter = "Файлы Excel (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm";
@ -34,14 +30,11 @@ namespace RehauSku.Interface
if (dialog.ShowDialog() == DialogResult.OK)
{
foreach (string file in dialog.FileNames)
{
fileNames.Add(file);
}
}
return dialog.FileNames;
}
return fileNames.ToArray();
else return null;
}
}
public static void SaveWorkbookAs()

View File

@ -38,7 +38,7 @@ namespace RehauSku.Interface
MergeTool mergeTool = new MergeTool();
string[] files = Dialog.GetMultiplyFiles();
if (files.Length != 0)
if (files != null)
{
mergeTool.SourceFiles = SourcePriceList.GetSourceLists(files);
mergeTool.OpenNewPrice();
@ -51,7 +51,7 @@ namespace RehauSku.Interface
CombineTool combineTool = new CombineTool();
string[] files = Dialog.GetMultiplyFiles();
if (files.Length != 0)
if (files != null)
{
combineTool.SourceFiles = SourcePriceList.GetSourceLists(files);
combineTool.OpenNewPrice();