3133 lines
87 KiB
C++
3133 lines
87 KiB
C++
// WOHeaderDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "sp.h"
|
|
#include "WOHeaderDlg.h"
|
|
#include "FindClientDlg.h"
|
|
#include "WODlg.h"
|
|
#include "ClientsDlg.h"
|
|
#include "ContactsViewDlg.h"
|
|
#include "projectsdlg.h"
|
|
#include "wotypesdlg.h"
|
|
#include "usersdlg.h"
|
|
#include "gzCurrencyFormatter.h"
|
|
#include "ProbStatDlg.h"
|
|
#include "StatusDlg.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>
|
|
#define _STARTING_PRINT_COMMAND_ID 32299
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CWOHeaderDlg dialog
|
|
|
|
|
|
CWOHeaderDlg::CWOHeaderDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CWOHeaderDlg::IDD, pParent)
|
|
, m_lClientDefaultRate(0)
|
|
, m_pSubMenu(NULL)
|
|
, m_bShowQueriesOnPrint(false)
|
|
, m_bAlertPopup(false)
|
|
{
|
|
//{{AFX_DATA_INIT(CWOHeaderDlg)
|
|
//}}AFX_DATA_INIT
|
|
m_strWorkorderID="0";
|
|
|
|
//set initial cb selections
|
|
m_strSelClient="0";
|
|
m_strSelCategory="0";
|
|
m_strSelProject="0";
|
|
m_strSelTech="-1";
|
|
|
|
m_lSchedTech1=-1;
|
|
m_lSchedTech2=-1;
|
|
m_lSchedTech3=-1;
|
|
m_lSchedTech4=-1;
|
|
|
|
m_strSelectedStatus="0";
|
|
m_oledtPresetStartDate.SetDate(1968,03,12);
|
|
m_oledtPresetEndDate.SetDate(1968,03,12);
|
|
|
|
bModified=false;
|
|
m_pApp = (CSpApp*)AfxGetApp();
|
|
/*
|
|
rs=new GZRset("Error: Work order header");
|
|
rs->SetConnect(m_pApp->strConnectString);
|
|
|
|
cbrs=new GZRset("Error: Work order header utility recordset\r\n",true);
|
|
cbrs->SetConnect(m_pApp->strConnectString);
|
|
|
|
rsPrint=new GZRset("Workorder screen rsPrint error:",true);
|
|
rsPrint->SetConnect(m_pApp->strConnectString);
|
|
*/
|
|
//Initialize recordset pointer
|
|
|
|
rs=m_pApp->rsPool->GetRS("CWOHeaderDlg (RS)");
|
|
cbrs=m_pApp->rsPool->GetRS("CWOHeaderDlg (CBRS)");
|
|
rsPrint=m_pApp->rsPool->GetRSPrint("CWOHeaderDlg (RSPRINT)");
|
|
|
|
rsSubPrint=m_pApp->rsPool->GetRSPrint("CWOHeaderDlg (RSSUBPRINT)");
|
|
}
|
|
|
|
|
|
CWOHeaderDlg::~CWOHeaderDlg()
|
|
{
|
|
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(&rsSubPrint->m_nID);
|
|
}
|
|
|
|
void CWOHeaderDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//return;//test
|
|
//{{AFX_DATA_MAP(CWOHeaderDlg)
|
|
DDX_Control(pDX, IDC_TEC4, m_radTech4);
|
|
DDX_Control(pDX, IDC_TEC3, m_radTech3);
|
|
DDX_Control(pDX, IDC_TEC2, m_radTech2);
|
|
DDX_Control(pDX, IDC_SCHEDTECHSELECTORGROUP, m_grpSchedTechGroup);
|
|
DDX_Control(pDX, IDC_TEC1, m_radTech1);
|
|
DDX_Control(pDX, IDC_LBLTROUBLEREPORTED, m_lblTroulbleReported);
|
|
DDX_Control(pDX, IDC_LBLTROUBLEFOUND, m_lblTroubleFound);
|
|
DDX_Control(pDX, IDC_LBLACTIONTAKEN, m_lblActionTaken);
|
|
DDX_Control(pDX, IDC_EDTROUBLEREPORTED, m_edTroubleReported);
|
|
DDX_Control(pDX, IDC_EDTROUBLEFOUND, m_edTroubleFound);
|
|
DDX_Control(pDX, IDC_EDACTIONTAKEN, m_edActionTaken);
|
|
DDX_Control(pDX, IDC_LBLPROBSLIST2, m_lblProbsList);
|
|
DDX_Control(pDX, IDC_LBLTECHNOTES, m_lblTechNotes);
|
|
DDX_Control(pDX, IDC_LBLHISTORY, m_lblHist);
|
|
DDX_Control(pDX, IDC_LBLSTATUS, m_lblStatus);
|
|
DDX_Control(pDX, IDC_LBLREFNUMBER, m_lblRefNumber);
|
|
DDX_Control(pDX, IDC_LBLQUICKDESCRIPTION, m_lblQuickDescription);
|
|
DDX_Control(pDX, IDC_LBLOURREF, m_lblOurRef);
|
|
DDX_Control(pDX, IDC_LBLINVOICE, m_lblInvoice);
|
|
DDX_Control(pDX, IDC_LBLCONTACT, m_lblContact);
|
|
DDX_Control(pDX, IDC_LBL_GROUP2, m_lblGroup2);
|
|
DDX_Control(pDX, IDC_LBL_GROUP1, m_lblGroup1);
|
|
DDX_Control(pDX, IDC_EDOURREFNUMBER, m_edOurRefNum);
|
|
DDX_Control(pDX, IDC_CBSTATUS, m_cbStatus);
|
|
DDX_Control(pDX, IDC_lblContactInfo, m_lblContactInfo);
|
|
DDX_Control(pDX, IDC_EDCLIENTCONTACT, m_edClientContact);
|
|
DDX_Control(pDX, IDC_EDCLIENTREFNUM, m_edClientRefNum);
|
|
DDX_Control(pDX, IDC_LBLESTRATE, m_lblEstRate);
|
|
DDX_Control(pDX, IDC_LBLESTHOURS, m_lblEstHours);
|
|
DDX_Control(pDX, IDC_EDESTHOURS, m_edEstHours);
|
|
DDX_Control(pDX, IDC_CBESTRATE, m_cbEstRate);
|
|
DDX_Control(pDX, IDC_LBLS6, m_lbls6);
|
|
DDX_Control(pDX, IDC_LBLS5, m_lbls5);
|
|
DDX_Control(pDX, IDC_LBLS4, m_lbls4);
|
|
DDX_Control(pDX, IDC_LBLS3, m_lbls3);
|
|
DDX_Control(pDX, IDC_LBLS2, m_lbls2);
|
|
DDX_Control(pDX, IDC_CKANYTIME, m_ckAnyTime);
|
|
DDX_Control(pDX, IDC_LBLCONTRACT, m_lblContract);
|
|
DDX_Control(pDX, IDC_LBLTECHLIST, m_lblTechs);
|
|
DDX_Control(pDX, IDC_EDSCHEDSTARTTIME, m_edStartTime);
|
|
DDX_Control(pDX, IDC_EDSCHEDENDTIME, m_edEndTime);
|
|
DDX_Control(pDX, IDC_DTSCHEDENDDATE, m_dtEndDate);
|
|
DDX_Control(pDX, IDC_LBPROBS, m_lbProblems);
|
|
DDX_Control(pDX, IDC_LBLPROJECTS, m_lblProjects);
|
|
DDX_Control(pDX, IDC_LBLFIND, m_lblFind);
|
|
DDX_Control(pDX, IDC_EDWONOTES, m_edNotes);
|
|
DDX_Control(pDX, IDC_EDINVOICE, m_edInvoice);
|
|
DDX_Control(pDX, IDC_DTSCHEDDATE, m_dtSchedDate);
|
|
DDX_Control(pDX, IDC_CLIENTLIST_LABEL, m_lblClients);
|
|
DDX_Control(pDX, IDC_CKONSITE, m_ckOnsite);
|
|
DDX_Control(pDX, IDC_CBSCHEDTECHLIST, m_cbSchedTechList);
|
|
DDX_Control(pDX, IDC_CBPROJECTS, m_cbProjects);
|
|
DDX_Control(pDX, IDC_CBCLIENTS, m_cbClients);
|
|
DDX_Control(pDX, IDC_CBCATEGORY, m_cbCategories);
|
|
DDX_Control(pDX, IDC_CATEGORYLISTLABEL, m_lblCategories);
|
|
DDX_Control(pDX, IDC_BTNEDITPROBS, m_btnEditProblem);
|
|
DDX_Control(pDX, IDC_BTNDELETEPROB, m_btnDeleteProblem);
|
|
DDX_Control(pDX, IDC_BTNADDPROB, m_btnAddProblem);
|
|
//}}AFX_DATA_MAP
|
|
DDX_Control(pDX, IDC_LBL_TRIAL_DETAILS, m_lblTrialDetails);
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CWOHeaderDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CWOHeaderDlg)
|
|
ON_BN_CLICKED(IDC_LBLFIND, OnLblfind)
|
|
ON_BN_CLICKED(IDC_BTNADDPROB, OnBtnaddprob)
|
|
ON_BN_CLICKED(IDC_BTNDELETEPROB, OnBtndeleteprob)
|
|
ON_BN_CLICKED(IDC_BTNEDITPROBS, OnBtneditprobs)
|
|
ON_BN_CLICKED(IDC_CATEGORYLISTLABEL, OnCategorylistlabel)
|
|
ON_CBN_CLOSEUP(IDC_CBCATEGORY, OnCloseupCbcategory)
|
|
ON_CBN_CLOSEUP(IDC_CBCLIENTS, OnCloseupCbclients)
|
|
ON_CBN_CLOSEUP(IDC_CBPROJECTS, OnCloseupCbprojects)
|
|
ON_CBN_CLOSEUP(IDC_CBSCHEDTECHLIST, OnCloseupCbschedtechlist)
|
|
ON_BN_CLICKED(IDC_CKONSITE, OnCkonsite)
|
|
ON_BN_CLICKED(IDC_CLIENTLIST_LABEL, OnClientlistLabel)
|
|
ON_NOTIFY(NM_KILLFOCUS, IDC_DTSCHEDDATE, OnKillfocusDtscheddate)
|
|
ON_EN_KILLFOCUS(IDC_EDINVOICE, OnKillfocusEdinvoice)
|
|
ON_EN_KILLFOCUS(IDC_EDWONOTES, OnKillfocusEdwonotes)
|
|
ON_BN_CLICKED(IDC_LBLPROJECTS, OnLblprojects)
|
|
ON_LBN_DBLCLK(IDC_LBPROBS, OnDblclkLbprobs)
|
|
ON_EN_KILLFOCUS(IDC_EDSCHEDSTARTTIME, OnKillfocusEdschedstarttime)
|
|
ON_EN_KILLFOCUS(IDC_EDSCHEDENDTIME, OnKillfocusEdschedendtime)
|
|
ON_NOTIFY(NM_KILLFOCUS, IDC_DTSCHEDENDDATE, OnKillfocusDtschedenddate)
|
|
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTSCHEDDATE, OnDatetimechangeDtscheddate)
|
|
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTSCHEDENDDATE, OnDatetimechangeDtschedenddate)
|
|
ON_BN_CLICKED(IDC_LBLCONTRACT, OnLblcontract)
|
|
ON_BN_CLICKED(IDC_CKANYTIME, OnCkanytime)
|
|
ON_EN_KILLFOCUS(IDC_EDCLIENTCONTACT, OnKillfocusEdclientcontact)
|
|
ON_EN_KILLFOCUS(IDC_EDCLIENTREFNUM, OnKillfocusEdclientrefnum)
|
|
ON_COMMAND(ID_STANWO_DONE, OnStanwoDone)
|
|
ON_COMMAND(ID_STANWO_DELETE, OnStanwoDelete)
|
|
ON_COMMAND(ID_STANWO_PRINT_DISPATCH, OnStanwoPrintDispatch)
|
|
ON_COMMAND(ID_STANWO_PRINT_BRIEF, OnStanwoPrintBrief)
|
|
ON_COMMAND(ID_STANWO_PRINT_DETAILED, OnStanwoPrintDetailed)
|
|
ON_COMMAND(ID_STANWO_COSTATUS, OnStanwoCostatus)
|
|
ON_EN_KILLFOCUS(IDC_EDESTHOURS, OnKillfocusEdesthours)
|
|
ON_CBN_CLOSEUP(IDC_CBESTRATE, OnCloseupCbestrate)
|
|
ON_CBN_CLOSEUP(IDC_CBSTATUS, OnCloseupCbstatus)
|
|
ON_EN_KILLFOCUS(IDC_EDOURREFNUMBER, OnKillfocusEdourrefnumber)
|
|
ON_BN_CLICKED(IDC_LBL_GROUP1, OnLblGroup1)
|
|
ON_BN_CLICKED(IDC_LBL_GROUP2, OnLblGroup2)
|
|
ON_COMMAND(ID_STANWO_CLIENTNOTES, OnStanwoClientnotes)
|
|
ON_BN_CLICKED(IDC_LBLSTATUS, OnLblstatus)
|
|
ON_BN_CLICKED(IDC_LBLHISTORY, OnLblhistory)
|
|
ON_BN_CLICKED(IDC_LBLTECHNOTES, OnLbltechnotes)
|
|
ON_EN_KILLFOCUS(IDC_EDACTIONTAKEN, OnKillfocusEdactiontaken)
|
|
ON_EN_KILLFOCUS(IDC_EDTROUBLEFOUND, OnKillfocusEdtroublefound)
|
|
ON_EN_KILLFOCUS(IDC_EDTROUBLEREPORTED, OnKillfocusEdtroublereported)
|
|
ON_BN_CLICKED(IDC_TEC1, OnTec1)
|
|
ON_BN_CLICKED(IDC_TEC2, OnTec2)
|
|
ON_BN_CLICKED(IDC_TEC3, OnTec3)
|
|
ON_BN_CLICKED(IDC_TEC4, OnTec4)
|
|
//}}AFX_MSG_MAP
|
|
ON_COMMAND_RANGE( _STARTING_PRINT_COMMAND_ID, _STARTING_PRINT_COMMAND_ID+100, OnPrintReport )
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CWOHeaderDlg message handlers
|
|
|
|
BOOL CWOHeaderDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
bool bIsNew=false;
|
|
m_nSelectedTechNumber=1;
|
|
CWaitCursor dummy;
|
|
ShowWindow(FALSE);
|
|
//check user rights
|
|
Security();
|
|
bModified=false;
|
|
|
|
|
|
//check for empty, should be zero
|
|
//or a workorder number, never empty
|
|
ASSERT(!m_strWorkorderID.IsEmpty());
|
|
|
|
//Check if eval database, if so highlight problem items
|
|
//and add text about parts labour etc
|
|
//registered?
|
|
if(m_pApp->m_uiFeatures&LICENSE_REGISTERED)
|
|
{;}
|
|
else
|
|
{
|
|
m_lblTrialDetails.ShowWindow(TRUE);
|
|
m_lblTrialDetails.SetFontBold(TRUE);
|
|
m_lblTrialDetails.SetWindowText("(EDIT or ADD an item in the list below to enter Parts, Labor, Unit, Warranty)");
|
|
m_lblTrialDetails.SetTextColor(RGB(153,0,0));
|
|
//m_lblFind.SetFontUnderline(TRUE);
|
|
//m_lblFind.SetLink(TRUE);
|
|
//m_lblFind.SetLinkCursor(m_pApp->hcHand);
|
|
//m_lblFind.SetLinkURL("");
|
|
|
|
}
|
|
|
|
//"Hyperlink-o-size" labels
|
|
m_lblFind.SetTextColor(RGB(0,0,255));
|
|
m_lblFind.SetFontUnderline(TRUE);
|
|
m_lblFind.SetLink(TRUE);
|
|
m_lblFind.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblFind.SetLinkURL("");
|
|
|
|
|
|
m_lblHist.SetTextColor(RGB(0,0,255));
|
|
m_lblHist.SetFontUnderline(TRUE);
|
|
m_lblHist.SetLink(TRUE);
|
|
m_lblHist.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblHist.SetLinkURL("");
|
|
|
|
//STATUS
|
|
m_lblStatus.SetTextColor(RGB(0,0,255));
|
|
m_lblStatus.SetFontUnderline(TRUE);
|
|
m_lblStatus.SetLink(TRUE);
|
|
m_lblStatus.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblStatus.SetLinkURL("");
|
|
|
|
//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("");
|
|
|
|
m_lblCategories.SetTextColor(RGB(0,0,255));
|
|
m_lblCategories.SetFontUnderline(TRUE);
|
|
m_lblCategories.SetLink(TRUE);
|
|
m_lblCategories.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblCategories.SetLinkURL("");
|
|
|
|
m_lblTechNotes.SetTextColor(RGB(255,0,0));
|
|
m_lblTechNotes.SetFontUnderline(TRUE);
|
|
m_lblTechNotes.SetLink(TRUE);
|
|
m_lblTechNotes.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblTechNotes.SetFontBold(TRUE);
|
|
m_lblTechNotes.SetLinkURL("");
|
|
|
|
|
|
m_lblClients.SetTextColor(RGB(0,0,255));
|
|
m_lblClients.SetFontUnderline(TRUE);
|
|
m_lblClients.SetLink(TRUE);
|
|
m_lblClients.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblClients.SetLinkURL("");
|
|
|
|
m_lblProjects.SetTextColor(RGB(0,0,255));
|
|
m_lblProjects.SetFontUnderline(TRUE);
|
|
m_lblProjects.SetLink(TRUE);
|
|
m_lblProjects.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblProjects.SetLinkURL("");
|
|
|
|
//GROUP1
|
|
m_lblGroup1.SetTextColor(RGB(0,0,0));
|
|
m_lblGroup1.SetFontUnderline(FALSE);
|
|
m_lblGroup1.SetLink(TRUE);
|
|
m_lblGroup1.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblGroup1.SetLinkURL("");
|
|
m_lblGroup1.SetFontSize(14);
|
|
|
|
//GROUP2
|
|
m_lblGroup2.SetTextColor(RGB(0,0,255));
|
|
m_lblGroup2.SetFontUnderline(TRUE);
|
|
m_lblGroup2.SetLink(TRUE);
|
|
m_lblGroup2.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblGroup2.SetLinkURL("");
|
|
m_lblGroup2.SetFontSize(14);
|
|
|
|
//m_lblContactInfo.SetFontBold(TRUE);
|
|
//m_lblContactInfo.SetFontSize(12);
|
|
|
|
m_dtSchedDate.SetTime(COleDateTime::GetCurrentTime());
|
|
m_dtEndDate.SetTime(COleDateTime::GetCurrentTime());
|
|
m_edStartTime.SetWindowText("8:00:00 AM");
|
|
m_edEndTime.SetWindowText("8:00:00 PM");
|
|
|
|
//Display estimate fields?
|
|
if(cbrs->QueryReadOnly("SELECT defaults.woestimate FROM defaults;"))
|
|
cbrs->FetchField("woestimate",&m_bShowEstimates);
|
|
if(m_bShowEstimates)
|
|
{
|
|
FillEstRatesList();
|
|
m_lblEstHours.ShowWindow(TRUE);
|
|
m_lblEstRate.ShowWindow(TRUE);
|
|
m_cbEstRate.ShowWindow(TRUE);
|
|
m_edEstHours.ShowWindow(TRUE);
|
|
m_edEstHours.SetWindowText("0");
|
|
|
|
}
|
|
FillPickLists();
|
|
FillReportList();
|
|
//if this is created from visual schedule
|
|
//then show sched stuff
|
|
if(m_oledtPresetStartDate.GetYear()==1968)
|
|
EnableSched(false);
|
|
else
|
|
EnableSched(true);
|
|
|
|
//only used to change prompt when delete or canel is selected
|
|
m_bAddMode=false;
|
|
if(m_strWorkorderID=="0")
|
|
{
|
|
//v1.9.4.4 - fix for no techs and trying to make a new work order
|
|
if(m_cbSchedTechList.GetCount()<3)
|
|
{
|
|
//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;
|
|
if(CreateWorkorder()==false)
|
|
{
|
|
AfxMessageBox("Unable to create workorder");
|
|
CDialog::OnCancel();
|
|
}
|
|
|
|
//m_ckAnyTime.SetCheck(TRUE);
|
|
m_ckOnsite.SetCheck(m_pApp->m_bDefOnsite ? TRUE : FALSE);
|
|
|
|
//m_btnDeleteWO.SetWindowText("Cancel");
|
|
CMenu* pMenu=this->GetMenu();
|
|
pMenu->ModifyMenu(ID_STANWO_DELETE,MF_BYCOMMAND,ID_STANWO_DELETE,"Cancel add");
|
|
|
|
//only used to change prompt when delete or canel is selected
|
|
m_bAddMode=true;
|
|
}
|
|
else
|
|
FillFields();
|
|
|
|
|
|
CString str;
|
|
str.Format("Workorder #: %s",m_strWorkorderID);
|
|
SetWindowText(str);
|
|
Check4Contract(false);
|
|
|
|
//set notes to 110 chars maximum
|
|
m_edNotes.SetLimitText(110);
|
|
m_edOurRefNum.SetLimitText(80);
|
|
m_edTroubleReported.SetLimitText(250);
|
|
m_edTroubleFound.SetLimitText(250);
|
|
m_edActionTaken.SetLimitText(250);
|
|
|
|
//display default controls
|
|
ShowGroup(1);
|
|
|
|
//===================================================
|
|
// 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);
|
|
//===================================================
|
|
|
|
m_radTech1.SetCheck(TRUE);
|
|
|
|
//specialty form !@#$ing around .... ARRRGGGHHH!!!!
|
|
if(m_pApp->m_bShowProblemActionFields)
|
|
{
|
|
LayoutControls();
|
|
}
|
|
if(bIsNew)
|
|
m_cbClients.SetFocus();
|
|
else
|
|
m_edNotes.SetFocus();
|
|
return FALSE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
|
|
|
|
//*****************************************
|
|
void CWOHeaderDlg::OnLblfind()
|
|
{
|
|
CString str;
|
|
CFindClientDlg d;
|
|
d.SetReturn(&str);
|
|
if(d.DoModal()==IDOK)
|
|
{
|
|
if(str!="0" && !str.IsEmpty())
|
|
m_cbClients.Select(str);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//************************************************
|
|
void CWOHeaderDlg::SetWorkorderID(CString strWorkorderID)
|
|
{
|
|
m_strWorkorderID=strWorkorderID;
|
|
|
|
}
|
|
|
|
//*************************************
|
|
//fill all the combo boxes
|
|
void CWOHeaderDlg::FillPickLists()
|
|
{
|
|
long lData;
|
|
CString strData,strIndex;
|
|
|
|
//============================================
|
|
//CATEGORIES
|
|
m_cbCategories.Clear();
|
|
//first enter default item
|
|
strData="< None >";
|
|
strIndex="0";
|
|
m_cbCategories.AddRow(strData,strIndex);
|
|
|
|
|
|
cbrs->QueryReadOnly("SELECT wotypes.* FROM wotypes ORDER BY wotypes.category;");
|
|
|
|
if(!cbrs->IsEmpty())
|
|
{
|
|
do
|
|
{
|
|
cbrs->FetchField("category",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
m_cbCategories.AddRow(strData,strIndex);
|
|
}while(cbrs->MoveForward());
|
|
}
|
|
m_cbCategories.Select(m_strSelCategory);
|
|
//==========================================
|
|
|
|
//==========================================
|
|
//PROJECTS
|
|
m_cbProjects.Clear();
|
|
strData="< None >";
|
|
strIndex="0";
|
|
m_cbProjects.AddRow(strData,strIndex);
|
|
|
|
|
|
cbrs->QueryReadOnly("SELECT projects.* FROM projects "
|
|
"WHERE (((projects.active)=True)) "
|
|
"ORDER BY projects.name;");
|
|
|
|
|
|
if(!cbrs->IsEmpty())
|
|
{
|
|
do
|
|
{
|
|
cbrs->FetchField("name",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
m_cbProjects.AddRow(strData,strIndex);
|
|
}while(cbrs->MoveForward());
|
|
}
|
|
m_cbProjects.Select(m_strSelProject);
|
|
//============================================
|
|
|
|
//==========================================
|
|
//TECHLIST
|
|
m_cbSchedTechList.Clear();
|
|
strData="< Not used or scheduled >";
|
|
strIndex="-1";
|
|
m_cbSchedTechList.AddRow(strData,strIndex);
|
|
strData="< To be assigned >";
|
|
strIndex="0";
|
|
m_cbSchedTechList.AddRow(strData,strIndex);
|
|
|
|
|
|
cbrs->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(!cbrs->IsEmpty())
|
|
{
|
|
do
|
|
{
|
|
cbrs->FetchField("name",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
m_cbSchedTechList.AddRow(strData,strIndex);
|
|
}while(cbrs->MoveForward());
|
|
m_cbSchedTechList.Select(m_strSelTech);
|
|
}
|
|
|
|
//============================================
|
|
|
|
|
|
|
|
//==========================================
|
|
//CLIENTS LIST
|
|
|
|
m_cbClients.Clear();
|
|
strData=" Select client ";
|
|
strIndex="0";
|
|
m_cbClients.AddRow(strData,strIndex);
|
|
|
|
cbrs->QueryReadOnly("SELECT clients.id, clients.isheadoffice , clients.company AS name "
|
|
"FROM clients WHERE (((clients.isheadoffice)=False)) ORDER BY clients.company;");
|
|
|
|
|
|
if(!cbrs->IsEmpty())
|
|
{
|
|
do
|
|
{
|
|
cbrs->FetchField("name",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
m_cbClients.AddRow(strData,strIndex);
|
|
}while(cbrs->MoveForward());
|
|
}
|
|
m_cbClients.Select(m_strSelClient);
|
|
//============================================
|
|
|
|
|
|
|
|
//==========================================
|
|
//WORKORDER STATUS LIST
|
|
|
|
|
|
//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(m_strSelectedStatus);
|
|
//============================================
|
|
|
|
}
|
|
|
|
|
|
//===================================
|
|
bool CWOHeaderDlg::CreateWorkorder()
|
|
{
|
|
|
|
CString q;
|
|
COleDateTime dtData;
|
|
long lData;
|
|
bool bData;
|
|
|
|
//start a new workorder:
|
|
//open the workorder table with a query guaranteed to
|
|
//return no records as this is probably better performance
|
|
if(!rs->Query("SELECT wo.* FROM wo WHERE (((wo.id)=0));"))
|
|
return false;
|
|
rs->pTheConnection->BeginTrans();
|
|
//now add the new record
|
|
if(!rs->AddNewRecord())
|
|
return false;
|
|
|
|
if(!rs->UpdateField("creator",&m_pApp->m_lusrID))
|
|
return false;
|
|
|
|
if(!rs->UpdateField("modifier",&m_pApp->m_lusrID))
|
|
return false;
|
|
|
|
dtData=COleDateTime::GetCurrentTime();
|
|
|
|
if(!rs->UpdateField("created",&dtData))
|
|
return false;
|
|
|
|
if(!rs->UpdateField("modified",&dtData))
|
|
return false;
|
|
|
|
//--------------------------------------------
|
|
//Added Nov 18th 2000 to accomodate
|
|
//visual scheduling added workorders
|
|
|
|
//Set the tech
|
|
lData=atol(m_strSelTech);
|
|
//added nov 19 2001 to fix vanishing tech problem when opening client record
|
|
m_lSchedTech1=lData;
|
|
if(!rs->UpdateField("assigntech",&lData))
|
|
return false;
|
|
|
|
//Set the start date if applicable
|
|
if(m_oledtPresetStartDate.GetYear()!=1968)
|
|
{
|
|
m_dtSchedStart1=m_oledtPresetStartDate;
|
|
m_dtSchedStart2=m_oledtPresetStartDate;
|
|
m_dtSchedStart3=m_oledtPresetStartDate;
|
|
m_dtSchedStart4=m_oledtPresetStartDate;
|
|
bData=false;
|
|
rs->UpdateField("anytime",&bData);
|
|
rs->UpdateField("starttime",&m_oledtPresetStartDate);
|
|
m_dtSchedDate.SetTime(m_oledtPresetStartDate);
|
|
m_edStartTime.SetWindowText(m_oledtPresetStartDate.Format(VAR_TIMEVALUEONLY));
|
|
}
|
|
|
|
//Set the end date if applicable
|
|
if(m_oledtPresetEndDate.GetYear()!=1968)
|
|
{
|
|
m_dtSchedStop1=m_oledtPresetEndDate;
|
|
m_dtSchedStop2=m_oledtPresetEndDate;
|
|
m_dtSchedStop3=m_oledtPresetEndDate;
|
|
m_dtSchedStop4=m_oledtPresetEndDate;
|
|
|
|
rs->UpdateField("stoptime",&m_oledtPresetEndDate);
|
|
m_dtEndDate.SetTime(m_oledtPresetEndDate);
|
|
m_edEndTime.SetWindowText(m_oledtPresetEndDate.Format(VAR_TIMEVALUEONLY));
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
//added 09/01/2001 wasn't saving properly
|
|
//SET THE DEFONSITE FIELD
|
|
bData=m_pApp->m_bDefOnsite;
|
|
rs->UpdateField("onsite",&bData);
|
|
|
|
|
|
|
|
// SET THE DEFAULT STATUS of this new workorder
|
|
rs->UpdateField("status",&m_pApp->m_lDefNewWOStatus);
|
|
m_strSelectedStatus.Format("%u",m_pApp->m_lDefNewWOStatus);
|
|
m_cbStatus.Select(m_strSelectedStatus);
|
|
|
|
if(!rs->SaveRecord())
|
|
return false;
|
|
rs->pTheConnection->CommitTrans();
|
|
rs->Close();
|
|
//now go back and find the record just created to get the id number
|
|
//by using some unique variables for the query
|
|
q.Format("SELECT wo.* FROM wo WHERE (((wo.creator)=%u) "
|
|
"AND ((wo.created)=#%s#) AND ((wo.client)=0));",m_pApp->m_lusrID,dtData.Format(_T("%m/%d/%Y %H:%M:%S")));
|
|
if(!rs->Query(q))
|
|
return false;
|
|
|
|
if(!rs->FetchField("id",&lData))
|
|
return false;
|
|
|
|
m_strWorkorderID.Format("%u",lData);
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
|
|
|
|
//************************************************************
|
|
//SAVE EDIT CONTROL FIELD
|
|
//************************************************************
|
|
bool CWOHeaderDlg::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();
|
|
UpdateModified();
|
|
return true;
|
|
}
|
|
|
|
//************************************************************
|
|
//SAVE GZCOMBO CONTROL FIELD
|
|
//************************************************************
|
|
bool CWOHeaderDlg::SaveField(CgzCombo *cbControl,CString fldname)
|
|
{
|
|
|
|
|
|
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 CWOHeaderDlg::SaveField(CButton *ckControl,CString fldname)
|
|
{
|
|
|
|
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 CWOHeaderDlg::SaveField(CDateTimeCtrl *dtControl,CString fldname)
|
|
{
|
|
|
|
COleDateTime dtData;
|
|
dtControl->GetTime(dtData);
|
|
rs->UpdateField(fldname,&dtData);
|
|
rs->SaveRecord();
|
|
UpdateModified();
|
|
return true;
|
|
}
|
|
//************************************************
|
|
//UPDATE MODIFIED DATA
|
|
//*************************************************
|
|
bool CWOHeaderDlg::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();
|
|
bModified=true;
|
|
|
|
return true;
|
|
}
|
|
|
|
void CWOHeaderDlg::OnBtnaddprob()
|
|
{
|
|
//check for client selected
|
|
if(m_cbClients.GetCurrentRowID()=="0")
|
|
{
|
|
AfxMessageBox("Please select a client before proceeding.");
|
|
return;
|
|
}
|
|
CWODlg d;
|
|
//set problem ID to zero to indicate new problem
|
|
d.SetIDValues(m_strWorkorderID,"0",m_strSelClient,&bModified);
|
|
/*if(d.DoModal()==IDOK)
|
|
{
|
|
FillProblemList();
|
|
bModified=true;
|
|
}*/
|
|
d.DoModal();
|
|
FillProblemList();
|
|
bModified=true;
|
|
}
|
|
|
|
void CWOHeaderDlg::OnBtndeleteprob()
|
|
{
|
|
CString strSelectedProblemID,q;
|
|
strSelectedProblemID=m_lbProblems.GetSelectedItem(0);
|
|
if(strSelectedProblemID=="0" || strSelectedProblemID.IsEmpty())//no selection
|
|
return;
|
|
if(AfxMessageBox("Warning: Do you really want to delete this problem\r\n"
|
|
"And all it's labor, parts and other information?",MB_YESNO)==IDNO)
|
|
return;
|
|
|
|
//still here, so lets start a-deletin'
|
|
|
|
//LABOUR
|
|
q.Format("DELETE labor.*, labor.link FROM labor "
|
|
"WHERE (((labor.link)=%s));",strSelectedProblemID);
|
|
rs->Ex(q);
|
|
|
|
//SUBREPAIRS
|
|
q.Format("DELETE subrepair.*, subrepair.link FROM subrepair "
|
|
"WHERE (((subrepair.link)=%s));",strSelectedProblemID);
|
|
rs->Ex(q);
|
|
|
|
//PARTS
|
|
q.Format("DELETE woparts.*, woparts.link FROM woparts "
|
|
"WHERE (((woparts.link)=%s));",strSelectedProblemID);
|
|
rs->Ex(q);
|
|
|
|
//PROBLEM ITSELF
|
|
q.Format("DELETE probs.*, probs.link FROM probs "
|
|
"WHERE (((probs.id)=%s));",strSelectedProblemID);
|
|
rs->Ex(q);
|
|
|
|
//Refresh the view
|
|
FillProblemList();
|
|
bModified=true;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CWOHeaderDlg::OnBtneditprobs()
|
|
{
|
|
CString strSelectedProblemID;
|
|
m_lbProblems.RebuildIndex();
|
|
strSelectedProblemID=m_lbProblems.GetSelectedItem(0);
|
|
if(strSelectedProblemID=="0" || strSelectedProblemID.IsEmpty())//no selection
|
|
return;
|
|
CWODlg d;
|
|
|
|
d.SetIDValues(m_strWorkorderID,strSelectedProblemID,m_strSelClient, &bModified);
|
|
d.DoModal();
|
|
FillProblemList();
|
|
}
|
|
|
|
|
|
|
|
|
|
//****************************************
|
|
void CWOHeaderDlg::OnClientlistLabel()
|
|
{ /*
|
|
CClientsDlg d;
|
|
d.DoModal();
|
|
FillPickLists();
|
|
*/
|
|
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)
|
|
{
|
|
FillPickLists();
|
|
m_cbClients.Select(str);
|
|
}
|
|
|
|
OnTec1();
|
|
}
|
|
//*****************************************
|
|
void CWOHeaderDlg::OnCategorylistlabel()
|
|
{
|
|
CWOTypesDlg d;
|
|
d.DoModal();
|
|
FillPickLists();
|
|
OnTec1();
|
|
}
|
|
|
|
//**********************************************
|
|
void CWOHeaderDlg::OnLblprojects()
|
|
{
|
|
CProjectsDlg d;
|
|
d.DoModal();
|
|
FillPickLists();
|
|
OnTec1();
|
|
|
|
}
|
|
|
|
|
|
//*******************************************
|
|
void CWOHeaderDlg::OnCloseupCbcategory()
|
|
{
|
|
SaveField(&m_cbCategories,"type");
|
|
m_strSelCategory=m_cbCategories.GetCurrentRowID();
|
|
}
|
|
|
|
void CWOHeaderDlg::OnCloseupCbclients()
|
|
{
|
|
//Added check to avoid repetition if client not changed
|
|
CString strData;
|
|
if(m_bAlertPopup)
|
|
return;
|
|
strData=m_cbClients.GetCurrentRowID();
|
|
if(strData==m_strSelClient) return;
|
|
|
|
if(!m_bIsOpen && !m_bAddMode)
|
|
if(AfxMessageBox(
|
|
"Warning:\r\n"
|
|
"This workorder is closed!\r\n"
|
|
"Are you certain you want to change the client?",MB_YESNO)==IDNO)
|
|
{
|
|
m_cbClients.Select(m_strSelClient);
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_strSelClient=m_cbClients.GetCurrentRowID();
|
|
|
|
//not a client then exit
|
|
if(m_strSelClient=="0") return;
|
|
|
|
SaveField(&m_cbClients,"client");
|
|
m_lClientDefaultRate=0;
|
|
Check4Contract(true);//now gets default rate as well: m_lClientDefaultRate
|
|
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);
|
|
//update estimated rate using client default if hours are zero only
|
|
m_edEstHours.GetWindowText(strData);
|
|
if(strData!="0") return;
|
|
|
|
if(m_lClientDefaultRate!=0)
|
|
{
|
|
m_cbEstRate.Select(m_lClientDefaultRate);
|
|
SaveField(&m_cbEstRate,"estrate");
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnCloseupCbprojects()
|
|
{
|
|
SaveField(&m_cbProjects,"project");
|
|
m_strSelProject=m_cbProjects.GetCurrentRowID();
|
|
}
|
|
|
|
void CWOHeaderDlg::OnCloseupCbschedtechlist()
|
|
{
|
|
m_strSelTech=m_cbSchedTechList.GetCurrentRowID();
|
|
switch(m_nSelectedTechNumber)
|
|
{
|
|
case 1:
|
|
SaveField(&m_cbSchedTechList,"assigntech");
|
|
m_lSchedTech1=atol(m_strSelTech);
|
|
break;
|
|
case 2:
|
|
SaveField(&m_cbSchedTechList,"assigntech2");
|
|
m_lSchedTech2=atol(m_strSelTech);
|
|
break;
|
|
case 3:
|
|
SaveField(&m_cbSchedTechList,"assigntech3");
|
|
m_lSchedTech3=atol(m_strSelTech);
|
|
break;
|
|
case 4:
|
|
SaveField(&m_cbSchedTechList,"assigntech4");
|
|
m_lSchedTech4=atol(m_strSelTech);
|
|
break;
|
|
|
|
}
|
|
|
|
//v1.9.4.4 fix bug where picking a tech but not selecting
|
|
//any date or time would result in not displaying a time bar for that tech
|
|
//in schedule screen (duhhh! We're really scraping the bottom of the barrel here)
|
|
SaveStartDate(false);
|
|
SaveEndDate();
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnCkonsite()
|
|
{
|
|
SaveField(&m_ckOnsite,"onsite");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CWOHeaderDlg::OnKillfocusEdinvoice()
|
|
{
|
|
SaveField(&m_edInvoice,"invoice",true);
|
|
|
|
}
|
|
|
|
//******************************************
|
|
void CWOHeaderDlg::OnKillfocusEdwonotes()
|
|
{
|
|
SaveField(&m_edNotes,"notes",true);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CWOHeaderDlg::OnDblclkLbprobs()
|
|
{
|
|
|
|
//same as clicking on edit
|
|
//except you have to force a kill focus
|
|
//so that the list gets filled
|
|
m_lbProblems.RebuildIndex();
|
|
OnBtneditprobs();
|
|
|
|
}
|
|
|
|
//**************************************************************
|
|
void CWOHeaderDlg::OnKillfocusEdschedstarttime()
|
|
{
|
|
|
|
|
|
//no changes then don't bother
|
|
if(m_edStartTime.GetModify()!=TRUE) return;
|
|
SaveStartDate(false);
|
|
/*
|
|
|
|
COleDateTime dtDate,dtTime;
|
|
m_dtSchedDate.GetTime(dtDate);
|
|
CString strData;
|
|
m_edStartTime.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_edStartTime.SetWindowText(strData);
|
|
|
|
//save the complete date/time
|
|
dtTime.SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
|
rs->UpdateField("starttime",&dtTime);
|
|
rs->SaveRecord();
|
|
m_edStartTime.SetModify(FALSE);
|
|
UpdateModified();
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
//*************************************************
|
|
//END TIME
|
|
void CWOHeaderDlg::OnKillfocusEdschedendtime()
|
|
{
|
|
//no changes then don't bother
|
|
if(m_edEndTime.GetModify()!=TRUE) return;
|
|
SaveEndDate();
|
|
/*
|
|
|
|
COleDateTime dtDate,dtTime;
|
|
m_dtEndDate.GetTime(dtDate);
|
|
CString strData;
|
|
m_edEndTime.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_edEndTime.SetWindowText(strData);
|
|
|
|
//save the complete date/time
|
|
dtTime.SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
|
rs->UpdateField("stoptime",&dtTime);
|
|
rs->SaveRecord();
|
|
m_edEndTime.SetModify(FALSE);
|
|
UpdateModified();
|
|
*/
|
|
|
|
}
|
|
//*********************************************
|
|
//END DATE
|
|
void CWOHeaderDlg::OnKillfocusDtschedenddate(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
|
|
SaveEndDate();
|
|
*pResult = 0;
|
|
}
|
|
|
|
|
|
//****************************************************
|
|
//START DATE
|
|
void CWOHeaderDlg::OnKillfocusDtscheddate(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
|
|
SaveStartDate();
|
|
|
|
*pResult = 0;
|
|
}
|
|
|
|
//***********************************************
|
|
void CWOHeaderDlg::OnDatetimechangeDtscheddate(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
SaveStartDate();
|
|
|
|
*pResult = 0;
|
|
}
|
|
//************************
|
|
void CWOHeaderDlg::OnDatetimechangeDtschedenddate(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
SaveEndDate();
|
|
*pResult = 0;
|
|
}
|
|
|
|
|
|
//************************************
|
|
void CWOHeaderDlg::SaveStartDate(bool bResetEndDate)
|
|
{
|
|
COleDateTime dtDate,dtTime;
|
|
m_dtSchedDate.GetTime(dtDate);
|
|
CString strData;
|
|
m_edStartTime.GetWindowText(strData);
|
|
|
|
if(dtTime.ParseDateTime(strData,VAR_TIMEVALUEONLY)==FALSE)
|
|
{
|
|
AfxMessageBox("Invalid starting *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_edStartTime.SetWindowText(strData);
|
|
|
|
//save the complete date/time
|
|
dtTime.SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
|
|
|
//modified 07/26/01 to accomodate multi-techs
|
|
switch(m_nSelectedTechNumber)
|
|
{
|
|
case 1:
|
|
rs->UpdateField("starttime",&dtTime);
|
|
m_dtSchedStart1=dtTime;
|
|
break;
|
|
case 2:
|
|
rs->UpdateField("starttime2",&dtTime);
|
|
m_dtSchedStart2=dtTime;
|
|
break;
|
|
case 3:
|
|
rs->UpdateField("starttime3",&dtTime);
|
|
m_dtSchedStart3=dtTime;
|
|
break;
|
|
case 4:
|
|
rs->UpdateField("starttime4",&dtTime);
|
|
m_dtSchedStart4=dtTime;
|
|
break;
|
|
|
|
}
|
|
|
|
//change the end date to match
|
|
//as 90% of the time it should be on the same
|
|
//day
|
|
|
|
//10/12/2002
|
|
//90% isn't good enough:
|
|
if(bResetEndDate)
|
|
m_dtEndDate.SetTime(dtTime);
|
|
|
|
rs->SaveRecord();
|
|
UpdateModified();
|
|
SaveEndDate();
|
|
}
|
|
|
|
|
|
//**************************************
|
|
void CWOHeaderDlg::SaveEndDate()
|
|
{
|
|
COleDateTime dtDate,dtTime;
|
|
m_dtEndDate.GetTime(dtDate);
|
|
CString strData;
|
|
m_edEndTime.GetWindowText(strData);
|
|
|
|
if(dtTime.ParseDateTime(strData,VAR_TIMEVALUEONLY)==FALSE)
|
|
{
|
|
AfxMessageBox("Invalid end *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_edEndTime.SetWindowText(strData);
|
|
|
|
//save the complete date/time
|
|
dtTime.SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
|
|
|
//rs->UpdateField("stoptime",&dtTime);
|
|
//modified 07/26/01 to accomodate multi-techs
|
|
switch(m_nSelectedTechNumber)
|
|
{
|
|
case 1:
|
|
rs->UpdateField("stoptime",&dtTime);
|
|
m_dtSchedStop1=dtTime;
|
|
break;
|
|
case 2:
|
|
rs->UpdateField("stoptime2",&dtTime);
|
|
m_dtSchedStop2=dtTime;
|
|
break;
|
|
case 3:
|
|
rs->UpdateField("stoptime3",&dtTime);
|
|
m_dtSchedStop3=dtTime;
|
|
break;
|
|
case 4:
|
|
rs->UpdateField("stoptime4",&dtTime);
|
|
m_dtSchedStop4=dtTime;
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rs->SaveRecord();
|
|
UpdateModified();
|
|
|
|
}
|
|
|
|
|
|
//Fill fields from existing record
|
|
void CWOHeaderDlg::FillFields()
|
|
{
|
|
CString q,strData;
|
|
long lData;
|
|
COleDateTime dtData;
|
|
bool bData;
|
|
float fEstHours;
|
|
q.Format("SELECT wo.* FROM wo WHERE (((wo.id)=%s));",m_strWorkorderID);
|
|
rs->Query(q);
|
|
|
|
//OUR REFERENCE NUMBER
|
|
rs->FetchField("ourref",&strData);
|
|
m_edOurRefNum.SetWindowText(strData);
|
|
|
|
//STATUS
|
|
rs->FetchField("status",&lData);
|
|
strData.Format("%u",lData);
|
|
m_strSelectedStatus=strData;
|
|
m_cbStatus.Select(strData);
|
|
|
|
//ESTIMATED HOURS
|
|
rs->FetchField("esthours",&fEstHours);
|
|
//01/31/2003 localization fix for floats
|
|
//convert float to localized string
|
|
//_variant_t vItem(fEstHours);
|
|
//vItem.ChangeType(VT_BSTR,NULL);
|
|
//strData=vItem.bstrVal;
|
|
|
|
//strData.Format("%g",fEstHours);
|
|
m_edEstHours.SetWindowText(FtoA(fEstHours));
|
|
|
|
//ESTIMATED RATE
|
|
rs->FetchField("estrate",&lData);
|
|
strData.Format("%u",lData);
|
|
m_cbEstRate.Select(strData);
|
|
|
|
|
|
//PROJECT
|
|
rs->FetchField("project",&lData);
|
|
strData.Format("%u",lData);
|
|
m_strSelProject=strData;
|
|
m_cbProjects.Select(strData);
|
|
|
|
//CLIENT
|
|
rs->FetchField("client",&lData);
|
|
strData.Format("%u",lData);
|
|
m_cbClients.Select(strData);
|
|
m_strSelClient=strData;
|
|
|
|
//TYPE
|
|
rs->FetchField("type",&lData);
|
|
strData.Format("%u",lData);
|
|
m_strSelCategory=strData;
|
|
m_cbCategories.Select(strData);
|
|
|
|
//CLOSED/OPEN
|
|
rs->FetchField("closed",&dtData);
|
|
m_bIsOpen=false;
|
|
if(dtData.GetYear()==1968)//it's open
|
|
m_bIsOpen=true;
|
|
UpdateClosedOpen();
|
|
|
|
//NOTES
|
|
rs->FetchField("notes",&strData);
|
|
m_edNotes.SetWindowText(strData);
|
|
|
|
//ONSITE
|
|
rs->FetchField("onsite",&bData);
|
|
m_ckOnsite.SetCheck(bData ? TRUE : FALSE);
|
|
|
|
//ANYTIME
|
|
rs->FetchField("anytime",&bData);
|
|
m_ckAnyTime.SetCheck(bData ? TRUE : FALSE);
|
|
if(bData)
|
|
EnableSched(false);
|
|
else
|
|
EnableSched(true);
|
|
|
|
//---------------------------Fetch tech fields -----------------
|
|
//STARTTIME/START DATE
|
|
rs->FetchField("starttime",&m_dtSchedStart1);
|
|
rs->FetchField("starttime2",&m_dtSchedStart2);
|
|
rs->FetchField("starttime3",&m_dtSchedStart3);
|
|
rs->FetchField("starttime4",&m_dtSchedStart4);
|
|
|
|
//ASSIGNTECH
|
|
rs->FetchField("assigntech",&m_lSchedTech1);
|
|
rs->FetchField("assigntech2",&m_lSchedTech2);
|
|
rs->FetchField("assigntech3",&m_lSchedTech3);
|
|
rs->FetchField("assigntech4",&m_lSchedTech4);
|
|
|
|
//ENDTIME/END DATE
|
|
rs->FetchField("stoptime",&m_dtSchedStop1);
|
|
rs->FetchField("stoptime2",&m_dtSchedStop2);
|
|
rs->FetchField("stoptime3",&m_dtSchedStop3);
|
|
rs->FetchField("stoptime4",&m_dtSchedStop4);
|
|
|
|
ShowSchedTech();
|
|
//----------------------------------------------------------------
|
|
|
|
//INVOICE
|
|
rs->FetchField("invoice",&strData);
|
|
m_edInvoice.SetWindowText(strData);
|
|
|
|
//CLIENT REFERENCE NUMBER
|
|
rs->FetchField("clientrefnum",&strData);
|
|
m_edClientRefNum.SetWindowText(strData);
|
|
|
|
//CLIENT CONTACT
|
|
rs->FetchField("clientcontact",&strData);
|
|
m_edClientContact.SetWindowText(strData);
|
|
|
|
//Trouble reported
|
|
rs->FetchField("prob_reported",&strData);
|
|
m_edTroubleReported.SetWindowText(strData);
|
|
|
|
//Trouble found
|
|
rs->FetchField("prob_found",&strData);
|
|
m_edTroubleFound.SetWindowText(strData);
|
|
|
|
//Action taken
|
|
rs->FetchField("action_taken",&strData);
|
|
m_edActionTaken.SetWindowText(strData);
|
|
|
|
|
|
|
|
FillProblemList();
|
|
|
|
DisplayContactInfo();
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::FillProblemList()
|
|
{
|
|
CString q,strData,str,strIndex;
|
|
long lData;
|
|
//PROBLEM LIST
|
|
m_lbProblems.Clear();
|
|
q.Format("SELECT probs.id, probs.brief as name, probstat.notes AS stat "
|
|
"FROM probstat RIGHT JOIN probs ON probstat.id = probs.status "
|
|
"WHERE (((probs.wolink)=%s)) ORDER BY probs.id;",m_strWorkorderID);
|
|
|
|
cbrs->QueryReadOnly(q);
|
|
|
|
if(!cbrs->IsEmpty())
|
|
{
|
|
do
|
|
{
|
|
cbrs->FetchField("name",&strData);
|
|
if(strData.IsEmpty())
|
|
strData="<Description unavailable> ";
|
|
str=strData.SpanExcluding( "\r\n");
|
|
cbrs->FetchField("stat",&strData);
|
|
str=str + " <" + strData + ">";
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
//SpanExcluding to return the first line only
|
|
m_lbProblems.AddRow(str,strIndex);
|
|
}while(cbrs->MoveForward());
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//security function
|
|
void CWOHeaderDlg::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_radTech4.EnableWindow(FALSE);
|
|
//m_radTech3.EnableWindow(FALSE);
|
|
//m_radTech2.EnableWindow(FALSE);
|
|
m_grpSchedTechGroup.EnableWindow(FALSE);
|
|
//m_radTech1.EnableWindow(FALSE);
|
|
|
|
m_edTroubleReported.EnableWindow(FALSE);
|
|
m_edTroubleFound.EnableWindow(FALSE);
|
|
m_edActionTaken.EnableWindow(FALSE);
|
|
m_edOurRefNum.EnableWindow(FALSE);
|
|
m_cbStatus.EnableWindow(FALSE);
|
|
m_edClientContact.EnableWindow(FALSE);
|
|
m_edClientRefNum.EnableWindow(FALSE);
|
|
m_edEstHours.EnableWindow(FALSE);
|
|
m_cbEstRate.EnableWindow(FALSE);
|
|
m_ckAnyTime.EnableWindow(FALSE);
|
|
m_edStartTime.EnableWindow(FALSE);
|
|
m_edEndTime.EnableWindow(FALSE);
|
|
m_dtEndDate.EnableWindow(FALSE);
|
|
//m_lbProblems;
|
|
|
|
m_edNotes.EnableWindow(FALSE);
|
|
m_edInvoice.EnableWindow(FALSE);
|
|
m_dtSchedDate.EnableWindow(FALSE);
|
|
m_lblClients.EnableWindow(FALSE);
|
|
m_ckOnsite.EnableWindow(FALSE);
|
|
m_cbSchedTechList.EnableWindow(FALSE);
|
|
m_cbProjects.EnableWindow(FALSE);
|
|
m_cbClients.EnableWindow(FALSE);
|
|
m_cbCategories.EnableWindow(FALSE);
|
|
//m_btnEditProblem.EnableWindow(FALSE);
|
|
m_btnDeleteProblem.EnableWindow(FALSE);
|
|
m_btnAddProblem.EnableWindow(FALSE);
|
|
|
|
//disable delete workorder option
|
|
CMenu* pMenu=this->GetMenu();
|
|
pMenu->EnableMenuItem(ID_STANWO_DELETE, MF_DISABLED | MF_GRAYED);
|
|
//v1.9.4.2 disable change status option
|
|
pMenu->EnableMenuItem(ID_STANWO_COSTATUS, MF_DISABLED | MF_GRAYED);
|
|
|
|
//v1.9.4.4
|
|
m_lblCategories.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_STANWO_DELETE, MF_DISABLED | MF_GRAYED);
|
|
}
|
|
}
|
|
|
|
|
|
void CWOHeaderDlg::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);
|
|
|
|
|
|
}
|
|
|
|
|
|
//NOT only check for contract but get tech notes
|
|
//10/12/2002 and now get default rate from client record as well
|
|
void CWOHeaderDlg::Check4Contract(bool bAlert)
|
|
{
|
|
|
|
CString q,strAlert;
|
|
long lContract,lHeadOffice;
|
|
|
|
//check for contract
|
|
m_lblContract.ShowWindow(FALSE);
|
|
m_strClientContractID.Empty();
|
|
|
|
|
|
//return if no client selected to avoid errors
|
|
if(m_strSelClient=="0") return;
|
|
|
|
|
|
//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], [clients].[defrate] "
|
|
"FROM clients WHERE ((([clients].[id])=%s) And "
|
|
"(([clients].[isheadoffice])=False));",m_strSelClient);
|
|
cbrs->QueryReadOnly(q);
|
|
if(cbrs->IsEmpty()) return;
|
|
|
|
//new: added 10/12/2002
|
|
//fetch default rate to set estimated rate box
|
|
cbrs->FetchField("defrate",&m_lClientDefaultRate);
|
|
|
|
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;
|
|
strAlert="Client alert message:\r\n"+strAlert;
|
|
AfxMessageBox(strAlert,MB_ICONINFORMATION);
|
|
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 CWOHeaderDlg::OnCkanytime()
|
|
{
|
|
bool anytime;
|
|
anytime=m_ckAnyTime.GetCheck() ? true : false;
|
|
EnableSched(false);
|
|
if(!anytime)
|
|
{//set defaults and save 'em
|
|
m_dtEndDate.SetTime(COleDateTime::GetCurrentTime());
|
|
m_dtSchedDate.SetTime(COleDateTime::GetCurrentTime());
|
|
m_edEndTime.SetWindowText("8:00pm");
|
|
m_edStartTime.SetWindowText("8:00am");
|
|
SaveStartDate();
|
|
SaveEndDate();
|
|
EnableSched(true);
|
|
}
|
|
SaveField(&m_ckAnyTime,"anytime");
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::EnableSched(bool bEnable)
|
|
{
|
|
if(m_bReadOnly) return;
|
|
BOOL enable = bEnable ? TRUE : FALSE;
|
|
m_ckAnyTime.SetCheck(!bEnable);
|
|
m_dtEndDate.EnableWindow(enable);
|
|
m_dtSchedDate.EnableWindow(enable);
|
|
m_edEndTime.EnableWindow(enable);
|
|
m_edStartTime.EnableWindow(enable);
|
|
m_lblTechs.EnableWindow(enable);
|
|
m_cbSchedTechList.EnableWindow(enable);
|
|
//m_lbls1.EnableWindow(enable);
|
|
m_lbls2.EnableWindow(enable);
|
|
m_lbls3.EnableWindow(enable);
|
|
m_lbls4.EnableWindow(enable);
|
|
m_lbls5.EnableWindow(enable);
|
|
m_lbls6.EnableWindow(enable);
|
|
m_radTech1.EnableWindow(enable);
|
|
m_radTech2.EnableWindow(enable);
|
|
m_radTech3.EnableWindow(enable);
|
|
m_radTech4.EnableWindow(enable);
|
|
m_grpSchedTechGroup.EnableWindow(enable);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::PrintFinalWorkorder(CString strReport)
|
|
{
|
|
CString q;
|
|
CString strData;
|
|
|
|
|
|
//print the workorder selected in the combo box
|
|
//3 occurences of wor number.
|
|
/*
|
|
//CHANGES 8/16/00 change INNER JOIN PARTS... to LEFT JOIN PARTS as
|
|
//misc parts were not showing on printed workorder since they didn't
|
|
//appear in the parts table. Left join is all woparts and only matching parts
|
|
//previous inner join required both to match which doesn't happen with a misc...blah blah blah ramble ramble etc.
|
|
|
|
UPDATE 1/5/2001 that part above about misc part descriptions still wasn't working because a missing misc part is not null, but zero length
|
|
// fixed it now.
|
|
|
|
The big news: If you have a memo field in a UNION query use the keyword ALL after UNION or it will try to remove duplicates
|
|
in the memo fields and since they are memo fields they are unsortable.
|
|
*/
|
|
|
|
q.Format("SELECT \"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, wom.probnum, wom.ctype, wom.LABPN, wom.TRAVPN, wom.PROBNOTES, wom.PROBBRIEF, wom.item, wom.linetotal, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.created AS wodate, wo.id AS "
|
|
"wonumber, wo.invoice, wo.notes, wo.prob_reported, wo.prob_found, wo.action_taken, clients.billheadoffice, clients.first, clients.last, clients.mailaddress, clients.streetaddress, "
|
|
"clients.city, clients.stateprov, clients.postal, clients.country, clients.bizphone, clients.extension, "
|
|
"clients.fax, clients.email, [clients].[company] AS clientname, IIf(IsNull([headoffices].[company]),[headoffices].[last] & \", \" & "
|
|
"[headoffices].[first],[headoffices].[company]) AS headname, wom.details, wom.STARTDATE, wom.STOPDATE, projects.name AS PROJNAME, projects.notes AS PROJNOTES "
|
|
|
|
"FROM (((units RIGHT JOIN (probs RIGHT JOIN ((([SELECT \"1\" AS ctype, rates.partnum AS LABPN, travelrates.partnum AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink AS "
|
|
"wonum, \"Service: \" & users.first & \" \" & users.last & \" - \" & IIf(labor.hours>0,labor.hours & \" @ \" & "
|
|
"Format(rates.rate,\"Currency\") & \" (pn:\" & rates.partnum & \")\",\"\") & IIf(labor.nchours>0,\" (\" & labor.nchours "
|
|
"& \" no charge)\",\"\") & IIf(labor.travhours>0,\", \" & labor.travhours & \" travel @ \" & "
|
|
"Format(travelrates.rate,\"Currency\") & IIf(IsNull(travelrates.partnum),\"\",\" (pn:\" & travelrates.partnum & \")\"),"
|
|
"\"\") AS item, (labor.hours*rates.rate)+(labor.travhours*travelrates.rate) AS linetotal,labor.details, labor.start AS STARTDATE, labor.stop as STOPDATE FROM users "
|
|
"INNER JOIN (rates AS travelrates INNER JOIN (rates INNER JOIN (labor INNER JOIN probs ON labor.link = "
|
|
"probs.id) ON rates.id = labor.rate) ON travelrates.id = labor.travrate) ON users.id = labor.tech WHERE "
|
|
|
|
"(((probs.wolink)=%s)) UNION ALL (SELECT \"2\" AS ctype, \"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, \"Parts: \" & "
|
|
"IIf(IsNull(woparts.misc),parts.partnumber & \" \" & parts.description & \": \" & woparts.quantity & \" @ \" & "
|
|
"Format(woparts.price,\"Currency\") & \" ea.(sn:\" & woparts.sn & \")\",woparts.misc & \": \" & woparts.quantity & \" @ \" & "
|
|
"Format(woparts.price,\"Currency\")& \" ea.(sn:\" & woparts.sn & \")\") AS item, woparts.quantity*woparts.price AS linetotal,\"\" AS details, #03/12/1968# AS STARTDATE, #03/12/1968# AS STOPDATE FROM "
|
|
"(probs INNER JOIN woparts ON probs.id = woparts.link) LEFT JOIN parts ON woparts.partnum = parts.id WHERE "
|
|
|
|
"(((probs.wolink)=%s)) UNION ALL (SELECT \"3\" AS ctype,\"na\" AS LABPN, \"na\" AS TRAVPN, probs.notes AS PROBNOTES, probs.brief AS PROBBRIEF, probs.id AS probnum, probs.wolink as wonum, "
|
|
"\"Third party service: \" AS item, subrepair.charge AS linettotal, \"\" AS details, #03/12/1968# AS STARTDATE, #03/12/1968# AS STOPDATE FROM probs INNER JOIN subrepair "
|
|
|
|
|
|
|
|
"ON probs.id = subrepair.link WHERE (((probs.wolink)=%s) AND ((subrepair.charge)<>0))))]. AS wom LEFT JOIN wo "
|
|
"ON wom.wonum = wo.id) LEFT JOIN clients ON wo.client = clients.id) LEFT JOIN clients AS headoffices ON "
|
|
"clients.headoffice = headoffices.id) ON probs.id = wom.probnum) ON units.id = probs.unit) LEFT JOIN unitmodels "
|
|
"ON units.model = unitmodels.id) LEFT JOIN nonclients ON unitmodels.manufacturer = nonclients.id) LEFT JOIN projects ON wo.project = projects.id ORDER BY wom.STARTDATE DESC;",
|
|
m_pApp->m_strRegCompany,m_strWorkorderID,
|
|
m_strWorkorderID, m_strWorkorderID);
|
|
|
|
|
|
|
|
|
|
//dont allow this to creep into a release build
|
|
|
|
#ifdef _DEBUG
|
|
|
|
m_pApp->ShowStuff(q);
|
|
|
|
#endif
|
|
|
|
Flush(true);
|
|
rsPrint->QueryReadOnly(q);
|
|
rsPrint->QueryReadOnly(q);
|
|
|
|
|
|
|
|
|
|
if(!rsPrint->IsEmpty())
|
|
{
|
|
|
|
|
|
#ifdef _DEBUG
|
|
m_pApp->CreateTTX("wostand.ttx",rsPrint->RecordSetPointer());
|
|
#endif
|
|
|
|
m_pApp->PrintCMReportRDC(strReport,rsPrint->RecordSetPointer());
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
AfxMessageBox("There is no data to print. \r\nMake sure you have at least one labor item or part on this workorder.\r\nThis can also be caused by not having at least one travel rate.\r\nEven if you don't use travel rates create one \"dummy\" travel rate.");
|
|
|
|
|
|
}
|
|
|
|
|
|
Flush(false);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::PrintDispatchWorkorder()
|
|
{
|
|
|
|
CString q,strReport;
|
|
bool bNoParts;
|
|
CString strData,strRateID,strTech,strRateDescription;
|
|
float fHours=0;
|
|
CgzCurrencyFormatter cfm;
|
|
COleCurrency crData;
|
|
strRateID=m_cbEstRate.GetCurrentRowID();
|
|
if(strRateID.IsEmpty()) strRateID="0";
|
|
|
|
//Moved out of conditional section immediately below
|
|
m_cbSchedTechList.GetWindowText(strTech);
|
|
|
|
|
|
if(m_bShowEstimates)
|
|
{
|
|
|
|
m_cbEstRate.GetWindowText(strRateDescription);
|
|
q.Format("SELECT rates.rate FROM rates "
|
|
"WHERE (((rates.id)=%s));",strRateID);
|
|
rsPrint->QueryReadOnly(q);
|
|
if(rsPrint->IsEmpty())
|
|
{
|
|
AfxMessageBox("Can't find estimated rate you selected");
|
|
crData.SetCurrency(0,0);
|
|
fHours=0;
|
|
|
|
}
|
|
else
|
|
{
|
|
rsPrint->FetchField("rate",&crData);
|
|
m_edEstHours.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);
|
|
//fHours=(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
|
|
{
|
|
fHours=(float)vtData;//cast variant to float (locale friendly)
|
|
}
|
|
catch( _com_error &e )
|
|
{
|
|
//Since this is caught at time of entry, doing it again here seems redundant
|
|
//but just in case threw in this try/catch block and default to zero
|
|
fHours=0;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
crData.SetCurrency(0,0);
|
|
fHours=0;
|
|
|
|
}
|
|
|
|
strRateDescription=strRateDescription + ": " + cfm.Format(crData);
|
|
//print the dispatch format workorder
|
|
|
|
q.Format(
|
|
"SELECT \"%s\" AS estrate, \"%s\" AS scheduledtech, %f AS esthours, "
|
|
"IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) "
|
|
"AS clientname, IIf(IsNull([clients].[streetaddress]),[clients].[mailaddress],[clients].[streetaddress]) "
|
|
"& IIf(IsNull([clients].[city]),\"\",Chr(13) & [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.notes AS wonotes, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.prob_reported, wo.prob_found, wo.action_taken, 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], wo.stoptime AS [Booked for END], wo.closed, probs.brief, clients.mailaddress, clients.streetaddress, clients.city, clients.stateprov, clients.postal, clients.country, clients.bizphone, clients.extension, clients.technotes, clients.first, clients.last, probstat.notes AS STATUS, probstat_1.notes AS ITEMSTATUS, projects.name AS PROJNAME, projects.notes AS PROJNOTES "
|
|
"FROM projects RIGHT JOIN ((((((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) LEFT JOIN probstat ON wo.status = probstat.id) LEFT JOIN probstat AS probstat_1 ON probs.status = probstat_1.id) ON projects.id = wo.project "
|
|
"WHERE (((wo.id)=%s));",
|
|
strRateDescription,strTech, fHours,
|
|
m_pApp->m_strRegCompany,m_strWorkorderID);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
q.Format("SELECT \"%s\" AS estrate, \"%s\" AS scheduledtech, %f AS esthours, IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS clientname, "
|
|
"IIf(IsNull([clients].[streetaddress]),[clients].[mailaddress],[clients].[streetaddress]) & IIf(IsNull([clients].[city]),\"\","
|
|
"Chr(13) & [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.notes AS wonotes, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.prob_reported, wo.prob_found, wo.action_taken, 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], wo.stoptime AS [Booked for END], wo.closed, probs.brief, clients.mailaddress, clients.streetaddress, "
|
|
"clients.city, clients.stateprov, clients.postal, clients.country, clients.bizphone, clients.extension, clients.technotes, clients.first, clients.last, probstat.notes AS STATUS, probstat_1.notes AS ITEMSTATUS "
|
|
|
|
"FROM projects ((((((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) LEFT JOIN probstat ON wo.status = probstat.id) LEFT JOIN probstat AS probstat_1 ON probs.status = probstat_1.id "
|
|
"WHERE (((wo.id)=%s));",strRateDescription,strTech, fHours, m_pApp->m_strRegCompany,m_strWorkorderID);
|
|
*/
|
|
/*
|
|
strData="SELECT \"Cleaning - laser printer: $25.00\" AS estrate, \"Miller, Joe\" AS scheduledtech, 0 AS esthours, IIf(IsNull([clients].[company]),[clients].[last] & \", \" & [clients].[first],[clients].[company]) AS clientname, "
|
|
"IIf(IsNull([clients].[streetaddress]),[clients].[mailaddress],[clients].[streetaddress]) & IIf(IsNull([clients].[city]),\"\",Chr(13) & [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, \"test\" AS compname, wo.notes AS wonotes, wo.clientrefnum, wo.clientcontact, wo.ourref, wo.prob_reported, wo.prob_found, wo.action_taken, 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], wo.stoptime AS [Booked for END], wo.closed, probs.brief, clients.mailaddress, clients.streetaddress, clients.city, clients.stateprov, clients.postal, clients.country, clients.bizphone, clients.extension, clients.technotes, clients.first, clients.last, "
|
|
"probstat.notes AS STATUS, probstat_1.notes AS ITEMSTATUS, projects.name AS PROJNAME, projects.notes AS PROJNOTES"
|
|
|
|
"FROM projects RIGHT JOIN ((((((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) LEFT JOIN probstat ON wo.status = probstat.id) LEFT JOIN probstat AS probstat_1 ON probs.status = probstat_1.id) ON projects.id = wo.project"
|
|
"WHERE (((wo.id)=72));";
|
|
*/
|
|
|
|
//don't allow this to creep into a release build...unh..unh...unh...DON'T!
|
|
#ifdef _DEBUG
|
|
m_pApp->ShowStuff(q);
|
|
#endif
|
|
Flush(true);
|
|
|
|
|
|
rsPrint->QueryReadOnly(q);
|
|
rsPrint->QueryReadOnly(q);
|
|
|
|
//check for parts
|
|
q.Format("SELECT woparts.id "
|
|
"FROM woparts RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) ON woparts.link = probs.id "
|
|
"WHERE (((woparts.id) Is Not Null) AND ((wo.id)=%s));",m_strWorkorderID);
|
|
|
|
#ifdef _DEBUG
|
|
m_pApp->ShowStuff(q);
|
|
#endif
|
|
|
|
rsSubPrint->QueryReadOnly(q);
|
|
if(rsSubPrint->IsEmpty())
|
|
bNoParts=true;
|
|
else
|
|
bNoParts=false;
|
|
|
|
if(!bNoParts)
|
|
{
|
|
q.Format("SELECT probs.id, woparts.quantity, woparts.sn, parts.partnumber, woparts.misc, "
|
|
"parts.description, parts.retail, "
|
|
|
|
/*not misc*/
|
|
"IIf(IsNull(woparts.misc),[parts].[partnumber] "
|
|
"& \" \" & [parts].[description] & \": \" & [woparts].[quantity] & \" @ \" & "
|
|
"Format([woparts].[price],\"Currency\") & \" ea.(sn:\" & IIf(IsNull([woparts].[sn]),\"---\",[woparts].[sn]) & \")\", "
|
|
/*Misc*/
|
|
"[woparts].[misc] & \": \" & [woparts].[quantity] & \" @ \" & "
|
|
"Format([woparts].[price],\"Currency\") & \" ea.(sn:\" & [woparts].[sn] & \")\") "
|
|
|
|
"AS item, [woparts].[quantity]*[woparts].[price] AS linetotal "
|
|
"FROM (woparts RIGHT JOIN (probs RIGHT JOIN wo ON probs.wolink = wo.id) ON woparts.link = probs.id) LEFT JOIN parts ON woparts.partnum = parts.id "
|
|
"WHERE (((woparts.quantity) Is Not Null) AND ((wo.id)=%s));",m_strWorkorderID);
|
|
#ifdef _DEBUG
|
|
m_pApp->ShowStuff(q);
|
|
#endif
|
|
rsSubPrint->QueryReadOnly(q);
|
|
rsSubPrint->QueryReadOnly(q);
|
|
}
|
|
|
|
|
|
if(!rsPrint->IsEmpty())
|
|
{
|
|
//Create sub report ttx file
|
|
#ifdef _DEBUG
|
|
m_pApp->CreateTTX("wodispstpartssub.ttx",rsSubPrint->RecordSetPointer());
|
|
m_pApp->CreateTTX("wodispst.ttx",rsPrint->RecordSetPointer());
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
m_pApp->PrintSubCMReportRDC("Workorder dispatch",rsPrint->RecordSetPointer(),"wodispstpartssub.rpt",rsSubPrint->RecordSetPointer());
|
|
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
AfxMessageBox("There is no no data, can't print!");
|
|
|
|
|
|
}
|
|
Flush(false);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWOHeaderDlg::FillEstRatesList()
|
|
{
|
|
|
|
//fill travel and regular rates list boxes
|
|
CString strData;
|
|
CString strIndex;
|
|
long lData;
|
|
bool bData;
|
|
m_cbEstRate.Clear();
|
|
cbrs->QueryReadOnly("SELECT rates.* FROM rates ORDER BY rates.name;");
|
|
if(!cbrs->IsEmpty())
|
|
{
|
|
//fill combo box with available categories
|
|
cbrs->MoveFirst();
|
|
cbrs->FetchField("travelrate",&bData);
|
|
cbrs->FetchField("name",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
if(bData!=true)//it's a travel rate
|
|
m_cbEstRate.AddRow(strData,strIndex);
|
|
while(cbrs->MoveForward())
|
|
{
|
|
cbrs->FetchField("travelrate",&bData);
|
|
cbrs->FetchField("name",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
|
|
if(bData!=true)//it's a travel rate
|
|
m_cbEstRate.AddRow(strData,strIndex);
|
|
}
|
|
m_cbEstRate.SetCurSel(0);
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnKillfocusEdclientcontact()
|
|
{
|
|
SaveField(&m_edClientContact,"clientcontact",true);
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnKillfocusEdclientrefnum()
|
|
{
|
|
SaveField(&m_edClientRefNum,"clientrefnum",true);
|
|
|
|
}
|
|
|
|
//securenet fields
|
|
void CWOHeaderDlg::OnKillfocusEdactiontaken()
|
|
{
|
|
SaveField(&m_edActionTaken,"action_taken",true);
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnKillfocusEdtroublefound()
|
|
{
|
|
SaveField(&m_edTroubleFound,"prob_found",true);
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnKillfocusEdtroublereported()
|
|
{
|
|
SaveField(&m_edTroubleReported,"prob_reported",true);
|
|
|
|
}
|
|
|
|
//-----------------------
|
|
|
|
void CWOHeaderDlg::Flush(bool bClose)
|
|
{
|
|
if(bClose)
|
|
{
|
|
rs->Close();
|
|
}
|
|
else
|
|
{
|
|
FillFields();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//menu replacement for done button
|
|
void CWOHeaderDlg::OnStanwoDone()
|
|
{
|
|
//check for client selected
|
|
if(m_cbClients.GetCurrentRowID()=="0")
|
|
{
|
|
AfxMessageBox("Please select a client before proceeding.");
|
|
return;
|
|
}
|
|
|
|
COleDateTime dtData;
|
|
|
|
if(bModified)
|
|
{
|
|
VERIFY(rs->UpdateField("modifier",&m_pApp->m_lusrID));
|
|
dtData=COleDateTime::GetCurrentTime();
|
|
VERIFY(rs->UpdateField("modified",&dtData));
|
|
VERIFY(rs->SaveRecord());
|
|
}
|
|
//flush recordset.
|
|
|
|
m_pApp->m_bRefreshStatScreen=bModified;
|
|
|
|
CDialog::OnOK();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWOHeaderDlg::OnStanwoDelete()
|
|
{
|
|
CString q,q1,strSelectedProblemID;
|
|
long lData;
|
|
if(m_bAddMode)
|
|
{
|
|
q="Cancel adding this new workorder?";
|
|
}
|
|
else
|
|
{
|
|
q="Warning: You have chosen to permanently delete this workorder\r\n"
|
|
"and all it's data.\r\n\r\nAre you sure?";
|
|
}
|
|
|
|
if(AfxMessageBox(q,MB_YESNO)==IDNO)
|
|
return;
|
|
|
|
//still here, so lets start a-deletin'
|
|
//Loop through all the problems for this workorder
|
|
//and delete whatever exists for each one
|
|
q1.Format("SELECT probs.id FROM probs "
|
|
"WHERE (((probs.wolink)=%s));",m_strWorkorderID);
|
|
rs->Query(q1);
|
|
|
|
if(!rs->IsEmpty())
|
|
{
|
|
do{
|
|
rs->FetchField("id",&lData);
|
|
strSelectedProblemID.Format("%u",lData);
|
|
ASSERT(!strSelectedProblemID.IsEmpty());
|
|
//LABOUR
|
|
q.Format("DELETE labor.*, labor.link FROM labor "
|
|
"WHERE (((labor.link)=%s));",strSelectedProblemID);
|
|
rs->Ex(q);
|
|
|
|
//SUBREPAIRS
|
|
q.Format("DELETE subrepair.*, subrepair.link FROM subrepair "
|
|
"WHERE (((subrepair.link)=%s));",strSelectedProblemID);
|
|
rs->Ex(q);
|
|
|
|
//PARTS
|
|
q.Format("DELETE woparts.*, woparts.link FROM woparts "
|
|
"WHERE (((woparts.link)=%s));",strSelectedProblemID);
|
|
rs->Ex(q);
|
|
|
|
//PROBLEM ITSELF
|
|
q.Format("DELETE probs.*, probs.link FROM probs "
|
|
"WHERE (((probs.id)=%s));",strSelectedProblemID);
|
|
rs->Ex(q);
|
|
}while(rs->MoveForward());
|
|
}
|
|
|
|
//DELETE WO record
|
|
q.Format("DELETE wo.*, wo.id FROM wo "
|
|
"WHERE (((wo.id)=%s));",m_strWorkorderID);
|
|
rs->Ex(q);
|
|
m_pApp->m_bRefreshStatScreen=true;
|
|
rs->Close();
|
|
CDialog::OnOK();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWOHeaderDlg::OnStanwoPrintDispatch()
|
|
{
|
|
//added because clicking a menu item doesn't kill
|
|
//focus on a control to allow it to update
|
|
m_btnAddProblem.SetFocus();
|
|
|
|
//broke it out here in case there becomes multiple
|
|
//versions of the dispatch workorder later, then
|
|
//can just call and supply report name like
|
|
//the final workorder
|
|
PrintDispatchWorkorder();
|
|
}
|
|
|
|
void CWOHeaderDlg::OnStanwoPrintBrief()
|
|
{
|
|
//added because clicking a menu item doesn't kill
|
|
//focus on a control to allow it to update
|
|
m_btnAddProblem.SetFocus();
|
|
|
|
PrintFinalWorkorder("Brief workorder");
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnStanwoPrintDetailed()
|
|
{
|
|
//added because clicking a menu item doesn't kill
|
|
//focus on a control to allow it to update
|
|
m_btnAddProblem.SetFocus();
|
|
|
|
PrintFinalWorkorder("Detailed workorder");
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CWOHeaderDlg::OnStanwoCostatus()
|
|
{
|
|
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")),strStatusQ,m_strWorkorderID);
|
|
cbrs->Ex(q);
|
|
cbrs->Close();
|
|
bModified=true;
|
|
//-----
|
|
|
|
UpdateClosedOpen();
|
|
}
|
|
|
|
|
|
//Update the menu to show closed or open status of workorder
|
|
void CWOHeaderDlg::UpdateClosedOpen()
|
|
{
|
|
CString strData;
|
|
strData=m_bIsOpen ? "<In progress> ":"<Closed> ";
|
|
CMenu* pMenu=this->GetMenu();
|
|
pMenu->ModifyMenu(ID_STANWO_COSTATUS,MF_BYCOMMAND,ID_STANWO_COSTATUS,strData);
|
|
//v1.9.4.2
|
|
if(m_bReadOnly)
|
|
pMenu->EnableMenuItem(ID_STANWO_COSTATUS, MF_DISABLED | MF_GRAYED);
|
|
|
|
this->DrawMenuBar();
|
|
}
|
|
|
|
void CWOHeaderDlg::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 CWOHeaderDlg::OnKillfocusEdesthours()
|
|
{
|
|
|
|
CString strData;
|
|
float fData;
|
|
|
|
m_edEstHours.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 Estimated 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_edEstHours.Undo();
|
|
m_edEstHours.SetModify(FALSE);
|
|
m_edEstHours.SetFocus();
|
|
return;
|
|
}
|
|
|
|
rs->UpdateField("esthours",&fData);
|
|
rs->SaveRecord();
|
|
UpdateModified();
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnCloseupCbestrate()
|
|
{
|
|
SaveField(&m_cbEstRate,"estrate");
|
|
}
|
|
|
|
|
|
void CWOHeaderDlg::OnCloseupCbstatus()
|
|
{
|
|
|
|
SaveField(&m_cbStatus,"status");
|
|
m_strSelectedStatus=m_cbStatus.GetCurrentRowID();
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnKillfocusEdourrefnumber()
|
|
{
|
|
SaveField(&m_edOurRefNum,"ourref",true);
|
|
}
|
|
|
|
void CWOHeaderDlg::OnLblGroup1()
|
|
{
|
|
ShowGroup(1);
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnLblGroup2()
|
|
{
|
|
ShowGroup(2);
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::ShowGroup(int nGroup)
|
|
{
|
|
BOOL g1,g2;
|
|
m_lblGroup2.SetTextColor(RGB(0,0,0));
|
|
m_lblGroup2.SetFontUnderline(FALSE);
|
|
m_lblGroup2.SetFontBold(TRUE);
|
|
m_lblGroup2.SetSunken(FALSE);
|
|
|
|
m_lblGroup1.SetTextColor(RGB(0,0,0));
|
|
m_lblGroup1.SetFontUnderline(FALSE);
|
|
m_lblGroup1.SetFontBold(TRUE);
|
|
m_lblGroup1.SetSunken(FALSE);
|
|
|
|
switch(nGroup)
|
|
{
|
|
|
|
case 1:
|
|
m_lblGroup2.SetTextColor(RGB(0,0,255));
|
|
m_lblGroup2.SetFontUnderline(TRUE);
|
|
m_lblGroup2.SetFontBold(FALSE);
|
|
m_lblGroup1.SetSunken(TRUE);
|
|
g1=TRUE;
|
|
g2=FALSE;
|
|
break;
|
|
|
|
case 2:
|
|
m_lblGroup1.SetTextColor(RGB(0,0,255));
|
|
m_lblGroup1.SetFontUnderline(TRUE);
|
|
m_lblGroup1.SetFontBold(FALSE);
|
|
m_lblGroup2.SetSunken(TRUE);
|
|
|
|
g1=FALSE;
|
|
g2=TRUE;
|
|
break;
|
|
|
|
}
|
|
m_cbCategories.ShowWindow(g1);
|
|
m_lblCategories.ShowWindow(g1);
|
|
m_cbStatus.ShowWindow(g1);
|
|
m_lblStatus.ShowWindow(g1);
|
|
m_edClientContact.ShowWindow(g1);
|
|
m_edClientRefNum.ShowWindow(g1);
|
|
m_lblRefNumber.ShowWindow(g1);
|
|
m_lblContact.ShowWindow(g1);
|
|
m_edNotes.ShowWindow(g1);
|
|
m_lblQuickDescription.ShowWindow(g1);
|
|
|
|
|
|
m_edOurRefNum.ShowWindow(g2);
|
|
m_lblOurRef.ShowWindow(g2);
|
|
m_cbProjects.ShowWindow(g2);
|
|
m_lblProjects.ShowWindow(g2);
|
|
m_edInvoice.ShowWindow(g2);
|
|
m_lblInvoice.ShowWindow(g2);
|
|
m_cbEstRate.ShowWindow(g2);
|
|
m_edEstHours.ShowWindow(g2);
|
|
m_lblEstHours.ShowWindow(g2);
|
|
m_lblEstRate.ShowWindow(g2);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnStanwoClientnotes()
|
|
{
|
|
CContactsViewDlg d;
|
|
d.Setup(m_cbClients.GetCurrentRowID());
|
|
d.DoModal();
|
|
}
|
|
|
|
void CWOHeaderDlg::OnLblstatus()
|
|
{
|
|
CProbStatDlg d;
|
|
d.DoModal();
|
|
FillPickLists();
|
|
OnTec1();
|
|
}
|
|
|
|
|
|
|
|
void CWOHeaderDlg::OnLblhistory()
|
|
{
|
|
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();
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnLbltechnotes()
|
|
{
|
|
m_pApp->ShowStuff(m_strTechNotes);
|
|
|
|
}
|
|
|
|
|
|
//accomodate various screen sizes and special circumstance
|
|
//Note to self:
|
|
//Never, ever, promise anyone a single line of custom code
|
|
//or you'll regret it forever.
|
|
//DAMN! (this is due to securenet customizations May 2001)
|
|
|
|
//new method for resizing controls see:
|
|
//http://wwwusers.brookes.ac.uk/p0071643/resize.htm
|
|
void CWOHeaderDlg::LayoutControls()
|
|
{
|
|
|
|
|
|
CRect rectMain, rectCtl, rectCtl2;
|
|
|
|
float fHeight,fOldHeight;
|
|
CPoint topleft,topleft2;
|
|
if(m_pApp->m_bShowProblemActionFields)
|
|
{
|
|
m_lbProblems.GetWindowRect(rectCtl);
|
|
topleft=rectCtl.TopLeft();
|
|
ScreenToClient(&topleft);
|
|
fHeight=(float)rectCtl.Height();
|
|
fOldHeight=fHeight;
|
|
fHeight=fHeight/(float)3;
|
|
topleft.y+=(long)(fOldHeight-fHeight);
|
|
m_lbProblems.MoveWindow(topleft.x,topleft.y,rectCtl.Width(),(long)fHeight,TRUE);
|
|
m_lbProblems.RedrawWindow();
|
|
|
|
|
|
//Move title
|
|
m_lblProbsList.GetWindowRect(rectCtl);
|
|
fHeight=(float)rectCtl.Height();
|
|
m_lblProbsList.MoveWindow(topleft.x,topleft.y-(long)fHeight,rectCtl.Width(),(long)fHeight,TRUE);
|
|
|
|
//Move buttons
|
|
m_btnDeleteProblem.GetWindowRect(rectCtl);
|
|
topleft=rectCtl.TopLeft();
|
|
ScreenToClient(&topleft);
|
|
fHeight=(float)rectCtl.Height();
|
|
|
|
//now have topleft and height
|
|
m_btnEditProblem.GetWindowRect(rectCtl);
|
|
topleft2=rectCtl.TopLeft();
|
|
ScreenToClient(&topleft2);
|
|
topleft2.y=topleft.y-(long)fHeight;
|
|
m_btnEditProblem.MoveWindow(topleft2.x,topleft2.y,rectCtl.Width(),rectCtl.Height(),TRUE);
|
|
|
|
//now have topleft and height
|
|
m_btnAddProblem.GetWindowRect(rectCtl);
|
|
topleft2=rectCtl.TopLeft();
|
|
ScreenToClient(&topleft2);
|
|
topleft2.y=topleft.y-(long)(fHeight*2);
|
|
m_btnAddProblem.MoveWindow(topleft2.x,topleft2.y,rectCtl.Width(),rectCtl.Height(),TRUE);
|
|
|
|
//Display extra controls
|
|
m_lblTroulbleReported.ShowWindow(TRUE);
|
|
m_lblTroubleFound.ShowWindow(TRUE);
|
|
m_lblActionTaken.ShowWindow(TRUE);
|
|
m_edTroubleReported.ShowWindow(TRUE);
|
|
m_edTroubleFound.ShowWindow(TRUE);
|
|
m_edActionTaken.ShowWindow(TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWOHeaderDlg::OnTec1()
|
|
{
|
|
m_nSelectedTechNumber=1;
|
|
ShowSchedTech();
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnTec2()
|
|
{
|
|
m_nSelectedTechNumber=2;
|
|
ShowSchedTech();
|
|
|
|
}
|
|
|
|
void CWOHeaderDlg::OnTec3()
|
|
{
|
|
m_nSelectedTechNumber=3;
|
|
ShowSchedTech();
|
|
}
|
|
|
|
void CWOHeaderDlg::OnTec4()
|
|
{
|
|
m_nSelectedTechNumber=4;
|
|
ShowSchedTech();
|
|
|
|
}
|
|
|
|
//display selected tech
|
|
void CWOHeaderDlg::ShowSchedTech()
|
|
{
|
|
COleDateTime dtStart,dtStop;
|
|
COleDateTimeSpan dtSpan;
|
|
dtSpan.SetDateTimeSpan(0,1,0,0);//one hour to be added to now for empty stop time
|
|
CString strData;
|
|
long lTechID;
|
|
bool bPreviouslyEmptyDates=false;
|
|
|
|
switch (m_nSelectedTechNumber)
|
|
{
|
|
case 1:
|
|
dtStart=m_dtSchedStart1;
|
|
dtStop=m_dtSchedStop1;
|
|
lTechID=m_lSchedTech1;
|
|
break;
|
|
|
|
case 2:
|
|
dtStart=m_dtSchedStart2;
|
|
dtStop=m_dtSchedStop2;
|
|
lTechID=m_lSchedTech2;
|
|
break;
|
|
|
|
case 3:
|
|
dtStart=m_dtSchedStart3;
|
|
dtStop=m_dtSchedStop3;
|
|
lTechID=m_lSchedTech3;
|
|
break;
|
|
|
|
case 4:
|
|
dtStart=m_dtSchedStart4;
|
|
dtStop=m_dtSchedStop4;
|
|
lTechID=m_lSchedTech4;
|
|
break;
|
|
|
|
}
|
|
|
|
if(dtStart.GetYear()==1899)
|
|
{
|
|
if(m_nSelectedTechNumber!=1)
|
|
{ //set to first techs settings if not set yet
|
|
dtStart=m_dtSchedStart1;
|
|
}
|
|
else
|
|
{
|
|
dtStart=COleDateTime::GetCurrentTime();
|
|
}
|
|
|
|
bPreviouslyEmptyDates=true;
|
|
}
|
|
|
|
if(dtStop.GetYear()==1899)
|
|
{
|
|
if(m_nSelectedTechNumber!=1)
|
|
{
|
|
//set to first techs settings if not set yet
|
|
dtStop=m_dtSchedStop1;
|
|
|
|
}
|
|
else
|
|
{
|
|
dtStop=COleDateTime::GetCurrentTime();
|
|
dtStop+=dtSpan;
|
|
}
|
|
|
|
bPreviouslyEmptyDates=true;
|
|
}
|
|
|
|
//set start date/time
|
|
m_dtSchedDate.SetTime(dtStart);
|
|
strData=dtStart.Format(VAR_TIMEVALUEONLY);
|
|
m_edStartTime.SetWindowText(strData);
|
|
|
|
|
|
//set end date/time
|
|
m_dtEndDate.SetTime(dtStop);
|
|
strData=dtStop.Format(VAR_TIMEVALUEONLY);
|
|
m_edEndTime.SetWindowText(strData);
|
|
|
|
|
|
//select assigned tech
|
|
m_cbSchedTechList.Select(lTechID);
|
|
|
|
//need to save here in case user doesn't make a date or time
|
|
//selection, otherwise we end up with a blank date
|
|
//which plays hell in the schedule screen
|
|
if(bPreviouslyEmptyDates && lTechID!=-1)
|
|
{
|
|
SaveStartDate();
|
|
SaveEndDate();
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//enter key avoidance hack
|
|
//added 08/07/2001!!! Nobody tells me anything, it's been doing this forever.
|
|
void CWOHeaderDlg::OnOK()
|
|
{}
|
|
|
|
|
|
|
|
|
|
void CWOHeaderDlg::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)=\"wostandard\")) ORDER BY rptsmaster.wodisplayorder;";
|
|
if(!cbrs->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_STWO_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);
|
|
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
|
|
cbrs->FetchField("virtualname",&strData);
|
|
m_pSubMenu->AppendMenu(0,uiResourceID,strData);
|
|
|
|
|
|
}while(cbrs->MoveForward());
|
|
}
|
|
|
|
|
|
|
|
|
|
void CWOHeaderDlg::OnPrintReport( UINT nID )
|
|
{
|
|
|
|
//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;
|
|
}
|
|
|
|
|
|
|
|
|
|
CString strVirtualReportName,strTTXPath;
|
|
CString strSubVirtualReportName,strSubTTXPath;
|
|
CString strError,strShowQuery,strTemp;
|
|
CString q,strQuery,strSubQuery;
|
|
CString strWOID,strRegTo,strSchedTech;
|
|
bool bHasSubreport=false;
|
|
CString strData,strRateID,strTech,strRateDescription,strEstHours;
|
|
float fHours=0;
|
|
CgzCurrencyFormatter cfm;
|
|
COleCurrency crData;
|
|
strRateID=m_cbEstRate.GetCurrentRowID();
|
|
if(strRateID.IsEmpty()) strRateID="0";
|
|
|
|
//Get tech name
|
|
m_cbSchedTechList.GetWindowText(strTech);
|
|
|
|
|
|
if(m_bShowEstimates)
|
|
{
|
|
|
|
m_cbEstRate.GetWindowText(strRateDescription);
|
|
q.Format("SELECT rates.rate FROM rates "
|
|
"WHERE (((rates.id)=%s));",strRateID);
|
|
rsPrint->QueryReadOnly(q);
|
|
if(rsPrint->IsEmpty())
|
|
{
|
|
AfxMessageBox("Can't find estimated rate you selected");
|
|
crData.SetCurrency(0,0);
|
|
fHours=0;
|
|
|
|
}
|
|
else
|
|
{
|
|
rsPrint->FetchField("rate",&crData);
|
|
m_edEstHours.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);
|
|
//fHours=(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
|
|
{
|
|
fHours=(float)vtData;//cast variant to float (locale friendly)
|
|
}
|
|
catch( _com_error &e )
|
|
{
|
|
//Since this is caught at time of entry, doing it again here seems redundant
|
|
//but just in case threw in this try/catch block and default to zero
|
|
fHours=0;
|
|
}
|
|
|
|
strEstHours.Format("%f",fHours);
|
|
|
|
}
|
|
|
|
|
|
strRateDescription=strRateDescription + ": " + cfm.Format(crData);
|
|
}
|
|
else
|
|
{
|
|
crData.SetCurrency(0,0);
|
|
fHours=0;
|
|
strRateDescription="n/a";
|
|
strEstHours="0";
|
|
|
|
}
|
|
|
|
|
|
|
|
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"
|
|
"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"
|
|
"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"
|
|
"due to the error previously reported\r\n"
|
|
"by the database driver.",strVirtualReportName);
|
|
AfxMessageBox(strError);
|
|
return;
|
|
|
|
}
|
|
|
|
if(!cbrs->FetchField("subfilename",&strSubVirtualReportName))
|
|
{
|
|
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;
|
|
|
|
}
|
|
|
|
//See if there is a sub report
|
|
if(!strSubVirtualReportName.IsEmpty()) bHasSubreport=true;
|
|
|
|
|
|
if(bHasSubreport)
|
|
{
|
|
strSubTTXPath=strSubVirtualReportName;
|
|
strSubTTXPath.Replace(".rpt",".ttx");
|
|
|
|
if(!cbrs->FetchField("subreportquery",&strSubQuery))
|
|
{
|
|
strError.Format(
|
|
"Unable to print:\r\n"
|
|
"%s\r\n"
|
|
"The sub report query failed due to the error\r\n"
|
|
"previously reported by the database driver.",strVirtualReportName);
|
|
AfxMessageBox(strError);
|
|
return;
|
|
|
|
}
|
|
|
|
if(strSubQuery.IsEmpty())
|
|
{
|
|
|
|
strError.Format(
|
|
"Unable to print:\r\n"
|
|
"%s has a sub report file name \"%s\" but no subreport query\r\n"
|
|
"in the rptsmaster table of the database (it's blank)\r\n"
|
|
"Check your customized report settings.",strVirtualReportName,strSubVirtualReportName);
|
|
AfxMessageBox(strError);
|
|
return;
|
|
|
|
}
|
|
}//endif has subreport
|
|
|
|
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(strRateDescription.IsEmpty()) strRateDescription="n/a";
|
|
strQuery.Replace("~ESTRATE",strRateDescription);
|
|
|
|
if(strEstHours.IsEmpty()) strEstHours="0";
|
|
strQuery.Replace("~ESTHOURS",strEstHours);
|
|
strQuery.Replace("~SCHEDTECH",strTech);
|
|
|
|
if(m_bShowQueriesOnPrint)
|
|
{
|
|
strTemp.Format("Query after tokens replaced for:%s\r\n"
|
|
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n"
|
|
"%s\r\n"
|
|
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n\r\n\r\n",strVirtualReportName,strQuery);
|
|
strShowQuery+=strTemp;
|
|
|
|
|
|
|
|
}
|
|
|
|
if(!strSubQuery.IsEmpty())
|
|
{
|
|
if(m_bShowQueriesOnPrint)
|
|
{
|
|
strTemp.Format("Raw Sub-Query for:%s\r\n"
|
|
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n"
|
|
"%s\r\n"
|
|
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n\r\n\r\n",strSubVirtualReportName,strSubQuery);
|
|
strShowQuery+=strTemp;
|
|
|
|
|
|
|
|
}
|
|
strSubQuery.Replace("~REGTO",m_pApp->m_strRegCompany);
|
|
strSubQuery.Replace("Evaluation",m_pApp->m_strRegCompany);
|
|
strSubQuery.Replace("~WOID",m_strWorkorderID);
|
|
if(strRateDescription.IsEmpty()) strRateDescription="n/a";
|
|
strSubQuery.Replace("~ESTRATE",strRateDescription);
|
|
if(strEstHours.IsEmpty()) strEstHours="0";
|
|
strSubQuery.Replace("~ESTHOURS",strEstHours);
|
|
strSubQuery.Replace("~SCHEDTECH",strTech);
|
|
|
|
if(m_bShowQueriesOnPrint)
|
|
{
|
|
strTemp.Format("Sub-Query after tokens replaced for:%s\r\n"
|
|
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n"
|
|
"%s\r\n"
|
|
"-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n",strSubVirtualReportName,strSubQuery);
|
|
strShowQuery+=strTemp;
|
|
m_pApp->ShowStuff(strShowQuery);
|
|
|
|
|
|
}
|
|
|
|
//run sub query
|
|
|
|
if(!rsSubPrint->QueryReadOnly(strSubQuery))
|
|
{
|
|
strError.Format(
|
|
"Unable to print:\r\n"
|
|
"%s\r\n"
|
|
"Due to sub query error previously\r\n"
|
|
"reported 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(!rsSubPrint->QueryReadOnly(strSubQuery))
|
|
{
|
|
strError.Format(
|
|
"Unable to print:\r\n"
|
|
"%s\r\n"
|
|
"Due to sub query error previously\r\n"
|
|
"reported by the database driver.",strVirtualReportName);
|
|
AfxMessageBox(strError);
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
//if no sub report show query if selected to do so
|
|
//if it has a sub report the query is shown already at this point
|
|
if(!bHasSubreport)
|
|
if(m_bShowQueriesOnPrint)
|
|
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(bHasSubreport)
|
|
{
|
|
if(!rsPrint->IsEmpty())
|
|
{
|
|
m_pApp->PrintSubCMReportRDC(strVirtualReportName,rsPrint->RecordSetPointer(),strSubVirtualReportName,rsSubPrint->RecordSetPointer());
|
|
if(m_pApp->m_lusrID==1)//manager account?
|
|
{
|
|
m_pApp->CreateTTX(strTTXPath,rsPrint->RecordSetPointer(),true);
|
|
m_pApp->CreateTTX(strSubTTXPath,rsSubPrint->RecordSetPointer(),true);
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox("There is no data to print. \r\n");
|
|
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
if(!rsPrint->IsEmpty())
|
|
{
|
|
m_pApp->PrintCMReportRDC(strVirtualReportName,rsPrint->RecordSetPointer());
|
|
if(m_pApp->m_lusrID==1)//manager account?
|
|
m_pApp->CreateTTX(strTTXPath,rsPrint->RecordSetPointer(),true);
|
|
|
|
}
|
|
else
|
|
{
|
|
AfxMessageBox(
|
|
"There is no data to print. \r\n"
|
|
"Make sure you have at least one labor item or part on this workorder.\r\n\r\n"
|
|
"This can also be caused by not having at least one travel rate.\r\n"
|
|
"Even if you don't use travel rates create one \"dummy\" travel rate.");
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//reopen the recordsets
|
|
Flush(false);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|