// sp.cpp : Defines the class behaviors for the application. // //memory leak debugging help //#define _CRTDBG_MAP_ALLOC //#include //#include //_CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); //#define _CRTDBG_MAP_ALLOC //===================== #include "stdafx.h" #include "sp.h" #include "afxpriv.h" #include "MainFrm.h" #include "spDoc.h" #include "spView.h" #include "logindlg.h" #include "nullform.h" #include "UserPrefsDlg.h" #include "rpts.h" #include "dbutils.h" #include "srch.h" #include "stat.h" #include "snr.h" #include "LoanersDlg.h" #include "ArasClientRequests.h" #include "zonesdlg.h" #include "clientsdlg.h" #include "GroupsDlg.h" #include "UsersDlg.h" #include "simplewodlg.h" #include "nonclientsdlg.h" #include "projectsdlg.h" #include "modelsdlg.h" #include "mailreaderdlg.h" #include "UnitsDlg.h" #include "PartsDlg.h" #include "dlgtasks.h" #include "contactdlg.h" #include "WOHeaderDlg.h" #include "WOTypesDlg.h" #include "RatesDlg.h" #include "RptSetDlg.h" #include "PMCheckDlg.h" #include "TED.H" //<---for displaying info while developing #include "schedulefrm.h" #include "SchedGrps.h" #include "DlgSchedMarkers.h" #include "probstatdlg.h" #include "ayasysinfo.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CSpApp BEGIN_MESSAGE_MAP(CSpApp, CWinApp) //{{AFX_MSG_MAP(CSpApp) ON_COMMAND(ID_APP_ABOUT, OnAppAbout) ON_COMMAND(ID_VIEW_WORKORDERS, OnViewWorkorders) ON_COMMAND(ID_EXIT, OnExit) ON_COMMAND(ID_OPTIONS_REPORTS, OnOptionsReports) ON_COMMAND(ID_OPTIONS_EDIT_CLIENTS, OnOptionsEditClients) ON_COMMAND(ID_OPTIONS_EDIT_ZONES, OnOptionsEditZones) ON_COMMAND(ID_OPTIONS_EDIT_USERS, OnOptionsEditUsers) ON_COMMAND(ID_OPTIONS_EDIT_TASKS, OnOptionsEditTasks) ON_COMMAND(ID_OPTIONS_EDIT_UNITS, OnOptionsEditUnits) ON_COMMAND(ID_OPTIONS_EDIT_UNITMODELS, OnOptionsEditUnitmodels) ON_COMMAND(ID_OPTIONS_EDIT_PARTS, OnOptionsEditParts) ON_COMMAND(ID_OPTIONS_EDIT_PROJECTS, OnOptionsEditProjects) ON_COMMAND(ID_TOOLS_SECURITY, OnToolsSecurity) ON_COMMAND(ID_OPTIONS_EDIT_ADDRESSBOOK_COURIERSSHIPPERS, OnOptionsEditAddressbookCouriersshippers) ON_COMMAND(ID_VIEW_MAIL, OnViewMail) ON_COMMAND(ID_OPTIONS_EDIT_RATES, OnOptionsEditRates) ON_COMMAND(ID_OPTIONS_EDIT_ADDRESSBOOK_MANUFACTURERSSUPPLIERS, OnOptionsEditAddressbookManufacturerssuppliers) ON_COMMAND(ID_OPTIONS_EDIT_ADDRESSBOOK_RESELLERSCOMPETITORS, OnOptionsEditAddressbookResellerscompetitors) ON_COMMAND(ID_OPTIONS_EDIT_ADDRESSBOOK_SUBCONTRACTORS, OnOptionsEditAddressbookSubcontractors) ON_COMMAND(ID_OPTIONS_EDIT_WORKORDERTYPES, OnOptionsEditWorkordertypes) ON_COMMAND(ID_HELP_EMAILTECHSUPPORT, OnHelpEmailtechsupport) ON_COMMAND(ID_HELP_SUGGESTIONS, OnHelpSuggestions) ON_COMMAND(ID_HELP_VISITOURWEBSITE, OnHelpVisitourwebsite) ON_COMMAND(ID_SEARCH, OnSearch) ON_COMMAND(ID_VIEW_DATABASE, OnViewDatabase) ON_COMMAND(ID_VIEW_SHIPPINGRECEIVING, OnViewShippingreceiving) ON_COMMAND(ID_FILE_LOANERSRENTALS, OnFileLoanersrentals) ON_COMMAND(ID_FILE_PMCHECK, OnFilePmcheck) ON_COMMAND(ID_REPORTS, OnReports) ON_COMMAND(ID_OPTIONS_USER, OnOptionsUser) ON_COMMAND(ID_VISUAL_SCHEDULE, OnVisualSchedule) ON_COMMAND(ID_HELP_PURCHASE, OnHelpPurchase) ON_COMMAND(ID_OPTIONS_EDIT_SCHEDGRPS, OnOptionsEditSchedgrps) ON_COMMAND(ID_OPTIONS_EDIT_SCHEDMARKERS, OnOptionsEditSchedmarkers) ON_COMMAND(ID_VIEW_ARAS_SERVICE_REQUESTS, OnViewArasServiceRequests) ON_COMMAND(ID_CONTEXT_HELP, DoHelp) ON_COMMAND(ID_HELP_MANUAL, OnHelpManual) //}}AFX_MSG_MAP // Standard file based document commands ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew) ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen) ON_COMMAND(ID_NC_ADDRESS, OnNcAddress) ON_COMMAND(ID_NC_ADDRESS2, OnNcAddress2) ON_COMMAND(ID_NC_ADDRESS3, OnNcAddress3) ON_COMMAND(ID_NC_ADDRESS4, OnNcAddress4) ON_COMMAND(ID_ACCELERATOR_CLIENTS, OnAcceleratorClients) ON_COMMAND(ID_ACCELERATOR_CATEGORIES, OnAcceleratorCategories) ON_COMMAND(ID_ACCELERATOR_EXIT, OnAcceleratorExit) ON_COMMAND(ID_ACCELERATOR_MODELS, OnAcceleratorModels) ON_COMMAND(ID_ACCELERATOR_PARTS, OnAcceleratorParts) ON_COMMAND(ID_ACCELERATOR_PROJECTS, OnAcceleratorProjects) ON_COMMAND(ID_ACCELERATOR_RATES, OnAcceleratorRates) ON_COMMAND(ID_ACCELERATOR_SCHEDULE_GROUPS, OnAcceleratorScheduleGroups) ON_COMMAND(ID_ACCELERATOR_SCHEDULE_MARKERS, OnAcceleratorScheduleMarkers) ON_COMMAND(ID_ACCELERATOR_TASKS, OnAcceleratorTasks) ON_COMMAND(ID_ACCELERATOR_UNITS, OnAcceleratorUnits) ON_COMMAND(ID_ACCELERATOR_ZONES, OnAcceleratorZones) ON_COMMAND(ID_ACCELERATOR_STATUS, OnAcceleratorStatus) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CSpApp construction CSpApp::CSpApp() : m_bDefShowHGridOnMainScreen(false) { // Place all significant initialization in InitInstance m_lusrID=0; m_lRegLicCount=-1;//ANYTHING m_strRegCompany=""; m_bTech=false; m_lDefNewWOStatus=0; m_lDefClosedWOStatus=0; m_lDefReOpenWOStatus=0; m_bUseTransactions=false; } ///////////////////////////////////////////////////////////////////////////// // The one and only CSpApp object CSpApp theApp; ///////////////////////////////////////////////////////////////////////////// // CSpApp initialization BOOL CSpApp::InitInstance() { { // BLOCK: doc template registration // Register the document template. Document templates serve // as the connection between documents, frame windows and views. // Attach this form to another document or frame window by changing // the document or frame class in the constructor below. CSingleDocTemplate* pNewDocTemplate = new CSingleDocTemplate( IDR_SCHEDULEFRM_TMPL, RUNTIME_CLASS(CSpDoc), // document class RUNTIME_CLASS(CMainFrame), // frame class RUNTIME_CLASS(CScheduleFrm)); // view class AddDocTemplate(pNewDocTemplate); } { // BLOCK: doc template registration // Register the document template. Document templates serve // as the connection between documents, frame windows and views. // Attach this form to another document or frame window by changing // the document or frame class in the constructor below. CSingleDocTemplate* pNewDocTemplate = new CSingleDocTemplate( IDR_NULLFORM_TMPL, RUNTIME_CLASS(CSpDoc), // document class RUNTIME_CLASS(CMainFrame), // frame class RUNTIME_CLASS(CNullForm)); // view class AddDocTemplate(pNewDocTemplate); } { // BLOCK: doc template registration // Register the document template. Document templates serve // as the connection between documents, frame windows and views. // Attach this form to another document or frame window by changing // the document or frame class in the constructor below. CSingleDocTemplate* pNewDocTemplate = new CSingleDocTemplate( IDR_SNR_TMPL, RUNTIME_CLASS(CSpDoc), // document class RUNTIME_CLASS(CMainFrame), // frame class RUNTIME_CLASS(CSnR)); // view class AddDocTemplate(pNewDocTemplate); } { // BLOCK: doc template registration // Register the document template. Document templates serve // as the connection between documents, frame windows and views. // Attach this form to another document or frame window by changing // the document or frame class in the constructor below. CSingleDocTemplate* pNewDocTemplate = new CSingleDocTemplate( IDR_DBUTILS_TMPL, RUNTIME_CLASS(CSpDoc), // document class RUNTIME_CLASS(CMainFrame), // frame class RUNTIME_CLASS(CDBUtils)); // view class AddDocTemplate(pNewDocTemplate); } { // BLOCK: doc template registration // Register the document template. Document templates serve // as the connection between documents, frame windows and views. // Attach this form to another document or frame window by changing // the document or frame class in the constructor below. CSingleDocTemplate* pNewDocTemplate = new CSingleDocTemplate( IDR_SRCH_TMPL, RUNTIME_CLASS(CSpDoc), // document class RUNTIME_CLASS(CMainFrame), // frame class RUNTIME_CLASS(SRCH)); // view class AddDocTemplate(pNewDocTemplate); } { // BLOCK: doc template registration // Register the document template. Document templates serve // as the connection between documents, frame windows and views. // Attach this form to another document or frame window by changing // the document or frame class in the constructor below. CSingleDocTemplate* pNewDocTemplate = new CSingleDocTemplate( IDR_STAT_TMPL, RUNTIME_CLASS(CSpDoc), // document class RUNTIME_CLASS(CMainFrame), // frame class RUNTIME_CLASS(STAT)); // view class AddDocTemplate(pNewDocTemplate); } { // BLOCK: doc template registration // Register the document template. Document templates serve // as the connection between documents, frame windows and views. // Attach this form to another document or frame window by changing // the document or frame class in the constructor below. CSingleDocTemplate* pNewDocTemplate = new CSingleDocTemplate( IDR_RPTS_TMPL, RUNTIME_CLASS(CSpDoc), // document class RUNTIME_CLASS(CMainFrame), // frame class RUNTIME_CLASS(RPTS)); // view class AddDocTemplate(pNewDocTemplate); } AfxInitRichEdit( ); AfxOleInit(); AfxEnableControlContainer(); // initialise the RDC object variables to NULL m_Report = NULL; pSections = NULL; pSection = NULL; pRepObjects = NULL; pRepObject = NULL; pApplication = NULL; InitializeRDC(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. //#ifdef _AFXDLL // Enable3dControls(); // Call this when using MFC in a shared DLL //#else // Enable3dControlsStatic(); // Call this when linking to MFC statically //#endif // Change the registry key under which our settings are stored. // TODO: You should modify this string to be something appropriate // such as the name of your company or organization. //SetRegistryKey(_T("Ground Zero Tech-Works")); //LoadStdProfileSettings(0); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CSpDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CSpView)); AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo,dummy; //ParseCommandLine(cmdInfo); //added 07/26/2001 for hyperlinks hcHand=LoadCursor(IDC_GZHAND); if(!VerifyData()) return false; CLoginDlg d; if(d.DoModal()==IDCANCEL) { //rsPool->Empty(); //delete rsPool; return false; } //added 08/03/2001 to stop errors //just before an update rsPool->SupressErrors(true); //DISPLAY STARTUP SCREEN.... m_pDlgStartUp=new CDlgStartUp; m_pDlgStartUp->Create(IDD_DLGSTARTUP); m_pDlgStartUp->ShowWindow(SW_SHOW); m_pDlgStartUp->m_pc.SetPos(0); m_pDlgStartUp->UpdateWindow(); m_nCmdShow=SW_HIDE; // Dispatch commands specified on the command line if (!ProcessShellCommand(dummy))//<-causing flicker return FALSE; //ProcessShellCommand(dummy);//<-causing flicker //m_pMainWnd->ShowWindow(SW_HIDE);//SW_SHOWMAXIMIZED); /*** Begin modification of default InitInstance ***/ m_nCurView = 0; // Save index of the currently active view class // Keep array of views as member of WinApp CView* pActiveView = ((CFrameWnd*) m_pMainWnd)->GetActiveView(); m_pViews[0] = pActiveView; //default view m_pDlgStartUp->m_pc.SetPos(1); m_pDlgStartUp->UpdateWindow(); m_pViews[1] = (CView*) new RPTS; m_pDlgStartUp->m_pc.SetPos(2); m_pDlgStartUp->UpdateWindow(); m_pViews[2] = (CView*) new STAT; m_pDlgStartUp->m_pc.SetPos(3); m_pDlgStartUp->UpdateWindow(); m_pViews[3] = (CView*) new SRCH; m_pDlgStartUp->m_pc.SetPos(4); m_pDlgStartUp->UpdateWindow(); m_pViews[4] = (CView*) new CDBUtils; m_pDlgStartUp->m_pc.SetPos(5); m_pDlgStartUp->UpdateWindow(); m_pViews[5] = (CView*) new CSnR; m_pDlgStartUp->m_pc.SetPos(6); m_pDlgStartUp->UpdateWindow(); m_pViews[6] = (CView*) new CNullForm; m_pDlgStartUp->m_pc.SetPos(7); m_pDlgStartUp->UpdateWindow(); m_pViews[7] = (CView*) new CScheduleFrm; //and 3 and 4 and 5 and 6 etc etc etc m_pDlgStartUp->m_pc.SetPos(8); m_pDlgStartUp->UpdateWindow(); CDocument* pCurrentDoc = ((CFrameWnd*) m_pMainWnd)->GetActiveDocument(); // Initialize a CCreateContext to point to the active document. // With this context, the new view is added to the document // when the view is created in CView::OnCreate(). CCreateContext newContext; newContext.m_pNewViewClass = NULL; newContext.m_pNewDocTemplate = NULL; newContext.m_pLastView = NULL; newContext.m_pCurrentFrame = NULL; newContext.m_pCurrentDoc = pCurrentDoc; //default window size, gets resized later. CRect rect(0, 0, 0, 0); m_pDlgStartUp->m_pc.SetPos(9); m_pDlgStartUp->UpdateWindow(); //iterate through each additional form, //making sure to start at 1 to exclude the default view //which has all the initialization done automatically. for ( int nView=1; nViewCreate(NULL, NULL, (AFX_WS_DEFAULT_VIEW & ~WS_VISIBLE), rect, m_pMainWnd, AFX_IDW_PANE_FIRST + nView, &newContext); //initialize each *extra* view m_pViews[nView]->OnInitialUpdate(); m_pDlgStartUp->m_pc.SetPos(9+nView); m_pDlgStartUp->UpdateWindow(); } /*** End modification of default InitInstance ***/ // The one and only window has been initialized, so show and update it. m_pMainWnd->UpdateWindow(); if(VerifyDatabaseVersion()==false) { //added 08/03/2001 to stop errors //just before an update rsPool->SupressErrors(false); //CLOSE STARTUP WINDOW m_pDlgStartUp->DestroyWindow(); m_bBadDatabaseVersion=true; SwitchView(4); } else { //added 08/03/2001 to stop errors //just before an update rsPool->SupressErrors(false); m_bBadDatabaseVersion=false; SwitchView(4); if(Allowed(RSTAT,true)!=0) SwitchView(2); else SwitchView(6); m_pDlgStartUp->m_pc.SetPos(18); m_pDlgStartUp->UpdateWindow(); } m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED); //CLOSE STARTUP WINDOW m_pDlgStartUp->DestroyWindow(); Test(); return TRUE; } CView* CSpApp::SwitchView( UINT nIndex ) { ASSERT( nIndex >=0 && nIndex < NUMVIEWS ); int nSecure; CView* pNewView = m_pViews[nIndex]; CView* pActiveView = ((CFrameWnd*) m_pMainWnd)->GetActiveView(); if ( !pActiveView ) // No currently active view return NULL; if ( pNewView == pActiveView ) // Already there return pActiveView; switch(nIndex) { case 1: nSecure=Allowed(RREPORTS,true); if(nSecure==0 || nSecure==2) { SecurityWarning(); return pActiveView; } break; case 3://search if(Allowed(RSEARCH,false)==0) { SecurityWarning(); return pActiveView; } break; case 4: //v1.9.3.0 commented out as the menu security handles this now //and it was preventing the bootscan from being called when a user //logs in that doesn't have rights to the dbutils screen so //PM processing was not getting done in some cases. //if(Allowed(RDBUTIL,false)==0) //{ // //SecurityWarning(); // return pActiveView; //} break; case 5: if(Allowed(RSNR,false)==0) { SecurityWarning(); return pActiveView; } break; case 6: if(Allowed(RSCHEDULE,false)==0) { SecurityWarning(); return pActiveView; } break; } ProcessActiveViewClose(); m_nCurView = nIndex; // Store the new current view's index // exchange view window ID's so RecalcLayout() works UINT temp = ::GetWindowLong(pActiveView->m_hWnd, GWL_ID); ::SetWindowLong(pActiveView->m_hWnd, GWL_ID, ::GetWindowLong(pNewView->m_hWnd, GWL_ID)); ::SetWindowLong(pNewView->m_hWnd, GWL_ID, temp); // Display and update the new current view - hide the old one pActiveView->ShowWindow(SW_HIDE); pNewView->ShowWindow(SW_SHOW); ((CFrameWnd*) m_pMainWnd)->SetActiveView(pNewView); ((CFrameWnd*) m_pMainWnd)->RecalcLayout(); ProcessActiveViewOpen(); pNewView->Invalidate(); return pActiveView; } bool CSpApp::ProcessActiveViewClose() { CView* pActiveView = ((CFrameWnd*) m_pMainWnd)->GetActiveView(); if ( !pActiveView ) return TRUE; // No active view TO save data from, so count as success //check for each kind of view if ( pActiveView->IsKindOf( RUNTIME_CLASS(STAT) ) ) { ((STAT*)pActiveView)->DeActivate(); } else if ( pActiveView->IsKindOf( RUNTIME_CLASS(RPTS) ) ) { ((RPTS*)pActiveView)->DeActivate(); } else if ( pActiveView->IsKindOf( RUNTIME_CLASS(CSnR) ) ) { ((CSnR*)pActiveView)->DeActivate(); } else if ( pActiveView->IsKindOf( RUNTIME_CLASS(SRCH) ) ) { ((SRCH*)pActiveView)->DeActivate(); } else if ( pActiveView->IsKindOf( RUNTIME_CLASS(CDBUtils) ) ) { ((CDBUtils*)pActiveView)->DeActivate(); } else if ( pActiveView->IsKindOf( RUNTIME_CLASS(CScheduleFrm) ) ) { ((CScheduleFrm*)pActiveView)->DeActivate(); } //ETC ETC ETC return true; } bool CSpApp::ProcessActiveViewOpen() { CView* pActiveView = ((CFrameWnd*) m_pMainWnd)->GetActiveView(); if ( !pActiveView ) return TRUE; // No active view TO save data from, so count as success if ( pActiveView->IsKindOf( RUNTIME_CLASS(STAT) ) ) { ((STAT*)pActiveView)->Activate(); } else if ( pActiveView->IsKindOf( RUNTIME_CLASS(RPTS) ) ) { ((RPTS*)pActiveView)->Activate(); } else if ( pActiveView->IsKindOf( RUNTIME_CLASS(CSnR) ) ) { ((CSnR*)pActiveView)->Activate(); } else if ( pActiveView->IsKindOf( RUNTIME_CLASS(SRCH) ) ) { ((SRCH*)pActiveView)->Activate(); } else if ( pActiveView->IsKindOf( RUNTIME_CLASS(CDBUtils) ) ) { ((CDBUtils*)pActiveView)->Activate(); } else if ( pActiveView->IsKindOf( RUNTIME_CLASS(CSpView) ) ) { ((CSpView*)pActiveView)->Activate(); } else if ( pActiveView->IsKindOf( RUNTIME_CLASS(CScheduleFrm) ) ) { ((CScheduleFrm*)pActiveView)->Activate(); } //ETC ETC ETC return true; } void CSpApp::SetMainCaption(CString pCaption) { ((CFrameWnd*) m_pMainWnd)->SetWindowText(pCaption); } ///////////////////////////////////////////////////////////////////////////// // CAboutDlg dialog used for App About #include "modulver.h" #include "label.h" class CAboutDlg : public CDialog { public: CAboutDlg(); CSpApp* m_pApp; // Dialog Data //{{AFX_DATA(CAboutDlg) enum { IDD = IDD_ABOUTBOX }; CStatic m_lblBuild; //}}AFX_DATA // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAboutDlg) protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: //{{AFX_MSG(CAboutDlg) virtual BOOL OnInitDialog(); afx_msg void OnBtnsupportinfo(); //}}AFX_MSG DECLARE_MESSAGE_MAP() public: CLabel m_lblEmail; CLabel m_lblWebSite; afx_msg void OnStnClickedLblEmailSupport(); afx_msg void OnStnClickedLblSupportSite(); }; CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) { //{{AFX_DATA_INIT(CAboutDlg) //}}AFX_DATA_INIT } void CAboutDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CAboutDlg) DDX_Control(pDX, IDC_LBLBUILD, m_lblBuild); //}}AFX_DATA_MAP m_pApp = (CSpApp*)AfxGetApp(); DDX_Control(pDX, IDC_LBL_EMAIL_SUPPORT, m_lblEmail); DDX_Control(pDX, IDC_LBL_SUPPORT_SITE, m_lblWebSite); } BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) //{{AFX_MSG_MAP(CAboutDlg) ON_BN_CLICKED(IDC_BTNSUPPORTINFO, OnBtnsupportinfo) //}}AFX_MSG_MAP ON_STN_CLICKED(IDC_LBL_EMAIL_SUPPORT, OnStnClickedLblEmailSupport) ON_STN_CLICKED(IDC_LBL_SUPPORT_SITE, OnStnClickedLblSupportSite) END_MESSAGE_MAP() // App command to run the dialog void CSpApp::OnAppAbout() { CAboutDlg aboutDlg; aboutDlg.DoModal(); } ///////////////////////////////////////////////////////////////////////////// // CSpApp message handlers #include "RPTS.h" #include "STAT.h" #include "SRCH.h" #include "DBUtils.h" #include "SnR.h" #include "NullForm.h" #include "ScheduleFrm.h" #include "afxwin.h" /* m_pViews[0] = pActiveView; //default view m_pViews[1] = (CView*) new RPTS; m_pViews[2] = (CView*) new STAT; m_pViews[3] = (CView*) new SRCH; m_pViews[4] = (CView*) new CDBUtils; */ //Print builtin report using user settings if found void CSpApp::PrintCMReportRDC(CString VirtReportName,_RecordsetPtr m_pRecordSet) { CString strLocalError; CWaitCursor cw; //Get printer and report settings GZRset* rs; rs=rsPool->GetRS("CSpApp::PrintCMReportRDC"); cryp=new GZK; CString strErr; CString m_strPORT; CString m_strDEVICE; CString m_strDRIVER; long lPaperOrientation; long lPaperSize; long lPaperSource; long lDuplexType; _variant_t vtCopies; vtCopies=(long)1; CString q,msg,ReportName,str1,str2,strReportVersion; long lData; bool Preview,UseDefaults,defaultprinter,bData; UseDefaults=false; short copies=1; //FIND master report name q.Format("SELECT rptsmaster.filename FROM rptsmaster " "WHERE (((rptsmaster.virtualname)=\"%s\"));",VirtReportName); rs->QueryReadOnly(q); ASSERT(!rs->IsEmpty()); rs->FetchField("filename",&str1); ReportName=ReportDirectory() + str1; cw.Restore(); q.Format("SELECT rptsusers.* FROM rptsusers " "WHERE (((rptsusers.virtualname)=\"%s\") AND " "((rptsusers.user)=%u));",VirtReportName,m_lusrID); rs->QueryReadOnly(q); if(rs->IsEmpty()) { //DEFAULTS TO USE IF NO USER RECORD UseDefaults=true; defaultprinter=true; Preview=true; copies=1; } else { rs->FetchField("defaultprtr",&bData); if(bData) defaultprinter=true; else { defaultprinter=false; //PRINTER SETTINGS rs->FetchField("porient",&lPaperOrientation); rs->FetchField("psize",&lPaperSize); rs->FetchField("psource",&lPaperSource); rs->FetchField("pduplex",&lDuplexType); rs->FetchField("port",&m_strPORT); rs->FetchField("device",&m_strDEVICE); rs->FetchField("driver",&m_strDRIVER); } //CUSTOM REPORT rs->FetchField("filename",&str1); if(str1!="na") ReportName=str1;//already = master default ARRRR! //COPIES rs->FetchField("copies",&lData); vtCopies=lData; //PREVIEW rs->FetchField("preview",&bData); Preview=bData; } cw.Restore(); //Output or preview the report VARIANT vtFalse; VariantInit(&vtFalse); vtFalse.vt=VT_BOOL; vtFalse.boolVal=FALSE; VARIANT vtTrue; VariantInit(&vtTrue); vtTrue.vt=VT_BOOL; vtTrue.boolVal=TRUE; //preview report selected try{//start of try block for reporting (Crystal rdc) stuff cw.Restore(); strLocalError.Format("open report %s",ReportName); m_Report = pApplication->OpenReport(_bstr_t(ReportName)); strLocalError="set the data source"; cw.Restore(); m_Report->Database->Tables->GetItem(1)->SetDataSource(_variant_t((IDispatch *)m_pRecordSet,true)); //Set the OLE object (logo) source /*ISectionsPtr Sections; ISectionPtr Section; IReportObjectsPtr Objects; Sections=m_Report->Sections(); Section=Sections->GetItem(0); Objects=Section->ReportObjects();*/ //set custom report settings if any if(defaultprinter==false) { cw.Restore(); strLocalError="Set custom printer settings"; if(!m_strDEVICE.IsEmpty())//not the default printer? m_Report->SelectPrinter(_bstr_t(m_strDRIVER),_bstr_t(m_strDEVICE),_bstr_t(m_strPORT)); m_Report->PutPaperOrientation((CRPaperOrientation)lPaperOrientation); m_Report->PutPaperSize((CRPaperSize)lPaperSize); m_Report->PutPaperSource((CRPaperSource)lPaperSource); m_Report->PutPrinterDuplex((CRPrinterDuplexType)lDuplexType); } if(Preview) { cw.Restore(); strLocalError="preview the report onscreen"; CReportViewerDlg d; d.m_Report=m_Report; if(d.DoModal()==-1) { strLocalError="Preview the report onscreen"; } } else m_Report->PrintOut(vtFalse,vtCopies); }//end try block for report (Crystal rdc) stuff catch(_com_error& e) { _bstr_t bstrSource(e.Source()); _bstr_t bstrDescription(e.Description()); TRACE("*************************************************\n"); TRACE("Exception thrown for classes generated by #import\n"); TRACE("\tCode = %081x\n", e.Error); TRACE("\tCode Meaning = %s\n", e.ErrorMessage()); TRACE("\tSource = %s\n", (LPCTSTR) bstrSource); TRACE("Description = %s\n", (LPCTSTR) bstrDescription); TRACE("*************************************************\n"); strErr.Format( "Printing error: AyaNova asked the Crystal Reports RDC printing engine\r\n" "to print your report, but the RDC returned the following error instead:\r\n\r\n" "Code = %x\r\n" "Code Meaning = %s\r\n" "Source = %s\r\n" "Description = %s\r\n\r\n" "This error came at the point where AyaNova had just asked the RDC to\r\n" "%s.\r\n\r\n\r\n" "See the \"Errors and problems printing\" page on our web site at:\r\n" "http://www.ayanova.com/faq_technical.htm\r\n" "to resolve this problem.\r\n\r\n" "(It is recommended that you copy this error message and save it to a text file\r\n" "in case you need to send this error message to AyaNova technical support.)\r\n", e.Error,e.ErrorMessage(),(LPCTSTR) bstrSource,(LPCTSTR) bstrDescription,strLocalError); ShowStuff(strErr); //HandleComError(e,strLocalError); } } // ////Print builtin report using user settings if found //void CSpApp::PrintCMReport(CString VirtReportName,_RecordsetPtr m_pRecordSet) //{ // PrintCMReportRDC(VirtReportName,m_pRecordSet); // return; // //TODO Verify printer before selecting!!!! // //rs=new GZRset("Error: Report settings screen "); // //rs->SetConnect(strConnectString); // //m_pRecordSet->GetActiveConnection(); // GZRset* rs; // rs=rsPool->GetRS("CSpApp::PrintCMReport"); // cryp=new GZK; // // CString m_strDEVMODE; // CString m_strPORT; // CString m_strDEVICE; // CString m_strDRIVER; // long m_lDevModeSize; // short pJob; // int bResult; // int nEngineVer=0,nDllVer=0; // CString q,msg,ReportName,str1,str2,strReportVersion; // long lData; // bool Preview,UseDefaults,defaultprinter,bData; // UseDefaults=false; // short copies=1; // LPDEVMODE dm; // dm=new DEVMODE; // //FIND master report name // q.Format("SELECT rptsmaster.filename FROM rptsmaster " // "WHERE (((rptsmaster.virtualname)=\"%s\"));",VirtReportName); // rs->QueryReadOnly(q); // ASSERT(!rs->IsEmpty()); // rs->FetchField("filename",&str1); // ReportName=ReportDirectory() + str1; // // q.Format("SELECT rptsusers.* FROM rptsusers " // "WHERE (((rptsusers.virtualname)=\"%s\") AND " // "((rptsusers.user)=%u));",VirtReportName,m_lusrID); // rs->QueryReadOnly(q); // if(rs->IsEmpty()) // { // //DEFAULTS TO USE IF NO USER RECORD // UseDefaults=true; // defaultprinter=true; // Preview=true; // copies=1; // // } // else//<<~~~~~~~~~~~~~~~~~~~~BUG BUG BUG // //if user has printer set to default why is this // //executing?? And later asserting... // { // rs->FetchField("defaultprtr",&bData); // if(bData) // defaultprinter=true; // else // { // defaultprinter=false; // //PRINTER SETTINGS // rs->FetchField("devmode",&m_strDEVMODE); // rs->FetchField("port",&m_strPORT); // rs->FetchField("device",&m_strDEVICE); // rs->FetchField("driver",&m_strDRIVER); // rs->FetchField("devmodesize",&m_lDevModeSize); // int x=(int)m_lDevModeSize; // //Decode DEVMODE // // // char* dc; // dc=new char[x]; // cryp->DecodeB64(&m_strDEVMODE,dc); // memcpy(dm,dc,x); // delete dc; // } // // //CUSTOM REPORT // rs->FetchField("filename",&str1); // if(str1!="na") // ReportName=str1;//already = master default ARRRR! // // // //COPIES // rs->FetchField("copies",&lData); // copies=(short)lData; // // // //PREVIEW // rs->FetchField("preview",&bData); // Preview=bData; // } // // // // // // Open report engine and report. // if (! PEOpenEngine()) // ::MessageBox(0, "Failed to open report engine.", "Error", MB_OK | MB_ICONEXCLAMATION); // // pJob = PEOpenPrintJob(ReportName); // // if (! pJob) // { // msg.Format("Failed to open report:%s",ReportName); // ::MessageBox(0, msg, "Error", MB_OK | MB_ICONEXCLAMATION); // } // // // Set ADO object as datasource of the report. // PETablePrivateInfo privateInfo; // memset(&privateInfo, 0, sizeof(PETablePrivateInfo)); // privateInfo.StructSize = sizeof(PETablePrivateInfo); // privateInfo.nBytes = sizeof(IDispatch FAR *); // privateInfo.tag = 3; // _variant_t idsp; // idsp = static_cast < IUnknown*>(m_pRecordSet); // privateInfo.dataPtr= (BYTE FAR *)&idsp.punkVal; // //******************************* // /* SUB REPORT INFO // 'Begin Method 2: // 'Quick method for setting private data. This method steps through the Object model in 'one 'line instead of creating and setting separate objects to reach the desired method. 'Make sure the Subreport name is known when using OpenSubreport method. // // Call crpReport.Database.Tables.Item(1).SetPrivateData(3, ADOrs1) // Set crpSubreport = crpReport.OpenSubreport("Subreport1") // Call crpSubreport.Database.Tables.Item(1).SetPrivateData(3, ADOrs2) // // 'End Method 2: // // 'Preview the Report. // crpReport.Preview // // End Sub // // // // */ // bResult = PESetNthTablePrivateInfo(pJob, 0, &privateInfo); // if (!bResult) // ::MessageBox(0, "PESetNthTablePrivateInfo failed.", "Error", MB_OK | MB_ICONEXCLAMATION); // // // //Custom printer? // if(defaultprinter!=true) // { // PESelectPrinter(pJob,m_strDRIVER, m_strDEVICE,m_strPORT,dm); // } // // // // //Added 1.7.2.0 // //Validate report and engine // PEReportSummaryInfo si; // PEGetReportSummaryInfo(pJob,&si); // // //validate the report version is ok // strReportVersion=si.subject; // if(!strReportVersion.IsEmpty() && strReportVersion.Find('.')!=-1) // { // if(CompareVersions(strReportVersion,m_strThisVersion)==0) // { // msg.Format( // "Warning: The report you are about to print:\r\n" // "%s\r\n" // "is designed for AyaNova version %s\r\n" // "You are running AyaNova version %s \r\n\r\n" // "There may be a problem printing this report.\r\n" // "Ensure you have the correct copy of\r\n" // "the report file to match this version of AyaNova \r\n\r\n" // "If you need further assistance, copy this message and email it to \r\n" // "AyaNova technical support department: support@ayanova.com", // ReportName,strReportVersion, m_strThisVersion); // ShowStuff(msg); // // } // // } // // //Validate the engine version is new enough // nEngineVer=PEGetVersion(PE_GV_ENGINE); // if(nEngineVer==0) nEngineVer=1793;//because it may not exist on non development system // // nDllVer=PEGetVersion(PE_GV_DLL); // if(nDllVer==0) nDllVer=1793;//because it may not exist on non development system // //1793 // if(nEngineVer < 1793 || nDllVer < 1793) // { // msg.Format( // "Warning: Your crystal reports printing engine seems to be\r\n" // "an older version than was provided with AyaNova.\r\n\r\n" // "This could result in printing problems\r\n" // "The version just started on this computer is:\r\n" // "Engine:%i, Dll:%i\r\n" // "Both should be version 1793 or newer\r\n" // "Contact technical support with this message",nEngineVer,nDllVer); // ShowStuff(msg); // } // // // // // // //PREVIEW // if(Preview) // { // // bResult = PEOutputToWindow(pJob, "AyaNova - report", 50, 50, 550, 500, WS_MAXIMIZE | WS_SYSMENU,0); // if (!bResult) // ::MessageBox(0, "PEOutputToWindow failed.", "Error", MB_OK | MB_ICONEXCLAMATION); // // // //TEST CODE //#ifdef _DEBUG // // // //#endif // // // // //TEST CODE // // // // //defaults for print preview window // PEWindowOptions pwo; // pwo.StructSize = PE_SIZEOF_WINDOW_OPTIONS; // pwo.canDrillDown=PE_UNCHANGED; // pwo.hasCancelButton=PE_UNCHANGED; // pwo.hasCloseButton=TRUE;//PE_UNCHANGED; // pwo.hasExportButton=PE_UNCHANGED; // pwo.hasGroupTree=TRUE;//PE_UNCHANGED; // pwo.hasNavigationControls=PE_UNCHANGED; // pwo.hasPrintButton=PE_UNCHANGED; // pwo.hasPrintSetupButton=TRUE; // pwo.hasProgressControls=PE_UNCHANGED; // pwo.hasRefreshButton=PE_UNCHANGED; // pwo.hasSearchButton=TRUE;//PE_UNCHANGED; // pwo.hasZoomControl=PE_UNCHANGED; // pwo.showDocumentTips=PE_UNCHANGED; // pwo.showToolbarTips=TRUE;//PE_UNCHANGED; // // bResult = PESetWindowOptions(pJob,&pwo); // if (!bResult) // ::MessageBox(0, "PESetWindowOptions failed.", "Error", MB_OK | MB_ICONEXCLAMATION); // // // // // } // else // {//JUST PRINT DIRECTLY // // bResult = PEOutputToPrinter(pJob,copies); // if (!bResult) // ::MessageBox(0, "PEOutputToPrinter failed.", "Error", MB_OK | MB_ICONEXCLAMATION); // // } // bResult = PEStartPrintJob(pJob, TRUE); // if (!bResult) // ::MessageBox(0, "Failed to start print job.", "Error", MB_OK | MB_ICONEXCLAMATION); // // PEClosePrintJob(pJob); // // delete dm; // // //delete rs; // rsPool->ReleaseRS(&rs->m_nID); // delete cryp; // // //} //*************************** NEW SUB REPORT PRINTING OPTION ************************************ //Print builtin report using user settings if found void CSpApp::PrintSubCMReportRDC(CString VirtReportName, _RecordsetPtr m_pRecordSet, CString strSubName, _RecordsetPtr m_pSubRecordSet) { CString strLocalError; CWaitCursor cw; //Get printer and report settings GZRset* rs; rs=rsPool->GetRS("CSpApp::PrintCMReportRDC"); cryp=new GZK; CString strErr; CString m_strPORT; CString m_strDEVICE; CString m_strDRIVER; long lPaperOrientation; long lPaperSize; long lPaperSource; long lDuplexType; _variant_t vtCopies; vtCopies=(long)1; CString q,msg,ReportName,str1,str2,strReportVersion; long lData; bool Preview,UseDefaults,defaultprinter,bData; UseDefaults=false; short copies=1; //FIND master report name q.Format("SELECT rptsmaster.filename FROM rptsmaster " "WHERE (((rptsmaster.virtualname)=\"%s\"));",VirtReportName); rs->QueryReadOnly(q); ASSERT(!rs->IsEmpty()); rs->FetchField("filename",&str1); ReportName=ReportDirectory() + str1; q.Format("SELECT rptsusers.* FROM rptsusers " "WHERE (((rptsusers.virtualname)=\"%s\") AND " "((rptsusers.user)=%u));",VirtReportName,m_lusrID); rs->QueryReadOnly(q); if(rs->IsEmpty()) { //DEFAULTS TO USE IF NO USER RECORD UseDefaults=true; defaultprinter=true; Preview=true; copies=1; } else { rs->FetchField("defaultprtr",&bData); if(bData) defaultprinter=true; else { defaultprinter=false; //PRINTER SETTINGS rs->FetchField("porient",&lPaperOrientation); rs->FetchField("psize",&lPaperSize); rs->FetchField("psource",&lPaperSource); rs->FetchField("pduplex",&lDuplexType); rs->FetchField("port",&m_strPORT); rs->FetchField("device",&m_strDEVICE); rs->FetchField("driver",&m_strDRIVER); } //CUSTOM REPORT rs->FetchField("filename",&str1); if(str1!="na") ReportName=str1;//already = master default ARRRR! //COPIES rs->FetchField("copies",&lData); vtCopies=lData; //PREVIEW rs->FetchField("preview",&bData); Preview=bData; } //Output or preview the report VARIANT vtFalse; VariantInit(&vtFalse); vtFalse.vt=VT_BOOL; vtFalse.boolVal=FALSE; VARIANT vtTrue; VariantInit(&vtTrue); vtTrue.vt=VT_BOOL; vtTrue.boolVal=TRUE; //preview report selected try{//start of try block for reporting (Crystal rdc) stuff strLocalError.Format("open report %s",ReportName); m_Report = pApplication->OpenReport(_bstr_t(ReportName)); m_SubReport = m_Report->OpenSubreport(_bstr_t(strSubName)); strLocalError="set the Main report data source"; m_Report->Database->Tables->GetItem(1)->SetDataSource(_variant_t((IDispatch *)m_pRecordSet,true)); strLocalError="set the SUB report data source"; m_SubReport->Database->Tables->GetItem(1)->SetDataSource(_variant_t((IDispatch *)m_pSubRecordSet,true)); //set custom report settings if any if(defaultprinter==false) { if(!m_strDEVICE.IsEmpty())//not the default printer? m_Report->SelectPrinter(_bstr_t(m_strDRIVER),_bstr_t(m_strDEVICE),_bstr_t(m_strPORT)); m_Report->PutPaperOrientation((CRPaperOrientation)lPaperOrientation); m_Report->PutPaperSize((CRPaperSize)lPaperSize); m_Report->PutPaperSource((CRPaperSource)lPaperSource); m_Report->PutPrinterDuplex((CRPrinterDuplexType)lDuplexType); } if(Preview) { strLocalError="preview the report onscreen"; CReportViewerDlg d; d.m_Report=m_Report; if(d.DoModal()==-1) { strLocalError="Error during preview the report onscreen"; } } else m_Report->PrintOut(vtFalse,vtCopies); }//end try block for report (Crystal rdc) stuff catch(_com_error& e) { _bstr_t bstrSource(e.Source()); _bstr_t bstrDescription(e.Description()); TRACE("*************************************************\n"); TRACE("Exception thrown for classes generated by #import\n"); TRACE("\tCode = %081x\n", e.Error); TRACE("\tCode Meaning = %s\n", e.ErrorMessage()); TRACE("\tSource = %s\n", (LPCTSTR) bstrSource); TRACE("Description = %s\n", (LPCTSTR) bstrDescription); TRACE("*************************************************\n"); strErr.Format( "Error: AyaNova asked the Crystal Reports RDC printing engine\r\n" "to print your report, but the RDC returned the following error instead:\r\n\r\n" "Code = %x\r\n" "Code Meaning = %s\r\n" "Source = %s\r\n" "Description = %s\r\n\r\n" "This error came at the point where AyaNova had just asked the RDC to\r\n" "%s.\r\n\r\n\r\n" "See the \"Errors and problems printing\" page on our web site at:\r\n" "http://www.ayanova.com/faq_technical.htm\r\n" "to resolve this problem.\r\n\r\n" "(It is recommended that you copy this error message and save it to a text file\r\n" "in case you need to send this error message to AyaNova technical support.)\r\n", e.Error,e.ErrorMessage(),(LPCTSTR) bstrSource,(LPCTSTR) bstrDescription,strLocalError); ShowStuff(strErr); //HandleComError(e,strLocalError); } } //***************** END OF NEW SUB REPORT PRINTING OPTION ********************************** //print cm report with sub report test function //temporary only to test proof of concept //Print builtin report using user settings if found //void CSpApp::PrintSubCMReport(CString VirtReportName, _RecordsetPtr m_pRecordSet, CString strSubName, // _RecordsetPtr m_pSubRecordSet) //{ // // PrintSubCMReportRDC(VirtReportName, m_pRecordSet, strSubName, m_pSubRecordSet); // return; // // //TODO Verify printer before selecting!!!! // //rs=new GZRset("Error: Report settings screen "); // //rs->SetConnect(strConnectString); // //m_pRecordSet->GetActiveConnection(); // GZRset* rs; // rs=rsPool->GetRS("CSpApp::PrintCMReport"); // cryp=new GZK; // // CString m_strDEVMODE; // CString m_strPORT; // CString m_strDEVICE; // CString m_strDRIVER; // long m_lDevModeSize; // short pJob; // short pSubReport; // int bResult; // int nEngineVer=0,nDllVer=0; // CString q,msg,SubReportName,ReportName,str1,str2,strReportVersion; // long lData; // bool Preview,UseDefaults,defaultprinter,bData; // UseDefaults=false; // short copies=1; // LPDEVMODE dm; // dm=new DEVMODE; // //FIND master report name // q.Format("SELECT rptsmaster.filename FROM rptsmaster " // "WHERE (((rptsmaster.virtualname)=\"%s\"));",VirtReportName); // rs->QueryReadOnly(q); // ASSERT(!rs->IsEmpty()); // rs->FetchField("filename",&str1); // ReportName=ReportDirectory() + str1; // // // q.Format("SELECT rptsusers.* FROM rptsusers " // "WHERE (((rptsusers.virtualname)=\"%s\") AND " // "((rptsusers.user)=%u));",VirtReportName,m_lusrID); // rs->QueryReadOnly(q); // if(rs->IsEmpty()) // { // //DEFAULTS TO USE IF NO USER RECORD // UseDefaults=true; // defaultprinter=true; // Preview=true; // copies=1; // // } // else // { // rs->FetchField("defaultprtr",&bData); // if(bData) // defaultprinter=true; // else // { // defaultprinter=false; // //PRINTER SETTINGS // rs->FetchField("devmode",&m_strDEVMODE); // rs->FetchField("port",&m_strPORT); // rs->FetchField("device",&m_strDEVICE); // rs->FetchField("driver",&m_strDRIVER); // rs->FetchField("devmodesize",&m_lDevModeSize); // int x=(int)m_lDevModeSize; // //Decode DEVMODE // // // char* dc; // dc=new char[x]; // cryp->DecodeB64(&m_strDEVMODE,dc); // memcpy(dm,dc,x); // delete dc; // } // // //CUSTOM REPORT // rs->FetchField("filename",&str1); // if(str1!="na") // ReportName=str1;//already = master default ARRRR! // // // //COPIES // rs->FetchField("copies",&lData); // copies=(short)lData; // // // //PREVIEW // rs->FetchField("preview",&bData); // Preview=bData; // } // // // // // // Open report engine and report. // if (! PEOpenEngine()) // ::MessageBox(0, "Failed to open report engine.", "Error", MB_OK | MB_ICONEXCLAMATION); // // pJob = PEOpenPrintJob(ReportName); // // if (! pJob) // { // msg.Format("Failed to open report:%s",ReportName); // ::MessageBox(0, msg, "Error", MB_OK | MB_ICONEXCLAMATION); // } // // // Set ADO object as datasource of the report. // PETablePrivateInfo privateInfo; // memset(&privateInfo, 0, sizeof(PETablePrivateInfo)); // privateInfo.StructSize = sizeof(PETablePrivateInfo); // privateInfo.nBytes = sizeof(IDispatch FAR *); // privateInfo.tag = 3; // _variant_t idsp; // idsp = static_cast < IUnknown*>(m_pRecordSet); // privateInfo.dataPtr= (BYTE FAR *)&idsp.punkVal; // // bResult = PESetNthTablePrivateInfo(pJob, 0, &privateInfo); // if (!bResult) // ::MessageBox(0, "PESetNthTablePrivateInfo failed.", "Error", MB_OK | MB_ICONEXCLAMATION); // // // //******************************* // /* SUB REPORT INFO // 'Begin Method 2: // 'Quick method for setting private data. This method steps through the Object model // in 'one 'line instead of creating and setting separate objects to reach the desired method. // 'Make sure the Subreport name is known when using OpenSubreport method. // // Call crpReport.Database.Tables.Item(1).SetPrivateData(3, ADOrs1) // Set crpSubreport = crpReport.OpenSubreport("Subreport1") // Call crpSubreport.Database.Tables.Item(1).SetPrivateData(3, ADOrs2) // // 'End Method 2: // // 'Preview the Report. // crpReport.Preview // // End Sub // // // // */ // PETablePrivateInfo SubprivateInfo; // memset(&SubprivateInfo, 0, sizeof(PETablePrivateInfo)); // SubprivateInfo.StructSize = sizeof(PETablePrivateInfo); // SubprivateInfo.nBytes = sizeof(IDispatch FAR *); // SubprivateInfo.tag = 3; // _variant_t subidsp; // subidsp = static_cast < IUnknown*>(m_pSubRecordSet); // SubprivateInfo.dataPtr= (BYTE FAR *)&subidsp.punkVal; // // SubReportName=ReportDirectory()+strSubName; // pSubReport=PEOpenSubreport(pJob,strSubName); // // bResult = PESetNthTablePrivateInfo(pSubReport, 0, &SubprivateInfo); // if (!bResult) // ::MessageBox(0, "PESetNthTablePrivateInfo failed.", "Error", MB_OK | MB_ICONEXCLAMATION); // // // //END OF SUBREPORT CODE // //******************************************************************************************************* // // //Custom printer? // if(defaultprinter!=true) // { // PESelectPrinter(pJob,m_strDRIVER, m_strDEVICE,m_strPORT,dm); // } // // // // //Added 1.7.2.0 // //Validate report and engine // PEReportSummaryInfo si; // PEGetReportSummaryInfo(pJob,&si); // // //validate the report version is ok // strReportVersion=si.subject; // if(!strReportVersion.IsEmpty() && strReportVersion.Find('.')!=-1) // { // if(CompareVersions(strReportVersion,m_strThisVersion)==0) // { // msg.Format( // "Warning: The report you are about to print:\r\n" // "%s\r\n" // "is designed for AyaNova version %s\r\n" // "You are running AyaNova version %s \r\n\r\n" // "There may be a problem printing this report.\r\n" // "Ensure you have the correct copy of\r\n" // "the report file to match this version of AyaNova \r\n\r\n" // "If you need further assistance, copy this message and email it to \r\n" // "AyaNova technical support department: support@ayanova.com", // ReportName,strReportVersion, m_strThisVersion); // ShowStuff(msg); // // } // // } // // //Validate the engine version is new enough // nEngineVer=PEGetVersion(PE_GV_ENGINE); // if(nEngineVer==0) nEngineVer=1793;//because it may not exist on non development system // // nDllVer=PEGetVersion(PE_GV_DLL); // if(nDllVer==0) nDllVer=1793;//because it may not exist on non development system // //1793 // if(nEngineVer < 1793 || nDllVer < 1793) // { // msg.Format( // "Warning: Your crystal reports printing engine seems to be\r\n" // "an older version than was provided with AyaNova.\r\n\r\n" // "This could result in printing problems\r\n" // "The version just started on this computer is:\r\n" // "Engine:%i, Dll:%i\r\n" // "Both should be version 1793 or newer\r\n" // "Contact technical support with this message",nEngineVer,nDllVer); // ShowStuff(msg); // } // // // // // // //PREVIEW // if(Preview) // { // // bResult = PEOutputToWindow(pJob, "AyaNova - report", 50, 50, 550, 500, WS_MAXIMIZE | WS_SYSMENU,0); // if (!bResult) // ::MessageBox(0, "PEOutputToWindow failed.", "Error", MB_OK | MB_ICONEXCLAMATION); // // // //TEST CODE //#ifdef _DEBUG // // // //#endif // // // // //TEST CODE // // // // //defaults for print preview window // PEWindowOptions pwo; // pwo.StructSize = PE_SIZEOF_WINDOW_OPTIONS; // pwo.canDrillDown=PE_UNCHANGED; // pwo.hasCancelButton=PE_UNCHANGED; // pwo.hasCloseButton=TRUE;//PE_UNCHANGED; // pwo.hasExportButton=PE_UNCHANGED; // pwo.hasGroupTree=TRUE;//PE_UNCHANGED; // pwo.hasNavigationControls=PE_UNCHANGED; // pwo.hasPrintButton=PE_UNCHANGED; // pwo.hasPrintSetupButton=TRUE; // pwo.hasProgressControls=PE_UNCHANGED; // pwo.hasRefreshButton=PE_UNCHANGED; // pwo.hasSearchButton=TRUE;//PE_UNCHANGED; // pwo.hasZoomControl=PE_UNCHANGED; // pwo.showDocumentTips=PE_UNCHANGED; // pwo.showToolbarTips=TRUE;//PE_UNCHANGED; // // bResult = PESetWindowOptions(pJob,&pwo); // if (!bResult) // ::MessageBox(0, "PESetWindowOptions failed.", "Error", MB_OK | MB_ICONEXCLAMATION); // // // // // } // else // {//JUST PRINT DIRECTLY // // bResult = PEOutputToPrinter(pJob,copies); // if (!bResult) // ::MessageBox(0, "PEOutputToPrinter failed.", "Error", MB_OK | MB_ICONEXCLAMATION); // // } // bResult = PEStartPrintJob(pJob, TRUE); // if (!bResult) // ::MessageBox(0, "Failed to start print job.", "Error", MB_OK | MB_ICONEXCLAMATION); // // PEClosePrintJob(pJob); // // delete dm; // // //delete rs; // rsPool->ReleaseRS(&rs->m_nID); // delete cryp; // // //} ////**************************END OF TEST NEW PRINT REPORT ********** ////***************************************************************** // // ////************************************** //void CSpApp::PrintReport(CString ReportName,_RecordsetPtr m_pRecordSet) //{ // // // // call document report function // short pJob; // int bResult; // CString msg; // // Open report engine and report. // if (! PEOpenEngine()) // ::MessageBox(0, "Failed to open report engine.", "Error", MB_OK | MB_ICONEXCLAMATION); // // pJob = PEOpenPrintJob(ReportName); // // if (! pJob) // { // msg.Format("Failed to open report:%s",ReportName); // ::MessageBox(0, msg, "Error", MB_OK | MB_ICONEXCLAMATION); // } // // // Set ADO object as datasource of the report. // PETablePrivateInfo privateInfo; // memset(&privateInfo, 0, sizeof(PETablePrivateInfo)); // privateInfo.StructSize = sizeof(PETablePrivateInfo); // privateInfo.nBytes = sizeof(IDispatch FAR *); // privateInfo.tag = 3; // _variant_t idsp; // idsp = static_cast < IUnknown*>(m_pRecordSet); // privateInfo.dataPtr= (BYTE FAR *)&idsp.punkVal; // //******************************* // // bResult = PESetNthTablePrivateInfo(pJob, 0, &privateInfo); // if (!bResult) // ::MessageBox(0, "PESetNthTablePrivateInfo failed.", "Error", MB_OK | MB_ICONEXCLAMATION); // // // Preview report. // // pass this->hWnd for the last parameter to place the window inside another window // // use the WM_SIZE or WM_PAINT message to resize crystal when its parent window changes in size // CPrintDialog dlg(TRUE); // LPDEVMODE dm; // if(dlg.DoModal()==TRUE) // { // //LPDEVMODE devmode = dlg.GetDevMode() // dm=dlg.GetDevMode(); // PESelectPrinter(pJob,(LPCTSTR) dlg.GetDriverName(), (LPCTSTR) dlg.GetDeviceName(),(LPCTSTR) dlg.GetPortName(),dm); // } // // bResult = PEOutputToWindow(pJob, "AyaNova - report", 50, 50, 550, 500, WS_MAXIMIZE | WS_SYSMENU,0); // if (!bResult) // ::MessageBox(0, "PEOutputToWindow failed.", "Error", MB_OK | MB_ICONEXCLAMATION); // // bResult = PEStartPrintJob(pJob, TRUE); // if (!bResult) // ::MessageBox(0, "Failed to start print job.", "Error", MB_OK | MB_ICONEXCLAMATION); // // PEClosePrintJob(pJob); // // // //} //************************************** //create a .ttx file for reporting void CSpApp::CreateTTX(CString ReportName,_RecordsetPtr m_pRecordSet, bool bSilent) { ReportName= ReportDirectory() + ReportName; //Recordset pointer fixup declarations: _variant_t idsp;//holder for pointer to recordset //get the pointer for the recordset in required format idsp = static_cast < IUnknown*>(m_pRecordSet); //DLL calling declarations: typedef BOOL FAR (WINAPI *FDPROC)(BYTE FAR *lpUnk,LPCSTR fileName, BOOL bOverWriteExistingFile); HINSTANCE hinstLib; FDPROC ProcCreateTTX; BOOL fFreeResult; // Get a handle to the DLL module. hinstLib = LoadLibrary("p2smon.dll"); // If the handle is valid, try to get the function address. if (hinstLib != NULL) { ProcCreateTTX = (FDPROC) GetProcAddress(hinstLib, "CreateFieldDefFile"); // If the function address is valid, call the function. if (ProcCreateTTX != NULL) (ProcCreateTTX) ((BYTE FAR *)&idsp.punkVal,ReportName,TRUE); else AfxMessageBox("Error procuring CreateFieldDefFile function address"); // Free the DLL module. fFreeResult = FreeLibrary(hinstLib); //indicate success if(!bSilent) { ReportName=ReportName + " - DONE"; AfxMessageBox(ReportName); } } else AfxMessageBox("Error loading p2smon.dll"); } ////************************************** ////create a .ttx file and skeleton report, optionally launch report designer //void CSpApp::CreateTTXandReport(CString ReportName,CString DefName,_RecordsetPtr m_pRecordSet) //{ // ReportName=ReportDirectory() + ReportName; // DefName=ReportDirectory() + DefName; // // //Recordset pointer fixup declarations: // _variant_t idsp;//holder for pointer to recordset // //get the pointer for the recordset in required format // idsp = static_cast < IUnknown*>(m_pRecordSet); // // //DLL calling declarations: // typedef BOOL FAR (WINAPI *FDPROC)(BYTE FAR *lpUnk,LPCSTR ReportFile,LPCSTR FieldDefFile, BOOL bOverWriteExistingFile, BOOL LaunchDesigner); // HINSTANCE hinstLib; // FDPROC ProcCreateTTX; // BOOL fFreeResult; // // // Get a handle to the DLL module. // hinstLib = LoadLibrary("p2smon.dll"); // // If the handle is valid, try to get the function address. // if (hinstLib != NULL) // { // ProcCreateTTX = (FDPROC) GetProcAddress(hinstLib, "CreateReportOnRuntimeDS"); // // // If the function address is valid, call the function. // if (ProcCreateTTX != NULL) // (ProcCreateTTX) ((BYTE FAR *)&idsp.punkVal,ReportName,DefName,TRUE,TRUE); // else///m_pApp->CreateTTXandReport("c:\\test.ttx","C:\\test.rpt",rs->RecordSetPointer(),TRUE); // AfxMessageBox("Error procuring CreateFieldDefFile function address"); // // AfxMessageBox(ReportName); // // Free the DLL module. // fFreeResult = FreeLibrary(hinstLib); // // // } // else // AfxMessageBox("Error loading p2smon.dll"); // //} ////Get printer settings from user //void CSpApp::PrintSetup() //{ // // CPrintDialog dlg(TRUE); // if(dlg.DoModal()==TRUE) // { // // // (LPCTSTR) dlg.GetDeviceName(), // (LPCTSTR) dlg.GetPortName(), // (LPCTSTR) dlg.GetDriverName(); // dlg.m_pd; // // // // // // // } // //} //Return the report directory path with terminating slash CString CSpApp::ReportDirectory() { return m_strDBPATH; } void CSpApp::OnViewWorkorders() { SwitchView(2);//status screen } void CSpApp::OnAcceleratorExit() {OnExit();} void CSpApp::OnExit() { ProcessActiveViewClose(); //delete m_pViews[0];// = pActiveView; //default view //delete m_pViews[1];// = (CView*) new RPTS; //delete m_pViews[2];// = (CView*) new STAT; //delete m_pViews[3];// = (CView*) new SRCH; //delete m_pViews[4];// = (CView*) new CDBUtils; //delete m_pViews[5];// = (CView*) new CSnR; //delete m_pViews[6]; //delete m_pViews[7]; m_pViews[0]->DestroyWindow();// = pActiveView; //default view m_pViews[1]->DestroyWindow();// = (CView*) new RPTS; m_pViews[2]->DestroyWindow();// = (CView*) new STAT; m_pViews[3]->DestroyWindow();// = (CView*) new SRCH; m_pViews[4]->DestroyWindow();// = (CView*) new CDBUtils; m_pViews[5]->DestroyWindow();// = (CView*) new CSnR; m_pViews[6]->DestroyWindow(); m_pViews[7]->DestroyWindow();//CScheduleFrm rsPool->Empty(); delete rsPool; ((CFrameWnd*) m_pMainWnd)->PostMessage(WM_QUIT); //PostMessage(WM_QUIT); } //User report settings void CSpApp::OnOptionsReports() { CRptSetDlg d; d.DoModal(); } void CSpApp::OnAcceleratorClients() {OnOptionsEditClients();} void CSpApp::OnOptionsEditClients() { CClientsDlg d; d.DoModal(); } void CSpApp::OnAcceleratorZones() {OnOptionsEditZones();} void CSpApp::OnOptionsEditZones() { CZonesDlg zd; zd.DoModal(); } void CSpApp::OnOptionsEditUsers() { CUsersDlg d; d.DoModal(); } void CSpApp::OnAcceleratorTasks() {OnOptionsEditTasks();} void CSpApp::OnOptionsEditTasks() { CDlgTasks d; d.DoModal(); } void CSpApp::OnAcceleratorUnits() {OnOptionsEditUnits();} void CSpApp::OnOptionsEditUnits() { CUnitsDlg d; d.DoModal(); } void CSpApp::OnAcceleratorModels() {OnOptionsEditUnitmodels();} void CSpApp::OnOptionsEditUnitmodels() { CModelsDlg d; d.DoModal(); } void CSpApp::OnAcceleratorParts() {OnOptionsEditParts();} void CSpApp::OnOptionsEditParts() { CPartsDlg d; d.DoModal(); } void CSpApp::OnAcceleratorProjects() {OnOptionsEditProjects(); } void CSpApp::OnOptionsEditProjects() { CProjectsDlg d; //d.SetPassbackString(&str); d.DoModal(); } void CSpApp::OnAcceleratorStatus() { CProbStatDlg d; d.DoModal(); } void CSpApp::OnToolsSecurity() { CGroupsDlg d; d.DoModal(); } void CSpApp::OnViewMail() { CMailReaderDlg d; d.DoModal(); } void CSpApp::OnAcceleratorRates() {OnOptionsEditRates(); } void CSpApp::OnOptionsEditRates() { CRatesDlg d; d.DoModal(); } //ALT F3 void CSpApp::OnNcAddress3() {OpenNonClientAddressBook(3);} void CSpApp::OnOptionsEditAddressbookManufacturerssuppliers() {OpenNonClientAddressBook(3);} //ALT F2 void CSpApp::OnNcAddress2() {OpenNonClientAddressBook(2);} void CSpApp::OnOptionsEditAddressbookCouriersshippers() {OpenNonClientAddressBook(2);} //ALT F4 void CSpApp::OnNcAddress4() {OpenNonClientAddressBook(5);} void CSpApp::OnOptionsEditAddressbookResellerscompetitors() {OpenNonClientAddressBook(5);} //ALT F1 accelerator void CSpApp::OnNcAddress() {OpenNonClientAddressBook(1);} void CSpApp::OnOptionsEditAddressbookSubcontractors() {OpenNonClientAddressBook(1); } void CSpApp::OnAcceleratorCategories() {OnOptionsEditWorkordertypes();} void CSpApp::OnOptionsEditWorkordertypes() { CWOTypesDlg d; d.DoModal(); } //Schedule groups void CSpApp::OnAcceleratorScheduleGroups() {OnOptionsEditSchedgrps();} void CSpApp::OnOptionsEditSchedgrps() { CSchedGrps d; d.DoModal(); } //time off days and flags void CSpApp::OnAcceleratorScheduleMarkers() {OnOptionsEditSchedmarkers();} void CSpApp::OnOptionsEditSchedmarkers() { CDlgSchedMarkers d; d.DoModal(); } void CSpApp::OpenNonClientAddressBook(long ltype) { CNonClientsDlg d; d.SetType(<ype); d.DoModal(); } void CSpApp::OnHelpEmailtechsupport() { AfxMessageBox("Please include your registered company name as it appears \r\n" "on the main program screen or indicate if you are evaluating for our records.\r\n\r\n" "Please be as specific as possible when mailing tech support.\r\n" "If you have received an error message, include the exact message\r\n" "and what part of the program you were in when you received it.\r\n"); ShellExecute(NULL,"open","mailto:support@ayanova.com",NULL,NULL,SW_SHOWNORMAL); } void CSpApp::OnHelpSuggestions() { if(AfxMessageBox("We welcome all suggestions, many features in our software \r\n" "are suggested by our users. \r\n\r\n" "Would you like to make a suggestion now?\r\n(requires internet connection)",MB_YESNO)==IDYES) ShellExecute(NULL,"open","http://www.ayanova.com/feedback.aspx",NULL,NULL,SW_SHOWNORMAL); } void CSpApp::OnHelpManual() { if(AfxMessageBox( "View or download the complete AyaNova manual from our website. \r\n" "The manual contains a full reference to all areas of the program \r\n" "As well as tutorials, tips and tricks and answers to common questions\r\n\r\n" "Visit the manual page on our website now?\r\n(requires internet connection)",MB_YESNO)==IDYES) ShellExecute(NULL,"open","http://www.ayanova.com/manual.htm",NULL,NULL,SW_SHOWNORMAL); else AfxMessageBox("The manual can be found at www.ayanova.com"); } void CSpApp::OnHelpVisitourwebsite() {ShellExecute(NULL,"open","http://www.ayanova.com",NULL,NULL,SW_SHOWNORMAL);} void CSpApp::OnHelpPurchase() {ShellExecute(NULL,"open","http://www.ayanova.com/purchase.htm",NULL,NULL,SW_SHOWNORMAL);} void CSpApp::OnHelpLicense() {ShellExecute(NULL,"open","license.txt",NULL,NULL,SW_SHOWNORMAL);} //management reports void CSpApp::OnReports() {SwitchView(1);} void CSpApp::OnSearch() {SwitchView(3);} void CSpApp::OnVisualSchedule() {SwitchView(7);} void CSpApp::OnViewDatabase() {SwitchView(4); } void CSpApp::OnViewShippingreceiving() {SwitchView(5);} void CSpApp::OnFileLoanersrentals() { CLoanersDlg d; d.DoModal(); } void CSpApp::OnViewArasServiceRequests() { CArasClientRequests d; d.DoModal(); } void CSpApp::OnFilePmcheck() { CPMCheckDlg d; d.DoModal(); } void CSpApp::ShowStuff(CString strStuff) { CTED d; d.m_strText=strStuff; d.DoModal(); } bool CSpApp::VerifyData() { bool bUseSQLServer=false; CString StartIn,temp,folder,strDeadConnectString,strDeadQuery; CFileStatus cfs; GZK k; //CFile::GetStatus("scdata.sc",cfs); //---------changed 11/27/00 if(!CFile::GetStatus(SCDATAFILE,cfs)) { folder=cfs.m_szFullName; folder.Replace(SCDATAFILE,""); #ifdef AYQB temp.Format("Cannot locate data file %s in the current folder\r\n%s\r\n\r\n" "Note: If you have not run the AyaNova QuickBooks Interface trial edition\r\n" "program yet, then you should do so before running this special\r\n" "edition of AyaNova as the QuickBooks interface needs to create a special\r\n" "copy of your AyaNova database for use with this program.\r\n\r\n" "Otherwise...\r\n\r\n" "You should be running this program from the directory\r\n" "where your %s file is located, or preferrably\r\n" "you should set the StartIn property of the icon/shortcut\r\n" "you use to run this program to point to the location where your\r\n" "%s file is located.",SCDATAFILE,folder,SCDATAFILE,SCDATAFILE); #else temp.Format("Cannot locate data file %s in the current folder\r\n%s\r\n\r\n" "You should be running this program from the directory\r\n" "where your %s file is located, or preferrably\r\n" "you should set the StartIn property of the icon/shortcut\r\n" "you use to run this program to point to the location where your\r\n" "%s file is located.",SCDATAFILE,folder,SCDATAFILE,SCDATAFILE); #endif AfxMessageBox(temp); return false; } //------------------------- StartIn.Format("%s",cfs.m_szFullName); #ifdef _DEBUG //StartIn="F:\\data\\data\\scdata.sc"; #endif if( StartIn.IsEmpty()) { AfxMessageBox("Cannot locate data file\r\nHave you set your StartIn Icon property correctly?"); return false; } else { StartIn=StartIn.Left(StartIn.GetLength()-sizeof(SCDATAFILE));//ADDRESS.GZ0 trim 11 characters leave path m_strDBPATH=StartIn; #ifdef AYQB //encrypted database password= // {F0F35532-9DDB-4b58-A3D6-57C0F0971B74} //ALTER DATABASE PASSWORD NewPassword OldPassword //ALTER DATABASE PASSWORD administrator NULL //Standard connection string Jet OLEDB:Database Password=abraxis; strConnectString.Format("%s%s\\%s;Jet OLEDB:Database Password=%s;Mode = Share Exclusive;", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=", m_strDBPATH,SCDATAFILE,k.InLineDecrypt("wStSBeWasHK+XthZOWuHpw"/*1abraxis9*/)); #else //Standard connection string strConnectString.Format("%s%s\\%s;", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=", m_strDBPATH,SCDATAFILE); #endif //************************ //SQL SERVER TEST STUFF, REM OUT FOR PRODUCTION /* strConnectString.Format("DSN=ayanova;UID=sa;PWD=;"); bUseSQLServer=true; */ //********************************************** //Exclusive mode connect string temp.Format("%s%s\\%s;Mode = Share Exclusive;","Provider=Microsoft.Jet.OLEDB.4.0;Data Source=", m_strDBPATH,SCDATAFILE); strConnectStringExclusive=temp; //"DEAD" connection string strDeadConnectString.Format("%s%s%s;", "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=", m_strDBPATH,"\\empty.sc"); //Query used to open "dead" database strDeadQuery="SELECT nulltable.* FROM nulltable;"; //used by CSpApp::ReportDirectory() m_strDBPATH=m_strDBPATH+"\\"; //****************************************** //RECORDSET POOL OBJECT SETUP rsPool= new CGZRsetPool; rsPool->m_bSQLServer=bUseSQLServer; rsPool->m_strDBPATH=m_strDBPATH; //*********************************************** rsPool->strConnectString=strConnectString; rsPool->m_strLiveConnectString=strConnectString; rsPool->m_strLiveConnectStringExclusive=strConnectStringExclusive; rsPool->m_strDeadConnectString=strDeadConnectString; rsPool->m_strCloseQuery=strDeadQuery; rsPool->StartConnection(); } return true; } BOOL CAboutDlg::OnInitDialog() { CDialog::OnInitDialog(); CString str; CModuleVersion ver; if(ver.GetFileVersionInfo(_T("sc.exe"))) { // display file version from VS_FIXEDFILEINFO struct #ifdef AYQB str.Format("AyaNovaź CE QBI\n*** For use with QB trial interface only ***\nProgram build: QBI%d.%d.%d.%d Database version: %s\n" "Copyright (C) 1999-2004 Ground Zero Tech-Works Inc.", HIWORD(ver.dwFileVersionMS), LOWORD(ver.dwFileVersionMS), HIWORD(ver.dwFileVersionLS), LOWORD(ver.dwFileVersionLS),m_pApp->m_strDataVersion.Right(3)); #else str.Format("AyaNovaź CE\nProgram build: %d.%d.%d.%d Database version: %s\n" "Copyright (C) 1999-2004 Ground Zero Tech-Works Inc.", HIWORD(ver.dwFileVersionMS), LOWORD(ver.dwFileVersionMS), HIWORD(ver.dwFileVersionLS), LOWORD(ver.dwFileVersionLS),m_pApp->m_strDataVersion); #endif m_lblBuild.SetWindowText(str); } //make a EMAIL "hyperlink" m_lblEmail.SetTextColor(RGB(0,0,255)); m_lblEmail.SetFontUnderline(TRUE); m_lblEmail.SetLink(TRUE); m_lblEmail.SetLinkCursor(m_pApp->hcHand); m_lblEmail.SetLinkURL("mailto:support@ayanova.com"); //make a website "hyperlink" m_lblWebSite.SetTextColor(RGB(0,0,255)); m_lblWebSite.SetFontUnderline(TRUE); m_lblWebSite.SetLink(TRUE); m_lblWebSite.SetLinkCursor(m_pApp->hcHand); m_lblWebSite.SetLinkURL("http://www.ayanova.com"); SetWindowText("About AyaNova CE..."); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } //takes an int referring to the security item //in question and returns one of three ints //0=not allowed , 1=full, 2=read only //bRefresh true= refresh from database int CSpApp::Allowed(int right, bool bRefresh) { //**************************************************** //SECURITY RIGHTS /* #define NUMRIGHTS 26 #define RIGHTS_WORKORDERSTAT 0 //workorder status screen #define RIGHTS_WORKORDER 1 //workorder entry screen #define RIGHTS_SHIPPING 2 // shipping and receiving #define RIGHTS_MAIL 3 //use the mail system (no read only here) #define RIGHTS_DBASEUTILS 4 // use the database utilities #define RIGHTS_SECURITYGROUPS 5 // rights to create edit GROUPS #define RIGHTS_SEARCH 6 // access to the search screen #define RIGHTS_REPORTS 7 // access to the reporting screen not workorder printing #define RIGHTS_PRINTING 8 //able to change printing setup #define RIGHTS_CLIENTS 9 //CLIENTS SCREEN #define RIGHTS_RATES 10 //RATES SCREEN #define RIGHTS_ZONES 11 #define RIGHTS_UNITS 12 #define RIGHTS_MODELS 13 #define RIGHTS_PARTS 14 #define RIGHTS_TASKS 15 #define RIGHTS_PROJECTS 16 #define RIGHTS_WOTYPES 17 //BLAH #define RIGHTS_ADDRESSBOOKS 18 //MODIFY ADDRESS BOOKS #define RIGHTS_USERS 19 //RIGHT TO EDIT USERS AND PLACE IN GROUPS #define RIGHTS_PM 20 //preventative maintenance screen #define RIGHTS_LOANERS 21 //loaner equipment screen #define RIGHTS_SCHEDULE 22//scheduling screen #define RIGHTS_SCHED_GROUPS 23//schedule groups screen #define RIGHTS_SCHED_MARKERS 24//schedule groups screen #define RIGHTS_USERPREFS 25//user preferences */ //********************************************************** CString q,temp; int x; if(bRefresh) { GZRset* rs; rs=rsPool->GetRS("Error at:CSpApp::Allowed"); cryp=new GZK; q.Format("SELECT groups.b " "FROM groups " "WHERE (((groups.id)=%u));",m_lGroupID); rs->QueryReadOnly(q); if(rs->IsEmpty()) { AfxMessageBox("Invalid Group ID"); rsPool->ReleaseRS(&rs->m_nID); return 0;//no access } rs->FetchField("b",&temp); #ifdef AYQB temp="WFCLnNJiFR9P1a46lrBX89S4dB96+B4Ng7gw2oaG/tg"; #endif //GZRset* rs; //rs=rsPool->GetRS("Error at:CSpApp::Allowed"); rsPool->ReleaseRS(&rs->m_nID); cryp->GZDecrypt(&temp,false); m_strRights=temp.Right(NUMRIGHTS); delete cryp; } x = atoi(m_strRights.Mid(right,1)); return x; } //************************************************************************************ //display the secure area warning void CSpApp::SecurityWarning() { GZK c; c.gzMsgBox("SIzZ2ShI1lZ/mf3i5I1/FnG9/ctr1CdaVR1spykMOwd6tM1VEiw6JcRXw5qHVAqYA+9tUbcP" "INOYB6AsYO4vPo9Pg4zZJihTd79GmmDMHuIalcb/HXxYaZO3dS0Bz+rc",999); } void CSpApp::OnOptionsUser() { CUserPrefsDlg d; d.DoModal(); } void CSpApp::DoHelp() { //AfxMessageBox("HELP"); } void CSpApp::WinHelp(DWORD dwData, UINT nCmd) { int nIDNUM; //AfxMessageBox("WINHELP"); if(dwData==0x20080)//mainframe, means form has focus not dialog { //select which help topic to show for this form switch(m_nCurView) { case 1: nIDNUM=IDD_RPTS_FORM; break; case 2: nIDNUM=IDD_STAT_FORM; break; case 3://search nIDNUM=IDD_SRCH_FORM; break; case 4: nIDNUM=IDD_DBUTILS_FORM; break; case 5: nIDNUM=IDD_SNR_FORM; break; case 7://visual schedule nIDNUM=IDD_SCHEDULEFRM_FORM; break; } CWinApp::WinHelp (0x00020000 + nIDNUM,HELP_CONTEXT);//HELP_CONTEXTPOPUP); } else CWinApp::WinHelp(dwData, nCmd); //if zero then topic not found, should show generic } //Verify that the database matches this build //return true if it does or false if it doesn't //used in InitInstance in this class near the end //Added July 18th 2001 - verify program version //if this running program is older than database says //then exit immediately to prevent problems bool CSpApp::VerifyDatabaseVersion() { CString q,strThisVersion,strTargetVersion; //rs->Initialize("Error at:CSpApp::VerifyDatabaseVersion"); GZRset* rs; rs=rsPool->GetRS("CSpApp::VerifyDatabaseVersion"); //verify that this program version is not too old rs->QueryReadOnly("SELECT defaults.min_exe FROM defaults;"); if(!rs->IsEmpty()) { //GET the db version in the database defaults table rs->FetchField("min_exe",&strTargetVersion); //compare with allowed version, newer versions of the program are ok, //older ones are not. //********************************************* //********************************************* //********************************************* //SET THE APPLICATION VERSION NUMBER HERE: m_strThisVersion="1.9.4.0"; //********************************************* //********************************************* //********************************************* if(CompareVersions(m_strThisVersion,strTargetVersion)==0)//older? { rsPool->ReleaseRS(&rs->m_nID); q.Format( "Problem: This version of AyaNova is too old to work with the AyaNova\r\n" "database you have just accessed.\r\n\r\n" "This is AyaNova version %s\r\n" "Only version %s or newer can be used with this AyaNova database.\r\n\r\n" "This usually happens when a network of computers running AyaNova is upgraded\r\n" "or being upgraded to the latest version but this computer has not been upgraded yet.\r\n\r\n" "AyaNova will now close to protect your data.",m_strThisVersion,strTargetVersion); AfxMessageBox(q); ::PostQuitMessage(0); return true; } } rs->QueryReadOnly("SELECT defaults.versioninfo FROM defaults;"); if(rs->IsEmpty()) { AfxMessageBox("Can't validate database version, contact tech support."); rsPool->ReleaseRS(&rs->m_nID); return true;//no access } //GET the db version in the database defaults table rs->FetchField("versioninfo",&m_strDBVersion); rsPool->ReleaseRS(&rs->m_nID); //********************************************* //********************************************* //********************************************* //********************************************* //********************************************* //********************************************* #ifdef AYQB //SET THE VERSION NUMBER HERE: //CURRENTDBVERSION defined in dbutils if(m_strDBVersion!="9169" && m_strDBVersion!="9168" && m_strDBVersion!="9170" && m_strDBVersion!="9171")//<< (int)dtSpan.GetTotalSeconds()); } BOOL CSpApp::PeekAndPump() { static MSG msg; while (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) { if (!AfxGetApp()->PumpMessage()) { ::PostQuitMessage(0); return FALSE; } } return TRUE; } //compare this version to target version //if this version is older return 0 //if equal return 1 //if this version is newer return 2 //if there is an error return -1 int CSpApp::CompareVersions(CString strThisVersion, CString strTargetVersion) { bool bDone=false; CString strDigit; int nThisVersionDigit, nTargetVersionDigit; int nThisVersionStart=0,nThisVersionStop=0; int nTargetVersionStart=0,nTargetVersionStop=0; int nThisVersionLength=0,nTargetVersionLength=0; int nRetValue=-1;//assume error unless otherwise //prequalify nTargetVersionLength=strTargetVersion.GetLength(); nThisVersionLength=strThisVersion.GetLength(); if(strThisVersion.GetLength()<2 || strThisVersion.Find('.')==-1) return -1; if(strTargetVersion.GetLength()<2 || strTargetVersion.Find('.')==-1) return -1; //check digits one by one starting at the left //compare each pair while(!bDone) { //Get This version digit nThisVersionStop = strThisVersion.Find('.',nThisVersionStart); if(nThisVersionStop==-1)//end of string { strDigit=strThisVersion.Mid(nThisVersionStart,strThisVersion.GetLength()-nThisVersionStart); nThisVersionDigit=atoi(strThisVersion.Mid(nThisVersionStart,strThisVersion.GetLength()-nThisVersionStart)); bDone=true; } else//it's before the end of string { nThisVersionDigit=atoi(strThisVersion.Mid(nThisVersionStart,(nThisVersionStop-nThisVersionStart))); strDigit=strThisVersion.Mid(nThisVersionStart,(nThisVersionStop-nThisVersionStart)); } nThisVersionStart=nThisVersionStop+1; //Get target version digit nTargetVersionStop = strTargetVersion.Find('.',nTargetVersionStart); if(nTargetVersionStop==-1)//end of string { nTargetVersionDigit=atoi(strTargetVersion.Mid(nTargetVersionStart,strTargetVersion.GetLength()-nTargetVersionStart)); bDone=true; } else//it's before the end of string nTargetVersionDigit=atoi(strTargetVersion.Mid(nTargetVersionStart,(nTargetVersionStop-nTargetVersionStart))); nTargetVersionStart=nTargetVersionStop+1; //Newer? if(nThisVersionDigit>nTargetVersionDigit) { nRetValue=2;//newer bDone=true;//no need to go any further } //Older? if(nThisVersionDigit < nTargetVersionDigit) { nRetValue=0;//Older bDone=true;//no need to go any further } //Equal? No problem, just set retvalue to equal and keep going if(nThisVersionDigit == nTargetVersionDigit) nRetValue=1; } return nRetValue; } void CAboutDlg::OnBtnsupportinfo() { CString strUserInfo,strMsg,strDBInfo, strSysInfo,strProgramRanFrom, strProgFiles, strDBFiles, strTemp; CString strLogoFile,strLogoIsSample,strBMPAssociatedWith, strAssocAppName; char ch[1000]; COleDateTime dtData=COleDateTime::GetCurrentTime(); //v1.9.4.4 load version string that is used throughout program //this will be up to date when a release is made. CString strVersion; strVersion.LoadString(AFX_IDS_APP_TITLE); CWaitCursor cw; GetModuleFileName(NULL,ch,295); strProgramRanFrom=ch; //Get standard user info and company reg data strUserInfo.Format( "USER DATA\r\n" "Company: %s\r\n" "Current user: %s\r\n" "Program path: %s\r\n" "DB Path: %s\r\n" "DB Version: %s\r\n" "Program version: %s", m_pApp->m_strRegCompany, m_pApp->m_strCurrentUserName, strProgramRanFrom, m_pApp->m_strDBPATH, m_pApp->m_strDBVersion, strVersion); //Get all the regular info CAyaSysInfo si; strSysInfo=si.GetAllInfo(); //Get files in directories strTemp=strProgramRanFrom.Left(strProgramRanFrom.ReverseFind('\\')); strTemp+="\\*.*"; strProgFiles=si.GetFilesInfo(strTemp); strTemp.Format("%s*.*",m_pApp->m_strDBPATH); strDBFiles=si.GetFilesInfo(strTemp); //Get the logo.bmp file properties strLogoIsSample="--"; strTemp=si.GetFilesInfo("C:\\Program Files\\AyaNova\\logo.bmp"); strTemp.Replace("\r\n",""); //File found? if(strTemp.Find("not found") == -1 ) { if(strTemp.Find("crc: 982881d3")!=-1) strLogoIsSample="logo is SAMPLE (\"your logo here\")"; else strLogoIsSample="Logo is custom"; //Get the bmp file association FindExecutable(_T("logo.bmp"),_T("C:\\Program Files\\AyaNova\\"),ch); strBMPAssociatedWith.Format("%s",ch); //add plain text of what this is //default value if not paint or picture viewer strAssocAppName=" *** UNKNOWN PROGRAM, NOT TESTED OR APPROVED ***"; //check if associated with Windows XP etc picture viewer which is OK if(strBMPAssociatedWith.Find(_T("shimgvw.dll")) !=-1) strAssocAppName=" (Microsoft Picture Viewer - tested ok)"; if(strBMPAssociatedWith.Find(_T("mspaint.exe")) !=-1) strAssocAppName=" (Microsoft Paint)"; strBMPAssociatedWith+=strAssocAppName; } strTemp.TrimRight("\r\n"); strLogoFile.Format( "LOGO FILE INFORMATION (c:\\Program Files\\AyaNova\\logo.bmp)\r\n" "File details :%s\r\n" "Is it sample? :%s\r\n" "BMP opens with : %s\r\n" ,strTemp,strLogoIsSample,strBMPAssociatedWith); //Get the database info m_pApp->rsPool->GetDBProps(); strDBInfo.Format( "DATABASE DRIVER INFORMATION\r\n" "ADO Version : %s\r\n" "DBMS Name : %s\r\n" "DBMS Version : %s\r\n" "OLE DB Version : %s\r\n" "Provider Name : %s\r\n" "Provider Version : %s\r\n", m_pApp->rsPool->m_strADOVersion, m_pApp->rsPool->m_strDBMSName, m_pApp->rsPool->m_strDBMSVersion, m_pApp->rsPool->m_strOLEDbVersion, m_pApp->rsPool->m_strProviderName, m_pApp->rsPool->m_strProviderVersion); strTemp.Format("AyaNova CE support data compiled: %s\r\n------------------------------------------------------------------------------\r\n",dtData.Format("%b.%d.%Y %H:%M:%S")); strMsg = strTemp + strUserInfo + "\r\n\r\n" + strSysInfo + "\r\n\r\n" + strDBInfo + "\r\n\r\n" + strLogoFile +"\r\n\r\n" + "FILE INFORMATION\r\n" + "Files in program folder:\r\n" + strProgFiles + "\r\nFiles in database folder:\r\n" + strDBFiles; m_pApp->ShowStuff(strMsg); } void CAboutDlg::OnStnClickedLblEmailSupport() { // TODO: Add your control notification handler code here } void CAboutDlg::OnStnClickedLblSupportSite() { // TODO: Add your control notification handler code here } bool CSpApp::InitializeRDC(void) { try { // Create instance of Application object pApplication.CreateInstance("CrystalRuntime.Application.9"); return true; } catch(_com_error& e) { CString strErr; _bstr_t bstrSource(e.Source()); _bstr_t bstrDescription(e.Description()); TRACE("*************************************************\n"); TRACE("Exception thrown for classes generated by #import\n"); TRACE("\tCode = %081x\n", e.Error); TRACE("\tCode Meaning = %s\n", e.ErrorMessage()); TRACE("\tSource = %s\n", (LPCTSTR) bstrSource); TRACE("Description = %s\n", (LPCTSTR) bstrDescription); TRACE("*************************************************\n"); strErr.Format( "Error: Unable to initialize Crystal Reports RDC printing engine\r\n" "AyaNova will be unable to print.\r\n\r\n" "See the \"Errors and problems printing\" page on our web site at:\r\n" "http://www.ayanova.com/faq_technical.htm\r\n" "to resolve this problem.\r\n\r\n" "Full error is:\r\n\r\n" "Code = %x\r\n" "Code Meaning = %s\r\n" "Source = %s\r\n" "Description = %s\r\n\r\n" "This error came at the point where AyaNova had just attempted to intialize the RDC (craxdrt9.dll)\r\n" ,e.Error,e.ErrorMessage(),(LPCTSTR) bstrSource,(LPCTSTR) bstrDescription); ShowStuff(strErr); //HandleComError(e,strLocalError); } if(pApplication==NULL) AfxMessageBox("Error: Unable to initialize Crystal Reports RDC printing engine\r\n" "AyaNova will be unable to print."); return false; } void CSpApp::Test(void) { CString ReportName= ReportDirectory() + "temp.ttx"; //_RecordsetPtr m_pRecordSet GZRset* rs; rs=rsPool->GetRS("Error at:CSpApp::Test()"); rs->QueryReadOnly("SELECT rates.* FROM rates;"); //Recordset pointer fixup declarations: _variant_t idsp;//holder for pointer to recordset //get the pointer for the recordset in required format idsp = static_cast < IUnknown*>(rs->RecordSetPointer()); //DLL calling declarations: typedef BOOL FAR (WINAPI *FDPROC)(BYTE FAR *lpUnk,LPCSTR fileName, BOOL bOverWriteExistingFile); HINSTANCE hinstLib; FDPROC ProcCreateTTX; BOOL fFreeResult; // Get a handle to the DLL module. hinstLib = LoadLibrary("p2smon.dll"); // If the handle is valid, try to get the function address. if (hinstLib != NULL) { ProcCreateTTX = (FDPROC) GetProcAddress(hinstLib, "CreateFieldDefFile"); //// If the function address is valid, call the function. if (ProcCreateTTX != NULL) (ProcCreateTTX) ((BYTE FAR *)&idsp.punkVal,ReportName,TRUE); else AfxMessageBox("Error procuring CreateFieldDefFile function address"); // Free the DLL module. fFreeResult = FreeLibrary(hinstLib); ////indicate success //if(!bSilent) //{ // ReportName=ReportName + " - DONE"; // AfxMessageBox(ReportName); //} } else AfxMessageBox("Error loading p2smon.dll"); rsPool->ReleaseRS(&rs->m_nID); }