-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReportCollector.cs
More file actions
767 lines (641 loc) · 31.1 KB
/
ReportCollector.cs
File metadata and controls
767 lines (641 loc) · 31.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
using NPOI.HSSF.Util;
using NPOI.SS.UserModel;
using NPOI.SS.Util;
using NPOI.Util;
using NPOI.XSSF.UserModel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace RepCol_2
{
public partial class ReportCollector : Form, IDisposable
{
public ReportCollector()
{
InitializeComponent();
TypeFile.SelectedItem = "ALL";
tabNameBox.SelectedIndexChanged += tabNameBox_SelectedIndexChanged;
// Загрузка настроек по парам [ключ]-[значение].
NameValueCollection allAppSettings = ConfigurationManager.AppSettings;
if (allAppSettings.Count < 1)
{
MessageBox.Show("Каталоги по умолчанию не заданы");
}
// Восстановление состояния:
string sourceFolderStr = allAppSettings["sourcePath"];
string destinationFolderStr = allAppSettings["destinationPath"];
string configFilePath = allAppSettings["configFilePath"];
sourceFolder.Text = sourceFolderStr;
destinationFolder.Text = destinationFolderStr;
textSettingPath.Text = configFilePath;
// string configPath = "";
isClickButtonSelectAll = true;
if (sourceFolder.Text != "")
{
tempPath = sourceFolder.Text;
string[] second = Directory.GetFiles(tempPath);
for (int i = 0; i < second.Length; i++)
{
fileList[i] = second[i];
}
filesPath = fileList;
GetBooksSource(filesPath);
//GetNameListWorkBooks(filesPath);
}
}
//OpenFileDialog openFileDialog = new OpenFileDialog();
// Список листов книг
string[] fileList = new string[100];
// Список выбранных файлов
string[] filesPath = new string[100];
// Переменная для хранения пути к конечному файлу
string fileNameFiished = "";
//
string pathFile = "";
// Объявляем тип делегата
public delegate ISheet[] ReportSheetDelegat(List<string> ListBook);
// Переменная для хранения строки с названием листа
string selectedStateTabName = "";
//Переменная для хранения количества колонок
int lastColumnSource = 0;
//Флаг проверки нажатия кнопки для выбора каатлога-приемника
bool isClickButtonUnloadFile = false;
//Флаг проверки нажатия кнопки для выбора каатлога-источника
bool isClickButtonSelectAll = false;
// строка содержащая путь к каталогу - источнику
string tempPath = "";
//
// ISheet[] oSheetList = new ISheet[] { };
ISheet[] sheets = new ISheet[500];
//=================== Метод формирования итогового файла ==================
/// <summary>
/// Метод вставки данных в книгу
/// </summary>
/// <param name="FileNamesSelect"> Список выбранных файлов</param>
/// <param name="selectedState">Выбранный тип файла</param>
#region ImportExcelHSSF_2(string[] FileNamesSelect, string selectedState)
private void ImportExcelHSSF_2(string[] FileNamesSelect, string selectedState)
{
//----------- книга - приемник -----------------
var newbook = new XSSFWorkbook();
ISheet sheetBook = newbook.CreateSheet(tabNameBox.SelectedItem.ToString());
IRow rowsheet = sheetBook.CreateRow(0);
ICell cell = rowsheet.CreateCell(0);
//ICellStyle cellStyle = newbook.CreateCellStyle();
//----------- счетчик строк в листе ------------------
int countRow = 0;
int CountRowNull = 0;
//--- цикл перебора всех листов с нужным названием ------
for (var nextsheet = 0; nextsheet < sheets.Length; nextsheet++)
{
if (sheets[nextsheet] == null)
break;
else
if (sheets[nextsheet].SheetName == tabNameBox.SelectedItem.ToString())
{
// проверка на наличие данных в листе
// если лист не пустой то вставляем со смещением countRow
if (sheetBook.GetRow(sheetBook.LastRowNum) != sheetBook.GetRow(sheetBook.FirstRowNum))
{
CountRowNull = CopyRow(int.Parse(rowNumberCopy.Text), sheets[nextsheet], sheetBook, countRow, newbook);
countRow += sheets[nextsheet].LastRowNum - int.Parse(rowNumberCopy.Text) + 2- CountRowNull;
}
else
if (sheetBook.GetRow(sheetBook.LastRowNum) == sheetBook.GetRow(sheetBook.FirstRowNum))
{
//------ копирование по строкам-----------------
CountRowNull = CopyRow(0, sheets[nextsheet], sheetBook, newbook);
if (int.TryParse(rowNumberCopy.Text, out _) == true)
countRow = sheets[nextsheet].LastRowNum - int.Parse(rowNumberCopy.Text) + 2 - CountRowNull;
else
{
MessageBox.Show($"В поле: \r\n {label4.Text} \r\n введены некоректные данные");
break;
}
}
}
else
continue;
}
// -- Формирование имени конечного файла
fileNameFiished = tabNameBox.SelectedItem.ToString()+ "-" + selectedState + ".xlsx";
pathFile = @"C:\Users\Public\" + fileNameFiished;
//Проверка нажата ли кнопка сохранить файл
if (fileNameBox.Text != "")
{
pathFile = destinationFolder.Text + "\\" + fileNameBox.Text;
if (pathFile == "")
{
MessageBox.Show("Укажите путь для сохранения файла!");
}
else
{
SaveWorkbook(newbook, pathFile);
MessageBox.Show("Сохранение выполнено");
}
}
else
MessageBox.Show("Введите название файла");
}
#endregion
//================= Метод получения всех листов книг-источников =============
/// <summary>
/// Метод получения всех листов выбранных книг Excel
/// </summary>
/// <param name="ListBook"> список выбранных книг</param>
/// <returns></returns>
#region GetBooksSource(List<string> FileNamesSelect)
private void GetBooksSource(string[] ListBook)
{
IWorkbook[] books = OpenWorkbook(ListBook);
//GetStreamFromBook(ListBook, out books);
//-------- цикл перебора всех листов из книг ------
int countSheetBook = 0;
for (var workbook = 0; workbook < books.Length; workbook++)
{
if (books[workbook] == null)
break;
// цикл по листам
for (int i = 0; i < books[workbook].NumberOfSheets; i++)
{
if (books[workbook].GetSheetAt(i) == null)
{
break;
}
else
{
sheets[countSheetBook] = books[workbook].GetSheetAt(i);
if (sheets[countSheetBook] == null)
break;
else
{
if (!tabNameBox.Items.OfType<string>().Contains(sheets[countSheetBook].SheetName))
{
tabNameBox.Items.Add(sheets[countSheetBook].SheetName);
}
countSheetBook++;
}
}
}
}
//return sheets;
}
#endregion
//================================================================================
/// <summary>
/// Метод копирования диапазона ячеек
/// </summary>
/// <param name="range">диапазон ячеек</param>
/// <param name="sourceSheet">лист-источник</param>
/// <param name="destinationSheet">лист-приемник</param>
#region CopyRange(CellRangeAddress range, ISheet sourceSheet, ISheet destinationSheet)
int CopyRange(CellRangeAddress range, ISheet sourceSheet, ISheet destinationSheet, XSSFWorkbook newbook)
{
MissingCellPolicy cellPolicyCreaate = new MissingCellPolicy();
cellPolicyCreaate = MissingCellPolicy.RETURN_BLANK_AS_NULL;
int CountRowNullSkip = 0;
for (var rowNum = range.FirstRow; rowNum <= range.LastRow; rowNum++)
{
IRow sourceRow = sourceSheet.GetRow(rowNum);
if (sourceRow != null && (sourceRow.GetCell(0)?.CellType != CellType.Blank && sourceRow.GetCell(0, cellPolicyCreaate) != null))
{
if (destinationSheet.GetRow(rowNum - CountRowNullSkip) == null)
destinationSheet.CreateRow(rowNum - CountRowNullSkip);
}
else
{
CountRowNullSkip++;
continue;
}
if (sourceRow != null && (sourceRow.GetCell(0)?.CellType != CellType.Blank && sourceRow.GetCell(0, cellPolicyCreaate) != null))
{
IRow destinationRow = destinationSheet.GetRow(rowNum - CountRowNullSkip);
for (var col = 0; col < range.LastColumn; col++)
{
destinationRow.CreateCell(col);
CopyCell(sourceRow.GetCell(col), destinationRow.GetCell(col), newbook, col);
}
}
}
return CountRowNullSkip;
}
#endregion
//=============== перегруженный метод вставки со смещением на countRowoffset ======================
/// <summary>
/// Метод копирования диапазона ячеек
/// </summary>
/// <param name="range">диапазон ячеек</param>
/// <param name="sourceSheet">лист-источник</param>
/// <param name="destinationSheet">лист-приемник</param>
/// <param name="countRowoffset">смещение</param>
#region CopyRange(CellRangeAddress range, ISheet sourceSheet, ISheet destinationSheet, int countRowoffset)
int CopyRange(CellRangeAddress range, ISheet sourceSheet, ISheet destinationSheet, int countRowoffset, XSSFWorkbook newbook)
{
MissingCellPolicy cellPolicyCreaate = new MissingCellPolicy();
cellPolicyCreaate = MissingCellPolicy.RETURN_BLANK_AS_NULL;
int countNullRow = 0;
for (var rowNum = range.FirstRow; rowNum <= range.LastRow; rowNum++)
{
IRow sourceRow = sourceSheet.GetRow(rowNum);
if (sourceRow != null && (sourceRow.GetCell(0)?.CellType != CellType.Blank && sourceRow.GetCell(0, cellPolicyCreaate) != null))
{
if (destinationSheet.GetRow(rowNum + countRowoffset - countNullRow) == null)
destinationSheet.CreateRow(rowNum + countRowoffset - countNullRow);
}
else
{
countNullRow++;
continue;
}
if (sourceRow != null && (sourceRow.GetCell(0)?.CellType != CellType.Blank && sourceRow.GetCell(0, cellPolicyCreaate) != null))
{
IRow destinationRow = destinationSheet.GetRow(rowNum + countRowoffset - countNullRow);
for (var col = sourceRow.FirstCellNum; col < range.LastColumn; col++)
{
destinationRow.CreateCell(col);
CopyCell(sourceRow.GetCell(col), destinationRow.GetCell(col), newbook, col);
}
}
}
return countNullRow;
}
#endregion
//======================== метод CopyRow ===========================================
/// <summary>
/// Метод установки данных для копирования
/// </summary>
/// <param name="row">начальная строка</param>
/// <param name="sourceSheet">лист-источник</param>
/// <param name="destinationSheet">лист-приемник</param>
#region CopyRow(int row, ISheet sourceSheet, ISheet destinationSheet)
int CopyRow(int row, ISheet sourceSheet, ISheet destinationSheet, XSSFWorkbook newbook)
{
if (int.TryParse(countColumn.Text, out _) == true)
{
lastColumnSource = int.Parse(countColumn.Text);
}
else
MessageBox.Show($"В поле: \r\n {label5.Text} \r\n введены некоректные данные");
var range = new CellRangeAddress(0, sourceSheet.LastRowNum, 0, lastColumnSource);
int coutNullRow;
return coutNullRow = CopyRange(range, sourceSheet, destinationSheet, newbook);
}
#endregion
//=========== перегруженный метод CopyRow со смещение на countRow сторк ===================
/// <summary>
/// Метод установки данных для копировани
/// </summary>
/// <param name="row">начальная строка</param>
/// <param name="sourceSheet">лист-источник</param>
/// <param name="destinationSheet">лист-приемник</param>
/// <param name="countRow">смещение</param>
#region CopyRow(int row, ISheet sourceSheet, ISheet destinationSheet, int countRow)
int CopyRow( int row, ISheet sourceSheet, ISheet destinationSheet, int countRow, XSSFWorkbook newbook)
{
lastColumnSource = int.Parse(countColumn.Text);
int rowNumSource = row - 1;
int countRowoffset = countRow;
var range = new CellRangeAddress(rowNumSource, sourceSheet.LastRowNum, 0, lastColumnSource);
int rowNullCount = 0;
//var range = destinationSheet.CopyRow(row, rowNum);
return rowNullCount = CopyRange(range, sourceSheet, destinationSheet, countRowoffset, newbook);
}
#endregion
//==================== метод CopyCell ===================================================
/// <summary>
/// Метод установки типа ячейки
/// </summary>
/// <param name="source">ячейка из книги-источника</param>
/// <param name="destination">ячейка из книги-приемника</param>
#region CopyCell(ICell source, ICell destination)
void CopyCell(ICell source, ICell destination, XSSFWorkbook newbook, int col)
{
if (destination != null && source != null)
{
var cellStyleBorderAndColor = newbook.CreateCellStyle();
cellStyleBorderAndColor.CloneStyleFrom(source.CellStyle);
//cellStyleBorderAndColor.SetFont(defaultFont);
destination.CellStyle = cellStyleBorderAndColor;
//var colorForeground = new XSSFColor(new byte[] { 255, 255, 0 });
//var foreground = cellStyleBorderAndColor.FillForegroundColor;
if (source.CellStyle.FillPattern == FillPattern.SolidForeground)
{
cellStyleBorderAndColor.FillPattern = FillPattern.SolidForeground;
//short cellBackground = source.CellStyle.FillForegroundColor;
//destination.CellStyle.FillForegroundColor = cellBackground;
destination.CellStyle.FillPattern = source.CellStyle.FillPattern;
}
// destination.CellComment = source.CellComment;
//destination.CellStyle = source.CellStyle;
//destination.Hyperlink = source.Hyperlink;
switch (source.CellType)
{
case CellType.Formula:
source.SetCellType(CellType.String);
var fontFormula = (XSSFFont)newbook.CreateFont();
var colorFormula = new XSSFColor(new byte[] { 0, 176, 80 });
var backGroundFormula = new XSSFColor(new byte[] { 142, 169, 219 });
destination.SetCellValue(source.StringCellValue);
if (col == 13 && destination.StringCellValue == "ОК")
{
fontFormula.SetColor(colorFormula);
cellStyleBorderAndColor.SetFont(fontFormula);
}
break;
case CellType.Numeric:
destination.SetCellValue(source.NumericCellValue);
break;
case CellType.String:
//var fontString = (XSSFFont)newbook.CreateFont();
//var colorString = new XSSFColor(new byte[] { 0, 176, 80 });
destination.SetCellValue(source.StringCellValue);
//if (col == 13 && destination.StringCellValue == "ОК" )
//{
// fontString.SetColor(colorString);
// cellStyleBorderAndColor.SetFont(fontString);
//}
break;
}
}
}
#endregion
//========================= метод OpenWorkbook ==========================================
/// <summary>
/// Метод считывания данных из файла в поток
/// </summary>
/// <param name="path">путь к файлу</param>
/// <returns></returns>
#region OpenWorkbook(string path)
IWorkbook[] OpenWorkbook(string[] path)
{
IWorkbook[] workbook = new IWorkbook[100];
for (int i = 0; i < path.Length; i++)
{
if (path[i] == null)
break;
else
{
using (FileStream fileStream = new FileStream(path[i], FileMode.Open, FileAccess.Read))
{
workbook[i] = WorkbookFactory.Create(fileStream);
}
XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workbook[i]);
}
}
return workbook;
}
#endregion
//======================= метод Сохранения потока в книгу =================================
/// <summary>
/// Метод записи данных из потока в файл
/// </summary>
/// <param name="workbook"> книга для записи</param>
/// <param name="path">источник данных</param>
#region SaveWorkbook(IWorkbook workbook, string path)
void SaveWorkbook(IWorkbook workbook, string path)
{
try
{
using (var fileStream = new FileStream(path, FileMode.CreateNew, FileAccess.Write))
{
workbook.Write(fileStream);
}
}
catch (Exception e)
{
MessageBox.Show($"Обнаружена ошибка в работе программы! \r\n Обратитесь к разработчику \r\n {e}");
}
}
#endregion
//===================== Обработчик нажатия кнопки Сформировать ==========================
/// <summary>
/// Обработчик кнопки Сформировать отчет
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
#region RepColl_Click(object sender, EventArgs e)
private void RepColl_Click(object sender, EventArgs e)
{
//--- Сохранение выбранного типа файла из ComboBox
string selectedState = TypeFile.SelectedItem.ToString();
if (sourceFolder.Text == "")
{
MessageBox.Show("Выберите каталог-источник");
}
else
if (tabNameBox.Text == "")
{
MessageBox.Show("Выберите вкладку");
}
else
if (rowNumberCopy.Text == "")
{
MessageBox.Show("Выберите начальную строку для копирования");
}
else
if (int.TryParse(rowNumberCopy.Text, out _) != true)
{
MessageBox.Show($"В поле: \r\n {label4.Text} \r\n введены некоректные данные");
}
else
if (countColumn.Text == "")
{
MessageBox.Show("Выберите количество колонок для копирования");
}
else
if (int.TryParse(countColumn.Text, out _) != true)
{
MessageBox.Show($"В поле: \r\n {label5.Text} \r\n введены некоректные данные");
}
else
if (isClickButtonUnloadFile == false && destinationFolder.Text == "")
{
MessageBox.Show("Вы не выбрали каталог для сохранения итогового файла!");
}
else
if (isClickButtonSelectAll == false && sourceFolder.Text == "")
MessageBox.Show("Вы не выбрали каталог с файлами для отчета");
else
{
ImportExcelHSSF_2(filesPath, selectedState);
//GC.Collect(0, GCCollectionMode.Forced);
}
}
#endregion
//============================== Метод выбора файла =====================================
/// <summary>
/// Метод выбора каталога-источника
/// </summary>
/// <returns>возвращает список файлов Excel</returns>
#region GetListFileExcel()
public string[] GetListFileExcel()
{
//Список для имен выбранных файлов
if (isClickButtonSelectAll == true)
{
// очищаем список листов после нового нажатия и формируем его заново
Array.Clear(fileList, 0, fileList.Length);
FolderBrowserDialog browser = new FolderBrowserDialog();
browser.SelectedPath = sourceFolder.Text;
if (sourceFolder.Text != "")
tempPath = sourceFolder.Text;
else
tempPath = "";
if (browser.ShowDialog() == DialogResult.OK)
{
if (new DirectoryInfo(browser.SelectedPath).GetFiles("*.xlsx").Any(x => x.Extension == ".xlsx"))
{
if (sourceFolder.Text != "")
{
sourceFolder.Refresh();
sourceFolder.Text = browser.SelectedPath;
tempPath = sourceFolder.Text;
}
else
tempPath = browser.SelectedPath; // prints path
}
else
MessageBox.Show("В указанном каталоге отсутствуют файлы Excel");
}
sourceFolder.Text = tempPath;
if (tempPath == "")
{
return null;
}
else
{
for (int i = 0; i < Directory.GetFiles(tempPath).Length; i++)
{
fileList[i] = Directory.GetFiles(tempPath)[i];
}
return fileList;
}
}
else
return null;
}
#endregion
//================== Обработчик нажатия кнопки выбора исходных файлов ========================
/// <summary>
/// Обработчик нажатия кнопки Выбор из источника
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
#region SelectAll_Click
public void SelectAll_Click(object sender, EventArgs e)
{
tabNameBox.Items.Clear();
isClickButtonSelectAll = true;
filesPath = GetListFileExcel();
if (filesPath == null)
{
MessageBox.Show("Файлы не выбраны");
}
else
{
GetBooksSource(filesPath);
//GetNameListWorkBooks(filesPath);
}
}
#endregion
//=============== Обработчик нажатия кнопки сохранения агрегированного файла ==========================
/// <summary>
/// Обработчик нажатия кнопки Выбор для указания места сохранения готового файла
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
#region unloadFile_Click
public void UnloadFile_Click(object sender, EventArgs e)
{
isClickButtonUnloadFile = true;
pathFile = destinationFolder.Text;
GetNameFileIntoButton(pathFile);
}
#endregion
private void tabNameBox_SelectedIndexChanged(object sender, EventArgs e)
{
selectedStateTabName = tabNameBox.SelectedItem.ToString();
}
// ======================== Метод сохранения и получения имени файла ================================
/// <summary>
/// Метод вызова диалога для сохранения файла и задание названия
/// </summary>
/// <param name="getPath"></param>
/// <returns></returns>
#region GetNameFileIntoButton(string getPath)
string GetNameFileIntoButton(string getPath)
{
FolderBrowserDialog browser2 = new FolderBrowserDialog();
browser2.SelectedPath = destinationFolder.Text;
if (browser2.ShowDialog() == DialogResult.OK)
{
if (getPath == "")
{
destinationFolder.Text = browser2.SelectedPath;
return destinationFolder.Text;
}
else
{
browser2.SelectedPath = destinationFolder.Text;
return destinationFolder.Text;
}
}
else
{
if(destinationFolder.Text == "")
MessageBox.Show("Укажите путь для сохранения файла!");
return null;
}
}
#endregion
//================== Обработчик нажатия кнопки Запустить ========================
/// <summary>
/// Обработчик нажатия кнопки Запустить установку конфига
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
#region
private void ButStartFormConfig_Click(object sender, EventArgs e)
{
//Запуск второй формы с настройками конфига
ConfigSettings cs = new ConfigSettings
{
Owner = this
};
cs.ShowDialog();
}
#endregion
//============ Обработчик события на нажатие в текстовое поле "Имя Файла"
/// <summary>
/// Обработчик события на нажатие в текстовое поле "Имя Файла"
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
#region fileNameBox_MouseClick(object sender, MouseEventArgs e)
private void fileNameBox_MouseClick(object sender, MouseEventArgs e)
{
// -- Формирование имени конечного файла
string selectedState = TypeFile.SelectedItem.ToString();
if (tabNameBox.SelectedItem == null)
MessageBox.Show("Ввод имени файла осуществляйте в последнюю очередь!!!");
else
{
fileNameFiished = tabNameBox.SelectedItem.ToString() + "-" + selectedState + ".xlsx";
fileNameBox.Text = fileNameFiished;
}
}
#endregion
}
}