Files
ayanova7/archive/ayanova 1.9.4 CE final release db schema 171/sp/DlgDispStatPopup.cpp

264 lines
6.5 KiB
C++

// DlgDispStatPopup.cpp : implementation file
//
#include "stdafx.h"
#include "sp.h"
#include "DlgDispStatPopup.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgDispStatPopup dialog
CDlgDispStatPopup::CDlgDispStatPopup(CWnd* pParent /*=NULL*/)
: CDialog(CDlgDispStatPopup::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgDispStatPopup)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pApp = (CSpApp*)AfxGetApp();
//Initialize recordset pointer
rs=m_pApp->rsPool->GetRS("CDlgDispStatPopup");
}
void CDlgDispStatPopup::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgDispStatPopup)
DDX_Control(pDX, IDC_LBLWOINFO, m_lblWOInfo);
DDX_Control(pDX, IDC_DTSTARTTIME, m_dtStartTime);
DDX_Control(pDX, IDC_DTENDTIME, m_dtEndTime);
DDX_Control(pDX, IDC_DTSCHEDENDDATE, m_dtEndDate);
DDX_Control(pDX, IDC_DTSCHEDSTARTDATE, m_dtStartDate);
DDX_Control(pDX, IDC_LBLTECHS, m_lblTechNumber);
DDX_Control(pDX, IDC_CBTECHLIST, m_cbTechList);
DDX_Control(pDX, IDC_CBSTATUSITEMLIST, m_cbStatus);
DDX_Control(pDX, IDC_LBLSTATUSLIST, m_lblStatus);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgDispStatPopup, CDialog)
//{{AFX_MSG_MAP(CDlgDispStatPopup)
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
ON_BN_CLICKED(IDC_BTN_CANCEL, OnBtnCancel)
ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTSCHEDSTARTDATE, OnDatetimechangeDtschedstartdate)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgDispStatPopup message handlers
void CDlgDispStatPopup::OnOK()
{}
CDlgDispStatPopup::~CDlgDispStatPopup()
{
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
}
BOOL CDlgDispStatPopup::OnInitDialog()
{
CDialog::OnInitDialog();
Security();
CString q;
q.Format("Assigned tech number %s is:",*m_pstrSelectedTechNumber);
m_lblTechNumber.SetWindowText(q);
FillTechList();
FillList();
m_dtEndDate.SetTime(*m_pdtEnd);
m_dtStartDate.SetTime(*m_pdtStart);
m_dtEndTime.SetTime(*m_pdtEnd);
m_dtStartTime.SetTime(*m_pdtStart);
//added for MASS benefit
m_lblWOInfo.SetWindowText(m_strWOInfo);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgDispStatPopup::FillList()
{
CString q,strData,strIndex;
long lData;
//FILL STATUS LIST
m_cbStatus.Clear();
m_cbStatus.AddRow(" <No status>","0");
rs->QueryReadOnly("SELECT probstat.id, probstat.notes FROM probstat ORDER BY probstat.id;");
if(!rs->IsEmpty())
{
do
{
rs->FetchField("notes",&strData);
rs->FetchField("id",&lData);
strIndex.Format("%u",lData);
m_cbStatus.AddRow(strData,strIndex);
}while(rs->MoveForward());
if(m_pstrSelectedStatus->IsEmpty())
m_cbStatus.SetCurSel(0);
else
m_cbStatus.Select(*m_pstrSelectedStatus);
}
}
void CDlgDispStatPopup::OnBtndone()
{
CString q;
COleDateTime dtDate,dtTime;
*m_pstrSelectedStatus=m_cbStatus.GetCurrentRowID();
*m_pstrSelectedTech=m_cbTechList.GetCurrentRowID();
//fetch colours if it's a valid status item
if(*m_pstrSelectedStatus!="0")
{
q.Format("SELECT probstat.red, probstat.green, probstat.blue "
"FROM probstat WHERE (((probstat.id)=%s));",*m_pstrSelectedStatus);
rs->QueryReadOnly(q);
rs->FetchField("red",m_plRed);
rs->FetchField("green",m_plGreen);
rs->FetchField("blue",m_plBlue);
}
else
{
*m_plRed=0;
*m_plGreen=0;
*m_plBlue=0;
}
//store date and times
m_dtStartDate.GetTime(dtDate);
m_dtStartTime.GetTime(dtTime);
m_pdtStart->SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),
dtTime.GetHour(),dtTime.GetMinute(),0);
m_dtEndDate.GetTime(dtDate);
m_dtEndTime.GetTime(dtTime);
m_pdtEnd->SetDateTime(dtDate.GetYear(),dtDate.GetMonth(),dtDate.GetDay(),
dtTime.GetHour(),dtTime.GetMinute(),0);
CDialog::OnOK();
}
void CDlgDispStatPopup::FillTechList()
{
CString strData;
CString strIndex;
CString q;
long lData;
m_cbTechList.Clear();
m_cbTechList.AddRow(" <To be assigned>","0");
//look for selected tech and see if in inactive list:
if(!m_pstrSelectedTech->IsEmpty() && *m_pstrSelectedTech!="0")
{
q.Format("SELECT users.id, [last] & \", \" & [first] AS fullname "
"FROM users "
"WHERE (((users.id)=%s) AND ((users.active)=False));",*m_pstrSelectedTech);
rs->QueryReadOnly(q);
if(!rs->IsEmpty()) //it's an inactive tech put them in the list "manually"
{
rs->FetchField("fullname",&strData);
rs->FetchField("id",&lData);
strIndex.Format("%u",lData);
q="<NA> " + strData;
m_cbTechList.AddRow(q,strIndex);
}
}
//change to active only 10/03/00
q="SELECT users.id, [last] & \", \" & [first] AS fullname FROM users "
"WHERE (((users.id)<>1) AND ((users.tech)=True) AND ((users.active)=True)) "
"ORDER BY users.last;";
//////////////////m_pApp->ShowStuff(q);
rs->QueryReadOnly(q);
if(!rs->IsEmpty())
{
rs->MoveFirst();
rs->FetchField("fullname",&strData);
rs->FetchField("id",&lData);
strIndex.Format("%u",lData);
m_cbTechList.AddRow(strData,strIndex);
while(rs->MoveForward())
{
rs->FetchField("fullname",&strData);
rs->FetchField("id",&lData);
strIndex.Format("%u",lData);
m_cbTechList.AddRow(strData,strIndex);
}
}
//if(!m_pstrSelectedTech->IsEmpty())
m_cbTechList.Select(*m_pstrSelectedTech);
//else
//{//attempt to select by current user id
// m_pstrSelectedTech->Format("%u",m_pApp->m_lusrID);
// m_cbTechList.Select(*m_pstrSelectedTech);
// }
}
void CDlgDispStatPopup::OnBtnCancel()
{
CDialog::OnCancel();
}
void CDlgDispStatPopup::OnDatetimechangeDtschedstartdate(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
COleDateTime dtData;
m_dtStartDate.GetTime(dtData);
m_dtEndDate.SetTime(dtData);
*pResult = 0;
}
void CDlgDispStatPopup::Security()
{
int x=m_pApp->Allowed(RWORKORDER,true);
if(x==0)//no access allowed
{
m_pApp->SecurityWarning();
CDialog::OnCancel();
}
if(x==2)//read only
{
m_cbStatus.EnableWindow(FALSE);
m_cbTechList.EnableWindow(FALSE);
m_dtEndDate.EnableWindow(FALSE);
m_dtEndTime.EnableWindow(FALSE);
m_dtStartDate.EnableWindow(FALSE);
m_dtStartTime.EnableWindow(FALSE);
}
}