// UnitsDlg.cpp : implementation file // #include "stdafx.h" #include "sp.h" #include "UnitsDlg.h" #include "NonClientsDlg.h" #include "ModelsDlg.h" #include "ClientsDlg.h" #include "PM.h" #include "SimpleDate.h" #include "GenericPopupList.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CUnitsDlg dialog CUnitsDlg::CUnitsDlg(CWnd* pParent /*=NULL*/) : CDialog(CUnitsDlg::IDD, pParent) { //{{AFX_DATA_INIT(CUnitsDlg) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT m_bAddMode=false; m_pApp= (CSpApp*)AfxGetApp(); /* rs=new GZRset("Error: Units dialog"); rs->SetConnect(m_pApp->strConnectString); cbrs=new GZRset("Error: Units dialog combo box recordset\r\n"); cbrs->SetConnect(m_pApp->strConnectString); */ //Initialize recordset pointer rs=m_pApp->rsPool->GetRS("CUnitsDlg (RS)"); cbrs=m_pApp->rsPool->GetRS("CUnitsDlg (CBRS)"); m_pstrReturnUnit=NULL; m_pstrReturnClient=NULL; m_strSelectedUnit.Empty(); m_strSelectedClient.Empty(); m_strSelectedModel.Empty(); m_bListByDescription=true; m_bIniting=true; m_bSubUnitSelected=false; m_bAddIsDuplicate=false; } //***************************** CUnitsDlg::~CUnitsDlg() { m_pApp->rsPool->ReleaseRS(&rs->m_nID); m_pApp->rsPool->ReleaseRS(&cbrs->m_nID); } //************************************* void CUnitsDlg::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CUnitsDlg) DDX_Control(pDX, IDC_LBL_SUB_UNITS, m_lblSubUnits); DDX_Control(pDX, IDC_CBSN2, m_cbSubSn); DDX_Control(pDX, IDC_BTNADDDUPLICATE, m_btnAddDuplicate); DDX_Control(pDX, IDC_EDLASTMETERREADING, m_edLastMeterReading); DDX_Control(pDX, IDC_BTNPM, m_btnPM); DDX_Control(pDX, IDC_LBLBYMODEL, m_lblByModel); DDX_Control(pDX, IDC_LBLBYDESC, m_lblByDesc); DDX_Control(pDX, IDC_CKRENTAL, m_ckRental); DDX_Control(pDX, IDC_EDID3, m_edID3); DDX_Control(pDX, IDC_EDID2, m_edID2); DDX_Control(pDX, IDC_EDID1, m_edID1); DDX_Control(pDX, IDC_CKPM, m_ckPM); DDX_Control(pDX, IDC_LBLSNLIST, m_lblSNList); DDX_Control(pDX, IDC_LBLRESELLERS, m_lblResellers); DDX_Control(pDX, IDC_LBLMODEL, m_lblModel); DDX_Control(pDX, IDC_LBLCLIENT, m_lblClient); DDX_Control(pDX, IDC_EDWARRANTYTERMS, m_edWarrantyTerms); DDX_Control(pDX, IDC_EDSN, m_edSN); DDX_Control(pDX, IDC_EDRECEIPT, m_edReceipt); DDX_Control(pDX, IDC_EDNOTES, m_edNotes); DDX_Control(pDX, IDC_EDDESCRIPTION, m_edDescription); DDX_Control(pDX, IDC_DTPURCHASED, m_dtPurchased); DDX_Control(pDX, IDC_DONE, m_btnDone); DDX_Control(pDX, IDC_CKBOUGHTHERE, m_ckBoughtHere); DDX_Control(pDX, IDC_CBSN, m_cbSN); DDX_Control(pDX, IDC_CBRESELLERS, m_cbResellers); DDX_Control(pDX, IDC_CBMODELS, m_cbModels); DDX_Control(pDX, IDC_CBCLIENTS, m_cbClients); DDX_Control(pDX, IDC_BTNADD, m_btnAdd); DDX_Control(pDX, IDC_BTNDELETE, m_btnDelete); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CUnitsDlg, CDialog) //{{AFX_MSG_MAP(CUnitsDlg) ON_CBN_CLOSEUP(IDC_CBSN, OnCloseupCbsn) ON_CBN_CLOSEUP(IDC_CBMODELS, OnCloseupCbmodels) ON_CBN_CLOSEUP(IDC_CBCLIENTS, OnCloseupCbclients) ON_BN_CLICKED(IDC_DONE, OnDone) ON_BN_CLICKED(IDC_LBLRESELLERS, OnLblresellers) ON_BN_CLICKED(IDC_LBLMODEL, OnLblmodel) ON_BN_CLICKED(IDC_LBLCLIENT, OnLblclient) ON_EN_KILLFOCUS(IDC_EDWARRANTYTERMS, OnKillfocusEdwarrantyterms) ON_EN_KILLFOCUS(IDC_EDSN, OnKillfocusEdsn) ON_EN_KILLFOCUS(IDC_EDRECEIPT, OnKillfocusEdreceipt) ON_EN_KILLFOCUS(IDC_EDNOTES, OnKillfocusEdnotes) ON_EN_KILLFOCUS(IDC_EDDESCRIPTION, OnKillfocusEddescription) ON_NOTIFY(DTN_DATETIMECHANGE, IDC_DTPURCHASED, OnDatetimechangeDtpurchased) ON_BN_CLICKED(IDC_CKPM, OnCkpm) ON_BN_CLICKED(IDC_CKBOUGHTHERE, OnCkboughthere) ON_CBN_CLOSEUP(IDC_CBRESELLERS, OnCloseupCbresellers) ON_BN_CLICKED(IDC_BTNDELETE, OnBtndelete) ON_BN_CLICKED(IDC_BTNADD, OnBtnadd) ON_BN_CLICKED(IDC_CKRENTAL, OnCkrental) ON_BN_CLICKED(IDC_LBLBYDESC, OnLblbydesc) ON_BN_CLICKED(IDC_LBLBYMODEL, OnLblbymodel) ON_EN_KILLFOCUS(IDC_EDID1, OnKillfocusEdid1) ON_EN_KILLFOCUS(IDC_EDID2, OnKillfocusEdid2) ON_EN_KILLFOCUS(IDC_EDID3, OnKillfocusEdid3) ON_BN_CLICKED(IDC_BTNPM, OnBtnpm) ON_EN_KILLFOCUS(IDC_EDLASTMETERREADING, OnKillfocusEdlastmeterreading) ON_BN_CLICKED(IDC_BTNADDDUPLICATE, OnBtnaddduplicate) ON_CBN_CLOSEUP(IDC_CBSN2, OnCloseupCbsn2) ON_BN_CLICKED(IDC_LBL_SUB_UNITS, OnLblSubUnits) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CUnitsDlg message handlers void CUnitsDlg::SetReturnStrings(CString *sn,CString *client) { m_pstrReturnUnit=sn; m_pstrReturnClient=client; //specific sn requested? if(!m_pstrReturnUnit->IsEmpty()) m_strSelectedUnit=*m_pstrReturnUnit; //specific client requested? if(!m_pstrReturnClient->IsEmpty()) m_strSelectedClient=*m_pstrReturnClient; } //*********************************** BOOL CUnitsDlg::OnInitDialog() { CDialog::OnInitDialog(); CWaitCursor wait; ShowWindow(SW_HIDE); Security(); //make "hyperlinks" m_lblClient.SetTextColor(RGB(0,0,255)); m_lblClient.SetFontUnderline(TRUE); m_lblClient.SetLink(TRUE); m_lblClient.SetLinkCursor(m_pApp->hcHand); m_lblClient.SetLinkURL(""); m_lblModel.SetTextColor(RGB(0,0,255)); m_lblModel.SetFontUnderline(TRUE); m_lblModel.SetLink(TRUE); m_lblModel.SetLinkCursor(m_pApp->hcHand); m_lblModel.SetLinkURL(""); m_lblResellers.SetTextColor(RGB(0,0,255)); m_lblResellers.SetFontUnderline(TRUE); m_lblResellers.SetLink(TRUE); m_lblResellers.SetLinkCursor(m_pApp->hcHand); m_lblResellers.SetLinkURL(""); m_lblByDesc.SetTextColor(RGB(0,0,255)); m_lblByDesc.SetFontUnderline(TRUE); m_lblByDesc.SetLink(TRUE); m_lblByDesc.SetLinkCursor(m_pApp->hcHand); m_lblByDesc.SetLinkURL(""); m_lblByModel.SetTextColor(RGB(0,0,255)); m_lblByModel.SetFontUnderline(TRUE); m_lblByModel.SetLink(TRUE); m_lblByModel.SetLinkCursor(m_pApp->hcHand); m_lblByModel.SetLinkURL(""); m_lblSubUnits.SetTextColor(RGB(0,0,255)); m_lblSubUnits.SetFontUnderline(TRUE); m_lblSubUnits.SetLink(TRUE); m_lblSubUnits.SetLinkCursor(m_pApp->hcHand); m_lblSubUnits.SetLinkURL(""); //SETUP FOR MODE //display clients name at top and //filter by passed sn/client FillModelList(); FillClientList(); FillResellerList(); //EnableFields(false); //must be called last, as is dependant on other list values FillSNList(); ShowWindow(SW_MAXIMIZE); m_cbSN.SetFocus(); m_bIniting=false; //=================================================== // 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); //=================================================== return FALSE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } //***************************************** //====================================== void CUnitsDlg::FillSNList() { CString q,client,model,strData,strIndex; long lData; m_cbSN.Clear(); m_cbSubSn.Clear(); //client=m_cbClients.GetCurrentRowID(); //model=m_cbModels.GetCurrentRowID(); //No filter //if(client=="0" && model == "0") q="SELECT units.sn, units.id FROM units ORDER BY units.sn;"; /* //Filter by client if(client!="0" && model == "0") q.Format("SELECT units.sn, units.id FROM units " "WHERE (((units.client)=%s)) ORDER BY units.sn;",client); //Filter by model number if(client=="0" && model != "0") q.Format(" SELECT units.sn, units.id FROM units " "WHERE (((units.model)=%s)) ORDER BY units.sn;",model); //Filter by client and model number if(client!="0" && model != "0") q.Format("SELECT units.sn, units.id FROM units " "WHERE (((units.client)=%s) AND ((units.model)=%s));",client,model); */ //Set the default strData="