AyaNova CE Archive added as recovered from storage during attempt to upgrade a customer from v1.7 to v8!
This commit is contained in:
@@ -462,6 +462,7 @@ Global
|
||||
{3EF693E1-F60E-4D0F-929C-CBF8BEF96F12}.ReleaseX86AyaNova|x86.Build.0 = Release|x86
|
||||
{3A426361-1480-49A3-B596-53ABB98087F9}.Debug|.NET.ActiveCfg = Debug|Any CPU
|
||||
{3A426361-1480-49A3-B596-53ABB98087F9}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{3A426361-1480-49A3-B596-53ABB98087F9}.Debug|Any CPU.Build.0 = Debug|x86
|
||||
{3A426361-1480-49A3-B596-53ABB98087F9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{3A426361-1480-49A3-B596-53ABB98087F9}.Debug|WBI.ActiveCfg = Debug|Any CPU
|
||||
{3A426361-1480-49A3-B596-53ABB98087F9}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,84 @@
|
||||
#if !defined(AFX_ARASCLIENTREQUESTS_H__261CC395_46C3_4AB5_9BD8_2048C6FC98E0__INCLUDED_)
|
||||
#define AFX_ARASCLIENTREQUESTS_H__261CC395_46C3_4AB5_9BD8_2048C6FC98E0__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// ArasClientRequests.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CArasClientRequests dialog
|
||||
#include "ReportCtrl.h"
|
||||
#include "gzrset.h"
|
||||
class CArasClientRequests : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CArasClientRequests(CWnd* pParent = NULL); // standard constructor
|
||||
BOOL bColumnSortAsc[7];//<---COLUMN COUNT HERE MUST BE UPDATED WHEN NEW ONES ADDED
|
||||
CString m_strOrderBy;
|
||||
void Security();
|
||||
~CArasClientRequests();
|
||||
|
||||
CString m_strCriteria;
|
||||
void Criteria();
|
||||
void FillView();
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CArasClientRequests)
|
||||
enum { IDD = IDD_ARAS_CLIENT_REQUESTS };
|
||||
CStatic m_lblDetails;
|
||||
CStatic m_lblBrief;
|
||||
CEdit m_edDetails;
|
||||
CEdit m_edBrief;
|
||||
CButton m_btnOK;
|
||||
CReportCtrl m_rc;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CArasClientRequests)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CArasClientRequests)
|
||||
virtual void OnOK();
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnArasRequestsClose();
|
||||
afx_msg void OnArasRequestsMakeWorkorder();
|
||||
afx_msg void OnArasRequestsReject();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
int m_nTimer;
|
||||
long m_lCurrentItem;
|
||||
void LayoutControls();
|
||||
void FillFields();
|
||||
GZRset* rs;
|
||||
GZRset* rsPrint;
|
||||
CSpApp* m_pApp;
|
||||
void OnRvnItemDbClick(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
void OnRvnItemClick(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
void OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
CImageList m_ilReport;
|
||||
public:
|
||||
afx_msg void OnArasRequestsRefresh();
|
||||
afx_msg void OnTimer(UINT nIDEvent);
|
||||
void OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex,BOOL bSysMenu);
|
||||
afx_msg void OnUpdateArasRequestsMakeWorkorder(CCmdUI *pCmdUI);
|
||||
afx_msg void OnUpdateArasRequestsReject(CCmdUI *pCmdUI);
|
||||
// used to limit access for security
|
||||
bool m_bReadOnly;
|
||||
afx_msg void OnArasRequestsAccept();
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_ARASCLIENTREQUESTS_H__261CC395_46C3_4AB5_9BD8_2048C6FC98E0__INCLUDED_)
|
||||
@@ -0,0 +1,593 @@
|
||||
// AyaSysInfo.cpp: implementation of the CAyaSysInfo class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "AyaSysInfo.h"
|
||||
#include "crc32static.h"
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
#define MAXNETLOOP 20
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CAyaSysInfo::CAyaSysInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
CAyaSysInfo::~CAyaSysInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
//return basic system information
|
||||
CString CAyaSysInfo::GetSysInfo()
|
||||
{
|
||||
CString strTemp,strReturn;
|
||||
DWORD dwWhatever=255;
|
||||
char chBuff[255];
|
||||
char ch;
|
||||
int x=0;
|
||||
long lDriveType;
|
||||
memset(chBuff,0,sizeof(int));
|
||||
|
||||
strReturn.Empty();
|
||||
strReturn="SYSTEM INFORMATION:\r\n";
|
||||
//computer name
|
||||
if(GetComputerName(chBuff,&dwWhatever))
|
||||
strTemp.Format("Computer name: [%s]\r\n",chBuff);
|
||||
strReturn+=strTemp;
|
||||
|
||||
strReturn += GetOpSysVersion() + "\r\n";
|
||||
|
||||
|
||||
|
||||
//local drive letters
|
||||
if(GetLogicalDriveStrings(255,chBuff))
|
||||
{
|
||||
strReturn+="Drive information:\r\n";
|
||||
strTemp.Empty();
|
||||
ch=chBuff[x];
|
||||
do{
|
||||
|
||||
strTemp+=ch;
|
||||
strTemp+=":\\";
|
||||
lDriveType=GetDriveType(strTemp);
|
||||
|
||||
switch (lDriveType)
|
||||
{
|
||||
case DRIVE_NO_ROOT_DIR:
|
||||
strTemp+=" - No root path determinable. Invalid\r\n";
|
||||
break;
|
||||
case DRIVE_REMOVABLE:
|
||||
strTemp+=" - Removable drive\r\n";
|
||||
break;
|
||||
case DRIVE_FIXED:
|
||||
strTemp+=" - Fixed drive\r\n";
|
||||
break;
|
||||
case DRIVE_REMOTE:
|
||||
strTemp+=" - remote network drive\r\n";
|
||||
break;
|
||||
case DRIVE_CDROM:
|
||||
strTemp+=" - CDROM drive\r\n";
|
||||
break;
|
||||
case DRIVE_RAMDISK:
|
||||
strTemp+=" - RAM drive\r\n";
|
||||
break;
|
||||
default:
|
||||
strTemp+=" - Unknown type\r\n";
|
||||
|
||||
|
||||
}
|
||||
strReturn+= "\t" + strTemp;
|
||||
strTemp.Empty();
|
||||
x+=4;
|
||||
ch=chBuff[x];
|
||||
}while(ch!=0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//memory
|
||||
strReturn+="\r\n";
|
||||
MEMORYSTATUS ms;
|
||||
GlobalMemoryStatus(&ms);
|
||||
|
||||
strTemp.Format("RAM: %ld kb of physical memory\r\n",ms.dwTotalPhys/1024);
|
||||
strReturn+=strTemp;
|
||||
|
||||
strTemp.Format("RAM: %ld percent of memory is in use\r\n",ms.dwMemoryLoad);
|
||||
strReturn+=strTemp;
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
|
||||
//Get locale information
|
||||
CString CAyaSysInfo::GetLocalInfo()
|
||||
{
|
||||
CString strTemp,strReturn;
|
||||
char chBuff[50];
|
||||
memset(chBuff,0,sizeof(int));
|
||||
|
||||
strReturn.Empty();
|
||||
strReturn="LOCALE INFORMATION:\r\n";
|
||||
|
||||
//short date format
|
||||
if(GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SSHORTDATE,chBuff,50))
|
||||
strTemp.Format("Short date format: [%s]\r\n",chBuff);
|
||||
strReturn+=strTemp;
|
||||
|
||||
//Currency symbol
|
||||
if(GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SCURRENCY,chBuff,50))
|
||||
strTemp.Format("Currency symbol: [%s]\r\n",chBuff);
|
||||
strReturn+=strTemp;
|
||||
|
||||
//language
|
||||
if(GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SENGLANGUAGE ,chBuff,50))
|
||||
strTemp.Format("Language: [%s]\r\n",chBuff);
|
||||
strReturn+=strTemp;
|
||||
|
||||
//Country
|
||||
if(GetLocaleInfo(LOCALE_USER_DEFAULT,LOCALE_SCOUNTRY,chBuff,50))
|
||||
strTemp.Format("Country: [%s]\r\n",chBuff);
|
||||
strReturn+=strTemp;
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
|
||||
//Get info from every function and return it all
|
||||
CString CAyaSysInfo::GetAllInfo()
|
||||
{
|
||||
CString strReturn;
|
||||
strReturn.Empty();
|
||||
|
||||
//Local info
|
||||
strReturn=GetLocalInfo();
|
||||
strReturn+="\r\n" + GetSysInfo();
|
||||
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//os version info
|
||||
CString CAyaSysInfo::GetOpSysVersion()
|
||||
{
|
||||
CString strReturn, strTemp;
|
||||
strReturn="Operating system: [";
|
||||
OSVERSIONINFOEX osvi;
|
||||
BOOL bOsVersionInfoEx;
|
||||
|
||||
// Try calling GetVersionEx using the OSVERSIONINFOEX structure,
|
||||
// which is supported on Windows 2000.
|
||||
//
|
||||
// If that fails, try using the OSVERSIONINFO structure.
|
||||
|
||||
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
|
||||
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
||||
|
||||
if( !(bOsVersionInfoEx = GetVersionEx ((OSVERSIONINFO *) &osvi)) )
|
||||
{
|
||||
// If OSVERSIONINFOEX doesn't work, try OSVERSIONINFO.
|
||||
|
||||
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
|
||||
if (! GetVersionEx ( (OSVERSIONINFO *) &osvi) )
|
||||
return "OS VERSION UNKNOWN";
|
||||
}
|
||||
|
||||
switch (osvi.dwPlatformId)
|
||||
{
|
||||
case VER_PLATFORM_WIN32_NT:
|
||||
|
||||
if(osvi.dwMajorVersion < 4)
|
||||
strReturn+="Windows NT pre v4.0 ";
|
||||
|
||||
if(osvi.dwMajorVersion == 4 && osvi.dwMinorVersion== 0)
|
||||
strReturn+="Windows NT 4.0 ";
|
||||
|
||||
if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion== 0)
|
||||
strReturn+="Windows 2000 ";
|
||||
|
||||
if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion== 1)
|
||||
strReturn+="Windows XP ";
|
||||
|
||||
if(osvi.dwMajorVersion == 5 && osvi.dwMinorVersion== 2)
|
||||
strReturn+="Windows server 2003 family ";
|
||||
|
||||
// Test for specific product on Windows NT 4.0 SP6 and later.
|
||||
if( bOsVersionInfoEx )
|
||||
{
|
||||
// Test for the workstation type.
|
||||
if ( osvi.wProductType == VER_NT_WORKSTATION )
|
||||
{
|
||||
if( osvi.dwMajorVersion == 4 )
|
||||
strReturn+= "Workstation 4.0 " ;
|
||||
else if( osvi.wSuiteMask & VER_SUITE_PERSONAL )
|
||||
strReturn+="Home Edition ";
|
||||
else
|
||||
strReturn+="Professional ";
|
||||
}
|
||||
|
||||
// Test for the server type.
|
||||
else if ( osvi.wProductType == VER_NT_SERVER )
|
||||
{
|
||||
if( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 2 )
|
||||
{
|
||||
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
|
||||
strReturn+="Datacenter Edition " ;
|
||||
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
|
||||
strReturn+="Enterprise Edition ";
|
||||
else if ( osvi.wSuiteMask == VER_SUITE_BLADE )
|
||||
strReturn+="Web Edition ";
|
||||
else
|
||||
strReturn+="Standard Edition ";
|
||||
}
|
||||
|
||||
else if( osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0 )
|
||||
{
|
||||
if( osvi.wSuiteMask & VER_SUITE_DATACENTER )
|
||||
strReturn+="Datacenter Server ";
|
||||
else if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
|
||||
strReturn+="Advanced Server ";
|
||||
else
|
||||
strReturn+="Server ";
|
||||
}
|
||||
|
||||
else // Windows NT 4.0
|
||||
{
|
||||
if( osvi.wSuiteMask & VER_SUITE_ENTERPRISE )
|
||||
strReturn+="Server 4.0, Enterprise Edition ";
|
||||
else
|
||||
strReturn+="Server 4.0 ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
strTemp.Format("%s",osvi.szCSDVersion);
|
||||
strTemp.TrimLeft(" ");
|
||||
if(strTemp.IsEmpty())
|
||||
strTemp="n/a";
|
||||
strReturn+= " Version: " + strTemp;
|
||||
|
||||
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case VER_PLATFORM_WIN32_WINDOWS:
|
||||
if(osvi.dwMajorVersion == 4 && osvi.dwMinorVersion== 0)
|
||||
strReturn+="Windows 95";
|
||||
|
||||
if(osvi.dwMajorVersion == 4 && osvi.dwMinorVersion== 10)
|
||||
strReturn+="Windows 98";
|
||||
|
||||
if(osvi.dwMajorVersion == 4 && osvi.dwMinorVersion== 90)
|
||||
strReturn+="Windows ME";
|
||||
|
||||
strTemp.Format("%s",osvi.szCSDVersion);
|
||||
strTemp.TrimLeft(" ");
|
||||
if(strTemp.IsEmpty())
|
||||
strTemp="n/a";
|
||||
strReturn+= " Version: " + strTemp;
|
||||
|
||||
|
||||
break;
|
||||
|
||||
case VER_PLATFORM_WIN32s:
|
||||
|
||||
strReturn+="Microsoft Win32s \r\n";
|
||||
break;
|
||||
}
|
||||
strReturn+="]\r\n";
|
||||
return strReturn;
|
||||
}
|
||||
|
||||
//usage: pass in a path or file name
|
||||
//returns all files if just a path
|
||||
//or details on the one file if a single file
|
||||
//with crc32 checksums
|
||||
//does *not* recurse
|
||||
CString CAyaSysInfo::GetFilesInfo(CString strStartPath)
|
||||
{
|
||||
CString strReturn, strTemp, strSize;
|
||||
CFileFind ff;
|
||||
CTime ct,wt;
|
||||
CCrc32Static crc;
|
||||
DWORD dwcheck=0;
|
||||
|
||||
|
||||
|
||||
unsigned int uiFileSize;
|
||||
bool bGotPath=false;
|
||||
BOOL bWorking = ff.FindFile(strStartPath);
|
||||
|
||||
//Change 02/20/2003
|
||||
if(!bWorking)
|
||||
strReturn.Format("File not found",strStartPath);
|
||||
|
||||
while (bWorking)
|
||||
{
|
||||
bWorking = ff.FindNextFile();
|
||||
|
||||
// skip . and .. files; otherwise, we'd
|
||||
// recurse infinitely!
|
||||
|
||||
if (ff.IsDots())
|
||||
continue;
|
||||
if(ff.IsDirectory())
|
||||
{ if(bGotPath==false)
|
||||
{
|
||||
strTemp.Format("<Files in: %s>\r\n",ff.GetRoot());
|
||||
strReturn+=strTemp;
|
||||
bGotPath=true;
|
||||
}
|
||||
ff.GetCreationTime(ct);
|
||||
strTemp.Format("\r\n\\%-45s\t%s\t<folder>\r\n",ff.GetFileName(),ct.Format("%b.%d.%Y %H:%M:%S"));
|
||||
strReturn+=strTemp;
|
||||
|
||||
}
|
||||
else //it's a file, get file info
|
||||
{
|
||||
if(bGotPath==false)
|
||||
{
|
||||
strTemp.Format("<Files in: %s>\r\n",ff.GetRoot());
|
||||
strReturn+=strTemp;
|
||||
bGotPath=true;
|
||||
}
|
||||
ff.GetCreationTime(ct);
|
||||
ff.GetLastWriteTime(wt);
|
||||
uiFileSize=(UINT)ff.GetLength();
|
||||
if(uiFileSize < 1024)
|
||||
strSize.Format("%u bytes",uiFileSize);
|
||||
else
|
||||
{
|
||||
//convert to KB
|
||||
uiFileSize=uiFileSize/1024;
|
||||
strSize.Format("%u KB",uiFileSize);
|
||||
|
||||
}
|
||||
|
||||
crc.FileCrc32Assembly(ff.GetFilePath(),dwcheck);
|
||||
|
||||
strTemp.Format("%-35s\tC:%-15s\tW:%-15s\t%-8s\tcrc: %08x\r\n",ff.GetFileName(),
|
||||
ct.Format("%b.%d.%Y %H:%M:%S"),wt.Format("%b.%d.%Y %H:%M:%S"),strSize,dwcheck);
|
||||
strReturn+=strTemp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
ff.Close();
|
||||
return strReturn;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
||||
CString CAyaSysInfo::GetNetworkResources(LPNETRESOURCE lpnr)
|
||||
{
|
||||
m_lLoop++;
|
||||
m_lDepth++;
|
||||
if(m_lLoop>MAXNETLOOP)
|
||||
return "Overflow";
|
||||
CString strTemp, strReturn, strLastResource, strThisResource;
|
||||
|
||||
|
||||
DWORD dwResult, dwResultEnum;
|
||||
HANDLE hEnum;
|
||||
DWORD cbBuffer = 16384; // 16K is a good size
|
||||
DWORD cEntries = -1; // enumerate all possible entries
|
||||
LPNETRESOURCE lpnrLocal; // pointer to enumerated structures
|
||||
DWORD i;
|
||||
|
||||
|
||||
//
|
||||
// Call the WNetOpenEnum function to begin the enumeration.
|
||||
//
|
||||
dwResult = WNetOpenEnum(RESOURCE_GLOBALNET, // all network resources
|
||||
RESOURCETYPE_ANY, // all resources
|
||||
0, // enumerate all resources
|
||||
lpnr, // NULL first time the function is called
|
||||
&hEnum); // handle to the resource
|
||||
|
||||
if (dwResult != NO_ERROR)
|
||||
{
|
||||
//
|
||||
// Process errors with an application-defined error handler.
|
||||
//
|
||||
//NetErrorHandler(hwnd, dwResult, (LPSTR)"WNetOpenEnum");
|
||||
return "Network resources - FAIL";
|
||||
}
|
||||
//
|
||||
// Call the GlobalAlloc function to allocate resources.
|
||||
//
|
||||
lpnrLocal = (LPNETRESOURCE) GlobalAlloc(GPTR, cbBuffer);
|
||||
|
||||
do
|
||||
{
|
||||
//strReturn+="Calling Enumerate from master...\r\n";
|
||||
//
|
||||
// Initialize the buffer.
|
||||
//
|
||||
ZeroMemory(lpnrLocal, cbBuffer);
|
||||
//
|
||||
// Call the WNetEnumResource function to continue
|
||||
// the enumeration.
|
||||
//
|
||||
dwResultEnum = WNetEnumResource(hEnum, // resource handle
|
||||
&cEntries, // defined locally as -1
|
||||
lpnrLocal, // LPNETRESOURCE
|
||||
&cbBuffer); // buffer size
|
||||
//
|
||||
// If the call succeeds, loop through the structures.
|
||||
//
|
||||
strTemp.Format("\r\n\tdwResult=%i, loop=%u, CEntries=%i",dwResultEnum,m_lLoop, cEntries);
|
||||
strReturn+=strTemp;
|
||||
if (dwResultEnum == NO_ERROR)
|
||||
{
|
||||
strReturn+="\r\n\tNoError\r\n";
|
||||
//strTemp.Format("CEntries=%i\r\n",cEntries);
|
||||
//strReturn+=strTemp;
|
||||
for(i = 0; i < cEntries; i++)
|
||||
{
|
||||
|
||||
|
||||
if(RESOURCEUSAGE_CONTAINER != (lpnrLocal[i].dwUsage & RESOURCEUSAGE_CONTAINER))
|
||||
{
|
||||
if(i==0)
|
||||
{
|
||||
strTemp.Format("%s",lpnrLocal[i].lpProvider);
|
||||
if(!strTemp.IsEmpty() && strTemp!="(null)")
|
||||
strReturn+= "Provider: " + strTemp + "";
|
||||
}
|
||||
|
||||
strTemp.Format("%s",lpnrLocal[i].lpLocalName);
|
||||
if(!strTemp.IsEmpty() && strTemp!="(null)")
|
||||
strReturn+= "Local name: " + strTemp + " ";
|
||||
|
||||
strTemp.Format("%s",lpnrLocal[i].lpRemoteName);
|
||||
if(!strTemp.IsEmpty() && strTemp!="(null)")
|
||||
{
|
||||
strReturn+= "\r\n\tRemote name: " + strTemp + " ";
|
||||
strThisResource=strTemp;
|
||||
}
|
||||
strTemp.Format("%s",lpnrLocal[i].lpComment);
|
||||
if(!strTemp.IsEmpty() && strTemp!="(null)")
|
||||
strReturn+= " (Comment: " + strTemp + ")\r\n";
|
||||
|
||||
}
|
||||
// If the NETRESOURCE structure represents a container resource,
|
||||
// call the EnumerateFunc function recursively.
|
||||
|
||||
if(RESOURCEUSAGE_CONTAINER == (lpnrLocal[i].dwUsage & RESOURCEUSAGE_CONTAINER))
|
||||
if(lpnrLocal[i].lpProvider!="HP Network Printers")
|
||||
strReturn+=GetNetworkResources(&lpnrLocal[i]);
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// Process errors.
|
||||
//
|
||||
|
||||
}
|
||||
//
|
||||
// End do.
|
||||
//
|
||||
while(dwResultEnum != ERROR_NO_MORE_ITEMS);
|
||||
//
|
||||
// Call the GlobalFree function to free the memory.
|
||||
//
|
||||
GlobalFree((HGLOBAL)lpnrLocal);
|
||||
//
|
||||
// Call WNetCloseEnum to end the enumeration.
|
||||
//
|
||||
dwResult = WNetCloseEnum(hEnum);
|
||||
|
||||
if(dwResult != NO_ERROR)
|
||||
{
|
||||
//
|
||||
// Process errors.
|
||||
//
|
||||
//NetErrorHandler(hwnd, dwResult, (LPSTR)"WNetCloseEnum");
|
||||
return "Network resources - FAIL";
|
||||
}
|
||||
|
||||
//returning
|
||||
// m_lLoop--;
|
||||
m_lDepth--;
|
||||
strTemp.Format("\r\nDepth=%u\r\n",m_lDepth);
|
||||
strReturn+=strTemp;
|
||||
return strReturn;
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
/*
|
||||
//usage: pass in a path or file name
|
||||
//returns all files if just a path
|
||||
//or details on the one file if a single file
|
||||
//does *not* recurse
|
||||
CString CAyaSysInfo::GetFilesInfo(CString strStartPath)
|
||||
{
|
||||
CString strReturn, strTemp, strSize;
|
||||
CFileFind ff;
|
||||
CTime ct,wt;
|
||||
unsigned int uiFileSize;
|
||||
bool bGotPath=false;
|
||||
BOOL bWorking = ff.FindFile(strStartPath);
|
||||
|
||||
while (bWorking)
|
||||
{
|
||||
bWorking = ff.FindNextFile();
|
||||
|
||||
// skip . and .. files; otherwise, we'd
|
||||
// recur infinitely!
|
||||
|
||||
if (ff.IsDots())
|
||||
continue;
|
||||
if(ff.IsDirectory())
|
||||
{ if(bGotPath==false)
|
||||
{
|
||||
strTemp.Format("<Files in: %s>\r\n",ff.GetRoot());
|
||||
strReturn+=strTemp;
|
||||
bGotPath=true;
|
||||
}
|
||||
ff.GetCreationTime(ct);
|
||||
strTemp.Format("%-45s\t%s\t<folder>\r\n",ff.GetFileName(),ct.Format("%b.%d.%Y %H:%M:%S"));
|
||||
strReturn+=strTemp;
|
||||
|
||||
}
|
||||
else //it's a file, get file info
|
||||
{
|
||||
if(bGotPath==false)
|
||||
{
|
||||
strTemp.Format("<Files in: %s>\r\n",ff.GetRoot());
|
||||
strReturn+=strTemp;
|
||||
bGotPath=true;
|
||||
}
|
||||
ff.GetCreationTime(ct);
|
||||
ff.GetLastWriteTime(wt);
|
||||
uiFileSize=ff.GetLength();
|
||||
if(uiFileSize < 1024)
|
||||
strSize.Format("%u bytes",uiFileSize);
|
||||
else
|
||||
{
|
||||
//convert to KB
|
||||
uiFileSize=uiFileSize/1024;
|
||||
strSize.Format("%u KB",uiFileSize);
|
||||
|
||||
}
|
||||
|
||||
|
||||
strTemp.Format("%-45s\tC:%s\tW:%s\t%s\r\n",ff.GetFileName(),
|
||||
ct.Format("%b.%d.%Y %H:%M:%S"),wt.Format("%b.%d.%Y %H:%M:%S"),strSize);
|
||||
strReturn+=strTemp;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
ff.Close();
|
||||
return strReturn;
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -0,0 +1,30 @@
|
||||
// AyaSysInfo.h: interface for the CAyaSysInfo class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#if !defined(AFX_AYASYSINFO_H__E479F057_0490_40CF_B505_663BE21084D4__INCLUDED_)
|
||||
#define AFX_AYASYSINFO_H__E479F057_0490_40CF_B505_663BE21084D4__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
class CAyaSysInfo
|
||||
{
|
||||
public:
|
||||
CString GetFilesInfo(CString strStartPath);
|
||||
long m_lLoop;
|
||||
long m_lDepth;
|
||||
|
||||
//CString GetNetworkResources(LPNETRESOURCE lpnr);
|
||||
CString GetAllInfo();
|
||||
CString GetLocalInfo();
|
||||
CString GetSysInfo();
|
||||
CString GetOpSysVersion();
|
||||
CAyaSysInfo();
|
||||
virtual ~CAyaSysInfo();
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_AYASYSINFO_H__E479F057_0490_40CF_B505_663BE21084D4__INCLUDED_)
|
||||
@@ -0,0 +1,425 @@
|
||||
// CheckComboBox.cpp
|
||||
//
|
||||
// Written by Magnus Egelberg (magnus.egelberg@lundalogik.se)
|
||||
//
|
||||
// Copyright (C) 1999, Lundalogik AB, Sweden. All rights reserved.
|
||||
//
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
//#include "CheckCombo.h"
|
||||
#include "CheckComboBox.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
static WNDPROC m_pWndProc = 0;
|
||||
static CCheckComboBox *m_pComboBox = 0;
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CCheckComboBox, CComboBox)
|
||||
//{{AFX_MSG_MAP(CCheckComboBox)
|
||||
ON_MESSAGE(WM_CTLCOLORLISTBOX, OnCtlColorListBox)
|
||||
ON_MESSAGE(WM_GETTEXT, OnGetText)
|
||||
ON_MESSAGE(WM_GETTEXTLENGTH, OnGetTextLength)
|
||||
ON_CONTROL_REFLECT(CBN_DROPDOWN, OnDropDown)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
//
|
||||
// The subclassed COMBOLBOX message handler
|
||||
//
|
||||
extern "C" LRESULT FAR PASCAL ComboBoxListBoxProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
|
||||
switch (nMsg) {
|
||||
|
||||
|
||||
case WM_RBUTTONDOWN: {
|
||||
// If you want to select all/unselect all using the
|
||||
// right button, remove this ifdef. Personally, I don't really like it
|
||||
#if FALSE
|
||||
|
||||
if (m_pComboBox != 0) {
|
||||
INT nCount = m_pComboBox->GetCount();
|
||||
INT nSelCount = 0;
|
||||
|
||||
for (INT i = 0; i < nCount; i++) {
|
||||
if (m_pComboBox->GetCheck(i))
|
||||
nSelCount++;
|
||||
}
|
||||
|
||||
|
||||
m_pComboBox->SelectAll(nSelCount != nCount);
|
||||
|
||||
// Make sure to invalidate this window as well
|
||||
InvalidateRect(hWnd, 0, FALSE);
|
||||
m_pComboBox->GetParent()->SendMessage(WM_COMMAND, MAKELONG(GetWindowLong(m_pComboBox->m_hWnd, GWL_ID), CBN_SELCHANGE), (LPARAM)m_pComboBox->m_hWnd);
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Make the combobox always return -1 as the current selection. This
|
||||
// causes the lpDrawItemStruct->itemID in DrawItem() to be -1
|
||||
// when the always-visible-portion of the combo is drawn
|
||||
case LB_GETCURSEL: {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
case WM_CHAR: {
|
||||
if (wParam == VK_SPACE) {
|
||||
// Get the current selection
|
||||
INT nIndex = CallWindowProcA(m_pWndProc, hWnd, LB_GETCURSEL, wParam, lParam);
|
||||
|
||||
CRect rcItem;
|
||||
SendMessage(hWnd, LB_GETITEMRECT, nIndex, (LONG)(VOID *)&rcItem);
|
||||
InvalidateRect(hWnd, rcItem, FALSE);
|
||||
|
||||
// Invert the check mark
|
||||
m_pComboBox->SetCheck(nIndex, !m_pComboBox->GetCheck(nIndex));
|
||||
|
||||
// Notify that selection has changed
|
||||
m_pComboBox->GetParent()->SendMessage(WM_COMMAND, MAKELONG(GetWindowLong(m_pComboBox->m_hWnd, GWL_ID), CBN_SELCHANGE), (LPARAM)m_pComboBox->m_hWnd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case WM_LBUTTONDOWN: {
|
||||
|
||||
CRect rcClient;
|
||||
GetClientRect(hWnd, rcClient);
|
||||
|
||||
CPoint pt;
|
||||
pt.x = LOWORD(lParam);
|
||||
pt.y = HIWORD(lParam);
|
||||
|
||||
|
||||
if (PtInRect(rcClient, pt)) {
|
||||
INT nItemHeight = SendMessage(hWnd, LB_GETITEMHEIGHT, 0, 0);
|
||||
INT nTopIndex = SendMessage(hWnd, LB_GETTOPINDEX, 0, 0);
|
||||
|
||||
// Compute which index to check/uncheck
|
||||
INT nIndex = nTopIndex + pt.y / nItemHeight;
|
||||
|
||||
CRect rcItem;
|
||||
SendMessage(hWnd, LB_GETITEMRECT, nIndex, (LONG)(VOID *)&rcItem);
|
||||
|
||||
if (PtInRect(rcItem, pt)) {
|
||||
// Invalidate this window
|
||||
InvalidateRect(hWnd, rcItem, FALSE);
|
||||
m_pComboBox->SetCheck(nIndex, !m_pComboBox->GetCheck(nIndex));
|
||||
|
||||
// Notify that selection has changed
|
||||
m_pComboBox->GetParent()->SendMessage(WM_COMMAND, MAKELONG(GetWindowLong(m_pComboBox->m_hWnd, GWL_ID), CBN_SELCHANGE), (LPARAM)m_pComboBox->m_hWnd);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Do the default handling now (such as close the popup
|
||||
// window when clicked outside)
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_LBUTTONUP: {
|
||||
// Don't do anything here. This causes the combobox popup
|
||||
// windows to remain open after a selection has been made
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return CallWindowProc(m_pWndProc, hWnd, nMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CCheckComboBox::CCheckComboBox()
|
||||
{
|
||||
m_hListBox = 0;
|
||||
m_bTextUpdated = FALSE;
|
||||
m_bItemHeightSet = FALSE;
|
||||
}
|
||||
|
||||
|
||||
CCheckComboBox::~CCheckComboBox()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
BOOL CCheckComboBox::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID)
|
||||
{
|
||||
|
||||
// Remove the CBS_SIMPLE and CBS_DROPDOWN styles and add the one I'm designed for
|
||||
dwStyle &= ~0xF;
|
||||
dwStyle |= CBS_DROPDOWNLIST;
|
||||
|
||||
// Make sure to use the CBS_OWNERDRAWVARIABLE style
|
||||
dwStyle |= CBS_OWNERDRAWVARIABLE;
|
||||
|
||||
// Use default strings. We need the itemdata to store checkmarks
|
||||
dwStyle |= CBS_HASSTRINGS;
|
||||
|
||||
return CComboBox::Create(dwStyle, rect, pParentWnd, nID);
|
||||
}
|
||||
|
||||
|
||||
LRESULT CCheckComboBox::OnCtlColorListBox(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// If the listbox hasn't been subclassed yet, do so...
|
||||
if (m_hListBox == 0) {
|
||||
HWND hWnd = (HWND)lParam;
|
||||
|
||||
if (hWnd != 0 && hWnd != m_hWnd) {
|
||||
// Save the listbox handle
|
||||
m_hListBox = hWnd;
|
||||
|
||||
// Do the subclassing
|
||||
m_pWndProc = (WNDPROC)GetWindowLong(m_hListBox, GWL_WNDPROC);
|
||||
SetWindowLong(m_hListBox, GWL_WNDPROC, (LONG)ComboBoxListBoxProc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return DefWindowProc(WM_CTLCOLORLISTBOX, wParam, lParam);
|
||||
}
|
||||
|
||||
|
||||
void CCheckComboBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
|
||||
{
|
||||
HDC dc = lpDrawItemStruct->hDC;
|
||||
|
||||
CRect rcBitmap = lpDrawItemStruct->rcItem;
|
||||
CRect rcText = lpDrawItemStruct->rcItem;
|
||||
|
||||
CString strText;
|
||||
|
||||
// 0 - No check, 1 - Empty check, 2 - Checked
|
||||
INT nCheck = 0;
|
||||
|
||||
// Check if we are drawing the static portion of the combobox
|
||||
if ((LONG)lpDrawItemStruct->itemID < 0) {
|
||||
// Make sure the m_strText member is updated
|
||||
RecalcText();
|
||||
|
||||
// Get the text
|
||||
strText = m_strText;
|
||||
|
||||
// Don't draw any boxes on this item
|
||||
nCheck = 0;
|
||||
}
|
||||
|
||||
// Otherwise it is one of the items
|
||||
else {
|
||||
GetLBText(lpDrawItemStruct->itemID, strText);
|
||||
nCheck = 1 + (GetItemData(lpDrawItemStruct->itemID) != 0);
|
||||
|
||||
TEXTMETRIC metrics;
|
||||
GetTextMetrics(dc, &metrics);
|
||||
|
||||
rcBitmap.left = 0;
|
||||
rcBitmap.right = rcBitmap.left + metrics.tmHeight + metrics.tmExternalLeading + 6;
|
||||
rcBitmap.top += 1;
|
||||
rcBitmap.bottom -= 1;
|
||||
|
||||
rcText.left = rcBitmap.right;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (nCheck > 0) {
|
||||
SetBkColor(dc, GetSysColor(COLOR_WINDOW));
|
||||
SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
|
||||
|
||||
UINT nState = DFCS_BUTTONCHECK;
|
||||
|
||||
if (nCheck > 1)
|
||||
nState |= DFCS_CHECKED;
|
||||
|
||||
// Draw the checkmark using DrawFrameControl
|
||||
DrawFrameControl(dc, rcBitmap, DFC_BUTTON, nState);
|
||||
}
|
||||
|
||||
if (lpDrawItemStruct->itemState & ODS_SELECTED) {
|
||||
SetBkColor(dc, GetSysColor(COLOR_HIGHLIGHT));
|
||||
SetTextColor(dc, GetSysColor(COLOR_HIGHLIGHTTEXT));
|
||||
}
|
||||
else {
|
||||
SetBkColor(dc, GetSysColor(COLOR_WINDOW));
|
||||
SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
|
||||
}
|
||||
|
||||
// Erase and draw
|
||||
ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rcText, 0, 0, 0);
|
||||
DrawText(dc, ' ' + strText, strText.GetLength() + 1, &rcText, DT_SINGLELINE|DT_VCENTER|DT_END_ELLIPSIS);
|
||||
|
||||
if ((lpDrawItemStruct->itemState & (ODS_FOCUS|ODS_SELECTED)) == (ODS_FOCUS|ODS_SELECTED))
|
||||
DrawFocusRect(dc, &rcText);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CCheckComboBox::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
|
||||
{
|
||||
CClientDC dc(this);
|
||||
CFont *pFont = dc.SelectObject(GetFont());
|
||||
|
||||
if (pFont != 0) {
|
||||
|
||||
TEXTMETRIC metrics;
|
||||
dc.GetTextMetrics(&metrics);
|
||||
|
||||
lpMeasureItemStruct->itemHeight = metrics.tmHeight + metrics.tmExternalLeading;
|
||||
|
||||
// An extra height of 2 looks good I think.
|
||||
// Otherwise the list looks a bit crowded...
|
||||
lpMeasureItemStruct->itemHeight += 2;
|
||||
|
||||
|
||||
// This is needed since the WM_MEASUREITEM message is sent before
|
||||
// MFC hooks everything up if used in i dialog. So adjust the
|
||||
// static portion of the combo box now
|
||||
if (!m_bItemHeightSet) {
|
||||
m_bItemHeightSet = TRUE;
|
||||
SetItemHeight(-1, lpMeasureItemStruct->itemHeight);
|
||||
}
|
||||
|
||||
dc.SelectObject(pFont);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Make sure the combobox window handle is updated since
|
||||
// there may be many CCheckComboBox windows active
|
||||
//
|
||||
void CCheckComboBox::OnDropDown()
|
||||
{
|
||||
m_pComboBox = this;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Selects/unselects all items in the list
|
||||
//
|
||||
void CCheckComboBox::SelectAll(BOOL bCheck)
|
||||
{
|
||||
INT nCount = GetCount();
|
||||
|
||||
for (INT i = 0; i < nCount; i++)
|
||||
SetCheck(i, bCheck);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// By adding this message handler, we may use CWnd::GetText()
|
||||
//
|
||||
LRESULT CCheckComboBox::OnGetText(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
// Make sure the text is updated
|
||||
RecalcText();
|
||||
|
||||
if (lParam == 0)
|
||||
return 0;
|
||||
|
||||
// Copy the 'fake' window text
|
||||
lstrcpyn((LPSTR)lParam, m_strText, (INT)wParam);
|
||||
return m_strText.GetLength();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// By adding this message handler, we may use CWnd::GetTextLength()
|
||||
//
|
||||
LRESULT CCheckComboBox::OnGetTextLength(WPARAM, LPARAM)
|
||||
{
|
||||
// Make sure the text is updated
|
||||
RecalcText();
|
||||
return m_strText.GetLength();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// This routine steps thru all the items and builds
|
||||
// a string containing the checked items
|
||||
//
|
||||
void CCheckComboBox::RecalcText()
|
||||
{
|
||||
if (!m_bTextUpdated) {
|
||||
CString strText;
|
||||
|
||||
// Get the list count
|
||||
INT nCount = GetCount();
|
||||
|
||||
// Get the list separator
|
||||
TCHAR szBuffer[10] = {0};
|
||||
GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SLIST, szBuffer, sizeof(szBuffer));
|
||||
|
||||
CString strSeparator = szBuffer;
|
||||
|
||||
// If none found, the the ';'
|
||||
if (strSeparator.GetLength() == 0)
|
||||
strSeparator = ';';
|
||||
|
||||
// Trim extra spaces
|
||||
strSeparator.TrimRight();
|
||||
|
||||
// And one...
|
||||
strSeparator += ' ';
|
||||
|
||||
for (INT i = 0; i < nCount; i++) {
|
||||
|
||||
if (GetItemData(i)) {
|
||||
CString strItem;
|
||||
GetLBText(i, strItem);
|
||||
|
||||
if (!strText.IsEmpty())
|
||||
strText += strSeparator;
|
||||
|
||||
strText += strItem;
|
||||
}
|
||||
}
|
||||
|
||||
// Set the text
|
||||
m_strText = strText;
|
||||
|
||||
m_bTextUpdated = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
INT CCheckComboBox::SetCheck(INT nIndex, BOOL bFlag)
|
||||
{
|
||||
INT nResult = SetItemData(nIndex, bFlag);
|
||||
|
||||
if (nResult < 0)
|
||||
return nResult;
|
||||
|
||||
// Signal that the text need updating
|
||||
m_bTextUpdated = FALSE;
|
||||
|
||||
// Redraw the window
|
||||
Invalidate(FALSE);
|
||||
|
||||
return nResult;
|
||||
}
|
||||
|
||||
BOOL CCheckComboBox::GetCheck(INT nIndex)
|
||||
{
|
||||
return GetItemData(nIndex);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
#if !defined(AFX_CHECKCOMBOBOX_H__66750D93_95DB_11D3_9325_444553540000__INCLUDED_)
|
||||
#define AFX_CHECKCOMBOBOX_H__66750D93_95DB_11D3_9325_444553540000__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
class CCheckComboBox : public CComboBox
|
||||
{
|
||||
public:
|
||||
CCheckComboBox();
|
||||
virtual ~CCheckComboBox();
|
||||
|
||||
BOOL Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID);
|
||||
|
||||
// Selects all/unselects the specified item
|
||||
INT SetCheck(INT nIndex, BOOL bFlag);
|
||||
|
||||
// Returns checked state
|
||||
BOOL GetCheck(INT nIndex);
|
||||
|
||||
// Selects all/unselects all
|
||||
void SelectAll(BOOL bCheck = TRUE);
|
||||
|
||||
protected:
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CCheckComboBox)
|
||||
protected:
|
||||
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
|
||||
virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
//{{AFX_MSG(CCheckComboBox)
|
||||
afx_msg LRESULT OnCtlColorListBox(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT OnGetText(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg LRESULT OnGetTextLength(WPARAM wParam, LPARAM lParam);
|
||||
afx_msg void OnDropDown();
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
protected:
|
||||
// Routine to update the text
|
||||
void RecalcText();
|
||||
|
||||
// The subclassed COMBOLBOX window (notice the 'L')
|
||||
HWND m_hListBox;
|
||||
|
||||
// The string containing the text to display
|
||||
CString m_strText;
|
||||
BOOL m_bTextUpdated;
|
||||
|
||||
// A flag used in MeasureItem, see comments there
|
||||
BOOL m_bItemHeightSet;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CHECKCOMBOBOX_H__66750D93_95DB_11D3_9325_444553540000__INCLUDED_)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,225 @@
|
||||
#if !defined(AFX_CLIENTSDLG_H__8983F421_114C_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_CLIENTSDLG_H__8983F421_114C_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// ClientsDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClientsDlg dialog
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
#include "label.h"
|
||||
#include "statusdlg.h"
|
||||
#include "ResizeCtrl.h"
|
||||
#include "afxwin.h"
|
||||
#include "defaultsdlg.h"
|
||||
class CClientsDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CResizeCtrl m_resize;
|
||||
bool EditPrompt();
|
||||
bool m_bEditPrompt;
|
||||
void FillRatesLists();
|
||||
void Security();
|
||||
bool m_bReadOnly;
|
||||
CString m_strForceSelection;
|
||||
void SetDefaults();
|
||||
~CClientsDlg();
|
||||
|
||||
bool FillHeadOfficeList();
|
||||
|
||||
void BlankAllFields(bool bSetDefaults,bool bEnable);
|
||||
CString m_strSelectedClient;
|
||||
void SetReturnString(CString *ret);
|
||||
//Save fields
|
||||
bool SaveField(CEdit* edControl,CString fldname,bool AllowEmpty);
|
||||
bool SaveField(CgzCombo* cbControl,CString fldname);
|
||||
bool SaveField(CButton* ckControl,CString fldname);
|
||||
bool SaveField(CDateTimeCtrl* dtControl,CString fldname);
|
||||
bool UpdateModified();
|
||||
//-------------------------------
|
||||
|
||||
bool FillContractList();
|
||||
bool FillTechList();
|
||||
bool FillZoneList();
|
||||
bool FillFields();
|
||||
bool AddRecord(bool IsHeadOffice);
|
||||
bool RefreshDisplay(int dMode/*0=standard 1=headoffice 2=add*/);
|
||||
bool FillClientList();
|
||||
bool m_bAddMode;
|
||||
CClientsDlg(CWnd* pParent = NULL); // standard constructor
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
GZRset* rs2;
|
||||
CString * m_pstrReturnValue;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CClientsDlg)
|
||||
enum { IDD = IDD_CLIENTS };
|
||||
CButton m_btnNotes;
|
||||
CButton m_btnDone;
|
||||
CEdit m_edAcctNum;
|
||||
CgzCombo m_cbDefTravelRate;
|
||||
CgzCombo m_cbRate;
|
||||
CButton m_btnPM;
|
||||
CLabel m_lblHist;
|
||||
CLabel m_lblZone;
|
||||
CgzCombo m_cbZone;
|
||||
CButton m_ckBillHead;
|
||||
CLabel m_lblAlert;
|
||||
CEdit m_edAlert;
|
||||
CStatic m_lblTechNotes;
|
||||
CEdit m_edTechNotes;
|
||||
CStatic m_lblStreet;
|
||||
CEdit m_edStreet;
|
||||
CStatic m_lblStateProv;
|
||||
CEdit m_edStateProv;
|
||||
CLabel m_lblPreferTech;
|
||||
CgzCombo m_cbPreferTech;
|
||||
CStatic m_lblPostal;
|
||||
CEdit m_edPostal;
|
||||
CStatic m_lblPhone;
|
||||
CEdit m_edPhone;
|
||||
CStatic m_lblMail;
|
||||
CEdit m_edMail;
|
||||
CStatic m_lblLast;
|
||||
CEdit m_edLast;
|
||||
CStatic m_lblHeadOffice;
|
||||
CgzCombo m_cbHeadOffice;
|
||||
CStatic m_lblGenNotes;
|
||||
CEdit m_edGenNotes;
|
||||
CStatic m_lblFirst;
|
||||
CEdit m_edFirst;
|
||||
CStatic m_lblFax;
|
||||
CEdit m_edFax;
|
||||
CStatic m_lblExtension;
|
||||
CEdit m_edExtension;
|
||||
CLabel m_lblEmail;
|
||||
CEdit m_edEmail;
|
||||
CButton m_btnDelete;
|
||||
CStatic m_lblCountry;
|
||||
CEdit m_edCountry;
|
||||
CLabel m_lblContract;
|
||||
CStatic m_lblContractExpiry;
|
||||
CDateTimeCtrl m_dtContractExpiryDate;
|
||||
CgzCombo m_cbContract;
|
||||
CButton m_btnConsolidate;
|
||||
CStatic m_lblCompany;
|
||||
CEdit m_edCompany;
|
||||
CStatic m_lblCity;
|
||||
CEdit m_edCity;
|
||||
CButton m_btnAddHead;
|
||||
CButton m_btnAdd;
|
||||
CButton m_ckShowHeadOfficeCheck;
|
||||
CStatic m_lblClientListLabel;
|
||||
CgzCombo m_cbClientList;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CClientsDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CClientsDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnCloseupClientlist();
|
||||
afx_msg void OnHeadoffice();
|
||||
afx_msg void OnCloseupContract();
|
||||
afx_msg void OnDelete();
|
||||
afx_msg void OnAdd();
|
||||
afx_msg void OnAddhead();
|
||||
virtual void OnOK();
|
||||
afx_msg void OnKillfocusFirstname();
|
||||
afx_msg void OnKillfocusCompany();
|
||||
afx_msg void OnKillfocusLastname();
|
||||
afx_msg void OnKillfocusMailaddress();
|
||||
afx_msg void OnKillfocusStreet();
|
||||
afx_msg void OnKillfocusCity();
|
||||
afx_msg void OnKillfocusStateprovince();
|
||||
afx_msg void OnKillfocusPostal();
|
||||
afx_msg void OnKillfocusCountry();
|
||||
afx_msg void OnKillfocusPhone();
|
||||
afx_msg void OnKillfocusExtension();
|
||||
afx_msg void OnKillfocusEmail();
|
||||
afx_msg void OnKillfocusFax();
|
||||
afx_msg void OnCloseupHeadofficepicker();
|
||||
afx_msg void OnBillhead();
|
||||
afx_msg void OnKillfocusTechnotes();
|
||||
afx_msg void OnKillfocusGeneralnotes();
|
||||
afx_msg void OnCloseupZone();
|
||||
afx_msg void OnCloseupPrefertech();
|
||||
afx_msg void OnDatetimechangeContractexpirydate(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnKillfocusAlert();
|
||||
afx_msg void OnZonelabel();
|
||||
afx_msg void OnContractlabel();
|
||||
afx_msg void OnHistory();
|
||||
afx_msg void OnBtnpm();
|
||||
afx_msg void OnCloseupCbdefrate();
|
||||
afx_msg void OnCloseupCbdeftravel();
|
||||
afx_msg void OnBtnnotes();
|
||||
afx_msg void OnConsolidate();
|
||||
afx_msg void OnBtndone();
|
||||
afx_msg void OnKillfocusEdacctnum();
|
||||
afx_msg void OnClientsAras();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
afx_msg void OnNewClientrecord();
|
||||
afx_msg void OnUpdateNewClientrecord(CCmdUI *pCmdUI);
|
||||
afx_msg void OnNewHeadofficerecord();
|
||||
afx_msg void OnUpdateNewHeadofficerecord(CCmdUI *pCmdUI);
|
||||
afx_msg void OnEditDeletethisrecord();
|
||||
afx_msg void OnUpdateEditDeletethisrecord(CCmdUI *pCmdUI);
|
||||
afx_msg void OnEditConsolidatetwoclientstogether();
|
||||
afx_msg void OnUpdateEditConsolidatetwoclientstogether(CCmdUI *pCmdUI);
|
||||
afx_msg void OnUpdateClientsAras(CCmdUI *pCmdUI);
|
||||
afx_msg void OnToolsOpenclientnotebook();
|
||||
afx_msg void OnUpdateToolsOpenclientnotebook(CCmdUI *pCmdUI);
|
||||
afx_msg void OnToolsSchedulepreventivemaintenanceforthisclient();
|
||||
afx_msg void OnUpdateToolsSchedulepreventivemaintenanceforthisclient(CCmdUI *pCmdUI);
|
||||
afx_msg void OnToolsDisplayrecordhistory();
|
||||
afx_msg void OnUpdateToolsDisplayrecordhistory(CCmdUI *pCmdUI);
|
||||
afx_msg void OnClosethisscreen();
|
||||
afx_msg void OnUpdateClosethisscreen(CCmdUI *pCmdUI);
|
||||
afx_msg void OnClientMenuHelp();
|
||||
void OnInitMenuPopup(CMenu *pPopupMenu, UINT nIndex,BOOL bSysMenu);
|
||||
|
||||
// User is allowed into PM?
|
||||
bool m_bPMAllowed;
|
||||
|
||||
CEdit m_edPhone2;
|
||||
CEdit m_edPhone3;
|
||||
afx_msg void OnEnKillfocusPhone2();
|
||||
afx_msg void OnEnKillfocusPhone3();
|
||||
afx_msg void OnEmaillabel();
|
||||
|
||||
afx_msg void OnToolsSetaddressdefaults();
|
||||
|
||||
CgzCombo m_cbUnits;
|
||||
CLabel m_lblUnits;
|
||||
|
||||
void FillUnitList(void);
|
||||
afx_msg void OnStnClickedLblUnits();
|
||||
private:
|
||||
CString m_strDefaultCity;
|
||||
CString m_strDefaultStateProv;
|
||||
CString m_strDefaultPostal;
|
||||
CString m_strDefaultCountry;
|
||||
long lPreferredTech;
|
||||
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CLIENTSDLG_H__8983F421_114C_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,546 @@
|
||||
// ClientsRA.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "ClientsRA.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClientsRA dialog
|
||||
|
||||
|
||||
CClientsRA::CClientsRA(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CClientsRA::IDD, pParent)
|
||||
, m_bDontCallSaveRecord(false)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CClientsRA)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
//Initialize recordset pointer
|
||||
rs=m_pApp->rsPool->GetRS("CClientsRA");
|
||||
m_bAddMode=false;
|
||||
}
|
||||
|
||||
|
||||
void CClientsRA::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CClientsRA)
|
||||
DDX_Control(pDX, IDC_LBL_HISTORY, m_lblHistory);
|
||||
DDX_Control(pDX, IDC_EDPW, m_edPassword);
|
||||
DDX_Control(pDX, IDC_EDPRIVATENOTES, m_edPrivateNotes);
|
||||
DDX_Control(pDX, IDC_EDLOGINID, m_edLoginID);
|
||||
DDX_Control(pDX, IDC_CKWOREPORTS, m_ckWOReports);
|
||||
DDX_Control(pDX, IDC_CKVIEWWORKORDERS, m_ckViewWorkorders);
|
||||
DDX_Control(pDX, IDC_CKVIEWSTATUS, m_ckViewStatus);
|
||||
DDX_Control(pDX, IDC_CKVIEWREQUESTS, m_ckViewRequests);
|
||||
DDX_Control(pDX, IDC_CKREQUEST_SERVICE, m_ckRequestService);
|
||||
DDX_Control(pDX, IDC_CBCLIENT, m_cbClient);
|
||||
DDX_Control(pDX, IDC_CBACCOUNT, m_cbAccount);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CClientsRA, CDialog)
|
||||
//{{AFX_MSG_MAP(CClientsRA)
|
||||
ON_CBN_CLOSEUP(IDC_CBCLIENT, OnCloseupCbclient)
|
||||
ON_CBN_CLOSEUP(IDC_CBACCOUNT, OnCloseupCbaccount)
|
||||
ON_COMMAND(ID_CLIENT_RA_ADD, OnClientRaAdd)
|
||||
ON_COMMAND(ID_CLIENT_RA_CLOSE, OnClientRaClose)
|
||||
ON_COMMAND(ID_CLIENT_RA_DELETE, OnClientRaDelete)
|
||||
ON_EN_KILLFOCUS(IDC_EDLOGINID, OnKillfocusEdloginid)
|
||||
ON_EN_KILLFOCUS(IDC_EDPRIVATENOTES, OnKillfocusEdprivatenotes)
|
||||
ON_EN_KILLFOCUS(IDC_EDPW, OnKillfocusEdpw)
|
||||
ON_BN_CLICKED(IDC_CKWOREPORTS, OnCkworeports)
|
||||
ON_BN_CLICKED(IDC_CKVIEWWORKORDERS, OnCkviewworkorders)
|
||||
ON_BN_CLICKED(IDC_CKVIEWSTATUS, OnCkviewstatus)
|
||||
ON_BN_CLICKED(IDC_CKVIEWREQUESTS, OnCkviewrequests)
|
||||
ON_BN_CLICKED(IDC_CKREQUEST_SERVICE, OnCkrequestService)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClientsRA message handlers
|
||||
|
||||
void CClientsRA::OnOK()
|
||||
{}
|
||||
|
||||
CClientsRA::~CClientsRA()
|
||||
{
|
||||
//delete rs;
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
BOOL CClientsRA::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
// TODO: Add extra initialization here
|
||||
FillClientList();
|
||||
FillAccountList();
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CClientsRA::FillClientList()
|
||||
{
|
||||
CString q,strData,strIndex;
|
||||
long lData;
|
||||
|
||||
//fill client list
|
||||
m_strCurrentAccount.Empty();
|
||||
m_cbClient.Clear();
|
||||
ClearAllEntries();
|
||||
|
||||
q.Format("SELECT clients.id, clients.company FROM clients "
|
||||
"ORDER BY clients.company;");
|
||||
rs->QueryReadOnly(q);
|
||||
if(rs->IsEmpty())
|
||||
return;
|
||||
|
||||
do{
|
||||
rs->FetchField("company",&strData);
|
||||
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbClient.AddRow(strData,strIndex);
|
||||
|
||||
|
||||
}while(rs->MoveForward());
|
||||
|
||||
//handle empty selection or reselect current one
|
||||
if(m_strCurrentClient.IsEmpty()) //first time in
|
||||
{
|
||||
m_cbClient.SetCurSel(0);
|
||||
m_strCurrentClient=m_cbClient.GetCurrentRowID();
|
||||
|
||||
}
|
||||
else//something valid was selected before so stick with it
|
||||
m_cbClient.Select(m_strCurrentClient);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CClientsRA::FillAccountList()
|
||||
{
|
||||
CString q,strData,strIndex;
|
||||
long lData;
|
||||
//FILL ACCOUNT LIST
|
||||
m_cbAccount.Clear();
|
||||
|
||||
q.Format("SELECT clients_aras.id, clients_aras.loginid "
|
||||
"FROM clients_aras "
|
||||
"WHERE (((clients_aras.clientlink)=%s));",m_strCurrentClient);
|
||||
rs->QueryReadOnly(q);
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
AllowEntry(false);
|
||||
return;
|
||||
}
|
||||
|
||||
do{
|
||||
rs->FetchField("loginid",&strData);
|
||||
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbAccount.AddRow(strData,strIndex);
|
||||
|
||||
|
||||
}while(rs->MoveForward());
|
||||
|
||||
//done this way in case there is some reason later
|
||||
//to persist the selected account
|
||||
//m_strCurrentAccount.Empty();
|
||||
//handle empty selection or reselect current one
|
||||
if(m_strCurrentAccount.IsEmpty()) //first time in
|
||||
{
|
||||
m_cbAccount.SetCurSel(0);
|
||||
m_strCurrentAccount=m_cbAccount.GetCurrentRowID();
|
||||
|
||||
}
|
||||
else//something valid was selected before so stick with it
|
||||
m_cbAccount.Select(m_strCurrentAccount);
|
||||
|
||||
FillFields();
|
||||
}
|
||||
|
||||
void CClientsRA::AllowEntry(bool bAllow)
|
||||
{
|
||||
BOOL e=bAllow?TRUE:FALSE;
|
||||
m_ckRequestService.EnableWindow(e);
|
||||
m_ckViewRequests.EnableWindow(e);
|
||||
m_ckViewStatus.EnableWindow(e);
|
||||
m_ckViewWorkorders.EnableWindow(e);
|
||||
m_ckWOReports.EnableWindow(e);
|
||||
m_edLoginID.EnableWindow(e);
|
||||
m_edPassword.EnableWindow(e);
|
||||
m_edPrivateNotes.EnableWindow(e);
|
||||
m_lblHistory.EnableWindow(e);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CClientsRA::ClearAllEntries()
|
||||
{
|
||||
m_ckRequestService.SetCheck(FALSE);
|
||||
m_ckViewRequests.SetCheck(FALSE);
|
||||
m_ckViewStatus.SetCheck(FALSE);
|
||||
m_ckViewWorkorders.SetCheck(FALSE);
|
||||
m_ckWOReports.SetCheck(FALSE);
|
||||
m_edLoginID.SetWindowText("");
|
||||
m_edPassword.SetWindowText("");
|
||||
m_edPrivateNotes.SetWindowText("");
|
||||
m_lblHistory.SetWindowText("");
|
||||
}
|
||||
|
||||
void CClientsRA::FillFields()
|
||||
{
|
||||
CString q;
|
||||
bool bData;
|
||||
CString strData;
|
||||
COleDateTime dtData;
|
||||
CString strHistory;
|
||||
ClearAllEntries();
|
||||
if(m_strCurrentAccount.IsEmpty()) m_strCurrentAccount="0";//so that the following normal process happens
|
||||
|
||||
q.Format("SELECT clients_aras.*, [users].[last] & \", \" & [users].[first] AS CREATED_BY, "
|
||||
"[users_1].[last] & \", \" & [users_1].[first] AS LAST_EDITED_BY "
|
||||
"FROM (clients_aras LEFT JOIN users ON clients_aras.creator = users.id) LEFT JOIN users AS users_1 ON clients_aras.modifier = users_1.id "
|
||||
"WHERE (((clients_aras.id)=%s));",m_strCurrentAccount);
|
||||
rs->QueryReadOnly(q);
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
AllowEntry(false);
|
||||
return;
|
||||
}
|
||||
else
|
||||
AllowEntry(true);
|
||||
|
||||
rs->FetchField("loginid",&strData);
|
||||
m_edLoginID.SetWindowText(strData);
|
||||
|
||||
rs->FetchField("loginpw",&strData);
|
||||
m_edPassword.SetWindowText(strData);
|
||||
|
||||
rs->FetchField("private_notes",&strData);
|
||||
m_edPrivateNotes.SetWindowText(strData);
|
||||
|
||||
rs->FetchField("view_wo_status", &bData);
|
||||
m_ckViewStatus.SetCheck(bData?TRUE:FALSE);
|
||||
|
||||
rs->FetchField("request_service", &bData);
|
||||
m_ckRequestService.SetCheck(bData?TRUE:FALSE);
|
||||
|
||||
rs->FetchField("view_request_list", &bData);
|
||||
m_ckViewRequests.SetCheck(bData?TRUE:FALSE);
|
||||
|
||||
rs->FetchField("wo_view", &bData);
|
||||
m_ckViewWorkorders.SetCheck(bData?TRUE:FALSE);
|
||||
|
||||
rs->FetchField("wo_report", &bData);
|
||||
m_ckWOReports.SetCheck(bData?TRUE:FALSE);
|
||||
|
||||
|
||||
//HISTORY
|
||||
rs->FetchField("CREATED_BY",&strData);
|
||||
strHistory="Account created by: " + strData;
|
||||
rs->FetchField("created",&dtData);
|
||||
strHistory+=" On: " + dtData.Format() + "\r\n";
|
||||
|
||||
rs->FetchField("LAST_EDITED_BY",&strData);
|
||||
strHistory+="Last modified by: " + strData;
|
||||
rs->FetchField("modified",&dtData);
|
||||
strHistory+=" On: " + dtData.Format() + "\r\n";
|
||||
|
||||
|
||||
rs->FetchField("last_login_date",&dtData);
|
||||
strHistory+="Last remote login on: " + dtData.Format();
|
||||
m_lblHistory.SetWindowText(strHistory);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CClientsRA::OnCloseupCbclient()
|
||||
{
|
||||
if(m_strCurrentClient==m_cbClient.GetCurrentRowID())
|
||||
return;//do nothing if same client. Fixes bounce problem
|
||||
ClearAllEntries();
|
||||
m_strCurrentAccount.Empty();
|
||||
m_strCurrentClient=m_cbClient.GetCurrentRowID();
|
||||
FillAccountList();
|
||||
}
|
||||
|
||||
|
||||
void CClientsRA::OnCloseupCbaccount()
|
||||
{
|
||||
if(m_strCurrentAccount==m_cbAccount.GetCurrentRowID())
|
||||
return;//fix for bounce problem
|
||||
m_strCurrentAccount=m_cbAccount.GetCurrentRowID();
|
||||
FillFields();
|
||||
|
||||
}
|
||||
|
||||
void CClientsRA::OnClientRaAdd()
|
||||
{
|
||||
if(m_bAddMode)
|
||||
{
|
||||
//save record
|
||||
if(SaveRecord(false))
|
||||
{
|
||||
m_cbAccount.EnableWindow(TRUE);
|
||||
m_cbClient.EnableWindow(TRUE);
|
||||
m_bAddMode=false;
|
||||
m_strCurrentAccount.Empty();
|
||||
FillAccountList();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearAllEntries();
|
||||
AllowEntry(true);
|
||||
m_bAddMode=true;
|
||||
m_cbAccount.EnableWindow(FALSE);
|
||||
m_cbClient.EnableWindow(FALSE);
|
||||
}
|
||||
|
||||
HandleMenuMode();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CClientsRA::OnClientRaClose()
|
||||
{
|
||||
if(m_bAddMode)
|
||||
{
|
||||
AfxMessageBox("You can't close while adding a record.");
|
||||
return;
|
||||
}
|
||||
|
||||
CDialog::OnOK();
|
||||
|
||||
}
|
||||
|
||||
void CClientsRA::OnClientRaDelete()
|
||||
{
|
||||
if(m_bAddMode)//is cancel, not delete
|
||||
{
|
||||
m_bAddMode=false;
|
||||
m_cbAccount.EnableWindow(TRUE);
|
||||
m_cbClient.EnableWindow(TRUE);
|
||||
HandleMenuMode();
|
||||
FillAccountList();
|
||||
return;
|
||||
}
|
||||
|
||||
//Delete a record
|
||||
CString q;
|
||||
|
||||
q.Format("DELETE clients_aras.*, clients_aras.id FROM clients_aras "
|
||||
"WHERE (((clients_aras.id)=%s));",m_strCurrentAccount);
|
||||
if(AfxMessageBox("Delete this account?\r\nAre you sure?",MB_YESNO)==IDYES)
|
||||
{
|
||||
m_strCurrentAccount.Empty();
|
||||
ClearAllEntries();
|
||||
rs->Ex(q);
|
||||
FillAccountList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CClientsRA::HandleMenuMode()
|
||||
{
|
||||
CString strDeleteText;
|
||||
CString strAddText;
|
||||
|
||||
if(m_bAddMode)
|
||||
{
|
||||
strDeleteText="Ca&ncel add";
|
||||
strAddText="&Save";
|
||||
}
|
||||
else
|
||||
{
|
||||
strDeleteText="&Delete";
|
||||
strAddText="&Add";
|
||||
}
|
||||
|
||||
CMenu* pMenu=this->GetMenu();
|
||||
pMenu->ModifyMenu(ID_CLIENT_RA_ADD,MF_BYCOMMAND,ID_CLIENT_RA_ADD,strAddText);
|
||||
pMenu->ModifyMenu(ID_CLIENT_RA_DELETE,MF_BYCOMMAND,ID_CLIENT_RA_DELETE,strDeleteText);
|
||||
this->DrawMenuBar();
|
||||
}
|
||||
|
||||
bool CClientsRA::SaveRecord(bool bUpdate)
|
||||
{
|
||||
//don't do this if an update request and in add mode
|
||||
if(m_bAddMode && bUpdate==true) return false;
|
||||
|
||||
GZK k;
|
||||
|
||||
CString q,login,pw,notes,str,loginhashed;
|
||||
CString RequestService, ViewRequests, ViewStatus, ViewWorkorders, WOReports;
|
||||
COleDateTime dtNow, dtNever;
|
||||
dtNow=COleDateTime::GetCurrentTime();
|
||||
dtNever.SetDateTime(1968,03,12,0,0,0);
|
||||
|
||||
m_edLoginID.GetWindowText(login);
|
||||
if(login.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("Login can not be blank");
|
||||
return false;
|
||||
|
||||
}
|
||||
loginhashed=login;
|
||||
k.GZHash(&loginhashed);
|
||||
|
||||
m_edPassword.GetWindowText(pw);
|
||||
m_edPrivateNotes.GetWindowText(notes);
|
||||
notes.Replace("\"","'");
|
||||
|
||||
RequestService=m_ckRequestService.GetCheck() ? "True":"False";
|
||||
ViewRequests=m_ckViewRequests.GetCheck() ? "True":"False";
|
||||
ViewStatus=m_ckViewStatus.GetCheck() ? "True":"False";
|
||||
ViewWorkorders=m_ckViewWorkorders.GetCheck() ? "True":"False";
|
||||
WOReports=m_ckWOReports.GetCheck() ? "True":"False";
|
||||
|
||||
q.Format("SELECT users.login FROM users WHERE (((users.login)=\"%s\")); ",loginhashed);
|
||||
rs->QueryReadOnly(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
AfxMessageBox(
|
||||
"Security warning: The login assigned to this client can not be used.\r\n"
|
||||
"The reason is that the same login is in use already by an AyaNova user.\r\n\r\n"
|
||||
|
||||
"Login names must be unique amongst all AyaNova users and ARAS client accounts.\r\n\r\n"
|
||||
|
||||
"Change the login name to something unique before saving.",MB_ICONSTOP);
|
||||
m_edLoginID.SetFocus();
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(bUpdate==false)//insert new record
|
||||
{
|
||||
//Check if login name already exists and disallow if so
|
||||
q.Format("SELECT clients.company FROM clients_aras LEFT JOIN "
|
||||
"clients ON clients_aras.clientlink = clients.id WHERE "
|
||||
"(((clients_aras.loginid)=\"%s\"));",login);
|
||||
rs->QueryReadOnly(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
rs->FetchField("company",&str);
|
||||
q.Format(
|
||||
"Problem: No two ARAS client login id's can be the same.\r\n"
|
||||
"The account login id \"%s\" is already in use by \r\n"
|
||||
"an existing account for %s\r\n"
|
||||
"This record can not be saved until the login id is changed.\r\n",login,str);
|
||||
|
||||
AfxMessageBox(q,MB_ICONSTOP);
|
||||
m_edLoginID.SetFocus();
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
q.Format("INSERT INTO clients_aras ( clientlink, loginid, loginpw, view_wo_status, "
|
||||
"search_history, wo_view, wo_report, request_service, view_request_list, private_notes, "
|
||||
"last_login_date, creator, modifier, created, modified ) "
|
||||
"SELECT %s , \"%s\", \"%s\", %s, %s , %s, %s, %s, %s, \"%s\", #%s#, %u, %u, #%s#, #%s#;"
|
||||
,m_strCurrentClient,login, pw,ViewStatus, "False",ViewWorkorders,WOReports,RequestService,ViewRequests,notes,
|
||||
dtNever.Format(_T("%m/%d/%Y %H:%M:%S")),m_pApp->m_lusrID,m_pApp->m_lusrID,
|
||||
dtNow.Format(_T("%m/%d/%Y %H:%M:%S")),dtNow.Format(_T("%m/%d/%Y %H:%M:%S")));
|
||||
}
|
||||
|
||||
|
||||
else//update existing record
|
||||
{
|
||||
//check if login name already exists for other clients than this one
|
||||
//if so then disallow save
|
||||
|
||||
//Query for any user other than current account with same password
|
||||
q.Format("SELECT clients.company FROM clients_aras LEFT JOIN "
|
||||
"clients ON clients_aras.clientlink = clients.id WHERE "
|
||||
"(((clients_aras.loginid)=\"%s\") AND ((clients_aras.id)<>%s));",login,m_strCurrentAccount);
|
||||
rs->QueryReadOnly(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
rs->FetchField("company",&str);
|
||||
q.Format(
|
||||
"Problem: No two ARAS client login id's can be the same.\r\n"
|
||||
"The account login id \"%s\" is already in use by \r\n"
|
||||
"an existing account for %s\r\n"
|
||||
"This record can not be saved until the login id is changed.\r\n",login,str);
|
||||
|
||||
AfxMessageBox(q,MB_ICONSTOP);
|
||||
//m_edLoginID.SetFocus();
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
q.Format("UPDATE clients_aras SET loginid=\"%s\", loginpw=\"%s\", view_wo_status=%s, search_history=False, "
|
||||
"wo_view=%s, wo_report=%s, request_service=%s, view_request_list=%s, "
|
||||
"private_notes=\"%s\", modifier=%u, modified=#%s# "
|
||||
"WHERE (((clients_aras.id)=%s));",
|
||||
login,pw,ViewStatus,ViewWorkorders,WOReports,RequestService,ViewRequests,notes,m_pApp->m_lusrID,
|
||||
dtNow.Format(_T("%m/%d/%Y %H:%M:%S")),m_strCurrentAccount);
|
||||
|
||||
}
|
||||
|
||||
return(rs->Ex(q));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CClientsRA::OnKillfocusEdloginid()
|
||||
{
|
||||
if(m_bDontCallSaveRecord) return;
|
||||
m_bDontCallSaveRecord=true;
|
||||
if(SaveRecord(true))
|
||||
{
|
||||
if(!m_bAddMode)
|
||||
FillAccountList();
|
||||
}
|
||||
m_bDontCallSaveRecord=false;
|
||||
|
||||
}
|
||||
|
||||
void CClientsRA::OnKillfocusEdprivatenotes()
|
||||
{SaveRecord(true);}
|
||||
|
||||
void CClientsRA::OnKillfocusEdpw()
|
||||
{SaveRecord(true);}
|
||||
|
||||
void CClientsRA::OnCkworeports()
|
||||
{SaveRecord(true);}
|
||||
|
||||
void CClientsRA::OnCkviewworkorders()
|
||||
{SaveRecord(true);}
|
||||
|
||||
void CClientsRA::OnCkviewstatus()
|
||||
{SaveRecord(true);}
|
||||
|
||||
void CClientsRA::OnCkviewrequests()
|
||||
{SaveRecord(true);}
|
||||
|
||||
void CClientsRA::OnCkrequestService()
|
||||
{SaveRecord(true);}
|
||||
@@ -0,0 +1,91 @@
|
||||
#if !defined(AFX_CLIENTSRA_H__992FAD64_D5A5_4CCF_A1AE_AD3F5224139B__INCLUDED_)
|
||||
#define AFX_CLIENTSRA_H__992FAD64_D5A5_4CCF_A1AE_AD3F5224139B__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// ClientsRA.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CClientsRA dialog
|
||||
#include "gzrset.h"
|
||||
//#include "label.h"
|
||||
//#include "gzlistbox.h"
|
||||
#include "gzcombo.h"
|
||||
#include "gzk.h"
|
||||
|
||||
class CClientsRA : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
~CClientsRA();
|
||||
CString m_strCurrentClient;
|
||||
CClientsRA(CWnd* pParent = NULL); // standard constructor
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
bool m_bAddMode;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CClientsRA)
|
||||
enum { IDD = IDD_CLIENTS_RA };
|
||||
CStatic m_lblHistory;
|
||||
CEdit m_edPassword;
|
||||
CEdit m_edPrivateNotes;
|
||||
CEdit m_edLoginID;
|
||||
CButton m_ckWOReports;
|
||||
CButton m_ckViewWorkorders;
|
||||
CButton m_ckViewStatus;
|
||||
CButton m_ckViewRequests;
|
||||
CButton m_ckRequestService;
|
||||
CgzCombo m_cbClient;
|
||||
CgzCombo m_cbAccount;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CClientsRA)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CClientsRA)
|
||||
virtual void OnOK();
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnCloseupCbclient();
|
||||
afx_msg void OnCloseupCbaccount();
|
||||
afx_msg void OnClientRaAdd();
|
||||
afx_msg void OnClientRaClose();
|
||||
afx_msg void OnClientRaDelete();
|
||||
afx_msg void OnKillfocusEdloginid();
|
||||
afx_msg void OnKillfocusEdprivatenotes();
|
||||
afx_msg void OnKillfocusEdpw();
|
||||
afx_msg void OnCkworeports();
|
||||
afx_msg void OnCkviewworkorders();
|
||||
afx_msg void OnCkviewstatus();
|
||||
afx_msg void OnCkviewrequests();
|
||||
afx_msg void OnCkrequestService();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
bool SaveRecord(bool bUpdate);
|
||||
void HandleMenuMode();
|
||||
void FillFields();
|
||||
void ClearAllEntries();
|
||||
void AllowEntry(bool bAllow);
|
||||
CString m_strCurrentAccount;
|
||||
void FillAccountList();
|
||||
void FillClientList();
|
||||
public:
|
||||
// Used by saverecord and OnKillFocusEdLoginID to prevent looping error dialog
|
||||
bool m_bDontCallSaveRecord;
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CLIENTSRA_H__992FAD64_D5A5_4CCF_A1AE_AD3F5224139B__INCLUDED_)
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef _COMMON_H_
|
||||
#define _COMMON_H_
|
||||
|
||||
#ifndef _QWORD_DEFINED
|
||||
#define _QWORD_DEFINED
|
||||
typedef __int64 QWORD, *LPQWORD;
|
||||
#endif
|
||||
|
||||
#define MAKEQWORD(a, b) \
|
||||
((QWORD)( ((QWORD) ((DWORD) (a))) << 32 | ((DWORD) (b))))
|
||||
|
||||
#define LODWORD(l) \
|
||||
((DWORD)(l))
|
||||
#define HIDWORD(l) \
|
||||
((DWORD)(((QWORD)(l) >> 32) & 0xFFFFFFFF))
|
||||
|
||||
// Read 4K of data at a time (used in the C++ streams, Win32 I/O, and assembly functions)
|
||||
#define MAX_BUFFER_SIZE 4096
|
||||
|
||||
// Map a "view" size of 10MB (used in the filemap function)
|
||||
#define MAX_VIEW_SIZE 10485760
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,196 @@
|
||||
// ConsolidateDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "ConsolidateDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CConsolidateDlg dialog
|
||||
|
||||
|
||||
CConsolidateDlg::CConsolidateDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CConsolidateDlg::IDD, pParent)
|
||||
{
|
||||
|
||||
//{{AFX_DATA_INIT(CConsolidateDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
|
||||
m_pApp = (CSpApp*)AfxGetApp();
|
||||
/*
|
||||
rs=new GZRset("Error: Consolidate clients dialog");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
*/
|
||||
//Initialize recordset pointer
|
||||
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CConsolidateDlg");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
CConsolidateDlg::~CConsolidateDlg()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
void CConsolidateDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CConsolidateDlg)
|
||||
DDX_Control(pDX, IDC_CBTO, m_cbTo);
|
||||
DDX_Control(pDX, IDC_CBFROM, m_cbFrom);
|
||||
DDX_Control(pDX, IDC_BTNDONE, m_btnDone);
|
||||
DDX_Control(pDX, IDC_BTNCONSOLIDATE, m_btnConsolidate);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CConsolidateDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CConsolidateDlg)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
ON_BN_CLICKED(IDC_BTNCONSOLIDATE, OnBtnconsolidate)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CConsolidateDlg message handlers
|
||||
|
||||
void CConsolidateDlg::OnOK()
|
||||
{
|
||||
//Do nothing enter key workaround
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CConsolidateDlg::OnBtndone()
|
||||
{
|
||||
CDialog::OnOK();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Doooooo-iiiiiiitttttttt......
|
||||
void CConsolidateDlg::OnBtnconsolidate()
|
||||
{
|
||||
|
||||
CString q,from,to;
|
||||
|
||||
from=m_cbFrom.GetCurrentRowID();
|
||||
to=m_cbTo.GetCurrentRowID();
|
||||
|
||||
|
||||
|
||||
//validate the two entries
|
||||
//something in each one:
|
||||
if(from.IsEmpty() || to.IsEmpty() || from=="0" || to=="0")
|
||||
{
|
||||
AfxMessageBox("You must select a client from each list to proceed.");
|
||||
return;
|
||||
}
|
||||
//Not the same:
|
||||
if(from==to)
|
||||
{
|
||||
AfxMessageBox("Invalid selection (they can't be the same)");
|
||||
return;
|
||||
}
|
||||
|
||||
//warning:
|
||||
AfxMessageBox("Warning: all other users must close this program now to avoid database corruption.\r\n"
|
||||
"This operation will make changes to nearly every table in the entire database\r\n"
|
||||
"Note: this change will not currently update the Preventive maintenance area of the program\r\n"
|
||||
"If you use Preventive Maintenance and the client being consolidated is used there\r\n"
|
||||
"you will need to manually change them\r\n"
|
||||
"\r\nMake sure you are the only user running this program before clicking on OK");
|
||||
|
||||
if(AfxMessageBox("You're absolutely 100% certain no one else is running this program?\r\nClick NO to cancel without consolidating",MB_YESNO)!=IDYES)
|
||||
return;
|
||||
|
||||
//are you sure?
|
||||
if(AfxMessageBox("Warning: this operation can not be reversed.\r\n"
|
||||
"You're sure you want to do this?",MB_YESNO|MB_DEFBUTTON2)!=IDYES)
|
||||
return;
|
||||
|
||||
|
||||
//run the change queries (alphabetical order by table)
|
||||
|
||||
//CONTACTS
|
||||
q.Format("UPDATE contacts SET contacts.clientlink = %s "
|
||||
"WHERE (((contacts.clientlink)=%s));",to,from);
|
||||
rs->Ex(q);
|
||||
|
||||
/*//PMSCHEDULES
|
||||
q.Format("UPDATE pmschedules SET pmschedules.client = %s "
|
||||
"WHERE (((pmschedules.client)=%s));",to,from);
|
||||
rs->Ex(q);
|
||||
*/
|
||||
|
||||
//RENTALS
|
||||
q.Format("UPDATE rentals SET rentals.clientlink = %s "
|
||||
"WHERE (((rentals.clientlink)=%s));",to,from);
|
||||
rs->Ex(q);
|
||||
|
||||
//STATUSVIEWS
|
||||
q.Format("UPDATE statusviews SET statusviews.client = %s "
|
||||
"WHERE (((statusviews.client)=%s));",to,from);
|
||||
rs->Ex(q);
|
||||
|
||||
//UNITS
|
||||
q.Format("UPDATE units SET units.client = %s "
|
||||
"WHERE (((units.client)=%s));",to,from);
|
||||
rs->Ex(q);
|
||||
|
||||
//Workorders
|
||||
q.Format("UPDATE wo SET wo.client = %s "
|
||||
"WHERE (((wo.client)=%s));",to,from);
|
||||
rs->Ex(q);
|
||||
|
||||
AfxMessageBox("All done!\r\nYou might not see the changes take effect on the main\r\n"
|
||||
"workorder screen until you refresh the display");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
BOOL CConsolidateDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
CString strData, strIndex,q;
|
||||
long lData;
|
||||
q="SELECT clients.id, clients.company AS compname FROM clients "
|
||||
"ORDER BY clients.company;";
|
||||
rs->Query(q);
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
AfxMessageBox("Can't find any clients, that's wierd.");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_cbFrom.AddRow(" Select...","0");
|
||||
m_cbTo.AddRow(" Select...","0");
|
||||
|
||||
do
|
||||
{
|
||||
rs->FetchField("compname",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbFrom.AddRow(strData,strIndex);
|
||||
m_cbTo.AddRow(strData,strIndex);
|
||||
|
||||
}while(rs->MoveForward());
|
||||
|
||||
m_cbFrom.Select(0);
|
||||
m_cbTo.Select(0);
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
#if !defined(AFX_CONSOLIDATEDLG_H__1FD4A321_8EDE_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_CONSOLIDATEDLG_H__1FD4A321_8EDE_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// ConsolidateDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CConsolidateDlg dialog
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
|
||||
class CConsolidateDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
~CConsolidateDlg();
|
||||
CConsolidateDlg(CWnd* pParent = NULL); // standard constructor
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CConsolidateDlg)
|
||||
enum { IDD = IDD_CONSOLIDATE };
|
||||
CgzCombo m_cbTo;
|
||||
CgzCombo m_cbFrom;
|
||||
CButton m_btnDone;
|
||||
CButton m_btnConsolidate;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CConsolidateDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CConsolidateDlg)
|
||||
virtual void OnOK();
|
||||
afx_msg void OnBtndone();
|
||||
afx_msg void OnBtnconsolidate();
|
||||
virtual BOOL OnInitDialog();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CONSOLIDATEDLG_H__1FD4A321_8EDE_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,212 @@
|
||||
// ContactDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "ContactDlg.h"
|
||||
#include "mailmsgdlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CContactDlg dialog
|
||||
|
||||
|
||||
CContactDlg::CContactDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CContactDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CContactDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
/*
|
||||
rs=new GZRset("Error: ContactDlg screen");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
*/
|
||||
//Initialize recordset pointer
|
||||
rs=m_pApp->rsPool->GetRS("CContactDlg");
|
||||
m_bEditMode=false;//add mode by default
|
||||
}
|
||||
|
||||
CContactDlg::~CContactDlg()
|
||||
{
|
||||
//delete rs;
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
void CContactDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CContactDlg)
|
||||
DDX_Control(pDX, IDC_EDNOTES, m_edNotes);
|
||||
DDX_Control(pDX, IDC_DTTIME, m_dtTime);
|
||||
DDX_Control(pDX, IDC_DTDATE, m_dtDate);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CContactDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CContactDlg)
|
||||
ON_BN_CLICKED(IDC_BTNFOLLOWUP, OnBtnfollowup)
|
||||
ON_BN_CLICKED(IDC_BTNEXITNOSAVE, OnBtnexitnosave)
|
||||
ON_BN_CLICKED(IDC_BTNEXITSAVE, OnBtnexitsave)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CContactDlg message handlers
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//*****************************************************
|
||||
void CContactDlg::Setup(CString strClientID,CString strRecordID)
|
||||
{
|
||||
m_strClientID=strClientID;
|
||||
m_strRecordID=strRecordID;
|
||||
if(m_strRecordID!="0")
|
||||
m_bEditMode=true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//****************************************************
|
||||
BOOL CContactDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
if(m_bEditMode)
|
||||
FillFields();
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CContactDlg::OnBtnfollowup()
|
||||
{
|
||||
CString msg,sub,q,clientname;
|
||||
COleDateTime dtData;
|
||||
CString datestring;
|
||||
|
||||
m_edNotes.GetWindowText(msg);
|
||||
if(msg.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("There are no notes to send");
|
||||
return;
|
||||
|
||||
}
|
||||
//1.9.3.0
|
||||
msg.Replace("\"","''");
|
||||
//Get date
|
||||
m_dtDate.GetTime(dtData);
|
||||
datestring = dtData.Format(VAR_DATEVALUEONLY);
|
||||
|
||||
//Get time
|
||||
m_dtTime.GetTime(dtData);
|
||||
datestring += " " + dtData.Format(VAR_TIMEVALUEONLY);
|
||||
|
||||
//jam together
|
||||
dtData.ParseDateTime(datestring);
|
||||
|
||||
|
||||
q.Format("SELECT IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS cname "
|
||||
"FROM clients WHERE (((clients.id)=%s));",m_strClientID);
|
||||
rs->Query(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
rs->FetchField("cname",&clientname);
|
||||
sub="Note on client: " + clientname + " " + dtData.Format();
|
||||
}
|
||||
else
|
||||
{
|
||||
sub="Note on client: <unknown client> " + dtData.Format();
|
||||
}
|
||||
|
||||
CMailMsgDlg d;
|
||||
d.m_bNoRE=true;//don't put a RE: in front of subject or >'s in front of text lines
|
||||
d.SetForwardInfo(&sub,&msg);
|
||||
d.DoModal();
|
||||
}
|
||||
|
||||
void CContactDlg::OnBtnexitnosave()
|
||||
{
|
||||
CDialog::OnOK();
|
||||
|
||||
}
|
||||
|
||||
void CContactDlg::OnBtnexitsave()
|
||||
{
|
||||
COleDateTime dtData;
|
||||
CString datestring,notes;
|
||||
|
||||
m_edNotes.GetWindowText(notes);
|
||||
if(notes.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("No data to save");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//1.9.3.0
|
||||
notes.Replace("\"","''");
|
||||
|
||||
//Get date
|
||||
m_dtDate.GetTime(dtData);
|
||||
datestring = dtData.Format(VAR_DATEVALUEONLY);
|
||||
|
||||
//Get time
|
||||
m_dtTime.GetTime(dtData);
|
||||
datestring += " " + dtData.Format(VAR_TIMEVALUEONLY);
|
||||
|
||||
//jam together
|
||||
dtData.ParseDateTime(datestring);
|
||||
|
||||
|
||||
CString q;
|
||||
if(m_bEditMode)
|
||||
{
|
||||
q.Format("UPDATE contacts SET contacts.[date] = #%s#, contacts.staff = %u, "
|
||||
"contacts.notes = \"%s\", contacts.clientlink = %s, contacts.indexed = False "
|
||||
"WHERE (((contacts.id)=%s));",dtData.Format(_T("%m/%d/%Y %H:%M:%S")),m_pApp->m_lusrID,notes,m_strClientID,
|
||||
m_strRecordID);
|
||||
}
|
||||
else
|
||||
{
|
||||
q.Format("INSERT INTO contacts ( [date], staff, notes, clientlink ) "
|
||||
"SELECT #%s#, %u,\"%s\", %s;",dtData.Format(_T("%m/%d/%Y %H:%M:%S")),m_pApp->m_lusrID,notes,m_strClientID);
|
||||
}
|
||||
|
||||
|
||||
rs->Ex(q);
|
||||
rs->Close();
|
||||
rs->Close();
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
|
||||
//Populate with existing data if in edit mode
|
||||
void CContactDlg::FillFields()
|
||||
{
|
||||
CString q,notes;
|
||||
COleDateTime dtData;
|
||||
q.Format("SELECT contacts.date, contacts.notes FROM contacts "
|
||||
"WHERE (((contacts.id)=%s));",m_strRecordID);
|
||||
rs->QueryReadOnly(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
rs->FetchField("notes",¬es);
|
||||
rs->FetchField("date",&dtData);
|
||||
m_dtDate.SetTime(dtData);
|
||||
m_dtTime.SetTime(dtData);
|
||||
m_edNotes.SetWindowText(notes);
|
||||
}
|
||||
rs->Close();
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#if !defined(AFX_CONTACTDLG_H__126794C1_2CE8_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_CONTACTDLG_H__126794C1_2CE8_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// ContactDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CContactDlg dialog
|
||||
#include "gzrset.h"
|
||||
#include "label.h"
|
||||
class CContactDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
void FillFields();
|
||||
CString m_strRecordID;
|
||||
bool m_bEditMode;
|
||||
~CContactDlg();
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
CString m_strClientID;
|
||||
bool* m_pbDelete;
|
||||
void Setup(CString strClientID,CString strRecordID);
|
||||
CContactDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CContactDlg)
|
||||
enum { IDD = IDD_CONTACTS };
|
||||
CEdit m_edNotes;
|
||||
CDateTimeCtrl m_dtTime;
|
||||
CDateTimeCtrl m_dtDate;
|
||||
|
||||
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CContactDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CContactDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBtnfollowup();
|
||||
afx_msg void OnBtnexitnosave();
|
||||
afx_msg void OnBtnexitsave();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CONTACTDLG_H__126794C1_2CE8_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,225 @@
|
||||
// ContactsViewDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "ContactsViewDlg.h"
|
||||
#include "ContactDlg.h"
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CContactsViewDlg dialog
|
||||
|
||||
|
||||
CContactsViewDlg::CContactsViewDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CContactsViewDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CContactsViewDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
//Initialize recordset pointer
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CContactsViewDlg");
|
||||
|
||||
}
|
||||
|
||||
CContactsViewDlg::~CContactsViewDlg()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
void CContactsViewDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CContactsViewDlg)
|
||||
DDX_Control(pDX, IDC_LSTNBRECS, m_lstNBRecs);
|
||||
DDX_Control(pDX, IDC_EDNOTES, m_edNotes);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CContactsViewDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CContactsViewDlg)
|
||||
ON_BN_CLICKED(IDC_BTNADD, OnBtnadd)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
ON_LBN_SELCHANGE(IDC_LSTNBRECS, OnSelchangeLstnbrecs)
|
||||
ON_BN_CLICKED(IDC_BTNEDIT, OnBtnedit)
|
||||
ON_BN_CLICKED(IDC_BTNDEL, OnBtndel)
|
||||
ON_LBN_DBLCLK(IDC_LSTNBRECS, OnDblclkLstnbrecs)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CContactsViewDlg message handlers
|
||||
|
||||
|
||||
void CContactsViewDlg::OnBtnadd()
|
||||
{
|
||||
CContactDlg d;
|
||||
d.Setup(m_strClientID,"0");
|
||||
d.DoModal();
|
||||
rs->Close();
|
||||
FillView();
|
||||
|
||||
}
|
||||
|
||||
void CContactsViewDlg::Setup(CString strClientID)
|
||||
{
|
||||
if(strClientID.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("Invalid client ID");
|
||||
CDialog::OnOK();
|
||||
}
|
||||
m_strClientID=strClientID;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CContactsViewDlg::FillView()
|
||||
{
|
||||
CString q,username,notes,allnotes,header,strID;
|
||||
COleDateTime dtData;
|
||||
long lData;
|
||||
m_lstNBRecs.Clear();
|
||||
q.Format("SELECT contacts.id, contacts.date "
|
||||
"FROM contacts "
|
||||
"WHERE (((contacts.clientlink)=%s)) ORDER BY contacts.date DESC;",m_strClientID);
|
||||
//m_pApp->ShowStuff(q);
|
||||
rs->QueryReadOnly(q);
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
m_edNotes.SetWindowText("No items to display");
|
||||
}
|
||||
else
|
||||
{
|
||||
rs->MoveFirst();
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
rs->FetchField("date",&dtData);
|
||||
rs->FetchField("id",&lData);
|
||||
strID.Format("%u",lData);
|
||||
m_lstNBRecs.AddRow(dtData.Format(),strID);
|
||||
|
||||
}while(rs->MoveForward());
|
||||
m_lstNBRecs.SetCurSel(0);
|
||||
OnSelchangeLstnbrecs();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
BOOL CContactsViewDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
CString q;
|
||||
q.Format("SELECT IIf(IsNull([clients].[company]),[clients].[first] & \" \" & [clients].[last],[clients].[company]) AS clientname "
|
||||
"FROM clients WHERE (((clients.id)=%s));",m_strClientID);
|
||||
rs->QueryReadOnly(q);
|
||||
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
rs->FetchField("clientname",&q);
|
||||
q="Client notes for: " + q;
|
||||
SetWindowText(q);
|
||||
|
||||
}
|
||||
|
||||
FillView();
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CContactsViewDlg::OnBtndone()
|
||||
{
|
||||
CDialog::OnOK();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//sc.exe gpf here somewhere
|
||||
void CContactsViewDlg::OnSelchangeLstnbrecs()
|
||||
{
|
||||
CString q,username,notes,allnotes,header,strID;
|
||||
COleDateTime dtData;
|
||||
/*
|
||||
if(m_bJustOpened)
|
||||
strID=m_strFirstRecordID;
|
||||
else
|
||||
{*/
|
||||
//AfxMessageBox("Calling: GetSelectedItem");
|
||||
m_lstNBRecs.RebuildIndex();//<--------FIXES PROBLEM
|
||||
strID=m_lstNBRecs.GetSelectedItem(0);//<-------problem
|
||||
//}
|
||||
|
||||
q.Format("SELECT contacts.id, [users].[first] & \" \" & [users].[last] AS username, contacts.date, contacts.notes "
|
||||
"FROM contacts LEFT JOIN users ON contacts.staff = users.id "
|
||||
"WHERE (((contacts.id)=%s));",strID);
|
||||
|
||||
rs->QueryReadOnly(q);
|
||||
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
m_edNotes.SetWindowText("No data");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
rs->FetchField("username",&username);
|
||||
rs->FetchField("notes",¬es);
|
||||
rs->FetchField("date",&dtData);
|
||||
|
||||
header=dtData.Format() + " - " + username;
|
||||
|
||||
allnotes=allnotes+"--< "+header+" >--\r\n"+notes+"\r\n\r\n";
|
||||
m_edNotes.SetWindowText(allnotes);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CContactsViewDlg::OnBtnedit()
|
||||
{
|
||||
CContactDlg d;
|
||||
d.Setup(m_strClientID,m_lstNBRecs.GetSelectedItem(0));
|
||||
d.DoModal();
|
||||
rs->Close();
|
||||
FillView();
|
||||
|
||||
}
|
||||
|
||||
void CContactsViewDlg::OnBtndel()
|
||||
{
|
||||
CString q;
|
||||
if(AfxMessageBox("Delete selected record?",MB_YESNO)==IDYES)
|
||||
{
|
||||
q.Format("DELETE contacts.*, contacts.id "
|
||||
"FROM contacts "
|
||||
"WHERE (((contacts.id)=%s));",m_lstNBRecs.GetSelectedItem(0));
|
||||
|
||||
rs->Ex(q);
|
||||
rs->Close();
|
||||
FillView();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CContactsViewDlg::OnDblclkLstnbrecs()
|
||||
{
|
||||
OnBtnedit();
|
||||
}
|
||||
|
||||
void CContactsViewDlg::OnOK()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
#if !defined(AFX_CONTACTSVIEWDLG_H__D9199E03_7CD5_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_CONTACTSVIEWDLG_H__D9199E03_7CD5_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// ContactsViewDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CContactsViewDlg dialog
|
||||
#include "gzrset.h"
|
||||
#include "label.h"
|
||||
#include "gzlistbox.h"
|
||||
class CContactsViewDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CString m_strFirstRecordID;
|
||||
~CContactsViewDlg();
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
void FillView();
|
||||
CString m_strClientID;
|
||||
void Setup(CString strClientID);
|
||||
CContactsViewDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CContactsViewDlg)
|
||||
enum { IDD = IDD_CONTACTS_VIEW };
|
||||
CgzListBox m_lstNBRecs;
|
||||
CEdit m_edNotes;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CContactsViewDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CContactsViewDlg)
|
||||
afx_msg void OnBtnadd();
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBtndone();
|
||||
afx_msg void OnSelchangeLstnbrecs();
|
||||
afx_msg void OnBtnedit();
|
||||
afx_msg void OnBtndel();
|
||||
afx_msg void OnDblclkLstnbrecs();
|
||||
virtual void OnOK();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CONTACTSVIEWDLG_H__D9199E03_7CD5_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,300 @@
|
||||
// ContractsDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "ContractsDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CContractsDlg dialog
|
||||
|
||||
|
||||
CContractsDlg::CContractsDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CContractsDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CContractsDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
//Initialize recordset pointer
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CContractsDlg");
|
||||
|
||||
}
|
||||
|
||||
CContractsDlg::~CContractsDlg()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
|
||||
void CContractsDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CContractsDlg)
|
||||
DDX_Control(pDX, IDC_CONTRACT_LIST_LABEL, m_lblContractList);
|
||||
DDX_Control(pDX, IDC_CONTRACT_DELETE, m_btnContractDelete);
|
||||
DDX_Control(pDX, IDC_CONTRACT_ADD, m_btnContractAdd);
|
||||
DDX_Control(pDX, IDC_CONTRACTTERMS, m_edContractTerms);
|
||||
DDX_Control(pDX, IDC_CONTRACTNAME, m_edContractName);
|
||||
DDX_Control(pDX, IDC_CONTRACT_COMBO, m_cbContracts);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CContractsDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CContractsDlg)
|
||||
ON_BN_CLICKED(IDC_CONTRACT_DELETE, OnContractDelete)
|
||||
ON_BN_CLICKED(IDC_CONTRACT_ADD, OnContractAdd)
|
||||
ON_CBN_CLOSEUP(IDC_CONTRACT_COMBO, OnCloseupContractCombo)
|
||||
ON_EN_KILLFOCUS(IDC_CONTRACTNAME, OnKillfocusContractname)
|
||||
ON_EN_KILLFOCUS(IDC_CONTRACTTERMS, OnKillfocusContractterms)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
|
||||
//************************************************************
|
||||
//SAVE EDIT CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CContractsDlg::SaveField(CEdit *edControl,CString fldname,bool AllowEmpty)
|
||||
{
|
||||
|
||||
if(m_bAddMode) return true;//dont attempt to update
|
||||
CString str;
|
||||
//do nothing if not changed
|
||||
if(edControl->GetModify()!=TRUE) return true;
|
||||
|
||||
edControl->GetWindowText(str);
|
||||
//dont save empty fields if not allowed to
|
||||
if(!AllowEmpty)
|
||||
{
|
||||
|
||||
if(str.IsEmpty())
|
||||
{
|
||||
edControl->Undo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rs->UpdateField(fldname,&str);
|
||||
rs->SaveRecord();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
bool CContractsDlg::FillContractsList()
|
||||
{
|
||||
CString strData;
|
||||
CString strIndex;
|
||||
long lData;
|
||||
m_cbContracts.Clear();
|
||||
rs->Query("SELECT contracts.* FROM contracts ORDER BY contracts.name;");
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
EnableFields(false);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
EnableFields(true);
|
||||
//fill combo box with available zones
|
||||
rs->MoveFirst();
|
||||
rs->FetchField("name",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbContracts.AddRow(strData,strIndex);
|
||||
while(rs->MoveForward())
|
||||
{
|
||||
rs->FetchField("name",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbContracts.AddRow(strData,strIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//pretend user has selected so that other fields get filled in
|
||||
if(m_strSelectedContract.IsEmpty()) //first time in
|
||||
{
|
||||
m_cbContracts.SetCurSel(0);
|
||||
}
|
||||
else//something valid was selected before so stick with it
|
||||
m_cbContracts.Select(m_strSelectedContract);
|
||||
|
||||
OnCloseupContractCombo();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CContractsDlg message handlers
|
||||
|
||||
void CContractsDlg::OnContractDelete()
|
||||
{
|
||||
CString q,strData;
|
||||
q.Format("SELECT * FROM clients WHERE (contract = %s );",m_cbContracts.GetCurrentRowID());
|
||||
|
||||
|
||||
|
||||
rs->Query(q);
|
||||
if(rs->IsEmpty())//no clients in that zone
|
||||
{
|
||||
|
||||
q.Format("DELETE contracts.*, contracts.id FROM contracts WHERE (((contracts.id)=%s));",m_cbContracts.GetCurrentRowID());
|
||||
if(AfxMessageBox("Are you sure?",MB_YESNO)==IDYES)
|
||||
{
|
||||
rs->Ex(q);
|
||||
//a deleted zone can't be selected
|
||||
m_strSelectedContract="";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
q="DATA INTEGRITY PROTECTION:\r\nYou cannot delete this contract because\r\nthe following clients are set to use it:\r\n";
|
||||
|
||||
//fill combo box with available zones
|
||||
rs->MoveFirst();
|
||||
rs->FetchField("company",&strData);
|
||||
q=q+strData+"\r\n";
|
||||
|
||||
|
||||
while(rs->MoveForward())
|
||||
{
|
||||
rs->FetchField("company",&strData);
|
||||
q=q+strData+"\r\n";
|
||||
}
|
||||
AfxMessageBox(q);
|
||||
}
|
||||
FillContractsList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//*******************************************************************
|
||||
void CContractsDlg::OnContractAdd()
|
||||
{
|
||||
CString q,name,info;
|
||||
|
||||
if(m_bAddMode)
|
||||
{
|
||||
m_bAddMode=false;//saving:
|
||||
m_cbContracts.ShowWindow(TRUE);
|
||||
m_lblContractList.ShowWindow(TRUE);
|
||||
m_btnContractAdd.SetWindowText("Add");
|
||||
m_btnContractDelete.ShowWindow(TRUE);
|
||||
m_edContractTerms.GetWindowText(info);
|
||||
m_edContractName.GetWindowText(name);
|
||||
if(name.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("You must enter a contract name");
|
||||
}
|
||||
else
|
||||
{
|
||||
q.Format("INSERT INTO contracts ( name, terms ) SELECT \"%s\", \"%s\";",name,info);
|
||||
rs->Ex(q);
|
||||
rs->Close();
|
||||
//rs->AddNewRecord();
|
||||
//rs->UpdateField("name",&name);
|
||||
//rs->UpdateField("zoneinfo",&info);
|
||||
|
||||
|
||||
}
|
||||
|
||||
FillContractsList();
|
||||
|
||||
|
||||
}
|
||||
else//Go into add mode
|
||||
{
|
||||
EnableFields(true);
|
||||
m_cbContracts.ShowWindow(FALSE);
|
||||
m_lblContractList.ShowWindow(FALSE);
|
||||
m_btnContractAdd.SetWindowText("SAVE");
|
||||
m_btnContractDelete.ShowWindow(FALSE);
|
||||
m_edContractTerms.SetWindowText("");
|
||||
m_edContractName.SetWindowText("");
|
||||
m_edContractName.SetFocus();
|
||||
m_bAddMode=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//************************************************8
|
||||
void CContractsDlg::OnCloseupContractCombo()
|
||||
{
|
||||
//user has made a selection, update the visible list
|
||||
CString q;
|
||||
CString strData;
|
||||
q.Format("SELECT contracts.* FROM contracts WHERE (((contracts.id)=%s));",m_cbContracts.GetCurrentRowID());
|
||||
rs->Query(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
rs->FetchField("name",&strData);
|
||||
m_edContractName.SetWindowText(strData);
|
||||
rs->FetchField("terms",&strData);
|
||||
m_edContractTerms.SetWindowText(strData);
|
||||
|
||||
|
||||
}
|
||||
//save current selection so that updates and changes
|
||||
//will still show what was last selected
|
||||
m_strSelectedContract=m_cbContracts.GetCurrentRowID();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//******************************************************
|
||||
BOOL CContractsDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
m_edContractName.SetLimitText(25);
|
||||
|
||||
FillContractsList();
|
||||
m_bAddMode=false;
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
void CContractsDlg::EnableFields(bool bEnable)
|
||||
{
|
||||
BOOL enable= bEnable ? TRUE : FALSE;
|
||||
m_btnContractDelete.EnableWindow(enable);
|
||||
m_cbContracts.EnableWindow(enable);
|
||||
m_edContractName.EnableWindow(enable);
|
||||
m_edContractTerms.EnableWindow(enable);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CContractsDlg::OnKillfocusContractname()
|
||||
{
|
||||
SaveField(&m_edContractName,"name",false);
|
||||
|
||||
}
|
||||
|
||||
void CContractsDlg::OnKillfocusContractterms()
|
||||
{
|
||||
SaveField(&m_edContractTerms,"terms",false);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
#if !defined(AFX_CONTRACTSDLG_H__1DCAA4C1_143C_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_CONTRACTSDLG_H__1DCAA4C1_143C_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// ContractsDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CContractsDlg dialog
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
#include "label.h"
|
||||
|
||||
class CContractsDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
void EnableFields(bool bEnable);
|
||||
~CContractsDlg();
|
||||
CContractsDlg(CWnd* pParent = NULL); // standard constructor
|
||||
CString m_strSelectedContract;
|
||||
bool SaveField(CEdit *edControl,CString fldname,bool AllowEmpty);
|
||||
bool m_bAddMode;
|
||||
bool FillContractsList();
|
||||
CSpApp* m_pApp;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CContractsDlg)
|
||||
enum { IDD = IDD_CONTRACTS };
|
||||
CStatic m_lblContractList;
|
||||
CButton m_btnContractDelete;
|
||||
CButton m_btnContractAdd;
|
||||
CEdit m_edContractTerms;
|
||||
CEdit m_edContractName;
|
||||
CgzCombo m_cbContracts;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CContractsDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
GZRset* rs;
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CContractsDlg)
|
||||
afx_msg void OnContractDelete();
|
||||
afx_msg void OnContractAdd();
|
||||
afx_msg void OnCloseupContractCombo();
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnKillfocusContractname();
|
||||
afx_msg void OnKillfocusContractterms();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CONTRACTSDLG_H__1DCAA4C1_143C_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,435 @@
|
||||
#include "stdafx.h"
|
||||
#include "Crc32Static.h"
|
||||
//#include <fstream.h>
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
// Static CRC table
|
||||
DWORD CCrc32Static::s_arrdwCrc32Table[256] =
|
||||
{
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
|
||||
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
|
||||
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
||||
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
|
||||
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
|
||||
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
||||
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
|
||||
0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
|
||||
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
|
||||
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
|
||||
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
|
||||
0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
||||
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
|
||||
0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
|
||||
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
|
||||
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
|
||||
|
||||
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
|
||||
0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
||||
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
|
||||
0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
|
||||
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
|
||||
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
|
||||
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
|
||||
0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
||||
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
|
||||
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
|
||||
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
|
||||
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
|
||||
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
|
||||
0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
||||
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
|
||||
0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
|
||||
|
||||
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
|
||||
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
|
||||
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
|
||||
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
||||
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
|
||||
0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
|
||||
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
|
||||
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
||||
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
|
||||
0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
||||
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
|
||||
0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
|
||||
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
|
||||
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
|
||||
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
|
||||
0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
||||
|
||||
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
|
||||
0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
|
||||
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
|
||||
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
|
||||
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
|
||||
0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
||||
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
|
||||
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
|
||||
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
|
||||
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
|
||||
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
|
||||
0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
|
||||
0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
|
||||
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
||||
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D,
|
||||
};
|
||||
|
||||
//***********************************************
|
||||
CCrc32Static::CCrc32Static()
|
||||
{
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
CCrc32Static::~CCrc32Static()
|
||||
{
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
inline void CCrc32Static::CalcCrc32(const BYTE byte, DWORD &dwCrc32)
|
||||
{
|
||||
dwCrc32 = ((dwCrc32) >> 8) ^ s_arrdwCrc32Table[(byte) ^ ((dwCrc32) & 0x000000FF)];
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
bool CCrc32Static::GetFileSizeQW(const HANDLE hFile, QWORD &qwSize)
|
||||
{
|
||||
_ASSERTE(hFile != INVALID_HANDLE_VALUE);
|
||||
|
||||
bool bSuccess = true;
|
||||
|
||||
try
|
||||
{
|
||||
DWORD dwLo = 0, dwHi = 0;
|
||||
dwLo = GetFileSize(hFile, &dwHi);
|
||||
|
||||
if(dwLo == INVALID_FILE_SIZE && GetLastError() != NO_ERROR)
|
||||
{
|
||||
bSuccess = false;
|
||||
qwSize = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
qwSize = MAKEQWORD(dwHi, dwLo);
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
bSuccess = false;
|
||||
}
|
||||
|
||||
return bSuccess;
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
DWORD CCrc32Static::StringCrc32(LPCTSTR szString, DWORD &dwCrc32)
|
||||
{
|
||||
_ASSERTE(szString);
|
||||
|
||||
DWORD dwErrorCode = NO_ERROR;
|
||||
|
||||
dwCrc32 = 0xFFFFFFFF;
|
||||
|
||||
try
|
||||
{
|
||||
while(*szString != _T('\0'))
|
||||
{
|
||||
CalcCrc32((BYTE)*szString, dwCrc32);
|
||||
szString++;
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
// An unknown exception happened
|
||||
dwErrorCode = ERROR_CRC;
|
||||
}
|
||||
|
||||
dwCrc32 = ~dwCrc32;
|
||||
|
||||
return dwErrorCode;
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
//DWORD CCrc32Static::FileCrc32Streams(LPCTSTR szFilename, DWORD &dwCrc32)
|
||||
//{
|
||||
//#if UNICODE || _UNICODE
|
||||
// return ERROR_NOT_SUPPORTED;
|
||||
//#else
|
||||
// _ASSERTE(szFilename);
|
||||
// _ASSERTE(lstrlen(szFilename));
|
||||
//
|
||||
// DWORD dwErrorCode = NO_ERROR;
|
||||
// ifstream file;
|
||||
//
|
||||
// dwCrc32 = 0xFFFFFFFF;
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// // Open the file
|
||||
// file.open(szFilename, ios::in | ios::nocreate | ios::binary, filebuf::sh_read);
|
||||
//
|
||||
// if(file.is_open())
|
||||
// {
|
||||
// char buffer[MAX_BUFFER_SIZE];
|
||||
// int nLoop, nCount;
|
||||
// nCount = file.read(buffer, sizeof(buffer)).gcount();
|
||||
// while(nCount)
|
||||
// {
|
||||
// for(nLoop = 0; nLoop < nCount; nLoop++)
|
||||
// CalcCrc32(buffer[nLoop], dwCrc32);
|
||||
// nCount = file.read(buffer, sizeof(buffer)).gcount();
|
||||
// }
|
||||
//
|
||||
// file.close();
|
||||
// }
|
||||
// }
|
||||
// catch(...)
|
||||
// {
|
||||
// // An unknown exception happened
|
||||
// dwErrorCode = ERROR_CRC;
|
||||
// }
|
||||
//
|
||||
// if(file.is_open()) file.close();
|
||||
//
|
||||
// dwCrc32 = ~dwCrc32;
|
||||
//
|
||||
// return dwErrorCode;
|
||||
//#endif
|
||||
//}
|
||||
|
||||
//***********************************************
|
||||
DWORD CCrc32Static::FileCrc32Win32(LPCTSTR szFilename, DWORD &dwCrc32)
|
||||
{
|
||||
_ASSERTE(szFilename);
|
||||
_ASSERTE(lstrlen(szFilename));
|
||||
|
||||
DWORD dwErrorCode = NO_ERROR;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
dwCrc32 = 0xFFFFFFFF;
|
||||
|
||||
try
|
||||
{
|
||||
// Open the file
|
||||
hFile = CreateFile(szFilename,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_SEQUENTIAL_SCAN,
|
||||
NULL);
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
dwErrorCode = GetLastError();
|
||||
else
|
||||
{
|
||||
BYTE buffer[MAX_BUFFER_SIZE];
|
||||
DWORD dwBytesRead, dwLoop;
|
||||
BOOL bSuccess = ReadFile(hFile, buffer, sizeof(buffer), &dwBytesRead, NULL);
|
||||
while(bSuccess && dwBytesRead)
|
||||
{
|
||||
for(dwLoop = 0; dwLoop < dwBytesRead; dwLoop++)
|
||||
CalcCrc32(buffer[dwLoop], dwCrc32);
|
||||
bSuccess = ReadFile(hFile, buffer, sizeof(buffer), &dwBytesRead, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
// An unknown exception happened
|
||||
dwErrorCode = ERROR_CRC;
|
||||
}
|
||||
|
||||
if(hFile != NULL) CloseHandle(hFile);
|
||||
|
||||
dwCrc32 = ~dwCrc32;
|
||||
|
||||
return dwErrorCode;
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
DWORD CCrc32Static::FileCrc32Filemap(LPCTSTR szFilename, DWORD &dwCrc32)
|
||||
{
|
||||
_ASSERTE(szFilename);
|
||||
_ASSERTE(lstrlen(szFilename));
|
||||
|
||||
DWORD dwErrorCode = NO_ERROR;
|
||||
HANDLE hFile = NULL, hFilemap = NULL;
|
||||
|
||||
dwCrc32 = 0xFFFFFFFF;
|
||||
|
||||
try
|
||||
{
|
||||
// Open the file
|
||||
hFile = CreateFile(szFilename,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_SEQUENTIAL_SCAN,
|
||||
NULL);
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
dwErrorCode = GetLastError();
|
||||
else
|
||||
{
|
||||
QWORD qwFileSize = 0, qwFileOffset = 0;
|
||||
DWORD dwByteCount, dwViewSize;
|
||||
DWORD dwBaseAddress;
|
||||
|
||||
// Get the file size
|
||||
if(!GetFileSizeQW(hFile, qwFileSize))
|
||||
dwErrorCode = ERROR_BAD_LENGTH;
|
||||
else if(qwFileSize != 0) // We cannot CRC zero byte files
|
||||
{
|
||||
// Create the file mapping
|
||||
hFilemap = CreateFileMapping(hFile,
|
||||
NULL,
|
||||
PAGE_READONLY,
|
||||
0,
|
||||
0,
|
||||
NULL);
|
||||
if(hFilemap == NULL)
|
||||
dwErrorCode = GetLastError();
|
||||
else
|
||||
{
|
||||
LPBYTE pByte;
|
||||
|
||||
// Loop while we map a section of the file and CRC it
|
||||
while(qwFileSize > 0)
|
||||
{
|
||||
if(qwFileSize < MAX_VIEW_SIZE)
|
||||
dwViewSize = LODWORD(qwFileSize);
|
||||
else
|
||||
dwViewSize = MAX_VIEW_SIZE;
|
||||
|
||||
dwBaseAddress = (DWORD)MapViewOfFile(hFilemap,
|
||||
FILE_MAP_READ,
|
||||
HIDWORD(qwFileOffset),
|
||||
LODWORD(qwFileOffset),
|
||||
dwViewSize);
|
||||
|
||||
dwByteCount = dwViewSize;
|
||||
pByte = (LPBYTE)dwBaseAddress;
|
||||
while(dwByteCount-- > 0)
|
||||
{
|
||||
CalcCrc32(*pByte, dwCrc32);
|
||||
pByte++;
|
||||
}
|
||||
|
||||
UnmapViewOfFile((LPVOID)dwBaseAddress);
|
||||
qwFileOffset += dwViewSize;
|
||||
qwFileSize -= dwViewSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
// An unknown exception happened
|
||||
dwErrorCode = ERROR_CRC;
|
||||
}
|
||||
|
||||
if(hFile != NULL) CloseHandle(hFile);
|
||||
if(hFilemap != NULL) CloseHandle(hFilemap);
|
||||
|
||||
dwCrc32 = ~dwCrc32;
|
||||
|
||||
return dwErrorCode;
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
DWORD CCrc32Static::FileCrc32Assembly(LPCTSTR szFilename, DWORD &dwCrc32)
|
||||
{
|
||||
_ASSERTE(szFilename);
|
||||
_ASSERTE(lstrlen(szFilename));
|
||||
|
||||
DWORD dwErrorCode = NO_ERROR;
|
||||
HANDLE hFile = NULL;
|
||||
|
||||
dwCrc32 = 0xFFFFFFFF;
|
||||
|
||||
try
|
||||
{
|
||||
// Open the file
|
||||
hFile = CreateFile(szFilename,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_SYSTEM | FILE_FLAG_SEQUENTIAL_SCAN,
|
||||
NULL);
|
||||
if(hFile == INVALID_HANDLE_VALUE)
|
||||
dwErrorCode = GetLastError();
|
||||
else
|
||||
{
|
||||
// There is a bug in the Microsoft compilers where inline assembly
|
||||
// code cannot access static member variables. This is a work around
|
||||
// for that bug. For more info see Knowledgebase article Q88092
|
||||
LPVOID ptrCrc32Table = &s_arrdwCrc32Table;
|
||||
|
||||
BYTE buffer[MAX_BUFFER_SIZE];
|
||||
DWORD dwBytesRead;
|
||||
BOOL bSuccess = ReadFile(hFile, buffer, sizeof(buffer), &dwBytesRead, NULL);
|
||||
while(bSuccess && dwBytesRead)
|
||||
{
|
||||
// Register use:
|
||||
// eax - CRC32 value
|
||||
// ebx - a lot of things
|
||||
// ecx - CRC32 value
|
||||
// edx - address of end of buffer
|
||||
// esi - address of start of buffer
|
||||
// edi - CRC32 table
|
||||
__asm
|
||||
{
|
||||
// Save the esi and edi registers
|
||||
push esi
|
||||
push edi
|
||||
|
||||
mov eax, dwCrc32 // Load the pointer to dwCrc32
|
||||
mov ecx, [eax] // Dereference the pointer to load dwCrc32
|
||||
|
||||
mov edi, ptrCrc32Table // Load the CRC32 table
|
||||
|
||||
lea esi, buffer // Load buffer
|
||||
mov ebx, dwBytesRead // Load dwBytesRead
|
||||
lea edx, [esi + ebx] // Calculate the end of the buffer
|
||||
|
||||
crc32loop:
|
||||
xor eax, eax // Clear the eax register
|
||||
mov bl, byte ptr [esi] // Load the current source byte
|
||||
|
||||
mov al, cl // Copy crc value into eax
|
||||
inc esi // Advance the source pointer
|
||||
|
||||
xor al, bl // Create the index into the CRC32 table
|
||||
shr ecx, 8
|
||||
|
||||
mov ebx, [edi + eax * 4] // Get the value out of the table
|
||||
xor ecx, ebx // xor with the current byte
|
||||
|
||||
cmp edx, esi // Have we reached the end of the buffer?
|
||||
jne crc32loop
|
||||
|
||||
// Restore the edi and esi registers
|
||||
pop edi
|
||||
pop esi
|
||||
|
||||
mov eax, dwCrc32 // Load the pointer to dwCrc32
|
||||
mov [eax], ecx // Write the result
|
||||
}
|
||||
bSuccess = ReadFile(hFile, buffer, sizeof(buffer), &dwBytesRead, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
// An unknown exception happened
|
||||
dwErrorCode = ERROR_CRC;
|
||||
}
|
||||
|
||||
if(hFile != NULL) CloseHandle(hFile);
|
||||
|
||||
dwCrc32 = ~dwCrc32;
|
||||
|
||||
return dwErrorCode;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef _CRC32STATIC_H_
|
||||
#define _CRC32STATIC_H_
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
class CCrc32Static
|
||||
{
|
||||
public:
|
||||
CCrc32Static();
|
||||
virtual ~CCrc32Static();
|
||||
|
||||
static DWORD StringCrc32(LPCTSTR szString, DWORD &dwCrc32);
|
||||
//static DWORD FileCrc32Streams(LPCTSTR szFilename, DWORD &dwCrc32);
|
||||
static DWORD FileCrc32Win32(LPCTSTR szFilename, DWORD &dwCrc32);
|
||||
static DWORD FileCrc32Filemap(LPCTSTR szFilename, DWORD &dwCrc32);
|
||||
static DWORD FileCrc32Assembly(LPCTSTR szFilename, DWORD &dwCrc32);
|
||||
|
||||
protected:
|
||||
static bool GetFileSizeQW(const HANDLE hFile, QWORD &qwSize);
|
||||
static inline void CalcCrc32(const BYTE byte, DWORD &dwCrc32);
|
||||
|
||||
static DWORD s_arrdwCrc32Table[256];
|
||||
};
|
||||
|
||||
#endif
|
||||
7325
archive/ayanova 1.9.4 CE final release db schema 171/sp/DBUtils.cpp
Normal file
7325
archive/ayanova 1.9.4 CE final release db schema 171/sp/DBUtils.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,143 @@
|
||||
#if !defined(AFX_DBUTILS_H__F544FA42_4065_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_DBUTILS_H__F544FA42_4065_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// DBUtils.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDBUtils form view
|
||||
|
||||
#ifndef __AFXEXT_H__
|
||||
#include <afxext.h>
|
||||
#endif
|
||||
|
||||
#include "spdoc.h"
|
||||
#include "gzrset.h"
|
||||
#include "gzk.h"
|
||||
|
||||
class CDBUtils : public CFormView
|
||||
{
|
||||
public:
|
||||
CDBUtils(); // protected constructor used by dynamic creation
|
||||
DECLARE_DYNCREATE(CDBUtils)
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs2;
|
||||
GZRset* rs3;
|
||||
GZRset* rs;
|
||||
|
||||
CProgressCtrl* ppg[11];
|
||||
bool Execute(CString strQuery);
|
||||
|
||||
// Form Data
|
||||
public:
|
||||
//{{AFX_DATA(CDBUtils)
|
||||
enum { IDD = IDD_DBUTILS_FORM };
|
||||
CStatic m_st11;
|
||||
CProgressCtrl m_pg11;
|
||||
CButton m_btnTest;
|
||||
CStatic m_st9;
|
||||
CStatic m_st8;
|
||||
CStatic m_st7;
|
||||
CStatic m_st6;
|
||||
CStatic m_st10;
|
||||
CProgressCtrl m_pg9;
|
||||
CProgressCtrl m_pg8;
|
||||
CProgressCtrl m_pg7;
|
||||
CProgressCtrl m_pg6;
|
||||
CProgressCtrl m_pg10;
|
||||
CButton m_btnDelAll;
|
||||
CButton m_btnQuickIndex;
|
||||
CButton m_btnIndexAll;
|
||||
CButton m_btnDefaults;
|
||||
CButton m_btnCompact;
|
||||
CButton m_btnCM3;
|
||||
CStatic m_lblWordCount;
|
||||
CStatic m_lblPartialInfo;
|
||||
CStatic m_lblFullInfo;
|
||||
CStatic m_st5;
|
||||
CStatic m_st4;
|
||||
CStatic m_st3;
|
||||
CStatic m_st2;
|
||||
CStatic m_st1;
|
||||
CProgressCtrl m_pg5;
|
||||
CProgressCtrl m_pg4;
|
||||
CProgressCtrl m_pg3;
|
||||
CProgressCtrl m_pg2;
|
||||
CProgressCtrl m_pg1;
|
||||
//}}AFX_DATA
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
void EvaluationDatesAdvance();
|
||||
void WelcomeToSC();
|
||||
bool m_bBootScanDone;
|
||||
void BootScan();
|
||||
void MakeIntoWorkorder(CString strPMItem);
|
||||
void UpdateDatabaseSchema();
|
||||
void EraseAll();
|
||||
void SetRights();
|
||||
CString m_strErrorLog;
|
||||
void LogError(CString strError);
|
||||
void zTrace(CString msg, bool bShow);
|
||||
void ShowMe(CString txt);
|
||||
long FindMaxChar();
|
||||
void ShowIndexInfo();
|
||||
bool SuckWords(int nTable);
|
||||
|
||||
BOOL PeekAndPump();
|
||||
void ShowProgressControls(bool bShow);
|
||||
void Index(bool bFullIndex);
|
||||
bool ExclusiveAccess();
|
||||
void DeActivate();
|
||||
void Activate();
|
||||
CSpDoc* GetDocument();
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CDBUtils)
|
||||
public:
|
||||
virtual void OnInitialUpdate();
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual ~CDBUtils();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CDBUtils)
|
||||
afx_msg void OnBtncompact();
|
||||
afx_msg void OnBtndefaults();
|
||||
afx_msg void OnBtnindexall();
|
||||
afx_msg void OnBtnquickindex();
|
||||
afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
|
||||
afx_msg void OnBtncm3();
|
||||
afx_msg void OnBtndeleteall();
|
||||
afx_msg void OnBtntest();
|
||||
afx_msg void OnBtnexport();
|
||||
afx_msg void OnBtnimport();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
// _ConnectionPtr pConnection;
|
||||
public:
|
||||
afx_msg BOOL OnHelpInfo(HELPINFO* pHelpInfo);
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_DBUTILS_H__F544FA42_4065_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,243 @@
|
||||
#if !defined(AFX_CDIBSECTIONLITE_H__35D9F3D4_B960_11D2_A981_2C4476000000__INCLUDED_)
|
||||
#define AFX_CDIBSECTIONLITE_H__35D9F3D4_B960_11D2_A981_2C4476000000__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
// DIBSectionLite.h : header file
|
||||
//
|
||||
|
||||
// Copyright © Dundas Software Ltd. 1999, All Rights Reserved
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Properties:
|
||||
// NO Abstract class (does not have any objects)
|
||||
// NO Derived from CWnd
|
||||
// NO Is a CWnd.
|
||||
// NO Two stage creation (constructor & Create())
|
||||
// NO Has a message map
|
||||
// NO Needs a resource (template)
|
||||
// YES Persistent objects (saveable on disk)
|
||||
// YES Uses exceptions
|
||||
|
||||
// //////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Desciption :
|
||||
|
||||
// CDIBSectionLite is DIBSection wrapper class for win32 and WinCE platforms.
|
||||
// This class provides a simple interface to DIBSections including loading,
|
||||
// saving and displaying DIBsections.
|
||||
//
|
||||
// Full palette support is provided for Win32 and CE 2.11 and above.
|
||||
|
||||
// Using CDIBSectionLite :
|
||||
|
||||
// This class is very simple to use. The bitmap can be set using either SetBitmap()
|
||||
// (which accepts either a Device dependant or device independant bitmap, or a
|
||||
// resource ID) or by using Load(), which allows an image to be loaded from disk.
|
||||
// To display the bitmap simply use Draw or Stretch.
|
||||
//
|
||||
// eg.
|
||||
//
|
||||
// CDIBsection dibsection;
|
||||
// dibsection.Load(_T("image.bmp"));
|
||||
// dibsection.Draw(pDC, CPoint(0,0)); // pDC is of type CDC*
|
||||
//
|
||||
// CDIBsection dibsection;
|
||||
// dibsection.SetBitmap(IDB_BITMAP);
|
||||
// dibsection.Draw(pDC, CPoint(0,0)); // pDC is of type CDC*
|
||||
//
|
||||
// The CDIBsection API includes many methods to extract information about the
|
||||
// image, as well as palette options for getting and setting the current palette.
|
||||
//
|
||||
// Author: Chris Maunder (cmaunder@dundas.com)
|
||||
// Date : 12 April 1999
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// defines
|
||||
|
||||
//#define DIBSECTION_NO_DITHER // Disallow dithering via DrawDib functions
|
||||
#define DIBSECTION_NO_MEMDC_REUSE // Disallow the reuse of memory DC's
|
||||
//#define DIBSECTION_NO_PALETTE // Remove palette support
|
||||
/*// Only provide palette support for non-CE platforms, or for CE 2.11 and above
|
||||
#ifdef _WIN32_WCE
|
||||
#define DIBSECTION_NO_DITHER // DrawDib not supported on CE
|
||||
#if (_WIN32_WCE < 211)
|
||||
#define DIBSECTION_NO_PALETTE // No palette support on early CE devices
|
||||
#endif
|
||||
#endif
|
||||
*/
|
||||
// Include headers and lib for DrawDib routines
|
||||
#ifndef DIBSECTION_NO_DITHER
|
||||
#include <vfw.h>
|
||||
#pragma comment(lib, "vfw32")
|
||||
#endif
|
||||
|
||||
|
||||
#define DS_BITMAP_FILEMARKER ((WORD) ('M' << 8) | 'B') // is always "BM" = 0x4D42
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// BITMAPINFO wrapper
|
||||
|
||||
struct DIBINFO : public BITMAPINFO
|
||||
{
|
||||
RGBQUAD arColors[255]; // Color table info - adds an extra 255 entries to palette
|
||||
|
||||
operator LPBITMAPINFO() { return (LPBITMAPINFO) this; }
|
||||
operator LPBITMAPINFOHEADER() { return &bmiHeader; }
|
||||
RGBQUAD* ColorTable() { return bmiColors; }
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// LOGPALETTE wrapper
|
||||
|
||||
#ifndef DIBSECTION_NO_PALETTE
|
||||
struct PALETTEINFO : public LOGPALETTE
|
||||
{
|
||||
PALETTEENTRY arPalEntries[255]; // Palette entries
|
||||
|
||||
PALETTEINFO()
|
||||
{
|
||||
palVersion = (WORD) 0x300;
|
||||
palNumEntries = 0;
|
||||
::memset(palPalEntry, 0, 256*sizeof(PALETTEENTRY));
|
||||
}
|
||||
|
||||
operator LPLOGPALETTE() { return (LPLOGPALETTE) this; }
|
||||
operator LPPALETTEENTRY() { return (LPPALETTEENTRY) (palPalEntry); }
|
||||
};
|
||||
#endif // DIBSECTION_NO_PALETTE
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDIBSectionLite object
|
||||
|
||||
class CDIBSectionLite : public CObject
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CDIBSectionLite();
|
||||
virtual ~CDIBSectionLite();
|
||||
void DeleteObject();
|
||||
|
||||
// static helpers
|
||||
public:
|
||||
static int BytesPerLine(int nWidth, int nBitsPerPixel);
|
||||
static int NumColorEntries(int nBitsPerPixel, int nCompression);
|
||||
|
||||
static RGBQUAD ms_StdColors[];
|
||||
#ifndef DIBSECTION_NO_PALETTE
|
||||
static BOOL UsesPalette(CDC* pDC) { return (pDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE); }
|
||||
static BOOL CreateHalftonePalette(CPalette& palette, int nNumColors);
|
||||
#endif // DIBSECTION_NO_PALETTE
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
HBITMAP GetSafeHandle() const { return (this)? m_hBitmap : NULL; }
|
||||
operator HBITMAP() const { return GetSafeHandle(); }
|
||||
CSize GetSize() const { return CSize(GetWidth(), GetHeight()); }
|
||||
int GetHeight() const { return m_DIBinfo.bmiHeader.biHeight; }
|
||||
int GetWidth() const { return m_DIBinfo.bmiHeader.biWidth; }
|
||||
int GetPlanes() const { return m_DIBinfo.bmiHeader.biPlanes; }
|
||||
int GetBitCount() const { return m_DIBinfo.bmiHeader.biBitCount; }
|
||||
LPVOID GetDIBits() { return m_ppvBits; }
|
||||
LPBITMAPINFO GetBitmapInfo() { return (BITMAPINFO*) m_DIBinfo; }
|
||||
DWORD GetImageSize() const { return m_DIBinfo.bmiHeader.biSizeImage; }
|
||||
LPBITMAPINFOHEADER GetBitmapInfoHeader() { return (BITMAPINFOHEADER*) m_DIBinfo; }
|
||||
|
||||
// Operations (Palette)
|
||||
public:
|
||||
LPRGBQUAD GetColorTable() { return m_DIBinfo.ColorTable(); }
|
||||
BOOL SetColorTable(UINT nNumColors, RGBQUAD *pColors);
|
||||
int GetColorTableSize() { return m_iColorTableSize; }
|
||||
#ifndef DIBSECTION_NO_PALETTE
|
||||
CPalette *GetPalette() { return &m_Palette; }
|
||||
BOOL SetPalette(CPalette* pPalette);
|
||||
BOOL SetLogPalette(LOGPALETTE* pLogPalette);
|
||||
#endif // DIBSECTION_NO_PALETTE
|
||||
|
||||
// Operations (Setting the bitmap)
|
||||
public:
|
||||
BOOL SetBitmap(UINT nIDResource);
|
||||
BOOL SetBitmap(LPCTSTR lpszResourceName);
|
||||
BOOL SetBitmap(HBITMAP hBitmap
|
||||
#ifndef DIBSECTION_NO_PALETTE
|
||||
, CPalette* pPalette = NULL
|
||||
#endif
|
||||
);
|
||||
BOOL SetBitmap(LPBITMAPINFO lpBitmapInfo, LPVOID lpBits);
|
||||
|
||||
BOOL Load(LPCTSTR lpszFileName);
|
||||
BOOL Save(LPCTSTR lpszFileName);
|
||||
BOOL Copy(CDIBSectionLite& Bitmap);
|
||||
|
||||
// Operations (Display)
|
||||
public:
|
||||
BOOL Draw(CDC* pDC, CPoint ptDest, BOOL bForceBackground = FALSE);
|
||||
BOOL Stretch(CDC* pDC, CPoint ptDest, CSize size, BOOL bForceBackground = FALSE);
|
||||
|
||||
#ifndef DIBSECTION_NO_DITHER
|
||||
BOOL SetDither(BOOL bDither);
|
||||
BOOL GetDither();
|
||||
#endif // DIBSECTION_NO_DITHER
|
||||
|
||||
CDC* GetMemoryDC(CDC* pDC = NULL, BOOL bSelectPalette = TRUE);
|
||||
BOOL ReleaseMemoryDC(BOOL bForceRelease = FALSE);
|
||||
|
||||
// Overrideables
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
void _ShowLastError();
|
||||
#ifndef DIBSECTION_NO_PALETTE
|
||||
BOOL CreatePalette();
|
||||
BOOL FillDIBColorTable(UINT nNumColors, RGBQUAD *pRGB);
|
||||
#endif // DIBSECTION_NO_PALETTE
|
||||
UINT GetColorTableEntries(HDC hdc, HBITMAP hBitmap);
|
||||
#ifndef DIBSECTION_NO_DITHER
|
||||
HDRAWDIB GetDrawDibContext();
|
||||
#endif // DIBSECTION_NO_DITHER
|
||||
|
||||
protected:
|
||||
HBITMAP m_hBitmap; // Handle to DIBSECTION
|
||||
DIBINFO m_DIBinfo; // Bitmap header & color table info
|
||||
VOID *m_ppvBits; // Pointer to bitmap bits
|
||||
UINT m_iColorDataType; // color data type (palette or RGB values)
|
||||
UINT m_iColorTableSize; // Size of color table
|
||||
|
||||
CDC m_MemDC; // Memory DC for drawing on bitmap
|
||||
|
||||
#ifndef DIBSECTION_NO_DITHER
|
||||
BOOL m_bDither; // Use DrawDib routines for dithering?
|
||||
HDRAWDIB m_hDrawDib; // handle to a DrawDib DC
|
||||
#endif
|
||||
|
||||
#ifndef DIBSECTION_NO_MEMDC_REUSE
|
||||
BOOL m_bReuseMemDC; // Reeuse the memory DC? (Quicker, but not fully tested)
|
||||
#endif
|
||||
|
||||
#ifndef DIBSECTION_NO_PALETTE
|
||||
CPalette m_Palette; // Color palette
|
||||
CPalette *m_pOldPalette;
|
||||
#endif // DIBSECTION_NO_PALETTE
|
||||
|
||||
private:
|
||||
HBITMAP m_hOldBitmap; // Storage for previous bitmap in Memory DC
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_CDIBSECTIONLITE_H__35D9F3D4_B960_11D2_A981_2C4476000000__INCLUDED_)
|
||||
@@ -0,0 +1,245 @@
|
||||
// DefaultsDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "DefaultsDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDefaultsDlg dialog
|
||||
|
||||
|
||||
CDefaultsDlg::CDefaultsDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDefaultsDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CDefaultsDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
//Initialize recordset pointer
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CDefaultsDlg");
|
||||
}
|
||||
|
||||
|
||||
void CDefaultsDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CDefaultsDlg)
|
||||
DDX_Control(pDX, IDC_EDSCHEDWINDOW, m_edSchedWindow);
|
||||
DDX_Control(pDX, IDC_EDAUTOREFRESHSECS, m_edAutoRefresh);
|
||||
DDX_Control(pDX, IDC_CBREOPENSTATUS, m_cbStatusReopen);
|
||||
DDX_Control(pDX, IDC_CBNEWSTATUS, m_cbStatusNew);
|
||||
DDX_Control(pDX, IDC_CBCLOSEDSTATUS, m_cbStatusClosed);
|
||||
DDX_Control(pDX, IDC_CKESTIMATES, m_ckEstimates);
|
||||
DDX_Control(pDX, IDC_EDPROVSTATE, m_edProvState);
|
||||
DDX_Control(pDX, IDC_EDPOSTAL, m_edPostal);
|
||||
DDX_Control(pDX, IDC_EDCOUNTRY, m_edCountry);
|
||||
DDX_Control(pDX, IDC_EDCITY, m_edCity);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDefaultsDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CDefaultsDlg)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
ON_BN_CLICKED(IDC_CKESTIMATES, OnCkestimates)
|
||||
ON_EN_KILLFOCUS(IDC_EDAUTOREFRESHSECS, OnKillfocusEdautorefreshsecs)
|
||||
ON_EN_KILLFOCUS(IDC_EDSCHEDWINDOW, OnKillfocusEdschedwindow)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDefaultsDlg message handlers
|
||||
|
||||
BOOL CDefaultsDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
CString strData;
|
||||
bool bEstimates;
|
||||
|
||||
//rs->SetConnect(m_pApp->strConnectString);
|
||||
|
||||
|
||||
CString q,strIndex;
|
||||
long lData;
|
||||
//FILL STATUS LIST
|
||||
m_cbStatusClosed.Clear();
|
||||
m_cbStatusClosed.AddRow(" <No default status>","0");
|
||||
|
||||
m_cbStatusNew.Clear();
|
||||
m_cbStatusNew.AddRow(" <No default status>","0");
|
||||
|
||||
m_cbStatusReopen.Clear();
|
||||
m_cbStatusReopen.AddRow(" <No default status>","0");
|
||||
|
||||
|
||||
rs->QueryReadOnly("SELECT probstat.id, probstat.notes FROM probstat ORDER BY probstat.id;");
|
||||
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
rs->FetchField("notes",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbStatusClosed.AddRow(strData,strIndex);
|
||||
m_cbStatusNew.AddRow(strData,strIndex);
|
||||
m_cbStatusReopen.AddRow(strData,strIndex);
|
||||
}while(rs->MoveForward());
|
||||
|
||||
}
|
||||
rs->Query("SELECT * FROM defaults;");
|
||||
|
||||
rs->FetchField("city",&strData);
|
||||
m_edCity.SetWindowText(strData);
|
||||
|
||||
rs->FetchField("stateprov",&strData);
|
||||
m_edProvState.SetWindowText(strData);
|
||||
|
||||
rs->FetchField("postal",&strData);
|
||||
m_edPostal.SetWindowText(strData);
|
||||
|
||||
rs->FetchField("country",&strData);
|
||||
m_edCountry.SetWindowText(strData);
|
||||
|
||||
rs->FetchField("woestimate",&bEstimates);
|
||||
m_ckEstimates.SetCheck(bEstimates ? TRUE : FALSE);
|
||||
|
||||
rs->FetchField("wonewstat",&lData);
|
||||
m_cbStatusNew.Select(lData);
|
||||
|
||||
rs->FetchField("woclosestat",&lData);
|
||||
m_cbStatusClosed.Select(lData);
|
||||
|
||||
rs->FetchField("woreopenstat",&lData);
|
||||
m_cbStatusReopen.Select(lData);
|
||||
|
||||
rs->FetchField("schedrfrshsecs",&lData);//m_pApp->m_nSchedRefreshSecs);
|
||||
strData.Format("%u",lData);
|
||||
m_edAutoRefresh.SetWindowText(strData);
|
||||
|
||||
rs->FetchField("schedwindow",&lData);//m_pApp->m_nSchedRefreshSecs);
|
||||
strData.Format("%u",lData);
|
||||
m_edSchedWindow.SetWindowText(strData);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
CDefaultsDlg::~CDefaultsDlg()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
void CDefaultsDlg::OnBtndone()
|
||||
{
|
||||
CString strData;
|
||||
bool bEstimates;
|
||||
long lData;
|
||||
|
||||
m_edCity.GetWindowText(strData);
|
||||
rs->UpdateField("city",&strData);
|
||||
|
||||
m_edProvState.GetWindowText(strData);
|
||||
rs->UpdateField("stateprov",&strData);
|
||||
|
||||
m_edPostal.GetWindowText(strData);
|
||||
rs->UpdateField("postal",&strData);
|
||||
|
||||
m_edCountry.GetWindowText(strData);
|
||||
rs->UpdateField("country",&strData);
|
||||
|
||||
bEstimates=m_ckEstimates.GetCheck() ? true : false;
|
||||
rs->UpdateField("woestimate",&bEstimates);
|
||||
|
||||
lData=atol(m_cbStatusNew.GetCurrentRowID());
|
||||
rs->UpdateField("wonewstat",&lData);
|
||||
m_pApp->m_lDefNewWOStatus=lData;
|
||||
|
||||
lData=atol(m_cbStatusClosed.GetCurrentRowID());
|
||||
rs->UpdateField("woclosestat",&lData);
|
||||
m_pApp->m_lDefClosedWOStatus=lData;
|
||||
|
||||
|
||||
lData=atol(m_cbStatusReopen.GetCurrentRowID());
|
||||
rs->UpdateField("woreopenstat",&lData);
|
||||
m_pApp->m_lDefReOpenWOStatus=lData;
|
||||
|
||||
|
||||
m_edAutoRefresh.GetWindowText(strData);
|
||||
lData=atol(strData);
|
||||
rs->UpdateField("schedrfrshsecs",&lData);
|
||||
m_pApp->m_lSchedRefreshSecs=lData;
|
||||
|
||||
m_edSchedWindow.GetWindowText(strData);
|
||||
lData=atol(strData);
|
||||
rs->UpdateField("schedwindow",&lData);
|
||||
m_pApp->m_lSchedWindowDays=lData;
|
||||
|
||||
|
||||
|
||||
|
||||
rs->SaveRecord();
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CDefaultsDlg::OnCkestimates()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
|
||||
}
|
||||
|
||||
void CDefaultsDlg::OnKillfocusEdautorefreshsecs()
|
||||
{
|
||||
long x;
|
||||
CString str;
|
||||
m_edAutoRefresh.GetWindowText(str);
|
||||
x=atol(str);
|
||||
if(x!=0)
|
||||
{
|
||||
if(x<60)
|
||||
{
|
||||
AfxMessageBox("Must be at least one minute (60 seconds)");
|
||||
m_edAutoRefresh.SetWindowText("60");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CDefaultsDlg::OnKillfocusEdschedwindow()
|
||||
{
|
||||
long x;
|
||||
CString str;
|
||||
m_edSchedWindow.GetWindowText(str);
|
||||
x=atol(str);
|
||||
if(x<4)
|
||||
{
|
||||
AfxMessageBox("Must be at least 4 days");
|
||||
m_edAutoRefresh.SetWindowText("30");
|
||||
}
|
||||
|
||||
if(x>60)
|
||||
{
|
||||
AfxMessageBox("Caution: too high a setting may result in slow updates on schedule screen");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
#if !defined(AFX_DEFAULTSDLG_H__3A9EE8C1_43C8_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_DEFAULTSDLG_H__3A9EE8C1_43C8_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// DefaultsDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDefaultsDlg dialog
|
||||
#include "gzrset.h"
|
||||
#include "gzcombo.h"
|
||||
class CDefaultsDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
~CDefaultsDlg();
|
||||
CDefaultsDlg(CWnd* pParent = NULL); // standard constructor
|
||||
GZRset* rs;
|
||||
CSpApp* m_pApp;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CDefaultsDlg)
|
||||
enum { IDD = IDD_DEFAULTS };
|
||||
CEdit m_edSchedWindow;
|
||||
CEdit m_edAutoRefresh;
|
||||
CgzCombo m_cbStatusReopen;
|
||||
CgzCombo m_cbStatusNew;
|
||||
CgzCombo m_cbStatusClosed;
|
||||
CButton m_ckEstimates;
|
||||
CEdit m_edProvState;
|
||||
CEdit m_edPostal;
|
||||
CEdit m_edCountry;
|
||||
CEdit m_edCity;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CDefaultsDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CDefaultsDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBtndone();
|
||||
afx_msg void OnCkestimates();
|
||||
afx_msg void OnKillfocusEdautorefreshsecs();
|
||||
afx_msg void OnKillfocusEdschedwindow();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_DEFAULTSDLG_H__3A9EE8C1_43C8_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,154 @@
|
||||
#if !defined(AFX_DISPATCHFIELDSDLG_H__BDBF57C1_37BC_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_DISPATCHFIELDSDLG_H__BDBF57C1_37BC_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// DispatchFieldsDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDispatchFieldsDlg dialog
|
||||
#include "label.h"
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
#include "DispatchView.H"
|
||||
#include "afxwin.h"
|
||||
class CDispatchFieldsDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
~CDispatchFieldsDlg();
|
||||
void RefreshDisplay();
|
||||
void FillLists();
|
||||
|
||||
void BuildSQL();
|
||||
void SetReturnVariable(CDispatchView * dvReturn);
|
||||
|
||||
CDispatchFieldsDlg(CWnd* pParent = NULL); // standard constructor
|
||||
CDispatchView* pdv;
|
||||
CDispatchView* passeddv;
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CDispatchFieldsDlg)
|
||||
enum { IDD = IDD_DISPATCHFIELDS };
|
||||
CButton m_ckProject;
|
||||
CgzCombo m_cbProjects;
|
||||
CgzCombo m_cbCategories;
|
||||
CButton m_ckCategory;
|
||||
CButton m_ckSchedDate_TOMORROW;
|
||||
CButton m_ckCustRef;
|
||||
CButton m_ckStatus;
|
||||
CButton m_ckOurRef;
|
||||
CButton m_ckDate;
|
||||
CButton m_ckInvoice;
|
||||
CDateTimeCtrl m_dtEntryDate;
|
||||
CComboBox m_cbEntry;
|
||||
CLabel m_lbl16;
|
||||
CgzCombo m_cbReports;
|
||||
CLabel m_lbl15;
|
||||
CButton m_ckPreview;
|
||||
CButton m_ckSchedDate_BETWEEN;
|
||||
CEdit m_edSQL;
|
||||
CEdit m_edLastActivity_DAYS;
|
||||
CDateTimeCtrl m_dtSchedDate_START;
|
||||
CDateTimeCtrl m_dtSchedDate_END;
|
||||
CButton m_ckSchedDate_TODAY;
|
||||
CButton m_ckSchedDate_THISWEEK;
|
||||
CButton m_ckSchedDate_THISMONTH;
|
||||
CButton m_ckSchedDate_ANY;
|
||||
CButton m_ckOnsite_ONSITE;
|
||||
CButton m_ckOnsite_INHOUSE;
|
||||
CButton m_ckOnsite_BOTH;
|
||||
CButton m_ckLastActivity_ANY;
|
||||
CButton m_ckClosedOpen_OPEN;
|
||||
CButton m_ckClosedOpen_CLOSED;
|
||||
CButton m_ckClosedOpen_BOTH;
|
||||
CgzCombo m_cbZone;
|
||||
CgzCombo m_cbTech;
|
||||
CgzCombo m_cbClient;
|
||||
CLabel m_lbl14;
|
||||
CLabel m_lbl9;
|
||||
CLabel m_lbl8;
|
||||
CLabel m_lbl7;
|
||||
CLabel m_lbl6;
|
||||
CLabel m_lbl5;
|
||||
CLabel m_lbl4;
|
||||
CLabel m_lbl3;
|
||||
CLabel m_lbl2;
|
||||
CLabel m_lbl13;
|
||||
CLabel m_lbl12;
|
||||
CLabel m_lbl11;
|
||||
CLabel m_lbl10;
|
||||
CLabel m_lbl1;
|
||||
CButton m_ckZone;
|
||||
CButton m_ckWO;
|
||||
CButton m_ckSchedTech;
|
||||
CButton m_ckSchedEndDate;
|
||||
CButton m_ckSchedDate;
|
||||
CButton m_ckPostal;
|
||||
CButton m_ckOnsite;
|
||||
CButton m_ckLastActivity;
|
||||
CButton m_ckEntryDate;
|
||||
CButton m_ckClosedDate;
|
||||
CButton m_ckClosed;
|
||||
CButton m_ckClient;
|
||||
CButton m_ckCity;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CDispatchFieldsDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CDispatchFieldsDlg)
|
||||
afx_msg void OnBtndone();
|
||||
virtual void OnOK();
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBtncancel();
|
||||
afx_msg void OnButton1();
|
||||
afx_msg void OnCkclosedopenBoth();
|
||||
afx_msg void OnCkclosedopenOpenonly();
|
||||
afx_msg void OnCkclosedopenClosedonly();
|
||||
afx_msg void OnCkonsiteBoth();
|
||||
afx_msg void OnCkonsiteInhouseonly();
|
||||
afx_msg void OnCkonsiteOnsiteonly();
|
||||
afx_msg void OnCkscheddateAny();
|
||||
afx_msg void OnCkscheddateBetween();
|
||||
afx_msg void OnCkscheddateThismonth();
|
||||
afx_msg void OnCkscheddateThisweek();
|
||||
afx_msg void OnCkscheddateToday();
|
||||
afx_msg void OnCklastactivityAny();
|
||||
afx_msg void OnCloseupCbentry();
|
||||
afx_msg void OnCkinvoice();
|
||||
afx_msg void OnCkdate();
|
||||
afx_msg void OnDatetimechangeDtcheddateBetweenStart(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnDatetimechangeDtcheddateBetweenEnd(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnCkourref();
|
||||
afx_msg void OnCkstatus();
|
||||
afx_msg void OnCkscheddateTomorrow();
|
||||
afx_msg void OnCloseupCbcategories();
|
||||
afx_msg void OnCkcategory();
|
||||
afx_msg void OnCkproject();
|
||||
afx_msg void OnCloseupCbprojects();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
CgzCombo m_cbStatus;
|
||||
CStatic m_lblCreatedDays;
|
||||
CEdit m_edCreatedDays;
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_DISPATCHFIELDSDLG_H__BDBF57C1_37BC_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,96 @@
|
||||
// DispatchView.cpp: implementation of the CDispatchView class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
//#include "sp.h"
|
||||
#include "DispatchView.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CDispatchView::CDispatchView()
|
||||
{
|
||||
IsModified=false;
|
||||
|
||||
}
|
||||
|
||||
CDispatchView::~CDispatchView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CDispatchView::operator==(CDispatchView other)
|
||||
{
|
||||
|
||||
if(other.city!=city)
|
||||
return false;
|
||||
if(other.client!= client)
|
||||
return false;
|
||||
if(other.virtualreport!= virtualreport)
|
||||
return false;
|
||||
if(other.zone!= zone)
|
||||
return false;
|
||||
if(other.postal!= postal)
|
||||
return false;
|
||||
if(other.workorder!= workorder)
|
||||
return false;
|
||||
if(other.closed!= closed)
|
||||
return false;
|
||||
if(other.closeddate!= closeddate)
|
||||
return false;
|
||||
if(other.onsite!= onsite)
|
||||
return false;
|
||||
if(other.schedstart!= schedstart)
|
||||
return false;
|
||||
if(other.scheddatestart!= scheddatestart)
|
||||
return false;
|
||||
if(other.scheddateend!= scheddateend)
|
||||
return false;
|
||||
if(other.schedenddate!= schedenddate)
|
||||
return false;
|
||||
if(other.schedtech!= schedtech)
|
||||
return false;
|
||||
if(other.wocreateddate!= wocreateddate)
|
||||
return false;
|
||||
if(other.lastactivity!= lastactivity)
|
||||
return false;
|
||||
if(other.preview != preview)
|
||||
return false;
|
||||
if(other.woentrydate != woentrydate)
|
||||
return false;
|
||||
if(other.woentrydatetype != woentrydatetype)
|
||||
return false;
|
||||
if(other.invoice != invoice)
|
||||
return false;
|
||||
if(other.date != date)
|
||||
return false;
|
||||
if(other.ourrefnumber != ourrefnumber)
|
||||
return false;
|
||||
if(other.status != status)
|
||||
return false;
|
||||
if(other.custrefnumber != custrefnumber)
|
||||
return false;
|
||||
|
||||
if(other.category != category)
|
||||
return false;
|
||||
|
||||
if(other.project != project)
|
||||
return false;
|
||||
|
||||
if(other.lCreatedDays != lCreatedDays)
|
||||
return false;
|
||||
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
// DispatchView.h: interface for the CDispatchView class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_DISPATCHVIEW_H__8543FA81_389E_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_DISPATCHVIEW_H__8543FA81_389E_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
//for check/combo combinations
|
||||
//-1 means show with no specific one
|
||||
//0 means don't show at all
|
||||
//specific value means show and query for only certain type.
|
||||
class CDispatchView
|
||||
{
|
||||
public:
|
||||
long id;
|
||||
CString viewname;
|
||||
CString viewprofile;
|
||||
CString virtualreport;
|
||||
long client;
|
||||
long zone;
|
||||
long postal;
|
||||
long city;
|
||||
long workorder;
|
||||
long closed;
|
||||
//0 = not displayed 1="closed",2="open" ,3= "both"
|
||||
long closeddate;//0=not displayed else display
|
||||
long onsite;
|
||||
//0 = not displayed otherwise 1="both", 2= "onsite", 3="inhouse"
|
||||
long schedstart;
|
||||
//0 = not displayed otherwise 1=any,2=today,3=week,4=month,5=between
|
||||
COleDateTime scheddatestart;
|
||||
COleDateTime scheddateend;
|
||||
|
||||
//type field means following:
|
||||
//< anytime >;After...;Before...;in the last week;
|
||||
//in the last 2 weeks;in the last 45 days;this month;in the last 3 months;
|
||||
//in the last 6 months;this year;in the last 2 years;in the last 5 years;
|
||||
//Less than...;More than...;;;
|
||||
//0=Anytime
|
||||
//1=After woentrydate
|
||||
//2=Before woentrydate
|
||||
//3=within 1 week
|
||||
//4=within 2 weeks
|
||||
//5=last 45 days
|
||||
//6=within 1 month
|
||||
//7=within 3 months
|
||||
//8=within 6 months
|
||||
//9=within 1 year
|
||||
//10=within 2 years
|
||||
//11=within 5 years
|
||||
//12=Less than X days
|
||||
//13=More than X days
|
||||
//
|
||||
long woentrydatetype;
|
||||
|
||||
COleDateTime woentrydate;//
|
||||
long schedenddate;
|
||||
//0=not displayed
|
||||
|
||||
long schedtech;
|
||||
long wocreateddate;
|
||||
long lastactivity;
|
||||
//0 = not displayed otherwise -1= "any" or positive x meaning x days ago
|
||||
CString sqlcriteria;
|
||||
CString sqlorderby;//order by string - duh!
|
||||
bool IsModified;
|
||||
|
||||
//show wo description
|
||||
long preview;
|
||||
|
||||
//show invoice number
|
||||
long invoice;
|
||||
|
||||
//show combined date in one column
|
||||
//sched date for scheduled, open workorders
|
||||
//closed date for scheduled closed workorders
|
||||
//entry date for quick workorders
|
||||
long date;
|
||||
|
||||
//Show workorder overall status field
|
||||
long status;
|
||||
|
||||
//Show our reference number field
|
||||
long ourrefnumber;
|
||||
|
||||
//Show cust reference number field
|
||||
long custrefnumber;
|
||||
|
||||
//Category
|
||||
long category;
|
||||
|
||||
//Project
|
||||
long project;
|
||||
|
||||
//created less than greater than days
|
||||
long lCreatedDays;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool operator==(CDispatchView other);
|
||||
CDispatchView();
|
||||
virtual ~CDispatchView();
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_DISPATCHVIEW_H__8543FA81_389E_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,263 @@
|
||||
// DlgDispStatPopup.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "DlgDispStatPopup.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgDispStatPopup dialog
|
||||
|
||||
|
||||
CDlgDispStatPopup::CDlgDispStatPopup(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDlgDispStatPopup::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CDlgDispStatPopup)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp = (CSpApp*)AfxGetApp();
|
||||
//Initialize recordset pointer
|
||||
rs=m_pApp->rsPool->GetRS("CDlgDispStatPopup");
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CDlgDispStatPopup::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CDlgDispStatPopup)
|
||||
DDX_Control(pDX, IDC_LBLWOINFO, m_lblWOInfo);
|
||||
DDX_Control(pDX, IDC_DTSTARTTIME, m_dtStartTime);
|
||||
DDX_Control(pDX, IDC_DTENDTIME, m_dtEndTime);
|
||||
DDX_Control(pDX, IDC_DTSCHEDENDDATE, m_dtEndDate);
|
||||
DDX_Control(pDX, IDC_DTSCHEDSTARTDATE, m_dtStartDate);
|
||||
DDX_Control(pDX, IDC_LBLTECHS, m_lblTechNumber);
|
||||
DDX_Control(pDX, IDC_CBTECHLIST, m_cbTechList);
|
||||
DDX_Control(pDX, IDC_CBSTATUSITEMLIST, m_cbStatus);
|
||||
DDX_Control(pDX, IDC_LBLSTATUSLIST, m_lblStatus);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDlgDispStatPopup, CDialog)
|
||||
//{{AFX_MSG_MAP(CDlgDispStatPopup)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
ON_BN_CLICKED(IDC_BTN_CANCEL, OnBtnCancel)
|
||||
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTSCHEDSTARTDATE, OnDatetimechangeDtschedstartdate)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgDispStatPopup message handlers
|
||||
|
||||
void CDlgDispStatPopup::OnOK()
|
||||
{}
|
||||
|
||||
CDlgDispStatPopup::~CDlgDispStatPopup()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
|
||||
}
|
||||
|
||||
BOOL CDlgDispStatPopup::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
Security();
|
||||
CString q;
|
||||
q.Format("Assigned tech number %s is:",*m_pstrSelectedTechNumber);
|
||||
m_lblTechNumber.SetWindowText(q);
|
||||
FillTechList();
|
||||
FillList();
|
||||
m_dtEndDate.SetTime(*m_pdtEnd);
|
||||
m_dtStartDate.SetTime(*m_pdtStart);
|
||||
|
||||
m_dtEndTime.SetTime(*m_pdtEnd);
|
||||
m_dtStartTime.SetTime(*m_pdtStart);
|
||||
|
||||
//added for MASS benefit
|
||||
m_lblWOInfo.SetWindowText(m_strWOInfo);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CDlgDispStatPopup::FillList()
|
||||
{
|
||||
CString q,strData,strIndex;
|
||||
long lData;
|
||||
//FILL STATUS LIST
|
||||
m_cbStatus.Clear();
|
||||
m_cbStatus.AddRow(" <No status>","0");
|
||||
rs->QueryReadOnly("SELECT probstat.id, probstat.notes FROM probstat ORDER BY probstat.id;");
|
||||
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
rs->FetchField("notes",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbStatus.AddRow(strData,strIndex);
|
||||
}while(rs->MoveForward());
|
||||
if(m_pstrSelectedStatus->IsEmpty())
|
||||
m_cbStatus.SetCurSel(0);
|
||||
else
|
||||
m_cbStatus.Select(*m_pstrSelectedStatus);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CDlgDispStatPopup::OnBtndone()
|
||||
{
|
||||
|
||||
CString q;
|
||||
COleDateTime dtDate,dtTime;
|
||||
*m_pstrSelectedStatus=m_cbStatus.GetCurrentRowID();
|
||||
*m_pstrSelectedTech=m_cbTechList.GetCurrentRowID();
|
||||
|
||||
//fetch colours if it's a valid status item
|
||||
if(*m_pstrSelectedStatus!="0")
|
||||
{
|
||||
q.Format("SELECT probstat.red, probstat.green, probstat.blue "
|
||||
"FROM probstat WHERE (((probstat.id)=%s));",*m_pstrSelectedStatus);
|
||||
rs->QueryReadOnly(q);
|
||||
rs->FetchField("red",m_plRed);
|
||||
rs->FetchField("green",m_plGreen);
|
||||
rs->FetchField("blue",m_plBlue);
|
||||
}
|
||||
else
|
||||
{
|
||||
*m_plRed=0;
|
||||
*m_plGreen=0;
|
||||
*m_plBlue=0;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//store date and times
|
||||
m_dtStartDate.GetTime(dtDate);
|
||||
m_dtStartTime.GetTime(dtTime);
|
||||
m_pdtStart->SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),
|
||||
dtTime.GetHour(),dtTime.GetMinute(),0);
|
||||
|
||||
m_dtEndDate.GetTime(dtDate);
|
||||
m_dtEndTime.GetTime(dtTime);
|
||||
m_pdtEnd->SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),
|
||||
dtTime.GetHour(),dtTime.GetMinute(),0);
|
||||
|
||||
|
||||
|
||||
CDialog::OnOK();
|
||||
|
||||
}
|
||||
|
||||
void CDlgDispStatPopup::FillTechList()
|
||||
{
|
||||
CString strData;
|
||||
CString strIndex;
|
||||
CString q;
|
||||
long lData;
|
||||
m_cbTechList.Clear();
|
||||
m_cbTechList.AddRow(" <To be assigned>","0");
|
||||
//look for selected tech and see if in inactive list:
|
||||
if(!m_pstrSelectedTech->IsEmpty() && *m_pstrSelectedTech!="0")
|
||||
{
|
||||
q.Format("SELECT users.id, [last] & \", \" & [first] AS fullname "
|
||||
"FROM users "
|
||||
"WHERE (((users.id)=%s) AND ((users.active)=False));",*m_pstrSelectedTech);
|
||||
rs->QueryReadOnly(q);
|
||||
if(!rs->IsEmpty()) //it's an inactive tech put them in the list "manually"
|
||||
{
|
||||
rs->FetchField("fullname",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
q="<NA> " + strData;
|
||||
m_cbTechList.AddRow(q,strIndex);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//change to active only 10/03/00
|
||||
q="SELECT users.id, [last] & \", \" & [first] AS fullname FROM users "
|
||||
"WHERE (((users.id)<>1) AND ((users.tech)=True) AND ((users.active)=True)) "
|
||||
"ORDER BY users.last;";
|
||||
//////////////////m_pApp->ShowStuff(q);
|
||||
|
||||
rs->QueryReadOnly(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
rs->MoveFirst();
|
||||
rs->FetchField("fullname",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbTechList.AddRow(strData,strIndex);
|
||||
while(rs->MoveForward())
|
||||
{
|
||||
rs->FetchField("fullname",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbTechList.AddRow(strData,strIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//if(!m_pstrSelectedTech->IsEmpty())
|
||||
m_cbTechList.Select(*m_pstrSelectedTech);
|
||||
//else
|
||||
//{//attempt to select by current user id
|
||||
// m_pstrSelectedTech->Format("%u",m_pApp->m_lusrID);
|
||||
// m_cbTechList.Select(*m_pstrSelectedTech);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CDlgDispStatPopup::OnBtnCancel()
|
||||
{
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
void CDlgDispStatPopup::OnDatetimechangeDtschedstartdate(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
COleDateTime dtData;
|
||||
m_dtStartDate.GetTime(dtData);
|
||||
m_dtEndDate.SetTime(dtData);
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
void CDlgDispStatPopup::Security()
|
||||
{
|
||||
int x=m_pApp->Allowed(RWORKORDER,true);
|
||||
if(x==0)//no access allowed
|
||||
{
|
||||
m_pApp->SecurityWarning();
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
if(x==2)//read only
|
||||
{
|
||||
|
||||
m_cbStatus.EnableWindow(FALSE);
|
||||
m_cbTechList.EnableWindow(FALSE);
|
||||
m_dtEndDate.EnableWindow(FALSE);
|
||||
m_dtEndTime.EnableWindow(FALSE);
|
||||
m_dtStartDate.EnableWindow(FALSE);
|
||||
m_dtStartTime.EnableWindow(FALSE);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#if !defined(AFX_DLGDISPSTATPOPUP_H__B6217656_2D59_48A7_9254_58300EFE0CF8__INCLUDED_)
|
||||
#define AFX_DLGDISPSTATPOPUP_H__B6217656_2D59_48A7_9254_58300EFE0CF8__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// DlgDispStatPopup.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgDispStatPopup dialog
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
#include "label.h"
|
||||
|
||||
class CDlgDispStatPopup : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CString m_strWOInfo;
|
||||
COleDateTime* m_pdtStart;
|
||||
COleDateTime* m_pdtEnd;
|
||||
void FillTechList();
|
||||
CDlgDispStatPopup(CWnd* pParent = NULL); // standard constructor
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
CString* m_pstrSelectedStatus;
|
||||
CString* m_pstrSelectedTech;
|
||||
//added 07/27/01 to accomodate multi-techs
|
||||
CString* m_pstrSelectedTechNumber;
|
||||
|
||||
long* m_plRed;
|
||||
long* m_plGreen;
|
||||
long* m_plBlue;
|
||||
|
||||
|
||||
void FillList();
|
||||
~CDlgDispStatPopup();
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CDlgDispStatPopup)
|
||||
enum { IDD = IDD_SCHED_STAT_POPUP };
|
||||
CStatic m_lblWOInfo;
|
||||
CDateTimeCtrl m_dtStartTime;
|
||||
CDateTimeCtrl m_dtEndTime;
|
||||
CDateTimeCtrl m_dtEndDate;
|
||||
CDateTimeCtrl m_dtStartDate;
|
||||
CStatic m_lblTechNumber;
|
||||
CgzCombo m_cbTechList;
|
||||
CgzCombo m_cbStatus;
|
||||
CLabel m_lblStatus;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CDlgDispStatPopup)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CDlgDispStatPopup)
|
||||
virtual void OnOK();
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBtndone();
|
||||
afx_msg void OnBtnCancel();
|
||||
afx_msg void OnDatetimechangeDtschedstartdate(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
void Security();
|
||||
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_DLGDISPSTATPOPUP_H__B6217656_2D59_48A7_9254_58300EFE0CF8__INCLUDED_)
|
||||
@@ -0,0 +1,503 @@
|
||||
// DlgSchedMarkers.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "DlgSchedMarkers.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgSchedMarkers dialog
|
||||
|
||||
|
||||
CDlgSchedMarkers::CDlgSchedMarkers(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDlgSchedMarkers::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CDlgSchedMarkers)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
//Initialize recordset pointer
|
||||
rs=m_pApp->rsPool->GetRS("CDlgSchedMarkers");
|
||||
}
|
||||
|
||||
CDlgSchedMarkers::~CDlgSchedMarkers()
|
||||
{
|
||||
//delete rs;
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
void CDlgSchedMarkers::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CDlgSchedMarkers)
|
||||
DDX_Control(pDX, IDC_BTNCOLOR, m_btnColor);
|
||||
DDX_Control(pDX, IDC_BTNREFRESH, m_btnRefresh);
|
||||
DDX_Control(pDX, IDC_BTNDONE, m_btnDone);
|
||||
DDX_Control(pDX, IDC_BTNADD, m_btnAdd);
|
||||
DDX_Control(pDX, IDC_LSTMARKERS, m_lsMarkers);
|
||||
DDX_Control(pDX, IDC_LBLSAMPLE, m_lblSample);
|
||||
DDX_Control(pDX, IDC_EDNOTES, m_edNotes);
|
||||
DDX_Control(pDX, IDC_DTTSTART, m_dtStartTime);
|
||||
DDX_Control(pDX, IDC_DTTEND, m_dtEndTime);
|
||||
DDX_Control(pDX, IDC_DTSTART, m_dtStartDate);
|
||||
DDX_Control(pDX, IDC_DTEND, m_dtEndDate);
|
||||
DDX_Control(pDX, IDC_CBAPPLIESTO, m_cbAppliesTo);
|
||||
DDX_Control(pDX, IDC_BTNDEL, m_btnDelete);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDlgSchedMarkers, CDialog)
|
||||
//{{AFX_MSG_MAP(CDlgSchedMarkers)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
ON_LBN_SELCHANGE(IDC_LSTMARKERS, OnSelchangeLstmarkers)
|
||||
ON_BN_CLICKED(IDC_BTNCOLOR, OnBtncolor)
|
||||
ON_EN_KILLFOCUS(IDC_EDNOTES, OnKillfocusEdnotes)
|
||||
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTSTART, OnDatetimechangeDtstart)
|
||||
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTEND, OnDatetimechangeDtend)
|
||||
ON_CBN_CLOSEUP(IDC_CBAPPLIESTO, OnCloseupCbappliesto)
|
||||
ON_BN_CLICKED(IDC_BTNADD, OnBtnadd)
|
||||
ON_NOTIFY(NM_KILLFOCUS, IDC_DTTSTART, OnKillfocusDttstart)
|
||||
ON_NOTIFY(NM_KILLFOCUS, IDC_DTTEND, OnKillfocusDttend)
|
||||
ON_BN_CLICKED(IDC_BTNREFRESH, OnBtnrefresh)
|
||||
ON_BN_CLICKED(IDC_BTNDEL, OnBtndel)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgSchedMarkers message handlers
|
||||
|
||||
|
||||
|
||||
BOOL CDlgSchedMarkers::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
Security();
|
||||
m_lblSample.SetFontBold(TRUE);
|
||||
m_lblSample.SetFontSize(14);
|
||||
m_lblSample.SetBkColor(RGB(128,128,128));
|
||||
m_lGreen=m_lBlue=m_lRed=128;
|
||||
m_lblSample.SetTextColor(RGB(0,0,0));
|
||||
m_edNotes.SetLimitText(15);
|
||||
FillAppliesToList();
|
||||
FillMarkerList();
|
||||
m_bAddMode=false;
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CDlgSchedMarkers::FillAppliesToList()
|
||||
{
|
||||
CString strData, strIndex;
|
||||
long lData;
|
||||
m_cbAppliesTo.Clear();
|
||||
strData="< Office >";
|
||||
strIndex="0";
|
||||
m_cbAppliesTo.AddRow(strData,strIndex);
|
||||
|
||||
|
||||
rs->QueryReadOnly("SELECT users.id, [last] & \", \" & [first] AS name "
|
||||
"FROM users WHERE (((users.id)<>1) AND ((users.tech)=True) AND ((users.active)=True)) "
|
||||
"ORDER BY [last] & \", \" & [first];");
|
||||
|
||||
|
||||
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
rs->FetchField("name",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbAppliesTo.AddRow(strData,strIndex);
|
||||
}while(rs->MoveForward());
|
||||
m_cbAppliesTo.Select("0");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CDlgSchedMarkers::OnBtndone()
|
||||
{
|
||||
|
||||
CDialog::OnOK();
|
||||
|
||||
}
|
||||
|
||||
void CDlgSchedMarkers::OnOK()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
//Fill list of items
|
||||
void CDlgSchedMarkers::FillMarkerList()
|
||||
{
|
||||
long lData;
|
||||
CString strIndex,strData,strNotes,strName;
|
||||
COleDateTime dtStart,dtEnd;
|
||||
m_lsMarkers.Clear();
|
||||
EnableFields(false);
|
||||
rs->QueryReadOnly(
|
||||
"SELECT schedmarkers.id, schedmarkers.link, schedmarkers.startdate, schedmarkers.notes, "
|
||||
"users.first, users.last "
|
||||
"FROM schedmarkers LEFT JOIN users ON schedmarkers.link = users.id "
|
||||
"ORDER BY schedmarkers.startdate DESC;");
|
||||
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
EnableFields(true);
|
||||
do{
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
|
||||
rs->FetchField("startdate",&dtStart);
|
||||
strNotes=dtStart.Format();
|
||||
|
||||
rs->FetchField("notes",&strData);
|
||||
strNotes+="\t"+strData;
|
||||
|
||||
rs->FetchField("link",&lData);
|
||||
if(lData==0)
|
||||
{
|
||||
strName="<Office>";
|
||||
}
|
||||
else
|
||||
{
|
||||
rs->FetchField("last",&strData);
|
||||
strName=strData;
|
||||
rs->FetchField("first",&strData);
|
||||
strName+=", " + strData;
|
||||
}
|
||||
|
||||
strNotes+=" - "+strName;
|
||||
|
||||
m_lsMarkers.AddRow(strNotes,strIndex);
|
||||
}while(rs->MoveForward());
|
||||
|
||||
if(m_strSelectedItem.IsEmpty())
|
||||
{
|
||||
m_lsMarkers.SetCurSel(0);
|
||||
m_lsMarkers.RebuildIndex();//<--------FIXES PROBLEM
|
||||
m_strSelectedItem=m_lsMarkers.GetSelectedItem(0);//<-------problem
|
||||
}
|
||||
else
|
||||
m_lsMarkers.Select(m_strSelectedItem,true);
|
||||
//OnSelchangeLstmarkers();
|
||||
FillFields();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CDlgSchedMarkers::OnSelchangeLstmarkers()
|
||||
{
|
||||
|
||||
CString q,strID,strNotes,strAppliesTo;
|
||||
COleDateTime dtStart,dtEnd;
|
||||
|
||||
|
||||
m_lsMarkers.RebuildIndex();//<--------FIXES PROBLEM
|
||||
m_strSelectedItem=m_lsMarkers.GetSelectedItem(0);//<-------problem
|
||||
FillFields();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CDlgSchedMarkers::OnBtncolor()
|
||||
{
|
||||
CString q;
|
||||
|
||||
CColorDialog dlg(RGB(255,0,0),CC_SOLIDCOLOR/*|CC_PREVENTFULLOPEN*/);
|
||||
|
||||
if (dlg.DoModal() == IDOK)
|
||||
{
|
||||
COLORREF color = dlg.GetColor();
|
||||
|
||||
m_lRed=GetRValue(color);
|
||||
m_lGreen=GetGValue(color);
|
||||
m_lBlue=GetBValue(color);
|
||||
|
||||
|
||||
m_lblSample.SetBkColor(RGB(m_lRed,m_lGreen,m_lBlue));
|
||||
m_lblSample.SetTextColor(RGB(0,0,0));
|
||||
}
|
||||
SaveRecord(false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//save new record or update existing record
|
||||
void CDlgSchedMarkers::SaveRecord(bool bNew)
|
||||
{
|
||||
//only save or update a record if out of add mode
|
||||
if(m_bAddMode) return;
|
||||
CString q,strID,strNotes,strAppliesTo;
|
||||
COleDateTime dtStart,dtEnd,dtTime,dtDate;
|
||||
long lData;
|
||||
|
||||
|
||||
/*m_lsMarkers.RebuildIndex();//<--------FIXES PROBLEM
|
||||
strID=m_lsMarkers.GetSelectedItem(0);//<-------problem
|
||||
*/
|
||||
|
||||
//get start date/time
|
||||
m_dtStartTime.GetTime(dtTime);
|
||||
m_dtStartDate.GetTime(dtDate);
|
||||
dtStart.SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
||||
|
||||
//get End date/time
|
||||
m_dtEndTime.GetTime(dtTime);
|
||||
m_dtEndDate.GetTime(dtDate);
|
||||
dtEnd.SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
||||
|
||||
//Get notes
|
||||
m_edNotes.GetWindowText(strNotes);
|
||||
if(strNotes.IsEmpty()) strNotes="??";
|
||||
|
||||
//Get link
|
||||
strAppliesTo=m_cbAppliesTo.GetCurrentRowID();
|
||||
|
||||
//BUGBUG: on change of date schedule reverts to gray color
|
||||
|
||||
if(bNew)
|
||||
{
|
||||
|
||||
q.Format(
|
||||
"INSERT INTO schedmarkers ( link, startdate, enddate, notes, red, green, blue ) "
|
||||
"SELECT %s, #%s#, #%s#, '%s', %u, %u, %u;",strAppliesTo,dtStart.Format(_T("%m/%d/%Y %H:%M:%S")),
|
||||
dtEnd.Format(_T("%m/%d/%Y %H:%M:%S")),strNotes,m_lRed,m_lGreen,m_lBlue);
|
||||
rs->Ex(q,&lData);
|
||||
m_strSelectedItem.Format("%u",lData);
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(!m_strSelectedItem.IsEmpty());
|
||||
strID=m_strSelectedItem;
|
||||
q.Format(
|
||||
"UPDATE schedmarkers SET schedmarkers.link = %s, schedmarkers.startdate = #%s#, "
|
||||
"schedmarkers.enddate = #%s#, schedmarkers.notes = '%s', schedmarkers.red = %u, "
|
||||
"schedmarkers.green = %u, schedmarkers.blue = %u "
|
||||
"WHERE (((schedmarkers.id)=%s));",strAppliesTo,dtStart.Format(_T("%m/%d/%Y %H:%M:%S")),
|
||||
dtEnd.Format(_T("%m/%d/%Y %H:%M:%S")),strNotes,m_lRed,m_lGreen,m_lBlue,strID);
|
||||
|
||||
#ifdef _DEBUG
|
||||
//m_pApp->ShowStuff(q);
|
||||
#endif
|
||||
rs->Ex(q);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//force a delay to flush change before refilling list
|
||||
rs->QueryReadOnly("SELECT * FROM defaults;");
|
||||
rs->Close();
|
||||
m_pApp->Delay(1);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CDlgSchedMarkers::OnBtnadd()
|
||||
{
|
||||
COleDateTime dtData;
|
||||
dtData=COleDateTime::GetCurrentTime();
|
||||
if(m_bAddMode)
|
||||
{
|
||||
m_bAddMode=false;
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
m_btnDelete.ShowWindow(TRUE);
|
||||
m_btnRefresh.ShowWindow(TRUE);
|
||||
SaveRecord(true);
|
||||
m_strSelectedItem.Empty();
|
||||
FillMarkerList();
|
||||
}
|
||||
else
|
||||
{
|
||||
EnableFields(true);
|
||||
m_bAddMode=true;
|
||||
m_btnAdd.SetWindowText("SAVE");
|
||||
m_btnDone.ShowWindow(FALSE);
|
||||
m_btnRefresh.ShowWindow(FALSE);
|
||||
m_lblSample.SetBkColor(RGB(128,128,128));
|
||||
m_lblSample.SetTextColor(RGB(0,0,0));
|
||||
m_lGreen=m_lBlue=m_lRed=128;
|
||||
m_btnDelete.ShowWindow(FALSE);
|
||||
m_dtEndDate.SetTime(dtData);
|
||||
m_dtStartDate.SetTime(dtData);
|
||||
dtData.SetTime(0,0,0);
|
||||
m_dtStartTime.SetTime(dtData);
|
||||
dtData.SetTime(23,59,59);
|
||||
m_dtEndTime.SetTime(dtData);
|
||||
m_edNotes.SetWindowText("??");
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CDlgSchedMarkers::OnKillfocusDttstart(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
SaveRecord(false);
|
||||
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
void CDlgSchedMarkers::OnKillfocusDttend(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
SaveRecord(false);
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
void CDlgSchedMarkers::OnKillfocusEdnotes()
|
||||
{
|
||||
SaveRecord(false);
|
||||
}
|
||||
|
||||
|
||||
void CDlgSchedMarkers::OnDatetimechangeDtstart(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
COleDateTime dtData;
|
||||
if(m_bAddMode)//change stop date to start date when in add mode
|
||||
{
|
||||
m_dtStartDate.GetTime(dtData);
|
||||
m_dtEndDate.SetTime(dtData);
|
||||
|
||||
}
|
||||
SaveRecord(false);
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
void CDlgSchedMarkers::OnDatetimechangeDtend(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
SaveRecord(false);
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
void CDlgSchedMarkers::OnCloseupCbappliesto()
|
||||
{
|
||||
SaveRecord(false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//refresh list
|
||||
void CDlgSchedMarkers::OnBtnrefresh()
|
||||
{
|
||||
FillMarkerList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CDlgSchedMarkers::FillFields()
|
||||
{
|
||||
CString q,strNotes,strAppliesTo;
|
||||
COleDateTime dtStart,dtEnd;
|
||||
long lData;
|
||||
|
||||
ASSERT(!m_strSelectedItem.IsEmpty());
|
||||
q.Format("SELECT schedmarkers.* "
|
||||
"FROM schedmarkers "
|
||||
"WHERE (((schedmarkers.id)=%s));",m_strSelectedItem);
|
||||
rs->QueryReadOnly(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
rs->FetchField("startdate",&dtStart);
|
||||
rs->FetchField("enddate",&dtEnd);
|
||||
rs->FetchField("notes",&strNotes);
|
||||
rs->FetchField("red",&m_lRed);
|
||||
rs->FetchField("green",&m_lGreen);
|
||||
rs->FetchField("blue",&m_lBlue);
|
||||
rs->FetchField("link",&lData);
|
||||
m_dtStartDate.SetTime(dtStart);
|
||||
m_dtStartTime.SetTime(dtStart);
|
||||
m_dtEndDate.SetTime(dtEnd);
|
||||
m_dtEndTime.SetTime(dtEnd);
|
||||
m_edNotes.SetWindowText(strNotes);
|
||||
m_lblSample.SetBkColor(RGB(m_lRed,m_lGreen,m_lBlue));
|
||||
m_lblSample.SetTextColor(RGB(0,0,0));
|
||||
m_cbAppliesTo.Select(lData);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CDlgSchedMarkers::OnBtndel()
|
||||
{
|
||||
|
||||
if(AfxMessageBox("Delete selected item?\r\nAre you sure?",MB_YESNO)==IDNO) return;
|
||||
CString q;
|
||||
q.Format("DELETE schedmarkers.*, schedmarkers.id "
|
||||
"FROM schedmarkers "
|
||||
"WHERE (((schedmarkers.id)=%s));",m_strSelectedItem);
|
||||
|
||||
rs->Ex(q);
|
||||
rs->QueryReadOnly("SELECT * FROM defaults;");
|
||||
rs->Close();
|
||||
m_pApp->Delay(1);
|
||||
|
||||
m_strSelectedItem.Empty();
|
||||
FillMarkerList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//enable fields
|
||||
void CDlgSchedMarkers::EnableFields(bool bEnable)
|
||||
{
|
||||
if(m_bReadOnly) return;
|
||||
|
||||
BOOL e= bEnable ? TRUE:FALSE;
|
||||
m_btnDelete.EnableWindow(e);
|
||||
m_dtEndDate.EnableWindow(e);
|
||||
m_dtStartDate.EnableWindow(e);
|
||||
m_cbAppliesTo.EnableWindow(e);
|
||||
m_dtEndTime.EnableWindow(e);
|
||||
m_dtStartTime.EnableWindow(e);
|
||||
m_edNotes.EnableWindow(e);
|
||||
m_btnColor.EnableWindow(e);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CDlgSchedMarkers::Security()
|
||||
{
|
||||
m_bReadOnly=false;
|
||||
int x=m_pApp->Allowed(RSCHEDMARKERS,true);
|
||||
if(x==0)//no access allowed
|
||||
{
|
||||
m_pApp->SecurityWarning();
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
if(x==2)//read only
|
||||
{
|
||||
|
||||
m_bReadOnly=true;
|
||||
m_btnAdd.ShowWindow(FALSE);
|
||||
m_btnDelete.ShowWindow(FALSE);
|
||||
m_btnColor.EnableWindow(FALSE);
|
||||
m_cbAppliesTo.EnableWindow(FALSE);
|
||||
m_dtEndDate.EnableWindow(FALSE);
|
||||
m_dtEndTime.EnableWindow(FALSE);
|
||||
m_dtStartDate.EnableWindow(FALSE);
|
||||
m_dtStartTime.EnableWindow(FALSE);
|
||||
m_edNotes.EnableWindow(FALSE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
#if !defined(AFX_DLGSCHEDMARKERS_H__EA79FE52_81E9_4C2A_8177_1E8070B8BAC6__INCLUDED_)
|
||||
#define AFX_DLGSCHEDMARKERS_H__EA79FE52_81E9_4C2A_8177_1E8070B8BAC6__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// DlgSchedMarkers.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgSchedMarkers dialog
|
||||
#include "gzrset.h"
|
||||
#include "label.h"
|
||||
#include "gzlistbox.h"
|
||||
#include "gzcombo.h"
|
||||
|
||||
class CDlgSchedMarkers : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
void FillFields();
|
||||
CString m_strSelectedItem;
|
||||
void SaveRecord(bool bNew);
|
||||
long m_lRed;
|
||||
long m_lGreen;
|
||||
long m_lBlue;
|
||||
void FillMarkerList();
|
||||
void FillAppliesToList();
|
||||
~CDlgSchedMarkers();
|
||||
CDlgSchedMarkers(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
bool m_bAddMode;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CDlgSchedMarkers)
|
||||
enum { IDD = IDD_SCHED_MARKERS };
|
||||
CButton m_btnColor;
|
||||
CButton m_btnRefresh;
|
||||
CButton m_btnDone;
|
||||
CButton m_btnAdd;
|
||||
CgzListBox m_lsMarkers;
|
||||
CLabel m_lblSample;
|
||||
CEdit m_edNotes;
|
||||
CDateTimeCtrl m_dtStartTime;
|
||||
CDateTimeCtrl m_dtEndTime;
|
||||
CDateTimeCtrl m_dtStartDate;
|
||||
CDateTimeCtrl m_dtEndDate;
|
||||
CgzCombo m_cbAppliesTo;
|
||||
CButton m_btnDelete;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CDlgSchedMarkers)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CDlgSchedMarkers)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBtndone();
|
||||
virtual void OnOK();
|
||||
afx_msg void OnSelchangeLstmarkers();
|
||||
afx_msg void OnBtncolor();
|
||||
afx_msg void OnKillfocusEdnotes();
|
||||
afx_msg void OnDatetimechangeDtstart(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnDatetimechangeDtend(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnCloseupCbappliesto();
|
||||
afx_msg void OnBtnadd();
|
||||
afx_msg void OnKillfocusDttstart(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnKillfocusDttend(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnBtnrefresh();
|
||||
afx_msg void OnBtndel();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
bool m_bReadOnly;
|
||||
void Security();
|
||||
void EnableFields(bool bEnable);
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_DLGSCHEDMARKERS_H__EA79FE52_81E9_4C2A_8177_1E8070B8BAC6__INCLUDED_)
|
||||
@@ -0,0 +1,51 @@
|
||||
// DlgStartUp.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "DlgStartUp.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgStartUp dialog
|
||||
|
||||
|
||||
CDlgStartUp::CDlgStartUp(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDlgStartUp::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CDlgStartUp)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CDlgStartUp::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CDlgStartUp)
|
||||
DDX_Control(pDX, IDC_PG, m_pc);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDlgStartUp, CDialog)
|
||||
//{{AFX_MSG_MAP(CDlgStartUp)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgStartUp message handlers
|
||||
|
||||
BOOL CDlgStartUp::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
m_pc.SetRange(0,18);
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
#if !defined(AFX_DLGSTARTUP_H__85A91F44_E745_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_DLGSTARTUP_H__85A91F44_E745_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// DlgStartUp.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgStartUp dialog
|
||||
|
||||
class CDlgStartUp : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CDlgStartUp(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CDlgStartUp)
|
||||
enum { IDD = IDD_DLGSTARTUP };
|
||||
CProgressCtrl m_pc;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CDlgStartUp)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CDlgStartUp)
|
||||
virtual BOOL OnInitDialog();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_DLGSTARTUP_H__85A91F44_E745_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,446 @@
|
||||
// DlgTasks.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "DlgTasks.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgTasks dialog
|
||||
|
||||
|
||||
CDlgTasks::CDlgTasks(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CDlgTasks::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CDlgTasks)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_bAddMode=false;
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
/*
|
||||
rs=new GZRset("Error: Tasks dialog");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
*/
|
||||
//Initialize recordset pointer
|
||||
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CDlgTasks");
|
||||
|
||||
m_pstrReturnValue=NULL;
|
||||
m_strSelectedTask.Empty();
|
||||
|
||||
}
|
||||
|
||||
CDlgTasks::~CDlgTasks()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
void CDlgTasks::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CDlgTasks)
|
||||
DDX_Control(pDX, IDC_LBLTASKS, m_lblTasks);
|
||||
DDX_Control(pDX, IDC_CKACTIVE, m_ckActive);
|
||||
DDX_Control(pDX, IDC_EDMINUTES, m_edMinutes);
|
||||
DDX_Control(pDX, IDC_EDDETAILS, m_edDetails);
|
||||
DDX_Control(pDX, IDC_EDDESCRIPTION, m_edDescription);
|
||||
DDX_Control(pDX, IDC_CBTASKS, m_cbTasks);
|
||||
DDX_Control(pDX, IDC_BTNDONE, m_btnDone);
|
||||
DDX_Control(pDX, IDC_BTNDELETE, m_btnDelete);
|
||||
DDX_Control(pDX, IDC_BTNADD, m_btnAdd);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CDlgTasks, CDialog)
|
||||
//{{AFX_MSG_MAP(CDlgTasks)
|
||||
ON_BN_CLICKED(IDC_BTNADD, OnBtnadd)
|
||||
ON_BN_CLICKED(IDC_BTNDELETE, OnBtndelete)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
ON_CBN_CLOSEUP(IDC_CBTASKS, OnCloseupCbtasks)
|
||||
ON_EN_KILLFOCUS(IDC_EDDESCRIPTION, OnKillfocusEddescription)
|
||||
ON_EN_KILLFOCUS(IDC_EDDETAILS, OnKillfocusEddetails)
|
||||
ON_EN_KILLFOCUS(IDC_EDMINUTES, OnKillfocusEdminutes)
|
||||
ON_BN_CLICKED(IDC_CKACTIVE, OnCkactive)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgTasks message handlers
|
||||
|
||||
BOOL CDlgTasks::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
Security();
|
||||
// TODO: Add extra initialization here
|
||||
FillList();
|
||||
if(m_bReadOnly)
|
||||
{
|
||||
m_btnAdd.ShowWindow(FALSE);
|
||||
m_btnDelete.ShowWindow(FALSE);
|
||||
m_edDescription.SetReadOnly(TRUE);
|
||||
m_edDetails.SetReadOnly(TRUE);
|
||||
m_ckActive.EnableWindow(FALSE);
|
||||
m_edMinutes.SetReadOnly(TRUE);
|
||||
|
||||
|
||||
|
||||
}
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
|
||||
//*****************************************
|
||||
void CDlgTasks::OnBtnadd()
|
||||
{
|
||||
CString strData;
|
||||
bool bData;
|
||||
long lData;
|
||||
|
||||
if(!m_bAddMode)
|
||||
{ //go add mode
|
||||
DisableAll(false);
|
||||
m_bAddMode=true;
|
||||
m_btnDelete.SetWindowText("CANCEL");
|
||||
m_btnAdd.SetWindowText("SAVE");
|
||||
m_btnDone.ShowWindow(FALSE);
|
||||
m_lblTasks.ShowWindow(FALSE);
|
||||
m_cbTasks.ShowWindow(FALSE);
|
||||
ClearFields();
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{//SAVE Record
|
||||
|
||||
|
||||
m_edDescription.GetWindowText(strData);
|
||||
if(strData.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("You must enter a task description");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(!rs->AddNewRecord())
|
||||
return;
|
||||
|
||||
//SAVE DESCRIPTION
|
||||
rs->UpdateField("description",&strData);
|
||||
|
||||
//ACTIVE
|
||||
bData=(m_ckActive.GetCheck() ? true : false);
|
||||
rs->UpdateField("active",&bData);
|
||||
|
||||
//DETAILS
|
||||
m_edDetails.GetWindowText(strData);
|
||||
rs->UpdateField("details",&strData);
|
||||
|
||||
//Minutes
|
||||
m_edMinutes.GetWindowText(strData);
|
||||
lData=atol(strData);
|
||||
rs->UpdateField("minutes",&lData);
|
||||
|
||||
|
||||
//ATTEMPT TO SAVE
|
||||
if(!rs->SaveRecord())
|
||||
return;
|
||||
m_bAddMode=false;
|
||||
m_lblTasks.ShowWindow(TRUE);
|
||||
m_cbTasks.ShowWindow(TRUE);
|
||||
m_btnDelete.SetWindowText("Delete");
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
FillList();
|
||||
m_edDescription.GetWindowText(strData);
|
||||
m_cbTasks.SelectString(-1,strData);
|
||||
OnCloseupCbtasks();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*******************************************
|
||||
void CDlgTasks::OnBtndelete()
|
||||
{
|
||||
CString q;
|
||||
|
||||
if(m_bAddMode)
|
||||
{
|
||||
m_bAddMode=false;
|
||||
m_lblTasks.ShowWindow(TRUE);
|
||||
m_cbTasks.ShowWindow(TRUE);
|
||||
m_btnDelete.SetWindowText("Delete");
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
FillList();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//DELETE.....
|
||||
|
||||
|
||||
|
||||
//check if unused and deletable
|
||||
//IN PMPARTS???
|
||||
q.Format("SELECT probs.taskid FROM probs "
|
||||
"WHERE (((probs.taskid)=%s));",m_strSelectedTask);
|
||||
rs->Query(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
AfxMessageBox("DATA INTEGRITY PROTECTION:\r\n"
|
||||
"This task appears in one or more workorders\r\n"
|
||||
"and cannot be deleted at this time.");
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(AfxMessageBox("Permanently delete part?",MB_YESNO)==IDYES)
|
||||
{
|
||||
q.Format("DELETE tasks.*, tasks.id "
|
||||
"FROM tasks WHERE (((tasks.id)=%s));",m_strSelectedTask);
|
||||
rs->Ex(q);
|
||||
m_strSelectedTask="";
|
||||
FillList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//******************************************
|
||||
void CDlgTasks::OnBtndone()
|
||||
{
|
||||
if(m_pstrReturnValue!=NULL)
|
||||
*m_pstrReturnValue=m_strSelectedTask;
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CDlgTasks::OnCloseupCbtasks()
|
||||
{
|
||||
//FILL FIELDS
|
||||
CString strData,q;
|
||||
bool bData;
|
||||
long lData;
|
||||
|
||||
strData=m_cbTasks.GetCurrentRowID();
|
||||
|
||||
q.Format("SELECT tasks.* FROM tasks "
|
||||
"WHERE (((tasks.id)=%s));",m_cbTasks.GetCurrentRowID());
|
||||
|
||||
rs->Query(q);
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//DESCRIPTION
|
||||
rs->FetchField("description",&strData);
|
||||
m_edDescription.SetWindowText(strData);
|
||||
|
||||
//DETAILS
|
||||
rs->FetchField("details",&strData);
|
||||
m_edDetails.SetWindowText(strData);
|
||||
|
||||
|
||||
//ACTIVE
|
||||
rs->FetchField("active",&bData);
|
||||
m_ckActive.SetCheck(bData ? TRUE : FALSE);
|
||||
|
||||
|
||||
//MINUTES
|
||||
rs->FetchField("minutes",&lData);
|
||||
strData.Format("%u",lData);
|
||||
m_edMinutes.SetWindowText(strData);
|
||||
|
||||
|
||||
m_strSelectedTask=m_cbTasks.GetCurrentRowID();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CDlgTasks::OnKillfocusEddescription()
|
||||
{
|
||||
SaveField(&m_edDescription,"description",false);
|
||||
}
|
||||
|
||||
void CDlgTasks::OnKillfocusEddetails()
|
||||
{
|
||||
SaveField(&m_edDetails,"details",true);
|
||||
|
||||
}
|
||||
|
||||
void CDlgTasks::OnKillfocusEdminutes()
|
||||
{
|
||||
if(m_bAddMode) return;
|
||||
long lData;
|
||||
CString strData;
|
||||
m_edMinutes.GetWindowText(strData);
|
||||
lData=atol(strData);
|
||||
rs->UpdateField("minutes",&lData);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//************************************************************
|
||||
//SAVE EDIT CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CDlgTasks::SaveField(CEdit *edControl,CString fldname,bool AllowEmpty)
|
||||
{
|
||||
|
||||
if(m_bAddMode) return true;//dont attempt to update
|
||||
CString str;
|
||||
//do nothing if not changed
|
||||
if(edControl->GetModify()!=TRUE) return true;
|
||||
|
||||
edControl->GetWindowText(str);
|
||||
//dont save empty fields if not allowed to
|
||||
if(!AllowEmpty)
|
||||
{
|
||||
|
||||
if(str.IsEmpty())
|
||||
{
|
||||
edControl->Undo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rs->UpdateField(fldname,&str);
|
||||
rs->SaveRecord();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//************************************************************
|
||||
//SAVE CheckBox CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CDlgTasks::SaveField(CButton *ckControl,CString fldname)
|
||||
{
|
||||
if(m_bAddMode) return true;//dont attempt to update
|
||||
bool bData=false;
|
||||
BOOL BData;
|
||||
BData=ckControl->GetCheck();
|
||||
if(BData==TRUE) bData=true;
|
||||
rs->UpdateField(fldname,&bData);
|
||||
rs->SaveRecord();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//**********************************
|
||||
void CDlgTasks::FillList()
|
||||
{
|
||||
|
||||
CString strData;
|
||||
CString strIndex;
|
||||
long lData;
|
||||
m_cbTasks.Clear();
|
||||
|
||||
rs->Query("SELECT tasks.* FROM tasks "
|
||||
"ORDER BY tasks.description;");
|
||||
|
||||
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
DisableAll(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
rs->MoveFirst();
|
||||
|
||||
do
|
||||
{
|
||||
rs->FetchField("description",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbTasks.AddRow(strData,strIndex);
|
||||
|
||||
}while(rs->MoveForward());
|
||||
|
||||
|
||||
//pretend user has selected so that other fields get filled in
|
||||
if(m_strSelectedTask.IsEmpty()) //first time in
|
||||
{
|
||||
m_cbTasks.SetCurSel(0);
|
||||
m_strSelectedTask=m_cbTasks.GetCurrentRowID();
|
||||
|
||||
}
|
||||
else//something valid was selected before so stick with it
|
||||
m_cbTasks.Select(m_strSelectedTask);
|
||||
|
||||
|
||||
OnCloseupCbtasks();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//*******************************
|
||||
void CDlgTasks::ClearFields()
|
||||
{
|
||||
m_edDetails.SetWindowText("");
|
||||
m_edDescription.SetWindowText("");
|
||||
m_edMinutes.SetWindowText("0");
|
||||
m_ckActive.SetCheck(TRUE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CDlgTasks::OnCkactive()
|
||||
{
|
||||
SaveField(&m_ckActive,"active");
|
||||
}
|
||||
|
||||
void CDlgTasks::DisableAll(bool disable)
|
||||
{
|
||||
BOOL e = disable ? FALSE : TRUE;
|
||||
m_btnDelete.EnableWindow(e);
|
||||
m_cbTasks.EnableWindow(e);
|
||||
m_ckActive.EnableWindow(e);
|
||||
m_edDescription.EnableWindow(e);
|
||||
m_edMinutes.EnableWindow(e);
|
||||
m_edDetails.EnableWindow(e);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CDlgTasks::Security()
|
||||
{
|
||||
int x=m_pApp->Allowed(RTASKS,true);
|
||||
m_bReadOnly=false;
|
||||
if(x==2)//read only
|
||||
m_bReadOnly=true;
|
||||
if(x==0)
|
||||
{
|
||||
m_pApp->SecurityWarning();
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
#if !defined(AFX_DLGTASKS_H__69649FC1_2BEE_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_DLGTASKS_H__69649FC1_2BEE_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// DlgTasks.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CDlgTasks dialog
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
|
||||
class CDlgTasks : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
bool m_bReadOnly;
|
||||
void Security();
|
||||
void DisableAll(bool disable);
|
||||
void ClearFields();
|
||||
void FillList();
|
||||
CDlgTasks(CWnd* pParent = NULL); // standard constructor
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
GZRset* cbrs;
|
||||
CString * m_pstrReturnValue;
|
||||
~CDlgTasks();
|
||||
bool m_bAddMode;
|
||||
CString m_strSelectedTask;
|
||||
bool SaveField(CEdit *edControl,CString fldname,bool AllowEmpty);
|
||||
bool SaveField(CButton *ckControl,CString fldname);
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CDlgTasks)
|
||||
enum { IDD = IDD_TASKS };
|
||||
CStatic m_lblTasks;
|
||||
CButton m_ckActive;
|
||||
CEdit m_edMinutes;
|
||||
CEdit m_edDetails;
|
||||
CEdit m_edDescription;
|
||||
CgzCombo m_cbTasks;
|
||||
CButton m_btnDone;
|
||||
CButton m_btnDelete;
|
||||
CButton m_btnAdd;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CDlgTasks)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CDlgTasks)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBtnadd();
|
||||
afx_msg void OnBtndelete();
|
||||
afx_msg void OnBtndone();
|
||||
afx_msg void OnCloseupCbtasks();
|
||||
afx_msg void OnKillfocusEddescription();
|
||||
afx_msg void OnKillfocusEddetails();
|
||||
afx_msg void OnKillfocusEdminutes();
|
||||
afx_msg void OnCkactive();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_DLGTASKS_H__69649FC1_2BEE_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,206 @@
|
||||
// FindClientDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "FindClientDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CFindClientDlg dialog
|
||||
|
||||
|
||||
CFindClientDlg::CFindClientDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CFindClientDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CFindClientDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
/*
|
||||
rs=new GZRset("Error: Find client dialog");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
*/
|
||||
//Initialize recordset pointer
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CFindClientDlg");
|
||||
rs->Query("SELECT * FROM users WHERE users.id=0");
|
||||
m_pstrReturnValue=NULL;
|
||||
}
|
||||
|
||||
|
||||
CFindClientDlg::~CFindClientDlg()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
void CFindClientDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CFindClientDlg)
|
||||
DDX_Control(pDX, IDC_EDACCT, m_edAccount);
|
||||
DDX_Control(pDX, IDC_LBLRESULTS, m_lblResults);
|
||||
DDX_Control(pDX, IDC_EDSN, m_edSN);
|
||||
DDX_Control(pDX, IDC_EDPHONE, m_edPhone);
|
||||
DDX_Control(pDX, IDC_EDEMAIL, m_edEmail);
|
||||
DDX_Control(pDX, IDC_BTNSEARCH, m_btnSearch);
|
||||
DDX_Control(pDX, IDC_BTNDONE, m_btnDone);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CFindClientDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CFindClientDlg)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
ON_BN_CLICKED(IDC_BTNSEARCH, OnBtnsearch)
|
||||
ON_BN_CLICKED(IDC_BTNCLEAR, OnBtnclear)
|
||||
ON_BN_CLICKED(IDC_BTNCANCEL, OnBtncancel)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CFindClientDlg message handlers
|
||||
|
||||
void CFindClientDlg::OnBtndone()
|
||||
{
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
//****************************************
|
||||
void CFindClientDlg::OnBtnsearch()
|
||||
{
|
||||
CString strData,q;
|
||||
long lData;
|
||||
int x=0;
|
||||
*m_pstrReturnValue="0";
|
||||
m_lblResults.SetWindowText("");
|
||||
|
||||
m_edSN.GetWindowText(strData);
|
||||
|
||||
if(strData.IsEmpty())
|
||||
{
|
||||
m_edPhone.GetWindowText(strData);
|
||||
x=1;
|
||||
}
|
||||
|
||||
|
||||
if(strData.IsEmpty())
|
||||
{
|
||||
m_edEmail.GetWindowText(strData);
|
||||
x=2;
|
||||
}
|
||||
|
||||
|
||||
if(strData.IsEmpty())
|
||||
{
|
||||
m_edAccount.GetWindowText(strData);
|
||||
x=3;
|
||||
}
|
||||
|
||||
if(strData.IsEmpty())
|
||||
return;//nothing entered
|
||||
|
||||
//prepare the query based on what field was filled out
|
||||
switch (x)
|
||||
{
|
||||
case 0://SERIAL NUMBER
|
||||
q.Format("SELECT clients.id, IIf(IsNull([company]),[last] & \", \" & [first],[company]) AS name "
|
||||
"FROM units INNER JOIN clients ON units.client = clients.id "
|
||||
"WHERE (((units.sn)=\"%s\"));",strData);
|
||||
break;
|
||||
|
||||
case 1://PHONE NUMBER
|
||||
q.Format("SELECT clients.id, IIf(IsNull([company]),[last] & \", \" & [first],[company]) AS name "
|
||||
"FROM clients WHERE (((clients.bizphone)=\"%s\"));",strData);
|
||||
break;
|
||||
|
||||
case 2://EMAIL
|
||||
q.Format("SELECT clients.id, IIf(IsNull([company]),[last] & \", \" & [first],[company]) AS name "
|
||||
"FROM clients WHERE (((clients.email)=\"%s\"));",strData);
|
||||
break;
|
||||
|
||||
case 3://Client account number
|
||||
q.Format("SELECT clients.id, IIf(IsNull([company]),[last] & \", \" & [first],[company]) AS name "
|
||||
"FROM clients WHERE (((clients.acctnumber)=\"%s\"));",strData);
|
||||
break;
|
||||
}
|
||||
|
||||
//FUTURE: Modify this to allow for more than one match
|
||||
//FILL a list box or something
|
||||
//AfxMessageBox(q);
|
||||
rs->Query(q);
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
m_lblResults.SetFontBold(FALSE);
|
||||
m_lblResults.SetTextColor(RGB(255,0,0));
|
||||
m_lblResults.SetText("No match found");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lblResults.SetTextColor(RGB(0,0,255));
|
||||
|
||||
m_lblResults.SetFontBold(TRUE);
|
||||
rs->FetchField("name",&strData);
|
||||
strData="Found---> " + strData;
|
||||
m_lblResults.SetText(strData);
|
||||
|
||||
//get the ID value
|
||||
rs->FetchField("id",&lData);
|
||||
m_pstrReturnValue->Format("%u",lData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//****************************************
|
||||
BOOL CFindClientDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
ASSERT(m_pstrReturnValue!=NULL);
|
||||
//Hyperlink find label
|
||||
m_lblResults.SetFontSize(12);
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
//*****************************************
|
||||
void CFindClientDlg::SetReturn(CString *strReturnClientID)
|
||||
{
|
||||
m_pstrReturnValue=strReturnClientID;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*****************************
|
||||
void CFindClientDlg::OnBtnclear()
|
||||
{
|
||||
m_edEmail.SetWindowText("");
|
||||
m_edPhone.SetWindowText("");
|
||||
m_edSN.SetWindowText("");
|
||||
m_lblResults.SetWindowText("");
|
||||
}
|
||||
|
||||
|
||||
//*******************************
|
||||
void CFindClientDlg::OnBtncancel()
|
||||
{
|
||||
*m_pstrReturnValue="0";
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
|
||||
//Do nothing when user presses enter key
|
||||
void CFindClientDlg::OnOK()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
#if !defined(AFX_FINDCLIENTDLG_H__CA8D53C8_2FB6_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_FINDCLIENTDLG_H__CA8D53C8_2FB6_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// FindClientDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CFindClientDlg dialog
|
||||
|
||||
#include "gzrset.h"
|
||||
#include "label.h"
|
||||
|
||||
class CFindClientDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
~CFindClientDlg();
|
||||
void SetReturn(CString* strReturnClientID);
|
||||
CFindClientDlg(CWnd* pParent = NULL); // standard constructor
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
CString * m_pstrReturnValue;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CFindClientDlg)
|
||||
enum { IDD = IDD_FINDCLIENT };
|
||||
CEdit m_edAccount;
|
||||
CLabel m_lblResults;
|
||||
CEdit m_edSN;
|
||||
CEdit m_edPhone;
|
||||
CEdit m_edEmail;
|
||||
CButton m_btnSearch;
|
||||
CButton m_btnDone;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CFindClientDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CFindClientDlg)
|
||||
afx_msg void OnBtndone();
|
||||
afx_msg void OnBtnsearch();
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBtnclear();
|
||||
afx_msg void OnBtncancel();
|
||||
virtual void OnOK();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_FINDCLIENTDLG_H__CA8D53C8_2FB6_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,279 @@
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// File: CFlatHeaderCtrl.h
|
||||
// Version: 1.0.4
|
||||
//
|
||||
// Author: Maarten Hoeben
|
||||
// E-mail: hoeben@nwn.com
|
||||
//
|
||||
// Specification of the CFlatHeaderCtrl and associated classes.
|
||||
//
|
||||
// This code may be used in compiled form in any way you desire. This
|
||||
// file may be redistributed unmodified by any means PROVIDING it is
|
||||
// not sold for profit without the authors written consent, and
|
||||
// providing that this notice and the authors name and all copyright
|
||||
// notices remains intact.
|
||||
//
|
||||
// An email letting me know how you are using it would be nice as well.
|
||||
//
|
||||
// This file is provided "as is" with no expressed or implied warranty.
|
||||
// The author accepts no liability for any damage/loss of business that
|
||||
// this product may cause.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_FLATHEADERCTRL_H__2162BEB4_A882_11D2_B18A_B294B34D6940__INCLUDED_)
|
||||
#define AFX_FLATHEADERCTRL_H__2162BEB4_A882_11D2_B18A_B294B34D6940__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// FlatHeaderCtrl.h : header file
|
||||
//
|
||||
|
||||
#include <afxtempl.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#define FLATHEADER_TEXT_MAX 80
|
||||
#define FLATHEADER_TT_MAGIC -13111971
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CFlatHeaderCtrl window
|
||||
|
||||
class CFlatHeaderCtrl;
|
||||
class CFHDragWnd;
|
||||
class CFHDropWnd;
|
||||
|
||||
#define FH_PROPERTY_SPACING 1
|
||||
#define FH_PROPERTY_ARROW 2
|
||||
#define FH_PROPERTY_STATICBORDER 3
|
||||
#define FH_PROPERTY_DONTDROPCURSOR 4
|
||||
#define FH_PROPERTY_DROPTARGET 5
|
||||
#define FH_PROPERTY_ENABLETOOLTIPS 6
|
||||
|
||||
#define HDF_EX_AUTOWIDTH 0x0001
|
||||
#define HDF_EX_INCLUDESORT 0x0002
|
||||
#define HDF_EX_FIXEDWIDTH 0x0004
|
||||
#define HDF_EX_TOOLTIP 0x0008
|
||||
|
||||
typedef struct _HDITEMEX
|
||||
{
|
||||
UINT nStyle;
|
||||
INT iMinWidth;
|
||||
INT iMaxWidth;
|
||||
CString strToolTip;
|
||||
|
||||
_HDITEMEX() : nStyle(0), iMinWidth(0), iMaxWidth(-1) {};
|
||||
|
||||
} HDITEMEX, FAR* LPHDITEMEX;
|
||||
|
||||
class CFlatHeaderCtrl : public CHeaderCtrl
|
||||
{
|
||||
friend class CFHDragWnd;
|
||||
|
||||
DECLARE_DYNCREATE(CFlatHeaderCtrl)
|
||||
|
||||
// Construction
|
||||
public:
|
||||
CFlatHeaderCtrl();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
BOOL ModifyProperty(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
BOOL GetItemEx(INT iPos, HDITEMEX* phditemex) const;
|
||||
BOOL SetItemEx(INT iPos, HDITEMEX* phditemex);
|
||||
|
||||
INT GetItemWidth(LPHDITEM lphdi, BOOL bIncludeSort = FALSE);
|
||||
|
||||
void SetSortColumn(INT iPos, BOOL bSortAscending);
|
||||
INT GetSortColumn(BOOL* pbSortAscending = NULL);
|
||||
|
||||
INT GetDropResult();
|
||||
|
||||
// Overrides
|
||||
public:
|
||||
int GetHotIndex();
|
||||
int GetHotColumn();
|
||||
TCHAR m_szHotItemText[FLATHEADER_TEXT_MAX];
|
||||
|
||||
virtual ~CFlatHeaderCtrl();
|
||||
|
||||
virtual void DrawItem(LPDRAWITEMSTRUCT);
|
||||
virtual void DrawItem(CDC* pDC, CRect rect, LPHDITEM lphdi, BOOL bSort, BOOL bSortAscending);
|
||||
|
||||
virtual int OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CFlatHeaderCtrl)
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
BOOL m_bDoubleBuffer;
|
||||
INT m_iSpacing;
|
||||
SIZE m_sizeImage;
|
||||
SIZE m_sizeArrow;
|
||||
BOOL m_bStaticBorder;
|
||||
UINT m_nDontDropCursor;
|
||||
HWND m_hDropTarget;
|
||||
CRect m_rcDropTarget;
|
||||
INT m_iDropResult;
|
||||
|
||||
INT m_iHotIndex;
|
||||
INT m_iHotOrder;
|
||||
BOOL m_bHotItemResizable;
|
||||
HDHITTESTINFO m_hdhtiHotItem;
|
||||
HDITEM m_hdiHotItem;
|
||||
// TCHAR m_szHotItemText[FLATHEADER_TEXT_MAX];
|
||||
|
||||
BOOL m_bResizing;
|
||||
|
||||
INT m_iHotDivider;
|
||||
COLORREF m_crHotDivider;
|
||||
CFHDropWnd* m_pDropWnd;
|
||||
|
||||
BOOL m_bDragging;
|
||||
CFHDragWnd* m_pDragWnd;
|
||||
|
||||
UINT m_nClickFlags;
|
||||
CPoint m_ptClickPoint;
|
||||
|
||||
BOOL m_bSortAscending;
|
||||
INT m_iSortColumn;
|
||||
CArray<HDITEMEX, HDITEMEX> m_arrayHdrItemEx;
|
||||
|
||||
COLORREF m_cr3DHighLight;
|
||||
COLORREF m_cr3DShadow;
|
||||
COLORREF m_cr3DFace;
|
||||
COLORREF m_crText;
|
||||
|
||||
void DrawCtrl(CDC* pDC);
|
||||
INT DrawImage(CDC* pDC, CRect rect, LPHDITEM hdi, BOOL bRight);
|
||||
INT DrawBitmap(CDC* pDC, CRect rect, LPHDITEM hdi, CBitmap* pBitmap, BITMAP* pBitmapInfo, BOOL bRight);
|
||||
INT DrawText (CDC* pDC, CRect rect, LPHDITEM lphdi);
|
||||
INT DrawArrow(CDC* pDC, CRect rect, BOOL bSortAscending, BOOL bRight);
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CFlatHeaderCtrl)
|
||||
afx_msg LRESULT OnInsertItem(WPARAM wparam, LPARAM lparam);
|
||||
afx_msg LRESULT OnDeleteItem(WPARAM wparam, LPARAM lparam);
|
||||
afx_msg LRESULT OnSetImageList(WPARAM wparam, LPARAM lparam);
|
||||
afx_msg LRESULT OnSetHotDivider(WPARAM wparam, LPARAM lparam);
|
||||
afx_msg LRESULT OnLayout(WPARAM wparam, LPARAM lparam);
|
||||
afx_msg UINT OnNcHitTest(CPoint point);
|
||||
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
|
||||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
|
||||
afx_msg void OnPaint();
|
||||
afx_msg void OnSysColorChange();
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
||||
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
|
||||
afx_msg void OnCancelMode();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
|
||||
BOOL OnToolTipNotify(UINT nId, NMHDR *pNMHDR, LRESULT *pResult);
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CFHDragWnd window
|
||||
|
||||
#define FHDRAGWND_CLASSNAME _T("MFCFHDragWnd")
|
||||
|
||||
class CFHDragWnd : public CWnd
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CFHDragWnd();
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrrides
|
||||
protected:
|
||||
// Drawing
|
||||
virtual void OnDraw(CDC* pDC);
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CFHDragWnd)
|
||||
protected:
|
||||
virtual void PostNcDestroy();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CFHDragWnd();
|
||||
virtual BOOL Create(CRect rect, CFlatHeaderCtrl* pFlatHeaderCtrl, INT iItem, LPHDITEM lphdiItem);
|
||||
|
||||
protected:
|
||||
CFlatHeaderCtrl* m_pFlatHeaderCtrl;
|
||||
INT m_iItem;
|
||||
LPHDITEM m_lphdiItem;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CFHDragWnd)
|
||||
afx_msg void OnPaint();
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CFHDropWnd window
|
||||
|
||||
#define FHDROPWND_CLASSNAME _T("MFCFHDropWnd")
|
||||
|
||||
class CFHDropWnd : public CWnd
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CFHDropWnd(COLORREF crColor);
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
void SetWindowPos(INT x, INT y);
|
||||
|
||||
// Overrrides
|
||||
protected:
|
||||
// Drawing
|
||||
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CFHDropWnd)
|
||||
protected:
|
||||
virtual void PostNcDestroy();
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CFHDropWnd();
|
||||
virtual BOOL Create(INT iHeight);
|
||||
|
||||
protected:
|
||||
CBrush m_brush;
|
||||
CRgn m_rgn;
|
||||
|
||||
INT m_iHeight;
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CFHDropWnd)
|
||||
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_FLATHEADERCTRL_H__2162BEB4_A882_11D2_B18A_B294B34D6940__INCLUDED_)
|
||||
395
archive/ayanova 1.9.4 CE final release db schema 171/sp/GZK.cpp
Normal file
395
archive/ayanova 1.9.4 CE final release db schema 171/sp/GZK.cpp
Normal file
@@ -0,0 +1,395 @@
|
||||
// GZK.cpp: implementation of the GZK class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
|
||||
|
||||
#include "GZK.h"
|
||||
|
||||
#include "c:\data\projects\crypto31\config.h"
|
||||
#include "c:\data\projects\crypto31\twofish.h"
|
||||
#include "c:\data\projects\crypto31\base64.h"
|
||||
#include "c:\data\projects\crypto31\cbc.h"
|
||||
#include "c:\data\projects\crypto31\hex.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
USING_NAMESPACE(CryptoPP)
|
||||
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//this is an index into the key table. The key used will be the 16 bytes
|
||||
//that can be found starting at the following index location in the key table
|
||||
#define PRODUCT_UNIQUE_KEY_VALUE 235
|
||||
|
||||
|
||||
|
||||
BYTE GZ_KEY_TABLE[]={
|
||||
187,71,225,207,126,247,40,49,245,248,41,95,30,172,209,92,
|
||||
251,217,54,171,87,33,139,104,51,154,59,77,234,128,157,33,
|
||||
44,189,42,240,43,191,100,190,134,158,53,70,74,133,43,163,
|
||||
118,13,181,228,137,246,201,106,241,18,187,16,205,83,181,40,
|
||||
39,237,51,11,56,132,87,36,153,151,179,142,28,11,170,241,
|
||||
80,113,176,121,56,163,149,150,191,169,237,145,7,115,245,131,
|
||||
103,232,19,249,190,241,6,48,51,149,89,189,53,208,34,51,
|
||||
235,201,39,149,103,137,140,183,74,69,106,40,22,200,111,173,
|
||||
2,67,130,43,176,142,218,184,132,219,215,80,80,4,1,44,
|
||||
172,81,50,146,21,148,53,99,83,4,157,61,204,199,12,15,
|
||||
160,145,26,226,16,228,127,208,43,36,78,250,39,2,128,69,
|
||||
136,40,109,159,177,113,134,181,136,224,154,150,211,117,185,220,
|
||||
30,176,248,143,42,52,180,194,156,244,105,3,252,172,242,143,
|
||||
180,41,215,27,18,221,148,143,242,181,213,173,49,121,82,38,
|
||||
216,73,206,46,240,240,72,176,223,6,167,249,14,157,185,114,
|
||||
179,55,141,89,57,184,12,14,195,94,141,117,13,74,183,108,
|
||||
238,214,187,168,186,235,84,148,21,195,81,78,26,95,192,120,
|
||||
110,208,98,248,1,117,159,251,7,111,202,108,29,59,125,80,
|
||||
73,176,108,212,123,217,241,131,244,31,79,34,49,91,6,253,
|
||||
239,214,174,240,125,210,17,14,158,68,125,193,208,3,128,61,
|
||||
69,213,186,179,126,240,80,121,216,25,109,161,36,50,118,208,
|
||||
239,226,107,27,225,246,171,36,167,66,52,141,160,244,128,179,
|
||||
132,98,53,227,20,195,34,42,84,2,164,45,246,92,15,187,
|
||||
222,68,188,201,239,131,227,228,38,135,41,96,17,235,202,81,
|
||||
85,137,239,34,13,185,153,188,185,123,55,113,46,169,82,122,
|
||||
78,177,69,188,106,23,31,73,182,159,127,123,101,255,86,83,0,0,0,0};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Constructor, the key sets here
|
||||
GZK::GZK()
|
||||
{
|
||||
Key = new BYTE[16];//= GZ_KEY_TABLE;
|
||||
memcpy(Key,GZ_KEY_TABLE+PRODUCT_UNIQUE_KEY_VALUE,16);
|
||||
|
||||
}
|
||||
|
||||
|
||||
GZK::~GZK()
|
||||
{
|
||||
//destructor: since the decryption is done on an object passed in there is no wiping necessary?
|
||||
delete Key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void GZK::GZEncrypt(CString *src,bool hex)
|
||||
{
|
||||
char* instr;
|
||||
unsigned int c=src->GetLength();
|
||||
instr=new char[c+1];
|
||||
lstrcpy(instr,*src);
|
||||
char* outstr;
|
||||
char* retstr;
|
||||
TwofishEncryption* e;
|
||||
CBCPaddedEncryptor* enc;
|
||||
e=new TwofishEncryption(Key);
|
||||
enc=new CBCPaddedEncryptor(*e,Key);
|
||||
|
||||
enc->Put((byte *)instr, c);
|
||||
enc->Close();
|
||||
|
||||
c = enc->MaxRetrieveable();
|
||||
outstr = new char[c+1];
|
||||
enc->Get((byte *)outstr, c);
|
||||
outstr[c] = 0;
|
||||
|
||||
if(hex==false)
|
||||
{
|
||||
Base64Encoder e64;
|
||||
e64.Put((byte*)outstr,c);
|
||||
e64.Close();
|
||||
c=e64.MaxRetrieveable();
|
||||
retstr = new char[c+1];
|
||||
e64.Get((byte *)retstr,c);
|
||||
retstr[c]=0;
|
||||
retstr[c-1]=0;
|
||||
//b64str[c-2]=0;
|
||||
//b64str[c-3]=0;
|
||||
src->Format("%s",retstr);
|
||||
}
|
||||
else
|
||||
{
|
||||
HexEncoder he;
|
||||
he.Put((byte*)outstr,c);
|
||||
he.Close();
|
||||
c=he.MaxRetrieveable();
|
||||
retstr = new char[c+1];
|
||||
he.Get((byte *)retstr,c);
|
||||
retstr[c]=0;
|
||||
//retstr[c-1]=0;
|
||||
//b64str[c-2]=0;
|
||||
//b64str[c-3]=0;
|
||||
src->Format("%s",retstr);
|
||||
|
||||
}
|
||||
delete instr;
|
||||
delete e;
|
||||
delete enc;
|
||||
delete outstr;
|
||||
delete retstr;
|
||||
|
||||
}
|
||||
|
||||
void GZK::GZDecrypt(CString *src, bool hex)
|
||||
{ char* instr;
|
||||
unsigned int c=src->GetLength();
|
||||
instr=new char[c+1];
|
||||
lstrcpy(instr,*src);
|
||||
char* outstr;
|
||||
char* str;
|
||||
TwofishDecryption* d ;
|
||||
CBCPaddedDecryptor* dec;
|
||||
d=new TwofishDecryption(Key);
|
||||
dec=new CBCPaddedDecryptor(*d,Key);
|
||||
|
||||
|
||||
|
||||
if(hex==false)
|
||||
{
|
||||
Base64Decoder d64;
|
||||
d64.Put((byte*)instr,c);
|
||||
d64.Close();
|
||||
c=d64.MaxRetrieveable();
|
||||
str = new char[c];
|
||||
d64.Get((byte *)str,c);
|
||||
}
|
||||
else
|
||||
{
|
||||
HexDecoder hd;
|
||||
hd.Put((byte*)instr,c);
|
||||
hd.Close();
|
||||
c=hd.MaxRetrieveable();
|
||||
str = new char[c];
|
||||
hd.Get((byte *)str,c);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
dec->Put((byte *)str, c);
|
||||
dec->Close();
|
||||
c =dec->MaxRetrieveable();
|
||||
outstr = new char[c+1];
|
||||
dec->Get((byte *)outstr, c);
|
||||
outstr[c] = 0;
|
||||
|
||||
|
||||
src->Format("%s",outstr);
|
||||
|
||||
//wipe the memory contents before it goes out of scope
|
||||
memset(outstr,'\0',c);
|
||||
|
||||
delete d;
|
||||
delete dec;
|
||||
delete str;
|
||||
delete outstr;
|
||||
delete instr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//************* take an encrypted string and
|
||||
//************* display a decrypted version in a messagebox
|
||||
//display is a smokescreen, if less than 128 will not display message
|
||||
void GZK::gzMsgBox(char *cryptmsg,int display)
|
||||
{
|
||||
|
||||
CString msg;
|
||||
msg.Format("%s",cryptmsg);
|
||||
GZDecrypt(&msg,false);
|
||||
msg.Replace("~","\r\n");
|
||||
if(display<GZ_KEY_TABLE[174]) return;//dont display anything if less than 128
|
||||
AfxMessageBox(msg);
|
||||
}
|
||||
|
||||
|
||||
//******************* make a hash *********************
|
||||
//takes a string and changes it to the hash of the
|
||||
//original string.
|
||||
/*
|
||||
void GZK::GZHash(CString* src)
|
||||
{
|
||||
int x=src->GetLength();
|
||||
|
||||
unsigned char *str = new unsigned char[x];
|
||||
|
||||
|
||||
lstrcpy((char*)str, *src);
|
||||
|
||||
unsigned long hash = 5381;
|
||||
int c;
|
||||
while (c = *str++)
|
||||
hash = ((hash << 5) + hash) + c; // hash * 33 + c
|
||||
|
||||
src->Format("%u",hash);
|
||||
|
||||
//_CrtDumpMemoryLeaks();
|
||||
}
|
||||
*/
|
||||
//******************* make a djb2 hash *********************
|
||||
//takes a string of at most 200 bytes!!!
|
||||
//and changes it to the hash of the original string.
|
||||
//http://www.cs.yorku.ca/~oz/hash.html
|
||||
void GZK::GZHash(CString* src)
|
||||
{
|
||||
ASSERT(src->GetLength()< 190);//we can always increase it later
|
||||
//note:hash is performed on user first/last name and company name
|
||||
//company is max 75, user first and last is max 100+11others so
|
||||
//200 is assumed to be a very safe fixed amount
|
||||
//this function should be modified as before, but if less than
|
||||
//a certain amount then pads to avoid overwriting other memory.
|
||||
unsigned char *str = new unsigned char[200];
|
||||
unsigned char* placeholder=str;
|
||||
|
||||
lstrcpy((char*)str, *src);
|
||||
|
||||
unsigned long hash = 5381;
|
||||
int c;
|
||||
while (c = *str++)
|
||||
hash = ((hash << 5) + hash) + c; // hash * 33 + c
|
||||
|
||||
src->Format("%u",hash);
|
||||
delete placeholder;
|
||||
|
||||
//_CrtDumpMemoryLeaks();
|
||||
}
|
||||
|
||||
|
||||
//takes a pointer to two cstring objects, one contains the encrypted key
|
||||
//the other the plaintext client name
|
||||
//returns: a string of random characters whose total count of characters equals the
|
||||
//feature code enabled. On failure returns a random string of characters of a count that
|
||||
//is not equal to a known feature code.
|
||||
//==================
|
||||
|
||||
//decrypts the key and gets a string formatted like this:
|
||||
//Hash of clients name---->2345345345345,255<--feature code, one byte
|
||||
//separates the feature code
|
||||
//from the hash of the clients name,
|
||||
//hashes the clients name passed in,
|
||||
//compares the hash from key with the clients name hash
|
||||
//if hash ok then starts a loop from 1 to x where
|
||||
//x = the feature code byte value. Inserts a random
|
||||
//character into the keytag string each loop
|
||||
|
||||
void GZK::ValidateKey(CString *keytag,CString* custname,bool hex)
|
||||
{
|
||||
CString hash,features,hash2;
|
||||
int comma;
|
||||
//decrypt the key
|
||||
GZDecrypt(keytag,hex);
|
||||
|
||||
//split the key
|
||||
hash=keytag->SpanExcluding(",");
|
||||
comma=keytag->ReverseFind(',');
|
||||
features=keytag->Right(keytag->GetLength()-comma-1);
|
||||
comma=atoi(features.GetBuffer(999));
|
||||
|
||||
hash2.Format("%s",*custname);
|
||||
GZHash(&hash2);
|
||||
if(hash2==hash)//ok key
|
||||
{
|
||||
hex=false;//smoke
|
||||
custname->Format("%s","sadifjaskdfi");//and mirrors
|
||||
hash="";
|
||||
for(int x=0;x<comma;x++)
|
||||
hash+='t';
|
||||
|
||||
}
|
||||
else//bad key
|
||||
{
|
||||
hex=true;//smoke
|
||||
custname->Format("%s","ibmisdlmbir");//and mirrors
|
||||
hash="";
|
||||
for(int x=0;x<comma+GZ_KEY_TABLE[175];x++)//gzkey=69 at 175.
|
||||
hash+='t';
|
||||
}
|
||||
|
||||
keytag->Format("%s",hash);
|
||||
|
||||
|
||||
}
|
||||
|
||||
CString GZK::InLineDecrypt(char *str)
|
||||
{
|
||||
|
||||
CString text=str;
|
||||
GZDecrypt(&text,false);//always b64 for inline
|
||||
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
|
||||
//set a unique offset value to work with
|
||||
//this avoids using the built in key for uses
|
||||
//where you don't want exposure (known plain and cypher for example)
|
||||
void GZK::GZSetUniqueKey(int nOffset)
|
||||
{
|
||||
ASSERT(nOffset<400);
|
||||
memcpy(Key,GZ_KEY_TABLE+nOffset,16);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//encode a passed memory block into b64 text
|
||||
//need this for saving memory blocks to database
|
||||
//as text items (i.e. printer DEVMODE structure)
|
||||
CString GZK::EncodeB64(char *input, int size)
|
||||
{
|
||||
|
||||
|
||||
CString retString;
|
||||
unsigned int c=size;
|
||||
char* retstr;
|
||||
|
||||
Base64Encoder e64;
|
||||
e64.Put((byte*)input,c);
|
||||
e64.Close();
|
||||
c=e64.MaxRetrieveable();
|
||||
retstr = new char[c+1];
|
||||
e64.Get((byte *)retstr,c);
|
||||
retstr[c]=0;
|
||||
retstr[c-1]=0;
|
||||
|
||||
retString.Format("%s",retstr);
|
||||
delete retstr;
|
||||
return retString;
|
||||
}
|
||||
|
||||
void GZK::DecodeB64(CString* input, char* retblock)
|
||||
{
|
||||
|
||||
char* instr;
|
||||
unsigned int c=input->GetLength();
|
||||
instr=new char[c+1];
|
||||
lstrcpy(instr,*input);
|
||||
|
||||
Base64Decoder d64;
|
||||
d64.Put((byte*)instr,c);
|
||||
d64.Close();
|
||||
c=d64.MaxRetrieveable();
|
||||
d64.Get((byte *)retblock,c);
|
||||
delete instr;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
// GZK.h: interface for the GZK class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_GZK_H__5EE92AC5_D7E8_11D3_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_GZK_H__5EE92AC5_D7E8_11D3_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
|
||||
|
||||
/*
|
||||
#define GZ_KEY2 {44,189,42,240,43,191,100,190,134,158,53,70,74,133,43,163}
|
||||
#define GZ_KEY3 {118,13,181,228,137,246,201,106,241,18,187,16,205,83,181,40}
|
||||
#define GZ_KEY4 {39,237,51,11,56,132,87,36,153,151,179,142,28,11,170,241}
|
||||
#define GZ_KEY5 {80,113,176,121,56,163,149,150,191,169,237,145,7,115,245,131}
|
||||
#define GZ_KEY6 {103,232,19,249,190,241,6,48,51,149,89,189,53,208,34,51}
|
||||
#define GZ_KEY7 {235,201,39,149,103,137,140,183,74,69,106,40,22,200,111,173}
|
||||
#define GZ_KEY8 {2,67,130,43,176,142,218,184,132,219,215,80,80,4,1,44}
|
||||
#define GZ_KEY9 {172,81,50,146,21,148,53,99,83,4,157,61,204,199,12,15}
|
||||
#define GZ_KEY10 {160,145,26,226,16,228,127,208,43,36,78,250,39,2,128,69}
|
||||
#define GZ_KEY11 {136,40,109,159,177,113,134,181,136,224,154,150,211,117,185,220}
|
||||
#define GZ_KEY12 {30,176,248,143,42,52,180,194,156,244,105,3,252,172,242,143}
|
||||
#define GZ_KEY13 {180,41,215,27,18,221,148,143,242,181,213,173,49,121,82,38}
|
||||
#define GZ_KEY14 {216,73,206,46,240,240,72,176,223,6,167,249,14,157,185,114}
|
||||
#define GZ_KEY15 {179,55,141,89,57,184,12,14,195,94,141,117,13,74,183,108}
|
||||
#define GZ_KEY16 {238,214,187,168,186,235,84,148,21,195,81,78,26,95,192,120}
|
||||
#define GZ_KEY17 {110,208,98,248,1,117,159,251,7,111,202,108,29,59,125,80}
|
||||
#define GZ_KEY18 {73,176,108,212,123,217,241,131,244,31,79,34,49,91,6,253}
|
||||
#define GZ_KEY19 {239,214,174,240,125,210,17,14,158,68,125,193,208,3,128,61}
|
||||
#define GZ_KEY20 {69,213,186,179,126,240,80,121,216,25,109,161,36,50,118,208}
|
||||
#define GZ_KEY21 {239,226,107,27,225,246,171,36,167,66,52,141,160,244,128,179}
|
||||
#define GZ_KEY22 {132,98,53,227,20,195,34,42,84,2,164,45,246,92,15,187}
|
||||
#define GZ_KEY23 {222,68,188,201,239,131,227,228,38,135,41,96,17,235,202,81}
|
||||
#define GZ_KEY24 {85,137,239,34,13,185,153,188,185,123,55,113,46,169,82,122}
|
||||
#define GZ_KEY25 {78,177,69,188,106,23,31,73,182,159,127,123,101,255,86,83}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
class GZK
|
||||
{
|
||||
public:
|
||||
void DecodeB64(CString* input, char* retblock);
|
||||
CString EncodeB64(char * input,int size);
|
||||
void GZSetUniqueKey(int nOffset);
|
||||
CString InLineDecrypt(char* str);
|
||||
void ValidateKey(CString *keytag,CString* custname, bool hex);
|
||||
void GZHash(CString *src);
|
||||
void gzMsgBox(char * cryptmsg,int display);
|
||||
void GZDecrypt(CString *src, bool hex);
|
||||
void GZEncrypt(CString * src, bool hex);
|
||||
GZK();
|
||||
virtual ~GZK();
|
||||
BYTE* Key;
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_GZK_H__5EE92AC5_D7E8_11D3_964F_00C0F02C4B69__INCLUDED_)
|
||||
2220
archive/ayanova 1.9.4 CE final release db schema 171/sp/GZRset.cpp
Normal file
2220
archive/ayanova 1.9.4 CE final release db schema 171/sp/GZRset.cpp
Normal file
File diff suppressed because it is too large
Load Diff
135
archive/ayanova 1.9.4 CE final release db schema 171/sp/GZRset.h
Normal file
135
archive/ayanova 1.9.4 CE final release db schema 171/sp/GZRset.h
Normal file
@@ -0,0 +1,135 @@
|
||||
// GZRset.h: interface for the CGZRset class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_GZRSET_H__31F5EB01_0F99_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_GZRSET_H__31F5EB01_0F99_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
//NOTE: Un comment this to log database calls to disk
|
||||
|
||||
|
||||
//#define _RSTRACE_ 1
|
||||
|
||||
|
||||
|
||||
#ifdef _RSTRACE_
|
||||
#include "logtrace.h"
|
||||
#endif
|
||||
|
||||
|
||||
class GZRset
|
||||
{
|
||||
public:
|
||||
//Added 08/03/2001
|
||||
bool m_bSupressErrors;
|
||||
bool m_bSQLServer;
|
||||
int FetchFieldType(CString fld);
|
||||
_ConnectionPtr pTheConnection;
|
||||
CString SetFieldToMemo(CString fld);
|
||||
void SetErrMsg(CString strErrorID);
|
||||
CString m_strLastQuery;
|
||||
CString GetRSInfo();
|
||||
bool m_bRSPRINT;
|
||||
bool m_bPrinting;
|
||||
int m_nID;
|
||||
bool m_bReserved;
|
||||
bool SetToPrint(bool bPrinting);
|
||||
bool m_bInUse;
|
||||
bool m_bExclusiveConnection;
|
||||
CString m_strCloseQuery;
|
||||
void SetErrorMsg(CString strError);
|
||||
void Initialize(CString strError);
|
||||
CString m_strLiveConnectString;
|
||||
CString m_strLiveConnectStringExclusive ;
|
||||
CString m_strDeadConnectString;
|
||||
bool m_bIsClosed;
|
||||
bool Valid();
|
||||
CString GetLastError();
|
||||
|
||||
bool Query(CString strQuery);
|
||||
bool QueryReadOnly(CString strQuery);
|
||||
bool m_bForwardOnly;
|
||||
|
||||
bool Close();
|
||||
|
||||
_RecordsetPtr RecordSetPointer();
|
||||
|
||||
bool SaveRecord();
|
||||
bool AddNewRecord();
|
||||
|
||||
//old execute queries, should be removed
|
||||
//once no longer used anywhere else
|
||||
//bool Execute(CString strQuery);
|
||||
//bool Execute(CString strQuery, long* lIdentity);
|
||||
|
||||
//New execute queries
|
||||
bool Ex(CString strQuery);
|
||||
bool Ex(CString strQuery, long* lIdentity);
|
||||
|
||||
bool MoveBack();
|
||||
bool MoveForward();
|
||||
bool MoveLast();
|
||||
bool MoveFirst();
|
||||
|
||||
|
||||
|
||||
bool IsEmpty();
|
||||
bool FetchAllTextFieldsAsOneString( CString *strValue);
|
||||
bool FetchAnyFieldAsString(CString fld, CString* strValue);
|
||||
bool FetchField(CString fld, long* lValue);
|
||||
bool FetchField(CString fld, float* fValue);
|
||||
bool FetchField(CString fld, bool* bValue);
|
||||
bool FetchField(CString fld, CString *strValue);
|
||||
bool FetchField(CString fld, COleDateTime *dtValue);
|
||||
bool FetchField(CString fld, COleCurrency *crValue);
|
||||
//Byte type defined as 0-255
|
||||
bool FetchField(CString fld, unsigned char* byteValue);
|
||||
|
||||
bool UpdateField(CString fld, long* lValue);
|
||||
bool UpdateField(CString fld, float* fValue);
|
||||
bool UpdateField(CString fld, bool* bValue);
|
||||
bool UpdateField(CString fld, CString *strValue);
|
||||
bool UpdateField(CString fld, COleDateTime *dtValue);
|
||||
bool UpdateField(CString fld, COleCurrency *crValue);
|
||||
//byte value defined as 0-255
|
||||
bool UpdateField(CString fld, unsigned char* byteValue);
|
||||
|
||||
long FetchRecordCount();
|
||||
void SetConnect(CString str);
|
||||
|
||||
//OBSOLETE
|
||||
/*
|
||||
bool OpenForwardOnly(CString strQuery);
|
||||
bool Open(CString strQuery);
|
||||
bool Open();
|
||||
bool ChangeCursorLocation(bool bUseClient);
|
||||
bool Flush(_ConnectionPtr pConnection);
|
||||
*/
|
||||
//========================
|
||||
GZRset(CString strErr);
|
||||
GZRset(CString strErr,bool bUseClientCursor);
|
||||
virtual ~GZRset();
|
||||
private:
|
||||
#ifdef _RSTRACE_
|
||||
CLogTrace* log;
|
||||
#endif
|
||||
_ConnectionPtr pConnection;
|
||||
CString m_strErrMsg;
|
||||
CString m_strLastError;//last error string
|
||||
//string because it seems to be the only reliable
|
||||
//error message you get with ADO
|
||||
bool m_bNoRecords;
|
||||
long m_lRecordCount;
|
||||
_RecordsetPtr m_pRecordSet;
|
||||
bool m_bOpen;
|
||||
long m_lCurrentRecord;
|
||||
CString m_strConnect;
|
||||
public:
|
||||
// Forces updates within transactions for immediate write purposes only (not for it's intended purpose)
|
||||
bool m_bUseTransactions;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_GZRSET_H__31F5EB01_0F99_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,867 @@
|
||||
// GZRsetPool.cpp: implementation of the CGZRsetPool class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "GZRsetPool.h"
|
||||
#include "TED.H"
|
||||
#ifdef _DEBUG
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[]=__FILE__;
|
||||
#define new DEBUG_NEW
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
CGZRsetPool::CGZRsetPool()
|
||||
{
|
||||
|
||||
//IMPORTANT: to avoid memory fragmentation set this
|
||||
//value to something higher than the highest amount used
|
||||
//pool.SetSize(10);
|
||||
|
||||
//used to track how many were allocated
|
||||
//in order to set the pool size adequately
|
||||
m_nTotalAllocated=0;
|
||||
|
||||
//default is JET
|
||||
m_bSQLServer=false;
|
||||
|
||||
//Added 08/03/2001 to hide errors on update
|
||||
m_bSupressErrors=false;
|
||||
|
||||
m_bUseTransactions=false;
|
||||
|
||||
//TEST TEST TEST
|
||||
pConnection=NULL;
|
||||
}
|
||||
|
||||
CGZRsetPool::~CGZRsetPool()
|
||||
{
|
||||
//dump any allocated recordsets if any
|
||||
Empty();
|
||||
|
||||
}
|
||||
|
||||
//return a free recordset
|
||||
//sets nRSID to the unique serial number of this rs
|
||||
//for identification when closing later
|
||||
GZRset * CGZRsetPool::GetRS(CString strCallerInfo)
|
||||
{
|
||||
GZRset* rs;
|
||||
int x;
|
||||
x=GetFreeRecordsetID(false);
|
||||
rs=(GZRset*)pool.GetAt(x);
|
||||
ASSERT(rs!=NULL);
|
||||
rs->Close();
|
||||
rs->m_bExclusiveConnection=false;
|
||||
|
||||
TRACE("\r\n*******************************\r\n"
|
||||
"[ %i ] - total recordsets in the pool.\r\n"
|
||||
"*******************************\r\n"
|
||||
,m_nTotalAllocated);
|
||||
|
||||
rs->m_bRSPRINT=false;
|
||||
|
||||
//added Sept 30th 2002
|
||||
//ensures on a change of use transactions
|
||||
//that previously allocated rs's are set correctly
|
||||
//when first accessed
|
||||
rs->m_bUseTransactions=m_bUseTransactions;
|
||||
|
||||
rs->SetErrMsg(strCallerInfo);
|
||||
return rs;
|
||||
|
||||
}
|
||||
|
||||
//return a free recordset
|
||||
//sets nRSID to the unique serial number of this rs
|
||||
//for identification when closing later
|
||||
GZRset * CGZRsetPool::GetRSPrint(CString strCallerInfo)
|
||||
{
|
||||
GZRset* rs;
|
||||
int x;
|
||||
x=GetFreeRecordsetID(true);
|
||||
rs=(GZRset*)pool.GetAt(x);
|
||||
ASSERT(rs!=NULL);
|
||||
rs->Close();
|
||||
rs->m_bExclusiveConnection=false;
|
||||
|
||||
TRACE("\r\n*******************************\r\n"
|
||||
"[ %i ] - total recordsets in the pool.\r\n"
|
||||
"*******************************\r\n"
|
||||
,m_nTotalAllocated);
|
||||
|
||||
rs->m_bRSPRINT=true;
|
||||
rs->SetErrMsg(strCallerInfo);
|
||||
return rs;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//flag recordset nRSID as available
|
||||
bool CGZRsetPool::ReleaseRS(int* nID)
|
||||
{
|
||||
|
||||
GZRset* rs;
|
||||
rs=(GZRset*)pool.GetAt(*nID);
|
||||
ASSERT(rs!=NULL);
|
||||
//close it up just in case,
|
||||
//safe to call this repeatedly,
|
||||
//it just returns if already closed
|
||||
|
||||
rs->Close();
|
||||
|
||||
//Throw the RS back in the pool
|
||||
rs->m_bReserved=false;
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
//empty the pool
|
||||
//(delete all recordset objects)
|
||||
void CGZRsetPool::Empty()
|
||||
{
|
||||
int x;
|
||||
GZRset* rs;
|
||||
|
||||
if(m_nTotalAllocated>0)
|
||||
{
|
||||
for(x=0;x<m_nTotalAllocated;x++)
|
||||
{
|
||||
rs=(GZRset*)pool.GetAt(x);
|
||||
rs->Close();
|
||||
delete rs;
|
||||
|
||||
}
|
||||
|
||||
m_nTotalAllocated=0;
|
||||
}
|
||||
|
||||
//added March 22 2001 on a whim
|
||||
pool.RemoveAll();
|
||||
}
|
||||
|
||||
|
||||
//RETURNS the pool objarray index value of a free
|
||||
//recordset, also sets the recordset as in use
|
||||
int CGZRsetPool::GetFreeRecordsetID(bool bPrint)
|
||||
{
|
||||
|
||||
int x;
|
||||
|
||||
if(m_nTotalAllocated==0)//none made yet
|
||||
{
|
||||
|
||||
rsGENERIC = new GZRset("Allocated First");
|
||||
InitializeNewRS(rsGENERIC,bPrint);
|
||||
|
||||
x=pool.Add((CObject*)rsGENERIC);
|
||||
|
||||
//set this recordset's ID value
|
||||
rsGENERIC->m_nID=x;
|
||||
|
||||
//Increment the recordsets allocated counter
|
||||
m_nTotalAllocated++;
|
||||
return x;
|
||||
}
|
||||
|
||||
//there are some allocated, see if any are free
|
||||
for(int y=0; y<m_nTotalAllocated; y++)
|
||||
{
|
||||
rsGENERIC=(GZRset*)pool.GetAt(y);
|
||||
//rsGENERIC=pool.GetAt(y);
|
||||
if(rsGENERIC->m_bReserved==false)//is it free for use?
|
||||
{
|
||||
rsGENERIC->m_bReserved=true;
|
||||
return y;
|
||||
}
|
||||
}
|
||||
|
||||
//There are none free so we have to add one now
|
||||
rsGENERIC = new GZRset("Allocated");
|
||||
InitializeNewRS(rsGENERIC, bPrint);
|
||||
x=pool.Add((CObject*)rsGENERIC);
|
||||
|
||||
//set this recordset's ID value
|
||||
rsGENERIC->m_nID=x;
|
||||
|
||||
m_nTotalAllocated++;
|
||||
|
||||
//arbitrary test value
|
||||
ASSERT(m_nTotalAllocated<50);
|
||||
|
||||
return x;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool CGZRsetPool::InitializeNewRS(GZRset *rs,bool bPrint)
|
||||
{
|
||||
ASSERT(rs!=NULL);
|
||||
|
||||
//TEST TEST TEST
|
||||
ASSERT(pConnection!=NULL);
|
||||
rs->pTheConnection=pConnection;
|
||||
//set initial connection strings here
|
||||
rs->SetConnect(strConnectString);
|
||||
|
||||
//Set standard connection string here
|
||||
rs->m_strLiveConnectString=m_strLiveConnectString;
|
||||
|
||||
//Set exclusive connection string here
|
||||
rs->m_strLiveConnectStringExclusive=m_strLiveConnectStringExclusive;
|
||||
|
||||
//Set DEAD connect string: point to the empty database file
|
||||
rs->m_strDeadConnectString=m_strDeadConnectString;
|
||||
|
||||
//query to execute against the empty database file
|
||||
//to ensure the original connection gets closed
|
||||
//to the live database file
|
||||
rs->m_strCloseQuery=m_strCloseQuery;
|
||||
|
||||
//Take it out of the pool
|
||||
rs->m_bReserved=true;
|
||||
|
||||
//Added May21 2001 SQL server stuff
|
||||
rs->m_bSQLServer=m_bSQLServer;
|
||||
|
||||
//Added 08/03/2001
|
||||
rs->m_bSupressErrors=m_bSupressErrors;
|
||||
|
||||
//added 09/30/2002
|
||||
rs->m_bUseTransactions=m_bUseTransactions;
|
||||
|
||||
//This is now the first database call as of
|
||||
//December 8 2000
|
||||
rs->Close();
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
//Diagnostic routine
|
||||
void CGZRsetPool::ShowAllOpenRS()
|
||||
{
|
||||
int x;
|
||||
GZRset* rs;
|
||||
CString strMsg;
|
||||
if(m_nTotalAllocated>0)
|
||||
{
|
||||
strMsg.Format("Total recordsets allocated:%i\r\n",m_nTotalAllocated);
|
||||
for(x=0;x<m_nTotalAllocated;x++)
|
||||
{
|
||||
rs=(GZRset*)pool.GetAt(x);
|
||||
|
||||
strMsg+=rs->m_bInUse ? "** RS IS ACTIVE **":".. RS NOT ACTIVE ..";
|
||||
strMsg=strMsg+rs->GetRSInfo()+"\r\n"+rs->m_strLastQuery+"\r\n";
|
||||
strMsg+="\r\n---------------------------------\r\n";
|
||||
|
||||
|
||||
}
|
||||
CTED d;
|
||||
d.m_strText=strMsg;
|
||||
d.DoModal();
|
||||
|
||||
}
|
||||
else
|
||||
AfxMessageBox("No recordsets in use");
|
||||
|
||||
}
|
||||
|
||||
void CGZRsetPool::StartConnection()
|
||||
{
|
||||
//create a pointer to a connection
|
||||
//_ConnectionPtr pConnection = NULL;
|
||||
try{
|
||||
//instantiate it:
|
||||
pConnection.CreateInstance(__uuidof(Connection));
|
||||
|
||||
//get connect string
|
||||
_bstr_t strCnn(m_strLiveConnectString);
|
||||
|
||||
//open the connection
|
||||
//this will THROW if the database is corrupted
|
||||
pConnection->Open (strCnn, "", "", adConnectUnspecified);
|
||||
|
||||
|
||||
|
||||
DisplayProperties();
|
||||
}
|
||||
catch (_com_error &e)
|
||||
{
|
||||
|
||||
|
||||
CString cstrErrMsg,strEx;HRESULT hr=e.Error();
|
||||
int nReason=0;
|
||||
// get info from com error
|
||||
_bstr_t bstrSource(e.Source());
|
||||
_bstr_t bstrDescription(e.Description());
|
||||
CString str((BSTR)bstrDescription);
|
||||
//Decode error message from JET (hope it's in english)
|
||||
//because Microsoft doesn't pass through the original jet error
|
||||
//only the MDAC general error 80004005
|
||||
if(str.Find("File Already in Use")!=-1)
|
||||
nReason=1;//locked exclusive / no rights\
|
||||
|
||||
if(str.Find("The Microsoft Jet database engine cannot open the file '(unknown)'")!=-1)
|
||||
nReason=1;//locked exclusive / no rights\
|
||||
|
||||
if(str.Find("Name Not Found")!=-1)
|
||||
nReason=2;//file not found
|
||||
|
||||
if(str.Find("Unrecognized database format")!=-1)
|
||||
nReason=3;//corrupt or not a database.
|
||||
|
||||
|
||||
switch(nReason)
|
||||
{
|
||||
case 0://unknown error
|
||||
strEx="";
|
||||
break;
|
||||
|
||||
case 1://exclusive or no rights
|
||||
strEx="Common causes for this error:\r\n"
|
||||
"1) Insufficient rights to the database folder and file\r\n"
|
||||
"(check that you have full access rights to the database folder)\r\n"
|
||||
"\r\n"
|
||||
"2) Database file is already open in exclusive only mode by another user or program.\r\n"
|
||||
"(check if another program has the database open such as Access\r\n"
|
||||
"in exclusive only mode)\r\n\r\n";
|
||||
break;
|
||||
|
||||
case 2://file not found
|
||||
strEx="Common causes for this error:\r\n"
|
||||
"1) The wrong location has been specified for the database\r\n"
|
||||
"2) The database file has been deleted\r\n"
|
||||
"3) The database file has been renamed\r\n\r\n";
|
||||
break;
|
||||
|
||||
case 3://corrupt / not a database
|
||||
strEx="Common causes for this error:\r\n"
|
||||
"1) The database file is not actually a database file\r\n"
|
||||
"(someone renamed a non-database file to a database file name)\r\n"
|
||||
"\r\n"
|
||||
"2) The database file is damaged and needs to be repaired.\r\n"
|
||||
"(See the AyaNova manual reference section:\r\n"
|
||||
"\"Repairing the AyaNova Database\"\r\n"
|
||||
"which has complete instructions on repairing\r\n"
|
||||
"the database, the causes of database corruption\r\n"
|
||||
"and how to prevent the problem from happening\r\n"
|
||||
"again in future.)\r\n\r\n";
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
cstrErrMsg.Format(
|
||||
"AyaNova could not open the database file:\r\n"
|
||||
"\r\n"
|
||||
"%s\\scdata.sc\r\n"
|
||||
"\r\n"
|
||||
"The database driver gave the following reason:\r\n"
|
||||
"%s\r\n"
|
||||
"\r\n"
|
||||
"%s"
|
||||
"This program will now close...",m_strDBPATH,str,strEx);
|
||||
|
||||
|
||||
TRACE("*************************************************\n");
|
||||
TRACE("Exception thrown for classes generated by #import\n");
|
||||
TRACE("\tCode = %08x\n", hr);
|
||||
TRACE("\tCode Meaning = %s\n", e.ErrorMessage());
|
||||
TRACE("\tSource = %s\n", (LPCTSTR) bstrSource);
|
||||
TRACE("Description = %s\n", (LPCTSTR) bstrDescription);
|
||||
TRACE("*************************************************\n");
|
||||
#ifdef AYQB
|
||||
cstrErrMsg.Format(
|
||||
"AyaNova could not open the database file:\r\n\r\n"
|
||||
|
||||
"%sqbtrial.aya\r\n\r\n"
|
||||
|
||||
"This database file does not appear to be a AyaNova QBI trial edition\r\n"
|
||||
"compatible database.\r\n\r\n"
|
||||
|
||||
|
||||
|
||||
"AyaNova will now close...",m_strDBPATH);
|
||||
|
||||
#endif
|
||||
AfxMessageBox(cstrErrMsg);
|
||||
|
||||
|
||||
|
||||
|
||||
PostQuitMessage(-1);//exit now before anything worse happens
|
||||
return ;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
TRACE("*** Unhandled exception ***");
|
||||
//AfxMessageBox(m_strErrMsg);
|
||||
PostQuitMessage(-1);//exit now before anything worse happens
|
||||
return ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//****************************************************
|
||||
// compact the database through a jro object
|
||||
//**********************************************
|
||||
bool CGZRsetPool::Compact(bool bKeepOld)
|
||||
{
|
||||
bool status=true;
|
||||
CString src,dest,tempfile;
|
||||
CFileStatus fstat;
|
||||
CWaitCursor wait;
|
||||
|
||||
|
||||
//delete old one if exists
|
||||
tempfile.Format("%sscdata.tmp",m_strDBPATH);
|
||||
if(CFile::GetStatus(tempfile,fstat)==TRUE)//file exists
|
||||
{
|
||||
TRY
|
||||
{
|
||||
CFile::Remove( tempfile );
|
||||
}
|
||||
CATCH( CFileException, e )
|
||||
{
|
||||
status=false;
|
||||
CString cstrErrMsg;
|
||||
cstrErrMsg.Format("Error in Compact: %s cannot be removed",tempfile);
|
||||
AfxMessageBox(cstrErrMsg);
|
||||
}
|
||||
END_CATCH
|
||||
}
|
||||
|
||||
if(status==true)
|
||||
{
|
||||
|
||||
|
||||
|
||||
src.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%sscdata.sc;Jet OLEDB:Engine Type=5;",
|
||||
m_strDBPATH);
|
||||
|
||||
dest.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%sscdata.tmp;Jet OLEDB:Engine Type=5;",
|
||||
m_strDBPATH);
|
||||
|
||||
|
||||
_bstr_t bstsrc(src);
|
||||
_bstr_t bstdest(dest);
|
||||
|
||||
try
|
||||
{
|
||||
IJetEnginePtr jet(__uuidof(JetEngine));
|
||||
|
||||
jet->CompactDatabase(bstsrc, bstdest);
|
||||
}
|
||||
catch(_com_error &e)
|
||||
{
|
||||
status=false;
|
||||
CString cstrErrMsg;
|
||||
//get info from com error
|
||||
_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");
|
||||
cstrErrMsg.Format("Error in Compact: %s,\r\n%s",e.ErrorMessage(),(LPCTSTR) bstrDescription);
|
||||
AfxMessageBox(cstrErrMsg);
|
||||
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
status=false;
|
||||
TRACE( "*** Unhandled exception ***" );
|
||||
AfxMessageBox("Unhandled Error in Compact");
|
||||
PostQuitMessage(-1);//exit now before anything worse happens
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Added. indexing can leave a 100+mb old file
|
||||
//this way can delete it
|
||||
if(bKeepOld)
|
||||
{
|
||||
//copy mdb over old
|
||||
src.Format("%sscdata.sc",m_strDBPATH);
|
||||
dest.Format("%sscdata.old",m_strDBPATH);
|
||||
status=CopyFile(src.GetBuffer(100),dest.GetBuffer(100));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(status==true)
|
||||
{
|
||||
|
||||
|
||||
src.Format("%sscdata.tmp",m_strDBPATH);
|
||||
dest.Format("%sscdata.sc",m_strDBPATH);
|
||||
status=CopyFile(src.GetBuffer(100),dest.GetBuffer(100));
|
||||
|
||||
|
||||
}//if status==true
|
||||
|
||||
//delete gz1
|
||||
tempfile.Format("%sscdata.tmp",m_strDBPATH);
|
||||
if(CFile::GetStatus(tempfile,fstat)==TRUE)//file exists
|
||||
{
|
||||
TRY
|
||||
{
|
||||
CFile::Remove( tempfile );
|
||||
}
|
||||
CATCH( CFileException, e )
|
||||
{
|
||||
status=false;
|
||||
CString cstrErrMsg;
|
||||
cstrErrMsg.Format("Error at end of Compact: %s cannot be removed\r\nOtherwise compact OK",tempfile);
|
||||
AfxMessageBox(cstrErrMsg);
|
||||
}
|
||||
END_CATCH
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//*******************************************
|
||||
//copy a file, overwrite dest if exists
|
||||
bool CGZRsetPool::CopyFile(char *src, char *dest)
|
||||
{
|
||||
|
||||
CFile sourceFile;
|
||||
CFile destFile;
|
||||
CFileException ex;
|
||||
CString tempfile;
|
||||
|
||||
|
||||
|
||||
// open the source file for reading
|
||||
|
||||
if (!sourceFile.Open(src,
|
||||
CFile::modeRead | CFile::shareDenyWrite, &ex))
|
||||
{
|
||||
// complain if an error happened
|
||||
// no need to delete the ex object
|
||||
|
||||
TCHAR szError[1024];
|
||||
ex.GetErrorMessage(szError, 1024);
|
||||
CString errormsg;
|
||||
errormsg.Format("Error copying file %s to %s\r\n The error was: %s",src,dest,szError);
|
||||
AfxMessageBox(errormsg);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!destFile.Open(dest, CFile::modeWrite |
|
||||
CFile::shareExclusive | CFile::modeCreate, &ex))
|
||||
{
|
||||
TCHAR szError[1024];
|
||||
ex.GetErrorMessage(szError, 1024);
|
||||
CString errormsg;
|
||||
errormsg.Format("Error copying file %s to %s\r\n The error was: %s",src,dest,szError);
|
||||
AfxMessageBox(errormsg);
|
||||
sourceFile.Close();
|
||||
return false;
|
||||
}
|
||||
|
||||
BYTE buffer[4096];
|
||||
DWORD dwRead;
|
||||
|
||||
// Read in 4096-byte blocks,
|
||||
// remember how many bytes were actually read,
|
||||
// and try to write that many out. This loop ends
|
||||
// when there are no more bytes to read.
|
||||
|
||||
do
|
||||
{
|
||||
dwRead = sourceFile.Read(buffer, 4096);
|
||||
destFile.Write(buffer, dwRead);
|
||||
}
|
||||
while (dwRead > 0);
|
||||
|
||||
// Close both files
|
||||
|
||||
destFile.Close();
|
||||
sourceFile.Close();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool CGZRsetPool::GoExclusive()
|
||||
{
|
||||
try{
|
||||
if(pConnection->GetState()==adStateOpen)
|
||||
pConnection->Close();
|
||||
|
||||
//get connect string
|
||||
_bstr_t strCnn(m_strLiveConnectStringExclusive);
|
||||
|
||||
//open the connection
|
||||
pConnection->Open (strCnn, "", "", adConnectUnspecified);
|
||||
}
|
||||
catch (_com_error &e)
|
||||
{
|
||||
|
||||
CString cstrErrMsg;
|
||||
// get info from com error
|
||||
_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");
|
||||
cstrErrMsg.Format("At GoExclusive access (all other users out)\r\n %s,\r\n%s", e.ErrorMessage(), (LPCTSTR) bstrDescription);
|
||||
//cstrErrMsg.Format("%s: %s,\r\n%s",m_strErrMsg, e.ErrorMessage(), (LPCTSTR) bstrDescription);
|
||||
AfxMessageBox(cstrErrMsg);
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
TRACE("*** Unhandled exception ***");
|
||||
//AfxMessageBox(m_strErrMsg);
|
||||
PostQuitMessage(-1);//exit now before anything worse happens
|
||||
return false;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CGZRsetPool::GoShared()
|
||||
{
|
||||
try{
|
||||
|
||||
if(pConnection->GetState()==adStateOpen)
|
||||
pConnection->Close();
|
||||
|
||||
|
||||
//get connect string
|
||||
_bstr_t strCnn(m_strLiveConnectString);
|
||||
|
||||
//open the connection
|
||||
pConnection->Open (strCnn, "", "", adConnectUnspecified);
|
||||
}
|
||||
catch (_com_error &e)
|
||||
{
|
||||
|
||||
CString cstrErrMsg;
|
||||
// get info from com error
|
||||
_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");
|
||||
cstrErrMsg.Format("At GoShared()\r\n%s,\r\n%s\r\n", e.ErrorMessage(), (LPCTSTR) bstrDescription);
|
||||
//cstrErrMsg.Format("%s: %s,\r\n%s",m_strErrMsg, e.ErrorMessage(), (LPCTSTR) bstrDescription);
|
||||
AfxMessageBox(cstrErrMsg);
|
||||
return false;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
TRACE("*** Unhandled exception ***");
|
||||
//AfxMessageBox(m_strErrMsg);
|
||||
PostQuitMessage(-1);//exit now before anything worse happens
|
||||
return false;
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGZRsetPool::Disconnect()
|
||||
{
|
||||
if(pConnection->GetState()==adStateOpen)
|
||||
pConnection->Close();
|
||||
}
|
||||
|
||||
|
||||
//DIAGNOSIS Class for messing about with
|
||||
//connection and other properties
|
||||
//not actually used by the program
|
||||
void CGZRsetPool::DisplayProperties()
|
||||
{
|
||||
PropertiesPtr pPrpLoop = NULL;
|
||||
_variant_t vtIndex;
|
||||
_variant_t propValue;
|
||||
vtIndex.vt = VT_I2;
|
||||
_variant_t vtOne;
|
||||
vtOne.vt=VT_I4;
|
||||
vtOne.lVal=1;
|
||||
CString strName;
|
||||
pPrpLoop=pConnection->GetProperties();
|
||||
|
||||
|
||||
//pConnection->GetProperties()->GetItem()->Value=(_variant_t)1;
|
||||
|
||||
for (int intProperties = 0; intProperties < (int)pPrpLoop->
|
||||
GetCount(); intProperties++)
|
||||
{
|
||||
vtIndex.iVal = intProperties;
|
||||
propValue = pPrpLoop->GetItem(vtIndex)->Value;
|
||||
strName=(LPCSTR) pPrpLoop->GetItem(vtIndex)->GetName();
|
||||
if(strName=="Jet OLEDB:Transaction Commit Mode")
|
||||
{
|
||||
pPrpLoop->GetItem(vtIndex)->Value=vtOne;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
#ifdef _DEBUG
|
||||
propValue = pPrpLoop->GetItem(vtIndex)->Value;
|
||||
ASSERT(propValue.iVal==1);
|
||||
#endif
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Get datbase properties for tech support
|
||||
//displayed under help->About->Support info...
|
||||
void CGZRsetPool::GetDBProps()
|
||||
{
|
||||
try{
|
||||
if(pConnection->GetState()!=adStateOpen)
|
||||
return;
|
||||
//SET All version variables
|
||||
m_strADOVersion = (LPCSTR) pConnection->Version;
|
||||
|
||||
m_strDBMSName = (LPCSTR) (_bstr_t)
|
||||
pConnection->Properties->GetItem("DBMS Name")->Value;
|
||||
|
||||
m_strDBMSVersion= (LPCSTR) (_bstr_t) pConnection->
|
||||
Properties->GetItem("DBMS Version")->Value;
|
||||
|
||||
m_strOLEDbVersion=(LPCSTR) (_bstr_t)
|
||||
pConnection->Properties->GetItem("OLE DB Version")->Value;
|
||||
|
||||
m_strProviderName=(LPCSTR) (_bstr_t)
|
||||
pConnection->Properties->GetItem("Provider Name")->Value;
|
||||
|
||||
m_strProviderVersion=(LPCSTR) (_bstr_t)
|
||||
pConnection->Properties->GetItem("Provider Version")->Value;
|
||||
|
||||
/* m_strDriverVersion=(LPCSTR) (_bstr_t)
|
||||
pConnection->Properties->GetItem("Driver Name")->Value;
|
||||
|
||||
m_strDriverName=(LPCSTR) (_bstr_t)
|
||||
pConnection->Properties->GetItem("Driver Version")->Value;
|
||||
|
||||
m_strDriverODBCVersion=(LPCSTR) (_bstr_t)
|
||||
pConnection->Properties->GetItem("Driver ODBC Version")->Value;
|
||||
*/
|
||||
}
|
||||
catch (_com_error &e)
|
||||
{
|
||||
CString cstrErrMsg;
|
||||
// get info from com error
|
||||
_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");
|
||||
cstrErrMsg.Format("Error: Can't fetch database driver information.\r\n\r\nExact error is:\r\n%s", (LPCTSTR) bstrDescription);
|
||||
|
||||
|
||||
return ;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
TRACE("*** Unhandled exception ***");
|
||||
//AfxMessageBox(m_strErrMsg);
|
||||
|
||||
return ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Added 08/03/2001 to selective turn off error
|
||||
//warnings in gzrset to accomodate updates
|
||||
//so users don't freak out
|
||||
void CGZRsetPool::SupressErrors(bool bNoErrors)
|
||||
{
|
||||
m_bSupressErrors=bNoErrors;
|
||||
int x;
|
||||
GZRset* rs;
|
||||
if(m_nTotalAllocated>0)
|
||||
{
|
||||
|
||||
for(x=0;x<m_nTotalAllocated;x++)
|
||||
{
|
||||
rs=(GZRset*)pool.GetAt(x);
|
||||
|
||||
rs->m_bSupressErrors=m_bSupressErrors;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// GZRsetPool.h: interface for the CGZRsetPool class.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_GZRSETPOOL_H__CDF9C9E1_CCEA_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_GZRSETPOOL_H__CDF9C9E1_CCEA_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
#include "gzrset.h"
|
||||
#include <afxcoll.h>
|
||||
|
||||
class CGZRsetPool
|
||||
{
|
||||
public:
|
||||
void SupressErrors(bool bNoErrors);
|
||||
//Added 08/03/2001 to hide errors on update
|
||||
bool m_bSupressErrors;
|
||||
void GetDBProps();
|
||||
CString m_strADOVersion;
|
||||
CString m_strDBMSName;
|
||||
CString m_strDBMSVersion;
|
||||
CString m_strOLEDbVersion;
|
||||
CString m_strProviderName;
|
||||
CString m_strProviderVersion;
|
||||
CString m_strDriverVersion;
|
||||
CString m_strDriverName;
|
||||
CString m_strDriverODBCVersion;
|
||||
|
||||
bool m_bSQLServer;
|
||||
bool Compact(bool bKeepOld);
|
||||
bool CopyFile(char *src, char *dest);
|
||||
void DisplayProperties();
|
||||
void Disconnect();
|
||||
CString cstrErrMsg;
|
||||
bool GoShared();
|
||||
bool GoExclusive();
|
||||
|
||||
_ConnectionPtr pConnection;
|
||||
void StartConnection();
|
||||
void ShowAllOpenRS();
|
||||
GZRset* rsGENERIC;
|
||||
bool InitializeNewRS(GZRset* rs, bool bPrint);
|
||||
CString m_strCloseQuery;
|
||||
CString m_strDeadConnectString;
|
||||
CString m_strLiveConnectStringExclusive;
|
||||
CString m_strLiveConnectString;
|
||||
CString strConnectString;
|
||||
CString m_strDBPATH;
|
||||
int GetFreeRecordsetID(bool bPrint);
|
||||
int m_nTotalAllocated;
|
||||
GZRset* GetRS(CString strCallerInfo);
|
||||
GZRset* GetRSPrint(CString strCallerInfo);
|
||||
|
||||
void Empty();
|
||||
bool ReleaseRS(int* nRSID);
|
||||
|
||||
virtual ~CGZRsetPool();
|
||||
|
||||
CGZRsetPool();
|
||||
CObArray pool;
|
||||
// if true will force all updates within transactions which ensures immediate write out as were not so much concerned with data integrity here but immediacy
|
||||
bool m_bUseTransactions;
|
||||
};
|
||||
|
||||
#endif // !defined(AFX_GZRSETPOOL_H__CDF9C9E1_CCEA_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,103 @@
|
||||
// GenericPopupList.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "GenericPopupList.h"
|
||||
#include "StringParser.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGenericPopupList dialog
|
||||
|
||||
|
||||
CGenericPopupList::CGenericPopupList(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CGenericPopupList::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CGenericPopupList)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CGenericPopupList::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CGenericPopupList)
|
||||
DDX_Control(pDX, IDC_BTNOPEN, m_btnOpen);
|
||||
DDX_Control(pDX, IDC_BTNEXIT, m_btnExit);
|
||||
DDX_Control(pDX, IDC_LSTNBRECS, m_lb);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CGenericPopupList, CDialog)
|
||||
//{{AFX_MSG_MAP(CGenericPopupList)
|
||||
ON_LBN_DBLCLK(IDC_LSTNBRECS, OnDblclkLstnbrecs)
|
||||
ON_BN_CLICKED(IDC_BTNEXIT, OnBtnexit)
|
||||
ON_BN_CLICKED(IDC_BTNOPEN, OnBtnopen)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGenericPopupList message handlers
|
||||
|
||||
void CGenericPopupList::OnDblclkLstnbrecs()
|
||||
{
|
||||
CString strSelected;
|
||||
strSelected=m_lb.GetSelectedItem(0);
|
||||
m_pSelectedID->Format("%s",strSelected);
|
||||
CDialog::OnOK();
|
||||
|
||||
}
|
||||
|
||||
void CGenericPopupList::OnBtnopen()
|
||||
{
|
||||
OnDblclkLstnbrecs();
|
||||
}
|
||||
|
||||
|
||||
void CGenericPopupList::OnBtnexit()
|
||||
{
|
||||
m_pSelectedID->Empty();
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
|
||||
void CGenericPopupList::OnOK()
|
||||
{}
|
||||
|
||||
|
||||
BOOL CGenericPopupList::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
CString strData,strIndex;
|
||||
|
||||
//Fill list box from m_LbData
|
||||
CStringParser sp(m_strLbData,',');
|
||||
int nCount=sp.GetCount();
|
||||
|
||||
|
||||
if (nCount > 0)
|
||||
{
|
||||
|
||||
for (int i = 1; i <= nCount; i+=2)
|
||||
{
|
||||
strData = sp.GetField(i);
|
||||
strIndex=sp.GetField(i+1);
|
||||
m_lb.AddRow(strData,strIndex);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#if !defined(AFX_GENERICPOPUPLIST_H__0F1CCD67_9840_4BBA_A211_3BECB748D921__INCLUDED_)
|
||||
#define AFX_GENERICPOPUPLIST_H__0F1CCD67_9840_4BBA_A211_3BECB748D921__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// GenericPopupList.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGenericPopupList dialog
|
||||
#include "gzlistbox.h"
|
||||
class CGenericPopupList : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CString m_strLbData;
|
||||
CString * m_pSelectedID;
|
||||
CGenericPopupList(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CGenericPopupList)
|
||||
enum { IDD = IDD_GENERIC_LISTBOX };
|
||||
CButton m_btnOpen;
|
||||
CButton m_btnExit;
|
||||
CgzListBox m_lb;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CGenericPopupList)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CGenericPopupList)
|
||||
afx_msg void OnDblclkLstnbrecs();
|
||||
virtual void OnOK();
|
||||
afx_msg void OnBtnexit();
|
||||
afx_msg void OnBtnopen();
|
||||
virtual BOOL OnInitDialog();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_GENERICPOPUPLIST_H__0F1CCD67_9840_4BBA_A211_3BECB748D921__INCLUDED_)
|
||||
@@ -0,0 +1,82 @@
|
||||
// GetAllOrXValue.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "GetAllOrXValue.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGetAllOrXValue dialog
|
||||
|
||||
|
||||
CGetAllOrXValue::CGetAllOrXValue(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CGetAllOrXValue::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CGetAllOrXValue)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_plValueReturn=NULL;
|
||||
}
|
||||
|
||||
|
||||
void CGetAllOrXValue::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CGetAllOrXValue)
|
||||
DDX_Control(pDX, IDC_LBLPROMPT, m_lblPrompt);
|
||||
DDX_Control(pDX, IDC_EDX, m_edX);
|
||||
DDX_Control(pDX, IDC_CKALL, m_ckALL);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CGetAllOrXValue, CDialog)
|
||||
//{{AFX_MSG_MAP(CGetAllOrXValue)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGetAllOrXValue message handlers
|
||||
|
||||
void CGetAllOrXValue::OnOK()
|
||||
{
|
||||
CString str;
|
||||
if(m_ckALL.GetCheck()==TRUE)
|
||||
*m_plValueReturn=-1;
|
||||
else
|
||||
{
|
||||
m_edX.GetWindowText(str);
|
||||
if(str.IsEmpty())
|
||||
*m_plValueReturn=0;
|
||||
else
|
||||
*m_plValueReturn=atol(str);
|
||||
|
||||
}
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CGetAllOrXValue::OnCancel()
|
||||
{
|
||||
|
||||
*m_plValueReturn=0;//indicates cancelled
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
BOOL CGetAllOrXValue::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
ASSERT(m_plValueReturn!=NULL);
|
||||
|
||||
if(!m_strPrompt.IsEmpty())
|
||||
m_lblPrompt.SetWindowText(m_strPrompt);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#if !defined(AFX_GETALLORXVALUE_H__F43183C1_3F7B_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_GETALLORXVALUE_H__F43183C1_3F7B_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// GetAllOrXValue.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGetAllOrXValue dialog
|
||||
|
||||
class CGetAllOrXValue : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
long * m_plValueReturn;
|
||||
CString m_strPrompt;
|
||||
CGetAllOrXValue(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CGetAllOrXValue)
|
||||
enum { IDD = IDD_GETALLORXRECORDS };
|
||||
CStatic m_lblPrompt;
|
||||
CEdit m_edX;
|
||||
CButton m_ckALL;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CGetAllOrXValue)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CGetAllOrXValue)
|
||||
virtual void OnOK();
|
||||
virtual void OnCancel();
|
||||
virtual BOOL OnInitDialog();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_GETALLORXVALUE_H__F43183C1_3F7B_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,94 @@
|
||||
// GetStringDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "GetStringDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGetStringDlg dialog
|
||||
|
||||
|
||||
CGetStringDlg::CGetStringDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CGetStringDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CGetStringDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CGetStringDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CGetStringDlg)
|
||||
DDX_Control(pDX, IDC_LBLPROMPT, m_lblPrompt);
|
||||
DDX_Control(pDX, IDC_EDSTRING, m_edString);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CGetStringDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CGetStringDlg)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGetStringDlg message handlers
|
||||
|
||||
//Prompt=prompting string, pstrReturn=default and return string
|
||||
void CGetStringDlg::Setup(CString prompt, CString *pstrReturn)
|
||||
{
|
||||
if(prompt.IsEmpty())
|
||||
m_strPrompt="Enter text:";
|
||||
else
|
||||
m_strPrompt=prompt;
|
||||
|
||||
m_pstrReturn=pstrReturn;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//**************************************
|
||||
BOOL CGetStringDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
m_lblPrompt.SetWindowText(m_strPrompt);
|
||||
m_edString.SetWindowText(*m_pstrReturn);
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//*************************************
|
||||
void CGetStringDlg::OnCancel()
|
||||
{
|
||||
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
|
||||
//*************************************
|
||||
void CGetStringDlg::OnOK()
|
||||
{
|
||||
CString str;
|
||||
str.Empty();
|
||||
m_edString.GetWindowText(str);
|
||||
if(str.IsEmpty())
|
||||
CDialog::OnCancel();
|
||||
else
|
||||
{
|
||||
*m_pstrReturn=str;
|
||||
CDialog::OnOK();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
#if !defined(AFX_GETSTRINGDLG_H__483F7621_37D4_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_GETSTRINGDLG_H__483F7621_37D4_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// GetStringDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGetStringDlg dialog
|
||||
|
||||
class CGetStringDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CString * m_pstrReturn;
|
||||
CString m_strPrompt;
|
||||
void Setup(CString prompt, CString* pstrReturn);
|
||||
CGetStringDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CGetStringDlg)
|
||||
enum { IDD = IDD_GETSTRING };
|
||||
CStatic m_lblPrompt;
|
||||
CEdit m_edString;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CGetStringDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CGetStringDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
virtual void OnCancel();
|
||||
virtual void OnOK();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_GETSTRINGDLG_H__483F7621_37D4_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,803 @@
|
||||
// GroupsDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "GroupsDlg.h"
|
||||
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGroupsDlg dialog
|
||||
|
||||
|
||||
CGroupsDlg::CGroupsDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CGroupsDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CGroupsDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
k=new GZK;
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
|
||||
/*
|
||||
rs=new GZRset("Group rights dialog error:");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
lbrs=new GZRset("Group rights dialog reports listbox recordset error:");
|
||||
lbrs->SetConnect(m_pApp->strConnectString);
|
||||
*/
|
||||
//Initialize recordset pointer
|
||||
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CGroupsDlg (RS)");
|
||||
lbrs=m_pApp->rsPool->GetRS("CGroupsDlg (LBRS)");
|
||||
|
||||
m_strGroupsReports.Empty();
|
||||
}
|
||||
|
||||
CGroupsDlg::~CGroupsDlg()
|
||||
{
|
||||
delete k;
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
m_pApp->rsPool->ReleaseRS(&lbrs->m_nID);
|
||||
}
|
||||
|
||||
void CGroupsDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CGroupsDlg)
|
||||
DDX_Control(pDX, IDC_26, m_26);
|
||||
DDX_Control(pDX, IDC_25, m_25);
|
||||
DDX_Control(pDX, IDC_24, m_24);
|
||||
DDX_Control(pDX, IDC_23, m_23);
|
||||
DDX_Control(pDX, IDC_BTNDONE, m_btnDone);
|
||||
DDX_Control(pDX, IDC_LBRPTPOOL, m_lbReportsPool);
|
||||
DDX_Control(pDX, IDC_LBRPTGROUP, m_lbReportsGroup);
|
||||
DDX_Control(pDX, IDC_9, m_9);
|
||||
DDX_Control(pDX, IDC_8, m_8);
|
||||
DDX_Control(pDX, IDC_21, m_21);
|
||||
DDX_Control(pDX, IDC_22, m_22);
|
||||
DDX_Control(pDX, IDC_20, m_20);
|
||||
DDX_Control(pDX, IDC_19, m_19);
|
||||
DDX_Control(pDX, IDC_18, m_18);
|
||||
DDX_Control(pDX, IDC_17, m_17);
|
||||
DDX_Control(pDX, IDC_16, m_16);
|
||||
DDX_Control(pDX, IDC_15, m_15);
|
||||
DDX_Control(pDX, IDC_14, m_14);
|
||||
DDX_Control(pDX, IDC_13, m_13);
|
||||
DDX_Control(pDX, IDC_12, m_12);
|
||||
DDX_Control(pDX, IDC_11, m_11);
|
||||
DDX_Control(pDX, IDC_10, m_10);
|
||||
DDX_Control(pDX, IDC_7, m_7);
|
||||
DDX_Control(pDX, IDC_6, m_6);
|
||||
DDX_Control(pDX, IDC_5, m_5);
|
||||
DDX_Control(pDX, IDC_4, m_4);
|
||||
DDX_Control(pDX, IDC_3, m_3);
|
||||
DDX_Control(pDX, IDC_2, m_2);
|
||||
DDX_Control(pDX, IDC_1, m_1);
|
||||
DDX_Control(pDX, IDC_0, m_0);
|
||||
DDX_Control(pDX, IDC_GROUPNAME, m_edName);
|
||||
DDX_Control(pDX, IDC_GROUP_LIST_LABEL, m_lblGroupList);
|
||||
DDX_Control(pDX, IDC_GROUP_COMBO, m_cbGroup);
|
||||
DDX_Control(pDX, IDC_DELETE, m_btnDelete);
|
||||
DDX_Control(pDX, IDC_ADD, m_btnAdd);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CGroupsDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CGroupsDlg)
|
||||
ON_BN_CLICKED(IDC_ADD, OnAdd)
|
||||
ON_BN_CLICKED(IDC_DELETE, OnDelete)
|
||||
ON_CBN_CLOSEUP(IDC_GROUP_COMBO, OnCloseupGroupCombo)
|
||||
ON_BN_CLICKED(IDOK, OnOk)
|
||||
ON_EN_KILLFOCUS(IDC_GROUPNAME, OnKillfocusGroupname)
|
||||
ON_WM_RBUTTONDBLCLK()
|
||||
ON_BN_CLICKED(IDC_BTNREMOVERPT, OnBtnremoverpt)
|
||||
ON_BN_CLICKED(IDC_BTNADDRPT, OnBtnaddrpt)
|
||||
ON_LBN_DBLCLK(IDC_LBRPTGROUP, OnDblclkLbrptgroup)
|
||||
ON_LBN_DBLCLK(IDC_LBRPTPOOL, OnDblclkLbrptpool)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGroupsDlg message handlers
|
||||
|
||||
|
||||
void CGroupsDlg::FillListBox()
|
||||
{
|
||||
//fill list box with different groups
|
||||
CString strData;
|
||||
CString strIndex;
|
||||
long lData;
|
||||
m_cbGroup.Clear();
|
||||
|
||||
|
||||
|
||||
rs->Query("SELECT groups.* FROM groups;");
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
//fill combo box with available zones
|
||||
rs->MoveFirst();
|
||||
rs->FetchField("a",&strData);
|
||||
|
||||
//decrypt the name
|
||||
k->GZDecrypt(&strData,false);
|
||||
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbGroup.AddRow(strData,strIndex);
|
||||
while(rs->MoveForward())
|
||||
{
|
||||
rs->FetchField("a",&strData);
|
||||
//decrypt the name
|
||||
k->GZDecrypt(&strData,false);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbGroup.AddRow(strData,strIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//pretend user has selected so that other fields get filled in
|
||||
if(m_strSelectedGroup.IsEmpty()) //first time in
|
||||
{
|
||||
m_cbGroup.Select(1);
|
||||
//set last selected because were probably
|
||||
//here due to a delete and so whatever it was set
|
||||
//to is now invalid and will cause havoc on the
|
||||
//next save call.
|
||||
m_strLastComboID=m_cbGroup.GetCurrentRowID();
|
||||
|
||||
}
|
||||
else//something valid was selected before so stick with it
|
||||
m_cbGroup.Select(m_strSelectedGroup);
|
||||
|
||||
|
||||
SetFields();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CGroupsDlg::SetFields()
|
||||
{
|
||||
//user has made a selection, update the visible list
|
||||
CString q;
|
||||
CString strName;
|
||||
CString strRights;
|
||||
CString strHash;
|
||||
BOOL enable=TRUE;
|
||||
//save current selection so that updates and changes
|
||||
//will still show what was last selected
|
||||
m_strSelectedGroup=m_cbGroup.GetCurrentRowID();
|
||||
if(m_strSelectedGroup=="1" || m_bReadOnly) enable= FALSE;
|
||||
long lID;
|
||||
q.Format("SELECT groups.* FROM groups WHERE (((groups.id)=%s));",m_strSelectedGroup);
|
||||
rs->Query(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
m_strGroupsReports.Empty();
|
||||
|
||||
rs->FetchField("id",&lID);//id number
|
||||
rs->FetchField("a",&strName);//name string
|
||||
rs->FetchField("b",&strRights);//rights string
|
||||
rs->FetchField("c",&strHash);//checksum/hash
|
||||
rs->FetchField("d",&m_strGroupsReports);
|
||||
//decrypt if there is something there
|
||||
if(!m_strGroupsReports.IsEmpty())
|
||||
k->GZDecrypt(&m_strGroupsReports,false);
|
||||
|
||||
//used by save routine to see if user has made
|
||||
//report selection changes
|
||||
m_strGroupsReportsInitialValue=m_strGroupsReports;
|
||||
//stuff em all together and compare the hash value
|
||||
//to make sure no one has been screwing with the security
|
||||
//settings
|
||||
q.Format("%u%s%s",lID,strName,strRights);
|
||||
k->GZHash(&q);
|
||||
if(q.Compare(strHash)!=0 && m_bMasterMode==false)
|
||||
{
|
||||
AfxMessageBox("Security breach!\r\nGroup rights corrupted.");
|
||||
//PostQuitMessage(WM_QUIT);
|
||||
return;
|
||||
}
|
||||
|
||||
//take the rightmost numrights characters and set the rights buttons
|
||||
//accordingly
|
||||
k->GZDecrypt(&strRights,false);
|
||||
q=strRights.Right(NUMRIGHTS);
|
||||
}
|
||||
//initialize the rights buttons
|
||||
for(int x=0;x<NUMRIGHTS;x++)
|
||||
{
|
||||
strRights=q.Mid(x,1);
|
||||
if(m_pRight[x]!=NULL)
|
||||
m_pRight[x]->Set(strRights,true);
|
||||
m_pRight[x]->EnableWindow(enable);
|
||||
|
||||
}
|
||||
|
||||
//display the list name
|
||||
k->GZDecrypt(&strName,false);
|
||||
m_edName.SetWindowText(strName);
|
||||
m_edName.EnableWindow(enable);
|
||||
m_btnDelete.ShowWindow(enable);
|
||||
m_lbReportsGroup.EnableWindow(enable);
|
||||
m_lbReportsPool.EnableWindow(enable);
|
||||
if(enable)
|
||||
DisplayReportLists();
|
||||
|
||||
}
|
||||
|
||||
//************************************
|
||||
void CGroupsDlg::OnAdd()
|
||||
{
|
||||
CString str;
|
||||
if(m_bAddMode)//user is requesting to save
|
||||
{
|
||||
m_edName.GetWindowText(str);
|
||||
if(str.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("You must enter a group name");
|
||||
return;
|
||||
}
|
||||
|
||||
//bugbug: sometimes it complains about
|
||||
//adding a duplicate record when
|
||||
//not doing that. Could be add mode is
|
||||
//not resetting so it thinks it's adding
|
||||
//rather than updating.
|
||||
|
||||
//Seems to happen when you add a new record
|
||||
//edit then add a second.
|
||||
//seems to have started since adding code
|
||||
//to select newly added record automatically.
|
||||
|
||||
//Also is not clearing old values on add new properly.
|
||||
|
||||
m_bAddMode=false;
|
||||
m_cbGroup.ShowWindow(TRUE);
|
||||
m_lblGroupList.ShowWindow(TRUE);
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_btnDelete.SetWindowText("Delete");
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
//save the new record
|
||||
Save(false);
|
||||
FillListBox();
|
||||
}
|
||||
else//not add mode
|
||||
{
|
||||
Save(true);
|
||||
//DO: set default values of controls.
|
||||
m_edName.EnableWindow(TRUE);
|
||||
m_btnDelete.ShowWindow(TRUE);
|
||||
m_cbGroup.ShowWindow(FALSE);
|
||||
m_lblGroupList.ShowWindow(FALSE);
|
||||
m_btnAdd.SetWindowText("SAVE");
|
||||
m_btnDelete.SetWindowText("Cancel");
|
||||
m_btnDone.ShowWindow(FALSE);
|
||||
m_edName.SetWindowText("");
|
||||
m_edName.SetFocus();
|
||||
m_bAddMode=true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//*******************************************
|
||||
void CGroupsDlg::OnDelete()
|
||||
{
|
||||
CString strGroupID;
|
||||
if(m_bAddMode==true)//then this is the cancel button
|
||||
{
|
||||
m_bAddMode=false;
|
||||
m_cbGroup.ShowWindow(TRUE);
|
||||
m_lblGroupList.ShowWindow(TRUE);
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_btnDelete.SetWindowText("Delete");
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
FillListBox();
|
||||
return;
|
||||
}
|
||||
|
||||
//otherwise, delete the record
|
||||
|
||||
strGroupID=m_cbGroup.GetCurrentRowID();
|
||||
if(strGroupID=="1" && m_bMasterMode==false)
|
||||
{
|
||||
//AfxMessageBox("To protect your access the <MANAGERS> group can not be deleted.");
|
||||
return;
|
||||
}
|
||||
CString q,strData;
|
||||
q.Format("SELECT [first] & \" \" & [last] AS name "
|
||||
"FROM users WHERE (((users.c)=%s));",strGroupID);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
rs->Query(q);
|
||||
if(rs->IsEmpty())//no clients in that zone
|
||||
{
|
||||
|
||||
q.Format("DELETE groups.*, groups.id "
|
||||
"FROM groups WHERE (((groups.id)=%s));",m_cbGroup.GetCurrentRowID());
|
||||
|
||||
if(AfxMessageBox("Delete this group?",MB_YESNO)==IDYES)
|
||||
{
|
||||
rs->Ex(q);
|
||||
//a deleted zone can't be selected
|
||||
m_strSelectedGroup="";
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
q="DATA INTEGRITY PROTECTION:\r\nYou cannot delete this security group because\r\nthe following users are set to it:\r\n";
|
||||
|
||||
//fill combo box with available zones
|
||||
rs->MoveFirst();
|
||||
rs->FetchField("name",&strData);
|
||||
q=q+strData+"\r\n";
|
||||
|
||||
|
||||
while(rs->MoveForward())
|
||||
{
|
||||
rs->FetchField("name",&strData);
|
||||
q=q+strData+"\r\n";
|
||||
}
|
||||
AfxMessageBox(q);
|
||||
}
|
||||
FillListBox();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//****************************************************
|
||||
BOOL CGroupsDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
ShowWindow(SW_SHOWMAXIMIZED);
|
||||
m_bAddMode=false;
|
||||
|
||||
|
||||
|
||||
m_pRight[0]=&m_0;
|
||||
m_pRight[1]=&m_1;
|
||||
m_pRight[2]=&m_2;
|
||||
m_pRight[3]=&m_3;
|
||||
m_pRight[4]=&m_4;
|
||||
m_pRight[5]=&m_5;
|
||||
m_pRight[6]=&m_6;
|
||||
m_pRight[7]=&m_7;
|
||||
m_pRight[8]=&m_8;
|
||||
m_pRight[9]=&m_9;
|
||||
m_pRight[10]=&m_10;
|
||||
m_pRight[11]=&m_11;
|
||||
m_pRight[12]=&m_12;
|
||||
m_pRight[13]=&m_13;
|
||||
m_pRight[14]=&m_14;
|
||||
m_pRight[15]=&m_15;
|
||||
m_pRight[16]=&m_16;
|
||||
m_pRight[17]=&m_17;
|
||||
m_pRight[18]=&m_18;
|
||||
m_pRight[19]=&m_19;
|
||||
m_pRight[20]=&m_20;
|
||||
m_pRight[21]=&m_21;
|
||||
m_pRight[22]=&m_22;
|
||||
m_pRight[23]=&m_23;
|
||||
m_pRight[24]=&m_24;
|
||||
m_pRight[25]=&m_25;
|
||||
m_pRight[26]=&m_26;
|
||||
|
||||
//ASSUMPTION: can only get here from the main
|
||||
//menu bar, so either you can't get here at all
|
||||
//or you have read only access, so onlyt
|
||||
//have to set readonly here not check for
|
||||
//no access since that's taken care of in the
|
||||
//CspApp->switchview function
|
||||
if(m_pApp->Allowed(RSECURITY,true)==2)//read only?
|
||||
m_bReadOnly=true;
|
||||
else
|
||||
m_bReadOnly=false;
|
||||
|
||||
FillListBox();
|
||||
m_strLastComboID=m_cbGroup.GetCurrentRowID();
|
||||
|
||||
// m_lblHead1.SetFontName("Arial").SetFontSize(12).SetFontBold(TRUE).SetFontUnderline(TRUE).SetTextColor(RGB(0,0,0));
|
||||
// m_lblHead2.SetFontName("Arial").SetFontSize(12).SetFontBold(TRUE).SetFontUnderline(TRUE).SetTextColor(RGB(0,0,0));
|
||||
|
||||
m_bMasterMode=false;
|
||||
//===================================================
|
||||
// SET WINDOW SIZE TO MATCH WORK AREA
|
||||
ShowWindow(SW_SHOWMAXIMIZED);
|
||||
CRect workarea;
|
||||
SystemParametersInfo(SPI_GETWORKAREA,0,&workarea,0);
|
||||
SetWindowPos(NULL,workarea.left,workarea.top,workarea.Width(),workarea.Height(),SWP_NOZORDER);
|
||||
//===================================================
|
||||
|
||||
//DisplayReportLists();
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CGroupsDlg::OnCloseupGroupCombo()
|
||||
{
|
||||
|
||||
//call save
|
||||
if(m_strLastComboID!="1")
|
||||
Save(true);
|
||||
//set to current selection
|
||||
//when save is called before this line
|
||||
//it will be able to see if the combo has changed
|
||||
//and can use the last combo ID value instead
|
||||
//during the save
|
||||
m_strLastComboID=m_cbGroup.GetCurrentRowID();
|
||||
SetFields();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//********************************************
|
||||
//if update==true then update existing record
|
||||
//else create new record
|
||||
void CGroupsDlg::Save(bool Update/*or new*/)
|
||||
{
|
||||
CString q;
|
||||
CString strItem;
|
||||
CString strName;
|
||||
CString strRights;
|
||||
CString strHash;
|
||||
CString strGroupID;
|
||||
CString strReports;
|
||||
bool HereFromCBCloseup=false;
|
||||
long lID;
|
||||
int x;
|
||||
bool ThereAreChanges=false;
|
||||
|
||||
|
||||
if(Update)
|
||||
{
|
||||
//check the rights buttons
|
||||
for(x=0;x<NUMRIGHTS;x++)
|
||||
{
|
||||
if(m_pRight[x]->IsChanged())
|
||||
{
|
||||
ThereAreChanges=true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//check the group name box
|
||||
if(m_edName.GetModify()==TRUE)
|
||||
ThereAreChanges=true;
|
||||
|
||||
//check reports
|
||||
if(m_strGroupsReports!=m_strGroupsReportsInitialValue)
|
||||
ThereAreChanges=true;
|
||||
|
||||
//no changes? then exit routine
|
||||
if(ThereAreChanges==false)
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//save changes
|
||||
m_edName.GetWindowText(strName);
|
||||
if(strName.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("You must enter a group name");
|
||||
return;
|
||||
}
|
||||
|
||||
strRights=strName;
|
||||
for(x=0;x<NUMRIGHTS;x++)
|
||||
{
|
||||
m_pRight[x]->Get(&strItem);
|
||||
//tell the controls that they are now
|
||||
//at their default value
|
||||
//since they are, this prevents
|
||||
//later updates from thinking a save is
|
||||
//necessary
|
||||
m_pRight[x]->Set(strItem,true);
|
||||
strRights=strRights+strItem;
|
||||
}
|
||||
|
||||
//encrypt
|
||||
k->GZEncrypt(&strName,false);
|
||||
k->GZEncrypt(&strRights,false);
|
||||
strReports=m_strGroupsReports;
|
||||
|
||||
if(!strReports.IsEmpty())
|
||||
k->GZEncrypt(&strReports,false);
|
||||
|
||||
if(Update)
|
||||
{
|
||||
//Get the hash
|
||||
strGroupID=m_cbGroup.GetCurrentRowID();
|
||||
|
||||
//get id, or previous id if combo is in the
|
||||
//middle of changing
|
||||
if(strGroupID.Compare(m_strLastComboID)!=0)
|
||||
{
|
||||
strGroupID=m_strLastComboID;
|
||||
//flag so filllistbox doesn't get called later
|
||||
HereFromCBCloseup=true;
|
||||
}
|
||||
|
||||
if(strGroupID=="1" && m_bMasterMode==false)
|
||||
{
|
||||
//AfxMessageBox("To protect your access the <MANAGERS> group can not be modified.");
|
||||
return;
|
||||
}
|
||||
|
||||
//check if attempting to use the same group name
|
||||
//as another record users
|
||||
q.Format("SELECT groups.id, groups.a FROM groups "
|
||||
"WHERE (((groups.id)<>%s) AND ((groups.a)=\"%s\"));",strGroupID,strName);
|
||||
|
||||
rs->Query(q);
|
||||
if(!rs->IsEmpty())//group name already exists
|
||||
{
|
||||
AfxMessageBox("That group name is already in use!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
strHash=strGroupID;
|
||||
strHash=strHash+strName+strRights;
|
||||
k->GZHash(&strHash);
|
||||
//make up the execute query string
|
||||
q.Format("UPDATE groups SET groups.a = \"%s\", groups.b = \"%s\", "
|
||||
"groups.c = \"%s\", groups.d = \"%s\" WHERE (((groups.id)=%s));"
|
||||
,strName,strRights,strHash,strReports, strGroupID);
|
||||
//run the execute query
|
||||
rs->Ex(q);
|
||||
|
||||
|
||||
if(!HereFromCBCloseup)
|
||||
FillListBox();
|
||||
//bail
|
||||
return;
|
||||
}
|
||||
else//it's a wholesale new record
|
||||
{
|
||||
//see if another record is already using
|
||||
//this name...
|
||||
q.Format("SELECT groups.* FROM groups "
|
||||
"WHERE (((groups.a)=\"%s\"));",strName);
|
||||
rs->Query(q);
|
||||
if(!rs->IsEmpty())//group name already exists
|
||||
{
|
||||
AfxMessageBox("That group name is already in use!");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
rs->AddNewRecord();
|
||||
rs->UpdateField("a",&strName);
|
||||
rs->UpdateField("b",&strRights);
|
||||
rs->UpdateField("d",&strReports);
|
||||
if(!rs->SaveRecord())
|
||||
CDialog::OnCancel();
|
||||
|
||||
//now get the autonumber id assigned to this record
|
||||
q.Format("SELECT groups.* FROM groups WHERE (((groups.a)=\"%s\"));",strName);
|
||||
rs->Query(q);
|
||||
rs->FetchField("id",&lID);
|
||||
strHash.Format("%u",lID);
|
||||
//this is so after adding new group
|
||||
//list centers on it
|
||||
m_strSelectedGroup=strHash;
|
||||
|
||||
strHash=strHash+strName+strRights;
|
||||
k->GZHash(&strHash);
|
||||
//now save the hash
|
||||
rs->UpdateField("c",&strHash);
|
||||
if(!rs->SaveRecord())
|
||||
{
|
||||
AfxMessageBox("If you just received an error about creating a duplicate\r\n"
|
||||
"You were probably trying to use the same group name twice.\r\n"
|
||||
"Each group name must be unique");
|
||||
//pretend user pressed cancel
|
||||
m_bAddMode=true;
|
||||
OnDelete();
|
||||
}
|
||||
|
||||
//reset this bad boy
|
||||
m_strGroupsReportsInitialValue=m_strGroupsReports;
|
||||
//bob's your uncle
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*********************************************
|
||||
void CGroupsDlg::OnOk()
|
||||
{}//do nothing
|
||||
|
||||
|
||||
//****************************************
|
||||
void CGroupsDlg::OnKillfocusGroupname()
|
||||
{
|
||||
if(!m_bAddMode)
|
||||
Save(true);
|
||||
}
|
||||
|
||||
//***********************************
|
||||
bool CGroupsDlg::SaveField(CEdit *edControl,CString fldname,bool AllowEmpty)
|
||||
{
|
||||
CString str;
|
||||
//do nothing if not changed
|
||||
if(edControl->GetModify()!=TRUE) return true;
|
||||
|
||||
edControl->GetWindowText(str);
|
||||
//dont save empty fields if not allowed to
|
||||
if(!AllowEmpty)
|
||||
{
|
||||
|
||||
if(str.IsEmpty())
|
||||
{
|
||||
edControl->Undo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rs->UpdateField(fldname,&str);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CGroupsDlg::OnRButtonDblClk(UINT nFlags, CPoint point)
|
||||
{
|
||||
/*
|
||||
return;
|
||||
|
||||
if(m_pApp->m_lusrID!=1) return;//only the manager!
|
||||
CKD d;
|
||||
d.DoModal();
|
||||
// TODO: Add your message handler code here and/or call default
|
||||
m_bMasterMode=!m_bMasterMode;
|
||||
if(m_bMasterMode)
|
||||
SetWindowText("User groups - Edit / Add.");
|
||||
else
|
||||
SetWindowText("User groups - Edit / Add");
|
||||
//CDialog::OnRButtonDblClk(nFlags, point);
|
||||
*/
|
||||
}
|
||||
|
||||
//**********************************************
|
||||
void CGroupsDlg::OnBtnremoverpt()
|
||||
{
|
||||
CString fname,vname;
|
||||
int nFound=0;
|
||||
m_lbReportsGroup.RebuildIndex();
|
||||
int x=m_lbReportsGroup.SelectionCount();
|
||||
if(x<1) return;
|
||||
|
||||
for(int y=0;y<x;y++)
|
||||
{
|
||||
fname=m_lbReportsGroup.GetSelectedItem(y);
|
||||
//see if it's already in the list
|
||||
nFound=m_strGroupsReports.Find(fname,0);
|
||||
|
||||
|
||||
if(nFound!=-1)//not found
|
||||
m_strGroupsReports.Delete(nFound,fname.GetLength());
|
||||
|
||||
|
||||
}
|
||||
|
||||
//refresh display
|
||||
DisplayReportLists();
|
||||
}
|
||||
|
||||
|
||||
//***************************************
|
||||
void CGroupsDlg::OnBtnaddrpt()
|
||||
{
|
||||
CString fname;
|
||||
//needed for some weird hacky reason
|
||||
//that I never fixed
|
||||
m_lbReportsPool.RebuildIndex();
|
||||
int x=m_lbReportsPool.SelectionCount();
|
||||
if(x<1) return;
|
||||
|
||||
for(int y=0;y<x;y++)
|
||||
{
|
||||
fname=m_lbReportsPool.GetSelectedItem(y);
|
||||
|
||||
//see if it's already in the list
|
||||
if(m_strGroupsReports.Find(fname,0)==-1)//not found
|
||||
m_strGroupsReports+=fname;
|
||||
|
||||
}
|
||||
|
||||
//refresh display
|
||||
DisplayReportLists();
|
||||
|
||||
}
|
||||
|
||||
void CGroupsDlg::OnDblclkLbrptgroup()
|
||||
{
|
||||
OnBtnremoverpt();
|
||||
}
|
||||
|
||||
void CGroupsDlg::OnDblclkLbrptpool()
|
||||
{
|
||||
OnBtnaddrpt();
|
||||
}
|
||||
|
||||
|
||||
//**************************************
|
||||
//display all reports for this group
|
||||
//display all available reports not in group
|
||||
//safe to call from anywhere....:)
|
||||
void CGroupsDlg::DisplayReportLists()
|
||||
{
|
||||
|
||||
CString q,vname,fname;
|
||||
bool GroupHasReports=true;
|
||||
m_lbReportsPool.Clear();
|
||||
m_lbReportsGroup.Clear();
|
||||
//to avoid extra lb processing when adding strings
|
||||
if(m_strGroupsReports.IsEmpty()) GroupHasReports=false;
|
||||
|
||||
lbrs->Query("SELECT rptsmaster.virtualname, rptsmaster.filename "
|
||||
"FROM rptsmaster WHERE (((rptsmaster.x)=True)) ORDER BY rptsmaster.virtualname;");
|
||||
|
||||
ASSERT(!lbrs->IsEmpty());
|
||||
if(lbrs->IsEmpty()) return;
|
||||
|
||||
lbrs->MoveFirst();
|
||||
|
||||
do
|
||||
{
|
||||
lbrs->FetchField("virtualname",&vname);
|
||||
lbrs->FetchField("filename",&fname);
|
||||
//see if it's in the group if so put in group list
|
||||
if(!GroupHasReports)
|
||||
{//just put into the pool list
|
||||
m_lbReportsPool.AddRow(vname,fname);
|
||||
}
|
||||
else
|
||||
{//see where it goes and put it in the right list
|
||||
if(m_strGroupsReports.Find(fname,0)==-1)//not found
|
||||
m_lbReportsPool.AddRow(vname,fname);//into the pool
|
||||
else
|
||||
m_lbReportsGroup.AddRow(vname,fname);//into the group
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}while(lbrs->MoveForward());
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CGroupsDlg::OnBtndone()
|
||||
{
|
||||
Save(true);
|
||||
CDialog::OnOK();
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
#if !defined(AFX_GROUPSDLG_H__159836E3_1460_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_GROUPSDLG_H__159836E3_1460_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// GroupsDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CGroupsDlg dialog
|
||||
#include "gzrightsbutton.h"
|
||||
#include "gzk.h"
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
#include "label.h"
|
||||
#include "gzListBox.h"
|
||||
|
||||
|
||||
//****************************************************
|
||||
//SECURITY RIGHTS
|
||||
#define NUMRIGHTS 27
|
||||
#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
|
||||
#define RIGHTS_ARAS_REQUESTS 26//ARAS service requests
|
||||
|
||||
//**********************************************************
|
||||
|
||||
|
||||
|
||||
class CGroupsDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
bool m_bReadOnly;
|
||||
|
||||
CString m_strGroupsReports;
|
||||
CString m_strGroupsReportsInitialValue;
|
||||
void DisplayReportLists();
|
||||
~CGroupsDlg();
|
||||
bool m_bMasterMode;
|
||||
CString m_strLastComboID;
|
||||
void Save(bool Update/*or new*/);
|
||||
void SetFields();
|
||||
bool SaveField(CEdit *edControl,CString fldname,bool AllowEmpty);
|
||||
|
||||
void FillListBox();
|
||||
CGroupsDlg(CWnd* pParent = NULL); // standard constructor
|
||||
GZK* k;
|
||||
CSpApp* m_pApp;
|
||||
bool m_bAddMode;
|
||||
CgzRightsButton* m_pRight[NUMRIGHTS];
|
||||
CString m_strSelectedGroup;
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CGroupsDlg)
|
||||
enum { IDD = IDD_GROUPS };
|
||||
CgzRightsButton m_26;
|
||||
CgzRightsButton m_25;
|
||||
CgzRightsButton m_24;
|
||||
CgzRightsButton m_23;
|
||||
CButton m_btnDone;
|
||||
CgzListBox m_lbReportsPool;
|
||||
CgzListBox m_lbReportsGroup;
|
||||
CgzRightsButton m_9;
|
||||
CgzRightsButton m_8;
|
||||
CgzRightsButton m_21;
|
||||
CgzRightsButton m_22;
|
||||
CgzRightsButton m_20;
|
||||
CgzRightsButton m_19;
|
||||
CgzRightsButton m_18;
|
||||
CgzRightsButton m_17;
|
||||
CgzRightsButton m_16;
|
||||
CgzRightsButton m_15;
|
||||
CgzRightsButton m_14;
|
||||
CgzRightsButton m_13;
|
||||
CgzRightsButton m_12;
|
||||
CgzRightsButton m_11;
|
||||
CgzRightsButton m_10;
|
||||
CgzRightsButton m_7;
|
||||
CgzRightsButton m_6;
|
||||
CgzRightsButton m_5;
|
||||
CgzRightsButton m_4;
|
||||
CgzRightsButton m_3;
|
||||
CgzRightsButton m_2;
|
||||
CgzRightsButton m_1;
|
||||
CgzRightsButton m_0;
|
||||
CEdit m_edName;
|
||||
CStatic m_lblGroupList;
|
||||
CgzCombo m_cbGroup;
|
||||
CButton m_btnDelete;
|
||||
CButton m_btnAdd;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CGroupsDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
private:
|
||||
GZRset* rs;
|
||||
GZRset* lbrs;
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CGroupsDlg)
|
||||
afx_msg void OnAdd();
|
||||
afx_msg void OnDelete();
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnCloseupGroupCombo();
|
||||
afx_msg void OnOk();
|
||||
afx_msg void OnKillfocusGroupname();
|
||||
afx_msg void OnRButtonDblClk(UINT nFlags, CPoint point);
|
||||
afx_msg void OnBtnremoverpt();
|
||||
afx_msg void OnBtnaddrpt();
|
||||
afx_msg void OnDblclkLbrptgroup();
|
||||
afx_msg void OnDblclkLbrptpool();
|
||||
afx_msg void OnBtndone();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_GROUPSDLG_H__159836E3_1460_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
226
archive/ayanova 1.9.4 CE final release db schema 171/sp/KD.cpp
Normal file
226
archive/ayanova 1.9.4 CE final release db schema 171/sp/KD.cpp
Normal file
@@ -0,0 +1,226 @@
|
||||
// KD.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "KD.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CKD dialog
|
||||
|
||||
|
||||
CKD::CKD(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CKD::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CKD)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp = (CSpApp*)AfxGetApp();
|
||||
/*
|
||||
rs=new GZRset("Error 69 - email tech support");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
*/
|
||||
//Initialize recordset pointer
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CKD");
|
||||
k=new GZK;
|
||||
}
|
||||
|
||||
|
||||
void CKD::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CKD)
|
||||
DDX_Control(pDX, IDC_LBLK, m_lblK);
|
||||
DDX_Control(pDX, IDC_LBLINFO, m_lblInfo);
|
||||
DDX_Control(pDX, IDC_LBLC, m_lblC);
|
||||
DDX_Control(pDX, IDC_EDK, m_edK);
|
||||
DDX_Control(pDX, IDC_EDC, m_edC);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CKD, CDialog)
|
||||
//{{AFX_MSG_MAP(CKD)
|
||||
ON_BN_CLICKED(IDC_BTNSAVE, OnBtnsave)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CKD message handlers
|
||||
|
||||
void CKD::OnBtnsave()
|
||||
{
|
||||
|
||||
CString key,keyvalue;
|
||||
CString comp,company;
|
||||
|
||||
CString kCompHash;
|
||||
CString temp,q;
|
||||
int firstcomma,secondcomma,thirdcomma;
|
||||
|
||||
m_edC.GetWindowText(company);
|
||||
m_edK.GetWindowText(keyvalue);
|
||||
comp=company;
|
||||
key=keyvalue;
|
||||
|
||||
// COMPARE AGAINST ZAP LIST
|
||||
|
||||
k->GZHash(&comp);
|
||||
k->GZDecrypt(&key,false);
|
||||
firstcomma=key.Find(',',0);
|
||||
secondcomma=key.Find(',',firstcomma+1);
|
||||
thirdcomma=key.Find(',',secondcomma+1);
|
||||
if(firstcomma==-1 || secondcomma==-1 || thirdcomma==-1)
|
||||
{
|
||||
AfxMessageBox(k->InLineDecrypt("gE8Brl9JYwu9G+0BoCLatUpt2Ug5YXYs+1lBHILkRHB7hcyeWE6o3q8ztyj+9wTPP9+OzYAj"
|
||||
"ejaF8zlelDCG1Pz34nBTyKwSovUmpyTTNzQ"));
|
||||
/*Key or registered name is not valid.
|
||||
Please check your entries and try again.*/
|
||||
return;
|
||||
}
|
||||
|
||||
kCompHash=key.Left(firstcomma);
|
||||
|
||||
if(kCompHash!=comp)
|
||||
{
|
||||
AfxMessageBox(k->InLineDecrypt("gE8Brl9JYwu9G+0BoCLatUpt2Ug5YXYs+1lBHILkRHB7hcyeWE6o3q8ztyj+9wTPP9+OzYAj"
|
||||
"ejaF8zlelDCG1Pz34nBTyKwSovUmpyTTNzQ"));
|
||||
/*Key or registered name is not valid.
|
||||
Please check your entries and try again.*/
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//v1.9.4.5 TEAM ESD IMMEDIATE KEY CHECK
|
||||
if(kCompHash=="1575153704")//TEAM ESD
|
||||
{
|
||||
AfxMessageBox(k->InLineDecrypt("gE8Brl9JYwu9G+0BoCLatUpt2Ug5YXYs+1lBHILkRHB7hcyeWE6o3q8ztyj+9wTPP9+OzYAj"
|
||||
"ejaF8zlelDCG1Pz34nBTyKwSovUmpyTTNzQ"));
|
||||
/*Key or registered name is not valid.
|
||||
Please check your entries and try again.*/
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//*************v1.9.4.5 changes***********************************************
|
||||
//v1.9.4.5 add expiry date check as in the spDoc validate function that is
|
||||
//run at each login against the key code
|
||||
//expiry date?
|
||||
temp=key.Right(key.GetLength()-thirdcomma-1);
|
||||
if(temp==k->InLineDecrypt("Md2gXbFO5Vu4MqQpfyEWdw"/*15 eval key*/)
|
||||
|| temp==k->InLineDecrypt("hm0s/6NFOzjXMUUd/HaGEA") /*69 licensed key*/
|
||||
|| temp==k->InLineDecrypt("o2jDhqik1/EKD7zT1MBbJQ") /*5 eval key*/)
|
||||
{
|
||||
temp="";//do nothing, it's got a valid code number at the end, no worries
|
||||
//this is just a way to avoid re-writing the borrowed code above
|
||||
|
||||
}
|
||||
else//the date portion at the end isn't a code number, it should be a date
|
||||
//verify it's a valid date
|
||||
{
|
||||
//If we are here, then this key has an expiry date, check if expired and announce time left?
|
||||
COleDateTime dtData;
|
||||
COleDateTime dtNow=COleDateTime::GetCurrentTime();
|
||||
COleDateTimeSpan dtSpan;
|
||||
dtData.ParseDateTime(temp);
|
||||
CString m_strExpiryDays;
|
||||
CString strTemp;
|
||||
temp.Empty();//don't leave it floating around in memory
|
||||
if(dtData.GetStatus()!=0)//couldn't parse the date and time
|
||||
{
|
||||
AfxMessageBox(k->InLineDecrypt("gE8Brl9JYwu9G+0BoCLatUpt2Ug5YXYs+1lBHILkRHB7hcyeWE6o3q8ztyj+9wTPP9+OzYAj"
|
||||
"ejaF8zlelDCG1Pz34nBTyKwSovUmpyTTNzQ"));
|
||||
/*Key or registered name is not valid.
|
||||
Please check your entries and try again.*/
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//**********END V1.9.4.5 changes*****************************************
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
q.Format("UPDATE defaults SET defaults.regto = \"%s\", defaults.[key] = \"%s\";",company,keyvalue);
|
||||
if(!rs->Ex(q))
|
||||
{
|
||||
AfxMessageBox("Error saving information");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
AfxMessageBox(k->InLineDecrypt("ASRkzgxvjiV1EvBmxwtBVDVZ8mV1DqMqb6LMrZSb1PvJqc6eiDW1eIzpxeqgGH07O63CorO9"
|
||||
"+pnHKPzq2fOIWnO7cnQUX0ptXc+WVZbNvOMHOAxiTJ3TYzdkdDlaGCON"));
|
||||
|
||||
/*AyaNova unlocked successfully!
|
||||
|
||||
Restart AyaNova at all computers
|
||||
for changes to take effect.*/
|
||||
rs->Close();
|
||||
|
||||
if(k!=NULL)
|
||||
{
|
||||
delete k;
|
||||
k=NULL;
|
||||
}
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CKD::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
CString s;
|
||||
s="QWCsICmK0VAp3QHZkVXA6zD5n8y6eFWhlrv9f3tN7iI";
|
||||
/*Enter registration key*/
|
||||
k->GZDecrypt(&s,false);
|
||||
|
||||
SetWindowText(s);
|
||||
|
||||
m_lblInfo.SetWindowText(k->InLineDecrypt("sqFcTepw4hTfxfEcWmBEnVoqtOQdRplq7YTuO15bhbpGHizIoQxNjPsvveG/VPqTr9cRA1gV"
|
||||
"KtUz5WpV8cUdKtAopAVu/6fo8t3P8bAeRwOdaPRYwMnj6Tnal8xZGiC5ltQDIudvV2hUK+b1"
|
||||
"IkF/JnIEcODBNqJrPO1eHaGc0HE="));
|
||||
|
||||
/*Thank you for registering AyaNova!
|
||||
|
||||
Enter your registered company name
|
||||
and keycode in the text boxes provided below.
|
||||
*/
|
||||
|
||||
m_lblC.SetWindowText(k->InLineDecrypt("7/dnsYwUjm7Bg8gxlE7K4eFK4UxUsu+Hha4OI04vLRs"));//registered to
|
||||
m_lblK.SetWindowText(k->InLineDecrypt("VIXCLaT+N2aEpijLHKeTUw"));//keycode
|
||||
|
||||
rs->Query("SELECT defaults.regto, defaults.key FROM defaults;");
|
||||
rs->FetchField("regto",&s);
|
||||
m_edC.SetWindowText(s);
|
||||
rs->FetchField("key",&s);
|
||||
m_edK.SetWindowText(s);
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
CKD::~CKD()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
|
||||
if(k!=NULL) delete k;
|
||||
}
|
||||
|
||||
56
archive/ayanova 1.9.4 CE final release db schema 171/sp/KD.h
Normal file
56
archive/ayanova 1.9.4 CE final release db schema 171/sp/KD.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#if !defined(AFX_KD_H__C319C5CF_5D50_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_KD_H__C319C5CF_5D50_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// KD.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CKD dialog
|
||||
#include "gzk.h"
|
||||
#include "gzrset.h"
|
||||
class CKD : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
|
||||
~CKD();
|
||||
CKD(CWnd* pParent = NULL); // standard constructor
|
||||
CSpApp* m_pApp;
|
||||
GZK* k;
|
||||
GZRset* rs;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CKD)
|
||||
enum { IDD = IDD_KD };
|
||||
CStatic m_lblK;
|
||||
CStatic m_lblInfo;
|
||||
CStatic m_lblC;
|
||||
CEdit m_edK;
|
||||
CEdit m_edC;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CKD)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CKD)
|
||||
afx_msg void OnBtnsave();
|
||||
virtual BOOL OnInitDialog();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_KD_H__C319C5CF_5D50_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,276 @@
|
||||
// Label.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "Resource.h"
|
||||
#include "Label.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLabel
|
||||
|
||||
CLabel::CLabel()
|
||||
{
|
||||
m_crText = GetSysColor(COLOR_WINDOWTEXT);
|
||||
m_hBrush = ::CreateSolidBrush(GetSysColor(COLOR_3DFACE));
|
||||
|
||||
::GetObject((HFONT)GetStockObject(DEFAULT_GUI_FONT),sizeof(m_lf),&m_lf);
|
||||
|
||||
m_font.CreateFontIndirect(&m_lf);
|
||||
m_bTimer = FALSE;
|
||||
m_bState = FALSE;
|
||||
m_bLink = TRUE;
|
||||
m_hCursor = NULL;
|
||||
m_Type = None;
|
||||
|
||||
m_hwndBrush = ::CreateSolidBrush(GetSysColor(COLOR_3DFACE));
|
||||
}
|
||||
|
||||
|
||||
CLabel::~CLabel()
|
||||
{
|
||||
m_font.DeleteObject();
|
||||
::DeleteObject(m_hBrush);
|
||||
}
|
||||
|
||||
CLabel& CLabel::SetText(const CString& strText)
|
||||
{
|
||||
SetWindowText(strText);
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLabel& CLabel::SetTextColor(COLORREF crText)
|
||||
{
|
||||
m_crText = crText;
|
||||
RedrawWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLabel& CLabel::SetFontBold(BOOL bBold)
|
||||
{
|
||||
m_lf.lfWeight = bBold ? FW_BOLD : FW_NORMAL;
|
||||
ReconstructFont();
|
||||
RedrawWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLabel& CLabel::SetFontUnderline(BOOL bSet)
|
||||
{
|
||||
m_lf.lfUnderline = bSet;
|
||||
ReconstructFont();
|
||||
RedrawWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLabel& CLabel::SetFontItalic(BOOL bSet)
|
||||
{
|
||||
m_lf.lfItalic = bSet;
|
||||
ReconstructFont();
|
||||
RedrawWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLabel& CLabel::SetSunken(BOOL bSet)
|
||||
{
|
||||
if (!bSet)
|
||||
ModifyStyleEx(WS_EX_STATICEDGE,0,SWP_DRAWFRAME);
|
||||
else
|
||||
ModifyStyleEx(0,WS_EX_STATICEDGE,SWP_DRAWFRAME);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLabel& CLabel::SetBorder(BOOL bSet)
|
||||
{
|
||||
if (!bSet)
|
||||
ModifyStyle(WS_BORDER,0,SWP_DRAWFRAME);
|
||||
else
|
||||
ModifyStyle(0,WS_BORDER,SWP_DRAWFRAME);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLabel& CLabel::SetFontSize(int nSize)
|
||||
{
|
||||
nSize*=-1;
|
||||
m_lf.lfHeight = nSize;
|
||||
ReconstructFont();
|
||||
RedrawWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
CLabel& CLabel::SetBkColor(COLORREF crBkgnd)
|
||||
{
|
||||
if (m_hBrush)
|
||||
::DeleteObject(m_hBrush);
|
||||
|
||||
m_hBrush = ::CreateSolidBrush(crBkgnd);
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLabel& CLabel::SetFontName(const CString& strFont)
|
||||
{
|
||||
strcpy(m_lf.lfFaceName,strFont);
|
||||
ReconstructFont();
|
||||
RedrawWindow();
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CLabel, CStatic)
|
||||
//{{AFX_MSG_MAP(CLabel)
|
||||
ON_WM_CTLCOLOR_REFLECT()
|
||||
ON_WM_TIMER()
|
||||
ON_WM_LBUTTONDOWN()
|
||||
ON_WM_SETCURSOR()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLabel message handlers
|
||||
|
||||
HBRUSH CLabel::CtlColor(CDC* pDC, UINT nCtlColor)
|
||||
{
|
||||
// TODO: Change any attributes of the DC here
|
||||
|
||||
// TODO: Return a non-NULL brush if the parent's handler should not be called
|
||||
|
||||
if (CTLCOLOR_STATIC == nCtlColor)
|
||||
{
|
||||
pDC->SelectObject(&m_font);
|
||||
pDC->SetTextColor(m_crText);
|
||||
pDC->SetBkMode(TRANSPARENT);
|
||||
}
|
||||
|
||||
|
||||
if (m_Type == Background)
|
||||
{
|
||||
if (!m_bState)
|
||||
return m_hwndBrush;
|
||||
}
|
||||
|
||||
return m_hBrush;
|
||||
}
|
||||
|
||||
void CLabel::ReconstructFont()
|
||||
{
|
||||
m_font.DeleteObject();
|
||||
BOOL bCreated = m_font.CreateFontIndirect(&m_lf);
|
||||
|
||||
ASSERT(bCreated);
|
||||
}
|
||||
|
||||
|
||||
CLabel& CLabel::FlashText(BOOL bActivate)
|
||||
{
|
||||
if (m_bTimer)
|
||||
{
|
||||
SetWindowText(m_strText);
|
||||
KillTimer(1);
|
||||
}
|
||||
|
||||
if (bActivate)
|
||||
{
|
||||
GetWindowText(m_strText);
|
||||
m_bState = FALSE;
|
||||
|
||||
m_bTimer = TRUE;
|
||||
SetTimer(1,500,NULL);
|
||||
m_Type = Text;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLabel& CLabel::FlashBackground(BOOL bActivate)
|
||||
{
|
||||
|
||||
if (m_bTimer)
|
||||
KillTimer(1);
|
||||
|
||||
if (bActivate)
|
||||
{
|
||||
m_bState = FALSE;
|
||||
|
||||
m_bTimer = TRUE;
|
||||
SetTimer(1,500,NULL);
|
||||
|
||||
m_Type = Background;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void CLabel::OnTimer(UINT nIDEvent)
|
||||
{
|
||||
m_bState = !m_bState;
|
||||
|
||||
switch (m_Type)
|
||||
{
|
||||
case Text:
|
||||
if (m_bState)
|
||||
SetWindowText("");
|
||||
else
|
||||
SetWindowText(m_strText);
|
||||
break;
|
||||
|
||||
case Background:
|
||||
InvalidateRect(NULL,FALSE);
|
||||
UpdateWindow();
|
||||
break;
|
||||
}
|
||||
|
||||
CStatic::OnTimer(nIDEvent);
|
||||
}
|
||||
|
||||
CLabel& CLabel::SetLink(BOOL bLink)
|
||||
{
|
||||
m_bLink = bLink;
|
||||
|
||||
if (bLink)
|
||||
ModifyStyle(0,SS_NOTIFY);
|
||||
else
|
||||
ModifyStyle(SS_NOTIFY,0);
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void CLabel::OnLButtonDown(UINT nFlags, CPoint point)
|
||||
{
|
||||
|
||||
if(!m_strURL.IsEmpty())//do this only if there was an url
|
||||
ShellExecute(NULL,"open",m_strURL,NULL,NULL,SW_SHOWNORMAL);
|
||||
|
||||
//otherwise it's probably a button for something internal
|
||||
CStatic::OnLButtonDown(nFlags, point);
|
||||
}
|
||||
|
||||
BOOL CLabel::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message)
|
||||
{
|
||||
if (m_hCursor)
|
||||
{
|
||||
::SetCursor(m_hCursor);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return CStatic::OnSetCursor(pWnd, nHitTest, message);
|
||||
}
|
||||
|
||||
CLabel& CLabel::SetLinkCursor(HCURSOR hCursor)
|
||||
{
|
||||
m_hCursor = hCursor;
|
||||
return *this;
|
||||
}
|
||||
|
||||
CLabel& CLabel::SetLinkURL(const CString& strText)
|
||||
{
|
||||
m_strURL.Format("%s",strText);
|
||||
return *this;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
#if !defined(AFX_LABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_)
|
||||
#define AFX_LABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
// Label.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLabel window
|
||||
enum FlashType {None, Text, Background };
|
||||
|
||||
class CLabel : public CStatic
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CLabel();
|
||||
CLabel& SetBkColor(COLORREF crBkgnd);
|
||||
CLabel& SetTextColor(COLORREF crText);
|
||||
CLabel& SetText(const CString& strText);
|
||||
CLabel& SetFontBold(BOOL bBold);
|
||||
CLabel& SetFontName(const CString& strFont);
|
||||
CLabel& SetFontUnderline(BOOL bSet);
|
||||
CLabel& SetFontItalic(BOOL bSet);
|
||||
CLabel& SetFontSize(int nSize);
|
||||
CLabel& SetSunken(BOOL bSet);
|
||||
CLabel& SetBorder(BOOL bSet);
|
||||
CLabel& FlashText(BOOL bActivate);
|
||||
CLabel& FlashBackground(BOOL bActivate);
|
||||
CLabel& SetLink(BOOL bLink);
|
||||
CLabel& SetLinkCursor(HCURSOR hCursor);
|
||||
CLabel& SetLinkURL(const CString& strText);
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
protected:
|
||||
void ReconstructFont();
|
||||
COLORREF m_crText;
|
||||
HBRUSH m_hBrush;
|
||||
HBRUSH m_hwndBrush;
|
||||
LOGFONT m_lf;
|
||||
CFont m_font;
|
||||
CString m_strText;
|
||||
CString m_strURL;//added to use separate url
|
||||
BOOL m_bState;
|
||||
BOOL m_bTimer;
|
||||
BOOL m_bLink;
|
||||
FlashType m_Type;
|
||||
HCURSOR m_hCursor;
|
||||
// Operations
|
||||
public:
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CLabel)
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CLabel();
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CLabel)
|
||||
afx_msg HBRUSH CtlColor(CDC* pDC, UINT nCtlColor);
|
||||
afx_msg void OnTimer(UINT nIDEvent);
|
||||
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
||||
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
|
||||
//}}AFX_MSG
|
||||
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_LABEL_H__A4EABEC5_2E8C_11D1_B79F_00805F9ECE10__INCLUDED_)
|
||||
@@ -0,0 +1,823 @@
|
||||
// LoanersDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "LoanersDlg.h"
|
||||
#include "loanerseditdlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLoanersDlg dialog
|
||||
|
||||
|
||||
CLoanersDlg::CLoanersDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CLoanersDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CLoanersDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
|
||||
rsPrint=m_pApp->rsPool->GetRSPrint("CLoanersDlg rsPrint");
|
||||
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CLoanersDlg");
|
||||
|
||||
m_strCriteria=" WHERE (((rentals.returned)=False))";
|
||||
m_nDateCriteriaX=0;
|
||||
//show rented out items only when startup
|
||||
m_nTypeCriteriaX=2;
|
||||
}
|
||||
|
||||
CLoanersDlg::~CLoanersDlg()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rsPrint->m_nID);
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
void CLoanersDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CLoanersDlg)
|
||||
DDX_Control(pDX, IDC_CKRECEIVEDDATE, m_ckReceivedDate);
|
||||
DDX_Control(pDX, IDC_CKDUEDATE, m_ckDueDate);
|
||||
DDX_Control(pDX, IDC_CKANYDATE, m_ckAnyDate);
|
||||
DDX_Control(pDX, IDC_CKSENTDATE, m_ckSentDate);
|
||||
DDX_Control(pDX, IDC_CKSHOWRETURNED, m_ckShowReturned);
|
||||
DDX_Control(pDX, IDC_CKSHOWOUT, m_ckShowOut);
|
||||
DDX_Control(pDX, IDC_CKSHOWALLITEMS, m_ckShowAll);
|
||||
DDX_Control(pDX, IDC_REPORT, m_rc);
|
||||
DDX_Control(pDX, IDC_lblTo, m_lblTo);
|
||||
DDX_Control(pDX, IDC_DTTO, m_dtTo);
|
||||
DDX_Control(pDX, IDC_DTFROM, m_dtFrom);
|
||||
//}}AFX_DATA_MAP
|
||||
DDX_Control(pDX, IDC_LBL_SHOW, m_lblShow);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CLoanersDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CLoanersDlg)
|
||||
ON_BN_CLICKED(IDC_CKANYDATE, OnCkanydate)
|
||||
ON_BN_CLICKED(IDC_CKSENTDATE, OnCksentdate)
|
||||
ON_BN_CLICKED(IDC_CKDUEDATE, OnCkduedate)
|
||||
ON_BN_CLICKED(IDC_CKRECEIVEDDATE, OnCkreceiveddate)
|
||||
ON_BN_CLICKED(IDC_CKSHOWRETURNED, OnCkshowreturned)
|
||||
ON_BN_CLICKED(IDC_CKSHOWOUT, OnCkshowout)
|
||||
ON_BN_CLICKED(IDC_CKSHOWALLITEMS, OnCkshowallitems)
|
||||
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTTO, OnDatetimechangeDtto)
|
||||
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTFROM, OnDatetimechangeDtfrom)
|
||||
ON_NOTIFY(RVN_ITEMDBCLICK, IDC_REPORT, OnRvnItemDbClick)
|
||||
ON_NOTIFY(RVN_COLUMNCLICK, IDC_REPORT, OnColumnClick)
|
||||
ON_BN_CLICKED(IDC_BTNPRINT, OnBtnprint)
|
||||
//}}AFX_MSG_MAP
|
||||
ON_COMMAND(ID_NEW, OnNew)
|
||||
ON_COMMAND(ID_DELETE, OnDelete)
|
||||
ON_COMMAND(ID_CLOSE_LOANERS_AND_RENTALS, OnCloseThisScreen)
|
||||
ON_COMMAND(ID_HELPONLOANERS, OnHelponloaners)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLoanersDlg message handlers
|
||||
void CLoanersDlg::OnRvnItemDbClick(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
|
||||
LPNMREPORTVIEW lpnmrv = (LPNMREPORTVIEW)pNMHDR;
|
||||
|
||||
|
||||
|
||||
if(lpnmrv->iItem >=0)//-1 if clicked on invalid
|
||||
{
|
||||
|
||||
CLoanersEditDlg d;
|
||||
CString item=m_rc.GetItemText(lpnmrv->iItem,6);
|
||||
d.SetRentalID(&item);
|
||||
if(d.DoModal()==IDOK)
|
||||
FillView();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
*pResult = FALSE;
|
||||
}
|
||||
|
||||
BOOL CLoanersDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
m_resize.Create( this );
|
||||
ShowWindow(SW_HIDE);
|
||||
Security();
|
||||
CWaitCursor wait;
|
||||
//defaults
|
||||
m_ckShowOut.SetCheck(TRUE);
|
||||
m_ckAnyDate.SetCheck(TRUE);
|
||||
|
||||
CString profile,q;
|
||||
q.Format("SELECT users.rentalprofile "
|
||||
"FROM users WHERE (((users.id)=%u));",m_pApp->m_lusrID);
|
||||
rs->Query(q);
|
||||
rs->FetchField("rentalprofile",&profile);
|
||||
|
||||
|
||||
|
||||
m_ilReport.Create(IDB_BM2, 16, 1, RGB(255,0,255));
|
||||
m_rc.SetImageList(&m_ilReport);
|
||||
|
||||
//ShowWindow(SW_MAXIMIZE);
|
||||
|
||||
m_rc.InsertColor(0, 0x00C0D8C0);
|
||||
m_rc.InsertColor(1, ::GetSysColor(COLOR_GRAYTEXT));
|
||||
m_rc.InsertColor(2, 0x00D0C0C0);
|
||||
m_rc.InsertColor(3, 0x00804000);
|
||||
|
||||
|
||||
RVCOLUMN rvc;
|
||||
|
||||
rvc.nFormat = RVCF_TEXT|RVCF_EX_AUTOWIDTH|RVCF_EX_FIXEDWIDTH|RVCF_SUBITEM_IMAGE;
|
||||
rvc.iImage = 1;
|
||||
rvc.lpszText = _T("Status");
|
||||
rvc.iWidth = 60;
|
||||
m_rc.DefineColumn(0, &rvc);
|
||||
|
||||
rvc.nFormat = RVCF_TEXT;
|
||||
rvc.lpszText = "Item";
|
||||
rvc.iWidth = 60;
|
||||
m_rc.DefineColumn(1, &rvc);
|
||||
|
||||
rvc.lpszText = "At";
|
||||
rvc.iWidth = 60;
|
||||
m_rc.DefineColumn(2, &rvc);
|
||||
|
||||
rvc.lpszText = "Out";
|
||||
rvc.iWidth = 60;
|
||||
m_rc.DefineColumn(3, &rvc);
|
||||
|
||||
rvc.nFormat = RVCF_TEXT;
|
||||
rvc.lpszText = "Due";
|
||||
rvc.iWidth = 60;
|
||||
m_rc.DefineColumn(4, &rvc);
|
||||
|
||||
rvc.lpszText = "Rcvd.";
|
||||
rvc.iWidth = 60;
|
||||
m_rc.DefineColumn(5, &rvc);
|
||||
|
||||
rvc.nFormat = RVCF_TEXT | RVCF_EX_FIXEDWIDTH;
|
||||
rvc.lpszText = "id";
|
||||
rvc.iWidth = 0;
|
||||
m_rc.DefineColumn(6, &rvc);
|
||||
|
||||
rvc.nFormat = RVCF_TEXT;
|
||||
rvc.lpszText = "Ref";
|
||||
rvc.iWidth = 60;
|
||||
m_rc.DefineColumn(7, &rvc);
|
||||
|
||||
rvc.nFormat = RVCF_TEXT;
|
||||
rvc.lpszText = "Desc.";
|
||||
rvc.iWidth = 60;
|
||||
m_rc.DefineColumn(8, &rvc);
|
||||
|
||||
//setup according to users preferences
|
||||
if(!profile.IsEmpty())
|
||||
m_rc.GetProfile(&profile);
|
||||
else
|
||||
{
|
||||
|
||||
//not needed when setting by pref
|
||||
//but if there are no preferences then you would need it
|
||||
|
||||
m_rc.ActivateColumn(0, 0);
|
||||
m_rc.ActivateColumn(1, 1);
|
||||
m_rc.ActivateColumn(2, 2);
|
||||
m_rc.ActivateColumn(3, 3);
|
||||
m_rc.ActivateColumn(4, 4);
|
||||
m_rc.ActivateColumn(5, 5);
|
||||
m_rc.ActivateColumn(6, 6);
|
||||
m_rc.ActivateColumn(7, 7);
|
||||
m_rc.ActivateColumn(8, 8);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_rc.ModifyStyle(0, RVS_SINGLESELECT);
|
||||
//m_rc.ModifyStyle(0, RVS_SHOWCOLORALTERNATE);
|
||||
|
||||
|
||||
//turn off the grids
|
||||
m_rc.ModifyStyle(RVS_SHOWVGRID, 0);
|
||||
m_rc.ModifyStyle(RVS_SHOWHGRID, 0);
|
||||
|
||||
|
||||
|
||||
//retrieve the loaner items and display them
|
||||
FillView();
|
||||
Layout();
|
||||
|
||||
//Use the current width and height as the minimum size
|
||||
m_resize.SetMinimumTrackingSize();
|
||||
|
||||
//===================================================
|
||||
// SET WINDOW SIZE TO MATCH WORK AREA
|
||||
ShowWindow(SW_SHOWMAXIMIZED);
|
||||
CRect workarea;
|
||||
SystemParametersInfo(SPI_GETWORKAREA,0,&workarea,0);
|
||||
SetWindowPos(NULL,workarea.left,workarea.top,workarea.Width(),workarea.Height(),SWP_NOZORDER);
|
||||
//===================================================
|
||||
|
||||
|
||||
//ShowWindow(SW_MAXIMIZE);
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CLoanersDlg::FillView()
|
||||
{
|
||||
CString q;
|
||||
COleDateTime dtDefault;
|
||||
dtDefault.SetDate(1968,03,12);
|
||||
int x=0;
|
||||
q.Format("SELECT rentals.id, rentals.ref, IIf(IsNull([sn]),[rentals].[description] & [parts].[description],[company_person] & "
|
||||
"\" \" & [unitmodels].[description] & \" \" & [unitmodels].[model]) AS [desc], [rentals]![description] & "
|
||||
"IIf(IsNull([parts]![partnumber]),\"\",\"part:\" & [parts]![partnumber]) & "
|
||||
"IIf(IsNull([units]![sn]),\"\",\"unit:\" & [units]![sn]) AS item, [loanedto] & "
|
||||
"IIf(IsNull([clients]![company]),[clients]![first] & \" \" & [clients]![last],[clients]![company]) "
|
||||
"AS rentor, Format([dateout],\"Short Date\") AS outdate, IIf([datedue]=#%s#,\"na\",Format([datedue], "
|
||||
"\"Short Date\")) AS duedate, IIf([datereturn]=#%s#,\"Out\",Format([datereturn],\"Short Date\")) "
|
||||
"AS retdate, rentals.returned, DateDiff(\"d\",Now(),[datedue]) AS duedays "
|
||||
"FROM ((((rentals LEFT JOIN clients ON rentals.clientlink = clients.id) LEFT JOIN "
|
||||
"units ON rentals.unitlink = units.id) LEFT JOIN parts ON rentals.partlink = parts.id) "
|
||||
"LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id "
|
||||
"%s %s;",dtDefault.Format(_T("%m/%d/%Y")),
|
||||
dtDefault.Format(_T("%m/%d/%Y")),m_strCriteria,m_strOrderBy);
|
||||
/*
|
||||
q.Format("SELECT rentals.id, rentals.ref, [rentals]![description] "
|
||||
"& IIf(IsNull([parts]![partnumber]),\"\","
|
||||
"\"part:\" & [parts]![partnumber] ) & "
|
||||
"IIf(IsNull([units]![sn]),\"\",\"unit:\" & "
|
||||
"[units]![sn]) AS item, [loanedto] & "
|
||||
"IIf(IsNull([clients]![company]), "
|
||||
"[clients]![first] & \" \" & [clients]![last], "
|
||||
"[clients]![company]) AS rentor, Format([dateout], "
|
||||
"\"Short Date\") AS outdate, IIf([datedue]=#%s# "
|
||||
",\"na\",Format([datedue],\"Short Date\")) AS "
|
||||
"duedate, IIf([datereturn]=#%s#,\"Out\", "
|
||||
"Format([datereturn],\"Short Date\")) AS retdate, "
|
||||
"rentals.returned, DateDiff(\"d\",Now(),[datedue]) AS duedays "
|
||||
"FROM ((rentals LEFT JOIN clients ON "
|
||||
"rentals.clientlink = clients.id) LEFT JOIN units "
|
||||
"ON rentals.unitlink = units.id) LEFT JOIN parts "
|
||||
"ON rentals.partlink = parts.id %s %s;",dtDefault.Format(_T("%m/%d/%Y")),
|
||||
dtDefault.Format(_T("%m/%d/%Y")),m_strCriteria,m_strOrderBy);
|
||||
*/
|
||||
|
||||
//"WHERE ( ((rentals.datereturn) Between #06/01/2000# And #06/30/2000#) AND ((rentals.returned)=False));");
|
||||
// "WHERE ( ((rentals.returned)=True) AND ((rentals.dateout) Between #1/1/1990# And #1/1/2000#));");
|
||||
|
||||
|
||||
//WHERE (((rentals.returned)=True) AND ((rentals.dateout) Between #1/1/1990# And #1/1/2001#))
|
||||
//rs->Query("SELECT rentals.* FROM rentals WHERE (((rentals.id)=0));");
|
||||
|
||||
rs->Query(q);
|
||||
//m_pApp->ShowStuff(q);
|
||||
m_rc.DeleteAllItems();
|
||||
|
||||
|
||||
if(rs->IsEmpty())
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
CString strData,strItem,strRentor,strOutdate,strDueDays,strDuedate,strRetdate,strID,strRef,strDesc;
|
||||
COleDateTime dtDate;
|
||||
long lData;
|
||||
long lDueDays;
|
||||
bool bReturned;
|
||||
int nDueDays;
|
||||
rs->MoveFirst();
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
rs->FetchField("item",&strItem);
|
||||
//avoid the underline in the report control
|
||||
//for a single &
|
||||
strItem.Replace("&","&&");
|
||||
|
||||
|
||||
rs->FetchField("rentor",&strRentor);
|
||||
strRentor.Replace("&","&&");
|
||||
|
||||
rs->FetchField("outdate",&strOutdate);
|
||||
|
||||
rs->FetchField("duedate",&strDuedate);
|
||||
|
||||
rs->FetchField("retdate",&strRetdate);
|
||||
|
||||
rs->FetchField("duedays",&lDueDays);
|
||||
nDueDays=lDueDays;//atoi(strDueDays);
|
||||
|
||||
rs->FetchField("id",&lData);
|
||||
strID.Format("%u",lData);
|
||||
|
||||
rs->FetchField("returned",&bReturned);
|
||||
|
||||
rs->FetchField("ref",&strRef);
|
||||
|
||||
rs->FetchField("desc",&strDesc);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Set the look of the row and insert it
|
||||
|
||||
//LATE!
|
||||
RVITEM rvi;
|
||||
rvi.iItem = x;
|
||||
rvi.iSubItem = 0;
|
||||
rvi.nMask = RVIM_IMAGE|RVIM_PREVIEW|RVIM_STATE|RVIM_LPARAM;
|
||||
rvi.nState = 0;
|
||||
rvi.nPreview = 0;//no preview necessary
|
||||
if(bReturned)
|
||||
rvi.iImage=3;//blank
|
||||
else
|
||||
{
|
||||
rvi.iImage=0;//green light - default
|
||||
|
||||
if(nDueDays<0)//overdue
|
||||
rvi.iImage=2;//redlight
|
||||
|
||||
if(nDueDays==0)//due today
|
||||
rvi.iImage=1;//orange light
|
||||
|
||||
}
|
||||
|
||||
rvi.lParam = x;
|
||||
m_rc.InsertItem(&rvi);
|
||||
|
||||
|
||||
//ITEM
|
||||
rvi.iSubItem = 1;
|
||||
rvi.nMask = RVIM_TEXT;
|
||||
rvi.lpszText = strItem.GetBuffer(strItem.GetLength());
|
||||
m_rc.SetItem(&rvi);
|
||||
|
||||
//AT
|
||||
rvi.iSubItem = 2;
|
||||
rvi.lpszText = strRentor.GetBuffer(strRentor.GetLength());
|
||||
m_rc.SetItem(&rvi);
|
||||
|
||||
//OUT
|
||||
rvi.iSubItem = 3;
|
||||
rvi.lpszText = strOutdate.GetBuffer(strOutdate.GetLength());
|
||||
m_rc.SetItem(&rvi);
|
||||
|
||||
//DUE
|
||||
rvi.iSubItem = 4;
|
||||
rvi.lpszText = strDuedate.GetBuffer(strDuedate.GetLength());
|
||||
m_rc.SetItem(&rvi);
|
||||
|
||||
//BACK
|
||||
rvi.iSubItem = 5;
|
||||
if(bReturned==false)
|
||||
rvi.lpszText=" ";
|
||||
else
|
||||
rvi.lpszText = strRetdate.GetBuffer(strRetdate.GetLength());
|
||||
m_rc.SetItem(&rvi);
|
||||
|
||||
|
||||
//ID
|
||||
rvi.iSubItem = 6;
|
||||
rvi.lpszText = strID.GetBuffer(strID.GetLength());
|
||||
m_rc.SetItem(&rvi);
|
||||
|
||||
//ref
|
||||
rvi.iSubItem = 7;
|
||||
rvi.lpszText = strRef.GetBuffer(strRef.GetLength());
|
||||
m_rc.SetItem(&rvi);
|
||||
|
||||
//description
|
||||
rvi.iSubItem = 8;
|
||||
rvi.lpszText = strDesc.GetBuffer(strDesc.GetLength());
|
||||
m_rc.SetItem(&rvi);
|
||||
|
||||
x++;
|
||||
|
||||
}while(rs->MoveForward());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//SET CRITERIA FOR QUERY:
|
||||
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
//*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
|
||||
void CLoanersDlg::OnCkanydate()
|
||||
{
|
||||
m_nDateCriteriaX=0;
|
||||
ShowDateFields(false);
|
||||
Criteria();
|
||||
}
|
||||
|
||||
void CLoanersDlg::OnCksentdate()
|
||||
{/*
|
||||
if(m_nDateCriteriaX==0)//were not dates showing before
|
||||
{
|
||||
//so just show dates and exit
|
||||
m_ckAnyDate.SetCheck(FALSE);
|
||||
ShowDateFields(true);
|
||||
m_nDateCriteriaX=(1);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
ShowDateFields(true);
|
||||
m_nDateCriteriaX=(1);
|
||||
Criteria();
|
||||
}
|
||||
|
||||
void CLoanersDlg::OnCkduedate()
|
||||
{/*
|
||||
if(m_nDateCriteriaX==0)//were not dates showing before
|
||||
{
|
||||
//so just show dates and exit
|
||||
m_ckAnyDate.SetCheck(FALSE);
|
||||
ShowDateFields(true);
|
||||
m_nDateCriteriaX=(2);
|
||||
return;
|
||||
}*/
|
||||
ShowDateFields(true);
|
||||
m_nDateCriteriaX=(2);
|
||||
Criteria();
|
||||
}
|
||||
|
||||
void CLoanersDlg::OnCkreceiveddate()
|
||||
{
|
||||
/*
|
||||
if(m_nDateCriteriaX==0)//were not dates showing before
|
||||
{
|
||||
//so just show dates and exit
|
||||
m_ckAnyDate.SetCheck(FALSE);
|
||||
ShowDateFields(true);
|
||||
m_nDateCriteriaX=(3);
|
||||
return;
|
||||
}*/
|
||||
ShowDateFields(true);
|
||||
m_nDateCriteriaX=(3);
|
||||
Criteria();
|
||||
|
||||
}
|
||||
|
||||
void CLoanersDlg::OnDatetimechangeDtto(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
|
||||
Criteria();
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
void CLoanersDlg::OnDatetimechangeDtfrom(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
|
||||
Criteria();
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
void CLoanersDlg::OnCkshowreturned()
|
||||
{
|
||||
m_nTypeCriteriaX=1;
|
||||
Criteria();
|
||||
|
||||
}
|
||||
|
||||
void CLoanersDlg::OnCkshowout()
|
||||
{
|
||||
m_nTypeCriteriaX=2;
|
||||
Criteria();
|
||||
}
|
||||
|
||||
void CLoanersDlg::OnCkshowallitems()
|
||||
{
|
||||
m_nTypeCriteriaX=0;
|
||||
Criteria();
|
||||
}
|
||||
|
||||
|
||||
//set date and type criteria and rebuild list
|
||||
void CLoanersDlg::Criteria()
|
||||
{
|
||||
CString strFrom,strTo,strDatePart,strTypePart;
|
||||
COleDateTime dtData;
|
||||
m_ckAnyDate.SetCheck(FALSE);
|
||||
m_ckDueDate.SetCheck(FALSE);
|
||||
m_ckSentDate.SetCheck(FALSE);
|
||||
m_ckShowAll.SetCheck(FALSE);
|
||||
m_ckShowOut.SetCheck(FALSE);
|
||||
m_ckShowReturned.SetCheck(FALSE);
|
||||
m_ckReceivedDate.SetCheck(FALSE);
|
||||
|
||||
m_dtFrom.GetTime(dtData);
|
||||
strFrom=dtData.Format(_T("%m/%d/%Y"));
|
||||
|
||||
m_dtTo.GetTime(dtData);
|
||||
strTo=dtData.Format(_T("%m/%d/%Y"));
|
||||
|
||||
m_strCriteria.Empty();
|
||||
|
||||
switch(m_nDateCriteriaX)
|
||||
{
|
||||
|
||||
case 1://sent date
|
||||
m_ckSentDate.SetCheck(TRUE);
|
||||
strDatePart.Format("((rentals.dateout) Between #%s# And #%s#)",strFrom,strTo);
|
||||
break;
|
||||
|
||||
case 2://due date
|
||||
m_ckDueDate.SetCheck(TRUE);
|
||||
strDatePart.Format("((rentals.datedue) Between #%s# And #%s#)",strFrom,strTo);
|
||||
break;
|
||||
|
||||
case 3://received date
|
||||
m_ckReceivedDate.SetCheck(TRUE);
|
||||
strDatePart.Format("((rentals.datereturn) Between #%s# And #%s#) AND ((rentals.returned)=True)",strFrom,strTo);
|
||||
break;
|
||||
|
||||
default://any date
|
||||
strDatePart.Empty();
|
||||
m_ckAnyDate.SetCheck(TRUE);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch(m_nTypeCriteriaX)
|
||||
{
|
||||
|
||||
case 1://returned
|
||||
strTypePart=" ((rentals.returned)=True)";
|
||||
|
||||
m_ckShowReturned.SetCheck(TRUE);
|
||||
break;
|
||||
|
||||
case 2://out
|
||||
|
||||
m_ckShowOut.SetCheck(TRUE);
|
||||
strTypePart=" ((rentals.returned)=False)";
|
||||
break;
|
||||
|
||||
default://all
|
||||
m_ckShowAll.SetCheck(TRUE);
|
||||
strTypePart.Empty();
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//No criteria
|
||||
if(strDatePart.IsEmpty() && strTypePart.IsEmpty())
|
||||
{
|
||||
m_strCriteria.Empty();
|
||||
FillView();
|
||||
return;
|
||||
}
|
||||
|
||||
//both criteria
|
||||
if(!strDatePart.IsEmpty() && !strTypePart.IsEmpty() )
|
||||
{
|
||||
|
||||
m_strCriteria=" WHERE (" + strTypePart + " AND " + strDatePart + ")";
|
||||
FillView();
|
||||
return;
|
||||
}
|
||||
|
||||
//only one criteria
|
||||
if(!strTypePart.IsEmpty())
|
||||
{
|
||||
m_strCriteria = " WHERE (" + strTypePart+ ")";
|
||||
FillView();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_strCriteria=" WHERE (" + strDatePart+ ")";
|
||||
FillView();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CLoanersDlg::ShowDateFields(bool bShow)
|
||||
{
|
||||
m_dtFrom.ShowWindow(bShow ? TRUE : FALSE);
|
||||
m_dtTo.ShowWindow(bShow ? TRUE : FALSE);
|
||||
m_lblTo.ShowWindow(bShow ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
|
||||
void CLoanersDlg::Security()
|
||||
{
|
||||
int x=m_pApp->Allowed(RLOANERS,true);
|
||||
|
||||
if(x==2)//read only
|
||||
{
|
||||
m_btnAdd.ShowWindow(FALSE);
|
||||
m_btnDelete.ShowWindow(FALSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(x==0)
|
||||
{
|
||||
m_pApp->SecurityWarning();
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//SET ORDER BY CLAUSE DEPENDING ON CLICK HERE
|
||||
void CLoanersDlg::OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
int x;
|
||||
CString str;
|
||||
CFlatHeaderCtrl* header;
|
||||
header=m_rc.GetHeaderCtrl();
|
||||
|
||||
|
||||
//FIND CLICKED COLUMN
|
||||
|
||||
str=header->m_szHotItemText;
|
||||
|
||||
if(str=="Status"){x=0;goto OUTTAHERE;}
|
||||
if(str=="Item"){x=1;goto OUTTAHERE;}
|
||||
if(str=="At"){x=2;goto OUTTAHERE;}
|
||||
if(str=="Out"){x=3;goto OUTTAHERE;}
|
||||
if(str=="Due"){x=4;goto OUTTAHERE;}
|
||||
if(str=="Rcvd."){x=5;goto OUTTAHERE;}
|
||||
if(str=="Ref"){x=7;goto OUTTAHERE;}
|
||||
if(str=="Desc."){x=8;goto OUTTAHERE;}
|
||||
|
||||
|
||||
OUTTAHERE:
|
||||
|
||||
|
||||
bColumnSortAsc[x]=!bColumnSortAsc[x];
|
||||
switch(x)
|
||||
{//DESC
|
||||
case 0://duedays
|
||||
m_strOrderBy="ORDER BY [datedue]";
|
||||
break;
|
||||
case 1://item
|
||||
m_strOrderBy="ORDER BY [rentals]![description] & IIf(IsNull([parts]![partnumber]),\"\",\"part:\" & [parts]![partnumber]) & IIf(IsNull([units]![sn]),\"\",\"unit:\" & [units]![sn])";
|
||||
break;
|
||||
case 2://RENTOR
|
||||
m_strOrderBy="ORDER BY [loanedto] & IIf(IsNull([clients]![company]),[clients]![first] & \" \" & [clients]![last],[clients]![company])";
|
||||
break;
|
||||
case 3://OUTDATE
|
||||
m_strOrderBy="ORDER BY [dateout]";
|
||||
break;
|
||||
|
||||
case 4://DUEDATE
|
||||
m_strOrderBy="ORDER BY [datedue]";
|
||||
break;
|
||||
|
||||
case 5://backdate/returned
|
||||
m_strOrderBy="ORDER BY rentals.returned,[datereturn]";
|
||||
break;
|
||||
|
||||
//case 6: is id number so not sortable
|
||||
|
||||
case 7://reference number/text
|
||||
m_strOrderBy="ORDER BY rentals.ref";
|
||||
break;
|
||||
|
||||
case 8://Description
|
||||
m_strOrderBy="ORDER BY IIf(IsNull([sn]),[rentals].[description] & [parts].[description],[company_person] & \" \" & [unitmodels].[description] & \" \" & [unitmodels].[model])";
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(!bColumnSortAsc[x])
|
||||
m_strOrderBy+=" DESC";
|
||||
|
||||
|
||||
header->SetSortColumn(header->GetHotIndex(),bColumnSortAsc[x]);
|
||||
|
||||
*pResult = TRUE;//TRUE means we handled it here thanks anyway
|
||||
FillView();
|
||||
}
|
||||
|
||||
|
||||
void CLoanersDlg::OnBtnprint()
|
||||
{
|
||||
CString q;
|
||||
COleDateTime dtDefault;
|
||||
dtDefault.SetDate(1968,03,12);
|
||||
q.Format("SELECT rentals.*, IIf(IsNull([sn]),[rentals].[description] & [parts].[description],[company_person] & "
|
||||
"\" \" & [unitmodels].[description] & \" \" & [unitmodels].[model]) AS [desc], [rentals]![description] & "
|
||||
"IIf(IsNull([parts]![partnumber]),\"\",\"part:\" & [parts]![partnumber]) & "
|
||||
"IIf(IsNull([units]![sn]),\"\",\"unit:\" & [units]![sn]) AS item, [loanedto] & "
|
||||
"IIf(IsNull([clients]![company]),[clients]![first] & \" \" & [clients]![last],[clients]![company]) "
|
||||
"AS rentor, Format([dateout],\"Short Date\") AS outdate, IIf([datedue]=#%s#,\"na\",Format([datedue], "
|
||||
"\"Short Date\")) AS duedate, IIf([datereturn]=#%s#,\"Out\",Format([datereturn],\"Short Date\")) "
|
||||
"AS retdate, DateDiff(\"d\",Now(),[datedue]) AS duedays "
|
||||
"FROM ((((rentals LEFT JOIN clients ON rentals.clientlink = clients.id) LEFT JOIN "
|
||||
"units ON rentals.unitlink = units.id) LEFT JOIN parts ON rentals.partlink = parts.id) "
|
||||
"LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id "
|
||||
"%s %s;",dtDefault.Format(_T("%m/%d/%Y")),
|
||||
dtDefault.Format(_T("%m/%d/%Y")),m_strCriteria,m_strOrderBy);
|
||||
|
||||
rsPrint->QueryReadOnly(q);
|
||||
if(rsPrint->IsEmpty())
|
||||
{
|
||||
AfxMessageBox("Nothing to print!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
//m_pApp->CreateTTX("loaners.ttx",rsPrint->RecordSetPointer());
|
||||
m_pApp->PrintCMReportRDC("loaners",rsPrint->RecordSetPointer());
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CLoanersDlg::OnNew()
|
||||
{
|
||||
CLoanersEditDlg d;
|
||||
if(d.DoModal()==IDOK)
|
||||
FillView();
|
||||
}
|
||||
|
||||
void CLoanersDlg::OnDelete()
|
||||
{
|
||||
int x;
|
||||
CString q,strID;
|
||||
x=m_rc.GetFirstSelectedItem();
|
||||
if(x<0) return;//no selection
|
||||
if(AfxMessageBox("Delete the highlighted item? Are you sure?",MB_YESNO)==IDNO)
|
||||
return;
|
||||
|
||||
strID=m_rc.GetItemText(x,6);
|
||||
|
||||
q.Format("DELETE rentals.* FROM rentals WHERE (((rentals.id)=%s));",strID);
|
||||
rs->Ex(q);
|
||||
FillView();
|
||||
}
|
||||
|
||||
void CLoanersDlg::OnCloseThisScreen()
|
||||
{
|
||||
CString profile,q;
|
||||
//save to user prefs.
|
||||
m_rc.WriteProfile(&profile);
|
||||
q.Format("UPDATE users SET users.rentalprofile = \"%s\" "
|
||||
"WHERE (((users.id)=%u));",profile,m_pApp->m_lusrID);
|
||||
rs->Ex(q);
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CLoanersDlg::OnHelponloaners()
|
||||
{
|
||||
WinHelp(0x200A8);
|
||||
//
|
||||
}
|
||||
|
||||
void CLoanersDlg::Layout(void)
|
||||
{
|
||||
int nVertFactor;//used to scale vertically
|
||||
int nDelta=0;//change in vertical height
|
||||
nVertFactor=0;
|
||||
nDelta=5;
|
||||
|
||||
|
||||
m_resize.Add(IDC_LBL_SHOW,0,100,0,0);
|
||||
m_resize.Add(IDC_CKSHOWRETURNED,0,100,0,0);
|
||||
|
||||
m_resize.Add(IDC_CKSHOWOUT,0,100,0,0);
|
||||
m_resize.Add(IDC_CKSHOWALLITEMS,0,100,0,0);
|
||||
m_resize.Add(IDC_CKANYDATE,0,100,0,0);
|
||||
m_resize.Add(IDC_CKSENTDATE,0,100,0,0);
|
||||
m_resize.Add(IDC_CKDUEDATE,0,100,0,0);
|
||||
m_resize.Add(IDC_CKRECEIVEDDATE,0,100,0,0);
|
||||
m_resize.Add(IDC_DTFROM,0,100,0,0);
|
||||
m_resize.Add(IDC_lblTo,0,100,0,0);
|
||||
m_resize.Add(IDC_DTTO,0,100,0,0);
|
||||
m_resize.Add(IDC_REPORT,0,0,100,100);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
#if !defined(AFX_LOANERSDLG_H__AC027B41_4377_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_LOANERSDLG_H__AC027B41_4377_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// LoanersDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLoanersDlg dialog
|
||||
#include "ReportCtrl.h"
|
||||
#include "gzrset.h"
|
||||
#include "ResizeCtrl.h"
|
||||
#include "afxwin.h"
|
||||
class CLoanersDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CResizeCtrl m_resize;
|
||||
BOOL bColumnSortAsc[9];//<---COLUMN COUNT HERE MUST BE UPDATED WHEN NEW ONES ADDED
|
||||
CString m_strOrderBy;
|
||||
void Security();
|
||||
~CLoanersDlg();
|
||||
void ShowDateFields(bool bShow);
|
||||
int m_nDateCriteriaX;
|
||||
int m_nTypeCriteriaX;
|
||||
CString m_strCriteria;
|
||||
void Criteria();
|
||||
void FillView();
|
||||
CLoanersDlg(CWnd* pParent = NULL); // standard constructor
|
||||
GZRset* rs;
|
||||
GZRset* rsPrint;
|
||||
CSpApp* m_pApp;
|
||||
void OnRvnItemDbClick(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
void OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CLoanersDlg)
|
||||
enum { IDD = IDD_LOANERS };
|
||||
CButton m_btnPrint;
|
||||
CButton m_btnDelete;
|
||||
CButton m_btnAdd;
|
||||
CButton m_ckReceivedDate;
|
||||
CButton m_ckDueDate;
|
||||
CButton m_ckAnyDate;
|
||||
CButton m_ckSentDate;
|
||||
CButton m_ckShowReturned;
|
||||
CButton m_ckShowOut;
|
||||
CButton m_ckShowAll;
|
||||
CReportCtrl m_rc;
|
||||
CStatic m_lblTo;
|
||||
CDateTimeCtrl m_dtTo;
|
||||
CDateTimeCtrl m_dtFrom;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CLoanersDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
CImageList m_ilReport;
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CLoanersDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnCkanydate();
|
||||
afx_msg void OnCksentdate();
|
||||
afx_msg void OnCkduedate();
|
||||
afx_msg void OnCkreceiveddate();
|
||||
afx_msg void OnCkshowreturned();
|
||||
afx_msg void OnCkshowout();
|
||||
afx_msg void OnCkshowallitems();
|
||||
afx_msg void OnDatetimechangeDtto(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnDatetimechangeDtfrom(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnBtnprint();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
afx_msg void OnNew();
|
||||
afx_msg void OnDelete();
|
||||
afx_msg void OnCloseThisScreen();
|
||||
afx_msg void OnHelponloaners();
|
||||
void Layout(void);
|
||||
CStatic m_lblShow;
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_LOANERSDLG_H__AC027B41_4377_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,476 @@
|
||||
// LoanersEditDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "LoanersEditDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLoanersEditDlg dialog
|
||||
|
||||
|
||||
CLoanersEditDlg::CLoanersEditDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CLoanersEditDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CLoanersEditDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp = (CSpApp*)AfxGetApp();
|
||||
//Initialize recordset pointer
|
||||
rs=m_pApp->rsPool->GetRS("CLoanersEditDlg");
|
||||
rs2=m_pApp->rsPool->GetRS("CLoanersEditDlg rs2");
|
||||
|
||||
cfm = new CgzCurrencyFormatter;
|
||||
m_strRentalID.Empty();
|
||||
m_strSelClient="0";
|
||||
m_strSelUnit="0";
|
||||
m_strSelPart="0";
|
||||
}
|
||||
|
||||
CLoanersEditDlg::~CLoanersEditDlg()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
m_pApp->rsPool->ReleaseRS(&rs2->m_nID);
|
||||
|
||||
delete cfm;
|
||||
|
||||
}
|
||||
|
||||
void CLoanersEditDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CLoanersEditDlg)
|
||||
DDX_Control(pDX, IDC_EDREF, m_edRef);
|
||||
DDX_Control(pDX, IDC_BTNCANCEL, m_btnCancel);
|
||||
DDX_Control(pDX, IDC_DTDATEDUE, m_dtDateDue);
|
||||
DDX_Control(pDX, IDC_EDNOTES, m_edNotes);
|
||||
DDX_Control(pDX, IDC_EDLOANEDTO, m_edLoanedTo);
|
||||
DDX_Control(pDX, IDC_EDDESCRIPTION, m_edDescription);
|
||||
DDX_Control(pDX, IDC_EDCHARGES, m_edCharges);
|
||||
DDX_Control(pDX, IDC_DTDATERETURN, m_dtDateReturn);
|
||||
DDX_Control(pDX, IDC_DTDATEOUT, m_dtDateOut);
|
||||
DDX_Control(pDX, IDC_CKRETURNED, m_ckReturned);
|
||||
DDX_Control(pDX, IDC_CBUNIT, m_cbUnits);
|
||||
DDX_Control(pDX, IDC_CBPART, m_cbParts);
|
||||
DDX_Control(pDX, IDC_CBCLIENT, m_cbClient);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CLoanersEditDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CLoanersEditDlg)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
ON_EN_KILLFOCUS(IDC_EDCHARGES, OnKillfocusEdcharges)
|
||||
ON_CBN_CLOSEUP(IDC_CBPART, OnCloseupCbpart)
|
||||
ON_CBN_CLOSEUP(IDC_CBUNIT, OnCloseupCbunit)
|
||||
ON_EN_KILLFOCUS(IDC_EDDESCRIPTION, OnKillfocusEddescription)
|
||||
ON_BN_CLICKED(IDC_BTNCANCEL, OnBtncancel)
|
||||
ON_BN_CLICKED(IDC_CKRETURNED, OnCkreturned)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLoanersEditDlg message handlers
|
||||
|
||||
BOOL CLoanersEditDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
Security();
|
||||
FillListBoxes();
|
||||
FillFields();
|
||||
m_edRef.SetLimitText(80);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
//pass in rental id to indicate editing:
|
||||
void CLoanersEditDlg::SetRentalID(CString *strRentalID)
|
||||
{
|
||||
if(strRentalID!=NULL)
|
||||
m_strRentalID=*strRentalID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CLoanersEditDlg::FillFields()
|
||||
{
|
||||
COleCurrency crCharges;
|
||||
COleDateTime dtOut,dtDue,dtReturned;
|
||||
bool bReturned;
|
||||
long lPart,lUnit,lClient;
|
||||
CString q,strData,strDescription,strLoanedTo,strNotes,strRef;
|
||||
|
||||
if(m_strRentalID.IsEmpty()) return;
|
||||
|
||||
q.Format("SELECT rentals.* FROM rentals "
|
||||
"WHERE (((rentals.id)=%s));",m_strRentalID);
|
||||
rs->Query(q);
|
||||
|
||||
|
||||
//Fetch the fields:
|
||||
rs->FetchField("partlink",&lPart);
|
||||
rs->FetchField("unitlink",&lUnit);
|
||||
rs->FetchField("clientlink",&lClient);
|
||||
rs->FetchField("loanedto",&strLoanedTo);
|
||||
rs->FetchField("description",&strDescription);
|
||||
rs->FetchField("dateout",&dtOut);
|
||||
rs->FetchField("datedue",&dtDue);
|
||||
rs->FetchField("datereturn",&dtReturned);
|
||||
rs->FetchField("charges",&crCharges);
|
||||
rs->FetchField("returned",&bReturned);
|
||||
rs->FetchField("notes",&strNotes);
|
||||
rs->FetchField("ref",&strRef);
|
||||
|
||||
|
||||
//CHARGES
|
||||
m_edCharges.SetWindowText(cfm->Format(crCharges));
|
||||
|
||||
//CLIENT
|
||||
m_cbClient.Select(lClient);
|
||||
|
||||
//LOANED TO
|
||||
m_edLoanedTo.SetWindowText(strLoanedTo);
|
||||
|
||||
//UNIT
|
||||
m_cbUnits.Select(lUnit);
|
||||
|
||||
//PART
|
||||
m_cbParts.Select(lPart);
|
||||
|
||||
//ITEM DESCRIPTION
|
||||
m_edDescription.SetWindowText(strDescription);
|
||||
|
||||
//OUT DATE
|
||||
m_dtDateOut.SetTime(dtOut);
|
||||
|
||||
//DUE DATE
|
||||
m_dtDateDue.SetTime(dtDue);
|
||||
|
||||
//RETURNED DATE
|
||||
m_dtDateReturn.SetTime(dtReturned);
|
||||
|
||||
//RETURNED FLAG
|
||||
m_ckReturned.SetCheck(bReturned ? TRUE : FALSE);
|
||||
m_dtDateReturn.EnableWindow(bReturned ? TRUE : FALSE);
|
||||
|
||||
//REFERENCE
|
||||
m_edRef.SetWindowText(strRef);
|
||||
|
||||
//NOTES
|
||||
m_edNotes.SetWindowText(strNotes);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CLoanersEditDlg::FillListBoxes()
|
||||
{
|
||||
CString strData;
|
||||
CString strIndex;
|
||||
CString q;
|
||||
|
||||
long lData;
|
||||
m_cbParts.Clear();
|
||||
m_cbParts.AddRow(" <Not a part>","0");
|
||||
|
||||
rs->QueryReadOnly("SELECT parts.id, [partnumber] & \" - \" "
|
||||
"& [description] AS name FROM parts "
|
||||
"WHERE (((parts.active)=True)) ORDER BY parts.partnumber;");
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
rs->MoveFirst();
|
||||
|
||||
do
|
||||
{
|
||||
rs->FetchField("name",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbParts.AddRow(strData,strIndex);
|
||||
}while(rs->MoveForward());
|
||||
|
||||
}
|
||||
|
||||
m_cbParts.Select(m_strSelPart);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//==========================================
|
||||
//CLIENTS LIST
|
||||
|
||||
m_cbClient.Clear();
|
||||
|
||||
m_cbClient.AddRow(" <non-database client>","0");
|
||||
|
||||
rs->QueryReadOnly("SELECT clients.id,clients.isheadoffice, IIf(IsNull([company]),[last] & \", \" & [first],[company]) AS name "
|
||||
"FROM clients WHERE (((clients.isheadoffice)=False)) ORDER BY IIf(IsNull([company]),[last] & \", \" & [first],[company]);");
|
||||
|
||||
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
rs->FetchField("name",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbClient.AddRow(strData,strIndex);
|
||||
}while(rs->MoveForward());
|
||||
}
|
||||
m_cbClient.Select(m_strSelClient);
|
||||
|
||||
//============================================
|
||||
//FILL UNIT LIST:
|
||||
m_cbUnits.Clear();
|
||||
m_cbUnits.AddRow(" < No unit >","0");
|
||||
|
||||
|
||||
|
||||
rs->QueryReadOnly("SELECT units.id, [sn] & \" - \" & [company_person] & \" \" & [unitmodels].[description] & \" \" & [unitmodels].[model] AS name "
|
||||
"FROM (units LEFT JOIN unitmodels ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id "
|
||||
"WHERE (((units.loaner)=True)) "
|
||||
"ORDER BY units.sn;");
|
||||
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
rs->FetchField("name",&strData);
|
||||
strData.TrimRight("- ");
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
|
||||
//see if it's out right now
|
||||
q.Format("SELECT rentals.unitlink FROM rentals "
|
||||
"WHERE (((rentals.returned)=False) AND ((rentals.unitlink)=%u));",lData);
|
||||
rs2->QueryReadOnly(q);
|
||||
if(!rs2->IsEmpty())//out
|
||||
strData="z_Out: " + strData;
|
||||
m_cbUnits.AddRow(strData,strIndex);
|
||||
}while(rs->MoveForward());
|
||||
}
|
||||
|
||||
m_cbUnits.Select(m_strSelUnit);
|
||||
}
|
||||
|
||||
//****************************************************
|
||||
//Saving/updating and exit
|
||||
void CLoanersEditDlg::OnBtndone()
|
||||
{
|
||||
|
||||
if(m_bReadOnly)
|
||||
CDialog::OnOK();
|
||||
COleCurrency crCharges;
|
||||
COleDateTime dtOut,dtDue,dtReturned;
|
||||
bool bReturned;
|
||||
long lPart,lUnit,lClient;
|
||||
CString q,strData,strDescription,strLoanedTo,strNotes,strRef;
|
||||
|
||||
|
||||
//CHARGES
|
||||
m_edCharges.GetWindowText(strData);
|
||||
crCharges.ParseCurrency(strData);
|
||||
|
||||
//CLIENT
|
||||
strData=m_cbClient.GetCurrentRowID();
|
||||
lClient=atol(strData);
|
||||
|
||||
//LOANED TO
|
||||
m_edLoanedTo.GetWindowText(strLoanedTo);
|
||||
|
||||
//UNIT
|
||||
strData=m_cbUnits.GetCurrentRowID();
|
||||
lUnit=atol(strData);
|
||||
|
||||
//PART
|
||||
strData=m_cbParts.GetCurrentRowID();
|
||||
lPart=atol(strData);
|
||||
|
||||
//ITEM DESCRIPTION
|
||||
m_edDescription.GetWindowText(strDescription);
|
||||
|
||||
//OUT DATE
|
||||
m_dtDateOut.GetTime(dtOut);
|
||||
|
||||
//DUE DATE
|
||||
m_dtDateDue.GetTime(dtDue);
|
||||
|
||||
//RETURNED DATE
|
||||
m_dtDateReturn.GetTime(dtReturned);
|
||||
|
||||
//RETURNED FLAG
|
||||
bReturned=m_ckReturned.GetCheck() ? true : false;
|
||||
|
||||
//REFERENCE
|
||||
m_edRef.GetWindowText(strRef);
|
||||
|
||||
//NOTES
|
||||
m_edNotes.GetWindowText(strNotes);
|
||||
|
||||
|
||||
//Validation and judging: "Whose cuisine will reign supreme?"
|
||||
if(lClient==0 && strLoanedTo.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("You need to indicate who has this equipment");
|
||||
return;
|
||||
}
|
||||
|
||||
if(lUnit==0 && lPart ==0 && strDescription.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("You haven't indicated what item this record refers to");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(m_strRentalID.IsEmpty())
|
||||
{//Add new record
|
||||
q="SELECT rentals.* FROM rentals "
|
||||
"WHERE (((rentals.id)=0));";
|
||||
}
|
||||
else
|
||||
{
|
||||
//update existing record
|
||||
q.Format("SELECT rentals.* FROM rentals "
|
||||
"WHERE (((rentals.id)=%s));",m_strRentalID);
|
||||
|
||||
}
|
||||
|
||||
rs->Query(q);
|
||||
//Add a record if necessary
|
||||
if(m_strRentalID.IsEmpty())
|
||||
rs->AddNewRecord();
|
||||
|
||||
//Update the fields:
|
||||
rs->UpdateField("partlink",&lPart);
|
||||
rs->UpdateField("unitlink",&lUnit);
|
||||
rs->UpdateField("clientlink",&lClient);
|
||||
rs->UpdateField("loanedto",&strLoanedTo);
|
||||
rs->UpdateField("description",&strDescription);
|
||||
rs->UpdateField("dateout",&dtOut);
|
||||
rs->UpdateField("datedue",&dtDue);
|
||||
rs->UpdateField("datereturn",&dtReturned);
|
||||
rs->UpdateField("charges",&crCharges);
|
||||
rs->UpdateField("returned",&bReturned);
|
||||
rs->UpdateField("ref",&strRef);
|
||||
rs->UpdateField("notes",&strNotes);
|
||||
rs->SaveRecord();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//this is just to flush the update through
|
||||
//rs->Query("SELECT rentals.* from rentals WHERE rentals.id=0;");
|
||||
//modified Jan 10 2000 as proper flush is now
|
||||
//guranteed with a close
|
||||
rs->Close();
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
|
||||
//Validate charges as entered
|
||||
void CLoanersEditDlg::OnKillfocusEdcharges()
|
||||
{
|
||||
CString strData;
|
||||
COleCurrency crData;
|
||||
m_edCharges.GetWindowText(strData);
|
||||
crData.ParseCurrency(strData);
|
||||
m_edCharges.SetWindowText(cfm->Format(crData));
|
||||
|
||||
}
|
||||
|
||||
void CLoanersEditDlg::OnCloseupCbpart()
|
||||
{
|
||||
|
||||
m_strSelPart=m_cbParts.GetCurrentRowID();
|
||||
//erase other two fields
|
||||
if(m_strSelPart!="0")
|
||||
{
|
||||
m_strSelUnit="0";
|
||||
m_cbUnits.Select(m_strSelUnit);
|
||||
m_edDescription.SetWindowText("");
|
||||
}
|
||||
}
|
||||
|
||||
void CLoanersEditDlg::OnCloseupCbunit()
|
||||
{
|
||||
m_strSelUnit=m_cbUnits.GetCurrentRowID();
|
||||
//erase other two fields
|
||||
if(m_strSelUnit!="0")
|
||||
{
|
||||
m_strSelPart="0";
|
||||
m_cbParts.Select(m_strSelPart);
|
||||
m_edDescription.SetWindowText("");
|
||||
}
|
||||
}
|
||||
|
||||
void CLoanersEditDlg::OnKillfocusEddescription()
|
||||
{
|
||||
CString strData;
|
||||
m_edDescription.GetWindowText(strData);
|
||||
if(strData.GetLength()>1)
|
||||
{
|
||||
m_strSelUnit="0";
|
||||
m_strSelPart="0";
|
||||
m_cbParts.Select(m_strSelPart);
|
||||
m_cbUnits.Select(m_strSelUnit);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CLoanersEditDlg::OnBtncancel()
|
||||
{
|
||||
CDialog::OnCancel();
|
||||
|
||||
}
|
||||
|
||||
void CLoanersEditDlg::OnOK(){}
|
||||
|
||||
|
||||
void CLoanersEditDlg::OnCkreturned()
|
||||
{
|
||||
m_dtDateReturn.EnableWindow(m_ckReturned.GetCheck());
|
||||
|
||||
}
|
||||
|
||||
void CLoanersEditDlg::Security()
|
||||
{
|
||||
int x=m_pApp->Allowed(RLOANERS,true);
|
||||
m_bReadOnly=false;
|
||||
if(x==2)//read only
|
||||
{
|
||||
m_bReadOnly=true;
|
||||
m_btnCancel.ShowWindow(FALSE);
|
||||
m_cbClient.EnableWindow(FALSE);
|
||||
m_cbParts.EnableWindow(FALSE);
|
||||
m_cbUnits.EnableWindow(FALSE);
|
||||
m_ckReturned.EnableWindow(FALSE);
|
||||
m_dtDateDue.EnableWindow(FALSE);
|
||||
m_dtDateOut.EnableWindow(FALSE);
|
||||
m_dtDateReturn.EnableWindow(FALSE);
|
||||
m_edCharges.SetReadOnly(TRUE);
|
||||
m_edDescription.SetReadOnly(TRUE);
|
||||
m_edLoanedTo.SetReadOnly(TRUE);
|
||||
m_edNotes.SetReadOnly(TRUE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(x==0)
|
||||
{
|
||||
m_pApp->SecurityWarning();
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
#if !defined(AFX_LOANERSEDITDLG_H__E6C958A1_4365_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_LOANERSEDITDLG_H__E6C958A1_4365_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// LoanersEditDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLoanersEditDlg dialog
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
#include "gzcurrencyformatter.h"
|
||||
class CLoanersEditDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
bool m_bReadOnly;
|
||||
void Security();
|
||||
CString m_strSelClient;
|
||||
CString m_strSelUnit;
|
||||
CString m_strSelPart;
|
||||
void FillListBoxes();
|
||||
void FillFields();
|
||||
void SetRentalID(CString * strRentalID);
|
||||
CString m_strRentalID;
|
||||
~CLoanersEditDlg();
|
||||
CLoanersEditDlg(CWnd* pParent = NULL); // standard constructor
|
||||
GZRset* rs;
|
||||
GZRset* rs2;
|
||||
|
||||
|
||||
CSpApp* m_pApp;
|
||||
CgzCurrencyFormatter* cfm;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CLoanersEditDlg)
|
||||
enum { IDD = IDD_LOANERSEDIT };
|
||||
CEdit m_edRef;
|
||||
CButton m_btnCancel;
|
||||
CDateTimeCtrl m_dtDateDue;
|
||||
CEdit m_edNotes;
|
||||
CEdit m_edLoanedTo;
|
||||
CEdit m_edDescription;
|
||||
CEdit m_edCharges;
|
||||
CDateTimeCtrl m_dtDateReturn;
|
||||
CDateTimeCtrl m_dtDateOut;
|
||||
CButton m_ckReturned;
|
||||
CgzCombo m_cbUnits;
|
||||
CgzCombo m_cbParts;
|
||||
CgzCombo m_cbClient;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CLoanersEditDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CLoanersEditDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBtndone();
|
||||
afx_msg void OnKillfocusEdcharges();
|
||||
afx_msg void OnCloseupCbpart();
|
||||
afx_msg void OnCloseupCbunit();
|
||||
afx_msg void OnKillfocusEddescription();
|
||||
afx_msg void OnBtncancel();
|
||||
virtual void OnOK();
|
||||
afx_msg void OnCkreturned();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_LOANERSEDITDLG_H__E6C958A1_4365_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,169 @@
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// LogTrace.cpp -- Implementation of the CLogTrace class
|
||||
|
||||
|
||||
#include "stdafx.h"
|
||||
#include <afxdisp.h>
|
||||
#include "LogTrace.h"
|
||||
|
||||
/**************************************************
|
||||
|
||||
How to use CLogTrace
|
||||
|
||||
1. Make a static CLogTrace object as a member of the application class
|
||||
|
||||
2. Add the following lines to the InitInstance of the program
|
||||
|
||||
|
||||
m_LogTrace.m_strAppName = "MyApp"; // use appropriate name here
|
||||
|
||||
m_LogTrace.SetFileName("Log.txt"); // sets the log file name and puts it in the exe path
|
||||
|
||||
m_LogTrace.OnStartup(TRUE, TRUE); // activates the log trace
|
||||
|
||||
3. Also in InitInstance, add the following line if you want to empty the log file
|
||||
each time the application starts
|
||||
|
||||
m_LogTrace.ResetFile();
|
||||
|
||||
|
||||
4. Any time you want to write to the log file, use the CLogTrace::WriteLine functions
|
||||
these will write the text along with date and time
|
||||
|
||||
|
||||
*******************************************************/
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
// Construction/Destruction
|
||||
|
||||
CLogTrace::CLogTrace()
|
||||
{
|
||||
m_bActive = FALSE;
|
||||
m_bTimeStamp = TRUE;
|
||||
|
||||
CString s;
|
||||
}
|
||||
|
||||
|
||||
CLogTrace::~CLogTrace()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// CLogTrace operations
|
||||
|
||||
|
||||
void CLogTrace::ResetFile()
|
||||
{
|
||||
CStdioFile f;
|
||||
CFileException fe;
|
||||
CString s;
|
||||
|
||||
if (m_strFileName.IsEmpty()) return;
|
||||
|
||||
if (f.Open(m_strFileName, CFile::modeWrite | CFile::modeCreate, &fe) == FALSE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
f.Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// bActive tells us if we want the trace to be active or not
|
||||
// bTimeStamp tells us if we want time stamps on each line
|
||||
// eliminating the time stamp allows us to use this class for a regular log file
|
||||
void CLogTrace::OnStartup(BOOL bActive, BOOL bTimeStamp)
|
||||
{
|
||||
m_bActive = bActive;
|
||||
m_bTimeStamp = bTimeStamp;
|
||||
if (bTimeStamp == FALSE) return;
|
||||
CString s;
|
||||
|
||||
// these ***'s help to indicate when one ru of the program ends and another starts
|
||||
// because we don't always overwrite the file each time
|
||||
|
||||
WriteLine("\n\n******************************************\n\n");
|
||||
s.Format("%s Log Trace %s\n\n", m_strAppName, COleDateTime::GetCurrentTime().Format());
|
||||
WriteLine(s);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// function to write a line of text to the log file
|
||||
void CLogTrace::WriteLine(LPCTSTR szLine)
|
||||
{
|
||||
CStdioFile f;
|
||||
CFileException fe;
|
||||
CString s;
|
||||
|
||||
if (m_bActive == FALSE) return;
|
||||
if (m_strFileName.IsEmpty()) return;
|
||||
|
||||
if (f.Open(m_strFileName, CFile::modeWrite | CFile::modeCreate |
|
||||
CFile::modeNoTruncate, &fe) == FALSE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
f.SeekToEnd();
|
||||
//TRACE("LOGGIN %s\n", szLine);
|
||||
if (m_bTimeStamp)
|
||||
{
|
||||
s.Format("%s\t%s\n", COleDateTime::GetCurrentTime().Format(),
|
||||
szLine);
|
||||
}
|
||||
else
|
||||
{
|
||||
s.Format("%s\n", szLine);
|
||||
}
|
||||
f.WriteString(s);
|
||||
}
|
||||
catch (CException* e)
|
||||
{
|
||||
e->Delete();
|
||||
}
|
||||
f.Close();
|
||||
}
|
||||
|
||||
// function to write a line of text, with an extra string
|
||||
void CLogTrace::WriteLine(LPCTSTR szFormat, LPCTSTR szAddInfo)
|
||||
{
|
||||
if (m_bActive == FALSE) return;
|
||||
CString s;
|
||||
s.Format(szFormat, szAddInfo);
|
||||
WriteLine(s);
|
||||
}
|
||||
|
||||
|
||||
// funtion to write a line of text with an extra integer
|
||||
void CLogTrace::WriteLine(LPCTSTR szFormat, int nAddInfo)
|
||||
{
|
||||
if (m_bActive == FALSE) return;
|
||||
CString s;
|
||||
s.Format(szFormat, nAddInfo);
|
||||
WriteLine(s);
|
||||
}
|
||||
|
||||
|
||||
// function to set the log file name. don't pass a fill path!
|
||||
// just pass something like "log.txt"
|
||||
// the file will be placed in the same dir as the exe file
|
||||
void CLogTrace::SetFileName(LPCTSTR szFileName)
|
||||
{
|
||||
TCHAR drive[_MAX_PATH], dir[_MAX_PATH], name[_MAX_PATH], ext[_MAX_PATH];
|
||||
|
||||
const char *path = _pgmptr ;
|
||||
|
||||
_splitpath(path, drive, dir, name, ext);
|
||||
|
||||
m_strFileName.Format("%s%s%s", drive, dir, szFileName);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// LogTrace.cpp -- Interface for the CLogTrace class
|
||||
// A class to do debug logging
|
||||
|
||||
|
||||
#ifndef __LOGTRACE_H__
|
||||
#define __LOGTRACE_H__
|
||||
|
||||
class CLogTrace
|
||||
{
|
||||
// Construction/Destruction
|
||||
public:
|
||||
CLogTrace();
|
||||
~CLogTrace();
|
||||
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
CString m_strAppName;
|
||||
|
||||
protected:
|
||||
BOOL m_bActive;
|
||||
CString m_strFileName;
|
||||
BOOL m_bTimeStamp;
|
||||
|
||||
// Operations
|
||||
public:
|
||||
void WriteLine(LPCTSTR szLine);
|
||||
void WriteLine(LPCTSTR szFormat, LPCTSTR szAddInfo);
|
||||
void WriteLine(LPCTSTR szFormat, int nAddInfo);
|
||||
void ResetFile();
|
||||
void OnStartup(BOOL bActive, BOOL bTimeStamp);
|
||||
void SetFileName(LPCTSTR szFileName);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
|
||||
// Inlines
|
||||
public:
|
||||
inline void SetActive(BOOL bSet)
|
||||
{
|
||||
m_bActive = bSet;
|
||||
}
|
||||
inline CString GetFileName()
|
||||
{
|
||||
return m_strFileName;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // __LOGTRACE_H__
|
||||
@@ -0,0 +1,525 @@
|
||||
// LoginDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "LoginDlg.h"
|
||||
//#define WHATTHEFUBAR 0
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLoginDlg dialog
|
||||
|
||||
|
||||
CLoginDlg::CLoginDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CLoginDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CLoginDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp = (CSpApp*)AfxGetApp();
|
||||
cryp=new GZK;
|
||||
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("Error at:CLoginDlg::CLoginDlg");
|
||||
|
||||
|
||||
//if(rs->Valid())
|
||||
// rs->SetConnect(m_pApp->strConnectString);
|
||||
|
||||
}
|
||||
|
||||
CLoginDlg::~CLoginDlg()
|
||||
{
|
||||
|
||||
/*dibBanner.DeleteObject();
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
delete cryp;*/
|
||||
}
|
||||
|
||||
void CLoginDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CLoginDlg)
|
||||
DDX_Control(pDX, IDC_LBLRC, m_lblRC);
|
||||
DDX_Control(pDX, IDC_LBLURL, m_lblURL);
|
||||
DDX_Control(pDX, IDC_EDPASSWORD, m_edPassword);
|
||||
DDX_Control(pDX, IDC_EDLOGIN, m_edLogin);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CLoginDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CLoginDlg)
|
||||
ON_WM_PAINT()
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLoginDlg message handlers
|
||||
|
||||
BOOL CLoginDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
SetWindowText("Login");
|
||||
//Contract
|
||||
|
||||
|
||||
m_lblURL.SetTextColor(RGB(0,0,255));
|
||||
m_lblURL.SetFontUnderline(TRUE);
|
||||
//m_lblURL.SetFontBold(TRUE);
|
||||
m_lblURL.SetFontSize(10);
|
||||
m_lblURL.SetLink(TRUE);
|
||||
m_lblURL.SetLinkURL("http://www.ayanova.com");
|
||||
m_lblURL.SetLinkCursor(m_pApp->hcHand);
|
||||
//dibBanner.SetDither(TRUE);
|
||||
// dibBanner.Load("000");//m_strBannerFile);
|
||||
#ifdef AYQB
|
||||
dibBanner.SetBitmap(IDB_QBSPLASH);
|
||||
#else
|
||||
dibBanner.SetBitmap(IDB_SPLASH);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
CString strComp;
|
||||
|
||||
//if invalid recordset just abort
|
||||
//this is the only way apparently
|
||||
if(!rs->Valid())
|
||||
CDialog::OnCancel();
|
||||
|
||||
//Added Sept 30th 2002
|
||||
//This is the first recordset instantiated, from here
|
||||
//Set the use transactions value so all future calls
|
||||
//will use the method selected
|
||||
|
||||
//Turn errors off in case db has not been updated yet
|
||||
bool bUseTransactions=false;
|
||||
|
||||
rs->m_bSupressErrors=true;
|
||||
if(rs->QueryReadOnly("SELECT defaults.transact FROM defaults;"))
|
||||
{
|
||||
|
||||
if(rs->FetchField("transact",&bUseTransactions))
|
||||
{
|
||||
m_pApp->m_bUseTransactions=bUseTransactions;
|
||||
m_pApp->rsPool->m_bUseTransactions=bUseTransactions;
|
||||
}
|
||||
}
|
||||
|
||||
//turn errors back on
|
||||
rs->m_bSupressErrors=false;
|
||||
|
||||
|
||||
rs->QueryReadOnly("SELECT defaults.regto FROM defaults;");
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
rs->FetchField("regto",&strComp);
|
||||
if(strComp=="Evaluation" || strComp=="AyaNova Evaluation")
|
||||
{
|
||||
m_edLogin.SetWindowText("manager");
|
||||
m_edPassword.SetWindowText("letmein");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
m_edLogin.SetWindowText("manager");
|
||||
m_edPassword.SetWindowText("letmein");
|
||||
#endif
|
||||
|
||||
m_lblRC.SetTextColor(RGB(255,255,255));
|
||||
m_lblRC.SetBkColor(RGB(255,112,16));
|
||||
m_lblRC.SetFontBold(TRUE);
|
||||
m_lblRC.SetFontSize(8);
|
||||
//m_lblRC.SetFontName("Arial");
|
||||
m_edLogin.SetFocus();
|
||||
|
||||
char* bogus=new char[34];
|
||||
delete bogus;
|
||||
|
||||
|
||||
|
||||
|
||||
return FALSE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CLoginDlg::OnPaint()
|
||||
{
|
||||
CPaintDC dc(this); // device context for painting
|
||||
|
||||
dibBanner.Draw(GetDC(), CPoint(11,10)); // pDC is of type CDC*
|
||||
|
||||
// Do not call CDialog::OnPaint() for painting messages
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CLoginDlg::OnOK()
|
||||
{
|
||||
m_edLogin.GetWindowText(login);
|
||||
m_edPassword.GetWindowText(password);
|
||||
if(login.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("You must enter a user name to login");
|
||||
}
|
||||
else
|
||||
{
|
||||
ProcessLogin();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CLoginDlg::OnCancel()
|
||||
{
|
||||
Cleanup();
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
void CLoginDlg::ProcessLogin()
|
||||
{
|
||||
|
||||
CString q;
|
||||
CString user;
|
||||
CString pass;
|
||||
CString testempty;
|
||||
CString strError;
|
||||
long lData=0;
|
||||
m_pApp->m_lusrID=0;
|
||||
|
||||
|
||||
pass=password;
|
||||
user=login;
|
||||
|
||||
|
||||
//PROCESS A LOG IN
|
||||
|
||||
// m_ctlLogin.GetWindowText(user);
|
||||
// m_ctlPassword.GetWindowText(pass);
|
||||
if(user.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("You must enter a login name");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef _WTF_
|
||||
AfxMessageBox("Process login: head");
|
||||
#endif
|
||||
//check for super user account
|
||||
//SuperUser(user);
|
||||
//hash entries
|
||||
cryp->GZHash(&user);
|
||||
testempty="@" + user +"gz";
|
||||
|
||||
|
||||
if(pass.IsEmpty())
|
||||
pass=testempty;
|
||||
|
||||
cryp->GZHash(&pass);
|
||||
//q.Format("SELECT users.* FROM users WHERE (((users.login)=\"%s\") AND ((users.pass)=\"%s\"));",user,pass);
|
||||
q.Format("SELECT users.* FROM users WHERE (((users.login)='%s') AND ((users.pass)='%s'));",user,pass);
|
||||
#ifdef _DEBUG
|
||||
// m_pApp->ShowStuff(q);
|
||||
#endif
|
||||
if(!rs->QueryReadOnly(q))
|
||||
{
|
||||
strError=rs->GetLastError();
|
||||
if(strError.Find("Unrecognized database format",0)!=-1)
|
||||
{
|
||||
if(AfxMessageBox("It appears that your database file scdata.sc may be corrupt.\r\n\r\n"
|
||||
"AyaNova can attempt to repair it, however due to a bug in the Microsoft \r\n"
|
||||
"Data access components, AyaNova may not be able to do it on it's own.\r\n"
|
||||
"If AyaNova is unable to repair it you will receive an error:\r\n"
|
||||
"\"Unrecognized database format\" and it will need to be repaired with Access 2000\r\n"
|
||||
"Microsoft Access 2000 can be used to repair your scdata.sc file if\r\n"
|
||||
"AyaNova is unable to repair it. Email us your scdata.sc file zipped up\r\n"
|
||||
"and we can do that for you, or if you have Access 2000, open it first, then open scdata.sc.\r\n"
|
||||
"Note that Access won't list scdata.sc as a file available to be opened as it doesn't end \r\n"
|
||||
"in the .mdb file extension, but you can type in the name yourself.\r\n"
|
||||
"\r\nWe are awaiting a bug fix from Microsoft that will allow AyaNova\r\n"
|
||||
"to perform as complete a repair as Microsoft Access 2000\r\n"
|
||||
"You can always email us if you have any questions about this at support@ayanova.com\r\n\r\n"
|
||||
"Would you like to attempt a repair now?",MB_YESNO)==IDYES)
|
||||
{
|
||||
rs->Close();//delete rs;
|
||||
rs=NULL;
|
||||
#ifdef _WTF_
|
||||
AfxMessageBox("Process login post unrecognized error");
|
||||
#endif
|
||||
Compact(true);
|
||||
Cleanup();
|
||||
CDialog::OnCancel();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else //not unrecognized database format, some other error
|
||||
{
|
||||
#ifdef _WTF_
|
||||
AfxMessageBox("Process login post dbase access error\r\nNot unrecognized database format related.");
|
||||
#endif
|
||||
|
||||
AfxMessageBox("The following error occured when trying to \r\n"
|
||||
"and access the database for the first time.");
|
||||
AfxMessageBox(strError);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
AfxMessageBox("Access denied");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
rs->FetchField("id",&lData);
|
||||
m_pApp->m_lusrID=lData;
|
||||
rs->Close();
|
||||
Cleanup();
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}//else not access denied
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//****************************************************
|
||||
// compact the database through a jro object
|
||||
//**********************************************
|
||||
bool CLoginDlg::Compact(bool bKeepOld)
|
||||
{
|
||||
bool status=true;
|
||||
CString src,dest,tempfile;
|
||||
CFileStatus fstat;
|
||||
CWaitCursor wait;
|
||||
|
||||
|
||||
//delete old one if exists
|
||||
tempfile.Format("%sscdata.tmp",m_pApp->m_strDBPATH);
|
||||
if(CFile::GetStatus(tempfile,fstat)==TRUE)//file exists
|
||||
{
|
||||
TRY
|
||||
{
|
||||
CFile::Remove( tempfile );
|
||||
}
|
||||
CATCH( CFileException, e )
|
||||
{
|
||||
status=false;
|
||||
CString cstrErrMsg;
|
||||
cstrErrMsg.Format("Error in Compact: %s cannot be removed",tempfile);
|
||||
AfxMessageBox(cstrErrMsg);
|
||||
}
|
||||
END_CATCH
|
||||
}
|
||||
|
||||
if(status==true)
|
||||
{
|
||||
|
||||
|
||||
|
||||
src.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%sscdata.sc;Jet OLEDB:Engine Type=5;",
|
||||
m_pApp->m_strDBPATH);
|
||||
|
||||
dest.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%sscdata.tmp;Jet OLEDB:Engine Type=5;",
|
||||
m_pApp->m_strDBPATH);
|
||||
|
||||
|
||||
_bstr_t bstsrc(src);
|
||||
_bstr_t bstdest(dest);
|
||||
|
||||
try
|
||||
{
|
||||
IJetEnginePtr jet(__uuidof(JetEngine));
|
||||
|
||||
jet->CompactDatabase(bstsrc, bstdest);
|
||||
}
|
||||
catch(_com_error &e)
|
||||
{
|
||||
status=false;
|
||||
CString cstrErrMsg;
|
||||
//get info from com error
|
||||
_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");
|
||||
cstrErrMsg.Format("Error in Compact: %s,\r\n%s",e.ErrorMessage(),(LPCTSTR) bstrDescription);
|
||||
AfxMessageBox(cstrErrMsg);
|
||||
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
status=false;
|
||||
TRACE( "*** Unhandled exception ***" );
|
||||
AfxMessageBox("Unhandled Error in Compact");
|
||||
PostQuitMessage(-1);//exit now before anything worse happens
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//Added. indexing can leave a 100+mb old file
|
||||
//this way can delete it
|
||||
if(bKeepOld)
|
||||
{
|
||||
//copy mdb over old
|
||||
src.Format("%sscdata.sc",m_pApp->m_strDBPATH);
|
||||
dest.Format("%sscdata.old",m_pApp->m_strDBPATH);
|
||||
status=CopyFile(src.GetBuffer(100),dest.GetBuffer(100));
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(status==true)
|
||||
{
|
||||
|
||||
|
||||
src.Format("%sscdata.tmp",m_pApp->m_strDBPATH);
|
||||
dest.Format("%sscdata.sc",m_pApp->m_strDBPATH);
|
||||
status=CopyFile(src.GetBuffer(100),dest.GetBuffer(100));
|
||||
|
||||
|
||||
}//if status==true
|
||||
|
||||
//delete gz1
|
||||
tempfile.Format("%sscdata.tmp",m_pApp->m_strDBPATH);
|
||||
if(CFile::GetStatus(tempfile,fstat)==TRUE)//file exists
|
||||
{
|
||||
TRY
|
||||
{
|
||||
CFile::Remove( tempfile );
|
||||
}
|
||||
CATCH( CFileException, e )
|
||||
{
|
||||
status=false;
|
||||
CString cstrErrMsg;
|
||||
cstrErrMsg.Format("Error at end of Compact: %s cannot be removed\r\nOtherwise compact OK",tempfile);
|
||||
AfxMessageBox(cstrErrMsg);
|
||||
}
|
||||
END_CATCH
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//*******************************************
|
||||
//copy a file, overwrite dest if exists
|
||||
bool CLoginDlg::CopyFile(char *src, char *dest)
|
||||
{
|
||||
|
||||
CFile sourceFile;
|
||||
CFile destFile;
|
||||
CFileException ex;
|
||||
CString tempfile;
|
||||
|
||||
|
||||
|
||||
// open the source file for reading
|
||||
|
||||
if (!sourceFile.Open(src,
|
||||
CFile::modeRead | CFile::shareDenyWrite, &ex))
|
||||
{
|
||||
// complain if an error happened
|
||||
// no need to delete the ex object
|
||||
|
||||
TCHAR szError[1024];
|
||||
ex.GetErrorMessage(szError, 1024);
|
||||
CString errormsg;
|
||||
errormsg.Format("Error copying file %s to %s\r\n The error was: %s",src,dest,szError);
|
||||
AfxMessageBox(errormsg);
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!destFile.Open(dest, CFile::modeWrite |
|
||||
CFile::shareExclusive | CFile::modeCreate, &ex))
|
||||
{
|
||||
TCHAR szError[1024];
|
||||
ex.GetErrorMessage(szError, 1024);
|
||||
CString errormsg;
|
||||
errormsg.Format("Error copying file %s to %s\r\n The error was: %s",src,dest,szError);
|
||||
AfxMessageBox(errormsg);
|
||||
sourceFile.Close();
|
||||
return false;
|
||||
}
|
||||
|
||||
BYTE buffer[4096];
|
||||
DWORD dwRead;
|
||||
|
||||
// Read in 4096-byte blocks,
|
||||
// remember how many bytes were actually read,
|
||||
// and try to write that many out. This loop ends
|
||||
// when there are no more bytes to read.
|
||||
|
||||
do
|
||||
{
|
||||
dwRead = sourceFile.Read(buffer, 4096);
|
||||
destFile.Write(buffer, dwRead);
|
||||
}
|
||||
while (dwRead > 0);
|
||||
|
||||
// Close both files
|
||||
|
||||
destFile.Close();
|
||||
sourceFile.Close();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Clean up allocated objects before closing
|
||||
void CLoginDlg::Cleanup(void)
|
||||
{
|
||||
dibBanner.DeleteObject();
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
delete cryp;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
#if !defined(AFX_LOGINDLG_H__6CB48A21_4631_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_LOGINDLG_H__6CB48A21_4631_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// LoginDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CLoginDlg dialog
|
||||
#include "dibsectionlite.h"//bitmap display class
|
||||
#include "gzk.h"
|
||||
#include "gzrset.h"
|
||||
#include "label.h"
|
||||
class CLoginDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
|
||||
|
||||
GZK * cryp;
|
||||
GZRset* rs;
|
||||
CSpApp* m_pApp;
|
||||
void ProcessLogin();
|
||||
bool Compact(bool bKeepOld);
|
||||
bool CopyFile(char *src, char *dest);
|
||||
CString strRegisteredTo;
|
||||
CString m_strBannerFile;
|
||||
CString password;
|
||||
CString login;
|
||||
~CLoginDlg();
|
||||
CLoginDlg(CWnd* pParent = NULL); // standard constructor
|
||||
CDIBSectionLite dibBanner;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CLoginDlg)
|
||||
enum { IDD = IDD_LOGIN };
|
||||
CLabel m_lblRC;
|
||||
CLabel m_lblURL;
|
||||
CEdit m_edPassword;
|
||||
CEdit m_edLogin;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CLoginDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CLoginDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnPaint();
|
||||
virtual void OnOK();
|
||||
virtual void OnCancel();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
// Clean up allocated objects before closing
|
||||
void Cleanup(void);
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_LOGINDLG_H__6CB48A21_4631_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,344 @@
|
||||
// Created by Microsoft (R) C/C++ Compiler Version 12.00.8447.0 (17b94d25).
|
||||
//
|
||||
// MSJRO.tlh
|
||||
//
|
||||
// C++ source equivalent of Win32 type library C:\PROGRAM FILES\COMMON FILES\System\ado\MSJRO.DLL
|
||||
// compiler-generated file created 08/28/00 at 14:47:54 - DO NOT EDIT!
|
||||
|
||||
//
|
||||
// Cross-referenced type libraries:
|
||||
//
|
||||
// #import "C:\PROGRAM FILES\COMMON FILES\SYSTEM\ADO\msado15.dll"
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#pragma pack(push, 8)
|
||||
|
||||
#include <comdef.h>
|
||||
|
||||
//
|
||||
// Forward references and typedefs
|
||||
//
|
||||
|
||||
struct __declspec(uuid("d2d139e0-b6ca-11d1-9f31-00c04fc29d52"))
|
||||
/* dual interface */ IReplica;
|
||||
struct __declspec(uuid("d2d139e2-b6ca-11d1-9f31-00c04fc29d52"))
|
||||
/* dual interface */ Filters;
|
||||
struct __declspec(uuid("d2d139e1-b6ca-11d1-9f31-00c04fc29d52"))
|
||||
/* dual interface */ Filter;
|
||||
struct __declspec(uuid("9f63d980-ff25-11d1-bb6f-00c04fae22da"))
|
||||
/* dual interface */ IJetEngine;
|
||||
struct /* coclass */ Replica;
|
||||
struct /* coclass */ JetEngine;
|
||||
|
||||
//
|
||||
// Smart pointer typedef declarations
|
||||
//
|
||||
|
||||
_COM_SMARTPTR_TYPEDEF(IReplica, __uuidof(IReplica));
|
||||
_COM_SMARTPTR_TYPEDEF(Filters, __uuidof(Filters));
|
||||
_COM_SMARTPTR_TYPEDEF(Filter, __uuidof(Filter));
|
||||
_COM_SMARTPTR_TYPEDEF(IJetEngine, __uuidof(IJetEngine));
|
||||
|
||||
//
|
||||
// Type library items
|
||||
//
|
||||
|
||||
enum ReplicaTypeEnum
|
||||
{
|
||||
jrRepTypeNotReplicable = 0,
|
||||
jrRepTypeDesignMaster = 1,
|
||||
jrRepTypeFull = 2,
|
||||
jrRepTypePartial = 3
|
||||
};
|
||||
|
||||
enum VisibilityEnum
|
||||
{
|
||||
jrRepVisibilityGlobal = 1,
|
||||
jrRepVisibilityLocal = 2,
|
||||
jrRepVisibilityAnon = 4
|
||||
};
|
||||
|
||||
enum UpdatabilityEnum
|
||||
{
|
||||
jrRepUpdFull = 0,
|
||||
jrRepUpdReadOnly = 2
|
||||
};
|
||||
|
||||
enum SyncTypeEnum
|
||||
{
|
||||
jrSyncTypeExport = 1,
|
||||
jrSyncTypeImport = 2,
|
||||
jrSyncTypeImpExp = 3
|
||||
};
|
||||
|
||||
enum SyncModeEnum
|
||||
{
|
||||
jrSyncModeIndirect = 1,
|
||||
jrSyncModeDirect = 2,
|
||||
jrSyncModeInternet = 3
|
||||
};
|
||||
|
||||
enum FilterTypeEnum
|
||||
{
|
||||
jrFilterTypeTable = 1,
|
||||
jrFilterTypeRelationship = 2
|
||||
};
|
||||
|
||||
struct __declspec(uuid("d2d139e0-b6ca-11d1-9f31-00c04fc29d52"))
|
||||
IReplica : IDispatch
|
||||
{
|
||||
//
|
||||
// Property data
|
||||
//
|
||||
|
||||
__declspec(property(get=GetActiveConnection,put=PutRefActiveConnection))
|
||||
IDispatchPtr ActiveConnection;
|
||||
__declspec(property(get=GetConflictFunction,put=PutConflictFunction))
|
||||
_bstr_t ConflictFunction;
|
||||
__declspec(property(get=GetConflictTables))
|
||||
_RecordsetPtr ConflictTables;
|
||||
__declspec(property(get=GetDesignMasterId,put=PutDesignMasterId))
|
||||
_variant_t DesignMasterId;
|
||||
__declspec(property(get=GetPriority))
|
||||
long Priority;
|
||||
__declspec(property(get=GetReplicaId))
|
||||
_variant_t ReplicaId;
|
||||
__declspec(property(get=GetReplicaType))
|
||||
enum ReplicaTypeEnum ReplicaType;
|
||||
__declspec(property(get=GetRetentionPeriod,put=PutRetentionPeriod))
|
||||
long RetentionPeriod;
|
||||
__declspec(property(get=GetVisibility))
|
||||
enum VisibilityEnum Visibility;
|
||||
__declspec(property(get=GetFilters))
|
||||
FiltersPtr Filters;
|
||||
|
||||
//
|
||||
// Wrapper methods for error-handling
|
||||
//
|
||||
|
||||
void PutRefActiveConnection (
|
||||
IDispatch * ppconn );
|
||||
void PutActiveConnection (
|
||||
const _variant_t & ppconn );
|
||||
IDispatchPtr GetActiveConnection ( );
|
||||
_bstr_t GetConflictFunction ( );
|
||||
void PutConflictFunction (
|
||||
_bstr_t pbstr );
|
||||
_RecordsetPtr GetConflictTables ( );
|
||||
_variant_t GetDesignMasterId ( );
|
||||
void PutDesignMasterId (
|
||||
const _variant_t & pvar );
|
||||
long GetPriority ( );
|
||||
_variant_t GetReplicaId ( );
|
||||
enum ReplicaTypeEnum GetReplicaType ( );
|
||||
long GetRetentionPeriod ( );
|
||||
void PutRetentionPeriod (
|
||||
long pl );
|
||||
enum VisibilityEnum GetVisibility ( );
|
||||
HRESULT CreateReplica (
|
||||
_bstr_t replicaName,
|
||||
_bstr_t description,
|
||||
enum ReplicaTypeEnum ReplicaType,
|
||||
enum VisibilityEnum Visibility,
|
||||
long Priority,
|
||||
enum UpdatabilityEnum updatability );
|
||||
VARIANT_BOOL GetObjectReplicability (
|
||||
_bstr_t objectName,
|
||||
_bstr_t objectType );
|
||||
HRESULT SetObjectReplicability (
|
||||
_bstr_t objectName,
|
||||
_bstr_t objectType,
|
||||
VARIANT_BOOL replicability );
|
||||
HRESULT MakeReplicable (
|
||||
_bstr_t connectionString,
|
||||
VARIANT_BOOL columnTracking );
|
||||
HRESULT PopulatePartial (
|
||||
_bstr_t FullReplica );
|
||||
HRESULT Synchronize (
|
||||
_bstr_t target,
|
||||
enum SyncTypeEnum syncType,
|
||||
enum SyncModeEnum syncMode );
|
||||
FiltersPtr GetFilters ( );
|
||||
|
||||
//
|
||||
// Raw methods provided by interface
|
||||
//
|
||||
|
||||
virtual HRESULT __stdcall putref_ActiveConnection (
|
||||
IDispatch * ppconn ) = 0;
|
||||
virtual HRESULT __stdcall put_ActiveConnection (
|
||||
VARIANT ppconn ) = 0;
|
||||
virtual HRESULT __stdcall get_ActiveConnection (
|
||||
IDispatch * * ppconn ) = 0;
|
||||
virtual HRESULT __stdcall get_ConflictFunction (
|
||||
BSTR * pbstr ) = 0;
|
||||
virtual HRESULT __stdcall put_ConflictFunction (
|
||||
BSTR pbstr ) = 0;
|
||||
virtual HRESULT __stdcall get_ConflictTables (
|
||||
struct _Recordset * * pprset ) = 0;
|
||||
virtual HRESULT __stdcall get_DesignMasterId (
|
||||
VARIANT * pvar ) = 0;
|
||||
virtual HRESULT __stdcall put_DesignMasterId (
|
||||
VARIANT pvar ) = 0;
|
||||
virtual HRESULT __stdcall get_Priority (
|
||||
long * pl ) = 0;
|
||||
virtual HRESULT __stdcall get_ReplicaId (
|
||||
VARIANT * pvar ) = 0;
|
||||
virtual HRESULT __stdcall get_ReplicaType (
|
||||
enum ReplicaTypeEnum * pl ) = 0;
|
||||
virtual HRESULT __stdcall get_RetentionPeriod (
|
||||
long * pl ) = 0;
|
||||
virtual HRESULT __stdcall put_RetentionPeriod (
|
||||
long pl ) = 0;
|
||||
virtual HRESULT __stdcall get_Visibility (
|
||||
enum VisibilityEnum * pl ) = 0;
|
||||
virtual HRESULT __stdcall raw_CreateReplica (
|
||||
BSTR replicaName,
|
||||
BSTR description,
|
||||
enum ReplicaTypeEnum ReplicaType,
|
||||
enum VisibilityEnum Visibility,
|
||||
long Priority,
|
||||
enum UpdatabilityEnum updatability ) = 0;
|
||||
virtual HRESULT __stdcall raw_GetObjectReplicability (
|
||||
BSTR objectName,
|
||||
BSTR objectType,
|
||||
VARIANT_BOOL * replicability ) = 0;
|
||||
virtual HRESULT __stdcall raw_SetObjectReplicability (
|
||||
BSTR objectName,
|
||||
BSTR objectType,
|
||||
VARIANT_BOOL replicability ) = 0;
|
||||
virtual HRESULT __stdcall raw_MakeReplicable (
|
||||
BSTR connectionString,
|
||||
VARIANT_BOOL columnTracking ) = 0;
|
||||
virtual HRESULT __stdcall raw_PopulatePartial (
|
||||
BSTR FullReplica ) = 0;
|
||||
virtual HRESULT __stdcall raw_Synchronize (
|
||||
BSTR target,
|
||||
enum SyncTypeEnum syncType,
|
||||
enum SyncModeEnum syncMode ) = 0;
|
||||
virtual HRESULT __stdcall get_Filters (
|
||||
struct Filters * * ppFilters ) = 0;
|
||||
};
|
||||
|
||||
struct __declspec(uuid("d2d139e2-b6ca-11d1-9f31-00c04fc29d52"))
|
||||
Filters : IDispatch
|
||||
{
|
||||
//
|
||||
// Property data
|
||||
//
|
||||
|
||||
__declspec(property(get=GetItem))
|
||||
FilterPtr Item[];
|
||||
__declspec(property(get=GetCount))
|
||||
long Count;
|
||||
|
||||
//
|
||||
// Wrapper methods for error-handling
|
||||
//
|
||||
|
||||
HRESULT Refresh ( );
|
||||
IUnknownPtr _NewEnum ( );
|
||||
long GetCount ( );
|
||||
FilterPtr GetItem (
|
||||
const _variant_t & Index );
|
||||
HRESULT Append (
|
||||
_bstr_t TableName,
|
||||
enum FilterTypeEnum FilterType,
|
||||
_bstr_t FilterCriteria );
|
||||
HRESULT Delete (
|
||||
const _variant_t & Index );
|
||||
|
||||
//
|
||||
// Raw methods provided by interface
|
||||
//
|
||||
|
||||
virtual HRESULT __stdcall raw_Refresh ( ) = 0;
|
||||
virtual HRESULT __stdcall raw__NewEnum (
|
||||
IUnknown * * ppvObject ) = 0;
|
||||
virtual HRESULT __stdcall get_Count (
|
||||
long * c ) = 0;
|
||||
virtual HRESULT __stdcall get_Item (
|
||||
VARIANT Index,
|
||||
struct Filter * * ppvObject ) = 0;
|
||||
virtual HRESULT __stdcall raw_Append (
|
||||
BSTR TableName,
|
||||
enum FilterTypeEnum FilterType,
|
||||
BSTR FilterCriteria ) = 0;
|
||||
virtual HRESULT __stdcall raw_Delete (
|
||||
VARIANT Index ) = 0;
|
||||
};
|
||||
|
||||
struct __declspec(uuid("d2d139e1-b6ca-11d1-9f31-00c04fc29d52"))
|
||||
Filter : IDispatch
|
||||
{
|
||||
//
|
||||
// Property data
|
||||
//
|
||||
|
||||
__declspec(property(get=GetTableName))
|
||||
_bstr_t TableName;
|
||||
__declspec(property(get=GetFilterType))
|
||||
enum FilterTypeEnum FilterType;
|
||||
__declspec(property(get=GetFilterCriteria))
|
||||
_bstr_t FilterCriteria;
|
||||
|
||||
//
|
||||
// Wrapper methods for error-handling
|
||||
//
|
||||
|
||||
_bstr_t GetTableName ( );
|
||||
enum FilterTypeEnum GetFilterType ( );
|
||||
_bstr_t GetFilterCriteria ( );
|
||||
|
||||
//
|
||||
// Raw methods provided by interface
|
||||
//
|
||||
|
||||
virtual HRESULT __stdcall get_TableName (
|
||||
BSTR * pbstr ) = 0;
|
||||
virtual HRESULT __stdcall get_FilterType (
|
||||
enum FilterTypeEnum * ptype ) = 0;
|
||||
virtual HRESULT __stdcall get_FilterCriteria (
|
||||
BSTR * pbstr ) = 0;
|
||||
};
|
||||
|
||||
struct __declspec(uuid("9f63d980-ff25-11d1-bb6f-00c04fae22da"))
|
||||
IJetEngine : IDispatch
|
||||
{
|
||||
//
|
||||
// Wrapper methods for error-handling
|
||||
//
|
||||
|
||||
HRESULT CompactDatabase (
|
||||
_bstr_t SourceConnection,
|
||||
_bstr_t Destconnection );
|
||||
HRESULT RefreshCache (
|
||||
struct _Connection * Connection );
|
||||
|
||||
//
|
||||
// Raw methods provided by interface
|
||||
//
|
||||
|
||||
virtual HRESULT __stdcall raw_CompactDatabase (
|
||||
BSTR SourceConnection,
|
||||
BSTR Destconnection ) = 0;
|
||||
virtual HRESULT __stdcall raw_RefreshCache (
|
||||
struct _Connection * Connection ) = 0;
|
||||
};
|
||||
|
||||
struct __declspec(uuid("d2d139e3-b6ca-11d1-9f31-00c04fc29d52"))
|
||||
Replica;
|
||||
// [ default ] interface IReplica
|
||||
|
||||
struct __declspec(uuid("de88c160-ff2c-11d1-bb6f-00c04fae22da"))
|
||||
JetEngine;
|
||||
// [ default ] interface IJetEngine
|
||||
|
||||
//
|
||||
// Wrapper method implementations
|
||||
//
|
||||
|
||||
#include "MSJRO.tli"
|
||||
|
||||
#pragma pack(pop)
|
||||
@@ -0,0 +1,230 @@
|
||||
// Created by Microsoft (R) C/C++ Compiler Version 12.00.8447.0 (17b94d25).
|
||||
//
|
||||
// MSJRO.tli
|
||||
//
|
||||
// Wrapper implementations for Win32 type library C:\PROGRAM FILES\COMMON FILES\System\ado\MSJRO.DLL
|
||||
// compiler-generated file created 08/28/00 at 14:47:54 - DO NOT EDIT!
|
||||
|
||||
#pragma once
|
||||
|
||||
//
|
||||
// interface IReplica wrapper method implementations
|
||||
//
|
||||
|
||||
inline void IReplica::PutRefActiveConnection ( IDispatch * ppconn ) {
|
||||
HRESULT _hr = putref_ActiveConnection(ppconn);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
}
|
||||
|
||||
inline void IReplica::PutActiveConnection ( const _variant_t & ppconn ) {
|
||||
HRESULT _hr = put_ActiveConnection(ppconn);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
}
|
||||
|
||||
inline IDispatchPtr IReplica::GetActiveConnection ( ) {
|
||||
IDispatch * _result;
|
||||
HRESULT _hr = get_ActiveConnection(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return IDispatchPtr(_result, false);
|
||||
}
|
||||
|
||||
inline _bstr_t IReplica::GetConflictFunction ( ) {
|
||||
BSTR _result;
|
||||
HRESULT _hr = get_ConflictFunction(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _bstr_t(_result, false);
|
||||
}
|
||||
|
||||
inline void IReplica::PutConflictFunction ( _bstr_t pbstr ) {
|
||||
HRESULT _hr = put_ConflictFunction(pbstr);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
}
|
||||
|
||||
inline _RecordsetPtr IReplica::GetConflictTables ( ) {
|
||||
struct _Recordset * _result;
|
||||
HRESULT _hr = get_ConflictTables(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _RecordsetPtr(_result, false);
|
||||
}
|
||||
|
||||
inline _variant_t IReplica::GetDesignMasterId ( ) {
|
||||
VARIANT _result;
|
||||
VariantInit(&_result);
|
||||
HRESULT _hr = get_DesignMasterId(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _variant_t(_result, false);
|
||||
}
|
||||
|
||||
inline void IReplica::PutDesignMasterId ( const _variant_t & pvar ) {
|
||||
HRESULT _hr = put_DesignMasterId(pvar);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
}
|
||||
|
||||
inline long IReplica::GetPriority ( ) {
|
||||
long _result;
|
||||
HRESULT _hr = get_Priority(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _result;
|
||||
}
|
||||
|
||||
inline _variant_t IReplica::GetReplicaId ( ) {
|
||||
VARIANT _result;
|
||||
VariantInit(&_result);
|
||||
HRESULT _hr = get_ReplicaId(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _variant_t(_result, false);
|
||||
}
|
||||
|
||||
inline enum ReplicaTypeEnum IReplica::GetReplicaType ( ) {
|
||||
enum ReplicaTypeEnum _result;
|
||||
HRESULT _hr = get_ReplicaType(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _result;
|
||||
}
|
||||
|
||||
inline long IReplica::GetRetentionPeriod ( ) {
|
||||
long _result;
|
||||
HRESULT _hr = get_RetentionPeriod(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _result;
|
||||
}
|
||||
|
||||
inline void IReplica::PutRetentionPeriod ( long pl ) {
|
||||
HRESULT _hr = put_RetentionPeriod(pl);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
}
|
||||
|
||||
inline enum VisibilityEnum IReplica::GetVisibility ( ) {
|
||||
enum VisibilityEnum _result;
|
||||
HRESULT _hr = get_Visibility(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _result;
|
||||
}
|
||||
|
||||
inline HRESULT IReplica::CreateReplica ( _bstr_t replicaName, _bstr_t description, enum ReplicaTypeEnum ReplicaType, enum VisibilityEnum Visibility, long Priority, enum UpdatabilityEnum updatability ) {
|
||||
HRESULT _hr = raw_CreateReplica(replicaName, description, ReplicaType, Visibility, Priority, updatability);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _hr;
|
||||
}
|
||||
|
||||
inline VARIANT_BOOL IReplica::GetObjectReplicability ( _bstr_t objectName, _bstr_t objectType ) {
|
||||
VARIANT_BOOL _result;
|
||||
HRESULT _hr = raw_GetObjectReplicability(objectName, objectType, &_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _result;
|
||||
}
|
||||
|
||||
inline HRESULT IReplica::SetObjectReplicability ( _bstr_t objectName, _bstr_t objectType, VARIANT_BOOL replicability ) {
|
||||
HRESULT _hr = raw_SetObjectReplicability(objectName, objectType, replicability);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _hr;
|
||||
}
|
||||
|
||||
inline HRESULT IReplica::MakeReplicable ( _bstr_t connectionString, VARIANT_BOOL columnTracking ) {
|
||||
HRESULT _hr = raw_MakeReplicable(connectionString, columnTracking);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _hr;
|
||||
}
|
||||
|
||||
inline HRESULT IReplica::PopulatePartial ( _bstr_t FullReplica ) {
|
||||
HRESULT _hr = raw_PopulatePartial(FullReplica);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _hr;
|
||||
}
|
||||
|
||||
inline HRESULT IReplica::Synchronize ( _bstr_t target, enum SyncTypeEnum syncType, enum SyncModeEnum syncMode ) {
|
||||
HRESULT _hr = raw_Synchronize(target, syncType, syncMode);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _hr;
|
||||
}
|
||||
|
||||
inline FiltersPtr IReplica::GetFilters ( ) {
|
||||
struct Filters * _result;
|
||||
HRESULT _hr = get_Filters(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return FiltersPtr(_result, false);
|
||||
}
|
||||
|
||||
//
|
||||
// interface Filters wrapper method implementations
|
||||
//
|
||||
|
||||
inline HRESULT Filters::Refresh ( ) {
|
||||
HRESULT _hr = raw_Refresh();
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _hr;
|
||||
}
|
||||
|
||||
inline IUnknownPtr Filters::_NewEnum ( ) {
|
||||
IUnknown * _result;
|
||||
HRESULT _hr = raw__NewEnum(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return IUnknownPtr(_result, false);
|
||||
}
|
||||
|
||||
inline long Filters::GetCount ( ) {
|
||||
long _result;
|
||||
HRESULT _hr = get_Count(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _result;
|
||||
}
|
||||
|
||||
inline FilterPtr Filters::GetItem ( const _variant_t & Index ) {
|
||||
struct Filter * _result;
|
||||
HRESULT _hr = get_Item(Index, &_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return FilterPtr(_result, false);
|
||||
}
|
||||
|
||||
inline HRESULT Filters::Append ( _bstr_t TableName, enum FilterTypeEnum FilterType, _bstr_t FilterCriteria ) {
|
||||
HRESULT _hr = raw_Append(TableName, FilterType, FilterCriteria);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _hr;
|
||||
}
|
||||
|
||||
inline HRESULT Filters::Delete ( const _variant_t & Index ) {
|
||||
HRESULT _hr = raw_Delete(Index);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _hr;
|
||||
}
|
||||
|
||||
//
|
||||
// interface Filter wrapper method implementations
|
||||
//
|
||||
|
||||
inline _bstr_t Filter::GetTableName ( ) {
|
||||
BSTR _result;
|
||||
HRESULT _hr = get_TableName(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _bstr_t(_result, false);
|
||||
}
|
||||
|
||||
inline enum FilterTypeEnum Filter::GetFilterType ( ) {
|
||||
enum FilterTypeEnum _result;
|
||||
HRESULT _hr = get_FilterType(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _result;
|
||||
}
|
||||
|
||||
inline _bstr_t Filter::GetFilterCriteria ( ) {
|
||||
BSTR _result;
|
||||
HRESULT _hr = get_FilterCriteria(&_result);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _bstr_t(_result, false);
|
||||
}
|
||||
|
||||
//
|
||||
// interface IJetEngine wrapper method implementations
|
||||
//
|
||||
|
||||
inline HRESULT IJetEngine::CompactDatabase ( _bstr_t SourceConnection, _bstr_t Destconnection ) {
|
||||
HRESULT _hr = raw_CompactDatabase(SourceConnection, Destconnection);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _hr;
|
||||
}
|
||||
|
||||
inline HRESULT IJetEngine::RefreshCache ( struct _Connection * Connection ) {
|
||||
HRESULT _hr = raw_RefreshCache(Connection);
|
||||
if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this));
|
||||
return _hr;
|
||||
}
|
||||
@@ -0,0 +1,318 @@
|
||||
// MailMsgDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "MailMsgDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailMsgDlg dialog
|
||||
|
||||
|
||||
CMailMsgDlg::CMailMsgDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CMailMsgDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CMailMsgDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
k=new GZK;
|
||||
k->GZSetUniqueKey(40);
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
/*
|
||||
rs=new GZRset("Mail message entry screen error:");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
*/
|
||||
//Initialize recordset pointer
|
||||
rs=m_pApp->rsPool->GetRS("CMailMsgDlg");
|
||||
|
||||
m_strMessage.Empty();
|
||||
m_strSubject.Empty();
|
||||
m_bNoRE=false;
|
||||
}
|
||||
|
||||
|
||||
void CMailMsgDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CMailMsgDlg)
|
||||
DDX_Control(pDX, IDC_USERS, m_lbUsers);
|
||||
DDX_Control(pDX, IDC_SUBJECT, m_edSubject);
|
||||
DDX_Control(pDX, IDC_SEND, m_btnSend);
|
||||
DDX_Control(pDX, IDC_POPUP, m_ckPopup);
|
||||
DDX_Control(pDX, IDC_MESSAGE, m_edMessage);
|
||||
DDX_Control(pDX, IDC_DATETIMEPICKER1, m_dtDate);
|
||||
DDX_Control(pDX, IDC_CANCEL, m_btnCancel);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMailMsgDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CMailMsgDlg)
|
||||
ON_BN_CLICKED(IDC_SEND, OnSend)
|
||||
ON_BN_CLICKED(IDC_CANCEL, OnCancel)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailMsgDlg message handlers
|
||||
|
||||
void CMailMsgDlg::OnOK()
|
||||
{
|
||||
|
||||
//CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CMailMsgDlg::OnCancel()
|
||||
{
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CMailMsgDlg::OnSend()
|
||||
{
|
||||
CString strMsg,strSubject,q;
|
||||
COleDateTime dtData,dtData2,dtData3;
|
||||
long lData;
|
||||
bool bData;
|
||||
int nRecipients=m_lbUsers.SelectionCount();
|
||||
//Ensure there is at least one selected user
|
||||
if(nRecipients==0)
|
||||
{
|
||||
AfxMessageBox("You must select at least one person\r\n"
|
||||
"to send this message to.");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//encrypt the subject and message
|
||||
//
|
||||
m_edMessage.GetWindowText(strMsg);
|
||||
m_edSubject.GetWindowText(strSubject);
|
||||
|
||||
if(strSubject.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("A subject is required");
|
||||
return;
|
||||
}
|
||||
|
||||
k->GZEncrypt(&strMsg,false);
|
||||
k->GZEncrypt(&strSubject,false);
|
||||
|
||||
//save the message
|
||||
|
||||
|
||||
//open the recordset without returning a record (no id=0)
|
||||
rs->Query("SELECT mail.* FROM mail;");
|
||||
rs->AddNewRecord();
|
||||
|
||||
|
||||
//********************************
|
||||
// START SAVING FIELDS
|
||||
//********************************
|
||||
//FROM
|
||||
rs->UpdateField("from",&m_pApp->m_lusrID);
|
||||
//rs->SaveRecord();
|
||||
|
||||
//DATE:
|
||||
dtData=COleDateTime::GetCurrentTime();
|
||||
rs->UpdateField("date",&dtData);
|
||||
//rs->SaveRecord();
|
||||
|
||||
|
||||
//POPUP
|
||||
bData = m_ckPopup.GetCheck() ? true:false;
|
||||
rs->UpdateField("popup",&bData);
|
||||
//rs->SaveRecord();
|
||||
|
||||
|
||||
//SUBJECT
|
||||
rs->UpdateField("subject",&strSubject);
|
||||
// rs->SaveRecord();
|
||||
|
||||
//MESSAGE
|
||||
rs->UpdateField("message",&strMsg);
|
||||
//rs->SaveRecord();
|
||||
|
||||
//DELIVERY DATE
|
||||
//get the date, remove on the date portion which
|
||||
//sets the time to 0:0:0 (midnight)
|
||||
m_dtDate.GetTime(dtData3);
|
||||
dtData2.SetDate(dtData3.GetYear(),dtData3.GetMonth(),dtData3.GetDay());
|
||||
|
||||
rs->UpdateField("deliverydate",&dtData2);
|
||||
rs->SaveRecord();
|
||||
|
||||
|
||||
//****************** DONE SAVING FIELDS *************
|
||||
//***************************************************
|
||||
|
||||
//retrieve the id number
|
||||
q.Format("SELECT mail.* FROM mail "
|
||||
"WHERE (((mail.from)=%u) AND ((mail.date)=#%s#));"
|
||||
,m_pApp->m_lusrID,dtData.Format(_T("%m/%d/%Y %H:%M:%S")));
|
||||
|
||||
rs->Query(q);
|
||||
|
||||
|
||||
//should work but....
|
||||
ASSERT(!rs->IsEmpty());
|
||||
|
||||
rs->FetchField("id",&lData);
|
||||
|
||||
|
||||
//save the recipient records
|
||||
for(int x=0;x<nRecipients;x++)
|
||||
{
|
||||
q.Format("INSERT INTO mailroute ( maillink, recipient, remind ) "
|
||||
"SELECT %u , %s , True;",lData,m_lbUsers.GetSelectedItem(x));
|
||||
|
||||
rs->Ex(q);
|
||||
|
||||
}
|
||||
|
||||
rs->Close();
|
||||
CDialog::OnOK();
|
||||
|
||||
}
|
||||
|
||||
BOOL CMailMsgDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
rs->Query("SELECT users.id, users.mail, [last] & \", \" & [first] AS name "
|
||||
"FROM users WHERE (((users.active)=True) AND (users.mail)=True) "
|
||||
"ORDER BY [last] & \", \" & [first];");
|
||||
|
||||
if(rs->IsEmpty())//bail
|
||||
{
|
||||
AfxMessageBox("No users could be found for you to send mail to");
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
//fill the list box
|
||||
|
||||
|
||||
CString strData;
|
||||
CString strIndex;
|
||||
long lData;
|
||||
m_lbUsers.Clear();
|
||||
//fill combo box with available zones
|
||||
rs->MoveFirst();
|
||||
rs->FetchField("name",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_lbUsers.AddRow(strData,strIndex);
|
||||
while(rs->MoveForward())
|
||||
{
|
||||
rs->FetchField("name",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_lbUsers.AddRow(strData,strIndex);
|
||||
}
|
||||
|
||||
|
||||
if(!m_strSubject.IsEmpty())
|
||||
{
|
||||
if(m_bNoRE)
|
||||
{
|
||||
m_edSubject.SetWindowText(m_strSubject);
|
||||
m_edMessage.SetWindowText(m_strMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
//if replying/forwarding, set previous message
|
||||
if(m_strSubject.Left(3)!="Re:")
|
||||
m_strSubject="Re: " + m_strSubject;
|
||||
m_strMessage=">" + m_strMessage;
|
||||
m_strMessage.Replace("\r\n","\r\n> ");
|
||||
m_edSubject.SetWindowText(m_strSubject);
|
||||
m_edMessage.SetWindowText(m_strMessage);
|
||||
}
|
||||
}
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
//***********************88
|
||||
CMailMsgDlg::~CMailMsgDlg()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
delete k;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//************************************************************
|
||||
//SAVE EDIT CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CMailMsgDlg::SaveField(CEdit *edControl,CString fldname,bool AllowEmpty)
|
||||
{
|
||||
|
||||
|
||||
CString str;
|
||||
//do nothing if not changed
|
||||
if(edControl->GetModify()!=TRUE) return true;
|
||||
|
||||
edControl->GetWindowText(str);
|
||||
//dont save empty fields if not allowed to
|
||||
if(!AllowEmpty)
|
||||
{
|
||||
|
||||
if(str.IsEmpty())
|
||||
{
|
||||
edControl->Undo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rs->UpdateField(fldname,&str);
|
||||
rs->SaveRecord();
|
||||
|
||||
edControl->SetModify(FALSE);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//************************************************************
|
||||
//SAVE CheckBox CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CMailMsgDlg::SaveField(CButton *ckControl,CString fldname)
|
||||
{
|
||||
|
||||
bool bData=false;
|
||||
BOOL BData;
|
||||
BData=ckControl->GetCheck();
|
||||
if(BData==TRUE) bData=true;
|
||||
rs->UpdateField(fldname,&bData);
|
||||
rs->SaveRecord();
|
||||
|
||||
return true;
|
||||
}
|
||||
//************************************************************
|
||||
//SAVE DateTimePicker CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CMailMsgDlg::SaveField(CDateTimeCtrl *dtControl,CString fldname)
|
||||
{
|
||||
|
||||
COleDateTime dtData;
|
||||
dtControl->GetTime(dtData);
|
||||
rs->UpdateField(fldname,&dtData);
|
||||
rs->SaveRecord();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CMailMsgDlg::SetForwardInfo(CString *pSubject, CString *pMessage)
|
||||
{
|
||||
m_strMessage=*pMessage;
|
||||
m_strSubject=*pSubject;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
#if !defined(AFX_MAILMSGDLG_H__D18DDDA4_2658_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_MAILMSGDLG_H__D18DDDA4_2658_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// MailMsgDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailMsgDlg dialog
|
||||
#include "gzk.h"
|
||||
#include "gzlistbox.h"
|
||||
#include "gzrset.h"
|
||||
class CMailMsgDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
bool m_bNoRE;
|
||||
void SetForwardInfo(CString* pSubject,CString* pMessage);
|
||||
CString m_strSubject;
|
||||
CString m_strMessage;
|
||||
|
||||
~CMailMsgDlg();
|
||||
CMailMsgDlg(CWnd* pParent = NULL); // standard constructor
|
||||
GZK* k;
|
||||
GZRset* rs;
|
||||
CSpApp* m_pApp;
|
||||
//Save fields
|
||||
bool SaveField(CEdit* edControl,CString fldname,bool AllowEmpty);
|
||||
bool SaveField(CButton* ckControl,CString fldname);
|
||||
bool SaveField(CDateTimeCtrl* dtControl,CString fldname);
|
||||
|
||||
//-------------------------------
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CMailMsgDlg)
|
||||
enum { IDD = IDD_MAILMSG };
|
||||
CgzListBox m_lbUsers;
|
||||
CEdit m_edSubject;
|
||||
CButton m_btnSend;
|
||||
CButton m_ckPopup;
|
||||
CEdit m_edMessage;
|
||||
CDateTimeCtrl m_dtDate;
|
||||
CButton m_btnCancel;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMailMsgDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CMailMsgDlg)
|
||||
virtual void OnOK();
|
||||
afx_msg void OnCancel();
|
||||
afx_msg void OnSend();
|
||||
virtual BOOL OnInitDialog();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_MAILMSGDLG_H__D18DDDA4_2658_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,511 @@
|
||||
// MailReaderDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "MailReaderDlg.h"
|
||||
#include "MailMsgDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailReaderDlg dialog
|
||||
|
||||
|
||||
CMailReaderDlg::CMailReaderDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CMailReaderDlg::IDD, pParent)
|
||||
, m_bReadOnly(false)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CMailReaderDlg)
|
||||
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
|
||||
k=new GZK;
|
||||
k->GZSetUniqueKey(40);
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CMailReaderDlg");
|
||||
}
|
||||
|
||||
CMailReaderDlg::~CMailReaderDlg()
|
||||
{
|
||||
delete k;
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
|
||||
void CMailReaderDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CMailReaderDlg)
|
||||
DDX_Control(pDX, IDC_MAIL_REPORT, m_rcMail);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMailReaderDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CMailReaderDlg)
|
||||
ON_NOTIFY(RVN_ITEMDRAWPREVIEW, IDC_MAIL_REPORT, OnRvnItemDrawPreview)
|
||||
ON_NOTIFY(RVN_ITEMDBCLICK, IDC_MAIL_REPORT, OnRvnItemDbClick)
|
||||
//}}AFX_MSG_MAP
|
||||
ON_COMMAND(ID_MAIL_NEWMESSAGE, OnMailNewmessage)
|
||||
ON_COMMAND(ID_MAIL_REPLY, OnMailReply)
|
||||
ON_COMMAND(ID_MAIL_DELETE, OnMailDelete)
|
||||
ON_COMMAND(ID_MAIL_CLOSETHISSCREEN, OnMailClosethisscreen)
|
||||
ON_COMMAND(ID_MAIL_HELP, OnMailHelp)
|
||||
ON_COMMAND(ID_MAIL_CHECKFORNEWMAIL, OnMailCheckfornewmail)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailReaderDlg message handlers
|
||||
|
||||
BOOL CMailReaderDlg::OnInitDialog()
|
||||
{
|
||||
|
||||
|
||||
CDialog::OnInitDialog();
|
||||
m_resize.Create( this );
|
||||
Security();
|
||||
|
||||
m_resize.Add(IDC_MAIL_REPORT,0,0,100,100);
|
||||
//Use the current width and height as the minimum size
|
||||
m_resize.SetMinimumTrackingSize();
|
||||
|
||||
CString profile,q;
|
||||
q.Format("SELECT users.mailprofile "
|
||||
"FROM users WHERE (((users.id)=%u));",m_pApp->m_lusrID);
|
||||
rs->Query(q);
|
||||
rs->FetchField("mailprofile",&profile);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//m_rcMail.ModifyStyle(0,RVS_SHOWVGRID);
|
||||
m_ilReport.Create(IDB_REPORT, 16, 1, RGB(255,0,255));
|
||||
m_rcMail.SetImageList(&m_ilReport);
|
||||
|
||||
ShowWindow(SW_MAXIMIZE);
|
||||
|
||||
m_rcMail.InsertColor(0, 0x00C0D8C0);
|
||||
m_rcMail.InsertColor(1, ::GetSysColor(COLOR_GRAYTEXT));
|
||||
m_rcMail.InsertColor(2, 0x00D0C0C0);
|
||||
m_rcMail.InsertColor(3, 0x00804000);
|
||||
|
||||
/*
|
||||
|
||||
RVCOLUMN rvc;
|
||||
rvc.lpszText = "Field";
|
||||
rvc.iWidth = 100;
|
||||
m_rcAbout.DefineColumn(0, &rvc);
|
||||
|
||||
rvc.lpszText = "Data";
|
||||
rvc.iWidth = 320;
|
||||
m_rcAbout.DefineColumn(1, &rvc);
|
||||
|
||||
m_rcAbout.ActivateColumn(0, 0);
|
||||
m_rcAbout.ActivateColumn(1, 1);
|
||||
|
||||
m_rcAbout.SetItemCount(100);
|
||||
*/
|
||||
|
||||
RVCOLUMN rvc;
|
||||
|
||||
rvc.nFormat = RVCF_IMAGE|RVCF_EX_AUTOWIDTH|RVCF_EX_FIXEDWIDTH|RVCF_SUBITEM_IMAGE;
|
||||
rvc.iImage = 0;
|
||||
rvc.lpszText = _T("Icon");
|
||||
m_rcMail.DefineColumn(0, &rvc);
|
||||
|
||||
rvc.nFormat = RVCF_TEXT;
|
||||
rvc.lpszText = "From:";
|
||||
rvc.iWidth = 175;
|
||||
m_rcMail.DefineColumn(1, &rvc);
|
||||
|
||||
rvc.lpszText = "Subject:";
|
||||
rvc.iWidth = 325;
|
||||
m_rcMail.DefineColumn(2, &rvc);
|
||||
|
||||
rvc.lpszText = "Date:";
|
||||
rvc.iWidth = 175;
|
||||
m_rcMail.DefineColumn(3, &rvc);
|
||||
|
||||
//setup according to users preferences
|
||||
if(!profile.IsEmpty())
|
||||
m_rcMail.GetProfile(&profile);
|
||||
else
|
||||
{
|
||||
|
||||
//not needed when setting by pref
|
||||
//but if there are no preferences then you would need it
|
||||
|
||||
m_rcMail.ActivateColumn(0, 0);
|
||||
m_rcMail.ActivateColumn(1, 1);
|
||||
m_rcMail.ActivateColumn(2, 2);
|
||||
m_rcMail.ActivateColumn(3, 3);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
m_rcMail.ModifyStyle(0, RVS_SINGLESELECT);
|
||||
//m_rcMail.ModifyStyle(0, RVS_SHOWCOLORALTERNATE);
|
||||
|
||||
|
||||
//turn off the grids
|
||||
m_rcMail.ModifyStyle(RVS_SHOWVGRID, 0);
|
||||
m_rcMail.ModifyStyle(RVS_SHOWHGRID, 0);
|
||||
|
||||
|
||||
|
||||
//retrieve the mail and display it
|
||||
FillView();
|
||||
|
||||
|
||||
|
||||
//===================================================
|
||||
// SET WINDOW SIZE TO MATCH WORK AREA
|
||||
ShowWindow(SW_SHOWMAXIMIZED);
|
||||
CRect workarea;
|
||||
SystemParametersInfo(SPI_GETWORKAREA,0,&workarea,0);
|
||||
SetWindowPos(NULL,workarea.left,workarea.top,workarea.Width(),workarea.Height(),SWP_NOZORDER);
|
||||
//===================================================
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CMailReaderDlg::OnRvnItemDrawPreview(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
|
||||
CString strText;
|
||||
LPNMRVDRAWPREVIEW lpnmrvdp = (LPNMRVDRAWPREVIEW)pNMHDR;
|
||||
|
||||
strText=m_Messages[0].GetAt(m_Messages[0].FindIndex(lpnmrvdp->iItem));
|
||||
|
||||
CReportCtrl& rc = m_rcMail;
|
||||
|
||||
CDC dc;
|
||||
dc.Attach(lpnmrvdp->hDC);
|
||||
if(lpnmrvdp->nState&RVIS_SELECTED)
|
||||
dc.SetTextColor(::GetFocus()==rc.m_hWnd ? GetSysColor(COLOR_HIGHLIGHTTEXT):GetSysColor(COLOR_HIGHLIGHT));
|
||||
else
|
||||
dc.SetTextColor(GetSysColor(COLOR_HIGHLIGHT));
|
||||
|
||||
lpnmrvdp->rect.left += 40;
|
||||
lpnmrvdp->rect.top += 2;
|
||||
lpnmrvdp->rect.bottom -= 2;
|
||||
dc.DrawText(strText, &lpnmrvdp->rect, DT_LEFT|DT_END_ELLIPSIS|DT_WORDBREAK|DT_NOPREFIX|DT_EXPANDTABS);
|
||||
|
||||
dc.Detach();
|
||||
*pResult = FALSE;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CMailReaderDlg::OnRvnItemDbClick(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
|
||||
LPNMREPORTVIEW lpnmrv = (LPNMREPORTVIEW)pNMHDR;
|
||||
|
||||
|
||||
|
||||
if(lpnmrv->iItem >=0)//-1 if clicked on invalid
|
||||
{
|
||||
|
||||
int x=lpnmrv->iItem;
|
||||
CString temp,msg,sub,strdate,sender,q;
|
||||
temp=m_Messages[0].GetAt(m_Messages[0].FindIndex(x));
|
||||
sub=m_rcMail.GetItemText(x,2);
|
||||
strdate=m_rcMail.GetItemText(x,3);
|
||||
sender=m_rcMail.GetItemText(x,1);
|
||||
|
||||
//Now format with header info
|
||||
msg.Format("From: %s\r\n"
|
||||
"Sent: %s\r\n"
|
||||
"Subject: %s\r\n\r\nMessage:\r\n%s",sender,strdate,sub,temp);
|
||||
|
||||
m_pApp->ShowStuff(msg);
|
||||
//AfxMessageBox(msg,MB_ICONINFORMATION|MB_OK);
|
||||
|
||||
//FLAG MAIL MESSAGE AS BEING READ
|
||||
q.Format("UPDATE mailroute SET mailroute.remind = False "
|
||||
"WHERE (((mailroute.maillink)=%s) AND ((mailroute.recipient)=%u));"
|
||||
,m_Messages[1].GetAt(m_Messages[1].FindIndex(lpnmrv->iItem)),m_pApp->m_lusrID);
|
||||
|
||||
rs->Ex(q);
|
||||
|
||||
|
||||
|
||||
RVITEM rvi;
|
||||
rvi.iItem = lpnmrv->iItem;
|
||||
rvi.iSubItem = 0;
|
||||
rvi.nMask = RVIM_IMAGE|RVIM_PREVIEW|RVIM_STATE;
|
||||
rvi.iImage = 4;
|
||||
rvi.nPreview = 0;
|
||||
rvi.nState = 0;
|
||||
m_rcMail.SetItem(&rvi);
|
||||
|
||||
}
|
||||
|
||||
*pResult = FALSE;
|
||||
}
|
||||
|
||||
|
||||
void CMailReaderDlg::FillView()
|
||||
{
|
||||
|
||||
CString q;
|
||||
bool bUnread;
|
||||
int x=0;
|
||||
|
||||
m_Messages[0].RemoveAll();
|
||||
m_Messages[1].RemoveAll();
|
||||
m_rcMail.DeleteAllItems();
|
||||
|
||||
q.Format("SELECT mail.*, [last] & \", \" & [first] AS fromname, mailroute.remind "
|
||||
"FROM (mail INNER JOIN mailroute ON mail.id = mailroute.maillink) "
|
||||
"LEFT JOIN users ON mail.from = users.id "
|
||||
"WHERE (((mailroute.recipient)=%u) AND ((mail.deliverydate)<Date()+1)) "
|
||||
"ORDER BY mail.date DESC;"
|
||||
,m_pApp->m_lusrID);
|
||||
|
||||
|
||||
rs->Query(q);
|
||||
|
||||
if(rs->IsEmpty())
|
||||
return;
|
||||
|
||||
|
||||
|
||||
CString strFrom,strSubject,strMessage,strDate,strID;
|
||||
COleDateTime dtDate;
|
||||
long lData;
|
||||
|
||||
|
||||
rs->MoveFirst();
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
rs->FetchField("fromname",&strFrom);
|
||||
//fix if a deleted user sent the message
|
||||
if(strFrom.Compare(", ")==0)
|
||||
strFrom="<Unknown>";
|
||||
|
||||
rs->FetchField("subject",&strSubject);
|
||||
k->GZDecrypt(&strSubject,false);
|
||||
rs->FetchField("message",&strMessage);
|
||||
k->GZDecrypt(&strMessage,false);
|
||||
m_Messages[0].AddTail(strMessage);
|
||||
rs->FetchField("deliverydate",&dtDate);
|
||||
//keep track of the ID numbers
|
||||
rs->FetchField("id",&lData);
|
||||
strID.Format("%u",lData);
|
||||
m_Messages[1].AddTail(strID);
|
||||
rs->FetchField("remind",&bUnread);
|
||||
|
||||
//Set the look of the row and insert it
|
||||
RVITEM rvi;
|
||||
rvi.iItem = x;
|
||||
rvi.iSubItem = 0;
|
||||
rvi.nMask = RVIM_IMAGE|RVIM_PREVIEW|RVIM_STATE|RVIM_LPARAM;
|
||||
if(bUnread==false)
|
||||
{
|
||||
rvi.nState = 0;
|
||||
rvi.iImage = 4;//Opened envelope
|
||||
rvi.nPreview = 0;//no preview necessary
|
||||
}
|
||||
else
|
||||
{
|
||||
rvi.nState = RVIS_BOLD;
|
||||
rvi.iImage = 3;//closed envelope
|
||||
if(!strMessage.IsEmpty())
|
||||
rvi.nPreview = 17;//hmmm?
|
||||
else
|
||||
rvi.nPreview=0;//nothing to show
|
||||
}
|
||||
|
||||
rvi.lParam = x;
|
||||
m_rcMail.InsertItem(&rvi);
|
||||
|
||||
|
||||
//RVS_OWNERDATA<---this is causing an assert
|
||||
|
||||
//FROM
|
||||
rvi.iSubItem = 1;
|
||||
rvi.nMask = RVIM_TEXT;
|
||||
rvi.lpszText = strFrom.GetBuffer(strFrom.GetLength());
|
||||
m_rcMail.SetItem(&rvi);
|
||||
|
||||
//SUBJECT
|
||||
rvi.iSubItem = 2;
|
||||
rvi.lpszText = strSubject.GetBuffer(strSubject.GetLength());
|
||||
m_rcMail.SetItem(&rvi);
|
||||
|
||||
//DATE
|
||||
rvi.iSubItem = 3;
|
||||
strDate=dtDate.Format();
|
||||
rvi.lpszText = strDate.GetBuffer(strDate.GetLength());
|
||||
m_rcMail.SetItem(&rvi);
|
||||
|
||||
x++;
|
||||
|
||||
}while(rs->MoveForward());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void CMailReaderDlg::OnOk()
|
||||
{}
|
||||
|
||||
|
||||
|
||||
|
||||
void CMailReaderDlg::Security()
|
||||
{
|
||||
m_bReadOnly=false;
|
||||
int x=m_pApp->Allowed(REMAIL,true);
|
||||
|
||||
if(x==2)//read only
|
||||
{
|
||||
m_bReadOnly=true;
|
||||
//m_btnNew.ShowWindow(FALSE);
|
||||
//m_btnDelete.ShowWindow(FALSE);
|
||||
//m_btnForward.ShowWindow(FALSE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(x==0)
|
||||
{
|
||||
m_bReadOnly=true;
|
||||
m_pApp->SecurityWarning();
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
}
|
||||
|
||||
void CMailReaderDlg::OnMailNewmessage()
|
||||
{
|
||||
// New message
|
||||
if(m_bReadOnly==true)
|
||||
{
|
||||
AfxMessageBox("Your AyaNova administrator has given you\r\n"
|
||||
"read-only access to mail.");
|
||||
return;
|
||||
|
||||
}
|
||||
CMailMsgDlg d;
|
||||
|
||||
d.DoModal();
|
||||
FillView();
|
||||
}
|
||||
|
||||
void CMailReaderDlg::OnMailReply()
|
||||
{
|
||||
if(m_bReadOnly==true)
|
||||
{
|
||||
AfxMessageBox("Your AyaNova administrator has given you\r\n"
|
||||
"read-only access to mail.");
|
||||
return;
|
||||
|
||||
}
|
||||
CString temp,msg,sub,strdate,sender;
|
||||
int x=m_rcMail.GetFirstSelectedItem();
|
||||
//validate there is a selection
|
||||
if(x<0)
|
||||
return;
|
||||
|
||||
temp=m_Messages[0].GetAt(m_Messages[0].FindIndex(x));
|
||||
sub=m_rcMail.GetItemText(x,2);
|
||||
strdate=m_rcMail.GetItemText(x,3);
|
||||
sender=m_rcMail.GetItemText(x,1);
|
||||
msg.Empty();
|
||||
//Now format with header info
|
||||
msg.Format("-----Original Message-----\r\n"
|
||||
"From: %s\r\n"
|
||||
"Sent: %s\r\n"
|
||||
"Subject: %s\r\n\r\n%s",sender,strdate,sub,temp);
|
||||
|
||||
|
||||
|
||||
//---Original Message-----
|
||||
//From: MCC First Aid [mailto:mccfirstaid@suncor.com]
|
||||
//Sent: Friday, May 12, 2000 8:00 AM
|
||||
//To: 'J Cardinal'
|
||||
//Subject: RE: Update for database program
|
||||
//
|
||||
|
||||
|
||||
|
||||
CMailMsgDlg d;
|
||||
d.SetForwardInfo(&sub,&msg);
|
||||
d.DoModal();
|
||||
|
||||
FillView();
|
||||
}
|
||||
|
||||
void CMailReaderDlg::OnMailDelete()
|
||||
{
|
||||
CString q;
|
||||
int x=m_rcMail.GetFirstSelectedItem();
|
||||
//validate there is a selection
|
||||
if(x<0)
|
||||
return;
|
||||
if(AfxMessageBox("Permanently delete this message?",MB_YESNO)==IDYES)
|
||||
{
|
||||
q.Format("DELETE mailroute.*, mailroute.maillink, mailroute.recipient "
|
||||
"FROM mailroute WHERE (((mailroute.maillink)=%s) AND ((mailroute.recipient)=%u));"
|
||||
,m_Messages[1].GetAt(m_Messages[1].FindIndex(x)),m_pApp->m_lusrID);
|
||||
|
||||
rs->Ex(q);
|
||||
rs->Close();
|
||||
FillView();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CMailReaderDlg::OnMailClosethisscreen()
|
||||
{
|
||||
CString profile,q;
|
||||
|
||||
//save to user prefs.
|
||||
m_rcMail.WriteProfile(&profile);
|
||||
q.Format("UPDATE users SET users.mailprofile = \"%s\" "
|
||||
"WHERE (((users.id)=%u));",profile,m_pApp->m_lusrID);
|
||||
rs->Ex(q);
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CMailReaderDlg::OnMailHelp()
|
||||
{
|
||||
WinHelp(0x2008E);
|
||||
}
|
||||
|
||||
void CMailReaderDlg::OnMailCheckfornewmail()
|
||||
{
|
||||
CWaitCursor cw;
|
||||
FillView();
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
#if !defined(AFX_MAILREADERDLG_H__638302E1_2734_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_MAILREADERDLG_H__638302E1_2734_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// MailReaderDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMailReaderDlg dialog
|
||||
#include "ReportCtrl.h"
|
||||
#include "gzk.h"
|
||||
#include "gzrset.h"
|
||||
#include "ResizeCtrl.h"
|
||||
|
||||
class CMailReaderDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CResizeCtrl m_resize;
|
||||
void Security();
|
||||
~CMailReaderDlg();
|
||||
CStringList m_Messages[2];
|
||||
void FillView();
|
||||
CMailReaderDlg(CWnd* pParent = NULL); // standard constructor
|
||||
void OnRvnItemDbClick(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
void OnRvnItemDrawPreview(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
GZK* k;
|
||||
GZRset* rs;
|
||||
CSpApp* m_pApp;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CMailReaderDlg)
|
||||
enum { IDD = IDD_MAILREADER };
|
||||
CReportCtrl m_rcMail;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMailReaderDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
CImageList m_ilReport;
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CMailReaderDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnOk();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
afx_msg void OnMailNewmessage();
|
||||
afx_msg void OnMailReply();
|
||||
afx_msg void OnMailDelete();
|
||||
afx_msg void OnMailClosethisscreen();
|
||||
afx_msg void OnMailHelp();
|
||||
bool m_bReadOnly;
|
||||
afx_msg void OnMailCheckfornewmail();
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_MAILREADERDLG_H__638302E1_2734_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,96 @@
|
||||
// MainFrm.cpp : implementation of the CMainFrame class
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
|
||||
#include "MainFrm.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
//#define _CRTDBG_MAP_ALLOC
|
||||
//#include <stdlib.h>
|
||||
//#include <crtdbg.h>
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame
|
||||
|
||||
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
|
||||
|
||||
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
|
||||
//{{AFX_MSG_MAP(CMainFrame)
|
||||
ON_WM_CLOSE()
|
||||
//}}AFX_MSG_MAP
|
||||
// Global help commands
|
||||
ON_COMMAND(ID_HELP_FINDER, CFrameWnd::OnHelpFinder)
|
||||
ON_COMMAND(ID_HELP, CFrameWnd::OnHelp)
|
||||
ON_COMMAND(ID_CONTEXT_HELP, CFrameWnd::OnContextHelp)
|
||||
ON_COMMAND(ID_DEFAULT_HELP, CFrameWnd::OnHelpFinder)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame construction/destruction
|
||||
|
||||
CMainFrame::CMainFrame()
|
||||
{
|
||||
// TODO: add member initialization code here
|
||||
m_bAutoMenuEnable = FALSE;
|
||||
}
|
||||
|
||||
CMainFrame::~CMainFrame()
|
||||
{
|
||||
}
|
||||
|
||||
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
if( !CFrameWnd::PreCreateWindow(cs) )
|
||||
return FALSE;
|
||||
// TODO: Modify the Window class or styles here by modifying
|
||||
// the CREATESTRUCT cs
|
||||
|
||||
cs.style = WS_OVERLAPPED | WS_CAPTION | FWS_ADDTOTITLE
|
||||
| WS_THICKFRAME | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX;// | WS_MAXIMIZE
|
||||
|
||||
cs.style &= ~FWS_ADDTOTITLE; // no title
|
||||
|
||||
/*
|
||||
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
|
||||
{
|
||||
cs.style &= ~FWS_ADDTOTITLE; // no title
|
||||
return CFrameWnd::PreCreateWindow(cs);
|
||||
}
|
||||
*/
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CMainFrame::AssertValid() const
|
||||
{
|
||||
//CFrameWnd::AssertValid();
|
||||
}
|
||||
|
||||
void CMainFrame::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CFrameWnd::Dump(dc);
|
||||
}
|
||||
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CMainFrame message handlers
|
||||
|
||||
|
||||
void CMainFrame::OnClose()
|
||||
{
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
m_pApp->OnExit();
|
||||
//CFrameWnd::OnClose();
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
// MainFrm.h : interface of the CMainFrame class
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if !defined(AFX_MAINFRM_H__A74C37E9_FC36_11D3_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_MAINFRM_H__A74C37E9_FC36_11D3_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
|
||||
class CMainFrame : public CFrameWnd
|
||||
{
|
||||
|
||||
protected: // create from serialization only
|
||||
CMainFrame();
|
||||
DECLARE_DYNCREATE(CMainFrame)
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
CSpApp* m_pApp;
|
||||
// Operations
|
||||
public:
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CMainFrame)
|
||||
public:
|
||||
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
public:
|
||||
virtual ~CMainFrame();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// Generated message map functions
|
||||
protected:
|
||||
//{{AFX_MSG(CMainFrame)
|
||||
afx_msg void OnClose();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_MAINFRM_H__A74C37E9_FC36_11D3_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,39 @@
|
||||
@echo off
|
||||
REM -- First make map file from Microsoft Visual C++ generated resource.h
|
||||
echo // MAKEHELP.BAT generated Help Map file. Used by SP.HPJ. >"hlp\sp.hm"
|
||||
echo. >>"hlp\sp.hm"
|
||||
echo // Commands (ID_* and IDM_*) >>"hlp\sp.hm"
|
||||
makehm ID_,HID_,0x10000 IDM_,HIDM_,0x10000 resource.h >>"hlp\sp.hm"
|
||||
echo. >>"hlp\sp.hm"
|
||||
echo // Prompts (IDP_*) >>"hlp\sp.hm"
|
||||
makehm IDP_,HIDP_,0x30000 resource.h >>"hlp\sp.hm"
|
||||
echo. >>"hlp\sp.hm"
|
||||
echo // Resources (IDR_*) >>"hlp\sp.hm"
|
||||
makehm IDR_,HIDR_,0x20000 resource.h >>"hlp\sp.hm"
|
||||
echo. >>"hlp\sp.hm"
|
||||
echo // Dialogs (IDD_*) >>"hlp\sp.hm"
|
||||
makehm IDD_,HIDD_,0x20000 resource.h >>"hlp\sp.hm"
|
||||
echo. >>"hlp\sp.hm"
|
||||
echo // Frame Controls (IDW_*) >>"hlp\sp.hm"
|
||||
makehm IDW_,HIDW_,0x50000 resource.h >>"hlp\sp.hm"
|
||||
REM -- Make help for Project SP
|
||||
|
||||
|
||||
echo Building Win32 Help files
|
||||
start /wait hcw /C /E /M "hlp\sp.hpj"
|
||||
if errorlevel 1 goto :Error
|
||||
if not exist "hlp\sp.hlp" goto :Error
|
||||
if not exist "hlp\sp.cnt" goto :Error
|
||||
echo.
|
||||
if exist Debug\nul copy "hlp\sp.hlp" Debug
|
||||
if exist Debug\nul copy "hlp\sp.cnt" Debug
|
||||
if exist Release\nul copy "hlp\sp.hlp" Release
|
||||
if exist Release\nul copy "hlp\sp.cnt" Release
|
||||
echo.
|
||||
goto :done
|
||||
|
||||
:Error
|
||||
echo hlp\sp.hpj(1) : error: Problem encountered creating help file
|
||||
|
||||
:done
|
||||
echo.
|
||||
@@ -0,0 +1,93 @@
|
||||
#if !defined(AFX_MEMDC_H__CA1D3541_7235_11D1_ABBA_00A0243D1382__INCLUDED_)
|
||||
#define AFX_MEMDC_H__CA1D3541_7235_11D1_ABBA_00A0243D1382__INCLUDED_
|
||||
|
||||
#if _MSC_VER >= 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER >= 1000
|
||||
// MemDC.h : header file
|
||||
//
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// CMemDC - memory DC
|
||||
//
|
||||
// Author: Keith Rule
|
||||
// Email: keithr@europa.com
|
||||
// Copyright 1996-1997, Keith Rule
|
||||
//
|
||||
// You may freely use or modify this code provided this
|
||||
// Copyright is included in all derived versions.
|
||||
//
|
||||
// History - 10/3/97 Fixed scrolling bug.
|
||||
// Added print support.
|
||||
// 25 feb 98 - fixed minor assertion bug
|
||||
//
|
||||
// This class implements a memory Device Context
|
||||
|
||||
class CMemDC : public CDC
|
||||
{
|
||||
public:
|
||||
|
||||
// constructor sets up the memory DC
|
||||
CMemDC(CDC* pDC) : CDC()
|
||||
{
|
||||
ASSERT(pDC != NULL);
|
||||
|
||||
m_pDC = pDC;
|
||||
m_pOldBitmap = NULL;
|
||||
m_bMemDC = !pDC->IsPrinting();
|
||||
|
||||
if (m_bMemDC) // Create a Memory DC
|
||||
{
|
||||
pDC->GetClipBox(&m_rect);
|
||||
CreateCompatibleDC(pDC);
|
||||
m_bitmap.CreateCompatibleBitmap(pDC, m_rect.Width(), m_rect.Height());
|
||||
m_pOldBitmap = SelectObject(&m_bitmap);
|
||||
SetWindowOrg(m_rect.left, m_rect.top);
|
||||
}
|
||||
else // Make a copy of the relevent parts of the current DC for printing
|
||||
{
|
||||
m_bPrinting = pDC->m_bPrinting;
|
||||
m_hDC = pDC->m_hDC;
|
||||
m_hAttribDC = pDC->m_hAttribDC;
|
||||
}
|
||||
}
|
||||
|
||||
// Destructor copies the contents of the mem DC to the original DC
|
||||
~CMemDC()
|
||||
{
|
||||
if (m_bMemDC)
|
||||
{
|
||||
// Copy the offscreen bitmap onto the screen.
|
||||
m_pDC->BitBlt(m_rect.left, m_rect.top, m_rect.Width(), m_rect.Height(),
|
||||
this, m_rect.left, m_rect.top, SRCCOPY);
|
||||
|
||||
//Swap back the original bitmap.
|
||||
SelectObject(m_pOldBitmap);
|
||||
} else {
|
||||
// All we need to do is replace the DC with an illegal value,
|
||||
// this keeps us from accidently deleting the handles associated with
|
||||
// the CDC that was passed to the constructor.
|
||||
m_hDC = m_hAttribDC = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Allow usage as a pointer
|
||||
CMemDC* operator->() {return this;}
|
||||
|
||||
// Allow usage as a pointer
|
||||
operator CMemDC*() {return this;}
|
||||
|
||||
private:
|
||||
CBitmap m_bitmap; // Offscreen bitmap
|
||||
CBitmap* m_pOldBitmap; // bitmap originally found in CMemDC
|
||||
CDC* m_pDC; // Saves CDC passed in constructor
|
||||
CRect m_rect; // Rectangle of drawing area.
|
||||
BOOL m_bMemDC; // TRUE if CDC really is a Memory DC.
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_MEMDC_H__CA1D3541_7235_11D1_ABBA_00A0243D1382__INCLUDED_)
|
||||
@@ -0,0 +1,337 @@
|
||||
// ModelCatsDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "ModelCatsDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CModelCatsDlg dialog
|
||||
|
||||
|
||||
CModelCatsDlg::CModelCatsDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CModelCatsDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CModelCatsDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_bAddMode=false;
|
||||
m_pApp = (CSpApp*)AfxGetApp();
|
||||
|
||||
/*rs=new GZRset("Error: Unit model categories dialog");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
*/
|
||||
//Initialize recordset pointer
|
||||
rs=m_pApp->rsPool->GetRS("CModelCatsDlg");
|
||||
|
||||
m_pstrReturnValue=NULL;
|
||||
}
|
||||
|
||||
CModelCatsDlg::~CModelCatsDlg()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
|
||||
void CModelCatsDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CModelCatsDlg)
|
||||
DDX_Control(pDX, IDC_LBLCATEGORY, m_lblCategory);
|
||||
DDX_Control(pDX, IDC_EDNOTES, m_edNotes);
|
||||
DDX_Control(pDX, IDC_EDCATEGORY, m_edCategory);
|
||||
DDX_Control(pDX, IDC_CBCATEGORIES, m_cbCategories);
|
||||
DDX_Control(pDX, IDC_BTNDONE, m_btnDone);
|
||||
DDX_Control(pDX, IDC_BTNDELETE, m_btnDelete);
|
||||
DDX_Control(pDX, IDC_BTNADD, m_btnAdd);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CModelCatsDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CModelCatsDlg)
|
||||
ON_BN_CLICKED(IDC_BTNADD, OnBtnadd)
|
||||
ON_BN_CLICKED(IDC_BTNDELETE, OnBtndelete)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
ON_CBN_CLOSEUP(IDC_CBCATEGORIES, OnCloseupCbcategories)
|
||||
ON_EN_KILLFOCUS(IDC_EDCATEGORY, OnKillfocusEdcategory)
|
||||
ON_EN_KILLFOCUS(IDC_EDNOTES, OnKillfocusEdnotes)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CModelCatsDlg message handlers
|
||||
|
||||
BOOL CModelCatsDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
Security();
|
||||
FillList();
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CModelCatsDlg::OnBtnadd()
|
||||
{
|
||||
CString strName,strNotes,q;
|
||||
|
||||
if(!m_bAddMode)
|
||||
{
|
||||
//go add mode
|
||||
m_btnDone.ShowWindow(FALSE);
|
||||
m_btnAdd.SetWindowText("SAVE");
|
||||
m_lblCategory.ShowWindow(FALSE);
|
||||
m_cbCategories.ShowWindow(FALSE);
|
||||
m_btnDelete.SetWindowText("CANCEL");
|
||||
m_edCategory.SetWindowText("");
|
||||
m_edNotes.SetWindowText("");
|
||||
m_bAddMode=true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//save
|
||||
m_edCategory.GetWindowText(strName);
|
||||
m_edNotes.GetWindowText(strNotes);
|
||||
if(strName.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("A category name is required to save this record");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
q.Format("INSERT INTO unitmodelcats ( name, notes )"
|
||||
"SELECT \"%s\" , \"%s\";",strName,strNotes);
|
||||
if(!rs->Ex(q))
|
||||
return;
|
||||
rs->Close();
|
||||
|
||||
|
||||
|
||||
//go normal mode
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_lblCategory.ShowWindow(TRUE);
|
||||
m_cbCategories.ShowWindow(TRUE);
|
||||
m_btnDelete.SetWindowText("Delete");
|
||||
m_strSelectedCategory="";
|
||||
m_bAddMode=false;
|
||||
FillList();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CModelCatsDlg::OnBtndelete()
|
||||
{
|
||||
CString q;
|
||||
if(m_bAddMode)
|
||||
{
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_lblCategory.ShowWindow(TRUE);
|
||||
m_cbCategories.ShowWindow(TRUE);
|
||||
m_btnDelete.SetWindowText("Delete");
|
||||
m_strSelectedCategory="";
|
||||
m_bAddMode=false;
|
||||
FillList();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//DELETE
|
||||
//see if it can be deleted first
|
||||
q.Format("SELECT unitmodels.id "
|
||||
"FROM unitmodels WHERE (((unitmodels.category)=%s));",m_strSelectedCategory);
|
||||
|
||||
rs->Query(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
AfxMessageBox("Data integrity protection!\r\n"
|
||||
"You can't delete this record at this time because\r\n"
|
||||
"it's attached to one or more Unit models.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(AfxMessageBox("Permanently delete this category.\r\nAre you sure?",MB_YESNO)==IDYES)
|
||||
{
|
||||
//run a delete query on it
|
||||
q.Format("DELETE unitmodelcats.*, unitmodelcats.id "
|
||||
"FROM unitmodelcats WHERE (((unitmodelcats.id)=%s));",m_strSelectedCategory);
|
||||
rs->Ex(q);
|
||||
m_strSelectedCategory.Empty();
|
||||
FillList();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CModelCatsDlg::OnBtndone()
|
||||
{
|
||||
if(m_pstrReturnValue!=NULL)
|
||||
*m_pstrReturnValue=m_strSelectedCategory;
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CModelCatsDlg::OnCloseupCbcategories()
|
||||
{
|
||||
m_strSelectedCategory=m_cbCategories.GetCurrentRowID();
|
||||
|
||||
FillFields();
|
||||
}
|
||||
|
||||
void CModelCatsDlg::OnKillfocusEdcategory()
|
||||
{
|
||||
|
||||
|
||||
SaveField(&m_edCategory,"name",false);
|
||||
if(!m_bAddMode)
|
||||
FillList();
|
||||
|
||||
}
|
||||
|
||||
void CModelCatsDlg::OnKillfocusEdnotes()
|
||||
{
|
||||
|
||||
SaveField(&m_edNotes,"notes",false);
|
||||
|
||||
}
|
||||
|
||||
void CModelCatsDlg::SetReturnString(CString *strReturn)
|
||||
{
|
||||
m_pstrReturnValue=strReturn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//****************************************
|
||||
//FILL LIST BOX
|
||||
//****************************************
|
||||
void CModelCatsDlg::FillList()
|
||||
{
|
||||
|
||||
CString strData;
|
||||
CString strIndex;
|
||||
long lData;
|
||||
m_cbCategories.Clear();
|
||||
|
||||
|
||||
|
||||
rs->Query("SELECT unitmodelcats.* FROM unitmodelcats;");
|
||||
if(rs->IsEmpty())
|
||||
return;
|
||||
|
||||
|
||||
rs->MoveFirst();
|
||||
|
||||
do
|
||||
{
|
||||
rs->FetchField("name",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbCategories.AddRow(strData,strIndex);
|
||||
}while(rs->MoveForward());
|
||||
|
||||
|
||||
|
||||
//pretend user has selected so that other fields get filled in
|
||||
if(m_strSelectedCategory.IsEmpty()) //first time in
|
||||
{
|
||||
m_cbCategories.SetCurSel(0);
|
||||
m_strSelectedCategory=m_cbCategories.GetCurrentRowID();
|
||||
|
||||
}
|
||||
else//something valid was selected before so stick with it
|
||||
m_cbCategories.Select(m_strSelectedCategory);
|
||||
|
||||
|
||||
FillFields();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Fillout contents of fields
|
||||
void CModelCatsDlg::FillFields()
|
||||
{
|
||||
CString q,strData;
|
||||
q.Format("SELECT unitmodelcats.* "
|
||||
"FROM unitmodelcats "
|
||||
"WHERE (((unitmodelcats.id)=%s));",m_cbCategories.GetCurrentRowID());
|
||||
|
||||
rs->Query(q);
|
||||
if(rs->IsEmpty())
|
||||
return;
|
||||
rs->FetchField("name",&strData);
|
||||
m_edCategory.SetWindowText(strData);
|
||||
|
||||
rs->FetchField("notes",&strData);
|
||||
m_edNotes.SetWindowText(strData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//************************************************************
|
||||
//SAVE EDIT CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CModelCatsDlg::SaveField(CEdit *edControl,CString fldname,bool AllowEmpty)
|
||||
{
|
||||
|
||||
if(m_bAddMode) return true;//dont attempt to update
|
||||
CString str;
|
||||
//do nothing if not changed
|
||||
if(edControl->GetModify()!=TRUE) return true;
|
||||
|
||||
edControl->GetWindowText(str);
|
||||
//dont save empty fields if not allowed to
|
||||
if(!AllowEmpty)
|
||||
{
|
||||
|
||||
if(str.IsEmpty())
|
||||
{
|
||||
edControl->Undo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rs->UpdateField(fldname,&str);
|
||||
rs->SaveRecord();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CModelCatsDlg::Security()
|
||||
{
|
||||
|
||||
int x=m_pApp->Allowed(RMODELS,true);
|
||||
if(x==0)//no access allowed
|
||||
{
|
||||
m_pApp->SecurityWarning();
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
if(x==2)//read only
|
||||
{
|
||||
m_btnAdd.ShowWindow(FALSE);
|
||||
m_btnDelete.ShowWindow(FALSE);
|
||||
|
||||
//m_cbCategories.EnableWindow(FALSE);
|
||||
m_edCategory.SetReadOnly(TRUE);
|
||||
m_edNotes.SetReadOnly(TRUE);
|
||||
m_lblCategory.EnableWindow(FALSE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
#if !defined(AFX_MODELCATSDLG_H__19D53F22_27FA_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_MODELCATSDLG_H__19D53F22_27FA_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// ModelCatsDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CModelCatsDlg dialog
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
|
||||
class CModelCatsDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
bool m_bReadOnly;
|
||||
void Security();
|
||||
~CModelCatsDlg();
|
||||
void FillFields();
|
||||
void FillList();
|
||||
bool m_bAddMode;
|
||||
CString m_strSelectedCategory;
|
||||
void SetReturnString(CString* strReturn);
|
||||
CModelCatsDlg(CWnd* pParent = NULL); // standard constructor
|
||||
bool SaveField(CEdit* edControl,CString fldname,bool AllowEmpty);
|
||||
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
CString * m_pstrReturnValue;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CModelCatsDlg)
|
||||
enum { IDD = IDD_MODELCATS };
|
||||
CStatic m_lblCategory;
|
||||
CEdit m_edNotes;
|
||||
CEdit m_edCategory;
|
||||
CgzCombo m_cbCategories;
|
||||
CButton m_btnDone;
|
||||
CButton m_btnDelete;
|
||||
CButton m_btnAdd;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CModelCatsDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CModelCatsDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBtnadd();
|
||||
afx_msg void OnBtndelete();
|
||||
afx_msg void OnBtndone();
|
||||
afx_msg void OnCloseupCbcategories();
|
||||
afx_msg void OnKillfocusEdcategory();
|
||||
afx_msg void OnKillfocusEdnotes();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_MODELCATSDLG_H__19D53F22_27FA_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,951 @@
|
||||
// ModelsDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "ModelsDlg.h"
|
||||
#include "ModelCatsDlg.h"
|
||||
#include "NonClientsDlg.h"
|
||||
#include "PM.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CModelsDlg dialog
|
||||
|
||||
|
||||
CModelsDlg::CModelsDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CModelsDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CModelsDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_bAddMode=false;
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
/*
|
||||
rs=new GZRset("Error: Unit models dialog");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
|
||||
cbrs=new GZRset("Error: Unit models dialog combo box recordset\r\n");
|
||||
cbrs->SetConnect(m_pApp->strConnectString);
|
||||
*/
|
||||
//Initialize recordset pointer
|
||||
|
||||
|
||||
cbrs=m_pApp->rsPool->GetRS("CModelsDlg (CBRS)");
|
||||
rs=m_pApp->rsPool->GetRS("CModelsDlg (RS)");
|
||||
|
||||
m_pstrReturnValue=NULL;
|
||||
m_strSelectedModel.Empty();
|
||||
m_bListByDescription=true;
|
||||
|
||||
}
|
||||
|
||||
CModelsDlg::~CModelsDlg()
|
||||
{
|
||||
|
||||
m_pApp->rsPool->ReleaseRS(&cbrs->m_nID);
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
|
||||
void CModelsDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CModelsDlg)
|
||||
DDX_Control(pDX, IDC_LBLBYDESC, m_lblByDesc);
|
||||
DDX_Control(pDX, IDC_LBLBYMODEL, m_lblByModel);
|
||||
DDX_Control(pDX, IDC_EDDESCRIPTION, m_edDescription);
|
||||
DDX_Control(pDX, IDC_BTNPM, m_btnPM);
|
||||
DDX_Control(pDX, IDC_LBLMODELLIST, m_lblModels);
|
||||
DDX_Control(pDX, IDC_LBLMANUFACTURER, m_lblManufacturer);
|
||||
DDX_Control(pDX, IDC_LBLCATEGORY, m_lblCategory);
|
||||
DDX_Control(pDX, IDC_EDWARRANTYTERMS, m_edWarrantyTerms);
|
||||
DDX_Control(pDX, IDC_EDWARRANTYMONTHS, m_edWarrantyMonths);
|
||||
DDX_Control(pDX, IDC_EDNOTES, m_edNotes);
|
||||
DDX_Control(pDX, IDC_EDMODEL, m_edModel);
|
||||
DDX_Control(pDX, IDC_DTINTRODUCED, m_dtIntroduced);
|
||||
DDX_Control(pDX, IDC_DTDISCONTINUED, m_dtDiscontinued);
|
||||
DDX_Control(pDX, IDC_CKLIFETIME, m_ckLifetime);
|
||||
DDX_Control(pDX, IDC_CKDISCONTINUED, m_ckDiscontinued);
|
||||
DDX_Control(pDX, IDC_CKACTIVE, m_ckActive);
|
||||
DDX_Control(pDX, IDC_CBMODELS, m_cbModels);
|
||||
DDX_Control(pDX, IDC_CBMANUFACTURERS, m_cbManufacturers);
|
||||
DDX_Control(pDX, IDC_CBCATEGORIES, m_cbCategories);
|
||||
DDX_Control(pDX, IDC_BTNDONE, m_btnDone);
|
||||
DDX_Control(pDX, IDC_BTNDELETE, m_btnDelete);
|
||||
DDX_Control(pDX, IDC_BTNADD, m_btnAdd);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CModelsDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CModelsDlg)
|
||||
ON_BN_CLICKED(IDC_BTNADD, OnBtnadd)
|
||||
ON_BN_CLICKED(IDC_BTNDELETE, OnBtndelete)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
ON_CBN_CLOSEUP(IDC_CBCATEGORIES, OnCloseupCbcategories)
|
||||
ON_CBN_CLOSEUP(IDC_CBMANUFACTURERS, OnCloseupCbmanufacturers)
|
||||
ON_CBN_CLOSEUP(IDC_CBMODELS, OnCloseupCbmodels)
|
||||
ON_BN_CLICKED(IDC_CKDISCONTINUED, OnCkdiscontinued)
|
||||
ON_BN_CLICKED(IDC_CKLIFETIME, OnCklifetime)
|
||||
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTDISCONTINUED, OnDatetimechangeDtdiscontinued)
|
||||
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTINTRODUCED, OnDatetimechangeDtintroduced)
|
||||
ON_EN_KILLFOCUS(IDC_EDMODEL, OnKillfocusEdmodel)
|
||||
ON_EN_KILLFOCUS(IDC_EDNOTES, OnKillfocusEdnotes)
|
||||
ON_EN_KILLFOCUS(IDC_EDWARRANTYMONTHS, OnKillfocusEdwarrantymonths)
|
||||
ON_EN_KILLFOCUS(IDC_EDWARRANTYTERMS, OnKillfocusEdwarrantyterms)
|
||||
ON_BN_CLICKED(IDC_LBLCATEGORY, OnLblcategory)
|
||||
ON_BN_CLICKED(IDC_LBLMANUFACTURER, OnLblmanufacturer)
|
||||
ON_BN_CLICKED(IDC_BTNPM, OnBtnpm)
|
||||
ON_EN_KILLFOCUS(IDC_EDDESCRIPTION, OnKillfocusEddescription)
|
||||
ON_BN_CLICKED(IDC_LBLBYMODEL, OnLblbymodel)
|
||||
ON_BN_CLICKED(IDC_LBLBYDESC, OnLblbydesc)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CModelsDlg message handlers
|
||||
|
||||
BOOL CModelsDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
Security();
|
||||
//make "hyperlinks"
|
||||
m_lblCategory.SetTextColor(RGB(0,0,255));
|
||||
m_lblCategory.SetFontUnderline(TRUE);
|
||||
m_lblCategory.SetLink(TRUE);
|
||||
m_lblCategory.SetLinkCursor(m_pApp->hcHand);
|
||||
m_lblCategory.SetLinkURL("");
|
||||
|
||||
|
||||
//make "hyperlinks"
|
||||
m_lblManufacturer.SetTextColor(RGB(0,0,255));
|
||||
m_lblManufacturer.SetFontUnderline(TRUE);
|
||||
m_lblManufacturer.SetLink(TRUE);
|
||||
m_lblManufacturer.SetLinkCursor(m_pApp->hcHand);
|
||||
m_lblManufacturer.SetLinkURL("");
|
||||
|
||||
|
||||
m_lblByDesc.SetTextColor(RGB(0,0,255));
|
||||
m_lblByDesc.SetFontUnderline(TRUE);
|
||||
m_lblByDesc.SetLink(TRUE);
|
||||
m_lblByDesc.SetLinkCursor(m_pApp->hcHand);
|
||||
m_lblByDesc.SetLinkURL("");
|
||||
|
||||
m_lblByModel.SetTextColor(RGB(0,0,255));
|
||||
m_lblByModel.SetFontUnderline(TRUE);
|
||||
m_lblByModel.SetLink(TRUE);
|
||||
m_lblByModel.SetLinkCursor(m_pApp->hcHand);
|
||||
m_lblByModel.SetLinkURL("");
|
||||
|
||||
|
||||
FillCategoryList();
|
||||
FillManufacturerList();
|
||||
//this one has to be last because it's going to
|
||||
//trigger selections on the other two
|
||||
FillModelList();
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void CModelsDlg::OnBtnadd()
|
||||
{
|
||||
CString strData;
|
||||
long lData;
|
||||
bool bData;
|
||||
COleDateTime dtData;
|
||||
CString q;
|
||||
|
||||
if(!m_bAddMode)
|
||||
{
|
||||
//Go into add mode
|
||||
EnableFields(true);
|
||||
m_bAddMode=true;
|
||||
m_lblModels.ShowWindow(FALSE);
|
||||
m_cbModels.ShowWindow(FALSE);
|
||||
m_btnPM.ShowWindow(FALSE);
|
||||
m_btnDone.ShowWindow(FALSE);
|
||||
m_btnAdd.SetWindowText("SAVE");
|
||||
m_btnDelete.SetWindowText("CANCEL");
|
||||
m_cbCategories.Select("0");
|
||||
m_cbManufacturers.Select("0");
|
||||
m_ckDiscontinued.SetCheck(FALSE);
|
||||
m_ckLifetime.SetCheck(FALSE);
|
||||
m_dtDiscontinued.SetTime(COleDateTime::GetCurrentTime());
|
||||
m_dtIntroduced.SetTime(COleDateTime::GetCurrentTime());
|
||||
m_edModel.SetWindowText("");
|
||||
m_edDescription.SetWindowText("");
|
||||
m_edNotes.SetWindowText("");
|
||||
m_edWarrantyMonths.SetWindowText("");
|
||||
m_edWarrantyTerms.SetWindowText("");
|
||||
m_lblByDesc.ShowWindow(FALSE);
|
||||
m_lblByModel.ShowWindow(FALSE);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//Validate and Save record
|
||||
m_edModel.GetWindowText(strData);
|
||||
if(strData.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("A Model number is required to save this record");
|
||||
return;
|
||||
}
|
||||
|
||||
//check if duplicate model number
|
||||
q.Format("SELECT unitmodels.model FROM unitmodels WHERE (((unitmodels.model)=\"%s\"));",strData);
|
||||
rs->QueryReadOnly(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
q.Format("Model number \"%s\" has already been used.\r\n"
|
||||
"Each model record must have a unique model number\r\n"
|
||||
"Change the model number to save this record.",strData);
|
||||
AfxMessageBox(q);
|
||||
m_edModel.SetFocus();
|
||||
return;
|
||||
|
||||
}
|
||||
rs->Query("SELECT unitmodels.* FROM unitmodels WHERE unitmodels.id = 0;");
|
||||
rs->AddNewRecord();
|
||||
|
||||
//MODEL
|
||||
rs->UpdateField("model",&strData);
|
||||
|
||||
//Description
|
||||
m_edDescription.GetWindowText(strData);
|
||||
rs->UpdateField("description",&strData);
|
||||
|
||||
//CATEGORY
|
||||
strData=m_cbCategories.GetCurrentRowID();
|
||||
lData=atol(strData);
|
||||
rs->UpdateField("category",&lData);
|
||||
|
||||
//LIFETIMEWARRANTY
|
||||
bData=(m_ckLifetime.GetCheck() ? true : false);
|
||||
rs->UpdateField("lifetimewarranty",&bData);
|
||||
|
||||
//WARRANTY (months)
|
||||
m_edWarrantyMonths.GetWindowText(strData);
|
||||
lData=atol(strData);
|
||||
rs->UpdateField("warranty",&lData);
|
||||
|
||||
//WARRANTYTERMS
|
||||
m_edWarrantyTerms.GetWindowText(strData);
|
||||
rs->UpdateField("warrantyterms",&strData);
|
||||
|
||||
//MANUFACTURER
|
||||
strData=m_cbManufacturers.GetCurrentRowID();
|
||||
lData=atol(strData);
|
||||
rs->UpdateField("manufacturer",&lData);
|
||||
|
||||
//DISCONTINUED
|
||||
bData=(m_ckDiscontinued.GetCheck() ? true : false);
|
||||
rs->UpdateField("discontinued",&bData);
|
||||
|
||||
//DISCONTINUED DATE
|
||||
m_dtDiscontinued.GetTime(dtData);
|
||||
rs->UpdateField("discodate",&dtData);
|
||||
|
||||
//INTRODUCED DATE
|
||||
m_dtIntroduced.GetTime(dtData);
|
||||
rs->UpdateField("introduced",&dtData);
|
||||
|
||||
//NOTES
|
||||
m_edNotes.GetWindowText(strData);
|
||||
rs->UpdateField("notes",&strData);
|
||||
|
||||
//SAVE NEW RECORD
|
||||
rs->SaveRecord();
|
||||
|
||||
|
||||
m_bAddMode=false;
|
||||
m_lblByDesc.ShowWindow(TRUE);
|
||||
m_lblByModel.ShowWindow(TRUE);
|
||||
m_btnPM.ShowWindow(TRUE);
|
||||
m_lblModels.ShowWindow(TRUE);
|
||||
m_cbModels.ShowWindow(TRUE);
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_btnDelete.SetWindowText("Delete");
|
||||
FillModelList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Delete
|
||||
void CModelsDlg::OnBtndelete()
|
||||
{
|
||||
CString q;
|
||||
|
||||
if(m_bAddMode)//then this is the cancel button
|
||||
{
|
||||
m_bAddMode=false;
|
||||
m_btnPM.ShowWindow(TRUE);
|
||||
m_lblModels.ShowWindow(TRUE);
|
||||
m_cbModels.ShowWindow(TRUE);
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
m_lblByDesc.ShowWindow(TRUE);
|
||||
m_lblByModel.ShowWindow(TRUE);
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_btnDelete.SetWindowText("Delete");
|
||||
FillModelList();
|
||||
return;
|
||||
}
|
||||
|
||||
if(m_bNoRecords) return;
|
||||
|
||||
//Delete the current record
|
||||
|
||||
//check if safe to delete
|
||||
q.Format("SELECT units.id "
|
||||
"FROM units WHERE (((units.model)=%s));",m_cbModels.GetCurrentRowID());
|
||||
|
||||
cbrs->Query(q);
|
||||
|
||||
if(!cbrs->IsEmpty())
|
||||
{
|
||||
AfxMessageBox("DATA INTEGRITY PROTECTION!\r\n"
|
||||
"There are one or more units that are attached to this model number.\r\n"
|
||||
"You can't delete this record at this time.");
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//SAFE TO DELETE
|
||||
q.Format("DELETE unitmodels.*, unitmodels.id "
|
||||
"FROM unitmodels WHERE (((unitmodels.id)=%s));",m_cbModels.GetCurrentRowID());
|
||||
|
||||
if(AfxMessageBox("Delete this record permanently?\r\nAre you sure?",MB_YESNO)==IDYES)
|
||||
{
|
||||
cbrs->Ex(q);
|
||||
m_strSelectedModel="";
|
||||
FillModelList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void CModelsDlg::OnBtndone()
|
||||
{
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
|
||||
//********************************
|
||||
void CModelsDlg::OnCloseupCbcategories()
|
||||
{
|
||||
SaveField(&m_cbCategories,"category");
|
||||
|
||||
}
|
||||
|
||||
void CModelsDlg::OnCloseupCbmanufacturers()
|
||||
{
|
||||
SaveField(&m_cbManufacturers,"manufacturer");
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-****************************
|
||||
void CModelsDlg::OnCloseupCbmodels()
|
||||
{
|
||||
m_strSelectedModel=m_cbModels.GetCurrentRowID();
|
||||
|
||||
FillFields();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*******************************
|
||||
void CModelsDlg::OnCkdiscontinued()
|
||||
{
|
||||
SaveField(&m_ckDiscontinued,"discontinued");
|
||||
m_dtDiscontinued.ShowWindow(m_ckDiscontinued.GetCheck());
|
||||
if(m_bReadOnly)
|
||||
m_dtDiscontinued.EnableWindow(FALSE);
|
||||
}
|
||||
|
||||
|
||||
//*******************************
|
||||
void CModelsDlg::OnCklifetime()
|
||||
{
|
||||
SaveField(&m_ckLifetime,"lifetimewarranty");
|
||||
|
||||
}
|
||||
|
||||
//************************************************
|
||||
void CModelsDlg::OnDatetimechangeDtdiscontinued(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
SaveField(&m_dtDiscontinued,"discodate");
|
||||
|
||||
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
//************************************************
|
||||
void CModelsDlg::OnDatetimechangeDtintroduced(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
SaveField(&m_dtIntroduced,"introduced");
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
//*****************************************
|
||||
void CModelsDlg::OnKillfocusEdmodel()
|
||||
{
|
||||
|
||||
SaveField(&m_edModel,"model",false);
|
||||
if(!m_bAddMode)
|
||||
FillModelList();
|
||||
}
|
||||
|
||||
//*********************************************
|
||||
void CModelsDlg::OnKillfocusEdnotes()
|
||||
{
|
||||
SaveField(&m_edNotes,"notes",true);
|
||||
|
||||
}
|
||||
|
||||
//************************************************
|
||||
void CModelsDlg::OnKillfocusEdwarrantymonths()
|
||||
{
|
||||
|
||||
long lData;
|
||||
|
||||
CString str;
|
||||
//do nothing if not changed
|
||||
if(m_edWarrantyMonths.GetModify()!=TRUE) return;
|
||||
|
||||
m_edWarrantyMonths.GetWindowText(str);
|
||||
//lData=atol(str);
|
||||
_variant_t vtData(str);
|
||||
//v1.9.4.4 added try / catch mechanism to catch dumb-asses entering text in a numeric field
|
||||
try
|
||||
{
|
||||
lData=(long)vtData;//cast variant to float (locale friendly)
|
||||
}
|
||||
catch( _com_error &e )
|
||||
{
|
||||
|
||||
AfxMessageBox("I could not interpret your entry in the Warranty Months field\r\n"
|
||||
"I can't save this field until a valid entry is made.\r\n"
|
||||
"If you want to leave it blank, put a zero in it.");
|
||||
m_edWarrantyMonths.Undo();
|
||||
m_edWarrantyMonths.SetModify(FALSE);
|
||||
m_edWarrantyMonths.SetFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
//v1.9.4.4 moved down here so validation will run in any mode
|
||||
if(m_bAddMode) return;//dont attempt to update
|
||||
|
||||
rs->UpdateField("warranty",&lData);
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CModelsDlg::OnKillfocusEdwarrantyterms()
|
||||
{
|
||||
SaveField(&m_edWarrantyTerms,"warrantyterms",true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*******************************
|
||||
void CModelsDlg::OnLblcategory()
|
||||
{
|
||||
CString str,id;
|
||||
CModelCatsDlg d;
|
||||
d.SetReturnString(&str);
|
||||
if(d.DoModal()==IDOK)
|
||||
{
|
||||
id=m_cbCategories.GetCurrentRowID();
|
||||
FillCategoryList();
|
||||
m_cbCategories.Select(id);
|
||||
}
|
||||
//OnCloseupCbcategories();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//**********************************
|
||||
void CModelsDlg::OnLblmanufacturer()
|
||||
{
|
||||
CString str,id;
|
||||
long ldata=3;//manufacturers are type 3
|
||||
CNonClientsDlg d;
|
||||
d.SetType(&ldata);
|
||||
d.SetReturnString(&str);
|
||||
if(d.DoModal()==IDOK)
|
||||
{
|
||||
id=m_cbManufacturers.GetCurrentRowID();
|
||||
FillManufacturerList();
|
||||
m_cbManufacturers.Select(id);
|
||||
//this will save the field change tothe
|
||||
//database since the user didn't select
|
||||
//the regular way.
|
||||
////OnCloseupCbmanufacturers();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CModelsDlg::FillCategoryList()
|
||||
{
|
||||
CString strData;
|
||||
CString strIndex;
|
||||
long lData;
|
||||
m_cbCategories.Clear();
|
||||
|
||||
//Set the default
|
||||
strData="<No category>";
|
||||
strIndex="0";
|
||||
m_cbCategories.AddRow(strData,strIndex);
|
||||
|
||||
cbrs->Query("SELECT unitmodelcats.* FROM unitmodelcats;");
|
||||
if(cbrs->IsEmpty())
|
||||
return;
|
||||
|
||||
|
||||
cbrs->MoveFirst();
|
||||
|
||||
do
|
||||
{
|
||||
cbrs->FetchField("name",&strData);
|
||||
cbrs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbCategories.AddRow(strData,strIndex);
|
||||
}while(cbrs->MoveForward());
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//********************************
|
||||
void CModelsDlg::FillModelList()
|
||||
{
|
||||
|
||||
CString strData;
|
||||
CString strIndex;
|
||||
long lData;
|
||||
m_cbModels.Clear();
|
||||
|
||||
|
||||
if(m_bListByDescription)
|
||||
{
|
||||
rs->Query("SELECT [company_person] & \" \" & [description] & \" \" & [model] AS item, unitmodels.id "
|
||||
"FROM unitmodels LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id "
|
||||
"ORDER BY [company_person] & \" \" & [description] & \" \" & [model];");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
rs->Query("SELECT [model] & \" \" & [company_person] & \" \" & [description] AS item, unitmodels.id "
|
||||
"FROM unitmodels LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id "
|
||||
"ORDER BY [company_person] & \" \" & [description] & \" \" & [model];");
|
||||
|
||||
}
|
||||
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
EnableFields(false);
|
||||
m_bNoRecords=true;
|
||||
return;
|
||||
}
|
||||
else
|
||||
m_bNoRecords=false;
|
||||
EnableFields(true);
|
||||
|
||||
rs->MoveFirst();
|
||||
|
||||
do
|
||||
{
|
||||
rs->FetchField("item",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbModels.AddRow(strData,strIndex);
|
||||
}while(rs->MoveForward());
|
||||
|
||||
|
||||
//pretend user has selected so that other fields get filled in
|
||||
if(m_strSelectedModel.IsEmpty()) //first time in
|
||||
{
|
||||
m_cbModels.SetCurSel(0);
|
||||
m_strSelectedModel=m_cbModels.GetCurrentRowID();
|
||||
|
||||
}
|
||||
else//something valid was selected before so stick with it
|
||||
m_cbModels.Select(m_strSelectedModel);
|
||||
|
||||
|
||||
//trigger selection
|
||||
OnCloseupCbmodels();
|
||||
}
|
||||
|
||||
|
||||
//********************************************
|
||||
void CModelsDlg::FillManufacturerList()
|
||||
{
|
||||
|
||||
CString strData;
|
||||
CString strIndex;
|
||||
long lData;
|
||||
m_cbManufacturers.Clear();
|
||||
|
||||
//set defaults
|
||||
strData="<Unknown>";
|
||||
strIndex="0";
|
||||
m_cbManufacturers.AddRow(strData,strIndex);
|
||||
|
||||
//type 3 = manufacturers
|
||||
cbrs->Query("SELECT nonclients.* "
|
||||
"FROM nonclients "
|
||||
"WHERE (((nonclients.type)=3)) "
|
||||
"ORDER BY nonclients.company_person;");
|
||||
|
||||
|
||||
if(cbrs->IsEmpty())
|
||||
return;
|
||||
|
||||
|
||||
cbrs->MoveFirst();
|
||||
|
||||
do
|
||||
{
|
||||
cbrs->FetchField("company_person",&strData);
|
||||
cbrs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbManufacturers.AddRow(strData,strIndex);
|
||||
}while(cbrs->MoveForward());
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*******************************************
|
||||
|
||||
void CModelsDlg::SetReturnString(CString *strReturn)
|
||||
{
|
||||
m_pstrReturnValue=strReturn;
|
||||
//specific record should be shown?
|
||||
if(!m_pstrReturnValue->IsEmpty())
|
||||
m_strSelectedModel=*m_pstrReturnValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//****************************************
|
||||
void CModelsDlg::FillFields()
|
||||
{
|
||||
|
||||
CString q,strData;
|
||||
COleDateTime dtData;
|
||||
bool bData;
|
||||
long lData;
|
||||
//Fill all fields based on current record.
|
||||
strData=m_cbModels.GetCurrentRowID();
|
||||
if(strData.IsEmpty())
|
||||
return;
|
||||
|
||||
q.Format("SELECT unitmodels.* "
|
||||
"FROM unitmodels "
|
||||
"WHERE (((unitmodels.id)=%s));",strData);
|
||||
|
||||
rs->Query(q);
|
||||
|
||||
if(rs->IsEmpty())
|
||||
return;//something very wrong if this ever gets called
|
||||
|
||||
//FETCHFIELDS AND FILL BOXES
|
||||
|
||||
//MODEL
|
||||
rs->FetchField("model",&strData);
|
||||
m_edModel.SetWindowText(strData);
|
||||
|
||||
//DESCRIPTION
|
||||
rs->FetchField("description",&strData);
|
||||
m_edDescription.SetWindowText(strData);
|
||||
|
||||
//CATEGORY
|
||||
rs->FetchField("category",&lData);
|
||||
strData.Format("%u",lData);
|
||||
m_cbCategories.Select(strData);
|
||||
|
||||
//LIFETIMEWARRANTY
|
||||
rs->FetchField("lifetimewarranty",&bData);
|
||||
m_ckLifetime.SetCheck(bData ? TRUE : FALSE);
|
||||
|
||||
//WARRANTY (months)
|
||||
rs->FetchField("warranty",&lData);
|
||||
strData.Format("%u",lData);
|
||||
m_edWarrantyMonths.SetWindowText(strData);
|
||||
|
||||
//WARRANTYTERMS
|
||||
rs->FetchField("warrantyterms",&strData);
|
||||
m_edWarrantyTerms.SetWindowText(strData);
|
||||
|
||||
//MANUFACTURER
|
||||
rs->FetchField("manufacturer",&lData);
|
||||
strData.Format("%u",lData);
|
||||
m_cbManufacturers.Select(strData);
|
||||
|
||||
//DISCONTINUED
|
||||
rs->FetchField("discontinued",&bData);
|
||||
m_ckDiscontinued.SetCheck(bData ? TRUE : FALSE);
|
||||
m_dtDiscontinued.ShowWindow(bData ? TRUE : FALSE);
|
||||
if(m_bReadOnly)
|
||||
m_dtDiscontinued.EnableWindow(FALSE);
|
||||
//DISCONTINUED DATE (IF APPLICABLE)
|
||||
if(bData)
|
||||
{
|
||||
rs->FetchField("discodate",&dtData);
|
||||
m_dtDiscontinued.SetTime(dtData);
|
||||
|
||||
}
|
||||
|
||||
//INTRODUCED DATE
|
||||
rs->FetchField("introduced",&dtData);
|
||||
m_dtIntroduced.SetTime(dtData);
|
||||
|
||||
//NOTES
|
||||
rs->FetchField("notes",&strData);
|
||||
m_edNotes.SetWindowText(strData);
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//************************************************************
|
||||
//SAVE EDIT CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CModelsDlg::SaveField(CEdit *edControl,CString fldname,bool AllowEmpty)
|
||||
{
|
||||
|
||||
if(m_bAddMode || m_bNoRecords) return true;//dont attempt to update
|
||||
CString str;
|
||||
//do nothing if not changed
|
||||
if(edControl->GetModify()!=TRUE) return true;
|
||||
|
||||
edControl->GetWindowText(str);
|
||||
//dont save empty fields if not allowed to
|
||||
if(!AllowEmpty)
|
||||
{
|
||||
|
||||
if(str.IsEmpty())
|
||||
{
|
||||
edControl->Undo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rs->UpdateField(fldname,&str);
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
//************************************************************
|
||||
//SAVE GZCOMBO CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CModelsDlg::SaveField(CgzCombo *cbControl,CString fldname)
|
||||
{
|
||||
|
||||
if(m_bAddMode || m_bNoRecords) return true;//dont attempt to update
|
||||
CString str;
|
||||
long lData;
|
||||
str=cbControl->GetCurrentRowID();
|
||||
if(str.IsEmpty()) return false;//shouldn't happen but...
|
||||
lData=atol(str);
|
||||
rs->UpdateField(fldname,&lData);
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
//************************************************************
|
||||
//SAVE CheckBox CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CModelsDlg::SaveField(CButton *ckControl,CString fldname)
|
||||
{
|
||||
if(m_bAddMode || m_bNoRecords) return true;//dont attempt to update
|
||||
bool bData=false;
|
||||
BOOL BData;
|
||||
BData=ckControl->GetCheck();
|
||||
if(BData==TRUE) bData=true;
|
||||
rs->UpdateField(fldname,&bData);
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
return true;
|
||||
}
|
||||
//************************************************************
|
||||
//SAVE DateTimePicker CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CModelsDlg::SaveField(CDateTimeCtrl *dtControl,CString fldname)
|
||||
{
|
||||
if(m_bAddMode || m_bNoRecords) return true;//dont attempt to update
|
||||
COleDateTime dtData;
|
||||
dtControl->GetTime(dtData);
|
||||
rs->UpdateField(fldname,&dtData);
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//************************************************
|
||||
//UPDATE MODIFIED DATA
|
||||
//*************************************************
|
||||
bool CModelsDlg::UpdateModified()
|
||||
{
|
||||
|
||||
//updates modified by and modified on fields
|
||||
rs->UpdateField("modifier",&m_pApp->m_lusrID);
|
||||
COleDateTime dtData;
|
||||
dtData=COleDateTime::GetCurrentTime();
|
||||
rs->UpdateField("modified",&dtData);
|
||||
rs->SaveRecord();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void CModelsDlg::OnBtnpm()
|
||||
{
|
||||
|
||||
if(m_bNoRecords || m_strSelectedModel.IsEmpty() || m_strSelectedModel=="0") return;
|
||||
|
||||
|
||||
//Open the PM dialog for this model
|
||||
CPM d;
|
||||
CString prompt;
|
||||
CString str;
|
||||
str=m_cbModels.GetCurrentRowText();//m_edModel.GetWindowText(str);
|
||||
prompt="Preventive maintenance for Model#: " + str;
|
||||
|
||||
//set criteria serial number
|
||||
d.PreInitialize(false,true,m_strSelectedModel,prompt);
|
||||
d.DoModal();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CModelsDlg::EnableFields(bool bEnable)
|
||||
{
|
||||
if(m_bReadOnly)
|
||||
return;
|
||||
BOOL enable = bEnable ? TRUE : FALSE;
|
||||
m_btnDelete.EnableWindow(enable);
|
||||
m_btnPM.EnableWindow(enable);
|
||||
m_cbCategories.EnableWindow(enable);
|
||||
m_cbManufacturers.EnableWindow(enable);
|
||||
m_cbModels.EnableWindow(enable);
|
||||
m_ckActive.EnableWindow(enable);
|
||||
m_ckDiscontinued.EnableWindow(enable);
|
||||
m_ckLifetime.EnableWindow(enable);
|
||||
m_dtDiscontinued.EnableWindow(enable);
|
||||
m_dtIntroduced.EnableWindow(enable);
|
||||
m_edModel.EnableWindow(enable);
|
||||
m_edNotes.EnableWindow(enable);
|
||||
m_lblCategory.EnableWindow(enable);
|
||||
m_lblManufacturer.EnableWindow(enable);
|
||||
m_lblModels.EnableWindow(enable);
|
||||
m_edWarrantyMonths.EnableWindow(enable);
|
||||
m_edWarrantyTerms.EnableWindow(enable);
|
||||
m_edDescription.EnableWindow(enable);
|
||||
|
||||
}
|
||||
|
||||
void CModelsDlg::OnKillfocusEddescription()
|
||||
{
|
||||
SaveField(&m_edDescription,"description",true);
|
||||
if(!m_bAddMode)
|
||||
FillModelList();
|
||||
}
|
||||
|
||||
void CModelsDlg::OnLblbymodel()
|
||||
{
|
||||
m_bListByDescription=false;
|
||||
FillModelList();
|
||||
}
|
||||
|
||||
void CModelsDlg::OnLblbydesc()
|
||||
{
|
||||
m_bListByDescription=true;
|
||||
FillModelList();
|
||||
}
|
||||
|
||||
void CModelsDlg::Security()
|
||||
{
|
||||
m_bReadOnly=false;
|
||||
int x=m_pApp->Allowed(RMODELS,true);
|
||||
if(x==0)//no access allowed
|
||||
{
|
||||
m_pApp->SecurityWarning();
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
if(x==2)//read only
|
||||
{
|
||||
m_bReadOnly=true;
|
||||
m_btnAdd.ShowWindow(FALSE);
|
||||
m_btnDelete.ShowWindow(FALSE);
|
||||
m_cbCategories.EnableWindow(FALSE);
|
||||
m_cbManufacturers.EnableWindow(FALSE);
|
||||
//m_cbModels.EnableWindow(FALSE);
|
||||
m_ckActive.EnableWindow(FALSE);
|
||||
m_ckDiscontinued.EnableWindow(FALSE);
|
||||
m_ckLifetime.EnableWindow(FALSE);
|
||||
m_dtDiscontinued.EnableWindow(FALSE);
|
||||
m_dtIntroduced.EnableWindow(FALSE);
|
||||
m_edDescription.SetReadOnly(TRUE);
|
||||
m_edModel.SetReadOnly(TRUE);
|
||||
m_edWarrantyTerms.SetReadOnly(TRUE);
|
||||
m_edWarrantyMonths.SetReadOnly(TRUE);
|
||||
m_lblCategory.EnableWindow(FALSE);
|
||||
m_lblManufacturer.EnableWindow(FALSE);
|
||||
|
||||
m_lblModels.EnableWindow(FALSE);
|
||||
m_edNotes.SetReadOnly(TRUE);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
#if !defined(AFX_MODELSDLG_H__19D53F21_27FA_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_MODELSDLG_H__19D53F21_27FA_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// ModelsDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CModelsDlg dialog
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
#include "label.h"
|
||||
//#include "statusdlg.h"
|
||||
class CModelsDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
bool m_bReadOnly;
|
||||
void Security();
|
||||
bool m_bListByDescription;
|
||||
void EnableFields(bool bEnable);
|
||||
bool m_bNoRecords;
|
||||
~CModelsDlg();
|
||||
bool m_bAddMode;
|
||||
void FillFields();
|
||||
CString m_strSelectedModel;
|
||||
void FillManufacturerList();
|
||||
void FillModelList();
|
||||
void FillCategoryList();
|
||||
void SetReturnString(CString *strReturn);
|
||||
//Save fields
|
||||
bool SaveField(CEdit* edControl,CString fldname,bool AllowEmpty);
|
||||
bool SaveField(CgzCombo* cbControl,CString fldname);
|
||||
bool SaveField(CButton* ckControl,CString fldname);
|
||||
bool SaveField(CDateTimeCtrl* dtControl,CString fldname);
|
||||
bool UpdateModified();
|
||||
//-------------------------------
|
||||
CModelsDlg(CWnd* pParent = NULL); // standard constructor
|
||||
CSpApp* m_pApp;
|
||||
|
||||
//The Extra recordset is for filling combo boxes
|
||||
GZRset* rs;
|
||||
GZRset* cbrs;
|
||||
CString * m_pstrReturnValue;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CModelsDlg)
|
||||
enum { IDD = IDD_MODELS };
|
||||
CLabel m_lblByDesc;
|
||||
CLabel m_lblByModel;
|
||||
CEdit m_edDescription;
|
||||
CButton m_btnPM;
|
||||
CStatic m_lblModels;
|
||||
CLabel m_lblManufacturer;
|
||||
CLabel m_lblCategory;
|
||||
CEdit m_edWarrantyTerms;
|
||||
CEdit m_edWarrantyMonths;
|
||||
CEdit m_edNotes;
|
||||
CEdit m_edModel;
|
||||
CDateTimeCtrl m_dtIntroduced;
|
||||
CDateTimeCtrl m_dtDiscontinued;
|
||||
CButton m_ckLifetime;
|
||||
CButton m_ckDiscontinued;
|
||||
CButton m_ckActive;
|
||||
CgzCombo m_cbModels;
|
||||
CgzCombo m_cbManufacturers;
|
||||
CgzCombo m_cbCategories;
|
||||
CButton m_btnDone;
|
||||
CButton m_btnDelete;
|
||||
CButton m_btnAdd;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CModelsDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CModelsDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBtnadd();
|
||||
afx_msg void OnBtndelete();
|
||||
afx_msg void OnBtndone();
|
||||
afx_msg void OnCloseupCbcategories();
|
||||
afx_msg void OnCloseupCbmanufacturers();
|
||||
afx_msg void OnCloseupCbmodels();
|
||||
afx_msg void OnCkdiscontinued();
|
||||
afx_msg void OnCklifetime();
|
||||
afx_msg void OnDatetimechangeDtdiscontinued(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnDatetimechangeDtintroduced(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnKillfocusEdmodel();
|
||||
afx_msg void OnKillfocusEdnotes();
|
||||
afx_msg void OnKillfocusEdwarrantymonths();
|
||||
afx_msg void OnKillfocusEdwarrantyterms();
|
||||
afx_msg void OnLblcategory();
|
||||
afx_msg void OnLblmanufacturer();
|
||||
afx_msg void OnBtnpm();
|
||||
afx_msg void OnKillfocusEddescription();
|
||||
afx_msg void OnLblbymodel();
|
||||
afx_msg void OnLblbydesc();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_MODELSDLG_H__19D53F21_27FA_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,135 @@
|
||||
////////////////////////////////////////////////////////////////
|
||||
// 1998 Microsoft Systems Journal
|
||||
// If this code works, it was written by Paul DiLascia.
|
||||
// If not, I don't know who wrote it.
|
||||
//
|
||||
// CModuleVersion provides an easy way to get version info
|
||||
// for a module.(DLL or EXE).
|
||||
//
|
||||
#include "StdAfx.h"
|
||||
#include "ModulVer.h"
|
||||
|
||||
CModuleVersion::CModuleVersion()
|
||||
{
|
||||
m_pVersionInfo = NULL; // raw version info data
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Destroy: delete version info
|
||||
//
|
||||
CModuleVersion::~CModuleVersion()
|
||||
{
|
||||
delete [] m_pVersionInfo;
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Get file version info for a given module
|
||||
// Allocates storage for all info, fills "this" with
|
||||
// VS_FIXEDFILEINFO, and sets codepage.
|
||||
//
|
||||
BOOL CModuleVersion::GetFileVersionInfo(LPCTSTR modulename)
|
||||
{
|
||||
m_translation.charset = 1252; // default = ANSI code page
|
||||
memset((VS_FIXEDFILEINFO*)this, 0, sizeof(VS_FIXEDFILEINFO));
|
||||
|
||||
// get module handle
|
||||
TCHAR filename[_MAX_PATH];
|
||||
HMODULE hModule = ::GetModuleHandle(modulename);
|
||||
if (hModule==NULL && modulename!=NULL)
|
||||
return FALSE;
|
||||
|
||||
// get module file name
|
||||
DWORD len = GetModuleFileName(hModule, filename,
|
||||
sizeof(filename)/sizeof(filename[0]));
|
||||
if (len <= 0)
|
||||
return FALSE;
|
||||
|
||||
// read file version info
|
||||
DWORD dwDummyHandle; // will always be set to zero
|
||||
len = GetFileVersionInfoSize(filename, &dwDummyHandle);
|
||||
if (len <= 0)
|
||||
return FALSE;
|
||||
|
||||
m_pVersionInfo = new BYTE[len]; // allocate version info
|
||||
if (!::GetFileVersionInfo(filename, 0, len, m_pVersionInfo))
|
||||
return FALSE;
|
||||
|
||||
LPVOID lpvi;
|
||||
UINT iLen;
|
||||
if (!VerQueryValue(m_pVersionInfo, _T("\\"), &lpvi, &iLen))
|
||||
return FALSE;
|
||||
|
||||
// copy fixed info to myself, which am derived from VS_FIXEDFILEINFO
|
||||
*(VS_FIXEDFILEINFO*)this = *(VS_FIXEDFILEINFO*)lpvi;
|
||||
|
||||
// Get translation info
|
||||
if (VerQueryValue(m_pVersionInfo,
|
||||
"\\VarFileInfo\\Translation", &lpvi, &iLen) && iLen >= 4) {
|
||||
m_translation = *(TRANSLATION*)lpvi;
|
||||
TRACE("code page = %d\n", m_translation.charset);
|
||||
}
|
||||
|
||||
return dwSignature == VS_FFI_SIGNATURE;
|
||||
}
|
||||
|
||||
//////////////////
|
||||
// Get string file info.
|
||||
// Key name is something like "CompanyName".
|
||||
// returns the value as a CString.
|
||||
//
|
||||
CString CModuleVersion::GetValue(LPCTSTR lpKeyName)
|
||||
{
|
||||
CString sVal;
|
||||
if (m_pVersionInfo) {
|
||||
|
||||
// To get a string value must pass query in the form
|
||||
//
|
||||
// "\StringFileInfo\<langID><codepage>\keyname"
|
||||
//
|
||||
// where <lang-codepage> is the languageID concatenated with the
|
||||
// code page, in hex. Wow.
|
||||
//
|
||||
CString query;
|
||||
query.Format(_T("\\StringFileInfo\\%04x%04x\\%s"),
|
||||
m_translation.langID,
|
||||
m_translation.charset,
|
||||
lpKeyName);
|
||||
|
||||
LPCTSTR pVal;
|
||||
UINT iLenVal;
|
||||
if (VerQueryValue(m_pVersionInfo, (LPTSTR)(LPCTSTR)query,
|
||||
(LPVOID*)&pVal, &iLenVal)) {
|
||||
|
||||
sVal = pVal;
|
||||
}
|
||||
}
|
||||
return sVal;
|
||||
}
|
||||
|
||||
// typedef for DllGetVersion proc
|
||||
typedef HRESULT (CALLBACK* DLLGETVERSIONPROC)(DLLVERSIONINFO *);
|
||||
|
||||
/////////////////
|
||||
// Get DLL Version by calling DLL's DllGetVersion proc
|
||||
//
|
||||
BOOL CModuleVersion::DllGetVersion(LPCTSTR modulename, DLLVERSIONINFO& dvi)
|
||||
{
|
||||
HINSTANCE hinst = LoadLibrary(modulename);
|
||||
if (!hinst)
|
||||
return FALSE;
|
||||
|
||||
// Must use GetProcAddress because the DLL might not implement
|
||||
// DllGetVersion. Depending upon the DLL, the lack of implementation of the
|
||||
// function may be a version marker in itself.
|
||||
//
|
||||
DLLGETVERSIONPROC pDllGetVersion =
|
||||
(DLLGETVERSIONPROC)GetProcAddress(hinst, _T("DllGetVersion"));
|
||||
|
||||
if (!pDllGetVersion)
|
||||
return FALSE;
|
||||
|
||||
memset(&dvi, 0, sizeof(dvi)); // clear
|
||||
dvi.cbSize = sizeof(dvi); // set size for Windows
|
||||
|
||||
return SUCCEEDED((*pDllGetVersion)(&dvi));
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
////////////////////////////////////////////////////////////////
|
||||
// 1998 Microsoft Systems Journal
|
||||
//
|
||||
// If this code works, it was written by Paul DiLascia.
|
||||
// If not, I don't know who wrote it.
|
||||
//
|
||||
#ifndef __MODULEVER_H
|
||||
#define __MODULEVER_H
|
||||
|
||||
// tell linker to link with version.lib for VerQueryValue, etc.
|
||||
#pragma comment(linker, "/defaultlib:version.lib")
|
||||
|
||||
#ifndef DLLVERSIONINFO
|
||||
// following is from shlwapi.h, in November 1997 release of the Windows SDK
|
||||
|
||||
typedef struct _DllVersionInfo
|
||||
{
|
||||
DWORD cbSize;
|
||||
DWORD dwMajorVersion; // Major version
|
||||
DWORD dwMinorVersion; // Minor version
|
||||
DWORD dwBuildNumber; // Build number
|
||||
DWORD dwPlatformID; // DLLVER_PLATFORM_*
|
||||
} DLLVERSIONINFO;
|
||||
|
||||
// Platform IDs for DLLVERSIONINFO
|
||||
#define DLLVER_PLATFORM_WINDOWS 0x00000001 // Windows 95
|
||||
#define DLLVER_PLATFORM_NT 0x00000002 // Windows NT
|
||||
|
||||
#endif // DLLVERSIONINFO
|
||||
|
||||
|
||||
|
||||
//////////////////
|
||||
// CModuleVersion version info about a module.
|
||||
// To use:
|
||||
//
|
||||
// CModuleVersion ver
|
||||
// if (ver.GetFileVersionInfo("_T("mymodule))) {
|
||||
// // info is in ver, you can call GetValue to get variable info like
|
||||
// CString s = ver.GetValue(_T("CompanyName"));
|
||||
// }
|
||||
//
|
||||
// You can also call the static fn DllGetVersion to get DLLVERSIONINFO.
|
||||
//
|
||||
class CModuleVersion : public VS_FIXEDFILEINFO {
|
||||
protected:
|
||||
BYTE* m_pVersionInfo; // all version info
|
||||
|
||||
struct TRANSLATION {
|
||||
WORD langID; // language ID
|
||||
WORD charset; // character set (code page)
|
||||
} m_translation;
|
||||
|
||||
public:
|
||||
CModuleVersion();
|
||||
virtual ~CModuleVersion();
|
||||
|
||||
BOOL GetFileVersionInfo(LPCTSTR modulename);
|
||||
CString GetValue(LPCTSTR lpKeyName);
|
||||
static BOOL DllGetVersion(LPCTSTR modulename, DLLVERSIONINFO& dvi);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,677 @@
|
||||
// NonClientsDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "NonClientsDlg.h"
|
||||
#include "StatusDlg.h"
|
||||
#include ".\nonclientsdlg.h"
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CNonClientsDlg dialog
|
||||
|
||||
|
||||
CNonClientsDlg::CNonClientsDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CNonClientsDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CNonClientsDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
m_pstrReturnValue=NULL;
|
||||
m_strSelectedContact.Empty();
|
||||
m_lListType=0;//not specified
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
/*
|
||||
rs=new GZRset("Non-client entry screen");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
*/
|
||||
//Initialize recordset pointer
|
||||
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CNonClientsDlg");
|
||||
//v1.9.4.4
|
||||
rs2=m_pApp->rsPool->GetRS("CNonClientsDlgRS2");
|
||||
}
|
||||
|
||||
|
||||
//destructor added by me later!
|
||||
CNonClientsDlg::~CNonClientsDlg()
|
||||
{
|
||||
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
//v1.9.4.4
|
||||
m_pApp->rsPool->ReleaseRS(&rs2->m_nID);
|
||||
}
|
||||
|
||||
void CNonClientsDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CNonClientsDlg)
|
||||
DDX_Control(pDX, IDC_EDACCT, m_edAccount);
|
||||
DDX_Control(pDX, IDC_DONE, m_btnDone);
|
||||
DDX_Control(pDX, IDC_HISTORY, m_lblHistory);
|
||||
DDX_Control(pDX, IDC_LBLLIST, m_lblList);
|
||||
DDX_Control(pDX, IDC_LBLWEBSITE, m_lblWebsite);
|
||||
DDX_Control(pDX, IDC_LBLEMAIL, m_lblEmail);
|
||||
DDX_Control(pDX, IDC_WEBSITE, m_edWebsite);
|
||||
DDX_Control(pDX, IDC_PHONE, m_edPhone);
|
||||
DDX_Control(pDX, IDC_NOTES, m_edNotes);
|
||||
DDX_Control(pDX, IDC_LIST, m_cbList);
|
||||
DDX_Control(pDX, IDC_FAX, m_edFax);
|
||||
DDX_Control(pDX, IDC_EMAIL, m_edEmail);
|
||||
DDX_Control(pDX, IDC_DELETE, m_btnDelete);
|
||||
DDX_Control(pDX, IDC_CONTACT, m_edContact);
|
||||
DDX_Control(pDX, IDC_COMPNAME, m_edCompName);
|
||||
DDX_Control(pDX, IDC_ADDRESS, m_edAddress);
|
||||
DDX_Control(pDX, IDC_ADD, m_btnAdd);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CNonClientsDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CNonClientsDlg)
|
||||
ON_CBN_CLOSEUP(IDC_LIST, OnCloseupList)
|
||||
ON_BN_CLICKED(IDC_ADD, OnAdd)
|
||||
ON_EN_KILLFOCUS(IDC_ADDRESS, OnKillfocusAddress)
|
||||
ON_EN_KILLFOCUS(IDC_COMPNAME, OnKillfocusCompname)
|
||||
ON_EN_KILLFOCUS(IDC_CONTACT, OnKillfocusContact)
|
||||
ON_BN_CLICKED(IDC_DELETE, OnDelete)
|
||||
ON_EN_KILLFOCUS(IDC_EMAIL, OnKillfocusEmail)
|
||||
ON_EN_KILLFOCUS(IDC_FAX, OnKillfocusFax)
|
||||
ON_EN_KILLFOCUS(IDC_NOTES, OnKillfocusNotes)
|
||||
ON_EN_KILLFOCUS(IDC_PHONE, OnKillfocusPhone)
|
||||
ON_EN_KILLFOCUS(IDC_WEBSITE, OnKillfocusWebsite)
|
||||
ON_BN_CLICKED(IDC_LBLEMAIL, OnLblemail)
|
||||
ON_BN_CLICKED(IDC_LBLWEBSITE, OnLblwebsite)
|
||||
ON_BN_CLICKED(IDC_DONE, OnDone)
|
||||
ON_BN_CLICKED(IDOK, OnOk)
|
||||
ON_BN_CLICKED(IDC_HISTORY, OnHistory)
|
||||
ON_EN_KILLFOCUS(IDC_EDACCT, OnKillfocusEdacct)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CNonClientsDlg message handlers
|
||||
|
||||
BOOL CNonClientsDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
Security();
|
||||
ASSERT(m_lListType!=0);//wasn't set
|
||||
|
||||
//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("");
|
||||
|
||||
//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("");
|
||||
|
||||
//make a HISTORY "hyperlink"
|
||||
m_lblHistory.SetTextColor(RGB(0,0,255));
|
||||
m_lblHistory.SetFontUnderline(TRUE);
|
||||
m_lblHistory.SetLink(TRUE);
|
||||
m_lblHistory.SetLinkCursor(m_pApp->hcHand);
|
||||
m_lblHistory.SetLinkURL("");
|
||||
|
||||
FillList();
|
||||
|
||||
m_bAddMode=false;
|
||||
//looks wierd, but may be ok if more fields
|
||||
//added later so left in for that reason
|
||||
//ShowWindow(SW_SHOWMAXIMIZED);
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//************************************************************
|
||||
//SAVE EDIT CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CNonClientsDlg::SaveField(CEdit *edControl,CString fldname,bool AllowEmpty)
|
||||
{
|
||||
|
||||
if(m_bAddMode) return true;//dont attempt to update
|
||||
CString str;
|
||||
//do nothing if not changed
|
||||
if(edControl->GetModify()!=TRUE) return true;
|
||||
|
||||
edControl->GetWindowText(str);
|
||||
//dont save empty fields if not allowed to
|
||||
if(!AllowEmpty)
|
||||
{
|
||||
|
||||
if(str.IsEmpty())
|
||||
{
|
||||
edControl->Undo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rs->UpdateField(fldname,&str);
|
||||
rs->SaveRecord();
|
||||
UpdateModified(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//************************************************
|
||||
//UPDATE MODIFIED DATA
|
||||
//*************************************************
|
||||
bool CNonClientsDlg::UpdateModified(bool IsNew)
|
||||
{
|
||||
COleDateTime dtData;
|
||||
//updates modified by and modified on fields
|
||||
if(IsNew)//update creator and created as well
|
||||
{
|
||||
rs->UpdateField("creator",&m_pApp->m_lusrID);
|
||||
|
||||
dtData=COleDateTime::GetCurrentTime();
|
||||
rs->UpdateField("created",&dtData);
|
||||
}
|
||||
|
||||
rs->UpdateField("modifier",&m_pApp->m_lusrID);
|
||||
|
||||
dtData=COleDateTime::GetCurrentTime();
|
||||
rs->UpdateField("modified",&dtData);
|
||||
if(!rs->SaveRecord()) return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CNonClientsDlg::FillList()
|
||||
{
|
||||
|
||||
CString strData;
|
||||
CString strIndex;
|
||||
CString q;
|
||||
long lData;
|
||||
m_cbList.Clear();
|
||||
|
||||
q.Format("SELECT nonclients.*, nonclienttypes.description AS LISTNAME "
|
||||
"FROM nonclients LEFT JOIN nonclienttypes ON "
|
||||
"nonclients.type = nonclienttypes.id "
|
||||
"WHERE (((nonclients.type)=%u)) "
|
||||
"ORDER BY nonclients.company_person;",m_lListType);
|
||||
|
||||
|
||||
rs->Query(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
//fill combo box with available zones
|
||||
rs->MoveFirst();
|
||||
rs->FetchField("LISTNAME",&strData);
|
||||
SetWindowText(strData);
|
||||
|
||||
rs->FetchField("company_person",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbList.AddRow(strData,strIndex);
|
||||
|
||||
while(rs->MoveForward())
|
||||
{
|
||||
rs->FetchField("company_person",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbList.AddRow(strData,strIndex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//pretend user has selected so that other fields get filled in
|
||||
if(m_strSelectedContact.IsEmpty()) //first time in
|
||||
{
|
||||
m_cbList.SetCurSel(0);
|
||||
}
|
||||
else//something valid was selected before so stick with it
|
||||
m_cbList.Select(m_strSelectedContact);
|
||||
|
||||
OnCloseupList();
|
||||
}
|
||||
else
|
||||
DisableAll(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//*************************************************
|
||||
void CNonClientsDlg::SetType(long *pType)
|
||||
{
|
||||
m_lListType=*pType;
|
||||
}
|
||||
|
||||
|
||||
//*****************************
|
||||
void CNonClientsDlg::OnCloseupList()
|
||||
{
|
||||
//Fill the fields as this is a simple dialog.
|
||||
//user has made a selection, update the visible list
|
||||
CString q;
|
||||
CString strData;
|
||||
strData=m_cbList.GetCurrentRowID();
|
||||
if(strData.IsEmpty())
|
||||
return;
|
||||
q.Format("SELECT nonclients.* FROM nonclients "
|
||||
"WHERE (((nonclients.id)=%s));",m_cbList.GetCurrentRowID());
|
||||
rs->Query(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
//COMPANY_PERSON
|
||||
rs->FetchField("company_person",&strData);
|
||||
m_edCompName.SetWindowText(strData);
|
||||
|
||||
//CONTACT
|
||||
rs->FetchField("contact",&strData);
|
||||
m_edContact.SetWindowText(strData);
|
||||
|
||||
//ADDRESS
|
||||
rs->FetchField("address",&strData);
|
||||
m_edAddress.SetWindowText(strData);
|
||||
|
||||
//PHONE
|
||||
rs->FetchField("phone",&strData);
|
||||
m_edPhone.SetWindowText(strData);
|
||||
|
||||
//FAX
|
||||
rs->FetchField("fax",&strData);
|
||||
m_edFax.SetWindowText(strData);
|
||||
|
||||
//EMAIL
|
||||
rs->FetchField("email",&strData);
|
||||
m_edEmail.SetWindowText(strData);
|
||||
|
||||
//WEBSITE
|
||||
rs->FetchField("website",&strData);
|
||||
m_edWebsite.SetWindowText(strData);
|
||||
|
||||
//ACCOUNT
|
||||
rs->FetchField("account",&strData);
|
||||
m_edAccount.SetWindowText(strData);
|
||||
|
||||
//NOTES
|
||||
rs->FetchField("notes",&strData);
|
||||
m_edNotes.SetWindowText(strData);
|
||||
|
||||
|
||||
}
|
||||
//save current selection so that updates and changes
|
||||
//will still show what was last selected
|
||||
m_strSelectedContact=m_cbList.GetCurrentRowID();
|
||||
}
|
||||
|
||||
//************************************
|
||||
//ADD NEW / SAVE
|
||||
//************************************
|
||||
void CNonClientsDlg::OnAdd()
|
||||
{
|
||||
CString strData;
|
||||
|
||||
if(!m_bAddMode)
|
||||
{//go to add mode
|
||||
DisableAll(false);
|
||||
m_bAddMode=true;
|
||||
m_btnDone.ShowWindow(FALSE);
|
||||
m_btnAdd.SetWindowText("Save");
|
||||
m_btnDelete.SetWindowText("Cancel");
|
||||
m_lblList.ShowWindow(FALSE);
|
||||
m_cbList.ShowWindow(FALSE);
|
||||
m_edAddress.SetWindowText("");
|
||||
m_edCompName.SetWindowText("");
|
||||
m_edContact.SetWindowText("");
|
||||
m_edEmail.SetWindowText("");
|
||||
m_edFax.SetWindowText("");
|
||||
m_edNotes.SetWindowText("");
|
||||
m_edPhone.SetWindowText("");
|
||||
m_edWebsite.SetWindowText("");
|
||||
m_edAccount.SetWindowText("");
|
||||
|
||||
|
||||
}
|
||||
else//save and exit add mode
|
||||
{
|
||||
m_edCompName.GetWindowText(strData);
|
||||
if(strData.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("Company or Name is required.");
|
||||
m_edCompName.Undo();
|
||||
m_edCompName.SetFocus();
|
||||
return;
|
||||
}
|
||||
if(IsDupeCompany(strData))
|
||||
{
|
||||
CString st;
|
||||
st.Format(
|
||||
"The company name \"%s\" has already been entered\r\n"
|
||||
"as a non-client contact and can not be used again.",strData);
|
||||
AfxMessageBox(st);
|
||||
m_edCompName.Undo();
|
||||
m_edCompName.SetFocus();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//add the record
|
||||
if(rs->AddNewRecord())
|
||||
{
|
||||
rs->UpdateField("type",&m_lListType);
|
||||
rs->UpdateField("company_person",&strData);
|
||||
|
||||
m_edAddress.GetWindowText(strData);
|
||||
rs->UpdateField("address",&strData);
|
||||
|
||||
m_edContact.GetWindowText(strData);
|
||||
rs->UpdateField("contact",&strData);
|
||||
|
||||
m_edEmail.GetWindowText(strData);
|
||||
rs->UpdateField("email",&strData);
|
||||
|
||||
m_edFax.GetWindowText(strData);
|
||||
rs->UpdateField("fax",&strData);
|
||||
|
||||
m_edNotes.GetWindowText(strData);
|
||||
rs->UpdateField("notes",&strData);
|
||||
|
||||
m_edPhone.GetWindowText(strData);
|
||||
rs->UpdateField("phone",&strData);
|
||||
|
||||
m_edWebsite.GetWindowText(strData);
|
||||
rs->UpdateField("website",&strData);
|
||||
|
||||
m_edAccount.GetWindowText(strData);
|
||||
rs->UpdateField("account",&strData);
|
||||
|
||||
|
||||
//this will save the record as well
|
||||
if(!UpdateModified(true))
|
||||
return;
|
||||
|
||||
m_bAddMode=false;
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_btnDelete.SetWindowText("Delete");
|
||||
m_lblList.ShowWindow(TRUE);
|
||||
m_cbList.ShowWindow(TRUE);
|
||||
FillList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//************************************
|
||||
//DELETE / CANCEL
|
||||
//************************************
|
||||
void CNonClientsDlg::OnDelete()
|
||||
{
|
||||
CString q,strID;
|
||||
|
||||
|
||||
if(m_bAddMode)//user pressed cancel button
|
||||
{
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
m_bAddMode=false;
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_btnDelete.SetWindowText("Delete");
|
||||
m_lblList.ShowWindow(TRUE);
|
||||
m_cbList.ShowWindow(TRUE);
|
||||
FillList();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//USER IS REQUESTING TO DELETE RECORD
|
||||
//check subrepairs to see if records exist
|
||||
strID=m_cbList.GetCurrentRowID();
|
||||
q.Format("SELECT subrepair.where "
|
||||
"FROM subrepair WHERE (((subrepair.where)=%s)) "
|
||||
"OR (((subrepair.sentvia)=%s));",strID,strID);
|
||||
rs->Query(q);
|
||||
if(!rs->IsEmpty())
|
||||
{
|
||||
AfxMessageBox("DATA INTEGRITY PROTECTION:\r\n"
|
||||
"You can't delete this record at this time.\r\n"
|
||||
"It is attached to one or more sub-contracted repair records.");
|
||||
return;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if(AfxMessageBox("Permanently delete?\r\nAre you sure?",MB_YESNO)==IDYES)
|
||||
{
|
||||
q.Format("DELETE nonclients.*, nonclients.id "
|
||||
"FROM nonclients WHERE (((nonclients.id)=%s));"
|
||||
,m_cbList.GetCurrentRowID());
|
||||
rs->Ex(q);
|
||||
//a deleted contact can't be selected
|
||||
m_strSelectedContact="";
|
||||
FillList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//**************************************
|
||||
//SAVE FIELDS
|
||||
//**************************************
|
||||
void CNonClientsDlg::OnKillfocusAddress()
|
||||
{SaveField(&m_edAddress,"address",true);}
|
||||
|
||||
void CNonClientsDlg::OnKillfocusCompname()
|
||||
{
|
||||
if(m_edCompName.GetModify()==FALSE) return;
|
||||
|
||||
CString strData;
|
||||
m_edCompName.GetWindowText(strData);
|
||||
if(strData.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("Company or Name is required, can't leave blank.");
|
||||
m_edCompName.Undo();
|
||||
m_edCompName.SetModify(FALSE);
|
||||
m_edCompName.SetFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
if(IsDupeCompany(strData))
|
||||
{
|
||||
CString st;
|
||||
st.Format(
|
||||
"The company name \"%s\" has already been entered\r\n"
|
||||
"as a non-client contact and can not be used again.",strData);
|
||||
AfxMessageBox(st);
|
||||
|
||||
m_edCompName.Undo();
|
||||
m_edCompName.SetModify(FALSE);
|
||||
m_edCompName.SetFocus();
|
||||
return;
|
||||
}
|
||||
|
||||
SaveField(&m_edCompName,"company_person",false);
|
||||
if(!m_bAddMode)
|
||||
FillList();
|
||||
}
|
||||
|
||||
void CNonClientsDlg::OnKillfocusContact()
|
||||
{SaveField(&m_edContact,"contact",true);}
|
||||
|
||||
void CNonClientsDlg::OnKillfocusEmail()
|
||||
{SaveField(&m_edEmail,"email",true);}
|
||||
|
||||
void CNonClientsDlg::OnKillfocusFax()
|
||||
{SaveField(&m_edFax,"fax",true);}
|
||||
|
||||
void CNonClientsDlg::OnKillfocusNotes()
|
||||
{SaveField(&m_edNotes,"notes",true);}
|
||||
|
||||
void CNonClientsDlg::OnKillfocusPhone()
|
||||
{SaveField(&m_edPhone,"phone",true);}
|
||||
|
||||
void CNonClientsDlg::OnKillfocusWebsite()
|
||||
{SaveField(&m_edWebsite,"website",true);}
|
||||
|
||||
void CNonClientsDlg::OnKillfocusEdacct()
|
||||
{SaveField(&m_edAccount,"account",true);}
|
||||
|
||||
|
||||
|
||||
//*****************************************
|
||||
void CNonClientsDlg::OnLblemail()
|
||||
{
|
||||
CString strURL;
|
||||
m_edEmail.GetWindowText(strURL);
|
||||
if(!strURL.IsEmpty())//do this only if there was an url
|
||||
{
|
||||
strURL="mailto:" + strURL;
|
||||
ShellExecute(NULL,"open",strURL,NULL,NULL,SW_SHOWNORMAL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*******************************************
|
||||
void CNonClientsDlg::OnLblwebsite()
|
||||
{
|
||||
CString strURL;
|
||||
m_edWebsite.GetWindowText(strURL);
|
||||
if(!strURL.IsEmpty())//do this only if there was an url
|
||||
{
|
||||
|
||||
ShellExecute(NULL,"open",strURL,NULL,NULL,SW_SHOWNORMAL);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CNonClientsDlg::OnDone()
|
||||
{
|
||||
|
||||
if(m_pstrReturnValue!=NULL)
|
||||
*m_pstrReturnValue=m_strSelectedContact;
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CNonClientsDlg::OnOk()
|
||||
{
|
||||
//do nothing
|
||||
}
|
||||
|
||||
void CNonClientsDlg::OnHistory()
|
||||
{
|
||||
|
||||
|
||||
|
||||
COleDateTime dtCreated,dtModified;
|
||||
CString modifier,creator;
|
||||
long m,c;
|
||||
//GET RECORD STATUS FIELDS
|
||||
rs->FetchField("created",&dtCreated);
|
||||
rs->FetchField("modified",&dtModified);
|
||||
|
||||
rs->FetchField("creator",&c);
|
||||
|
||||
rs->FetchField("modifier",&m);
|
||||
creator.Format("%u",c);
|
||||
modifier.Format("%u",m);
|
||||
|
||||
|
||||
CStatusDlg d;
|
||||
d.SetValues(&creator,&modifier,&dtCreated,&dtModified);
|
||||
d.DoModal();
|
||||
|
||||
}
|
||||
|
||||
void CNonClientsDlg::SetReturnString(CString* strReturn)
|
||||
{
|
||||
m_pstrReturnValue=strReturn;
|
||||
}
|
||||
|
||||
void CNonClientsDlg::DisableAll(bool disable)
|
||||
{
|
||||
BOOL e=disable ? FALSE : TRUE;
|
||||
m_btnDelete.EnableWindow(e);
|
||||
m_cbList.EnableWindow(e);
|
||||
m_edAddress.EnableWindow(e);
|
||||
m_edCompName.EnableWindow(e);
|
||||
m_edContact.EnableWindow(e);
|
||||
m_edEmail.EnableWindow(e);
|
||||
m_edFax.EnableWindow(e);
|
||||
m_edNotes.EnableWindow(e);
|
||||
m_edPhone.EnableWindow(e);
|
||||
m_edWebsite.EnableWindow(e);
|
||||
m_edAccount.EnableWindow(e);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CNonClientsDlg::Security()
|
||||
{
|
||||
|
||||
//m_bReadOnly=false;
|
||||
int x=m_pApp->Allowed(RNONCLIENTS,true);
|
||||
if(x==0)//no access allowed
|
||||
{
|
||||
m_pApp->SecurityWarning();
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
if(x==2)//read only
|
||||
{
|
||||
// m_bReadOnly=true;
|
||||
m_btnAdd.ShowWindow(FALSE);
|
||||
m_btnDelete.ShowWindow(FALSE);
|
||||
m_edAddress.SetReadOnly(TRUE);
|
||||
m_edCompName.SetReadOnly(TRUE);
|
||||
m_edContact.SetReadOnly(TRUE);
|
||||
m_edEmail.SetReadOnly(TRUE);
|
||||
m_edFax.SetReadOnly(TRUE);
|
||||
m_edNotes.SetReadOnly(TRUE);
|
||||
m_edPhone.SetReadOnly(TRUE);
|
||||
m_edWebsite.SetReadOnly(TRUE);
|
||||
m_edAccount.SetReadOnly(TRUE);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// v 1.9.4.4 addition - returns true if the company name entered already exists in the table
|
||||
bool CNonClientsDlg::IsDupeCompany(CString strNewCompanyName)
|
||||
{
|
||||
CString q;
|
||||
bool bIsDupe=false;
|
||||
q.Format("SELECT nonclients.company_person FROM nonclients WHERE "
|
||||
"(((nonclients.company_person)=\"%s\"));",strNewCompanyName);
|
||||
rs2->QueryReadOnly(q);
|
||||
if(!rs2->IsEmpty())
|
||||
bIsDupe=true;
|
||||
|
||||
rs2->Close();
|
||||
|
||||
return bIsDupe;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
#if !defined(AFX_NONCLIENTSDLG_H__12A88141_2588_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_NONCLIENTSDLG_H__12A88141_2588_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// NonClientsDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CNonClientsDlg dialog
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
#include "label.h"
|
||||
|
||||
class CNonClientsDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
void Security();
|
||||
void DisableAll(bool disable);
|
||||
void SetReturnString(CString* strReturn);
|
||||
CString m_strSelectedContact;
|
||||
void SetType(long* pType);
|
||||
long m_lListType;
|
||||
void FillList();
|
||||
CNonClientsDlg(CWnd* pParent = NULL); // standard constructor
|
||||
~CNonClientsDlg();
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
//v1.9.4.4 - added to confirm no dupes in company name before attempting to update
|
||||
GZRset* rs2;
|
||||
|
||||
CString * m_pstrReturnValue;
|
||||
bool m_bAddMode;
|
||||
//Save fields
|
||||
bool SaveField(CEdit* edControl,CString fldname,bool AllowEmpty);
|
||||
bool UpdateModified(bool IsNew);
|
||||
//-------------------------------
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CNonClientsDlg)
|
||||
enum { IDD = IDD_NONCLIENTS };
|
||||
CEdit m_edAccount;
|
||||
CButton m_btnDone;
|
||||
CLabel m_lblHistory;
|
||||
CStatic m_lblList;
|
||||
CLabel m_lblWebsite;
|
||||
CLabel m_lblEmail;
|
||||
CEdit m_edWebsite;
|
||||
CEdit m_edPhone;
|
||||
CEdit m_edNotes;
|
||||
CgzCombo m_cbList;
|
||||
CEdit m_edFax;
|
||||
CEdit m_edEmail;
|
||||
CButton m_btnDelete;
|
||||
CEdit m_edContact;
|
||||
CEdit m_edCompName;
|
||||
CEdit m_edAddress;
|
||||
CButton m_btnAdd;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CNonClientsDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CNonClientsDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnCloseupList();
|
||||
afx_msg void OnAdd();
|
||||
afx_msg void OnKillfocusAddress();
|
||||
afx_msg void OnKillfocusCompname();
|
||||
afx_msg void OnKillfocusContact();
|
||||
afx_msg void OnDelete();
|
||||
afx_msg void OnKillfocusEmail();
|
||||
afx_msg void OnKillfocusFax();
|
||||
afx_msg void OnKillfocusNotes();
|
||||
afx_msg void OnKillfocusPhone();
|
||||
afx_msg void OnKillfocusWebsite();
|
||||
afx_msg void OnLblemail();
|
||||
afx_msg void OnLblwebsite();
|
||||
afx_msg void OnDone();
|
||||
afx_msg void OnOk();
|
||||
afx_msg void OnHistory();
|
||||
afx_msg void OnKillfocusEdacct();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
public:
|
||||
// v 1.9.4.4 addition - returns true if the company name entered already exists in the table
|
||||
bool IsDupeCompany(CString strNewCompanyName);
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_NONCLIENTSDLG_H__12A88141_2588_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,72 @@
|
||||
// NullForm.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "NullForm.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CNullForm
|
||||
|
||||
IMPLEMENT_DYNCREATE(CNullForm, CFormView)
|
||||
|
||||
CNullForm::CNullForm()
|
||||
: CFormView(CNullForm::IDD)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CNullForm)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
CNullForm::~CNullForm()
|
||||
{
|
||||
}
|
||||
|
||||
void CNullForm::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CFormView::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CNullForm)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CNullForm, CFormView)
|
||||
//{{AFX_MSG_MAP(CNullForm)
|
||||
// NOTE - the ClassWizard will add and remove mapping macros here.
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CNullForm diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CNullForm::AssertValid() const
|
||||
{
|
||||
CFormView::AssertValid();
|
||||
}
|
||||
|
||||
void CNullForm::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CFormView::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CNullForm message handlers
|
||||
|
||||
void CNullForm::Activate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CNullForm::DeActivate()
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
#if !defined(AFX_NULLFORM_H__75C81BC1_5E20_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_NULLFORM_H__75C81BC1_5E20_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// NullForm.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CNullForm form view
|
||||
|
||||
#ifndef __AFXEXT_H__
|
||||
#include <afxext.h>
|
||||
#endif
|
||||
|
||||
class CNullForm : public CFormView
|
||||
{
|
||||
public:
|
||||
CNullForm(); // protected constructor used by dynamic creation
|
||||
DECLARE_DYNCREATE(CNullForm)
|
||||
|
||||
// Form Data
|
||||
public:
|
||||
//{{AFX_DATA(CNullForm)
|
||||
enum { IDD = IDD_NULLFORM_FORM };
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
// Attributes
|
||||
public:
|
||||
|
||||
// Operations
|
||||
public:
|
||||
void DeActivate();
|
||||
void Activate();
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CNullForm)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
virtual ~CNullForm();
|
||||
#ifdef _DEBUG
|
||||
virtual void AssertValid() const;
|
||||
virtual void Dump(CDumpContext& dc) const;
|
||||
#endif
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CNullForm)
|
||||
// NOTE - the ClassWizard will add and remove member functions here.
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_NULLFORM_H__75C81BC1_5E20_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
2275
archive/ayanova 1.9.4 CE final release db schema 171/sp/PM.cpp
Normal file
2275
archive/ayanova 1.9.4 CE final release db schema 171/sp/PM.cpp
Normal file
File diff suppressed because it is too large
Load Diff
184
archive/ayanova 1.9.4 CE final release db schema 171/sp/PM.h
Normal file
184
archive/ayanova 1.9.4 CE final release db schema 171/sp/PM.h
Normal file
@@ -0,0 +1,184 @@
|
||||
#if !defined(AFX_PM_H__BA63E282_9608_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_PM_H__BA63E282_9608_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// PM.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPM dialog
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
#include "gzlistbox.h"
|
||||
#include "label.h"
|
||||
#include "afxwin.h"
|
||||
#include "afxdtctl.h"
|
||||
|
||||
class CPM : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CString m_strPrompt;
|
||||
bool m_bQuick;
|
||||
CString m_strSelCategory;
|
||||
CString m_strSelProject;
|
||||
void FillTypeList();
|
||||
void FillProjectList();
|
||||
bool m_bModel;
|
||||
void UpdateMeterCount(bool bWriting);
|
||||
void Aging();
|
||||
COleDateTime m_dtUnitPurchasedDate;
|
||||
int m_nSeries;
|
||||
long m_lCurrentRecordID;
|
||||
void Schedule();
|
||||
void ScheduleClear();
|
||||
bool m_bEditing;
|
||||
bool m_bReschedule;
|
||||
void FillRequiredPartsList();
|
||||
CString m_strSelectedTech;
|
||||
void FillTechList();
|
||||
void ClearFields();
|
||||
void FillFields();
|
||||
CString m_strSelectedPM;
|
||||
void FillPMList();
|
||||
void FillPartsList();
|
||||
bool m_bNoRecord;
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
GZRset* cbrs;
|
||||
bool m_bAddMode;
|
||||
bool m_bAutoRepeat;
|
||||
bool m_bAutoWO;
|
||||
int m_nCurrentMode;
|
||||
void SwitchMode();
|
||||
bool m_bReadOnly;
|
||||
void EnableFields(bool bEnable);
|
||||
CString m_strCriteria;
|
||||
bool m_bClientMode;
|
||||
void PreInitialize(bool bClientMode, bool bModel, CString strCriteria, CString strPrompt, bool bResave=false);
|
||||
void GroupClick(int nClicked);
|
||||
~CPM();
|
||||
CPM(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CPM)
|
||||
enum { IDD = IDD_PM };
|
||||
CStatic m_lblSeries;
|
||||
CEdit m_edSeries;
|
||||
CStatic m_lblTime5;
|
||||
CStatic m_lblTime4;
|
||||
CEdit m_edTimeRepeatEveryWeeks;
|
||||
CEdit m_edTimeRepeatEveryDays;
|
||||
CgzCombo m_cbCategories;
|
||||
CLabel m_lblType;
|
||||
CLabel m_lblProject;
|
||||
CButton m_ckQuick;
|
||||
CButton m_ckOnsite;
|
||||
CgzCombo m_cbProjects;
|
||||
CButton m_btnEdit;
|
||||
CButton m_ckHold;
|
||||
CStatic m_lblQuant;
|
||||
CStatic m_lblPartsList;
|
||||
CLabel m_lblPart;
|
||||
CgzListBox m_lbParts;
|
||||
CEdit m_edPartQuantity;
|
||||
CButton m_btnRemovePart;
|
||||
CButton m_btnAddPart;
|
||||
CgzCombo m_cbParts;
|
||||
CButton m_rdTime;
|
||||
CButton m_rdMetric;
|
||||
CButton m_rdAge;
|
||||
CStatic m_lblTime3;
|
||||
CStatic m_lblTime2;
|
||||
CStatic m_lblTime1;
|
||||
CStatic m_lblTech;
|
||||
CStatic m_lblPMList;
|
||||
CStatic m_lblMeter4;
|
||||
CStatic m_lblMeter3;
|
||||
CStatic m_lblMeter2;
|
||||
CStatic m_lblMeter1;
|
||||
CStatic m_lblDayOfWeek;
|
||||
CStatic m_lblConvertMeter;
|
||||
CStatic m_lblConvertDays;
|
||||
CStatic m_lblAge5;
|
||||
CStatic m_lblAge4;
|
||||
CStatic m_lblAge3;
|
||||
CStatic m_lblAge2;
|
||||
CStatic m_lblAge1;
|
||||
CEdit m_edTimeRepeatEveryMonths;
|
||||
CEdit m_edNotes;
|
||||
CEdit m_edMeterRepeat;
|
||||
CEdit m_edMeterLastReading;
|
||||
CEdit m_edMeterFirstService;
|
||||
CEdit m_edDescription;
|
||||
CEdit m_edConvertToWoAfter;
|
||||
CEdit m_edAgeYears;
|
||||
CEdit m_edAgeRepeat;
|
||||
CEdit m_edAgeMonths;
|
||||
CDateTimeCtrl m_dtTimeNextServiceDate;
|
||||
CDateTimeCtrl m_dtAgeFirstServiceDate;
|
||||
CButton m_ckAutoWO;
|
||||
CButton m_ckAutoRepeat;
|
||||
CgzCombo m_cbTech;
|
||||
CgzCombo m_cbPMList;
|
||||
CComboBox m_cbDayOfWeek;
|
||||
CButton m_btnDone;
|
||||
CButton m_btnDelete;
|
||||
CButton m_btnClone;
|
||||
CButton m_btnAdd;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CPM)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CPM)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnRdage();
|
||||
afx_msg void OnRdmetric();
|
||||
afx_msg void OnRdtime();
|
||||
afx_msg void OnBtndone();
|
||||
afx_msg void OnCkautorepeat();
|
||||
afx_msg void OnCkautowo();
|
||||
afx_msg void OnBtnadd();
|
||||
afx_msg void OnCloseupCbpmlist();
|
||||
afx_msg void OnBtnaddpart();
|
||||
afx_msg void OnBtnremovepart();
|
||||
afx_msg void OnBtnedit();
|
||||
afx_msg void OnBtndelete();
|
||||
virtual void OnOK();
|
||||
afx_msg void OnKillfocusEdageyrs();
|
||||
afx_msg void OnKillfocusEdagemonths();
|
||||
afx_msg void OnKillfocusEdmeterlastreading();
|
||||
afx_msg void OnCkquick();
|
||||
afx_msg void OnLblpart();
|
||||
afx_msg void OnLblproject();
|
||||
afx_msg void OnLbltype();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
void Security();
|
||||
bool m_bReadOnlySecurity;
|
||||
public:
|
||||
CStatic m_lblStartTime;
|
||||
CStatic m_lblEndTime;
|
||||
CDateTimeCtrl m_dtStartTime;
|
||||
CDateTimeCtrl m_dtEndtime;
|
||||
// Used to force auto resaves when called from the client screen when a unit is selected as part of a model's PM
|
||||
bool m_bResave;
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_PM_H__BA63E282_9608_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,73 @@
|
||||
#if !defined(AFX_PMCHECKDLG_H__742E4B01_43CB_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_PMCHECKDLG_H__742E4B01_43CB_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// PMCheckDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPMCheckDlg dialog
|
||||
#include "ReportCtrl.h"
|
||||
#include "gzrset.h"
|
||||
#include "SimpleDate.h"
|
||||
#include "ResizeCtrl.h"
|
||||
class CPMCheckDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
CResizeCtrl m_resize;
|
||||
void MakeIntoWorkorder(CString strPMItem);
|
||||
CString m_strOrderBy;
|
||||
void FlipMeterDate();
|
||||
bool m_bShowDateFormat;
|
||||
void FillView();
|
||||
BOOL bColumnSortAsc[9];
|
||||
~CPMCheckDlg();
|
||||
CPMCheckDlg(CWnd* pParent = NULL); // standard constructor
|
||||
GZRset* rs;
|
||||
GZRset* rs2;
|
||||
GZRset* rs3;
|
||||
CSpApp* m_pApp;
|
||||
void OnRvnItemDbClick(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
void OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CPMCheckDlg)
|
||||
enum { IDD = IDD_PMCHECK };
|
||||
CReportCtrl m_rc;
|
||||
// NOTE: the ClassWizard will add data members here
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CPMCheckDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
CImageList m_ilReport;
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CPMCheckDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnPmviewDone();
|
||||
afx_msg void OnPmviewShowdateitems();
|
||||
afx_msg void OnPmviewShowmetered();
|
||||
afx_msg void OnPmviewSelecteditemConverttoworkorder();
|
||||
afx_msg void OnPmviewSelecteditemDelete();
|
||||
afx_msg void OnPmviewSelecteditemEdit();
|
||||
afx_msg void OnPmviewSelecteditemHoldrelease();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
bool m_bReadOnly;
|
||||
void Security();
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_PMCHECKDLG_H__742E4B01_43CB_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,952 @@
|
||||
// PMDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "PMDlg.h"
|
||||
#include "partsdlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPMDlg dialog
|
||||
|
||||
|
||||
CPMDlg::CPMDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CPMDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CPMDlg)
|
||||
//}}AFX_DATA_INIT
|
||||
m_bAddMode=false;
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
rs=new GZRset("Error: PM dialog");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
cbrs=new GZRset("Error: PM dialog combo box recordset\r\n");
|
||||
cbrs->SetConnect(m_pApp->strConnectString);
|
||||
m_strSelectedPM.Empty();
|
||||
m_strCriteria.Empty();
|
||||
m_bNoRecord=true;
|
||||
|
||||
}
|
||||
|
||||
//*********************************
|
||||
CPMDlg::~CPMDlg()
|
||||
{
|
||||
delete rs;
|
||||
delete cbrs;
|
||||
}
|
||||
|
||||
void CPMDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CPMDlg)
|
||||
DDX_Control(pDX, IDC_CKAUTOWO, m_ckAutoWO);
|
||||
DDX_Control(pDX, IDC_EDADVANCE, m_edAdvance);
|
||||
DDX_Control(pDX, IDC_LBLADVANCE, m_lblAdvance);
|
||||
DDX_Control(pDX, IDC_LBPARTSREQ, m_lbParts);
|
||||
DDX_Control(pDX, IDC_LBLQUANT, m_lblQuantity);
|
||||
DDX_Control(pDX, IDC_LBLPARTSLIST, m_lblPartsList);
|
||||
DDX_Control(pDX, IDC_CKREPEAT, m_ckRepeat);
|
||||
DDX_Control(pDX, IDC_LBLMETERMONTHS, m_lblMeterMonths);
|
||||
DDX_Control(pDX, IDC_CKONCEONLY, m_ckOnceOnly);
|
||||
DDX_Control(pDX, IDC_CKMETER, m_ckMeter);
|
||||
DDX_Control(pDX, IDC_CKAGE, m_ckAge);
|
||||
DDX_Control(pDX, IDC_EDQUANTITY, m_edQuantity);
|
||||
DDX_Control(pDX, IDC_BTNREMOVEPART, m_btnRemovePart);
|
||||
DDX_Control(pDX, IDC_LBLPMLIST, m_lblPMList);
|
||||
DDX_Control(pDX, IDC_LBLPART, m_lblPart);
|
||||
DDX_Control(pDX, IDC_LBLNEXTSERVICEDATE, m_lblNextServiceDate);
|
||||
DDX_Control(pDX, IDC_LBLAGEMETER, m_lblAgeMeter);
|
||||
DDX_Control(pDX, IDC_EDNOTES, m_edNotes);
|
||||
DDX_Control(pDX, IDC_EDMETERMONTHS, m_edMeterMonths);
|
||||
DDX_Control(pDX, IDC_EDDESCRIPTION, m_edDescription);
|
||||
DDX_Control(pDX, IDC_DTNEXTSERVICE, m_dtNextService);
|
||||
DDX_Control(pDX, IDC_CKACTIVE, m_ckActive);
|
||||
DDX_Control(pDX, IDC_CBPMLIST, m_cbPMList);
|
||||
DDX_Control(pDX, IDC_CBPARTS, m_cbParts);
|
||||
DDX_Control(pDX, IDC_BTNDONE, m_btnDone);
|
||||
DDX_Control(pDX, IDC_BTNDELETE, m_btnDelete);
|
||||
DDX_Control(pDX, IDC_BTNADDPART, m_btnAddPart);
|
||||
DDX_Control(pDX, IDC_BTNADD, m_btnAdd);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CPMDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CPMDlg)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
ON_BN_CLICKED(IDC_BTNREMOVEPART, OnBtnremovepart)
|
||||
ON_BN_CLICKED(IDC_BTNADDPART, OnBtnaddpart)
|
||||
ON_BN_CLICKED(IDC_BTNADD, OnBtnadd)
|
||||
ON_BN_CLICKED(IDC_BTNDELETE, OnBtndelete)
|
||||
ON_CBN_CLOSEUP(IDC_CBPARTS, OnCloseupCbparts)
|
||||
ON_CBN_CLOSEUP(IDC_CBPMLIST, OnCloseupCbpmlist)
|
||||
ON_BN_CLICKED(IDC_CKACTIVE, OnCkactive)
|
||||
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTNEXTSERVICE, OnDatetimechangeDtnextservice)
|
||||
ON_EN_KILLFOCUS(IDC_EDDESCRIPTION, OnKillfocusEddescription)
|
||||
ON_EN_KILLFOCUS(IDC_EDMETERMONTHS, OnKillfocusEdmetermonths)
|
||||
ON_EN_KILLFOCUS(IDC_EDNOTES, OnKillfocusEdnotes)
|
||||
ON_BN_CLICKED(IDC_LBLPART, OnLblpart)
|
||||
ON_BN_CLICKED(IDC_CKAGE, OnCkage)
|
||||
ON_BN_CLICKED(IDC_CKMETER, OnCkmeter)
|
||||
ON_BN_CLICKED(IDC_CKONCEONLY, OnCkonceonly)
|
||||
ON_BN_CLICKED(IDC_CKREPEAT, OnCkrepeat)
|
||||
ON_EN_KILLFOCUS(IDC_EDADVANCE, OnKillfocusEdadvance)
|
||||
ON_BN_CLICKED(IDC_CKAUTOWO, OnCkautowo)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPMDlg message handlers
|
||||
|
||||
void CPMDlg::SetMode(bool clientmode)
|
||||
{
|
||||
|
||||
m_bClientMode=clientmode;
|
||||
//false=model record
|
||||
//true =client record
|
||||
}
|
||||
|
||||
|
||||
//*************************************
|
||||
BOOL CPMDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
// ShowWindow(SW_MAXIMIZE);
|
||||
|
||||
//make "hyperlinks"
|
||||
m_lblPart.SetTextColor(RGB(0,0,255));
|
||||
m_lblPart.SetFontUnderline(TRUE);
|
||||
m_lblPart.SetLink(TRUE);
|
||||
m_lblPart.SetLinkCursor(m_pApp->hcHand);
|
||||
m_lblPart.SetLinkURL("");
|
||||
|
||||
|
||||
ASSERT(!m_strCriteria.IsEmpty());//would mean no criteria was passed
|
||||
if(m_strCriteria.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("Error in PMSCHEDULE dialog, no Model or Client criteria.");
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
if(m_bClientMode==true)
|
||||
{
|
||||
m_lblAgeMeter.ShowWindow(FALSE);
|
||||
m_ckAge.ShowWindow(FALSE);
|
||||
m_ckMeter.ShowWindow(FALSE);
|
||||
m_lblNextServiceDate.ShowWindow(TRUE);
|
||||
m_dtNextService.ShowWindow(TRUE);
|
||||
m_ckRepeat.SetWindowText("Repeat at interval");
|
||||
m_ckOnceOnly.SetWindowText("Service once only next service date");
|
||||
m_lblMeterMonths.SetWindowText("Repeat interval (months):");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lblAgeMeter.ShowWindow(TRUE);
|
||||
m_ckAge.ShowWindow(TRUE);
|
||||
m_ckMeter.ShowWindow(TRUE);
|
||||
m_lblNextServiceDate.ShowWindow(FALSE);
|
||||
m_dtNextService.ShowWindow(FALSE);
|
||||
m_ckRepeat.SetWindowText("Repeat every reading / age interval");
|
||||
m_ckOnceOnly.SetWindowText("Service once only at reading / age");
|
||||
m_lblMeterMonths.SetWindowText("Repeat interval (meter/months):");
|
||||
|
||||
}
|
||||
|
||||
|
||||
FillPartsList();
|
||||
FillPMList();
|
||||
|
||||
Security();
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//**************************************
|
||||
|
||||
void CPMDlg::SetCriteria(CString strID)
|
||||
{
|
||||
ASSERT(!strID.IsEmpty());
|
||||
m_strCriteria=strID;
|
||||
}
|
||||
|
||||
|
||||
//***************************************
|
||||
void CPMDlg::FillPMList()
|
||||
{
|
||||
|
||||
CString strData,strType,q;
|
||||
CString strIndex;
|
||||
long lData;
|
||||
m_cbPMList.Clear();
|
||||
|
||||
//are we doing this for a client or a model?
|
||||
if(m_bClientMode)
|
||||
strType="client";
|
||||
else
|
||||
strType="model";
|
||||
|
||||
//select all schedule records for this
|
||||
//client or unit model
|
||||
q.Format("SELECT pmschedules.* FROM pmschedules "
|
||||
"WHERE (((pmschedules.%s)=%s)) "
|
||||
"ORDER BY pmschedules.description;",strType,m_strCriteria);
|
||||
|
||||
rs->QueryReadOnly(q);
|
||||
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
m_bNoRecord=true;
|
||||
ClearFields();
|
||||
return;
|
||||
}
|
||||
m_bNoRecord=false;
|
||||
|
||||
rs->MoveFirst();
|
||||
|
||||
do
|
||||
{
|
||||
rs->FetchField("description",&strData);
|
||||
rs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbPMList.AddRow(strData,strIndex);
|
||||
|
||||
}while(rs->MoveForward());
|
||||
|
||||
|
||||
//pretend user has selected so that other fields get filled in
|
||||
if(m_strSelectedPM.IsEmpty()) //first time in
|
||||
{
|
||||
m_cbPMList.SetCurSel(0);
|
||||
m_strSelectedPM=m_cbPMList.GetCurrentRowID();
|
||||
|
||||
}
|
||||
else//something valid was selected before so stick with it
|
||||
m_cbPMList.Select(m_strSelectedPM);
|
||||
|
||||
FillFields();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*************************************
|
||||
void CPMDlg::FillPartsList()
|
||||
{
|
||||
|
||||
CString strData;
|
||||
CString strIndex;
|
||||
long lData;
|
||||
m_cbParts.Clear();
|
||||
|
||||
|
||||
|
||||
cbrs->QueryReadOnly("SELECT parts.id, [partnumber] & \" - \" "
|
||||
"& [description] AS name FROM parts "
|
||||
"ORDER BY parts.partnumber;");
|
||||
|
||||
|
||||
if(cbrs->IsEmpty())
|
||||
return;
|
||||
|
||||
|
||||
cbrs->MoveFirst();
|
||||
|
||||
do
|
||||
{
|
||||
cbrs->FetchField("name",&strData);
|
||||
cbrs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_cbParts.AddRow(strData,strIndex);
|
||||
|
||||
}while(cbrs->MoveForward());
|
||||
|
||||
|
||||
m_cbParts.SetCurSel(0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//***********************************
|
||||
void CPMDlg::OnBtndone()
|
||||
{
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//***********************************
|
||||
void CPMDlg::OnBtnremovepart()
|
||||
{
|
||||
CString str,q;
|
||||
if(m_bNoRecord) return;
|
||||
int x = m_lbParts.SelectionCount();
|
||||
if(x==0) return;
|
||||
|
||||
//Loop through and delete each item
|
||||
for(int y=0;y<x;y++)
|
||||
{
|
||||
q.Format("DELETE pmparts.*, pmparts.pmlink, pmparts.partnum FROM pmparts "
|
||||
"WHERE (((pmparts.pmlink)=%s) AND ((pmparts.partnum)=%s));",m_strSelectedPM,m_lbParts.GetSelectedItem(y));
|
||||
|
||||
if(!rs->Execute(q))
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
FillRequiredPartsList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//check for and fill in required parts lb
|
||||
void CPMDlg::FillRequiredPartsList()
|
||||
{
|
||||
|
||||
CString strData,q;
|
||||
CString strIndex;
|
||||
long lData;
|
||||
m_lbParts.Clear();
|
||||
|
||||
if(m_bNoRecord) return;
|
||||
|
||||
q.Format("SELECT parts.id, \"Quantity: \" & [quantity] & \" of \" & [partnumber] & \" - (\" & [description] & \")\" AS name "
|
||||
"FROM pmparts LEFT JOIN parts ON pmparts.partnum = parts.id "
|
||||
"WHERE (((pmparts.pmlink)=%s));",m_strSelectedPM);
|
||||
|
||||
cbrs->QueryReadOnly(q);
|
||||
|
||||
|
||||
if(cbrs->IsEmpty())
|
||||
return;
|
||||
|
||||
|
||||
cbrs->MoveFirst();
|
||||
|
||||
do
|
||||
{
|
||||
cbrs->FetchField("name",&strData);
|
||||
cbrs->FetchField("id",&lData);
|
||||
strIndex.Format("%u",lData);
|
||||
m_lbParts.AddRow(strData,strIndex);
|
||||
|
||||
}while(cbrs->MoveForward());
|
||||
}
|
||||
|
||||
|
||||
//*************************************************
|
||||
void CPMDlg::OnBtnaddpart()
|
||||
{
|
||||
CString q,strData;
|
||||
float fData;
|
||||
if(m_bNoRecord) return;
|
||||
m_edQuantity.GetWindowText(strData);
|
||||
fData=(float)atof(strData);
|
||||
q.Format("SELECT pmparts.pmlink FROM pmparts "
|
||||
"WHERE (((pmparts.pmlink)=%s) AND ((pmparts.partnum)=%s));",m_strSelectedPM,m_cbParts.GetCurrentRowID());
|
||||
cbrs->QueryReadOnly(q);
|
||||
if(!cbrs->IsEmpty())//trying to dupe...tsk tsk
|
||||
{
|
||||
AfxMessageBox("The same part can only be in the list once\r\n"
|
||||
"If you want to change the quantity on a part in the list\r\n"
|
||||
"You will need to delete it first and then re-add\r\n"
|
||||
"with the correct quantity");
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
//take the value selected and insert it
|
||||
q.Format("INSERT INTO pmparts ( pmlink, partnum, quantity ) "
|
||||
"SELECT %s, %s, %f;",m_strSelectedPM,m_cbParts.GetCurrentRowID(),fData);
|
||||
cbrs->Execute(q);
|
||||
cbrs->Close();
|
||||
FillRequiredPartsList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************************
|
||||
void CPMDlg::OnBtnadd()
|
||||
{
|
||||
CString strData,q;
|
||||
bool bData;
|
||||
float fData,fZero;
|
||||
long lData;
|
||||
COleDateTime dtData;
|
||||
fZero=0;
|
||||
|
||||
if(!m_bAddMode)
|
||||
{
|
||||
//Go Add mode
|
||||
m_bAddMode=true;
|
||||
m_lblPart.ShowWindow(FALSE);
|
||||
m_lblPMList.ShowWindow(FALSE);
|
||||
m_cbPMList.ShowWindow(FALSE);
|
||||
m_lbParts.ShowWindow(FALSE);
|
||||
m_btnRemovePart.ShowWindow(FALSE);
|
||||
m_btnAddPart.ShowWindow(FALSE);
|
||||
m_cbParts.ShowWindow(FALSE);
|
||||
m_lblPartsList.ShowWindow(FALSE);
|
||||
m_lblQuantity.ShowWindow(FALSE);
|
||||
m_edQuantity.ShowWindow(FALSE);
|
||||
m_btnDone.ShowWindow(FALSE);
|
||||
m_btnAdd.SetWindowText("SAVE");
|
||||
m_btnDelete.SetWindowText("CANCEL");
|
||||
ClearFields();
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{ //Save and go edit mode
|
||||
|
||||
|
||||
//DESCRIPTION
|
||||
m_edDescription.GetWindowText(strData);
|
||||
if(strData.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("Description is required to proceed");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!rs->AddNewRecord())
|
||||
return;
|
||||
|
||||
rs->UpdateField("description",&strData);
|
||||
|
||||
//UNITBASED
|
||||
bData=m_bClientMode ? false : true;
|
||||
rs->UpdateField("unitbased",&bData);
|
||||
|
||||
//CLIENT
|
||||
if(m_bClientMode)
|
||||
lData=atol(m_strCriteria);
|
||||
else
|
||||
lData=0;
|
||||
rs->UpdateField("client",&lData);
|
||||
|
||||
//MODEL
|
||||
if(!m_bClientMode)
|
||||
lData=atol(m_strCriteria);
|
||||
else
|
||||
lData=0;
|
||||
rs->UpdateField("model",&lData);
|
||||
|
||||
//AGEBASED
|
||||
bData=m_ckAge.GetCheck() ? true : false;
|
||||
rs->UpdateField("agebased",&bData);
|
||||
|
||||
//AGEMONTHS / METER
|
||||
m_edMeterMonths.GetWindowText(strData);
|
||||
fData=(float)atof(strData);
|
||||
|
||||
if(bData)//is age
|
||||
{
|
||||
rs->UpdateField("agemonths",&fData);
|
||||
rs->UpdateField("meter",&fZero);
|
||||
|
||||
}
|
||||
else
|
||||
{//is metric
|
||||
rs->UpdateField("meter",&fData);
|
||||
rs->UpdateField("agemonths",&fZero);
|
||||
|
||||
}
|
||||
|
||||
//CYCLICAL
|
||||
bData=m_ckRepeat.GetCheck() ? true : false;
|
||||
rs->UpdateField("cyclical",&bData);
|
||||
|
||||
//NOTES
|
||||
m_edNotes.GetWindowText(strData);
|
||||
rs->UpdateField("notes",&strData);
|
||||
|
||||
//NEXTDATE
|
||||
m_dtNextService.GetTime(dtData);
|
||||
rs->UpdateField("nextdate",&dtData);
|
||||
|
||||
//ACTIVE
|
||||
bData=m_ckActive.GetCheck() ? true : false;
|
||||
rs->UpdateField("active",&bData);
|
||||
|
||||
//ADVANCE WARNING
|
||||
m_edAdvance.GetWindowText(strData);
|
||||
if(strData.IsEmpty()) strData="1";
|
||||
lData=atol(strData);
|
||||
if(lData==0) lData=1;
|
||||
rs->UpdateField("advancewarning",&lData);
|
||||
|
||||
//CREATOR FIELDS
|
||||
dtData=COleDateTime::GetCurrentTime();
|
||||
rs->UpdateField("creator",&m_pApp->m_lusrID);
|
||||
rs->UpdateField("created",&dtData);
|
||||
rs->UpdateField("modifier",&m_pApp->m_lusrID);
|
||||
rs->UpdateField("modified",&dtData);
|
||||
if(!rs->SaveRecord())
|
||||
return;
|
||||
|
||||
|
||||
m_bAddMode=false;
|
||||
m_cbPMList.ShowWindow(TRUE);
|
||||
m_lblPart.ShowWindow(TRUE);
|
||||
m_lblPMList.ShowWindow(TRUE);
|
||||
m_lbParts.ShowWindow(TRUE);
|
||||
m_btnRemovePart.ShowWindow(TRUE);
|
||||
m_btnAddPart.ShowWindow(TRUE);
|
||||
m_cbParts.ShowWindow(TRUE);
|
||||
m_lblPartsList.ShowWindow(TRUE);
|
||||
m_lblQuantity.ShowWindow(TRUE);
|
||||
m_edQuantity.ShowWindow(TRUE);
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_btnDelete.SetWindowText("Delete");
|
||||
FillPMList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//***********************************************
|
||||
void CPMDlg::OnBtndelete()
|
||||
{
|
||||
CString q;
|
||||
|
||||
if(m_bAddMode)
|
||||
{//Cancel add mode
|
||||
m_bAddMode=false;
|
||||
m_lblPart.ShowWindow(TRUE);
|
||||
m_lblPMList.ShowWindow(TRUE);
|
||||
m_lbParts.ShowWindow(TRUE);
|
||||
m_btnRemovePart.ShowWindow(TRUE);
|
||||
m_btnAddPart.ShowWindow(TRUE);
|
||||
m_cbParts.ShowWindow(TRUE);
|
||||
m_lblPartsList.ShowWindow(TRUE);
|
||||
m_lblQuantity.ShowWindow(TRUE);
|
||||
m_edQuantity.ShowWindow(TRUE);
|
||||
m_cbPMList.ShowWindow(TRUE);
|
||||
m_btnDone.ShowWindow(TRUE);
|
||||
m_btnAdd.SetWindowText("Add");
|
||||
m_btnDelete.SetWindowText("Delete");
|
||||
FillPMList();
|
||||
}
|
||||
|
||||
if(m_bNoRecord) return;
|
||||
|
||||
|
||||
|
||||
if(AfxMessageBox("Permanently delete this PM record?",MB_YESNO)!=IDYES)
|
||||
return;
|
||||
|
||||
//delete PM entry
|
||||
q.Format("DELETE pmschedules.*, pmschedules.id FROM pmschedules "
|
||||
"WHERE (((pmschedules.id)=%s));",m_strSelectedPM);
|
||||
|
||||
if(!rs->Execute(q)) return;
|
||||
|
||||
//Delete parts list enty if any
|
||||
q.Format("DELETE pmparts.*, pmparts.pmlink FROM pmparts "
|
||||
"WHERE (((pmparts.pmlink)=%s));",m_strSelectedPM);
|
||||
rs->Execute(q);
|
||||
|
||||
m_strSelectedPM.Empty();
|
||||
FillPMList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//************************************************
|
||||
void CPMDlg::OnCloseupCbparts()
|
||||
{
|
||||
//do nothing, nothing necessary in this case
|
||||
|
||||
}
|
||||
|
||||
//************************************************
|
||||
void CPMDlg::OnCloseupCbpmlist()
|
||||
{
|
||||
m_strSelectedPM=m_cbPMList.GetCurrentRowID();
|
||||
FillFields();
|
||||
}
|
||||
|
||||
//******************************************
|
||||
void CPMDlg::OnCkactive()
|
||||
{
|
||||
|
||||
SaveField(&m_ckActive,"active");
|
||||
}
|
||||
//********************************
|
||||
void CPMDlg::OnDatetimechangeDtnextservice(NMHDR* pNMHDR, LRESULT* pResult)
|
||||
{
|
||||
SaveField(&m_dtNextService,"nextdate");
|
||||
|
||||
*pResult = 0;
|
||||
}
|
||||
|
||||
|
||||
//*************************************
|
||||
void CPMDlg::OnKillfocusEddescription()
|
||||
{
|
||||
SaveField(&m_edDescription,"description",false);
|
||||
if(!m_bAddMode)
|
||||
FillPMList();
|
||||
|
||||
}
|
||||
//*************************************
|
||||
void CPMDlg::OnKillfocusEdmetermonths()
|
||||
{
|
||||
if(m_bAddMode || m_bNoRecord) return;
|
||||
CString strData;
|
||||
bool bData;
|
||||
float fData,fZero;
|
||||
fZero=0;
|
||||
|
||||
bData=m_ckAge.GetCheck() ? true : false;
|
||||
//AGEMONTHS / METER
|
||||
m_edMeterMonths.GetWindowText(strData);
|
||||
fData=(float)atof(strData);
|
||||
|
||||
if(bData)//is age
|
||||
{
|
||||
rs->UpdateField("agemonths",&fData);
|
||||
rs->UpdateField("meter",&fZero);
|
||||
|
||||
}
|
||||
else
|
||||
{//is metric
|
||||
rs->UpdateField("meter",&fData);
|
||||
rs->UpdateField("agemonths",&fZero);
|
||||
|
||||
}
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
}
|
||||
|
||||
//*****************************
|
||||
void CPMDlg::OnKillfocusEdnotes()
|
||||
{
|
||||
SaveField(&m_edNotes,"notes",true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//************************************
|
||||
void CPMDlg::OnLblpart()
|
||||
{
|
||||
CPartsDlg d;
|
||||
if(d.DoModal()==IDOK)
|
||||
FillPartsList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//fill fields
|
||||
void CPMDlg::FillFields()
|
||||
{
|
||||
CString strData,q;
|
||||
COleDateTime dtData;
|
||||
bool bData;
|
||||
float fData;
|
||||
long lData;
|
||||
ClearFields();
|
||||
q.Format("SELECT pmschedules.* FROM pmschedules "
|
||||
"WHERE (((pmschedules.id)=%s));",m_cbPMList.GetCurrentRowID());
|
||||
rs->QueryReadOnly(q);
|
||||
if(rs->IsEmpty())
|
||||
return;
|
||||
|
||||
//DESCRIPTION
|
||||
rs->FetchField("description",&strData);
|
||||
m_edDescription.SetWindowText(strData);
|
||||
|
||||
//AGEBASED
|
||||
rs->FetchField("agebased",&bData);
|
||||
m_ckAge.SetCheck(bData ? TRUE : FALSE);
|
||||
m_ckMeter.SetCheck(!m_ckAge.GetCheck());
|
||||
|
||||
//AGEMONTHS
|
||||
if(bData)//is age based
|
||||
rs->FetchField("agemonths",&fData);
|
||||
else//is metric
|
||||
rs->FetchField("meter",&fData);
|
||||
strData.Format("%1.2f",fData);
|
||||
m_edMeterMonths.SetWindowText(strData);
|
||||
|
||||
|
||||
//CYCLICAL
|
||||
rs->FetchField("cyclical",&bData);
|
||||
m_ckRepeat.SetCheck(bData ? TRUE : FALSE);
|
||||
m_ckOnceOnly.SetCheck(!m_ckRepeat.GetCheck());
|
||||
|
||||
//NOTES
|
||||
rs->FetchField("notes",&strData);
|
||||
m_edNotes.SetWindowText(strData);
|
||||
|
||||
//NEXTDATE
|
||||
rs->FetchField("nextdate",&dtData);
|
||||
m_dtNextService.SetTime(dtData);
|
||||
|
||||
//ACTIVE
|
||||
rs->FetchField("active",&bData);
|
||||
m_ckActive.SetCheck(bData ? TRUE : FALSE);
|
||||
|
||||
//Autoworkorder
|
||||
rs->FetchField("autoworkorder",&bData);
|
||||
m_ckAutoWO.SetCheck(bData ? TRUE : FALSE);
|
||||
|
||||
//advance warning
|
||||
rs->FetchField("advancewarning",&lData);
|
||||
strData.Format("%u",lData);
|
||||
m_edAdvance.SetWindowText(strData);
|
||||
|
||||
FillRequiredPartsList();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//**************************************
|
||||
void CPMDlg::OnCkage()
|
||||
{
|
||||
m_ckMeter.SetCheck(!m_ckAge.GetCheck());
|
||||
SaveAgeMeterFields();
|
||||
}
|
||||
//********************************************
|
||||
void CPMDlg::OnCkmeter()
|
||||
{
|
||||
m_ckAge.SetCheck(!m_ckMeter.GetCheck());
|
||||
SaveAgeMeterFields();
|
||||
}
|
||||
|
||||
//************************************
|
||||
void CPMDlg::OnCkonceonly()
|
||||
{
|
||||
m_ckRepeat.SetCheck(!m_ckOnceOnly.GetCheck());
|
||||
if(m_ckRepeat.GetCheck()==FALSE)
|
||||
m_edMeterMonths.SetWindowText("0");
|
||||
SaveRepeatOnceOnlyFields();
|
||||
|
||||
}
|
||||
//*********************************************
|
||||
void CPMDlg::OnCkrepeat()
|
||||
{
|
||||
m_ckOnceOnly.SetCheck(!m_ckRepeat.GetCheck());
|
||||
SaveRepeatOnceOnlyFields();
|
||||
}
|
||||
|
||||
|
||||
//**********************************************
|
||||
void CPMDlg::OnCkautowo()
|
||||
{
|
||||
SaveField(&m_ckAutoWO,"autoworkorder");
|
||||
|
||||
}
|
||||
|
||||
|
||||
//************************************************
|
||||
//UPDATE MODIFIED DATA
|
||||
//*************************************************
|
||||
bool CPMDlg::UpdateModified()
|
||||
{
|
||||
//updates modified by and modified on fields
|
||||
rs->UpdateField("modifier",&m_pApp->m_lusrID);
|
||||
COleDateTime dtData;
|
||||
dtData=COleDateTime::GetCurrentTime();
|
||||
rs->UpdateField("modified",&dtData);
|
||||
rs->SaveRecord();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//************************************
|
||||
void CPMDlg::ClearFields()
|
||||
{
|
||||
|
||||
m_edNotes.SetWindowText("");
|
||||
m_edQuantity.SetWindowText("");
|
||||
m_edMeterMonths.SetWindowText("");
|
||||
m_edDescription.SetWindowText("");
|
||||
m_dtNextService.SetTime(COleDateTime::GetCurrentTime());
|
||||
m_ckRepeat.SetCheck(TRUE);
|
||||
m_ckOnceOnly.SetCheck(FALSE);
|
||||
m_ckMeter.SetCheck(FALSE);
|
||||
m_ckAge.SetCheck(TRUE);
|
||||
m_ckActive.SetCheck(TRUE);
|
||||
m_lbParts.Clear();
|
||||
}
|
||||
|
||||
|
||||
//************************************************************
|
||||
//SAVE EDIT CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CPMDlg::SaveField(CEdit *edControl,CString fldname,bool AllowEmpty)
|
||||
{
|
||||
|
||||
if(m_bAddMode || m_bNoRecord) return true;//dont attempt to update
|
||||
CString str;
|
||||
//do nothing if not changed
|
||||
if(edControl->GetModify()!=TRUE) return true;
|
||||
|
||||
edControl->GetWindowText(str);
|
||||
//dont save empty fields if not allowed to
|
||||
if(!AllowEmpty)
|
||||
{
|
||||
|
||||
if(str.IsEmpty())
|
||||
{
|
||||
edControl->Undo();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rs->UpdateField(fldname,&str);
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
//************************************************************
|
||||
//SAVE GZCOMBO CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CPMDlg::SaveField(CgzCombo *cbControl,CString fldname)
|
||||
{
|
||||
|
||||
if(m_bAddMode || m_bNoRecord) return true;//dont attempt to update
|
||||
CString str;
|
||||
long lData;
|
||||
str=cbControl->GetCurrentRowID();
|
||||
if(str.IsEmpty()) return false;//shouldn't happen but...
|
||||
lData=atol(str);
|
||||
rs->UpdateField(fldname,&lData);
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
//************************************************************
|
||||
//SAVE CheckBox CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CPMDlg::SaveField(CButton *ckControl,CString fldname)
|
||||
{
|
||||
if(m_bAddMode || m_bNoRecord) return true;//dont attempt to update
|
||||
bool bData=false;
|
||||
BOOL BData;
|
||||
BData=ckControl->GetCheck();
|
||||
if(BData==TRUE) bData=true;
|
||||
rs->UpdateField(fldname,&bData);
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
return true;
|
||||
}
|
||||
//************************************************************
|
||||
//SAVE DateTimePicker CONTROL FIELD
|
||||
//************************************************************
|
||||
bool CPMDlg::SaveField(CDateTimeCtrl *dtControl,CString fldname)
|
||||
{
|
||||
if(m_bAddMode || m_bNoRecord) return true;//dont attempt to update
|
||||
COleDateTime dtData;
|
||||
dtControl->GetTime(dtData);
|
||||
rs->UpdateField(fldname,&dtData);
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
return true;
|
||||
}
|
||||
|
||||
//**************************************
|
||||
void CPMDlg::SaveAgeMeterFields()
|
||||
{
|
||||
bool bData;
|
||||
if(m_bAddMode || m_bNoRecord) return;
|
||||
bData=m_ckAge.GetCheck() ? true : false;
|
||||
rs->UpdateField("agebased",&bData);
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
}
|
||||
|
||||
//*************************************
|
||||
void CPMDlg::SaveRepeatOnceOnlyFields()
|
||||
{
|
||||
bool bData;
|
||||
if(m_bAddMode || m_bNoRecord) return;
|
||||
bData=m_ckRepeat.GetCheck() ? true : false;
|
||||
rs->UpdateField("cyclical",&bData);
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CPMDlg::OnKillfocusEdadvance()
|
||||
{
|
||||
//ADVANCE WARNING
|
||||
if(m_bAddMode || m_bNoRecord) return;
|
||||
CString strData;
|
||||
long lData;
|
||||
|
||||
m_edAdvance.GetWindowText(strData);
|
||||
if(strData.IsEmpty()) strData="1";
|
||||
lData=atol(strData);
|
||||
if(lData==0) lData=1;
|
||||
|
||||
strData.Format("%u",lData);
|
||||
m_edAdvance.SetWindowText(strData);
|
||||
rs->UpdateField("advancewarning",&lData);
|
||||
|
||||
rs->SaveRecord();
|
||||
UpdateModified();
|
||||
}
|
||||
|
||||
void CPMDlg::Security()
|
||||
{
|
||||
|
||||
//m_bReadOnly=false;
|
||||
int x=m_pApp->Allowed(RPM,true);
|
||||
if(x==0)//no access allowed
|
||||
{
|
||||
m_pApp->SecurityWarning();
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
if(x==2)//read only
|
||||
{
|
||||
// m_bReadOnly=true;
|
||||
m_btnAdd.ShowWindow(FALSE);
|
||||
m_btnDelete.ShowWindow(FALSE);
|
||||
m_btnAddPart.ShowWindow(FALSE);
|
||||
m_btnRemovePart.ShowWindow(FALSE);
|
||||
m_cbParts.EnableWindow(FALSE);
|
||||
m_ckActive.EnableWindow(FALSE);
|
||||
m_ckAge.EnableWindow(FALSE);
|
||||
m_ckMeter.EnableWindow(FALSE);
|
||||
m_ckOnceOnly.EnableWindow(FALSE);
|
||||
m_ckRepeat.EnableWindow(FALSE);
|
||||
m_dtNextService.EnableWindow(FALSE);
|
||||
m_edAdvance.SetReadOnly(TRUE);
|
||||
m_edDescription.SetReadOnly(TRUE);
|
||||
m_edMeterMonths.SetReadOnly(TRUE);
|
||||
m_edNotes.SetReadOnly(TRUE);
|
||||
m_edQuantity.SetReadOnly(TRUE);
|
||||
|
||||
}
|
||||
}
|
||||
121
archive/ayanova 1.9.4 CE final release db schema 171/sp/PMDlg.h
Normal file
121
archive/ayanova 1.9.4 CE final release db schema 171/sp/PMDlg.h
Normal file
@@ -0,0 +1,121 @@
|
||||
#if !defined(AFX_PMDLG_H__69649FC2_2BEE_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_PMDLG_H__69649FC2_2BEE_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// PMDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPMDlg dialog
|
||||
#include "gzcombo.h"
|
||||
#include "gzrset.h"
|
||||
#include "gzlistbox.h"
|
||||
#include "label.h"
|
||||
|
||||
class CPMDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
void Security();
|
||||
~CPMDlg();
|
||||
void SaveRepeatOnceOnlyFields();
|
||||
void SaveAgeMeterFields();
|
||||
void ClearFields();
|
||||
void FillFields();
|
||||
bool m_bNoRecord;
|
||||
void FillRequiredPartsList();
|
||||
void FillPartsList();
|
||||
void FillPMList();
|
||||
void SetCriteria(CString strID);
|
||||
CString m_strCriteria;
|
||||
bool m_bClientMode;
|
||||
void SetMode(bool clientmode);
|
||||
CPMDlg(CWnd* pParent = NULL); // standard constructor
|
||||
//Save fields
|
||||
bool SaveField(CEdit* edControl,CString fldname,bool AllowEmpty);
|
||||
bool SaveField(CgzCombo* cbControl,CString fldname);
|
||||
bool SaveField(CButton* ckControl,CString fldname);
|
||||
bool SaveField(CDateTimeCtrl* dtControl,CString fldname);
|
||||
bool UpdateModified();
|
||||
//-------------------------------
|
||||
CSpApp* m_pApp;
|
||||
GZRset* rs;
|
||||
GZRset* cbrs;
|
||||
bool m_bAddMode;
|
||||
CString m_strSelectedPM;
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CPMDlg)
|
||||
enum { IDD = IDD_PMSCHEDULE };
|
||||
CButton m_ckAutoWO;
|
||||
CEdit m_edAdvance;
|
||||
CStatic m_lblAdvance;
|
||||
CgzListBox m_lbParts;
|
||||
CStatic m_lblQuantity;
|
||||
CStatic m_lblPartsList;
|
||||
CButton m_ckRepeat;
|
||||
CStatic m_lblMeterMonths;
|
||||
CButton m_ckOnceOnly;
|
||||
CButton m_ckMeter;
|
||||
CButton m_ckAge;
|
||||
CEdit m_edQuantity;
|
||||
CButton m_btnRemovePart;
|
||||
CStatic m_lblPMList;
|
||||
CLabel m_lblPart;
|
||||
CStatic m_lblNextServiceDate;
|
||||
CButton m_lblAgeMeter;
|
||||
CEdit m_edNotes;
|
||||
CEdit m_edMeterMonths;
|
||||
CEdit m_edDescription;
|
||||
CDateTimeCtrl m_dtNextService;
|
||||
CButton m_ckActive;
|
||||
CgzCombo m_cbPMList;
|
||||
CgzCombo m_cbParts;
|
||||
CButton m_btnDone;
|
||||
CButton m_btnDelete;
|
||||
CButton m_btnAddPart;
|
||||
CButton m_btnAdd;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CPMDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CPMDlg)
|
||||
virtual BOOL OnInitDialog();
|
||||
afx_msg void OnBtndone();
|
||||
afx_msg void OnBtnremovepart();
|
||||
afx_msg void OnBtnaddpart();
|
||||
afx_msg void OnBtnadd();
|
||||
afx_msg void OnBtndelete();
|
||||
afx_msg void OnCloseupCbparts();
|
||||
afx_msg void OnCloseupCbpmlist();
|
||||
afx_msg void OnCkactive();
|
||||
afx_msg void OnDatetimechangeDtnextservice(NMHDR* pNMHDR, LRESULT* pResult);
|
||||
afx_msg void OnKillfocusEddescription();
|
||||
afx_msg void OnKillfocusEdmetermonths();
|
||||
afx_msg void OnKillfocusEdnotes();
|
||||
afx_msg void OnLblpart();
|
||||
afx_msg void OnCkage();
|
||||
afx_msg void OnCkmeter();
|
||||
afx_msg void OnCkonceonly();
|
||||
afx_msg void OnCkrepeat();
|
||||
afx_msg void OnKillfocusEdadvance();
|
||||
afx_msg void OnCkautowo();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_PMDLG_H__69649FC2_2BEE_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,94 @@
|
||||
// PMViewPrompt.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "PMViewPrompt.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPMViewPrompt dialog
|
||||
|
||||
//RETURNS 0=CANCEL,1=SELECTED, 2=MASTER
|
||||
CPMViewPrompt::CPMViewPrompt(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CPMViewPrompt::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CPMViewPrompt)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pnReturn=NULL;
|
||||
}
|
||||
|
||||
BOOL CPMViewPrompt::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
ASSERT(m_pnReturn!=NULL);
|
||||
SetWindowText(m_strTitle);
|
||||
m_lblPrompt.SetWindowText(m_strPrompt);
|
||||
m_btnCancel.SetFocus();
|
||||
return FALSE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CPMViewPrompt::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CPMViewPrompt)
|
||||
DDX_Control(pDX, IDCANCEL, m_btnCancel);
|
||||
DDX_Control(pDX, IDC_LBLPROMPT, m_lblPrompt);
|
||||
DDX_Control(pDX, IDC_BTNSELECTEDONLY, m_btnSelectedOnly);
|
||||
DDX_Control(pDX, IDC_BTNMASTER, m_btnMaster);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CPMViewPrompt, CDialog)
|
||||
//{{AFX_MSG_MAP(CPMViewPrompt)
|
||||
ON_BN_CLICKED(IDC_BTNSELECTEDONLY, OnBtnselectedonly)
|
||||
ON_BN_CLICKED(IDC_BTNMASTER, OnBtnmaster)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPMViewPrompt message handlers
|
||||
|
||||
void CPMViewPrompt::OnOK()
|
||||
{//enter key hack
|
||||
}
|
||||
|
||||
void CPMViewPrompt::OnCancel()
|
||||
{
|
||||
*m_pnReturn=0;
|
||||
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
void CPMViewPrompt::OnBtnselectedonly()
|
||||
{
|
||||
*m_pnReturn=1;
|
||||
CDialog::OnOK();
|
||||
|
||||
}
|
||||
|
||||
void CPMViewPrompt::OnBtnmaster()
|
||||
{
|
||||
*m_pnReturn=2;
|
||||
CDialog::OnOK();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//RETURNS 0=CANCEL,1=SELECTED, 2=MASTER
|
||||
void CPMViewPrompt::Setup(/*RETURNS 0=CANCEL,1=SELECTED, 2=MASTER */CString strPrompt, CString strTitle, int * nResult)
|
||||
{
|
||||
m_strPrompt=strPrompt;
|
||||
m_strTitle=strTitle;
|
||||
m_pnReturn=nResult;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#if !defined(AFX_PMVIEWPROMPT_H__EC43E182_A380_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_PMVIEWPROMPT_H__EC43E182_A380_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// PMViewPrompt.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPMViewPrompt dialog
|
||||
|
||||
class CPMViewPrompt : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
int * m_pnReturn;
|
||||
CString m_strTitle;
|
||||
void Setup(CString strPrompt, CString strTitle, int* nResult);
|
||||
CString m_strPrompt;
|
||||
CPMViewPrompt(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CPMViewPrompt)
|
||||
enum { IDD = IDD_PMSERIESSINGLEPROMPTER };
|
||||
CButton m_btnCancel;
|
||||
CStatic m_lblPrompt;
|
||||
CButton m_btnSelectedOnly;
|
||||
CButton m_btnMaster;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CPMViewPrompt)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CPMViewPrompt)
|
||||
virtual void OnOK();
|
||||
virtual void OnCancel();
|
||||
afx_msg void OnBtnselectedonly();
|
||||
afx_msg void OnBtnmaster();
|
||||
virtual BOOL OnInitDialog();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_PMVIEWPROMPT_H__EC43E182_A380_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
@@ -0,0 +1,76 @@
|
||||
// PWDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "PWDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPWDlg dialog
|
||||
|
||||
|
||||
CPWDlg::CPWDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CPWDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CPWDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
}
|
||||
|
||||
|
||||
void CPWDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CPWDlg)
|
||||
DDX_Control(pDX, IDC_USER, m_edUsername);
|
||||
DDX_Control(pDX, IDOK, m_btnOK);
|
||||
DDX_Control(pDX, IDC_PW2, m_edPW2);
|
||||
DDX_Control(pDX, IDC_PW1, m_edPW1);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CPWDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CPWDlg)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPWDlg message handlers
|
||||
|
||||
void CPWDlg::PassPWString(CString *pw, CString *user)
|
||||
{
|
||||
strPassword=pw;
|
||||
strUserName=user;
|
||||
}
|
||||
|
||||
void CPWDlg::OnOK()
|
||||
{
|
||||
// TODO: Add extra validation here
|
||||
CString pw1,pw2,usr;
|
||||
m_edPW1.GetWindowText(pw1);
|
||||
m_edPW2.GetWindowText(pw2);
|
||||
m_edUsername.GetWindowText(usr);
|
||||
|
||||
if(usr.IsEmpty())
|
||||
{
|
||||
AfxMessageBox("You must enter a user login name");
|
||||
return;
|
||||
}
|
||||
|
||||
if(pw2.Compare(pw1)!=0)
|
||||
{
|
||||
AfxMessageBox("Password and confirmation do not match!");
|
||||
return;
|
||||
|
||||
}
|
||||
strPassword->Format("%s",pw1);
|
||||
strUserName->Format("%s",usr);
|
||||
CDialog::OnOK();
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
#if !defined(AFX_PWDLG_H__BAEA8B21_1776_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
#define AFX_PWDLG_H__BAEA8B21_1776_11D4_964F_00C0F02C4B69__INCLUDED_
|
||||
|
||||
#if _MSC_VER > 1000
|
||||
#pragma once
|
||||
#endif // _MSC_VER > 1000
|
||||
// PWDlg.h : header file
|
||||
//
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CPWDlg dialog
|
||||
|
||||
class CPWDlg : public CDialog
|
||||
{
|
||||
// Construction
|
||||
public:
|
||||
void PassPWString(CString* pw, CString *user);
|
||||
CPWDlg(CWnd* pParent = NULL); // standard constructor
|
||||
|
||||
// Dialog Data
|
||||
//{{AFX_DATA(CPWDlg)
|
||||
enum { IDD = IDD_PWDLG };
|
||||
CEdit m_edUsername;
|
||||
CButton m_btnOK;
|
||||
CEdit m_edPW2;
|
||||
CEdit m_edPW1;
|
||||
//}}AFX_DATA
|
||||
|
||||
|
||||
// Overrides
|
||||
// ClassWizard generated virtual function overrides
|
||||
//{{AFX_VIRTUAL(CPWDlg)
|
||||
protected:
|
||||
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
|
||||
//}}AFX_VIRTUAL
|
||||
|
||||
// Implementation
|
||||
protected:
|
||||
|
||||
// Generated message map functions
|
||||
//{{AFX_MSG(CPWDlg)
|
||||
virtual void OnOK();
|
||||
//}}AFX_MSG
|
||||
DECLARE_MESSAGE_MAP()
|
||||
private:
|
||||
CString * strUserName;
|
||||
CString * strPassword;
|
||||
};
|
||||
|
||||
//{{AFX_INSERT_LOCATION}}
|
||||
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
|
||||
|
||||
#endif // !defined(AFX_PWDLG_H__BAEA8B21_1776_11D4_964F_00C0F02C4B69__INCLUDED_)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user