Example #1
0
BOOL CDBFExplorerDoc::OnSaveDocument(LPCTSTR lpszPathName) 
{
	// close database
	m_dBaseFile->Close();

	if (_tcscmp(m_szTempFileName, _T("")) != 0)
	{
		// copy memo file
		CString strMemoFile1 = m_dBaseFile->GetMemoFileName(m_szTempFileName);
		CString strMemoFile2 = m_dBaseFile->GetMemoFileName(lpszPathName);

		CopyFile(strMemoFile1, strMemoFile2, FALSE);

		if (CopyFile(m_szTempFileName, lpszPathName, FALSE))
		{
			// empty name
			lstrcpy(m_szTempFileName, _T(""));
			return OnOpenDocument(lpszPathName);
		}
		else
			return FALSE;
	}

	// copy memo file
	CString strMemoFile1 = m_dBaseFile->GetMemoFileName(GetPathName());
	CString strMemoFile2 = m_dBaseFile->GetMemoFileName(lpszPathName);

	CopyFile(strMemoFile1, strMemoFile2, FALSE);

	// make copy and open new file
	if (CopyFile(GetPathName(), lpszPathName, FALSE))
	{
		return OnOpenDocument(lpszPathName);
	}

	return OnOpenDocument(lpszPathName);
}
BOOL CTortoiseGitBlameDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
	CCmdLineParser parser(AfxGetApp()->m_lpCmdLine);
	if(parser.HasVal(_T("rev")) && m_bFirstStartup)
	{
		m_Rev=parser.GetVal(_T("rev"));
		m_bFirstStartup = false;
	}
	else
	{
		m_Rev.Empty();
	}

	return OnOpenDocument(lpszPathName,m_Rev);
}
Example #3
0
BOOL CDBFExplorerDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	CStructureDlg dlg(AfxGetMainWnd());
	dlg.m_strTitle = _T("Create New DBF file");
	if (dlg.DoModal() == IDOK)
	{
		TCHAR szPath[MAX_PATH];
		GetTempPath(_countof(szPath), szPath);
      _tmakepath(m_szTempFileName, NULL, szPath, GetTitle(), _T(DBF_FILEEXT));
		if (m_dBaseFile->Create(m_szTempFileName, dlg.m_strFieldArray) == DBASE_SUCCESS)
		{
			if (OnOpenDocument(m_szTempFileName))
			{
				SetModifiedFlag(TRUE);
				return TRUE;
			}
			return FALSE;
		}
	}
	return FALSE;
}
Example #4
0
void CDBFExplorerDoc::OnFileStructure() 
{
   USES_CONVERSION;
	CStructureDlg dlg(AfxGetMainWnd());

	// copy fieldnames
	for (size_t i = 0; i < m_dBaseFile->GetFieldCount(); i++)
	{
      DBF_FIELD_INFO info;
      if (m_dBaseFile->GetFieldInfo(i, &info))
		{
			CString strFieldData;
			strFieldData.Format(_T("%s,%c,%d,%d"), A2CT(info.name), dbf_gettype_ext2int(info.type), info.length, info.decimals);
			dlg.m_strFieldArray.Add(strFieldData);
		}
	}

	if (dlg.DoModal() == IDOK)
	{
		if(MessageBox(GetFocus(), _T("The database structure has been changed.\nSome data may be lost during the conversion of the database.\nAre you sure you want to apply the changes?"), _T("DBF Explorer"), MB_YESNO | MB_ICONQUESTION) == IDYES)
		{
			// close database
			m_dBaseFile->Close();
	
			CString strFileName, strFileBackup, strMemoBackup;

			// temp file ?
			if (_tcscmp(m_szTempFileName, _T("")) != 0)
			{
				strFileName = m_szTempFileName;
			}
			else
				strFileName = GetPathName();

			strFileBackup = strFileName;
			strMemoBackup = m_dBaseFile->GetMemoFileName(strFileName);

			// make backup names
			int nPos = strFileBackup.ReverseFind('\\');
			if (nPos != -1)
			{
				strFileBackup.SetAt(nPos+1, '_');
				strMemoBackup.SetAt(nPos+1, '_');
			}
			// delete existing backups
			DeleteFile(strFileBackup);
			DeleteFile(strMemoBackup);

			// make backup copy of existing file
			if (!MoveFile(strFileName, strFileBackup))
			{
				MessageBox(GetFocus(), _T("Error while making backup"), _T("Updating structure"), MB_ICONSTOP);
				return;
			}
			
			// make backup copy of memo file
			MoveFile(m_dBaseFile->GetMemoFileName(strFileName), strMemoBackup);

			// create file with new structure
			if (m_dBaseFile->Create(strFileName, dlg.m_strFieldArray) == DBASE_SUCCESS)
			{
				if (OnOpenDocument(strFileName))
				{
					CopyBackupData(strFileBackup);

					if (_tcscmp(m_szTempFileName, _T("")) != 0)
						SetModifiedFlag();

					// reload records
					POSITION pos = GetFirstViewPosition();
					while (pos)
						((CDBFExplorerView *)GetNextView(pos))->ShowRecords(GetActiveFrame()->m_bShowDeletedRecords);
				}
			}
		}
	}	
}
BOOL CEtsEodManagerDoc::OnNewDocument()
{
	if(!OnOpenDocument(g_App.m_strCurrentReportFilePath))
		return FALSE;

	SetPathName(g_App.m_strCurrentReportFilePath);
	return TRUE;
}
Example #6
-10
void CbelaviewDoc::OnReload() 
{
	// TODO: Add your command handler code here
	CString pname = GetPathName();
	if(pname.GetLength()>0)
	{
		OnNewDocument();
		SetPathName(pname,FALSE);
		OnOpenDocument(pname);
	}
}