2535 lines
66 KiB
C++
2535 lines
66 KiB
C++
// SimpleWODlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "sp.h"
|
|
#include "SimpleWODlg.h"
|
|
#include "RatesDlg.h"
|
|
#include "ContactsViewDlg.h"
|
|
#include "probstatdlg.h"
|
|
#include <crtdbg.h>
|
|
#include ".\simplewodlg.h"
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
//#define _EAF 1
|
|
#define _STARTING_PRINT_COMMAND_ID 32299
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSimpleWODlg dialog
|
|
|
|
|
|
CSimpleWODlg::CSimpleWODlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CSimpleWODlg::IDD, pParent)
|
|
, m_pSubMenu(NULL)
|
|
, m_bShowQueriesOnPrint(false)
|
|
, m_bAlertPopup(false)
|
|
{
|
|
//{{AFX_DATA_INIT(CSimpleWODlg)
|
|
//}}AFX_DATA_INIT
|
|
|
|
|
|
m_pApp = (CSpApp*)AfxGetApp();
|
|
/*
|
|
rs=new GZRset("Quick workorder screen error:");
|
|
rs->SetConnect(m_pApp->strConnectString);
|
|
|
|
cbrs=new GZRset("Quick workorder screen contract RS error:");
|
|
cbrs->SetConnect(m_pApp->strConnectString);
|
|
|
|
|
|
rsPrint=new GZRset("Quick workorder screen rsPrint error:",true);
|
|
rsPrint->SetConnect(m_pApp->strConnectString);
|
|
|
|
|
|
//create the extra recordsets to facilitate quick
|
|
//saves later on
|
|
rsProb=new GZRset("Quick workorder screen Prob table error:");
|
|
rsLabor=new GZRset("Quick workorder screen Labour table error:");
|
|
|
|
rsProb->SetConnect(m_pApp->strConnectString);
|
|
rsLabor->SetConnect(m_pApp->strConnectString);
|
|
*/
|
|
//Initialize recordset pointer
|
|
|
|
|
|
rs=m_pApp->rsPool->GetRS("CSimpleWODlg RS");
|
|
cbrs=m_pApp->rsPool->GetRS("CSimpleWODlg CBRS");
|
|
rsProb=m_pApp->rsPool->GetRS("CSimpleWODlg RSPROB");
|
|
rsLabor=m_pApp->rsPool->GetRS("CSimpleWODlg RSLABOR");
|
|
rsPrint=m_pApp->rsPool->GetRSPrint("CSimpleWODlg RSPRINT");
|
|
|
|
|
|
//not editing as far as known
|
|
m_bEditing=false;
|
|
m_strSelectedRate.Empty();
|
|
m_strSelectedTravelRate.Empty();
|
|
m_strSelectedTech.Empty();
|
|
m_strSelClient.Empty();
|
|
m_strWorkorderID="0";
|
|
|
|
}
|
|
|
|
|
|
CSimpleWODlg::~CSimpleWODlg()
|
|
{
|
|
|
|
|
|
m_pApp->rsPool->ReleaseRS(&rsLabor->m_nID);
|
|
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
|
m_pApp->rsPool->ReleaseRS(&cbrs->m_nID);
|
|
m_pApp->rsPool->ReleaseRS(&rsPrint->m_nID);
|
|
m_pApp->rsPool->ReleaseRS(&rsProb->m_nID);
|
|
//_CrtDumpMemoryLeaks();
|
|
|
|
}
|
|
void CSimpleWODlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CSimpleWODlg)
|
|
DDX_Control(pDX, IDC_DATEPICKER2, m_dtEndDate);
|
|
DDX_Control(pDX, IDC_LBLTECHNOTES, m_lblTechNotes);
|
|
DDX_Control(pDX, IDC_HISTORY, m_lblHistory);
|
|
DDX_Control(pDX, IDC_EDOURREFNUMBER2, m_edOurRefNum);
|
|
DDX_Control(pDX, IDC_CBSTATUS, m_cbStatus);
|
|
DDX_Control(pDX, IDC_lblContactInfo, m_lblContactInfo);
|
|
DDX_Control(pDX, IDC_EDCLIENTREFNUM, m_edClientRefNumber);
|
|
DDX_Control(pDX, IDC_EDCLIENTCONTACT, m_edClientContact);
|
|
DDX_Control(pDX, IDC_LBLCONTRACT, m_lblContract);
|
|
DDX_Control(pDX, IDC_TECH_LABEL, m_lblTechList);
|
|
DDX_Control(pDX, IDC_TECHLIST, m_cbTechList);
|
|
DDX_Control(pDX, IDC_TRAVELRATELABEL, m_lblTravelRate);
|
|
DDX_Control(pDX, IDC_TRAVELRATESLIST, m_cbTravelRates);
|
|
DDX_Control(pDX, IDC_ONSITE, m_ckOnsite);
|
|
DDX_Control(pDX, IDC_DATEPICKER, m_dtDate);
|
|
DDX_Control(pDX, IDC_CLIENTLIST_LABEL, m_lblClients);
|
|
DDX_Control(pDX, IDC_RATE_LABEL, m_lblRate);
|
|
DDX_Control(pDX, IDC_LABEL_CATEGORY, m_lblCategory);
|
|
DDX_Control(pDX, IDC_ENDTIMERLABEL, m_lblEnd);
|
|
DDX_Control(pDX, IDC_TIMER, m_btnTimer);
|
|
DDX_Control(pDX, IDC_GENERALNOTES, m_edDetails);
|
|
DDX_Control(pDX, IDC_INVOICENUM, m_edInvoicedOn);
|
|
DDX_Control(pDX, IDC_TRAVEL, m_edTravelHours);
|
|
DDX_Control(pDX, IDC_NC, m_edNCHours);
|
|
DDX_Control(pDX, IDC_BILL, m_edBillHours);
|
|
DDX_Control(pDX, IDC_END, m_edEnd);
|
|
DDX_Control(pDX, IDC_START, m_edStart);
|
|
DDX_Control(pDX, IDC_TYPE, m_cbTypes);
|
|
DDX_Control(pDX, IDC_RATESLIST, m_cbRates);
|
|
DDX_Control(pDX, IDC_CLIENTLIST, m_cbClients);
|
|
//}}AFX_DATA_MAP
|
|
DDX_Control(pDX, IDC_ED_DISTANCE, m_edDistance);
|
|
DDX_Control(pDX, IDC_LBLSTATUS, m_lblStatus);
|
|
}
|
|
|
|
//IDC_LBLSTATUS
|
|
BEGIN_MESSAGE_MAP(CSimpleWODlg, CDialog)
|
|
//{{AFX_MSG_MAP(CSimpleWODlg)
|
|
ON_BN_CLICKED(IDC_TIMER, OnTimer)
|
|
ON_BN_CLICKED(IDC_LABEL_CATEGORY, OnLabelCategory)
|
|
ON_BN_CLICKED(IDC_RATE_LABEL, OnRateLabel)
|
|
ON_BN_CLICKED(IDC_CLIENTLIST_LABEL, OnClientlistLabel)
|
|
ON_CBN_CLOSEUP(IDC_TRAVELRATESLIST, OnCloseupTravelrateslist)
|
|
ON_CBN_CLOSEUP(IDC_RATESLIST, OnCloseupRateslist)
|
|
ON_BN_CLICKED(IDC_TRAVELHOURSLABEL, OnTravelhourslabel)
|
|
ON_CBN_CLOSEUP(IDC_TECHLIST, OnCloseupTechlist)
|
|
ON_CBN_CLOSEUP(IDC_TYPE, OnCloseupType)
|
|
ON_EN_KILLFOCUS(IDC_TRAVEL, OnKillfocusTravel)
|
|
ON_EN_KILLFOCUS(IDC_START, OnKillfocusStart)
|
|
ON_BN_CLICKED(IDC_ONSITE, OnOnsite)
|
|
ON_EN_KILLFOCUS(IDC_NC, OnKillfocusNc)
|
|
ON_EN_KILLFOCUS(IDC_INVOICENUM, OnKillfocusInvoicenum)
|
|
ON_EN_KILLFOCUS(IDC_GENERALNOTES, OnKillfocusGeneralnotes)
|
|
ON_EN_KILLFOCUS(IDC_END, OnKillfocusEnd)
|
|
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATEPICKER, OnDatetimechangeDatepicker)
|
|
ON_CBN_CLOSEUP(IDC_CLIENTLIST, OnCloseupClientlist)
|
|
ON_EN_KILLFOCUS(IDC_BILL, OnKillfocusBill)
|
|
ON_BN_CLICKED(IDC_LBLCONTRACT, OnLblcontract)
|
|
ON_EN_KILLFOCUS(IDC_EDCLIENTCONTACT, OnKillfocusEdclientcontact)
|
|
ON_EN_KILLFOCUS(IDC_EDCLIENTREFNUM, OnKillfocusEdclientrefnum)
|
|
ON_COMMAND(ID_QUICKWO_DONE, OnQuickwoDone)
|
|
ON_COMMAND(ID_QUICKWO_CLIENTNOTES, OnQuickwoClientnotes)
|
|
ON_COMMAND(ID_QUICKWO_DELETE, OnQuickwoDelete)
|
|
ON_COMMAND(ID_QUICKWO_PRINT, OnQuickwoPrint)
|
|
ON_COMMAND(ID_QUICKWO_PRINT_DISPATCH, OnQuickwoPrintDispatch)
|
|
ON_EN_KILLFOCUS(IDC_EDOURREFNUMBER2, OnKillfocusEdourrefnumber2)
|
|
ON_CBN_CLOSEUP(IDC_CBSTATUS, OnCloseupCbstatus)
|
|
ON_BN_CLICKED(IDC_HISTORY, OnHistory)
|
|
ON_BN_CLICKED(IDC_LBLTECHNOTES, OnLbltechnotes)
|
|
ON_COMMAND(ID_QUICKWO_COSTATUS, OnQuickwoCostatus)
|
|
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DATEPICKER2, OnDatetimechangeDatepicker2)
|
|
ON_BN_CLICKED(IDC_TRAVELRATELABEL, OnTravelratelabel)
|
|
//}}AFX_MSG_MAP
|
|
ON_EN_KILLFOCUS(IDC_ED_DISTANCE, OnEnKillfocusEdDistance)
|
|
ON_COMMAND_RANGE( _STARTING_PRINT_COMMAND_ID, _STARTING_PRINT_COMMAND_ID+100, OnPrintReport )
|
|
ON_BN_CLICKED(IDC_LBLSTATUS, OnStatuslabel)
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSimpleWODlg message handlers afx_msg void OnPrintReport( UINT nID );
|
|
|
|
|
|
BOOL CSimpleWODlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
m_resize.Create( this );
|
|
m_resize.Add(IDC_GENERALNOTES,0,0,0,90);
|
|
//Use the current width and height as the minimum size
|
|
m_resize.SetMinimumTrackingSize();
|
|
Security();
|
|
bool bIsNew=false;
|
|
|
|
CMenu* pMenu=this->GetMenu();
|
|
CWaitCursor WAITING;
|
|
//if(!m_pApp->m_bTech)
|
|
// AfxMessageBox("Not a tech");
|
|
ShowWindow(FALSE);
|
|
CString str,q;
|
|
long lData=0;
|
|
|
|
m_bTiming=false;
|
|
|
|
//Contract
|
|
m_lblContract.SetTextColor(RGB(255,0,0));
|
|
m_lblContract.SetFontUnderline(TRUE);
|
|
m_lblContract.SetFontBold(TRUE);
|
|
m_lblContract.SetLink(TRUE);
|
|
m_lblContract.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblContract.SetLinkURL("");
|
|
|
|
|
|
//Tech notes
|
|
m_lblTechNotes.SetTextColor(RGB(255,0,0));
|
|
m_lblTechNotes.SetFontUnderline(TRUE);
|
|
m_lblTechNotes.SetFontBold(TRUE);
|
|
m_lblTechNotes.SetLink(TRUE);
|
|
m_lblTechNotes.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblTechNotes.SetLinkURL("");
|
|
|
|
|
|
m_lblHistory.SetTextColor(RGB(0,0,255));
|
|
m_lblHistory.SetFontUnderline(TRUE);
|
|
m_lblHistory.SetLink(TRUE);
|
|
m_lblHistory.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblHistory.SetLinkURL("");
|
|
|
|
//Category hyperlink
|
|
m_lblCategory.SetTextColor(RGB(0,0,255));
|
|
m_lblCategory.SetFontUnderline(TRUE);
|
|
m_lblCategory.SetLink(TRUE);
|
|
m_lblCategory.SetLinkCursor(m_pApp->hcHand);
|
|
//empty url means it will not launch explorer
|
|
//and can be used as a button instead
|
|
m_lblCategory.SetLinkURL("");
|
|
|
|
//Rates dialog hyperlink
|
|
m_lblRate.SetTextColor(RGB(0,0,255));
|
|
m_lblRate.SetFontUnderline(TRUE);
|
|
m_lblRate.SetLink(TRUE);
|
|
m_lblRate.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblRate.SetLinkURL("");
|
|
|
|
//Travel Rates dialog hyperlink
|
|
m_lblTravelRate.SetTextColor(RGB(0,0,255));
|
|
m_lblTravelRate.SetFontUnderline(TRUE);
|
|
m_lblTravelRate.SetLink(TRUE);
|
|
m_lblTravelRate.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblTravelRate.SetLinkURL("");
|
|
|
|
//Clients dialog hyperlink
|
|
m_lblClients.SetTextColor(RGB(0,0,255));
|
|
m_lblClients.SetFontUnderline(TRUE);
|
|
m_lblClients.SetLink(TRUE);
|
|
m_lblClients.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblClients.SetLinkURL("");
|
|
|
|
//v1.9.3.0 Status dialog hyperlink
|
|
m_lblStatus.SetTextColor(RGB(0,0,255));
|
|
m_lblStatus.SetFontUnderline(TRUE);
|
|
m_lblStatus.SetLink(TRUE);
|
|
m_lblStatus.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblStatus.SetLinkURL("");
|
|
|
|
//fill combo boxes
|
|
FillClientList();
|
|
FillRatesList();
|
|
FillWOTypesList();
|
|
FillTechList();
|
|
FillStatusList();
|
|
FillReportList();
|
|
|
|
//AfxMessageBox(m_cbTechList.GetCurrentRowID());
|
|
//client contact info display
|
|
m_lblContactInfo.SetFontBold(TRUE);
|
|
m_lblContactInfo.SetFontSize(12);
|
|
|
|
//CREATE A NEW WORKORDER IF WERE NOT EDITING AN OLD ONE
|
|
if(m_strWorkorderID=="0")
|
|
{
|
|
//v1.9.4.4 - fix for no techs and trying to make a new work order
|
|
if(m_cbTechList.GetCount()==0)
|
|
{
|
|
//ABORT, no tech
|
|
AfxMessageBox("There are no active technicians available!\r\n\r\n"
|
|
"A work order can not be created until there is an active technician\r\n"
|
|
"entered.\r\n\r\n"
|
|
"(Use the: Options->Edit->Users&Rights menu sequence.)\r\n",MB_ICONSTOP);
|
|
CDialog::OnCancel();
|
|
return FALSE;
|
|
|
|
}
|
|
bIsNew=true;
|
|
//start a new workorder:
|
|
COleDateTime dtData;
|
|
dtData=COleDateTime::GetCurrentTime();
|
|
q.Format("INSERT INTO wo ( creator, created, modifier, modified ) "
|
|
"SELECT %u, #%s#,%u, #%s#;",m_pApp->m_lusrID,dtData.Format(_T("%m/%d/%Y %H:%M:%S")),m_pApp->m_lusrID,dtData.Format(_T("%m/%d/%Y %H:%M:%S")));
|
|
|
|
rs->Ex(q,&lData);
|
|
rs->Close();
|
|
m_strWorkorderID.Format("%u",lData);
|
|
m_strID.Format("%u",lData);
|
|
str.Format("Quick WO#: %s",m_strID);
|
|
SetWindowText(str);
|
|
// str="Quick Workorder - "+ m_pApp->m_strCurrentUserName;
|
|
// SetWindowText(str);
|
|
m_dtDate.SetTime(dtData);
|
|
m_edNCHours.SetWindowText("0");
|
|
m_edTravelHours.SetWindowText("0");
|
|
m_edDistance.SetWindowText("0");
|
|
m_edBillHours.SetWindowText("0");
|
|
m_edStart.SetWindowText("12:00");
|
|
m_edEnd.SetWindowText("12:00");
|
|
//SET USER DEFAULTS
|
|
m_ckOnsite.SetCheck(m_pApp->m_bDefOnsite ? TRUE : FALSE);
|
|
m_cbRates.Select(m_pApp->m_lUsersDefRate);
|
|
m_cbTravelRates.Select(m_pApp->m_lUsersDefTravelRate);
|
|
|
|
// SET THE DEFAULT STATUS of this new workorder
|
|
m_cbStatus.Select(m_pApp->m_lDefNewWOStatus);
|
|
|
|
pMenu->ModifyMenu(ID_QUICKWO_DELETE,MF_BYCOMMAND,ID_QUICKWO_DELETE,"Cancel add");
|
|
|
|
}
|
|
else//yes we are editing, fill in the fields
|
|
{
|
|
//no timer if editing.!@#$@!#$!
|
|
m_btnTimer.ShowWindow(FALSE);
|
|
FillFields();
|
|
FillRatesList();
|
|
|
|
}
|
|
|
|
if(m_bEditing)
|
|
Check4Contract(false);
|
|
/////////ShowWindow(SW_SHOWMAXIMIZED);
|
|
//===================================================
|
|
// 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);
|
|
//===================================================
|
|
//added 6/24/2001 to avoid mouse wheel accidental cust change when viewing only
|
|
if(bIsNew)
|
|
m_cbClients.SetFocus();
|
|
else
|
|
m_edDetails.SetFocus();
|
|
return FALSE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CSimpleWODlg::FillClientList()
|
|
{
|
|
|
|
|
|
CString strData;
|
|
CString strIndex;
|
|
CString strHead,q;
|
|
long lData;
|
|
m_cbClients.Clear();
|
|
m_cbClients.AddRow(" <choose client>","0");
|
|
lData=0;
|
|
|
|
q.Format("SELECT clients.id, clients.company AS compname FROM clients WHERE (((clients.isheadoffice)=False)) "
|
|
"ORDER BY clients.company;");
|
|
cbrs->QueryReadOnly(q);
|
|
|
|
|
|
|
|
|
|
|
|
if(!cbrs->IsEmpty())
|
|
{
|
|
//fill combo box with available clients
|
|
VERIFY(cbrs->MoveFirst());
|
|
VERIFY(cbrs->FetchField("compname",&strData));
|
|
VERIFY(cbrs->FetchField("id",&lData));
|
|
strIndex.Format("%u",lData);
|
|
m_cbClients.AddRow(strData,strIndex);
|
|
while(cbrs->MoveForward())
|
|
{
|
|
VERIFY(cbrs->FetchField("compname",&strData));
|
|
VERIFY(cbrs->FetchField("id",&lData));
|
|
strIndex.Format("%u",lData);
|
|
m_cbClients.AddRow(strData,strIndex);
|
|
}
|
|
|
|
m_cbClients.SetCurSel(0);
|
|
|
|
}//is no records?
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::FillRatesList()
|
|
{
|
|
//fill travel and regular rates list boxes
|
|
CString strData;
|
|
CString strIndex;
|
|
long lData;
|
|
bool bData,bActive;
|
|
m_cbTravelRates.Clear();
|
|
m_cbRates.Clear();
|
|
cbrs->QueryReadOnly("SELECT rates.* FROM rates ORDER BY rates.name;");
|
|
if(!cbrs->IsEmpty())
|
|
{
|
|
//fill combo box with available RATES
|
|
|
|
|
|
do
|
|
{
|
|
cbrs->FetchField("travelrate",&bData);
|
|
cbrs->FetchField("name",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
cbrs->FetchField("active",&bActive);
|
|
strIndex.Format("%u",lData);
|
|
|
|
if(bData==true)//it's a travel rate
|
|
{
|
|
if(bActive)
|
|
m_cbTravelRates.AddRow(strData,strIndex);
|
|
else
|
|
{
|
|
if(m_strSelectedTravelRate==strIndex)//inactive but selected
|
|
{
|
|
strData="<NA> " + strData;
|
|
m_cbTravelRates.AddRow(strData,strIndex);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
else//it's a standard rate
|
|
{
|
|
if(bActive)
|
|
m_cbRates.AddRow(strData,strIndex);
|
|
else
|
|
{
|
|
if(m_strSelectedRate==strIndex)//inactive but selected
|
|
{
|
|
strData="<NA> " + strData;
|
|
m_cbRates.AddRow(strData,strIndex);
|
|
|
|
}
|
|
}
|
|
}
|
|
}while(cbrs->MoveForward());
|
|
|
|
|
|
|
|
//select default rate
|
|
if(m_strSelectedRate.IsEmpty())
|
|
{
|
|
m_cbRates.SetCurSel(0);
|
|
m_strSelectedRate=m_cbRates.GetCurrentRowID();
|
|
}
|
|
else
|
|
m_cbRates.Select(m_strSelectedRate);
|
|
|
|
//select default travel rate
|
|
if(m_strSelectedTravelRate.IsEmpty())
|
|
{
|
|
m_cbTravelRates.SetCurSel(0);
|
|
m_strSelectedTravelRate=m_cbTravelRates.GetCurrentRowID();
|
|
}
|
|
else
|
|
m_cbTravelRates.Select(m_strSelectedTravelRate);
|
|
|
|
}
|
|
}
|
|
|
|
void CSimpleWODlg::FillWOTypesList()
|
|
{
|
|
CString strData;
|
|
CString strIndex;
|
|
long lData;
|
|
m_cbTypes.Clear();
|
|
m_cbTypes.AddRow("< No category >","0");
|
|
cbrs->QueryReadOnly("SELECT wotypes.* FROM wotypes ORDER BY wotypes.category;");
|
|
if(!cbrs->IsEmpty())
|
|
{
|
|
//fill combo box with available categories
|
|
cbrs->MoveFirst();
|
|
cbrs->FetchField("category",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
m_cbTypes.AddRow(strData,strIndex);
|
|
while(cbrs->MoveForward())
|
|
{
|
|
cbrs->FetchField("category",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
m_cbTypes.AddRow(strData,strIndex);
|
|
}
|
|
|
|
m_cbTypes.SetCurSel(0);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSimpleWODlg::OnTimer()
|
|
{
|
|
CString str;
|
|
double secs;
|
|
COleDateTimeSpan sp;
|
|
if(!m_bTiming)//then start the timer
|
|
{
|
|
//see if there is a start time already
|
|
m_edStart.GetWindowText(str);
|
|
if(!str.IsEmpty())
|
|
{
|
|
if(AfxMessageBox("Reset start time and start timer?\r\nAre you sure?",MB_YESNO)==IDNO)
|
|
return;
|
|
}
|
|
|
|
dt1=COleDateTime::GetCurrentTime();
|
|
str=dt1.Format(VAR_TIMEVALUEONLY);
|
|
m_edStart.SetWindowText(str);
|
|
m_edEnd.SetWindowText("Timing...");
|
|
m_btnTimer.SetWindowText("Stop timer");
|
|
m_lblEnd.SetFontBold(TRUE);
|
|
m_lblEnd.SetTextColor(RGB(255,0,0));
|
|
m_lblEnd.FlashText(TRUE);
|
|
m_bTiming=true;
|
|
}
|
|
else//stop the timer
|
|
{
|
|
dt2=COleDateTime::GetCurrentTime();
|
|
str=dt2.Format(VAR_TIMEVALUEONLY);
|
|
m_edEnd.SetWindowText(str);
|
|
m_btnTimer.SetWindowText("Timer");
|
|
m_lblEnd.SetFontBold(FALSE);
|
|
m_lblEnd.SetTextColor(RGB(0,0,0));
|
|
m_lblEnd.FlashText(FALSE);
|
|
m_bTiming=false;
|
|
sp=dt2-dt1;
|
|
secs=sp.GetTotalMinutes();
|
|
secs=secs/60;
|
|
//strData.Format("%g",fData);
|
|
//01/31/2003 localization fix for floats
|
|
//convert float to localized string
|
|
m_edBillHours.SetWindowText(FtoA(secs));
|
|
}
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::OnLabelCategory()
|
|
{
|
|
CString str;
|
|
CWOTypesDlg d;
|
|
d.SetReturnString(&str);
|
|
if(d.DoModal()==IDOK)
|
|
{
|
|
//fill category list
|
|
FillWOTypesList();
|
|
//select str string;
|
|
m_cbTypes.Select(str);
|
|
}
|
|
}
|
|
|
|
void CSimpleWODlg::OnRateLabel()
|
|
{
|
|
|
|
CRatesDlg d;
|
|
if(d.DoModal()==IDOK)
|
|
FillRatesList();
|
|
|
|
}
|
|
|
|
|
|
//****************************************
|
|
void CSimpleWODlg::OnClientlistLabel()
|
|
{
|
|
CString str;
|
|
CClientsDlg d;
|
|
d.SetReturnString(&str);
|
|
//Added 08/28/2001 to pre-select client on clients screen
|
|
d.m_strForceSelection=m_strSelClient;
|
|
if(d.DoModal()==IDOK)
|
|
{
|
|
FillClientList();
|
|
m_cbClients.Select(str);
|
|
}
|
|
//FillFields();
|
|
}
|
|
//----------------------------------------
|
|
|
|
//********************************
|
|
void CSimpleWODlg::OnOK()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
//*************************************************
|
|
//Pass in ID of workorder we want to edit/display
|
|
void CSimpleWODlg::SetWorkorderID(CString *pstrWOID)
|
|
{
|
|
|
|
//set the workorder to display
|
|
m_strWorkorderID=*pstrWOID;
|
|
//flag that were in editing mode
|
|
if(m_strWorkorderID!="0") m_bEditing=true;
|
|
}
|
|
|
|
void CSimpleWODlg::OnCloseupTravelrateslist()
|
|
{
|
|
m_strSelectedTravelRate=m_cbTravelRates.GetCurrentRowID();
|
|
|
|
SaveField(&m_cbTravelRates,"travrate",rsLabor);
|
|
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::OnCloseupRateslist()
|
|
{
|
|
m_strSelectedRate=m_cbRates.GetCurrentRowID();
|
|
SaveField(&m_cbRates,"rate",rsLabor);
|
|
}
|
|
|
|
void CSimpleWODlg::OnTravelhourslabel()
|
|
{
|
|
//same deal whichever gets clicked
|
|
//FUTURE: make it only show travel rates
|
|
//and vice versa depending on what gets clicked
|
|
OnRateLabel();
|
|
}
|
|
|
|
|
|
//fill the fields if this is an editing workorder//
|
|
void CSimpleWODlg::FillFields()
|
|
{
|
|
if(!m_bEditing) return;
|
|
//m_strWorkorderID
|
|
CString q,strData,strProblemID;
|
|
bool bData;
|
|
float fData;
|
|
COleDateTime dtData;
|
|
long lData;
|
|
|
|
|
|
|
|
|
|
q.Format("SELECT wo.* FROM wo WHERE (((wo.id)=%s));",m_strWorkorderID);
|
|
rs->Query(q);
|
|
if(rs->IsEmpty())
|
|
{
|
|
AfxMessageBox("Can't find workorder record");
|
|
CDialog::OnOK();
|
|
return;
|
|
}
|
|
|
|
strData.Format("Quick WO#: %s",m_strWorkorderID);
|
|
SetWindowText(strData);
|
|
|
|
//OUR REFERENCE NUMBER
|
|
rs->FetchField("ourref",&strData);
|
|
m_edOurRefNum.SetWindowText(strData);
|
|
|
|
//STATUS
|
|
rs->FetchField("status",&lData);
|
|
strData.Format("%u",lData);
|
|
m_cbStatus.Select(strData);
|
|
|
|
//CLIENT
|
|
rs->FetchField("client",&lData);
|
|
strData.Format("%u",lData);
|
|
m_cbClients.Select(strData);
|
|
m_strSelClient=strData;
|
|
|
|
//CATEGORY
|
|
rs->FetchField("type",&lData);
|
|
strData.Format("%u",lData);
|
|
m_cbTypes.Select(strData);
|
|
|
|
//ONSITE
|
|
rs->FetchField("onsite",&bData);
|
|
m_ckOnsite.SetCheck(bData ? TRUE:FALSE);
|
|
|
|
/* //DATE
|
|
rs->FetchField("closed",&dtData);
|
|
m_dtDate.SetTime(dtData);
|
|
*/
|
|
|
|
//CLOSED/OPEN
|
|
rs->FetchField("closed",&dtData);
|
|
//commented out 10/11/2002 get from labor table instead
|
|
//m_dtDate.SetTime(dtData);
|
|
m_bIsOpen=false;
|
|
if(dtData.GetYear()==1968)//it's open
|
|
m_bIsOpen=true;
|
|
UpdateClosedOpen();
|
|
|
|
|
|
//****************
|
|
//commented out 10/11/2002, should get from labor table
|
|
//not workorder header table
|
|
|
|
////STARTTIME
|
|
//rs->FetchField("starttime",&dtData);
|
|
//strData=dtData.Format(VAR_TIMEVALUEONLY);
|
|
//m_edStart.SetWindowText(strData);
|
|
//
|
|
////STOPTIME
|
|
//rs->FetchField("stoptime",&dtData);
|
|
|
|
//added June 23 2001 to support end date values
|
|
//m_dtEndDate.SetTime(dtData);
|
|
//***********************
|
|
|
|
strData=dtData.Format(VAR_TIMEVALUEONLY);
|
|
m_edEnd.SetWindowText(strData);
|
|
|
|
//INVOICE NUMBER
|
|
rs->FetchField("invoice",&strData);
|
|
m_edInvoicedOn.SetWindowText(strData);
|
|
|
|
//CLIENT REFERENCE NUMBER
|
|
rs->FetchField("clientrefnum",&strData);
|
|
m_edClientRefNumber.SetWindowText(strData);
|
|
|
|
//CLIENT CONTACT
|
|
rs->FetchField("clientcontact",&strData);
|
|
m_edClientContact.SetWindowText(strData);
|
|
|
|
//FETCH THE PROBLEM RECORD FIELDS
|
|
q.Format("SELECT probs.* FROM probs WHERE (((probs.wolink)=%s));",m_strWorkorderID);
|
|
rsProb->Query(q);
|
|
if(rsProb->IsEmpty())
|
|
{
|
|
AfxMessageBox("Can't find workorder problem record\r\nThis quick workorder is damaged or incomplete.");
|
|
CDialog::OnOK();
|
|
return;
|
|
}
|
|
|
|
|
|
//get id
|
|
rsProb->FetchField("id",&lData);
|
|
strProblemID.Format("%u",lData);
|
|
|
|
|
|
//FETCH THE BILLABLE LABOUR RECORD
|
|
q.Format("SELECT labor.* FROM labor "
|
|
"LEFT JOIN rates ON labor.rate = rates.id "
|
|
"WHERE (((labor.link)=%s));",strProblemID);
|
|
|
|
rsLabor->Query(q);
|
|
if(rsLabor->IsEmpty())
|
|
return;
|
|
|
|
//START
|
|
rsLabor->FetchField("start",&dtData);
|
|
strData=dtData.Format(VAR_TIMEVALUEONLY);
|
|
m_edStart.SetWindowText(strData);
|
|
m_dtDate.SetTime(dtData);
|
|
|
|
//STOP
|
|
rsLabor->FetchField("stop",&dtData);
|
|
strData=dtData.Format(VAR_TIMEVALUEONLY);
|
|
m_edEnd.SetWindowText(strData);
|
|
m_dtEndDate.SetTime(dtData);
|
|
|
|
//HOURS
|
|
rsLabor->FetchField("hours",&fData);
|
|
//strData.Format("%g",fData);
|
|
//01/31/2003 localization fix for floats
|
|
//convert float to localized string
|
|
m_edBillHours.SetWindowText(FtoA(fData));
|
|
|
|
|
|
//NOCHARGE HOURS
|
|
rsLabor->FetchField("nchours",&fData);
|
|
//01/31/2003 localization fix for floats
|
|
//convert float to localized string
|
|
m_edNCHours.SetWindowText(FtoA(fData));
|
|
|
|
|
|
//TECHNICIAN
|
|
rsLabor->FetchField("tech",&lData);
|
|
m_strSelectedTech.Format("%u",lData);
|
|
FillTechList();
|
|
|
|
//RATE
|
|
rsLabor->FetchField("rate",&lData);
|
|
strData.Format("%u",lData);
|
|
m_strSelectedRate=strData;
|
|
m_cbRates.Select(strData);
|
|
|
|
|
|
//DETAILS
|
|
rsLabor->FetchField("details",&strData);
|
|
m_edDetails.SetWindowText(strData);
|
|
|
|
|
|
//TRAVEL HOURS
|
|
rsLabor->FetchField("travhours",&fData);
|
|
//01/31/2003 localization fix for floats
|
|
//convert float to localized string
|
|
m_edTravelHours.SetWindowText(FtoA(fData));
|
|
|
|
//TRAVEL RATE
|
|
rsLabor->FetchField("travrate",&lData);
|
|
strData.Format("%u",lData);
|
|
m_strSelectedTravelRate=strData;
|
|
m_cbTravelRates.Select(strData);
|
|
|
|
//DISTANCE
|
|
rsLabor->FetchField("distance",&fData);
|
|
//01/31/2003 localization fix for floats
|
|
//convert float to localized string
|
|
m_edDistance.SetWindowText(FtoA(fData));
|
|
|
|
q.Format("SELECT wo.* FROM wo WHERE (((wo.id)=%s));",m_strWorkorderID);
|
|
rs->Query(q);
|
|
|
|
DisplayContactInfo();
|
|
}
|
|
|
|
void CSimpleWODlg::FillTechList()
|
|
{
|
|
//10/03/00 - fix for the licensing problem
|
|
//if the m_strSelected tech isn't in the list then
|
|
//add it "manually" after filling the list as normal
|
|
//like this: "* Bob Jones (inactive)"
|
|
|
|
|
|
CString strData;
|
|
CString strIndex;
|
|
CString q;
|
|
long lData;
|
|
m_cbTechList.Clear();
|
|
//look for selected tech and see if in inactive list:
|
|
if(!m_strSelectedTech.IsEmpty())
|
|
{
|
|
q.Format("SELECT users.id, [last] & \", \" & [first] AS fullname "
|
|
"FROM users "
|
|
"WHERE (((users.id)=%s) AND ((users.active)=False));",m_strSelectedTech);
|
|
cbrs->QueryReadOnly(q);
|
|
if(!cbrs->IsEmpty()) //it's an inactive tech put them in the list "manually"
|
|
{
|
|
cbrs->FetchField("fullname",&strData);
|
|
cbrs->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);
|
|
|
|
cbrs->QueryReadOnly(q);
|
|
if(!cbrs->IsEmpty())
|
|
{
|
|
cbrs->MoveFirst();
|
|
cbrs->FetchField("fullname",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
m_cbTechList.AddRow(strData,strIndex);
|
|
while(cbrs->MoveForward())
|
|
{
|
|
cbrs->FetchField("fullname",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
m_cbTechList.AddRow(strData,strIndex);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if(!m_strSelectedTech.IsEmpty())
|
|
m_cbTechList.Select(m_strSelectedTech);
|
|
else
|
|
{//attempt to select by current user id
|
|
m_strSelectedTech.Format("%u",m_pApp->m_lusrID);
|
|
m_cbTechList.Select(m_strSelectedTech);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::OnCloseupTechlist()
|
|
{
|
|
|
|
m_strSelectedTech=m_cbTechList.GetCurrentRowID();
|
|
SaveField(&m_cbTechList,"tech",rsLabor);
|
|
//added 10/10/2002 to ensure that main workorder list view
|
|
//shows the tech assigned to the workorder
|
|
SaveField(&m_cbTechList,"assigntech",rs);
|
|
//v1.9.4.4 to set rate based on selected tech, not current user id
|
|
SetClientRates();
|
|
}
|
|
|
|
void CSimpleWODlg::OnCloseupType()
|
|
{
|
|
|
|
SaveField(&m_cbTypes,"type",rs);
|
|
|
|
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::OnKillfocusTravel()
|
|
{
|
|
|
|
if(m_edTravelHours.GetModify()==FALSE) return;
|
|
|
|
CString strData;
|
|
float fData;
|
|
|
|
m_edTravelHours.GetWindowText(strData);
|
|
//02/19/2003 Fix crash on empty field
|
|
if(strData.IsEmpty()) strData="0";
|
|
//01/31/2003 convert to a variant bstr
|
|
_variant_t vtData(strData);
|
|
//fData=(float)vtData;//cast will cause variant to convert to float using locale specific routine
|
|
|
|
//v1.9.4.4 added try / catch mechanism to catch dumb-asses entering text in a numeric field
|
|
try{
|
|
fData=(float)vtData;//cast variant to float (locale friendly)
|
|
}
|
|
catch( _com_error &e )
|
|
{
|
|
|
|
AfxMessageBox("I could not interpret your entry in the Travel hours 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_edTravelHours.Undo();
|
|
m_edTravelHours.SetModify(FALSE);
|
|
m_edTravelHours.SetFocus();
|
|
return;
|
|
}
|
|
|
|
if(!m_bEditing) return;
|
|
rsLabor->UpdateField("travhours",&fData);
|
|
rsLabor->SaveRecord();
|
|
m_edTravelHours.SetModify(FALSE);
|
|
|
|
}
|
|
|
|
|
|
void CSimpleWODlg::OnEnKillfocusEdDistance()
|
|
{
|
|
if( m_edDistance.GetModify()==FALSE) return;
|
|
|
|
CString strData;
|
|
float fData;
|
|
|
|
m_edDistance.GetWindowText(strData);
|
|
//02/19/2003 Fix crash on empty field
|
|
if(strData.IsEmpty()) strData="0";
|
|
//01/31/2003 convert to a variant bstr
|
|
_variant_t vtData(strData);
|
|
//fData=(float)vtData;//cast variant to float (locale friendly)
|
|
|
|
//v1.9.4.4 added try / catch mechanism to catch dumb-asses entering text in a numeric field
|
|
try{
|
|
fData=(float)vtData;//cast variant to float (locale friendly)
|
|
}
|
|
catch( _com_error &e )
|
|
{
|
|
|
|
AfxMessageBox("I could not interpret your entry in the Distance 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_edDistance.Undo();
|
|
m_edDistance.SetModify(FALSE);
|
|
m_edDistance.SetFocus();
|
|
return;
|
|
}
|
|
|
|
//v1.9.4.4 moved down to here so validation occurs even on a new record
|
|
if(!m_bEditing) return;
|
|
rsLabor->UpdateField("distance",&fData);
|
|
rsLabor->SaveRecord();
|
|
m_edDistance.SetModify(FALSE);
|
|
}
|
|
|
|
void CSimpleWODlg::OnKillfocusStart()
|
|
{
|
|
//test 10/11/2002, required for saving properly now
|
|
//if(m_edStart.GetModify()==FALSE) return;
|
|
|
|
COleDateTime dtDate,dtTime;
|
|
m_dtDate.GetTime(dtDate);
|
|
CString strData;
|
|
m_edStart.GetWindowText(strData);
|
|
if(dtTime.ParseDateTime(strData,VAR_TIMEVALUEONLY)==FALSE)
|
|
{
|
|
AfxMessageBox("Invalid time entered.\r\n"
|
|
"You can enter time in many ways\r\n"
|
|
"We find it faster to use the period\r\n"
|
|
"symbol rather than a colon during entry.\r\n\r\n"
|
|
"Here are some examples of valid entry:\r\n"
|
|
"22.23 is interpreted as 10:00pm\r\n"
|
|
"9.0 = 9:00am\r\n"
|
|
"4.3p = 4:03pm\r\n"
|
|
"good old fashioned 12:30 still = 12:30pm\r\n"
|
|
"Outside north america valid entries\r\n"
|
|
"for your locale may be different");
|
|
return;
|
|
}
|
|
|
|
|
|
strData=dtTime.Format(VAR_TIMEVALUEONLY);
|
|
m_edStart.SetWindowText(strData);
|
|
|
|
if(!m_bEditing) return ;//dont attempt to update
|
|
|
|
|
|
//REMOVED following block 10/11/2002
|
|
//to use labor table for dates exclusively now
|
|
//save the time only value in the workorder header
|
|
//rs->UpdateField("starttime",&dtTime);
|
|
//rs->SaveRecord();
|
|
|
|
//save the complete date/time in the labor record. Guichy!
|
|
dtTime.SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
|
rsLabor->UpdateField("start",&dtTime);
|
|
rsLabor->SaveRecord();
|
|
|
|
m_edStart.SetModify(FALSE);
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::OnOnsite()
|
|
{
|
|
SaveField(&m_ckOnsite,"onsite",rs);
|
|
}
|
|
|
|
void CSimpleWODlg::OnKillfocusNc()
|
|
{
|
|
if( m_edNCHours.GetModify()==FALSE) return;
|
|
CString strData;
|
|
float fData;
|
|
//NOCHARGE HOURS
|
|
m_edNCHours.GetWindowText(strData);
|
|
//02/19/2003 Fix crash on empty field
|
|
if(strData.IsEmpty()) strData="0";
|
|
//01/31/2003 convert to a variant bstr
|
|
_variant_t vtData(strData);
|
|
//fData=(float)vtData;//cast variant to float (locale friendly)
|
|
|
|
//v1.9.4.4 added try / catch mechanism to catch dumb-asses entering text in a numeric field
|
|
try{
|
|
fData=(float)vtData;//cast variant to float (locale friendly)
|
|
}
|
|
catch( _com_error &e )
|
|
{
|
|
|
|
AfxMessageBox("I could not interpret your entry in the No charge hours 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_edNCHours.Undo();
|
|
m_edNCHours.SetModify(FALSE);
|
|
m_edNCHours.SetFocus();
|
|
return;
|
|
}
|
|
//v1.9.4.4 moved down to here so validation occurs even on a new record
|
|
if(!m_bEditing) return;
|
|
|
|
rsLabor->UpdateField("nchours",&fData);
|
|
rsLabor->SaveRecord();
|
|
m_edNCHours.SetModify(FALSE);
|
|
}
|
|
|
|
void CSimpleWODlg::OnKillfocusInvoicenum()
|
|
{
|
|
SaveField(&m_edInvoicedOn,"invoice",true,rs);
|
|
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::OnKillfocusGeneralnotes()
|
|
{
|
|
//DETAILS
|
|
SaveField(&m_edDetails,"details",true,rsLabor);
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::OnKillfocusEnd()
|
|
{
|
|
//wo=stoptime,labor=stop
|
|
|
|
|
|
|
|
//no changes then don't bother
|
|
//removed 06/23/01 to support end date
|
|
//because this is called when the end date is changed to handle both end date
|
|
//and end time
|
|
//if(m_edEnd.GetModify()!=TRUE) return;
|
|
|
|
|
|
|
|
COleDateTime dtDate,dtTime;
|
|
m_dtEndDate.GetTime(dtDate);
|
|
CString strData;
|
|
m_edEnd.GetWindowText(strData);
|
|
|
|
if(dtTime.ParseDateTime(strData,VAR_TIMEVALUEONLY)==FALSE)
|
|
{
|
|
AfxMessageBox("Invalid time entered.\r\n"
|
|
"You can enter time in many ways\r\n"
|
|
"We find it faster to use the period\r\n"
|
|
"symbol rather than a colon during entry.\r\n\r\n"
|
|
"Here are some examples of valid entry:\r\n"
|
|
"22.23 is interpreted as 10:00pm\r\n"
|
|
"9.0 = 9:00am\r\n"
|
|
"4.3p = 4:03pm\r\n"
|
|
"good old fashioned 12:30 still = 12:30pm\r\n"
|
|
"Outside north america valid entries\r\n"
|
|
"for your locale may be different");
|
|
return;
|
|
}
|
|
|
|
strData=dtTime.Format(VAR_TIMEVALUEONLY);
|
|
m_edEnd.SetWindowText(strData);
|
|
if(!m_bEditing) return ;//dont attempt to update
|
|
|
|
//moved up here 06/23/01 to save full date and time info in both woheader and labour
|
|
dtTime.SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
|
//save the time (and now date value 6/23/01) in the workorder header
|
|
//rs->UpdateField("stoptime",&dtTime);
|
|
//rs->SaveRecord();
|
|
//save the complete date/time in the labor record. Guichy!
|
|
//dtTime.SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
|
rsLabor->UpdateField("stop",&dtTime);
|
|
rsLabor->SaveRecord();
|
|
|
|
m_edEnd.SetModify(FALSE);
|
|
|
|
}
|
|
|
|
//start date
|
|
void CSimpleWODlg::OnDatetimechangeDatepicker(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
COleDateTime dtData;
|
|
m_dtDate.GetTime(dtData);
|
|
m_dtEndDate.SetTime(dtData);
|
|
|
|
SaveField(&m_dtDate,"closed",rs);
|
|
SaveField(&m_dtDate,"created",rs);
|
|
|
|
//SaveField(&m_dtDate,"closed",rs);
|
|
|
|
//TEST 10/11/2002
|
|
OnKillfocusStart();
|
|
//added July 20 2001 as end date still not being saved
|
|
OnKillfocusEnd();
|
|
*pResult = 0;
|
|
}
|
|
|
|
//end date
|
|
void CSimpleWODlg::OnDatetimechangeDatepicker2(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
|
|
OnKillfocusEnd();
|
|
*pResult = 0;
|
|
}
|
|
|
|
|
|
void CSimpleWODlg::OnCloseupClientlist()
|
|
{
|
|
if(m_cbClients.GetCurrentRowID()=="0") return;
|
|
if(m_bAlertPopup)
|
|
return;
|
|
//Added check to avoid repetition if client not changed
|
|
CString strData;
|
|
strData=m_cbClients.GetCurrentRowID();
|
|
if(strData==m_strSelClient) return;
|
|
|
|
m_strSelClient=m_cbClients.GetCurrentRowID();
|
|
|
|
|
|
|
|
SaveField(&m_cbClients,"client",rs);
|
|
Check4Contract(true);
|
|
SetClientRates();
|
|
DisplayContactInfo();
|
|
//Added 10/17/2002 to ensure correct client is selected after a popup
|
|
//reason being that popping up a dialog box kills focus on the client drop down
|
|
//which hasn't fully finished updating yet
|
|
//this cased one of our clients to send a tech to Montreal instead of Toronto
|
|
//as the previously selected client remained due to the popup causing
|
|
//the list box to not update to the new client
|
|
m_cbClients.Select(m_strSelClient);
|
|
}
|
|
|
|
void CSimpleWODlg::OnKillfocusBill()
|
|
{
|
|
if(m_edBillHours.GetModify()==FALSE) return;
|
|
CString strData;
|
|
float fData;
|
|
|
|
m_edBillHours.GetWindowText(strData);
|
|
//02/19/2003 Fix crash on empty field
|
|
if(strData.IsEmpty()) strData="0";
|
|
//01/31/2003 convert to a variant bstr
|
|
_variant_t vtData(strData);
|
|
try{//v1.9.4.4 added try / catch mechanism to catch dumb-asses entering text in a numeric field
|
|
fData=(float)vtData;//cast variant to float (locale friendly)
|
|
}
|
|
catch( _com_error &e )
|
|
{
|
|
|
|
AfxMessageBox("I could not interpret your entry in the Billable hours 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_edBillHours.Undo();
|
|
m_edBillHours.SetModify(FALSE);
|
|
m_edBillHours.SetFocus();
|
|
return;
|
|
}
|
|
|
|
//v1.9.4.4 moved down to here so validation occurs even on a new record
|
|
if(!m_bEditing) return;
|
|
|
|
|
|
rsLabor->UpdateField("hours",&fData);
|
|
rsLabor->SaveRecord();
|
|
m_edBillHours.SetModify(FALSE);
|
|
}
|
|
|
|
|
|
|
|
|
|
//************************************************************
|
|
//SAVE EDIT CONTROL FIELD
|
|
//************************************************************
|
|
bool CSimpleWODlg::SaveField(CEdit *edControl,CString fldname,bool AllowEmpty,GZRset* rsSet)
|
|
{
|
|
|
|
if(!m_bEditing) 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;
|
|
}
|
|
}
|
|
|
|
|
|
rsSet->UpdateField(fldname,&str);
|
|
rsSet->SaveRecord();
|
|
UpdateModified();
|
|
edControl->SetModify(FALSE);
|
|
return true;
|
|
}
|
|
|
|
//************************************************************
|
|
//SAVE GZCOMBO CONTROL FIELD
|
|
//************************************************************
|
|
bool CSimpleWODlg::SaveField(CgzCombo *cbControl,CString fldname,GZRset* rsSet)
|
|
{
|
|
|
|
if(!m_bEditing) 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);
|
|
rsSet->UpdateField(fldname,&lData);
|
|
rsSet->SaveRecord();
|
|
UpdateModified();
|
|
return true;
|
|
}
|
|
|
|
//************************************************************
|
|
//SAVE CheckBox CONTROL FIELD
|
|
//************************************************************
|
|
bool CSimpleWODlg::SaveField(CButton *ckControl,CString fldname,GZRset* rsSet)
|
|
{
|
|
if(!m_bEditing) return true;//dont attempt to update
|
|
bool bData=false;
|
|
BOOL BData;
|
|
BData=ckControl->GetCheck();
|
|
if(BData==TRUE) bData=true;
|
|
rsSet->UpdateField(fldname,&bData);
|
|
rsSet->SaveRecord();
|
|
UpdateModified();
|
|
return true;
|
|
}
|
|
//************************************************************
|
|
//SAVE DateTimePicker CONTROL FIELD
|
|
//************************************************************
|
|
bool CSimpleWODlg::SaveField(CDateTimeCtrl *dtControl,CString fldname,GZRset* rsSet)
|
|
{
|
|
if(!m_bEditing) return true;//dont attempt to update
|
|
COleDateTime dtData;
|
|
dtControl->GetTime(dtData);
|
|
rsSet->UpdateField(fldname,&dtData);
|
|
rsSet->SaveRecord();
|
|
UpdateModified();
|
|
return true;
|
|
}
|
|
|
|
|
|
//************************************************
|
|
//UPDATE MODIFIED DATA
|
|
//*************************************************
|
|
bool CSimpleWODlg::UpdateModified()
|
|
{
|
|
|
|
m_pApp->m_bRefreshStatScreen=true;
|
|
|
|
|
|
|
|
bool bIndexed=false;
|
|
//updates modified by and modified on fields
|
|
|
|
rs->UpdateField("modifier",&m_pApp->m_lusrID);
|
|
COleDateTime dtData;
|
|
dtData=COleDateTime::GetCurrentTime();
|
|
rs->UpdateField("modified",&dtData);
|
|
|
|
//flag as now not indexed any longer
|
|
//note: may not be true if the labour
|
|
//table parts of this wo were not modified, but
|
|
//who cares, this is simpler and wont make much
|
|
//difference in the big picture.
|
|
rsLabor->UpdateField("indexed",&bIndexed);
|
|
rsLabor->SaveRecord();
|
|
rs->SaveRecord();
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//checks for contract and also checks for tech notes and also popup alert message
|
|
|
|
void CSimpleWODlg::Check4Contract(bool bAlert)
|
|
{
|
|
CString q,client,strAlert;
|
|
client=m_cbClients.GetCurrentRowID();
|
|
long lContract,lHeadOffice;
|
|
//check for contract
|
|
m_lblContract.ShowWindow(FALSE);
|
|
m_strClientContractID.Empty();
|
|
//See if client has a contract
|
|
//if so, this will supersede head office so
|
|
//get contract number and return
|
|
q.Format("SELECT [clients].[contract], [clients].[headoffice], [clients].[technotes], [clients].[alert] "
|
|
"FROM clients WHERE ((([clients].[id])=%s) And "
|
|
"(([clients].[isheadoffice])=False));",client);
|
|
cbrs->QueryReadOnly(q);
|
|
ASSERT(!cbrs->IsEmpty());
|
|
cbrs->FetchField("contract",&lContract);
|
|
cbrs->FetchField("headoffice",&lHeadOffice);
|
|
cbrs->FetchField("technotes",&m_strTechNotes);
|
|
cbrs->FetchField("alert",&strAlert);
|
|
if(bAlert)
|
|
{
|
|
if(!strAlert.IsEmpty())
|
|
{
|
|
m_bAlertPopup=true;
|
|
AfxMessageBox(strAlert);
|
|
m_bAlertPopup=false;
|
|
}
|
|
}
|
|
|
|
if(m_strTechNotes.IsEmpty())
|
|
m_lblTechNotes.ShowWindow(FALSE);
|
|
else
|
|
m_lblTechNotes.ShowWindow(TRUE);
|
|
|
|
|
|
if(lContract>0)
|
|
{
|
|
m_lblContract.ShowWindow(TRUE);
|
|
m_strClientContractID.Format("%u",lContract);
|
|
return;
|
|
}
|
|
if(lHeadOffice==0) return;//no head office no point in proceeding
|
|
|
|
//Client has no contract, but does have a head
|
|
//office which may have a contract...
|
|
q.Format("SELECT clients.contract "
|
|
"FROM clients WHERE (((clients.id)=%u));",lHeadOffice);
|
|
cbrs->QueryReadOnly(q);
|
|
ASSERT(!cbrs->IsEmpty());
|
|
cbrs->FetchField("contract",&lContract);
|
|
if(lContract>0)
|
|
{
|
|
m_lblContract.ShowWindow(TRUE);
|
|
m_strClientContractID.Format("%u",lContract);
|
|
}
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::OnLblcontract()
|
|
{
|
|
CString q,name,terms;
|
|
|
|
q.Format("SELECT contracts.name, contracts.terms FROM contracts "
|
|
"WHERE (((contracts.id)=%s));",m_strClientContractID);
|
|
cbrs->QueryReadOnly(q);
|
|
if(cbrs->IsEmpty())
|
|
{
|
|
AfxMessageBox("Contract is missing!");
|
|
return;
|
|
}
|
|
|
|
cbrs->FetchField("name",&name);
|
|
cbrs->FetchField("terms",&terms);
|
|
q.Format("Contract:\r\n%s\r\n\r\nTerms:\r\n%s",name,terms);
|
|
AfxMessageBox(q);
|
|
|
|
}
|
|
|
|
//Extensively modified for v1.9.4.4
|
|
//now sets rates based on selected tech not current users id
|
|
//also now skips changing settings if hours are non-zero
|
|
void CSimpleWODlg::SetClientRates()
|
|
{
|
|
|
|
|
|
CString q;
|
|
//Dont change a thing if hours were entered
|
|
m_edBillHours.GetWindowText(q);
|
|
if(q!="0") return;
|
|
|
|
//long lData;
|
|
long lClientDefRate,lClientDefTravelRate;
|
|
long lSelectedTechDefRate,lSelectedTechDefTravelRate;
|
|
|
|
|
|
//Get clients default rates
|
|
q.Format("SELECT clients.defrate, clients.deftravelrate "
|
|
"FROM clients "
|
|
"WHERE (((clients.id)=%s));",m_cbClients.GetCurrentRowID());
|
|
|
|
cbrs->QueryReadOnly(q);
|
|
if(cbrs->IsEmpty())
|
|
{
|
|
|
|
lClientDefRate=0;
|
|
lClientDefTravelRate=0;
|
|
}
|
|
else
|
|
{
|
|
cbrs->FetchField("defrate",&lClientDefRate);
|
|
cbrs->FetchField("deftravelrate",&lClientDefTravelRate);
|
|
}
|
|
cbrs->Close();
|
|
|
|
//Get selected tech's default rates
|
|
q.Format("SELECT users.defrate, users.deftravelrate "
|
|
"FROM users "
|
|
"WHERE (((users.id)=%s));",m_cbTechList.GetCurrentRowID());
|
|
|
|
cbrs->QueryReadOnly(q);
|
|
if(cbrs->IsEmpty())
|
|
{
|
|
|
|
lSelectedTechDefRate=0;
|
|
lSelectedTechDefTravelRate=0;
|
|
}
|
|
else
|
|
{
|
|
cbrs->FetchField("defrate",&lSelectedTechDefRate);
|
|
cbrs->FetchField("deftravelrate",&lSelectedTechDefTravelRate);
|
|
}
|
|
cbrs->Close();
|
|
|
|
|
|
|
|
//Set rate to client or selected tech as appropriate
|
|
|
|
if(lClientDefRate!=0)
|
|
m_cbRates.Select(lClientDefRate);
|
|
else
|
|
m_cbRates.Select(lSelectedTechDefRate);
|
|
|
|
|
|
//Set travel rate
|
|
if(lClientDefTravelRate!=0)
|
|
m_cbTravelRates.Select(lClientDefTravelRate);
|
|
else
|
|
m_cbTravelRates.Select(lSelectedTechDefTravelRate);//v1.9.4.4
|
|
|
|
|
|
|
|
}
|
|
|
|
bool CSimpleWODlg::SaveNewRecord()
|
|
{
|
|
|
|
m_pApp->m_bRefreshStatScreen=true;
|
|
|
|
long lData,lLink;
|
|
CString strData,q;
|
|
COleDateTime dtData,dtTime,dtDate,dtEndDate;
|
|
bool bData;
|
|
float fData;//single
|
|
if(m_cbClients.GetCurrentRowID()=="0")
|
|
{
|
|
AfxMessageBox("Please choose a client first");
|
|
return false;
|
|
|
|
}
|
|
|
|
rs->Close();
|
|
q.Format("SELECT wo.* FROM wo WHERE (((wo.id)=%s));",m_strWorkorderID);
|
|
rs->Query(q);
|
|
|
|
|
|
|
|
//otherwise save new record
|
|
|
|
//validate everything
|
|
|
|
//Save the workorder fields
|
|
|
|
//CLIENT
|
|
lData=atol(m_cbClients.GetCurrentRowID());
|
|
ASSERT(lData>0);
|
|
rs->UpdateField("client",&lData);
|
|
|
|
//CATEGORY
|
|
lData=atol(m_cbTypes.GetCurrentRowID());
|
|
rs->UpdateField("type",&lData);
|
|
|
|
//CLOSED - time workorder closed
|
|
//keep the date for later on processing
|
|
//m_dtDate.GetTime(dtDate);
|
|
//m_dtEndDate.GetTime(dtEndDate);
|
|
dtDate=COleDateTime::GetCurrentTime();
|
|
rs->UpdateField("closed",&dtDate);
|
|
rs->UpdateField("created",&dtDate);
|
|
|
|
//ONSITE
|
|
bData= m_ckOnsite.GetCheck() ? true:false;
|
|
rs->UpdateField("onsite",&bData);
|
|
|
|
//Following block commented out 10/11/2002
|
|
//fixed to use labor table times instead
|
|
////STARTTIME
|
|
//m_edStart.GetWindowText(strData);
|
|
//dtData.ParseDateTime(strData,VAR_TIMEVALUEONLY);
|
|
//rs->UpdateField("starttime",&dtData);
|
|
//
|
|
////STOPTIME
|
|
//m_edEnd.GetWindowText(strData);
|
|
//dtTime.ParseDateTime(strData,VAR_TIMEVALUEONLY);
|
|
//dtData.SetDateTime(dtEndDate.GetYear(),dtEndDate.GetMonth(),dtEndDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
|
//
|
|
//rs->UpdateField("stoptime",&dtData);
|
|
|
|
//QUICK - flag this as a quickie workorder
|
|
//so that it gets displayed on this screen
|
|
//when selected to view
|
|
bData=true;
|
|
rs->UpdateField("quick",&bData);
|
|
|
|
|
|
|
|
//INVOICE #
|
|
m_edInvoicedOn.GetWindowText(strData);
|
|
rs->UpdateField("invoice",&strData);
|
|
|
|
//CLIENT REFERENCE NUMBER
|
|
m_edClientRefNumber.GetWindowText(strData);
|
|
rs->UpdateField("clientrefnum",&strData);
|
|
|
|
//OUR REFERENCE NUMBER
|
|
m_edOurRefNum.GetWindowText(strData);
|
|
rs->UpdateField("ourref",&strData);
|
|
|
|
//CLIENT CONTACT
|
|
m_edClientContact.GetWindowText(strData);
|
|
rs->UpdateField("clientcontact",&strData);
|
|
|
|
//added 10/13/2002 to ensure that main workorder list view
|
|
//shows the tech assigned to the workorder
|
|
//ASSIGNTECH
|
|
//SaveField(&m_cbTechList,"assigntech",rs);
|
|
lData=atol(m_cbTechList.GetCurrentRowID());
|
|
rs->UpdateField("assigntech",&lData);
|
|
|
|
|
|
rs->SaveRecord();
|
|
rs->Close();
|
|
|
|
|
|
//rs->FetchField("quick",&bData);
|
|
//ASSERT(bData==TRUE);
|
|
|
|
//Create a problem record
|
|
|
|
//open the probs table, return no records
|
|
rs->Query("SELECT probs.* FROM probs WHERE (((probs.id)=0));");
|
|
|
|
rs->AddNewRecord();
|
|
|
|
|
|
ASSERT(!m_strID.IsEmpty());
|
|
|
|
//SAVE THE WORKORDER ID NUMBER
|
|
rs->UpdateField("wolink",&m_strID);
|
|
|
|
//STATUS to zero
|
|
lData=0;
|
|
rs->UpdateField("status",&lData);
|
|
|
|
//CREATOR
|
|
rs->UpdateField("creator",&m_pApp->m_lusrID);
|
|
|
|
//CREATED
|
|
rs->UpdateField("created",&dtDate);//dtdate set earlier
|
|
|
|
//CREATOR
|
|
rs->UpdateField("modifier",&m_pApp->m_lusrID);
|
|
|
|
//CREATED
|
|
rs->UpdateField("modified",&dtDate);//dtdate set earlier
|
|
|
|
//Save problem record
|
|
rs->SaveRecord();
|
|
rs->Close();
|
|
|
|
//get id of problem record
|
|
q.Format("SELECT probs.id FROM probs "
|
|
"WHERE (((probs.wolink)=%s) AND "
|
|
"((probs.status)=0) AND "
|
|
"((probs.creator)=%u));",m_strID,m_pApp->m_lusrID);
|
|
|
|
|
|
rs->Query(q);
|
|
|
|
|
|
lLink=0;
|
|
rs->FetchField("id",&lLink);
|
|
ASSERT(lLink!=0);
|
|
|
|
|
|
//************************************
|
|
//************************************
|
|
//Use id to create a labour table record
|
|
//firstly open the labor table in a way that returns no records
|
|
rs->Query("SELECT labor.* FROM labor WHERE (((labor.link)=0));");
|
|
rs->AddNewRecord();
|
|
//set labour record fields
|
|
|
|
//LINK TO PROBLEM RECORD
|
|
rs->UpdateField("link",&lLink);
|
|
|
|
//TECH
|
|
strData=m_cbTechList.GetCurrentRowID();
|
|
lData=atol(strData);
|
|
rs->UpdateField("tech",&lData);
|
|
|
|
|
|
//HOURS
|
|
m_edBillHours.GetWindowText(strData);
|
|
//02/19/2003 Fix crash on empty field
|
|
if(strData.IsEmpty()) strData="0";
|
|
//01/31/2003 convert to a variant bstr
|
|
_variant_t vtData(strData);
|
|
fData=(float)vtData;//cast variant to float (locale friendly)
|
|
//fData=(float)atof(strData);
|
|
rs->UpdateField("hours",&fData);
|
|
|
|
//NOCHARGE HOURS
|
|
m_edNCHours.GetWindowText(strData);
|
|
//02/19/2003 Fix crash on empty field
|
|
if(strData.IsEmpty()) strData="0";
|
|
//01/31/2003 convert to a variant bstr
|
|
_variant_t vtData1(strData);
|
|
fData=(float)vtData1;//cast variant to float (locale friendly)
|
|
//fData=(float)atof(strData);
|
|
rs->UpdateField("nchours",&fData);
|
|
|
|
//TRAVEL HOURS
|
|
m_edTravelHours.GetWindowText(strData);
|
|
//02/19/2003 Fix crash on empty field
|
|
if(strData.IsEmpty()) strData="0";
|
|
//01/31/2003 convert to a variant bstr
|
|
_variant_t vtDatax1(strData);
|
|
fData=(float)vtDatax1;//cast variant to float (locale friendly)
|
|
//fData=(float)atof(strData);
|
|
rs->UpdateField("travhours",&fData);
|
|
|
|
//DISTANCE
|
|
m_edDistance.GetWindowText(strData);
|
|
//02/19/2003 Fix crash on empty field
|
|
if(strData.IsEmpty()) strData="0";
|
|
//01/31/2003 convert to a variant bstr
|
|
_variant_t vtData2(strData);
|
|
fData=(float)vtData2;//cast variant to float (locale friendly)
|
|
//fData=(float)atof(strData);
|
|
rs->UpdateField("distance",&fData);
|
|
|
|
//RATE
|
|
strData=m_cbRates.GetCurrentRowID();
|
|
lData=atol(strData);
|
|
rs->UpdateField("rate",&lData);
|
|
|
|
//TRAVEL RATE
|
|
strData=m_cbTravelRates.GetCurrentRowID();
|
|
lData=atol(strData);
|
|
rs->UpdateField("travrate",&lData);
|
|
|
|
|
|
|
|
|
|
//START
|
|
|
|
//this field expects time and also date
|
|
//so we need to get the time and add back in the date
|
|
//date is set earlier in this function
|
|
|
|
//moved down to here 10/11/2002
|
|
m_dtDate.GetTime(dtDate);
|
|
m_dtEndDate.GetTime(dtEndDate);
|
|
|
|
m_edStart.GetWindowText(strData);
|
|
dtTime.ParseDateTime(strData,VAR_TIMEVALUEONLY);
|
|
dtData.SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
|
rs->UpdateField("start",&dtData);
|
|
|
|
//STOP
|
|
//TODO:validation of conversion
|
|
m_edEnd.GetWindowText(strData);
|
|
dtTime.ParseDateTime(strData,VAR_TIMEVALUEONLY);
|
|
dtData.SetDateTime(dtEndDate.GetYear(),dtEndDate.GetMonth(),dtEndDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
|
rs->UpdateField("stop",&dtData);
|
|
|
|
//DETAILS
|
|
m_edDetails.GetWindowText(strData);
|
|
rs->UpdateField("details",&strData);
|
|
|
|
|
|
rs->SaveRecord();
|
|
|
|
|
|
m_bEditing=true;//we are now editing because of save
|
|
|
|
//01/11/2001 changed to:
|
|
rs->Close();
|
|
|
|
//changes 08/22/00 added the following
|
|
//to refresh recordset
|
|
FillFields();
|
|
|
|
//and same date as above added this bit
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CSimpleWODlg::OnKillfocusEdclientcontact()
|
|
{
|
|
SaveField(&m_edClientContact,"clientcontact",true,rs);
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::OnKillfocusEdclientrefnum()
|
|
{
|
|
SaveField(&m_edClientRefNumber,"clientrefnum",true,rs);
|
|
|
|
}
|
|
|
|
|
|
//added nov 10th 2000, to ensure
|
|
//all data is saved before printing
|
|
void CSimpleWODlg::Flush(bool bClose)
|
|
{
|
|
|
|
if(bClose)
|
|
{
|
|
//Added Nov 10th, deletes rs recordset object
|
|
//to flush it then calls fillfields at the bottom
|
|
//to reopen it.
|
|
|
|
rs->Close();
|
|
rsLabor->Close();
|
|
rsProb->Close();
|
|
//m_pApp->Delay(5);
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
//fill the recordsets again
|
|
FillFields();
|
|
}
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::OnQuickwoDone()
|
|
{
|
|
CString strData,q;
|
|
COleDateTime dtData,dtTime,dtDate;
|
|
//added because clicking a menu item doesn't kill
|
|
//focus on a control to allow it to update
|
|
m_ckOnsite.SetFocus();
|
|
|
|
|
|
if(m_cbClients.GetCurrentRowID()=="0")
|
|
{
|
|
AfxMessageBox("Please choose a client");
|
|
return;
|
|
|
|
}
|
|
|
|
//bail if user is only editing
|
|
if(m_bEditing)
|
|
{
|
|
CDialog::OnOK();
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
//otherwise save new record
|
|
SaveNewRecord();
|
|
|
|
|
|
|
|
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
void CSimpleWODlg::OnQuickwoClientnotes()
|
|
{
|
|
CContactsViewDlg d;
|
|
d.Setup(m_cbClients.GetCurrentRowID());
|
|
d.DoModal();
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CSimpleWODlg::OnQuickwoDelete()
|
|
{
|
|
CString q;
|
|
CString msg;
|
|
|
|
//added because clicking a menu item doesn't kill
|
|
//focus on a control to allow it to update
|
|
m_ckOnsite.SetFocus();
|
|
|
|
if(!m_bEditing)
|
|
{
|
|
msg="Abandon workorder?\r\nAre you sure?";
|
|
|
|
if(AfxMessageBox(msg,MB_YESNO)==IDYES)
|
|
{
|
|
q.Format("DELETE wo.*, wo.id FROM wo WHERE (((wo.id)=%s));",m_strID);
|
|
rs->Ex(q);
|
|
rs->QueryReadOnly("SELECT defaults.* FROM defaults");//just to flush
|
|
m_pApp->m_bRefreshStatScreen=true;
|
|
CDialog::OnOK();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
msg="Delete workorder?\r\nAre you sure?";
|
|
if(AfxMessageBox(msg,MB_YESNO)==IDYES)
|
|
{
|
|
q.Format("DELETE labor.*, probs.wolink "
|
|
"FROM labor INNER JOIN probs ON labor.link = probs.id "
|
|
"WHERE (((probs.wolink)=%s));",m_strWorkorderID);
|
|
rs->Ex(q);
|
|
|
|
q.Format("DELETE probs.wolink, probs.* "
|
|
"FROM probs "
|
|
"WHERE (((probs.wolink)=%s));",m_strWorkorderID);
|
|
rs->Ex(q);
|
|
|
|
|
|
|
|
q.Format("DELETE wo.*, wo.id FROM wo WHERE (((wo.id)=%s));",m_strWorkorderID);
|
|
rs->Ex(q);
|
|
rs->QueryReadOnly("SELECT defaults.* FROM defaults");//just to flush
|
|
m_pApp->m_bRefreshStatScreen=true;
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CSimpleWODlg::OnQuickwoPrint()
|
|
{
|
|
|
|
CString q;
|
|
CString parameters;
|
|
//added because clicking a menu item doesn't kill
|
|
//focus on a control to allow it to update
|
|
m_ckOnsite.SetFocus();
|
|
|
|
//Save first if new record
|
|
if(!m_bEditing)
|
|
{
|
|
if(!SaveNewRecord()) return;
|
|
//kill time here
|
|
//AfxMessageBox("Record Saved...proceeding to print");
|
|
|
|
}
|
|
|
|
//close the recordsets
|
|
Flush(true);
|
|
|
|
parameters.Format("\"%s\" AS zCompName, ",m_pApp->m_strRegCompany);
|
|
|
|
/*
|
|
q.Format("SELECT %s wo.*, probs.*, labor.*, users.first, users.last, users.initials, clients.* "
|
|
"FROM (users INNER JOIN (labor INNER JOIN (wo INNER JOIN probs ON wo.id = probs.wolink) ON labor.link = probs.id) ON users.id = labor.tech) LEFT JOIN clients ON wo.client = clients.id "
|
|
"WHERE (((wo.id)=%s));",parameters,m_strWorkorderID);
|
|
*/
|
|
|
|
q.Format("SELECT %s wo.id, wo.clientrefnum, wo.clientcontact, clients.company AS clientcompany, Format(wo.closed,\"Short Date\") AS wodate, "
|
|
"[users]![first] & \" \" & [users]![last] AS wotech, labor.hours, "
|
|
"labor.travhours, labor.nchours, rates_1.name AS workrate, rates.name "
|
|
"AS travrate, labor.start AS starttime, "
|
|
"labor.stop AS stoptime, wo.invoice, labor.details, wo.onsite "
|
|
"FROM (((users RIGHT JOIN (labor RIGHT JOIN (wo LEFT JOIN probs ON "
|
|
"wo.id = probs.wolink) ON labor.link = probs.id) ON users.id = "
|
|
"labor.tech) LEFT JOIN clients ON wo.client = clients.id) LEFT "
|
|
"JOIN rates ON labor.travrate = rates.id) LEFT JOIN rates AS "
|
|
"rates_1 ON labor.rate = rates_1.id WHERE (((wo.id)=%s));",parameters,m_strWorkorderID);
|
|
#ifdef _DEBUG
|
|
m_pApp->ShowStuff(q);
|
|
#endif
|
|
rsPrint->QueryReadOnly(q);
|
|
rsPrint->QueryReadOnly(q);
|
|
/*
|
|
CString strTEST;
|
|
strTEST=rsPrint->SetFieldToMemo("details");
|
|
//m_pApp->ShowStuff(strTEST);
|
|
*/
|
|
|
|
if(!rsPrint->IsEmpty())
|
|
{
|
|
m_pApp->PrintCMReportRDC("Quick workorder",rsPrint->RecordSetPointer());
|
|
#ifdef _DEBUG
|
|
m_pApp->CreateTTX("QuickWO.ttx",rsPrint->RecordSetPointer());
|
|
#endif
|
|
}
|
|
|
|
//reopen the recordsets
|
|
Flush(false);
|
|
}
|
|
|
|
void CSimpleWODlg::OnQuickwoPrintDispatch()
|
|
{
|
|
//added because clicking a menu item doesn't kill
|
|
//focus on a control to allow it to update
|
|
m_ckOnsite.SetFocus();
|
|
|
|
CString q;
|
|
|
|
//Save first if new record
|
|
if(!m_bEditing)
|
|
{
|
|
if(!SaveNewRecord()) return;
|
|
|
|
}
|
|
|
|
|
|
//print the dispatch format workorder
|
|
|
|
//close all the extra recordsets - Nov 10th 2000
|
|
//(U.S. presidential election uncertainty day 3)
|
|
Flush(true);
|
|
|
|
|
|
q.Format("SELECT IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS clientname, "
|
|
"IIf(IsNull([clients].[streetaddress]),[clients].[mailaddress],[clients].[streetaddress]) & IIf(IsNull([clients].[city]),\"\","
|
|
"[clients].[city]) & IIf(IsNull([clients].[stateprov]),\"\",\", \" & [clients].[stateprov] & "
|
|
"IIf(IsNull([clients].[postal]),\"\",\" \" & [clients].[postal])) AS address, "
|
|
"\"Work required: \" & [probs].[brief] & IIf([probs].[unit]<>0,Chr(13) & \"Unit: \" & [nonclients].[company_person] & "
|
|
"\" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] & \") SN: \" & [units].[sn],\"\") AS probheader, "
|
|
"\"%s\" AS compname, wo.id AS wonumber, wo.created, labor.details, probs.notes, IIf(IsNull(contracts_1.name),"
|
|
"[contracts].[name],contracts_1.name) AS contractinfo, IIf([probs].[unit]<>0,\"Unit: \" & "
|
|
"[nonclients].[company_person] & \" \" & [unitmodels].[description] & \" (\" & [unitmodels].[model] & \") SN: \" & "
|
|
"[units].[sn],\"\") AS Equipment, wo.starttime AS [Booked for], probs.brief, clients.mailaddress, clients.streetaddress, "
|
|
"clients.city, clients.stateprov, clients.postal, clients.country, clients.bizphone, clients.extension, clients.technotes, clients.first, clients.last, wo.clientrefnum, wo.ourref, wo.clientcontact "
|
|
"FROM (((labor RIGHT JOIN (((units RIGHT JOIN probs ON units.id = probs.unit) LEFT JOIN unitmodels ON "
|
|
"units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) ON labor.link = "
|
|
"probs.id) RIGHT JOIN ((wo LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN clients AS headoffices ON "
|
|
"clients.headoffice = headoffices.id) ON probs.wolink = wo.id) LEFT JOIN contracts ON clients.contract = "
|
|
"contracts.id) LEFT JOIN contracts AS contracts_1 ON headoffices.contract = contracts_1.id "
|
|
"WHERE (((wo.id)=%s));",m_pApp->m_strRegCompany,m_strWorkorderID);
|
|
|
|
rsPrint->QueryReadOnly(q);
|
|
rsPrint->QueryReadOnly(q);
|
|
|
|
if(!rsPrint->IsEmpty())
|
|
{
|
|
|
|
#ifdef _DEBUG
|
|
m_pApp->ShowStuff(q);
|
|
m_pApp->CreateTTX("wodispqu.ttx",rsPrint->RecordSetPointer());
|
|
#endif
|
|
m_pApp->PrintCMReportRDC("Workorder dispatch (Quick)",rsPrint->RecordSetPointer());
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
AfxMessageBox("There is no data to print!");
|
|
|
|
}
|
|
|
|
|
|
|
|
//reopen the closed recordsets
|
|
Flush(false);
|
|
}
|
|
|
|
void CSimpleWODlg::DisplayContactInfo()
|
|
{
|
|
CString q, strData, strDisplay;
|
|
//retrieve contact info based on workorder
|
|
|
|
q.Format(
|
|
"SELECT clients.first, clients.last, clients.company, "
|
|
"clients.mailaddress, clients.streetaddress, clients.city, "
|
|
"clients.stateprov, clients.postal, clients.country, clients.bizphone, "
|
|
"clients.extension, clients.fax, clients.email "
|
|
"FROM clients "
|
|
"WHERE (((clients.id)=%s));",m_strSelClient);
|
|
|
|
cbrs->QueryReadOnly(q);
|
|
if(cbrs->IsEmpty())
|
|
{
|
|
m_lblContactInfo.SetWindowText("");
|
|
return;
|
|
}
|
|
|
|
|
|
strDisplay="[Contact: ";
|
|
cbrs->FetchField("first",&strData);
|
|
if(!strData.IsEmpty())
|
|
strDisplay+=strData + " ";
|
|
|
|
cbrs->FetchField("last",&strData);
|
|
strDisplay+=strData+"]";
|
|
|
|
cbrs->FetchField("bizphone",&strData);
|
|
if(!strData.IsEmpty())
|
|
strDisplay+= "[Phone: " + strData;
|
|
|
|
cbrs->FetchField("extension",&strData);
|
|
if(!strData.IsEmpty())
|
|
strDisplay+=" ext:" + strData;
|
|
|
|
strDisplay+="]";
|
|
|
|
|
|
|
|
cbrs->FetchField("fax",&strData);
|
|
if(!strData.IsEmpty())
|
|
strDisplay+="[Fax: " + strData + "]";
|
|
|
|
cbrs->FetchField("email",&strData);
|
|
if(!strData.IsEmpty())
|
|
strDisplay+="[Email: " + strData + "]";
|
|
|
|
//Physical address for Lenny and the lock people
|
|
strDisplay+="[Addr: ";
|
|
cbrs->FetchField("streetaddress",&strData);
|
|
if(!strData.IsEmpty())
|
|
strDisplay+= strData + ", ";
|
|
cbrs->FetchField("city",&strData);
|
|
if(!strData.IsEmpty())
|
|
strDisplay+= strData;
|
|
strDisplay+="]";
|
|
|
|
m_lblContactInfo.SetWindowText(strDisplay);
|
|
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::FillStatusList()
|
|
{
|
|
//==========================================
|
|
//WORKORDER STATUS LIST
|
|
|
|
CString strData;
|
|
CString strIndex;
|
|
long lData;
|
|
|
|
//FILL STATUS LIST
|
|
m_cbStatus.Clear();
|
|
//first enter default item
|
|
strData="< N/A >";
|
|
strIndex="0";
|
|
m_cbStatus.AddRow(strData,strIndex);
|
|
|
|
cbrs->QueryReadOnly("SELECT probstat.id, probstat.notes FROM probstat ORDER BY probstat.id;");
|
|
|
|
if(!cbrs->IsEmpty())
|
|
{
|
|
do
|
|
{
|
|
cbrs->FetchField("notes",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
m_cbStatus.AddRow(strData,strIndex);
|
|
}while(cbrs->MoveForward());
|
|
}
|
|
m_cbStatus.Select("0");
|
|
//============================================
|
|
}
|
|
|
|
void CSimpleWODlg::OnKillfocusEdourrefnumber2()
|
|
{
|
|
SaveField(&m_edOurRefNum,"ourref",true,rs);
|
|
}
|
|
|
|
void CSimpleWODlg::OnCloseupCbstatus()
|
|
{
|
|
SaveField(&m_cbStatus,"status",rs);
|
|
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::OnHistory()
|
|
{
|
|
CString q;
|
|
q.Format("SELECT wo.created, wo.modified, wo.creator, wo.modifier FROM wo "
|
|
"WHERE (((wo.id)=%s));",m_strWorkorderID);
|
|
|
|
cbrs->QueryReadOnly(q);
|
|
|
|
|
|
COleDateTime dtCreated,dtModified;
|
|
CString modifier,creator;
|
|
long m,c;
|
|
//GET RECORD STATUS FIELDS
|
|
cbrs->FetchField("created",&dtCreated);
|
|
cbrs->FetchField("modified",&dtModified);
|
|
|
|
cbrs->FetchField("creator",&c);
|
|
|
|
cbrs->FetchField("modifier",&m);
|
|
creator.Format("%u",c);
|
|
modifier.Format("%u",m);
|
|
|
|
|
|
CStatusDlg d;
|
|
d.SetValues(&creator,&modifier,&dtCreated,&dtModified);
|
|
d.DoModal();
|
|
|
|
}
|
|
|
|
//Show tech notes
|
|
void CSimpleWODlg::OnLbltechnotes()
|
|
{
|
|
m_pApp->ShowStuff(m_strTechNotes);
|
|
|
|
}
|
|
|
|
void CSimpleWODlg::UpdateClosedOpen()
|
|
{
|
|
CString strData;
|
|
strData=m_bIsOpen ? "<In progress> ":"<Closed> ";
|
|
CMenu* pMenu=this->GetMenu();
|
|
pMenu->ModifyMenu(ID_QUICKWO_COSTATUS,MF_BYCOMMAND,ID_QUICKWO_COSTATUS,strData);
|
|
//v1.9.4.2
|
|
if(m_bReadOnly)
|
|
pMenu->EnableMenuItem(ID_QUICKWO_COSTATUS, MF_DISABLED | MF_GRAYED);
|
|
|
|
this->DrawMenuBar();
|
|
}
|
|
|
|
void CSimpleWODlg::OnQuickwoCostatus()
|
|
{
|
|
CString q, strStatusQ;
|
|
|
|
strStatusQ.Empty();
|
|
if(m_bIsOpen)
|
|
{
|
|
m_bIsOpen=false;
|
|
if(m_pApp->m_lDefClosedWOStatus!=0)
|
|
{
|
|
m_strSelectedStatus.Format("%u",m_pApp->m_lDefClosedWOStatus);
|
|
strStatusQ.Format(", wo.status=%s",m_strSelectedStatus);
|
|
m_cbStatus.Select(m_strSelectedStatus);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
m_bIsOpen=true;
|
|
if(m_pApp->m_lDefReOpenWOStatus!=0)
|
|
{
|
|
m_strSelectedStatus.Format("%u",m_pApp->m_lDefReOpenWOStatus);
|
|
strStatusQ.Format(", wo.status=%s",m_strSelectedStatus);
|
|
m_cbStatus.Select(m_strSelectedStatus);
|
|
}
|
|
}
|
|
|
|
|
|
//-----
|
|
COleDateTime dtData=COleDateTime::GetCurrentTime();
|
|
if(m_bIsOpen)
|
|
dtData.SetDate(1968,03,12);
|
|
|
|
q.Format("UPDATE wo SET wo.closed = #%s# %s WHERE (((wo.id)=%s));",dtData.Format(_T("%m/%d/%Y %H:%M:%S")),strStatusQ,m_strWorkorderID);
|
|
cbrs->Ex(q);
|
|
cbrs->Close();
|
|
|
|
//removed because of some strange voodoo when it says another user is modifying
|
|
// UpdateModified();
|
|
m_pApp->m_bRefreshStatScreen=true;
|
|
//-----
|
|
|
|
UpdateClosedOpen();
|
|
}
|
|
|
|
|
|
|
|
//added 07/25/01, somehow got missed all along :(
|
|
void CSimpleWODlg::OnTravelratelabel()
|
|
{
|
|
OnRateLabel();
|
|
}
|
|
|
|
void CSimpleWODlg::Security()
|
|
{
|
|
m_bReadOnly=false;
|
|
int x=m_pApp->Allowed(RWORKORDER,true);
|
|
if(x==0)//no access allowed
|
|
{
|
|
m_pApp->SecurityWarning();
|
|
CDialog::OnCancel();
|
|
}
|
|
if(x==2)//read only
|
|
{
|
|
|
|
m_bReadOnly=true;
|
|
m_dtEndDate.EnableWindow(FALSE);
|
|
m_edOurRefNum.EnableWindow(FALSE);
|
|
m_cbStatus.EnableWindow(FALSE);
|
|
m_edClientRefNumber.EnableWindow(FALSE);
|
|
m_edClientContact.EnableWindow(FALSE);
|
|
m_cbTechList.EnableWindow(FALSE);
|
|
m_cbTravelRates.EnableWindow(FALSE);
|
|
m_ckOnsite.EnableWindow(FALSE);
|
|
m_dtDate.EnableWindow(FALSE);
|
|
m_btnTimer.EnableWindow(FALSE);
|
|
m_edDetails.SetReadOnly(TRUE);//.EnableWindow(FALSE);
|
|
m_edInvoicedOn.EnableWindow(FALSE);
|
|
m_edTravelHours.EnableWindow(FALSE);
|
|
m_edDistance.EnableWindow(FALSE);
|
|
m_edNCHours.EnableWindow(FALSE);
|
|
m_edBillHours.EnableWindow(FALSE);
|
|
m_edEnd.EnableWindow(FALSE);
|
|
m_edStart.EnableWindow(FALSE);
|
|
m_cbTypes.EnableWindow(FALSE);
|
|
m_cbRates.EnableWindow(FALSE);
|
|
m_cbClients.EnableWindow(FALSE);
|
|
CMenu* pMenu=this->GetMenu();
|
|
pMenu->EnableMenuItem(ID_QUICKWO_DELETE, MF_DISABLED | MF_GRAYED);
|
|
//v1.9.4.2
|
|
pMenu->EnableMenuItem(ID_QUICKWO_COSTATUS, MF_DISABLED | MF_GRAYED);
|
|
|
|
|
|
|
|
//v1.9.4.4
|
|
m_lblCategory.EnableWindow(FALSE);
|
|
//m_lblProjects.EnableWindow(FALSE);
|
|
m_lblStatus.EnableWindow(FALSE);
|
|
//m_lblFind.EnableWindow(FALSE);
|
|
}
|
|
|
|
//v1.9.4.4 delete option disabled unless a member of managers
|
|
if(m_pApp->m_lGroupID!=1)
|
|
{
|
|
CMenu* pMenu=this->GetMenu();
|
|
pMenu->EnableMenuItem(ID_QUICKWO_DELETE, MF_DISABLED | MF_GRAYED);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void CSimpleWODlg::FillReportList(void)
|
|
{
|
|
|
|
CString q,strData;
|
|
UINT uiResourceID=_STARTING_PRINT_COMMAND_ID;/*id's 32289 to 33388 are set aside for what have u, in this case workorder report menu commands*/
|
|
|
|
q="SELECT rptsmaster.virtualname,rptsmaster.id, rptsmaster.wodisplayorder FROM rptsmaster WHERE "
|
|
"(((rptsmaster.recordset)=\"woquick\")) ORDER BY rptsmaster.wodisplayorder;";
|
|
if(!rs->QueryReadOnly(q)) return;
|
|
|
|
//get the corrent menu location
|
|
CMenu* pMainMenu = GetMenu();
|
|
//CMenu* m_pSubMenu=NULL;
|
|
for (int i=0;i<(int)pMainMenu->GetMenuItemCount();i++)
|
|
{
|
|
m_pSubMenu=pMainMenu->GetSubMenu(i);
|
|
if(m_pSubMenu && m_pSubMenu->GetMenuItemID(0)== ID_PRINT_PLACEHOLDER)
|
|
break;
|
|
}
|
|
ASSERT(m_pSubMenu);
|
|
|
|
//remove the placeholder
|
|
m_pSubMenu->RemoveMenu(0,MF_BYPOSITION);
|
|
//remove old report commands (lazy..I know)
|
|
m_pSubMenu->RemoveMenu(0,MF_BYPOSITION);
|
|
m_pSubMenu->RemoveMenu(0,MF_BYPOSITION);
|
|
|
|
//Show query option for manager account only
|
|
if(m_pApp->m_lusrID==1)
|
|
{
|
|
m_pSubMenu->AppendMenu(0,uiResourceID,"SHOW QUERIES ON PRINT");
|
|
m_pSubMenu->CheckMenuItem(uiResourceID,MF_UNCHECKED|MF_BYCOMMAND);
|
|
m_pSubMenu->AppendMenu(MF_SEPARATOR);
|
|
m_bShowQueriesOnPrint=false;
|
|
|
|
}
|
|
|
|
do{
|
|
uiResourceID++;
|
|
//Add menu item: report name, uiResourceID command
|
|
rs->FetchField("virtualname",&strData);
|
|
m_pSubMenu->AppendMenu(0,uiResourceID,strData);
|
|
|
|
|
|
}while(rs->MoveForward());
|
|
}
|
|
|
|
|
|
|
|
void CSimpleWODlg::OnPrintReport( UINT nID )
|
|
{
|
|
CString strVirtualReportName,strTTXPath;
|
|
CString strError;
|
|
CString q,strQuery;
|
|
CString strWOID,strRegTo,strSchedTech;
|
|
CString strShowQuery,strTemp;
|
|
|
|
//see if it's a checkmark that needs to be done
|
|
if(nID==_STARTING_PRINT_COMMAND_ID)//it's a click on show queries
|
|
{
|
|
m_bShowQueriesOnPrint=!m_bShowQueriesOnPrint;
|
|
if(m_bShowQueriesOnPrint)
|
|
m_pSubMenu->CheckMenuItem(_STARTING_PRINT_COMMAND_ID,MF_CHECKED|MF_BYCOMMAND);
|
|
else
|
|
m_pSubMenu->CheckMenuItem(_STARTING_PRINT_COMMAND_ID,MF_UNCHECKED|MF_BYCOMMAND);
|
|
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
m_pSubMenu->GetMenuString(nID,strVirtualReportName,MF_BYCOMMAND);
|
|
|
|
//added because clicking a menu item doesn't kill
|
|
//focus on a control to allow it to update
|
|
m_ckOnsite.SetFocus();
|
|
|
|
//Save first if new record
|
|
if(!m_bEditing)
|
|
if(!SaveNewRecord())
|
|
return;
|
|
|
|
//close the recordsets
|
|
Flush(true);
|
|
|
|
|
|
q.Format("SELECT rptsmaster.* FROM rptsmaster WHERE (((rptsmaster.virtualname)=\"%s\"));",strVirtualReportName);
|
|
//Fetch query
|
|
if(!cbrs->QueryReadOnly(q))
|
|
{
|
|
strError.Format(
|
|
"Unable to print:\r\n"
|
|
"%s\r\n"
|
|
"Can't open rptsmaster table due to the error previously reported\r\n"
|
|
"by the database driver.",strVirtualReportName);
|
|
AfxMessageBox(strError);
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
if(!cbrs->FetchField("filename",&strTTXPath))
|
|
{
|
|
strError.Format(
|
|
"Unable to print:\r\n"
|
|
"%s\r\n"
|
|
"can't retrieve report file name due to the error previously reported\r\n"
|
|
"by the database driver.",strVirtualReportName);
|
|
AfxMessageBox(strError);
|
|
return;
|
|
|
|
}
|
|
strTTXPath.Replace(".rpt",".ttx");
|
|
|
|
if(!cbrs->FetchField("query",&strQuery))
|
|
{
|
|
strError.Format(
|
|
"Unable to print:\r\n"
|
|
"%s\r\n"
|
|
"Can't retrieve report query due to the error previously reported\r\n"
|
|
"by the database driver.",strVirtualReportName);
|
|
AfxMessageBox(strError);
|
|
return;
|
|
|
|
}
|
|
|
|
if(m_bShowQueriesOnPrint)
|
|
{
|
|
strShowQuery.Format("---==< Database queries to aid in report customization >==---\r\n\r\n"
|
|
"Raw query for:%s\r\n"
|
|
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n"
|
|
"%s\r\n"
|
|
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n\r\n\r\n",strVirtualReportName,strQuery);
|
|
|
|
|
|
}
|
|
//make token substitutions
|
|
strQuery.Replace("~REGTO",m_pApp->m_strRegCompany);
|
|
strQuery.Replace("Evaluation",m_pApp->m_strRegCompany);
|
|
strQuery.Replace("~WOID",m_strWorkorderID);
|
|
|
|
if(m_bShowQueriesOnPrint)
|
|
{
|
|
strTemp.Format("Query after tokens replaced for:%s\r\n"
|
|
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n"
|
|
"%s\r\n"
|
|
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n",strVirtualReportName,strQuery);
|
|
strShowQuery+=strTemp;
|
|
|
|
m_pApp->ShowStuff(strShowQuery);
|
|
|
|
}
|
|
|
|
//run query
|
|
if(!rsPrint->QueryReadOnly(strQuery))
|
|
{
|
|
strError.Format(
|
|
"Unable to print:\r\n"
|
|
"%s\r\n"
|
|
"due to the error previously reported\r\n"
|
|
"by the database driver.",strVirtualReportName);
|
|
AfxMessageBox(strError);
|
|
return;
|
|
}
|
|
|
|
//run query again, because it seems to be needed
|
|
//and was done that way before.
|
|
//probably some sort of timing issue
|
|
//but it works and this is the last
|
|
//maint. release for this tired old code
|
|
if(!rsPrint->QueryReadOnly(strQuery))
|
|
{
|
|
strError.Format(
|
|
"Unable to print:\r\n"
|
|
"%s\r\n"
|
|
"due to the error previously reported\r\n"
|
|
"by the database driver.",strVirtualReportName);
|
|
AfxMessageBox(strError);
|
|
return;
|
|
}
|
|
|
|
//call report
|
|
if(!rsPrint->IsEmpty())
|
|
{
|
|
m_pApp->PrintCMReportRDC(strVirtualReportName,rsPrint->RecordSetPointer());
|
|
if(m_pApp->m_lusrID==1)//manager account?
|
|
m_pApp->CreateTTX(strTTXPath,rsPrint->RecordSetPointer(),true);
|
|
}
|
|
|
|
//reopen the recordsets
|
|
Flush(false);
|
|
|
|
|
|
|
|
|
|
}
|
|
// Convert a float to ascii preserving locale format
|
|
CString CSimpleWODlg::FtoA(float fData)
|
|
{
|
|
_variant_t vItem(fData);
|
|
_bstr_t bs;
|
|
VarFormatNumber(&vItem,-1,-2,-2,-2,0,bs.GetAddress());
|
|
return CString((BSTR)bs);
|
|
}
|
|
|
|
void CSimpleWODlg::OnStatuslabel()
|
|
{
|
|
CProbStatDlg d;
|
|
d.DoModal();
|
|
FillStatusList();
|
|
if(m_strSelectedStatus.IsEmpty())
|
|
m_strSelectedStatus="0";
|
|
m_cbStatus.Select(m_strSelectedStatus);
|
|
}
|
|
|
|
// Sets the selected labor rates for a selected tech that isn't the current logged in user (if there isn't a client default)
|
|
void CSimpleWODlg::SetForeignTechLaborRateDefaults(void)
|
|
{
|
|
}
|