AyaNova CE Archive added as recovered from storage during attempt to upgrade a customer from v1.7 to v8!
This commit is contained in:
465
archive/ayanova 1.9.4 CE final release db schema 171/sp/SnR.cpp
Normal file
465
archive/ayanova 1.9.4 CE final release db schema 171/sp/SnR.cpp
Normal file
@@ -0,0 +1,465 @@
|
||||
// SnR.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "SnR.h"
|
||||
#include "SnREdit.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
//memory leak debugging help
|
||||
#define _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSnR
|
||||
|
||||
IMPLEMENT_DYNCREATE(CSnR, CFormView)
|
||||
|
||||
CSnR::CSnR()
|
||||
: CFormView(CSnR::IDD)
|
||||
, m_nCX(0)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CSnR)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
|
||||
}
|
||||
|
||||
CSnR::~CSnR()
|
||||
{
|
||||
}
|
||||
|
||||
void CSnR::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CFormView::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CSnR)
|
||||
// NOTE: the ClassWizard will add DDX and DDV calls here
|
||||
DDX_Control(pDX, IDC_REPORT, m_rc);
|
||||
//}}AFX_DATA_MAP
|
||||
DDX_Control(pDX, IDC_CKSHOWCOMPLETED, m_ckShowCompleted);
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSnR, CFormView)
|
||||
//{{AFX_MSG_MAP(CSnR)
|
||||
ON_NOTIFY(RVN_ITEMDBCLICK, IDC_REPORT, OnRvnItemDbClick)
|
||||
//}}AFX_MSG_MAP
|
||||
ON_WM_SIZE()
|
||||
ON_BN_CLICKED(IDC_CKSHOWCOMPLETED, OnBnClickedCkshowcompleted)
|
||||
ON_WM_HELPINFO()
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSnR diagnostics
|
||||
|
||||
#ifdef _DEBUG
|
||||
void CSnR::AssertValid() const
|
||||
{
|
||||
CFormView::AssertValid();
|
||||
}
|
||||
|
||||
void CSnR::Dump(CDumpContext& dc) const
|
||||
{
|
||||
CFormView::Dump(dc);
|
||||
}
|
||||
#endif //_DEBUG
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSnR message handlers
|
||||
|
||||
void CSnR::Activate()
|
||||
{
|
||||
#ifdef _WTF_
|
||||
AfxMessageBox("SNR activate");
|
||||
#endif
|
||||
|
||||
/*
|
||||
if(rs==NULL)
|
||||
{
|
||||
rs=new GZRset("Shipping and receiving rs error:");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
}
|
||||
*/
|
||||
//Initialize recordset pointer
|
||||
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CSnR");
|
||||
|
||||
CString profile,q;
|
||||
q.Format("SELECT users.srprofile "
|
||||
"FROM users WHERE (((users.id)=%u));",m_pApp->m_lusrID);
|
||||
rs->Query(q);
|
||||
rs->FetchField("srprofile",&profile);
|
||||
if(!profile.IsEmpty())
|
||||
{
|
||||
for(int x=0;x<7;x++)
|
||||
m_rc.DeactivateColumn(x);
|
||||
m_rc.GetProfile(&profile);
|
||||
}
|
||||
FillView();
|
||||
|
||||
}
|
||||
|
||||
void CSnR::DeActivate()
|
||||
{
|
||||
#ifdef _WTF_
|
||||
AfxMessageBox("dbutils De-activate");
|
||||
#endif
|
||||
|
||||
CString profile,q;
|
||||
//save to user prefs.
|
||||
m_rc.WriteProfile(&profile);
|
||||
q.Format("UPDATE users SET users.srprofile = \"%s\" "
|
||||
"WHERE (((users.id)=%u));",profile,m_pApp->m_lusrID);
|
||||
rs->Ex(q);
|
||||
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSnR::OnInitialUpdate()
|
||||
{
|
||||
CFormView::OnInitialUpdate();
|
||||
|
||||
|
||||
m_strCrit.Empty();
|
||||
|
||||
//removed Jan 8th 2001 as unecessary
|
||||
//Initialize recordset pointer
|
||||
//rs=m_pApp->rsPool->GetRS("CSnR");
|
||||
|
||||
|
||||
|
||||
m_ilReport.Create(IDB_BM2, 16, 1, RGB(255,0,255));
|
||||
m_rc.SetImageList(&m_ilReport);
|
||||
|
||||
|
||||
|
||||
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 = "Client";
|
||||
rvc.iWidth = 60;
|
||||
m_rc.DefineColumn(2, &rvc);
|
||||
|
||||
|
||||
rvc.nFormat = RVCF_TEXT;
|
||||
rvc.lpszText = "Sent on";
|
||||
rvc.iWidth = 60;
|
||||
m_rc.DefineColumn(3, &rvc);
|
||||
|
||||
rvc.lpszText = "Due";
|
||||
rvc.iWidth = 60;
|
||||
m_rc.DefineColumn(4, &rvc);
|
||||
|
||||
//Checkmark
|
||||
rvc.nFormat = RVCF_TEXT|RVCF_SUBITEM_IMAGE|RVCF_CENTER;
|
||||
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);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
//removed Jan 8th 2001 as unecessary
|
||||
//retrieve the items and display them
|
||||
//FillView();
|
||||
//m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CSnR::FillView()
|
||||
{
|
||||
COleDateTime dtDefault;
|
||||
dtDefault.SetDate(1968,03,12);
|
||||
CString q;
|
||||
int x=0;
|
||||
m_strCrit.Empty();
|
||||
if(m_ckShowCompleted.GetCheck()==FALSE)
|
||||
m_strCrit=" WHERE (((subrepair.isback)=False)) ";
|
||||
|
||||
//1.9.3.0 added AS WOID to wo.id column for changes below
|
||||
q.Format("SELECT subrepair.id AS subid, wo.closed, wo.id AS WOID, IIf(IsNull([clients]![company]), "
|
||||
"[clients]![first] & \" \" & [clients]![last],[clients]![company]) AS compname, "
|
||||
"nonclients_2!company_person & \" \" & IIf(IsNull([unitmodels]![description]), "
|
||||
"[unitmodels]![model],[unitmodels]![description]) & \" \" & IIf(IsNull([sn]),\"\",\"sn:\" & [sn]) AS item, "
|
||||
"nonclients.company_person AS sentto, nonclients_1.company_person AS sentby, "
|
||||
"users.initials, IIf(subrepair.sent=#%s#,\"---\",Format(subrepair.sent,\"Short Date\")) AS strsent, subrepair.isback, "
|
||||
"IIf(subrepair.eta=#%s#,\"---\",Format(subrepair.eta,\"Short Date\")) AS streta, subrepair.received, DateDiff(\"d\",Now(),[subrepair].[eta]) AS duedays "
|
||||
"FROM (nonclients RIGHT JOIN (unitmodels RIGHT JOIN (units RIGHT JOIN (clients RIGHT JOIN (users RIGHT JOIN "
|
||||
"((subrepair LEFT JOIN (probs LEFT JOIN wo ON probs.wolink = wo.id) ON subrepair.link = probs.id) LEFT JOIN "
|
||||
"nonclients AS nonclients_1 ON subrepair.sentvia = nonclients_1.id) ON users.id = subrepair.creator) ON "
|
||||
"clients.id = wo.client) ON units.id = probs.unit) ON unitmodels.id = units.model) ON nonclients.id = "
|
||||
"subrepair.where) LEFT JOIN nonclients AS nonclients_2 ON unitmodels.manufacturer = nonclients_2.id "
|
||||
"%s ORDER BY subrepair.id DESC;",dtDefault.Format(_T("%m/%d/%Y")),dtDefault.Format(_T("%m/%d/%Y")),m_strCrit);
|
||||
|
||||
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//m_pApp->ShowStuff(q);
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
rs->Query(q);
|
||||
m_rc.DeleteAllItems();
|
||||
|
||||
|
||||
if(rs->IsEmpty())
|
||||
return;
|
||||
|
||||
|
||||
|
||||
|
||||
CString strData,strItem,strClient,strOutdate,strDueDays,strDuedate,strIsBack,strID;
|
||||
CString strWOID;
|
||||
COleDateTime dtDate;
|
||||
long lData;
|
||||
long lDueDays;
|
||||
bool bReturned;
|
||||
int nDueDays;
|
||||
rs->MoveFirst();
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
//Added 1.9.3.0
|
||||
rs->FetchField("WOID",&lData);
|
||||
strWOID.Format(" [WO: %u]",lData);
|
||||
|
||||
rs->FetchField("item",&strItem);
|
||||
//avoid the underline in the report control
|
||||
//for a single &
|
||||
strItem.Replace("&","&&");
|
||||
|
||||
|
||||
rs->FetchField("compname",&strClient);
|
||||
strClient.Replace("&","&&");
|
||||
|
||||
//Added v1.9.3.0
|
||||
strClient+=strWOID;
|
||||
|
||||
|
||||
rs->FetchField("strsent",&strOutdate);
|
||||
|
||||
rs->FetchField("streta",&strDuedate);
|
||||
|
||||
|
||||
rs->FetchField("duedays",&lDueDays);
|
||||
nDueDays=lDueDays;//atoi(strDueDays);
|
||||
|
||||
rs->FetchField("subid",&lData);
|
||||
strID.Format("%u",lData);
|
||||
|
||||
rs->FetchField("isback",&bReturned);
|
||||
|
||||
|
||||
|
||||
|
||||
//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);
|
||||
|
||||
//CLIENT
|
||||
rvi.iSubItem = 2;
|
||||
rvi.lpszText = strClient.GetBuffer(strClient.GetLength());
|
||||
m_rc.SetItem(&rvi);
|
||||
|
||||
//SENT 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);
|
||||
|
||||
//ISBACK
|
||||
rvi.nMask = RVIM_IMAGE |RVIM_CHECK;
|
||||
rvi.nState=0;//who knows what this is for?
|
||||
rvi.iSubItem = 5;
|
||||
rvi.iImage=-1;
|
||||
if(bReturned==false)
|
||||
rvi.iCheck = FALSE;
|
||||
else
|
||||
rvi.iCheck = TRUE;
|
||||
rvi.lpszText = "Check";
|
||||
m_rc.SetItem(&rvi);
|
||||
|
||||
|
||||
|
||||
|
||||
//ID
|
||||
rvi.nMask = RVIM_TEXT;
|
||||
rvi.iSubItem = 6;
|
||||
rvi.lpszText = strID.GetBuffer(strID.GetLength());
|
||||
m_rc.SetItem(&rvi);
|
||||
|
||||
|
||||
x++;
|
||||
|
||||
}while(rs->MoveForward());
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CSnR::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);
|
||||
//d.DoModal();
|
||||
|
||||
CSnREdit d;
|
||||
CString item=m_rc.GetItemText(lpnmrv->iItem,6);
|
||||
d.m_strSubRepairID=item;
|
||||
|
||||
if(d.DoModal()==IDOK)
|
||||
FillView();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
*pResult = FALSE;
|
||||
}
|
||||
|
||||
void CSnR::LayoutControls(void)
|
||||
{
|
||||
CRect rectCtl,rectStat;
|
||||
GetWindowRect(rectStat);
|
||||
|
||||
|
||||
int nOffset=rectStat.top;
|
||||
int nLastBottom,nRight,nHeight;
|
||||
//int nHeight,nWidth,nLeft;
|
||||
|
||||
|
||||
m_rc.GetWindowRect(rectCtl);
|
||||
|
||||
rectCtl.right=rectStat.right-73;
|
||||
rectCtl.top-=nOffset;
|
||||
rectCtl.left=13;
|
||||
rectCtl.bottom=rectStat.bottom-70-nOffset;
|
||||
m_rc.MoveWindow(rectCtl,TRUE);
|
||||
nLastBottom=rectCtl.bottom;
|
||||
nRight=rectCtl.right;
|
||||
|
||||
|
||||
m_ckShowCompleted.GetWindowRect(rectCtl);
|
||||
nHeight=rectCtl.Height();
|
||||
//rectCtl.right=rectStat.right-73;
|
||||
rectCtl.top=nLastBottom+10;
|
||||
//rectCtl.left=13;
|
||||
rectCtl.bottom=nLastBottom+nHeight+10;
|
||||
m_ckShowCompleted.MoveWindow(rectCtl,TRUE);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CSnR::OnSize(UINT nType, int cx, int cy)
|
||||
{
|
||||
|
||||
|
||||
CFormView::OnSize(nType, cx, cy);
|
||||
if(cx>m_nCX)//to cut down on number of times called
|
||||
{
|
||||
m_nCX=cx;
|
||||
if(m_rc.m_hWnd)
|
||||
{
|
||||
LayoutControls();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSnR::OnBnClickedCkshowcompleted()
|
||||
{
|
||||
FillView();
|
||||
}
|
||||
|
||||
BOOL CSnR::OnHelpInfo(HELPINFO* pHelpInfo)
|
||||
{
|
||||
WinHelp (0x00020000 + IDD_SNR_FORM,HELP_CONTEXT);
|
||||
return TRUE;
|
||||
}
|
||||
Reference in New Issue
Block a user