Esempio n. 1
0
void StoreImpl::Save(const char *filename) const
{
    Util::ScopedLock lock(m_pimpl->operationsCS);

    XML::CXML xml(WebWatchTag);
    
    xml << *m_pimpl->rootGroup;
    
    xml << m_pimpl->siteListSettings;
    
    XML::CXML *xmlWindowPlacement = xml.CreateChild(WindowPlacementTag);
    ConvertWindowPlacementToXML(m_pimpl->wp, *xmlWindowPlacement);
    
    ASSERT(m_pimpl->muSettings.get());
    xml << *m_pimpl->muSettings;
    
    ASSERT(m_pimpl->checkSettings.get());
    xml << *m_pimpl->checkSettings;

    xml << m_pimpl->siteGroupsTreeSettings;

    ASSERT(m_pimpl->generalSettings.get());
    xml << *m_pimpl->generalSettings;

    // Make a per-save backup of configuration file
    if (IsFileExistent(filename)) {
        MakeBackup(filename, perSave, 
                   AfxGetApp()->GetMainWnd()->GetSafeHwnd());
    }

    if (xml.SaveAs(filename) == false)
        throw StoreError(FormatCantSaveError(filename));
}
Esempio n. 2
0
bool TEvManMainManager::Initialize()
   {
      Q_D(TEvManMainManager);
      ExtSys::TPluginManager *pm = ExtSys::TPluginManager::Instance();
      pm->AddObject(d->DBSettings);


      CorePlugin::TActionManager *am = CorePlugin::ICore::Instance()->ActionManager();
      QAction *Action;
      CorePlugin::TAction *Cmd;

      QMenu *FileMenu = am->Menu(CorePlugin::Constants::MENU_FILE);
      Action = new QAction(QIcon(Constants::ICON_SYNC_ALL), "Sync All", CorePlugin::ICore::Instance()->MainWindow());
      Cmd = am->RegisterAction(Action,
                               Constants::ACTION_SYNC_ALL,
                               CorePlugin::TContext() << CorePlugin::Constants::CONTEXT_GLOBAL,
                               CorePlugin::ICore::Instance()->MainWindow());
      FileMenu->addAction(Cmd->Action());
      Cmd->SetDefaultKeySequence(QKeySequence("Ctrl+Shift+S"));
      connect(Action, SIGNAL(triggered()), this, SLOT(SyncAll()));

      QMenu *Tools = am->Menu(CorePlugin::Constants::MENU_TOOLS);
      Action = new QAction("Backup Now", CorePlugin::ICore::Instance()->MainWindow());
      Cmd = am->RegisterAction(Action,
                               Constants::ACTION_BACKUP_NOW,
                               CorePlugin::TContext() << CorePlugin::Constants::CONTEXT_GLOBAL,
                               CorePlugin::ICore::Instance()->MainWindow());
      Tools->addAction(Cmd->Action());
      Cmd->SetDefaultKeySequence(QKeySequence("Ctrl+Shift+B"));
      connect(Action, SIGNAL(triggered()), d->BackupAndRestoreManager, SLOT(MakeBackup()));

      d->BackupAndRestoreManager->Initialize();

      return true;
   }
Esempio n. 3
0
void __fastcall TForm1::actSortClassificationsExecute(TObject *Sender)
{
	if(!MakeBackup()) {
		Log->Lines->Add("Ошибка: Не удалось создать резервную копию файла");
		return;
	}

	Variant app = Variant::CreateObject("Excel.Application");
	app.OlePropertySet("Visible", true);
	Variant excel = app.OlePropertyGet("Workbooks").OleFunction("Open", WideString(m_strFileName.c_str()));
	Variant vSheets = excel.OlePropertyGet("Worksheets");

	Variant vSheet = vSheets.OlePropertyGet("Item",m_nPageClassification);
	UnicodeString strPageName = vSheet.OlePropertyGet("Name");
	if (strPageName.UpperCase() != UnicodeString("классификации").UpperCase()) {
	   app.OleProcedure("Quit");
	   Log->Lines->Add("Ошибка: Не верное имя страницы");
	   MessageBox (Handle, UnicodeString(L"Не верное имя страницы").c_str(), L"prompt", MB_OK);
	   return;
	};
	std::vector<exlClass> classes;
	ReadClassifications(vSheet, classes);
	WriteClassifications(vSheet, classes);


	Log->Lines->Add("Сохраняю файл...");
	try {
		app.OlePropertySet("DisplayAlerts",false);
		excel.OleProcedure("SaveAs", WideString(m_strFileName.c_str()));
		Log->Lines->Add("Классификации отсортированы!");
	} catch (...) {
		Log->Lines->Add("Ошибка: Пожалуйста закройте все открытые копии файла и повторите операцию");
	}
	app.OleProcedure("Quit");
}
//---------------------------------------------------------------------------
int Table::ConsistencyCheck(int in)
{
	char path_lock[_MAX_PATH];
	char drive[_MAX_DRIVE];
	char dir[_MAX_DIR];
	char fname[_MAX_FNAME];
	char ext[_MAX_EXT];

	_splitpath( Name, drive, dir, fname, ext );
	_makepath( path_lock, drive, dir, fname, ".lck");

	if (access(path_lock, 0)) // file does not exist
	{
		SetConsistencyInfo(CONSISTENCY_DONTKNOW);
		return 1; // no consistency check available, assume ok
	}

	FILE *lock = fopen(path_lock, "rb");
	if (!lock)
	{
		SetConsistencyInfo(CONSISTENCY_DONTKNOW);
		return 1; // failed to open lock, assume ok
	}


	unsigned int lockcrctable, lockcrcidx;
	fread(&lockcrctable, 4, 1, lock);
	fread(&lockcrcidx, 4, 1, lock);
	fclose(lock);
	unsigned int thiscrctable = crc32file(Name);
	unsigned int thiscrcidx = crc32file(IdxName);

	if (lockcrctable != thiscrctable || lockcrcidx != thiscrcidx)
	{
		if (in)
		{
			SetConsistencyInfo(CONSISTENCY_BACKUPCORRUPTED);
			return 0; // corrupted
		}
		if (!RestoreBackup())
		{
			SetConsistencyInfo(CONSISTENCY_CORRUPTED);
			return 0; // corrupted
		}
		if (!ConsistencyCheck(1))
			return 0;
		else
			SetConsistencyInfo(CONSISTENCY_RESTORED);
	}
	else
	{
		SetConsistencyInfo(CONSISTENCY_OK); // Data is valid, let's backup it if we need
		//  #ifdef DBBACKUP
		MakeBackup();
		//  #endif
	}

	return 1; // data is valid
}
Esempio n. 5
0
void Game_2048::Right() {
	// Сохраняем предыдущий ход
	MakeBackup();

	// Обновляем счетчик очков
	points = 0;

	// Смещаем все плитки в указанном направлении
	for (int i = 0; i < field_size; i++) {
		for (int j = field_size - 1; j >= 0; j--) {
			if (field[j][i] == 0) {
				for (int k = j - 1; k >= 0; k--) {
					if (field[k][i]) {
						field[j][i] = field[k][i];
						field[k][i] = 0;
						k = 0;
					}
				}
			}
		}
	}

	// Суммируем соседние плитки с одинаковыми значениями в указанном направлении
	for (int i = 0; i < field_size; i++) {
		for (int j = field_size - 1; j > 0; j--) {
			if (field[j][i] && field[j][i] == field[j - 1][i]) {
				field[j][i] += field[j - 1][i];
				field[j - 1][i] = 0;
				points += field[j][i];
				score += field[j][i];
			}
		}
	}

	// Снова смещаем все плитки в указанном направлении
	for (int i = 0; i < field_size; i++) {
		for (int j = field_size - 1; j >= 0; j--) {
			if (field[j][i] == 0) {
				for (int k = j - 1; k >= 0; k--) {
					if (field[k][i]) {
						field[j][i] = field[k][i];
						field[k][i] = 0;
						k = 0;
					}
				}
			}
		}
	}

	// Проверка окончания игры
	GameEndCheck();
}
Esempio n. 6
0
void Game_2048::Up() {
	// Сохраняем предыдущий ход
	MakeBackup();

	// Обновляем счетчик очков
	points = 0;

	// Смещаем все плитки в указанном направлении
	for (int i = 0; i < field_size; i++) {
		for (int j = 0; j < field_size; j++) {
			if (field[i][j] == 0) {
				for (int k = j + 1; k < field_size; k++) {
					if (field[i][k]) {
						field[i][j] = field[i][k];
						field[i][k] = 0;
						k = field_size;
					}
				}
			}
		}
	}

	// Суммируем соседние плитки с одинаковыми значениями в указанном направлении
	for (int i = 0; i < field_size; i++) {
		for (int j = 0; j < field_size - 1; j++) {
			if (field[i][j] && field[i][j] == field[i][j + 1]) {
				field[i][j] += field[i][j + 1];
				field[i][j + 1] = 0;
				points += field[i][j];
				score += field[i][j];
			}
		}
	}

	// Снова смещаем все плитки в указанном направлении
	for (int i = 0; i < field_size; i++) {
		for (int j = 0; j < field_size; j++) {
			if (field[i][j] == 0) {
				for (int k = j + 1; k < field_size; k++) {
					if (field[i][k]) {
						field[i][j] = field[i][k];
						field[i][k] = 0;
						k = field_size;
					}
				}
			}
		}
	}

	// Проверка окончания игры
	GameEndCheck();
}
Esempio n. 7
0
CFileBackup::CFileBackup(const CString& sFile, const CString& sFolder, BOOL bTimeStamp, const CString& sExt)
{
	MakeBackup(sFile, sFolder, bTimeStamp, sExt);
}
Esempio n. 8
0
void __fastcall TForm1::actRedesignClassificationsExecute(TObject *Sender)
{
	lblStatus->Caption = "";
	if(!MakeBackup()) {
		Log->Lines->Add("Не удалось создать резервную копию файла");
		lblStatus->Caption = "Ошибка: Не удалось создать резервную копию файла";
		return;
	}
	m_strRecomendations = "";

	lblStatus->Caption = "Открываю файл на чтение...";
	Variant app = Variant::CreateObject("Excel.Application");
    app.OlePropertySet("Visible", true);
	Variant excel = app.OlePropertyGet("Workbooks").OleFunction("Open", WideString(m_strFileName.c_str()));
	Variant vSheets = excel.OlePropertyGet("Worksheets");
	Variant vSheet = vSheets.OlePropertyGet("Item",m_nPageClassification);
	UnicodeString strPageName = vSheet.OlePropertyGet("Name");
	if (strPageName.UpperCase() != UnicodeString("классификации").UpperCase()) {
		app.OleProcedure("Quit");
		MessageBox (Handle, UnicodeString(L"Не верное имя страницы").c_str(), L"prompt", MB_OK);
		lblStatus->Caption = "Ошибка: Не верное имя страницы";
		return;
	};

	std::vector<exlClass> classes;
	ReadClassifications(vSheet, classes);

	std::vector<exlMonth> months;
	for (unsigned int i = 0; i < m_vMonth.size(); i++) {
		int nMonthPage = m_vMonth[i].Number;
		Variant vSheetMonth = vSheets.OlePropertyGet("Item",nMonthPage);
		ReadMonth(vSheetMonth, months);
	}
//	Log->Lines->Add("Обновляю линки." + IntToStr((int)months.size()));

	int nAll = classes.size() * months.size();
	Log->Lines->Add("Всего записей в месяцах: " + IntToStr((int)months.size()));
	std::vector<exlClass> newclasses;
	int nRemovedClasses = 0;
	ProgressBar1->Max = nAll;
	ProgressBar1->Min = 0;
	ProgressBar1->Position = 0;

	lblStatus->Caption = "Поиск наименований которые отсутвуют в месяцах...";
	Log->Lines->Add("Произвожу поиск наименований которые отсутвуют в месяцах...");
	for (unsigned int iC = 0; iC < classes.size(); iC++) {
		exlClass cl = classes[iC];
		cl.Monthes = "";
		UnicodeString name = classes[iC].Name.UpperCase();
		int nCount = 0;
		for (unsigned int iM = 0; iM < months.size(); iM++) {
			ProgressBar1->Position++;
			Application->ProcessMessages();
			UnicodeString name2 = months[iM].Name.UpperCase();
			if (name == name2) {
			   nCount++;
			   if (cl.Monthes.Pos(months[iM].Month) < 1) {
				  cl.Monthes += months[iM].Month + ";";
			   }
			}
		}
		if (nCount > 0) {
			newclasses.push_back(cl);
		} else {
			nRemovedClasses++;
			Log->Lines->Add("\tНаименование '" + cl.Name + "' - нигде не встречается и будет удалено из классификаций");
		}
	}
	Log->Lines->Add(" ** ");

	nAll = newclasses.size() * months.size();
	ProgressBar1->Max = nAll;
	ProgressBar1->Min = 0;
	ProgressBar1->Position = 0;
	int nAddClasses = 0;
	lblStatus->Caption = "Поиск наименований которые отсутвуют в списке классификаций...";
	Log->Lines->Add("Произвожу поиск наименований которые отсутвуют в списке классификаций...");
	for (unsigned int iM = 0; iM < months.size(); iM++) {
		UnicodeString name = months[iM].Name.UpperCase();
		int nCount = 0;
		for (unsigned int iC = 0; iC < newclasses.size(); iC++) {
			ProgressBar1->Position++;
			Application->ProcessMessages();
			UnicodeString name2 = newclasses[iC].Name.UpperCase();
			if (name == name2) {
			   nCount++;
			}
		}
		if (nCount == 0) {
			Log->Lines->Add("\tНаименование '" + months[iM].Name + "' - будет добавлено в классификации");
			exlClass cl;
			cl.Name = months[iM].Name;
			cl.Class = m_sUnknownClass;
			cl.Monthes += months[iM].Month + ";";
			newclasses.push_back(cl);
			nAddClasses++;

			nAll = newclasses.size() * months.size();
			ProgressBar1->Max = nAll;
		}
	}
	Log->Lines->Add("Будет удалено классификаций: " + IntToStr(nRemovedClasses));
    Log->Lines->Add("Будет добавлено классификаций: " + IntToStr(nAddClasses));
	Log->Lines->Add("Всего классификаций: " + IntToStr((int)(newclasses.size())));


	WriteClassifications(vSheet, newclasses);

	lblStatus->Caption = "Сохраняю файл...";
	Log->Lines->Add("Сохраняю файл...");
	try {
		app.OlePropertySet("DisplayAlerts",false);
		excel.OleProcedure("SaveAs", WideString(m_strFileName.c_str()));
		Log->Lines->Add("Данные сохранены!");
	} catch (...) {
		lblStatus->Caption = "Ошибка: Пожалуйста закройте все открытые копии файла и повторите операцию";
		Log->Lines->Add("Ошибка: Пожалуйста закройте все открытые копии файла и повторите операцию");
	}
    ProgressBar1->Position = 0;
	app.OleProcedure("Quit");
	lblStatus->Caption = "";
}
Esempio n. 9
0
void __fastcall TForm1::actCalcClassificationExecute(TObject *Sender)
{
	if(!MakeBackup()) {
		Log->Lines->Add("Не удалось создать резервную копию файла");
		return;
	}

	Variant app = Variant::CreateObject("Excel.Application");
	app.OlePropertySet("Visible", true);
	Variant excel = app.OlePropertyGet("Workbooks").OleFunction("Open", WideString(m_strFileName.c_str()));
	Variant vSheets = excel.OlePropertyGet("Worksheets");
	Variant vSheet = vSheets.OlePropertyGet("Item",m_nPageClassification);
	UnicodeString strPageName = vSheet.OlePropertyGet("Name");
	if (strPageName.UpperCase() != UnicodeString("классификации").UpperCase()) {
	   app.OleProcedure("Quit");
	   MessageBox (Handle, UnicodeString(L"Не верное имя страницы").c_str(), L"prompt", MB_OK);
	   return;
	};

	std::vector<exlClass> classes;
	ReadClassifications(vSheet, classes);

	std::vector<exlMonth> months;
	Variant vSheetMonth;
	double fSumSum = 0;
	for (unsigned int i = 0; i < m_vMonth.size(); i++) {
		if (cmbMonth->Text == m_vMonth[i].Name) {
			int nMonthPage = m_vMonth[i].Number;
			vSheetMonth = vSheets.OlePropertyGet("Item", nMonthPage);
			ReadMonth(vSheetMonth, months);
			ReadMonthSum(vSheetMonth, fSumSum);
		}
	}

	Log->Lines->Add("Произвожу расчет...");
    ProgressBar1->Max = months.size();
	ProgressBar1->Min = 0;
	double nSumHand = 0;

	std::vector<exlSumClass> vSumClasses;
	for (unsigned int i = 0; i < months.size(); i++) {
		ProgressBar1->Position = i;
		int nFound = 0;
		nSumHand += months[i].Price;
		for (unsigned int iC = 0; iC < classes.size(); iC++) {
			if (nFound == 0 && classes[iC].Name.UpperCase() == months[i].Name.UpperCase()) {
				months[i].Class = classes[iC].Class;
				months[i].LinkToClassification = createHyperLinkToClassification(classes, iC);
				nFound++;
			}
		}
		if (nFound == 0) {
			months[i].Class = m_sUnknownClass;
		}

		nFound = 0;
		for (unsigned int iC = 0; iC < vSumClasses.size(); iC++) {
			if (vSumClasses[iC].Name.UpperCase() == months[i].Class.UpperCase()) {
				vSumClasses[iC].Sum += months[i].Price;
				nFound++;
			}
		}
		if (nFound == 0) {
		   exlSumClass sm;
		   sm.Name = months[i].Class;
		   sm.Sum = months[i].Price;
		   vSumClasses.push_back(sm);
		}
	}

	/*for (unsigned int i = 0; i < vSumClasses.size(); i++) {
		Log->Lines->Add(vSumClasses[i].Name + " = " + FloatToStr(vSumClasses[i].Sum));
	}*/

	Log->Lines->Add("Готово.");

	Log->Lines->Add("Сортирую классификации...");
	ProgressBar1->Max = 100;
	ProgressBar1->Min = 0;

	{
		int nPermutation = 1;
		while (nPermutation > 0) {
			nPermutation = 0;
			for (unsigned int iC = 0; iC < vSumClasses.size()-1; iC++) {
				ProgressBar1->Position = (ProgressBar1->Position+1) % ProgressBar1->Max;
				Application->ProcessMessages();
				if (vSumClasses[iC].Name.UpperCase() > vSumClasses[iC+1].Name.UpperCase()) {
					exlSumClass buf = vSumClasses[iC];
					vSumClasses[iC] = vSumClasses[iC+1];
					vSumClasses[iC+1] = buf;
					nPermutation++;
				}
			}
		}
		ProgressBar1->Position = 0;
    }
	Log->Lines->Add("Готово.");

	Log->Lines->Add("Очистка старых данных");
	ProgressBar1->Max = 100;
	ProgressBar1->Min = 0;

	// clear sum classes, 11,12
	{
		bool b = true;
		int nRow = 1;
		while (b) {
			b = false;
			nRow++;
			ProgressBar1->Position = (ProgressBar1->Position+1) % ProgressBar1->Max;
			Application->ProcessMessages();

			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OleProcedure("ClearFormats");
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OleProcedure("ClearFormats");

			UnicodeString sValue11 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertyGet("Value");
			UnicodeString sValue12 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertyGet("Value");

			clearCell(vSheetMonth, nRow, 11);
			clearCell(vSheetMonth, nRow, 12);

			if (sValue12.Trim().Length() > 0 || sValue11.Trim().Length() > 0) {
				b = true;
			}
		}
		ProgressBar1->Position = 0;
	}

	// clear 14,15,16,17
	{
		bool b = true;
		int nRow = 1;
		while (b) {
			b = false;
			nRow++;
			ProgressBar1->Position = (ProgressBar1->Position+1) % ProgressBar1->Max;
			Application->ProcessMessages();

			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OleProcedure("ClearFormats");
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OleProcedure("ClearFormats");
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OleProcedure("ClearFormats");
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OleProcedure("ClearFormats");

			UnicodeString sValue14 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertyGet("Value");
			UnicodeString sValue15 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OlePropertyGet("Value");
			UnicodeString sValue16 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertyGet("Value");
			UnicodeString sValue17 = vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertyGet("Value");

			clearCell(vSheetMonth, nRow, 14);
			clearCell(vSheetMonth, nRow, 15);
			clearCell(vSheetMonth, nRow, 16);
			clearCell(vSheetMonth, nRow, 17);

			if (
				sValue14.Trim().Length() > 0
				|| sValue15.Trim().Length() > 0
				|| sValue16.Trim().Length() > 0
				|| sValue17.Trim().Length() > 0
			) {
				b = true;
			}
		}
		ProgressBar1->Position = 0;
	}


	Log->Lines->Add("Запись новых данных");
	{
		double nSum = 0;
		int nRow = 2;
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertySet("Value", WideString("Класс"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("Value", WideString("Сумма"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertyGet("Font").OlePropertySet("Bold", true);
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertyGet("Font").OlePropertySet("Bold", true);
		vSheetMonth.OlePropertyGet("Columns", WideString("K")).OlePropertySet("ColumnWidth", 20);
		vSheetMonth.OlePropertyGet("Columns", WideString("L")).OlePropertySet("ColumnWidth", 15);
		setBorders(vSheetMonth, nRow, 11);
		setBorders(vSheetMonth, nRow, 12);
		setColor(vSheetMonth, nRow, 11, RGBToInt(240, 230, 140));
		setColor(vSheetMonth, nRow, 12, RGBToInt(240, 230, 140));

		ProgressBar1->Max = vSumClasses.size();
		ProgressBar1->Min = 0;
		for (unsigned int i = 0; i < vSumClasses.size(); i++) {
			nRow++;
			ProgressBar1->Position = i;
			nSum += vSumClasses[i].Sum;
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertySet("Value", WideString(vSumClasses[i].Name));
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("Value", WideString(vSumClasses[i].Sum));

			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("NumberFormat", WideString(m_strNumberFormat));

			setBorders(vSheetMonth, nRow, 11);
			setBorders(vSheetMonth, nRow, 12);
		}
		nRow++;
		ProgressBar1->Position = 0;

		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertySet("Value", WideString("Итого:"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("Value", WideString(nSum));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("NumberFormat", WideString(m_strNumberFormat));

		nRow++;

		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,11).OlePropertySet("Value", WideString("Сумма сумм по дням:"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("Value", WideString(fSumSum));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,12).OlePropertySet("NumberFormat", WideString(m_strNumberFormat));
	}

	{
		double nSum = 0;
		int nRow = 2;
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertySet("Value", WideString("Класс"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OlePropertySet("Value", WideString("Наименование"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("Value", WideString("Цена"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertySet("Value", WideString("Ссылка"));

		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertyGet("Font").OlePropertySet("Bold", true);
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OlePropertyGet("Font").OlePropertySet("Bold", true);
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertyGet("Font").OlePropertySet("Bold", true);
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertyGet("Font").OlePropertySet("Bold", true);

		vSheetMonth.OlePropertyGet("Columns", WideString("N")).OlePropertySet("ColumnWidth", 20);
		vSheetMonth.OlePropertyGet("Columns", WideString("O")).OlePropertySet("ColumnWidth", 50);
		vSheetMonth.OlePropertyGet("Columns", WideString("P")).OlePropertySet("ColumnWidth", 15);
		vSheetMonth.OlePropertyGet("Columns", WideString("Q")).OlePropertySet("ColumnWidth", 50);

		setBorders(vSheetMonth, nRow, 14);
		setBorders(vSheetMonth, nRow, 15);
		setBorders(vSheetMonth, nRow, 16);
		setBorders(vSheetMonth, nRow, 17);

		setColor(vSheetMonth, nRow, 14, RGBToInt(240, 230, 140));
		setColor(vSheetMonth, nRow, 15, RGBToInt(240, 230, 140));
		setColor(vSheetMonth, nRow, 16, RGBToInt(240, 230, 140));
		setColor(vSheetMonth, nRow, 17, RGBToInt(240, 230, 140));

		ProgressBar1->Max = months.size();
		ProgressBar1->Min = 0;
		for (unsigned int i = 0; i < months.size(); i++) {
			nRow++;
			ProgressBar1->Position = i;
			nSum += months[i].Price;

			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertySet("Value", WideString(months[i].Class));
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,15).OlePropertySet("Value", WideString(months[i].Name));
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("Value", WideString(months[i].Price));
			vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("NumberFormat", WideString(m_strNumberFormat));

			if (months[i].Price < 0) {
				setColor(vSheetMonth, nRow, 16, RGBToInt(240, 230, 140));
			}


			// TODO: check linkt to classification
			// vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertySet("Value", WideString(months[i].LinkToClassification.c_str()));

			setBorders(vSheetMonth, nRow, 14);
			setBorders(vSheetMonth, nRow, 15);
			setBorders(vSheetMonth, nRow, 16);
			setBorders(vSheetMonth, nRow, 17);
		}
		nRow++;
		ProgressBar1->Position = 0;

		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,14).OlePropertySet("Value", WideString("Итого:"));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("Value", WideString(nSum));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,16).OlePropertySet("NumberFormat", WideString(m_strNumberFormat));
		vSheetMonth.OlePropertyGet("Cells").OlePropertyGet("Item",nRow,17).OlePropertySet("NumberFormat", WideString(m_strNumberFormat));
	}

	Log->Lines->Add("Сохраняю файл...");
	try {
		app.OlePropertySet("DisplayAlerts",false);
		excel.OleProcedure("SaveAs", WideString(m_strFileName.c_str()));
		Log->Lines->Add("Данные сохранены!");
	} catch (...) {
		Log->Lines->Add("Ошибка: Пожалуйста закройте все открытые копии файла и повторите операцию");
	}
    ProgressBar1->Position = 0;
	app.OleProcedure("Quit");
}