AyaNova CE Archive added as recovered from storage during attempt to upgrade a customer from v1.7 to v8!
This commit is contained in:
@@ -0,0 +1,206 @@
|
||||
// FindClientDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "sp.h"
|
||||
#include "FindClientDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CFindClientDlg dialog
|
||||
|
||||
|
||||
CFindClientDlg::CFindClientDlg(CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CFindClientDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CFindClientDlg)
|
||||
// NOTE: the ClassWizard will add member initialization here
|
||||
//}}AFX_DATA_INIT
|
||||
m_pApp= (CSpApp*)AfxGetApp();
|
||||
/*
|
||||
rs=new GZRset("Error: Find client dialog");
|
||||
rs->SetConnect(m_pApp->strConnectString);
|
||||
*/
|
||||
//Initialize recordset pointer
|
||||
|
||||
rs=m_pApp->rsPool->GetRS("CFindClientDlg");
|
||||
rs->Query("SELECT * FROM users WHERE users.id=0");
|
||||
m_pstrReturnValue=NULL;
|
||||
}
|
||||
|
||||
|
||||
CFindClientDlg::~CFindClientDlg()
|
||||
{
|
||||
m_pApp->rsPool->ReleaseRS(&rs->m_nID);
|
||||
}
|
||||
|
||||
void CFindClientDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CFindClientDlg)
|
||||
DDX_Control(pDX, IDC_EDACCT, m_edAccount);
|
||||
DDX_Control(pDX, IDC_LBLRESULTS, m_lblResults);
|
||||
DDX_Control(pDX, IDC_EDSN, m_edSN);
|
||||
DDX_Control(pDX, IDC_EDPHONE, m_edPhone);
|
||||
DDX_Control(pDX, IDC_EDEMAIL, m_edEmail);
|
||||
DDX_Control(pDX, IDC_BTNSEARCH, m_btnSearch);
|
||||
DDX_Control(pDX, IDC_BTNDONE, m_btnDone);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CFindClientDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CFindClientDlg)
|
||||
ON_BN_CLICKED(IDC_BTNDONE, OnBtndone)
|
||||
ON_BN_CLICKED(IDC_BTNSEARCH, OnBtnsearch)
|
||||
ON_BN_CLICKED(IDC_BTNCLEAR, OnBtnclear)
|
||||
ON_BN_CLICKED(IDC_BTNCANCEL, OnBtncancel)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CFindClientDlg message handlers
|
||||
|
||||
void CFindClientDlg::OnBtndone()
|
||||
{
|
||||
CDialog::OnOK();
|
||||
}
|
||||
|
||||
//****************************************
|
||||
void CFindClientDlg::OnBtnsearch()
|
||||
{
|
||||
CString strData,q;
|
||||
long lData;
|
||||
int x=0;
|
||||
*m_pstrReturnValue="0";
|
||||
m_lblResults.SetWindowText("");
|
||||
|
||||
m_edSN.GetWindowText(strData);
|
||||
|
||||
if(strData.IsEmpty())
|
||||
{
|
||||
m_edPhone.GetWindowText(strData);
|
||||
x=1;
|
||||
}
|
||||
|
||||
|
||||
if(strData.IsEmpty())
|
||||
{
|
||||
m_edEmail.GetWindowText(strData);
|
||||
x=2;
|
||||
}
|
||||
|
||||
|
||||
if(strData.IsEmpty())
|
||||
{
|
||||
m_edAccount.GetWindowText(strData);
|
||||
x=3;
|
||||
}
|
||||
|
||||
if(strData.IsEmpty())
|
||||
return;//nothing entered
|
||||
|
||||
//prepare the query based on what field was filled out
|
||||
switch (x)
|
||||
{
|
||||
case 0://SERIAL NUMBER
|
||||
q.Format("SELECT clients.id, IIf(IsNull([company]),[last] & \", \" & [first],[company]) AS name "
|
||||
"FROM units INNER JOIN clients ON units.client = clients.id "
|
||||
"WHERE (((units.sn)=\"%s\"));",strData);
|
||||
break;
|
||||
|
||||
case 1://PHONE NUMBER
|
||||
q.Format("SELECT clients.id, IIf(IsNull([company]),[last] & \", \" & [first],[company]) AS name "
|
||||
"FROM clients WHERE (((clients.bizphone)=\"%s\"));",strData);
|
||||
break;
|
||||
|
||||
case 2://EMAIL
|
||||
q.Format("SELECT clients.id, IIf(IsNull([company]),[last] & \", \" & [first],[company]) AS name "
|
||||
"FROM clients WHERE (((clients.email)=\"%s\"));",strData);
|
||||
break;
|
||||
|
||||
case 3://Client account number
|
||||
q.Format("SELECT clients.id, IIf(IsNull([company]),[last] & \", \" & [first],[company]) AS name "
|
||||
"FROM clients WHERE (((clients.acctnumber)=\"%s\"));",strData);
|
||||
break;
|
||||
}
|
||||
|
||||
//FUTURE: Modify this to allow for more than one match
|
||||
//FILL a list box or something
|
||||
//AfxMessageBox(q);
|
||||
rs->Query(q);
|
||||
if(rs->IsEmpty())
|
||||
{
|
||||
m_lblResults.SetFontBold(FALSE);
|
||||
m_lblResults.SetTextColor(RGB(255,0,0));
|
||||
m_lblResults.SetText("No match found");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_lblResults.SetTextColor(RGB(0,0,255));
|
||||
|
||||
m_lblResults.SetFontBold(TRUE);
|
||||
rs->FetchField("name",&strData);
|
||||
strData="Found---> " + strData;
|
||||
m_lblResults.SetText(strData);
|
||||
|
||||
//get the ID value
|
||||
rs->FetchField("id",&lData);
|
||||
m_pstrReturnValue->Format("%u",lData);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//****************************************
|
||||
BOOL CFindClientDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
ASSERT(m_pstrReturnValue!=NULL);
|
||||
//Hyperlink find label
|
||||
m_lblResults.SetFontSize(12);
|
||||
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
|
||||
//*****************************************
|
||||
void CFindClientDlg::SetReturn(CString *strReturnClientID)
|
||||
{
|
||||
m_pstrReturnValue=strReturnClientID;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//*****************************
|
||||
void CFindClientDlg::OnBtnclear()
|
||||
{
|
||||
m_edEmail.SetWindowText("");
|
||||
m_edPhone.SetWindowText("");
|
||||
m_edSN.SetWindowText("");
|
||||
m_lblResults.SetWindowText("");
|
||||
}
|
||||
|
||||
|
||||
//*******************************
|
||||
void CFindClientDlg::OnBtncancel()
|
||||
{
|
||||
*m_pstrReturnValue="0";
|
||||
CDialog::OnCancel();
|
||||
}
|
||||
|
||||
|
||||
//Do nothing when user presses enter key
|
||||
void CFindClientDlg::OnOK()
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user