1069 lines
25 KiB
C++
1069 lines
25 KiB
C++
// WoTabLabourEntryDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "sp.h"
|
|
#include "WoTabLabourEntryDlg.h"
|
|
#include "Ratesdlg.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>
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CWoTabLabourEntryDlg dialog
|
|
|
|
|
|
CWoTabLabourEntryDlg::CWoTabLabourEntryDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CWoTabLabourEntryDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CWoTabLabourEntryDlg)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
|
|
m_pApp = (CSpApp*)AfxGetApp();
|
|
|
|
/*
|
|
rs=new GZRset("CWoTabLabourEntry error:");
|
|
rs->SetConnect(m_pApp->strConnectString);
|
|
|
|
cbrs=new GZRset("CWoTabLabourEntry CBRS error:");
|
|
cbrs->SetConnect(m_pApp->strConnectString);
|
|
*/
|
|
//Initialize recordset pointer
|
|
|
|
rs=m_pApp->rsPool->GetRS(" CWoTabLabourEntryDlg (RS)");
|
|
cbrs=m_pApp->rsPool->GetRS("CWoTabLabourEntryDlg (CBRS)");
|
|
|
|
//not editing as far as known
|
|
m_bEditing=false;
|
|
m_strSelectedRate.Empty();
|
|
m_strSelectedTravelRate.Empty();
|
|
m_strSelectedTech.Empty();
|
|
m_strProblemID.Empty();
|
|
m_strLabourID.Empty();
|
|
bModified=false;
|
|
}
|
|
|
|
///***************************************
|
|
CWoTabLabourEntryDlg::~CWoTabLabourEntryDlg()
|
|
{
|
|
|
|
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
|
m_pApp->rsPool->ReleaseRS(&cbrs->m_nID);
|
|
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CWoTabLabourEntryDlg)
|
|
DDX_Control(pDX, IDC_DTDATEEND, m_dtEndDate);
|
|
DDX_Control(pDX, IDC_LBLTRAVELRATE, m_lblTravelRate);
|
|
DDX_Control(pDX, IDC_LBLTECH, m_lblTech);
|
|
DDX_Control(pDX, IDC_LBLRATE, m_lblRate);
|
|
DDX_Control(pDX, IDC_EDTRAVEL, m_edTravel);
|
|
DDX_Control(pDX, IDC_EDSTART, m_edStart);
|
|
DDX_Control(pDX, IDC_EDNOTES, m_edNotes);
|
|
DDX_Control(pDX, IDC_EDNC, m_edNC);
|
|
DDX_Control(pDX, IDC_EDEND, m_edEnd);
|
|
DDX_Control(pDX, IDC_EDBILL, m_edBill);
|
|
DDX_Control(pDX, IDC_DTDATE, m_dtDate);
|
|
DDX_Control(pDX, IDC_CBTRAVELRATESLIST, m_cbTravelRatesList);
|
|
DDX_Control(pDX, IDC_CBTECHLIST, m_cbTechList);
|
|
DDX_Control(pDX, IDC_CBRATESLIST, m_cbRatesList);
|
|
DDX_Control(pDX, IDC_BTNDONE, m_btnDone);
|
|
DDX_Control(pDX, IDC_BTNCANCEL, m_btnCancel);
|
|
//}}AFX_DATA_MAP
|
|
DDX_Control(pDX, IDC_ED_DISTANCE, m_edDistance);
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CWoTabLabourEntryDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CWoTabLabourEntryDlg)
|
|
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
|
ON_BN_CLICKED(IDC_BTNCANCEL, OnBtncancel)
|
|
ON_EN_KILLFOCUS(IDC_EDEND, OnKillfocusEdend)
|
|
ON_EN_KILLFOCUS(IDC_EDSTART, OnKillfocusEdstart)
|
|
ON_EN_KILLFOCUS(IDC_EDNOTES, OnKillfocusEdnotes)
|
|
ON_EN_KILLFOCUS(IDC_EDNC, OnKillfocusEdnc)
|
|
ON_EN_KILLFOCUS(IDC_EDBILL, OnKillfocusEdbill)
|
|
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTDATE, OnDatetimechangeDtdate)
|
|
ON_CBN_CLOSEUP(IDC_CBRATESLIST, OnCloseupCbrateslist)
|
|
ON_CBN_CLOSEUP(IDC_CBTECHLIST, OnCloseupCbtechlist)
|
|
ON_CBN_CLOSEUP(IDC_CBTRAVELRATESLIST, OnCloseupCbtravelrateslist)
|
|
ON_EN_KILLFOCUS(IDC_EDTRAVEL, OnKillfocusEdtravel)
|
|
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTDATEEND, OnDatetimechangeDtdateend)
|
|
ON_BN_CLICKED(IDC_LBLRATE, OnLblrate)
|
|
ON_BN_CLICKED(IDC_LBLTRAVELRATE, OnLbltravelrate)
|
|
//}}AFX_MSG_MAP
|
|
ON_EN_KILLFOCUS(IDC_ED_DISTANCE, OnEnKillfocusEdDistance)
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CWoTabLabourEntryDlg message handlers
|
|
|
|
void CWoTabLabourEntryDlg::OnOK()
|
|
{
|
|
//Enter key avoidance hack
|
|
}
|
|
|
|
BOOL CWoTabLabourEntryDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
Security();
|
|
/*
|
|
//Techs hyperlink
|
|
m_lblTech.SetTextColor(RGB(0,0,255));
|
|
m_lblTech.SetFontUnderline(TRUE);
|
|
m_lblTech.SetLink(TRUE);
|
|
|
|
m_lblTech.SetLinkURL("");
|
|
*/
|
|
//Rates dialog hyperlink
|
|
m_lblRate.SetTextColor(RGB(0,0,255));
|
|
m_lblRate.SetFontUnderline(TRUE);
|
|
m_lblRate.SetLink(TRUE);
|
|
m_lblRate.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblRate.SetLinkURL("");
|
|
|
|
//Travel Rates dialog hyperlink
|
|
m_lblTravelRate.SetTextColor(RGB(0,0,255));
|
|
m_lblTravelRate.SetFontUnderline(TRUE);
|
|
m_lblTravelRate.SetLink(TRUE);
|
|
m_lblTravelRate.SetLinkCursor(m_pApp->hcHand);
|
|
m_lblTravelRate.SetLinkURL("");
|
|
|
|
|
|
//fill combo boxes
|
|
FillRatesList();
|
|
FillTechList();
|
|
|
|
|
|
//Should always have been passed a problem ID number
|
|
ASSERT(!m_strProblemID.IsEmpty());
|
|
|
|
|
|
|
|
//CREATE A NEW LABOUR ITEM IF WERE NOT EDITING AN OLD ONE
|
|
if(m_bEditing)
|
|
{
|
|
|
|
FillFields();
|
|
FillRatesList();
|
|
|
|
}
|
|
else
|
|
{
|
|
//go add mode
|
|
//set defaults
|
|
m_dtDate.SetTime(COleDateTime::GetCurrentTime());
|
|
|
|
m_edNC.SetWindowText("0");
|
|
m_edTravel.SetWindowText("0");
|
|
m_edDistance.SetWindowText("0");
|
|
m_edBill.SetWindowText("0");
|
|
m_edStart.SetWindowText("12:00");
|
|
m_edEnd.SetWindowText("12:00");
|
|
|
|
|
|
CString str;
|
|
//try to set tech to current user
|
|
str.Format("%u",m_pApp->m_lusrID);
|
|
m_cbTechList.Select(str);
|
|
|
|
//SET USER DEFAULTS
|
|
m_cbRatesList.Select(m_pApp->m_lUsersDefRate);
|
|
m_cbTravelRatesList.Select(m_pApp->m_lUsersDefTravelRate);
|
|
SetClientRates();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::FillRatesList()
|
|
{
|
|
|
|
//fill travel and regular rates list boxes
|
|
bool bAtLeastOneTravelRate = false;
|
|
CString strData;
|
|
CString strIndex;
|
|
long lData;
|
|
bool bData,bActive;
|
|
m_cbTravelRatesList.Clear();
|
|
m_cbRatesList.Clear();
|
|
rs->QueryReadOnly("SELECT rates.* FROM rates ORDER BY rates.name;");
|
|
if(!rs->IsEmpty())
|
|
{
|
|
//fill combo box with available categories
|
|
|
|
|
|
do
|
|
{
|
|
rs->FetchField("travelrate",&bData);
|
|
rs->FetchField("name",&strData);
|
|
rs->FetchField("id",&lData);
|
|
rs->FetchField("active",&bActive);
|
|
strIndex.Format("%u",lData);
|
|
|
|
if(bData==true)//it's a travel rate
|
|
{
|
|
if(bActive)
|
|
{
|
|
m_cbTravelRatesList.AddRow(strData,strIndex);
|
|
bAtLeastOneTravelRate=true;
|
|
}
|
|
else
|
|
{
|
|
if(m_strSelectedTravelRate==strIndex)//inactive but selected
|
|
{
|
|
strData="<NA> " + strData;
|
|
m_cbTravelRatesList.AddRow(strData,strIndex);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
else//it's a standard rate
|
|
{
|
|
if(bActive)
|
|
m_cbRatesList.AddRow(strData,strIndex);
|
|
else
|
|
{
|
|
if(m_strSelectedRate==strIndex)//inactive but selected
|
|
{
|
|
strData="<NA> " + strData;
|
|
m_cbRatesList.AddRow(strData,strIndex);
|
|
|
|
}
|
|
}
|
|
}
|
|
}while(rs->MoveForward());
|
|
|
|
|
|
|
|
/*
|
|
if(bData==true)//it's a travel rate
|
|
{
|
|
bAtLeastOneTravelRate=true;
|
|
m_cbTravelRatesList.AddRow(strData,strIndex);
|
|
}
|
|
else
|
|
m_cbRatesList.AddRow(strData,strIndex);
|
|
while(rs->MoveForward())
|
|
{
|
|
rs->FetchField("travelrate",&bData);
|
|
rs->FetchField("name",&strData);
|
|
rs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
|
|
if(bData==true)//it's a travel rate
|
|
{
|
|
bAtLeastOneTravelRate=true;
|
|
m_cbTravelRatesList.AddRow(strData,strIndex);
|
|
}
|
|
else
|
|
m_cbRatesList.AddRow(strData,strIndex);
|
|
}
|
|
*/
|
|
|
|
|
|
|
|
//select default rate
|
|
if(m_strSelectedRate.IsEmpty())
|
|
{
|
|
m_cbRatesList.SetCurSel(0);
|
|
m_strSelectedRate=m_cbRatesList.GetCurrentRowID();
|
|
}
|
|
else
|
|
m_cbRatesList.Select(m_strSelectedRate);
|
|
|
|
//select default travel rate
|
|
if(m_strSelectedTravelRate.IsEmpty())
|
|
{
|
|
m_cbTravelRatesList.SetCurSel(0);
|
|
m_strSelectedTravelRate=m_cbTravelRatesList.GetCurrentRowID();
|
|
}
|
|
else
|
|
m_cbTravelRatesList.Select(m_strSelectedTravelRate);
|
|
|
|
}
|
|
if(!bAtLeastOneTravelRate)
|
|
AfxMessageBox("Warning: You need at least one travel rate in the system \r\n"
|
|
"before you enter *any* labor on a standard (this) type of workorder\r\n"
|
|
"Even if you don't use travel rates enter a \"dummy\" one now.\r\n"
|
|
"Travel rates only print on workorders if you enter more than\r\n"
|
|
"zero hours of travel time, but at least one is required to be present\r\n"
|
|
"internally by AyaNova in order to print workorders.");
|
|
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::FillTechList()
|
|
{
|
|
|
|
|
|
|
|
//10/03/00 - fix for the licensing problem
|
|
//if the m_strSelected tech isn't in the list then
|
|
//add it "manually" after filling the list as normal
|
|
//like this: "* Bob Jones (inactive)"
|
|
|
|
|
|
CString strData;
|
|
CString strIndex;
|
|
CString q;
|
|
long lData;
|
|
m_cbTechList.Clear();
|
|
//look for selected tech and see if in inactive list:
|
|
if(!m_strSelectedTech.IsEmpty())
|
|
{
|
|
q.Format("SELECT users.id, [last] & \", \" & [first] AS fullname "
|
|
"FROM users "
|
|
"WHERE (((users.id)=%s) AND ((users.active)=False));",m_strSelectedTech);
|
|
cbrs->QueryReadOnly(q);
|
|
if(!cbrs->IsEmpty()) //it's an inactive tech put them in the list "manually"
|
|
{
|
|
cbrs->FetchField("fullname",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
q="<NA> " + strData;
|
|
m_cbTechList.AddRow(q,strIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//change to active only 10/03/00
|
|
q="SELECT users.id, [last] & \", \" & [first] AS fullname FROM users "
|
|
"WHERE (((users.id)<>1) AND ((users.tech)=True) AND ((users.active)=True)) "
|
|
"ORDER BY users.last;";
|
|
//////////////////m_pApp->ShowStuff(q);
|
|
|
|
cbrs->QueryReadOnly(q);
|
|
if(!cbrs->IsEmpty())
|
|
{
|
|
cbrs->MoveFirst();
|
|
cbrs->FetchField("fullname",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
m_cbTechList.AddRow(strData,strIndex);
|
|
while(cbrs->MoveForward())
|
|
{
|
|
cbrs->FetchField("fullname",&strData);
|
|
cbrs->FetchField("id",&lData);
|
|
strIndex.Format("%u",lData);
|
|
m_cbTechList.AddRow(strData,strIndex);
|
|
}
|
|
|
|
}
|
|
|
|
if(!m_strSelectedTech.IsEmpty())
|
|
m_cbTechList.Select(m_strSelectedTech);
|
|
else
|
|
{//attempt to select by current user id
|
|
m_strSelectedTech.Format("%u",m_pApp->m_lusrID);
|
|
m_cbTechList.Select(m_strSelectedTech);
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CWoTabLabourEntryDlg::SetUp(CString* clientID, CString *strProblemID, CString *LabourID,bool* IsModified)
|
|
{
|
|
m_strProblemID=*strProblemID;
|
|
m_strLabourID=*LabourID;
|
|
m_strClientID=*clientID;
|
|
bModified=IsModified;
|
|
//if a labour item id was passed then were editing
|
|
m_bEditing=true;
|
|
|
|
if(m_strLabourID.IsEmpty() || m_strLabourID=="0")
|
|
m_bEditing=false;
|
|
}
|
|
|
|
|
|
|
|
|
|
//blah
|
|
void CWoTabLabourEntryDlg::FillFields()
|
|
{
|
|
if(!m_bEditing) return;
|
|
//m_strWorkorderID
|
|
CString q,strData,strProblemID;
|
|
|
|
float fData;
|
|
COleDateTime dtData;
|
|
long lData;
|
|
|
|
|
|
|
|
//FETCH LABOUR RECORD
|
|
q.Format("SELECT labor.* FROM labor "
|
|
"WHERE (((labor.id)=%s));",m_strLabourID);
|
|
|
|
rs->Query(q);
|
|
if(rs->IsEmpty())
|
|
return;
|
|
|
|
|
|
|
|
|
|
//TECHNICIAN
|
|
rs->FetchField("tech",&lData);
|
|
m_strSelectedTech.Format("%u",lData);
|
|
FillTechList();
|
|
|
|
|
|
//HOURS
|
|
rs->FetchField("hours",&fData);
|
|
//01/31/2003 localization fix for floats
|
|
//convert float to localized string
|
|
m_edBill.SetWindowText(FtoA(fData));
|
|
|
|
|
|
//NOCHARGE HOURS
|
|
rs->FetchField("nchours",&fData);
|
|
//01/31/2003 localization fix for floats
|
|
//convert float to localized string
|
|
m_edNC.SetWindowText(FtoA(fData));
|
|
|
|
//TRAVEL HOURS
|
|
rs->FetchField("travhours",&fData);
|
|
//01/31/2003 localization fix for floats
|
|
//convert float to localized string
|
|
m_edTravel.SetWindowText(FtoA(fData));
|
|
|
|
//DISTANCE
|
|
rs->FetchField("distance",&fData);
|
|
//01/31/2003 localization fix for floats
|
|
//convert float to localized string
|
|
m_edDistance.SetWindowText(FtoA(fData));
|
|
|
|
//RATE
|
|
rs->FetchField("rate",&lData);
|
|
strData.Format("%u",lData);
|
|
m_strSelectedRate=strData;
|
|
m_cbRatesList.Select(strData);
|
|
|
|
//TRAVEL RATES
|
|
rs->FetchField("travrate",&lData);
|
|
strData.Format("%u",lData);
|
|
m_strSelectedTravelRate=strData;
|
|
m_cbTravelRatesList.Select(strData);
|
|
|
|
//STARTTIME
|
|
rs->FetchField("start",&dtData);
|
|
strData=dtData.Format(VAR_TIMEVALUEONLY);
|
|
m_edStart.SetWindowText(strData);
|
|
//set date to start date
|
|
m_dtDate.SetTime(dtData);
|
|
|
|
//STOPTIME
|
|
rs->FetchField("stop",&dtData);
|
|
strData=dtData.Format(VAR_TIMEVALUEONLY);
|
|
m_edEnd.SetWindowText(strData);
|
|
//set end date
|
|
m_dtEndDate.SetTime(dtData);
|
|
|
|
|
|
//NOTES / DETAILS
|
|
rs->FetchField("details",&strData);
|
|
m_edNotes.SetWindowText(strData);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWoTabLabourEntryDlg::OnBtndone()
|
|
{
|
|
long lData;
|
|
CString strData,q;
|
|
COleDateTime dtData,dtTime,dtDate,dtEndDate;
|
|
float fData;//single
|
|
bool bData;//added 08/21/2001 to set indexed property here
|
|
//if not editing, add new record
|
|
rs->Close();
|
|
if(!m_bEditing)
|
|
{
|
|
q="SELECT labor.* FROM labor WHERE (((labor.link)=0));";
|
|
rs->Query(q);
|
|
if(!rs->AddNewRecord())
|
|
{
|
|
AfxMessageBox("Unable to create new labour record");
|
|
return;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
//FETCH LABOUR RECORD
|
|
q.Format("SELECT labor.* FROM labor "
|
|
"WHERE (((labor.id)=%s));",m_strLabourID);
|
|
|
|
rs->Query(q);
|
|
if(rs->IsEmpty())
|
|
{
|
|
AfxMessageBox("Can't find this labor record to update it!");
|
|
return;
|
|
}
|
|
|
|
}
|
|
|
|
rs->pTheConnection->BeginTrans();
|
|
//Save fields
|
|
//PROBLEM LINK
|
|
rs->UpdateField("link",&m_strProblemID);
|
|
|
|
//TECH
|
|
strData=m_cbTechList.GetCurrentRowID();
|
|
lData=atol(strData);
|
|
rs->UpdateField("tech",&lData);
|
|
|
|
|
|
//HOURS
|
|
m_edBill.GetWindowText(strData);
|
|
//02/19/2003 Fix crash on empty field
|
|
if(strData.IsEmpty()) strData="0";
|
|
//01/31/2003 convert to a variant bstr
|
|
_variant_t vtData(strData);
|
|
|
|
fData=(float)vtData;//cast variant to float (locale friendly)
|
|
//fData=(float)atof(strData);
|
|
|
|
|
|
rs->UpdateField("hours",&fData);
|
|
|
|
//NOCHARGE HOURS
|
|
m_edNC.GetWindowText(strData);
|
|
//02/19/2003 Fix crash on empty field
|
|
if(strData.IsEmpty()) strData="0";
|
|
//01/31/2003 convert to a variant bstr
|
|
_variant_t vtData1(strData);
|
|
fData=(float)vtData1;//cast variant to float (locale friendly)
|
|
//fData=(float)atof(strData);
|
|
rs->UpdateField("nchours",&fData);
|
|
|
|
//TRAVEL HOURS
|
|
m_edTravel.GetWindowText(strData);
|
|
//02/19/2003 Fix crash on empty field
|
|
if(strData.IsEmpty()) strData="0";
|
|
//01/31/2003 convert to a variant bstr
|
|
_variant_t vtData2(strData);
|
|
fData=(float)vtData2;//cast variant to float (locale friendly)
|
|
//fData=(float)atof(strData);
|
|
rs->UpdateField("travhours",&fData);
|
|
|
|
//DISTANCE
|
|
m_edDistance.GetWindowText(strData);
|
|
//02/19/2003 Fix crash on empty field
|
|
if(strData.IsEmpty()) strData="0";
|
|
//01/31/2003 convert to a variant bstr
|
|
_variant_t vtData3(strData);
|
|
fData=(float)vtData3;//cast variant to float (locale friendly)
|
|
//fData=(float)atof(strData);
|
|
rs->UpdateField("distance",&fData);
|
|
|
|
//RATE
|
|
strData=m_cbRatesList.GetCurrentRowID();
|
|
lData=atol(strData);
|
|
rs->UpdateField("rate",&lData);
|
|
|
|
//TRAVEL RATE
|
|
strData=m_cbTravelRatesList.GetCurrentRowID();
|
|
lData=atol(strData);
|
|
rs->UpdateField("travrate",&lData);
|
|
|
|
//DATE
|
|
m_dtDate.GetTime(dtDate);
|
|
|
|
//rs->UpdateField("closed",&dtDate);
|
|
|
|
//START
|
|
m_edStart.GetWindowText(strData);
|
|
|
|
//added 09/20/2000 to catch "Weatherall's bug".
|
|
if(strData.IsEmpty())
|
|
strData="12:00pm";
|
|
dtTime.ParseDateTime(strData,VAR_TIMEVALUEONLY);
|
|
dtData.SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
|
|
|
|
|
|
|
rs->UpdateField("start",&dtData);
|
|
|
|
//STOP Time
|
|
//END DATE
|
|
m_dtEndDate.GetTime(dtEndDate);
|
|
m_edEnd.GetWindowText(strData);
|
|
//added 09/20/2000 to catch "Weatherall's bug".
|
|
if(strData.IsEmpty())
|
|
strData="12:00pm";
|
|
dtTime.ParseDateTime(strData,VAR_TIMEVALUEONLY);
|
|
dtData.SetDateTime(dtEndDate.GetYear(),dtEndDate.GetMonth(),dtEndDate.GetDay(),dtTime.GetHour(),dtTime.GetMinute(),dtTime.GetSecond());
|
|
|
|
|
|
|
|
rs->UpdateField("stop",&dtData);
|
|
|
|
|
|
|
|
//DETAILS
|
|
m_edNotes.GetWindowText(strData);
|
|
rs->UpdateField("details",&strData);
|
|
|
|
|
|
//08/21/2001 each tab sets it's own indexed status now
|
|
bData=false;
|
|
rs->UpdateField("indexed",&bData);
|
|
|
|
rs->SaveRecord();
|
|
rs->pTheConnection->CommitTrans();
|
|
rs->Close();
|
|
//flush through changes or caller wont show updates
|
|
//rs->QueryReadOnly("SELECT labor.* FROM labor WHERE (((labor.link)=0));");
|
|
|
|
|
|
CDialog::OnOK();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWoTabLabourEntryDlg::OnBtncancel()
|
|
{
|
|
//just don't save fields
|
|
CDialog::OnCancel();
|
|
|
|
}
|
|
|
|
|
|
void CWoTabLabourEntryDlg::OnKillfocusEdend()
|
|
{
|
|
|
|
COleDateTime dtTime;
|
|
CString strData;
|
|
if(m_edEnd.GetModify()==TRUE)
|
|
*bModified=true;
|
|
m_edEnd.GetWindowText(strData);
|
|
|
|
if(dtTime.ParseDateTime(strData,VAR_TIMEVALUEONLY)==FALSE)
|
|
{
|
|
AfxMessageBox("Invalid time entered.\r\n"
|
|
"You can enter time in many ways\r\n"
|
|
"We find it faster to use the period\r\n"
|
|
"symbol rather than a colon during entry.\r\n\r\n"
|
|
"Here are some examples of valid entry:\r\n"
|
|
"22.23 is interpreted as 10:00pm\r\n"
|
|
"9.0 = 9:00am\r\n"
|
|
"4.3p = 4:03pm\r\n"
|
|
"good old fashioned 12:30 still = 12:30pm\r\n"
|
|
"Outside north america valid entries\r\n"
|
|
"for your locale may be different");
|
|
return;
|
|
}
|
|
|
|
strData=dtTime.Format(VAR_TIMEVALUEONLY);
|
|
m_edEnd.SetWindowText(strData);
|
|
|
|
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::OnKillfocusEdstart()
|
|
{
|
|
|
|
COleDateTime dtTime;
|
|
CString strData;
|
|
if(m_edStart.GetModify()==TRUE)
|
|
*bModified=true;
|
|
|
|
m_edStart.GetWindowText(strData);
|
|
|
|
if(dtTime.ParseDateTime(strData,VAR_TIMEVALUEONLY)==FALSE)
|
|
{
|
|
AfxMessageBox("Invalid time entered.\r\n"
|
|
"You can enter time in many ways\r\n"
|
|
"We find it faster to use the period\r\n"
|
|
"symbol rather than a colon during entry.\r\n\r\n"
|
|
"Here are some examples of valid entry:\r\n"
|
|
"22.23 is interpreted as 10:00pm\r\n"
|
|
"9.0 = 9:00am\r\n"
|
|
"4.3p = 4:03pm\r\n"
|
|
"good old fashioned 12:30 still = 12:30pm\r\n"
|
|
"Outside north america valid entries\r\n"
|
|
"for your locale may be different");
|
|
return;
|
|
}
|
|
|
|
strData=dtTime.Format(VAR_TIMEVALUEONLY);
|
|
m_edStart.SetWindowText(strData);
|
|
|
|
|
|
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::OnKillfocusEdnotes()
|
|
{
|
|
if(m_edNotes.GetModify())
|
|
*bModified=true;
|
|
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::OnKillfocusEdnc()
|
|
{
|
|
|
|
if(!m_edNC.GetModify()) return;
|
|
|
|
//HOURS
|
|
CString strData;
|
|
float fData;
|
|
m_edNC.GetWindowText(strData);
|
|
if(strData.IsEmpty()) strData="0";
|
|
_variant_t vtData(strData);
|
|
|
|
//v1.9.4.4 added try / catch mechanism to catch dumb-asses entering text in a numeric field
|
|
try
|
|
{
|
|
fData=(float)vtData;//cast variant to float (locale friendly)
|
|
}
|
|
catch( _com_error &e )
|
|
{
|
|
|
|
AfxMessageBox("I could not interpret your entry in the No charge hours field\r\n"
|
|
"I can't save this field until a valid entry is made.\r\n"
|
|
"If you want to leave it blank, put a zero in it.");
|
|
m_edNC.Undo();
|
|
m_edNC.SetModify(FALSE);
|
|
m_edNC.SetFocus();
|
|
return;
|
|
}
|
|
|
|
|
|
//entry was cleared so set back to
|
|
//unmodified so it will check if changed again
|
|
m_edNC.SetModify(FALSE);
|
|
|
|
*bModified=true;
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::OnKillfocusEdbill()
|
|
{
|
|
if(!m_edBill.GetModify()) return;
|
|
|
|
//HOURS
|
|
CString strData;
|
|
float fData;
|
|
m_edBill.GetWindowText(strData);
|
|
if(strData.IsEmpty()) strData="0";
|
|
_variant_t vtData(strData);
|
|
|
|
//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 Billable hours field\r\n"
|
|
"I can't save this field until a valid entry is made.\r\n"
|
|
"If you want to leave it blank, put a zero in it.");
|
|
m_edBill.Undo();
|
|
m_edBill.SetModify(FALSE);
|
|
m_edBill.SetFocus();
|
|
return;
|
|
}
|
|
|
|
|
|
//entry was cleared so set back to
|
|
//unmodified so it will check if changed again
|
|
m_edBill.SetModify(FALSE);
|
|
|
|
*bModified=true;
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::OnDatetimechangeDtdate(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
COleDateTime dtData;
|
|
m_dtDate.GetTime(dtData);
|
|
m_dtEndDate.SetTime(dtData);
|
|
|
|
*bModified=true;
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::OnDatetimechangeDtdateend(NMHDR* pNMHDR, LRESULT* pResult)
|
|
{
|
|
*bModified=true;
|
|
*pResult = 0;
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::OnCloseupCbrateslist()
|
|
{
|
|
*bModified=true;
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::OnCloseupCbtechlist()
|
|
{
|
|
*bModified=true;
|
|
SetClientRates();
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::OnCloseupCbtravelrateslist()
|
|
{
|
|
*bModified=true;
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::OnKillfocusEdtravel()
|
|
{
|
|
if(!m_edTravel.GetModify()) return;
|
|
|
|
//HOURS
|
|
CString strData;
|
|
float fData;
|
|
m_edTravel.GetWindowText(strData);
|
|
if(strData.IsEmpty()) strData="0";
|
|
_variant_t vtData(strData);
|
|
|
|
//v1.9.4.4 added try / catch mechanism to catch dumb-asses entering text in a numeric field
|
|
try
|
|
{
|
|
fData=(float)vtData;//cast variant to float (locale friendly)
|
|
}
|
|
catch( _com_error &e )
|
|
{
|
|
|
|
AfxMessageBox("I could not interpret your entry in the Travel hours field\r\n"
|
|
"I can't save this field until a valid entry is made.\r\n"
|
|
"If you want to leave it blank, put a zero in it.");
|
|
m_edTravel.Undo();
|
|
m_edTravel.SetModify(FALSE);
|
|
m_edTravel.SetFocus();
|
|
return;
|
|
}
|
|
|
|
|
|
//entry was cleared so set back to
|
|
//unmodified so it will check if changed again
|
|
m_edTravel.SetModify(FALSE);
|
|
|
|
*bModified=true;
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::Security()
|
|
{
|
|
int x=m_pApp->Allowed(RWORKORDER,false);
|
|
if(x==0)//no access allowed
|
|
{
|
|
m_pApp->SecurityWarning();
|
|
CDialog::OnCancel();
|
|
}
|
|
if(x==2 )//read only//changed01/22/01 allow non tech entry
|
|
{
|
|
|
|
m_cbRatesList.EnableWindow(FALSE);
|
|
m_cbTechList.EnableWindow(FALSE);
|
|
m_cbTravelRatesList.EnableWindow(FALSE);
|
|
m_dtDate.EnableWindow(FALSE);
|
|
|
|
//v1.9.4.2
|
|
m_dtEndDate.EnableWindow(FALSE);
|
|
|
|
m_edBill.SetReadOnly(TRUE);
|
|
m_edEnd.SetReadOnly(TRUE);
|
|
m_edNC.SetReadOnly(TRUE);
|
|
m_edNotes.SetReadOnly(TRUE);
|
|
m_edStart.SetReadOnly(TRUE);
|
|
m_edTravel.SetReadOnly(TRUE);
|
|
m_edDistance.SetReadOnly(TRUE);
|
|
m_lblRate.EnableWindow(FALSE);
|
|
m_lblTech.EnableWindow(FALSE);
|
|
m_lblTravelRate.EnableWindow(FALSE);
|
|
m_btnCancel.ShowWindow(FALSE);
|
|
|
|
}
|
|
}
|
|
//Extensively modified for v1.9.4.4
|
|
//now sets rates based on selected tech not current users id
|
|
//also now skips changing settings if hours are non-zero
|
|
void CWoTabLabourEntryDlg::SetClientRates()
|
|
{
|
|
|
|
|
|
CString q;
|
|
//Dont change a thing if hours were entered
|
|
m_edBill.GetWindowText(q);
|
|
if(q!="0") return;
|
|
|
|
//long lData;
|
|
long lClientDefRate,lClientDefTravelRate;
|
|
long lSelectedTechDefRate,lSelectedTechDefTravelRate;
|
|
|
|
|
|
//Get clients default rates
|
|
q.Format("SELECT clients.defrate, clients.deftravelrate "
|
|
"FROM clients "
|
|
"WHERE (((clients.id)=%s));",m_strClientID);
|
|
|
|
cbrs->QueryReadOnly(q);
|
|
if(cbrs->IsEmpty())
|
|
{
|
|
|
|
lClientDefRate=0;
|
|
lClientDefTravelRate=0;
|
|
}
|
|
else
|
|
{
|
|
cbrs->FetchField("defrate",&lClientDefRate);
|
|
cbrs->FetchField("deftravelrate",&lClientDefTravelRate);
|
|
}
|
|
cbrs->Close();
|
|
|
|
//Get selected tech's default rates
|
|
q.Format("SELECT users.defrate, users.deftravelrate "
|
|
"FROM users "
|
|
"WHERE (((users.id)=%s));",m_cbTechList.GetCurrentRowID());
|
|
|
|
cbrs->QueryReadOnly(q);
|
|
if(cbrs->IsEmpty())
|
|
{
|
|
|
|
lSelectedTechDefRate=0;
|
|
lSelectedTechDefTravelRate=0;
|
|
}
|
|
else
|
|
{
|
|
cbrs->FetchField("defrate",&lSelectedTechDefRate);
|
|
cbrs->FetchField("deftravelrate",&lSelectedTechDefTravelRate);
|
|
}
|
|
cbrs->Close();
|
|
|
|
|
|
|
|
//Set rate to client or selected tech as appropriate
|
|
|
|
if(lClientDefRate!=0)
|
|
m_cbRatesList.Select(lClientDefRate);
|
|
else
|
|
m_cbRatesList.Select(lSelectedTechDefRate);
|
|
|
|
|
|
//Set travel rate
|
|
if(lClientDefTravelRate!=0)
|
|
m_cbTravelRatesList.Select(lClientDefTravelRate);
|
|
else
|
|
m_cbTravelRatesList.Select(lSelectedTechDefTravelRate);//v1.9.4.4
|
|
|
|
|
|
|
|
}
|
|
/*
|
|
void CWoTabLabourEntryDlg::SetClientRates()
|
|
{
|
|
CString q;
|
|
long lData;
|
|
|
|
q.Format("SELECT clients.defrate, clients.deftravelrate "
|
|
"FROM clients "
|
|
"WHERE (((clients.id)=%s));",m_strClientID);
|
|
|
|
cbrs->QueryReadOnly(q);
|
|
if(cbrs->IsEmpty())
|
|
{
|
|
|
|
return;
|
|
}
|
|
|
|
cbrs->FetchField("defrate",&lData);
|
|
|
|
if(lData!=0)
|
|
m_cbRatesList.Select(lData);
|
|
|
|
cbrs->FetchField("deftravelrate",&lData);
|
|
if(lData!=0)
|
|
m_cbTravelRatesList.Select(lData);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
void CWoTabLabourEntryDlg::OnLblrate()
|
|
{
|
|
CRatesDlg d;
|
|
if(d.DoModal()==IDOK)
|
|
FillRatesList();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CWoTabLabourEntryDlg::OnLbltravelrate()
|
|
{
|
|
|
|
OnLblrate();
|
|
}
|
|
|
|
void CWoTabLabourEntryDlg::OnEnKillfocusEdDistance()
|
|
{
|
|
|
|
if(!m_edDistance.GetModify()) return;
|
|
|
|
//HOURS
|
|
CString strData;
|
|
float fData;
|
|
m_edDistance.GetWindowText(strData);
|
|
if(strData.IsEmpty()) strData="0";
|
|
_variant_t vtData(strData);
|
|
|
|
//v1.9.4.4 added try / catch mechanism to catch dumb-asses entering text in a numeric field
|
|
try
|
|
{
|
|
fData=(float)vtData;//cast variant to float (locale friendly)
|
|
}
|
|
catch( _com_error &e )
|
|
{
|
|
|
|
AfxMessageBox("I could not interpret your entry in the Distance field\r\n"
|
|
"I can't save this field until a valid entry is made.\r\n"
|
|
"If you want to leave it blank, put a zero in it.");
|
|
m_edDistance.Undo();
|
|
m_edDistance.SetModify(FALSE);
|
|
m_edDistance.SetFocus();
|
|
return;
|
|
}
|
|
|
|
|
|
//entry was cleared so set back to
|
|
//unmodified so it will check if changed again
|
|
m_edDistance.SetModify(FALSE);
|
|
|
|
*bModified=true;
|
|
}
|