📄 searchdialog.cpp
字号:
// SearchDialog.cpp : implementation file
//
#include "stdafx.h"
#include "DataBaseSoftWare.h"
#include "DataBaseSoftWareDlg.h"
#include "SearchDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern _RecordsetPtr m_pRecordset;
extern CDataBaseSoftWareApp theApp;
extern char *p;
/////////////////////////////////////////////////////////////////////////////
// SearchDialog dialog
SearchDialog::SearchDialog(CWnd* pParent /*=NULL*/)
: CDialog(SearchDialog::IDD, pParent)
{
//{{AFX_DATA_INIT(SearchDialog)
m_Name = _T("");
m_nChoice = -1;
m_time1 = 0;
m_time2 = 0;
//}}AFX_DATA_INIT
}
void SearchDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(SearchDialog)
DDX_Control(pDX, IDOK, m_ok);
DDX_Control(pDX, IDC_BUTTON_SEARCH, m_search);
DDX_Control(pDX, IDC_COMBO_ComIn, m_ComORIn);
DDX_Text(pDX, IDC_EDIT_SEARCHNAME, m_Name);
DDX_Radio(pDX, IDC_RADIO_COMIN, m_nChoice);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER1, m_time1);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER2, m_time2);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(SearchDialog, CDialog)
//{{AFX_MSG_MAP(SearchDialog)
ON_BN_CLICKED(IDC_BUTTON_SEARCH, OnButtonSearch)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// SearchDialog message handlers
BOOL SearchDialog::OnInitDialog()
{
CDialog::OnInitDialog();
// ((CButton *)GetDlgItem(IDC_RADIO_COMIN))->SetCheck(FALSE);//选上
m_pRecordset.CreateInstance("ADODB.Recordset");
m_pRecordset->Open("SELECT * FROM user_data",_variant_t((IDispatch *)theApp.m_pConnection,true),adOpenDynamic,adLockPessimistic,adCmdText);
UpdateData(FALSE);
((CButton *)GetDlgItem(IDC_RADIO_COMIN))->SetCheck(TRUE);//选上
return TRUE;
}
void SearchDialog::OnButtonSearch()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
if(!UpdateData())
return;
CString temp="%";
// GetDlgItem(IDC_EDIT_SEARCHCI)->GetWindowText(m_ComORIn);
GetDlgItem(IDC_EDIT_SEARCHNAME)->GetWindowText(m_Name);
CString sql;
CString temp1;
GetDlgItem(IDC_COMBO_ComIn)->GetWindowText(temp1);
HWND hWnd = ::FindWindow(NULL,"水平心名苑管理系统");
switch (m_nChoice)
{
case 0:
if(!temp1.IsEmpty())
{
sql.Format("Select * from user_data where IsCompuny like '%s%s%s'",temp,temp1,temp);
// sql = "select * from user_data where IndexID =6";
}
else
{
AfxMessageBox("请您先选择公司信息!");
return;
}
break;
case 1:
if(!m_Name.IsEmpty())
{
sql.Format("Select * from user_data where name like '%s%s%s'",temp,m_Name,temp);
// sql = "select * from user_data";
}
else
{
AfxMessageBox("请您先输入客户姓名或公司名称!");
return;
}
break;
case 2:
{
time_t osBinaryTime1 = m_time1.GetTime();
time_t osBinaryTime2 = m_time2.GetTime();
CString Time1=m_time1.Format("%Y-%m-%d");
CString Time2=m_time2.Format("%Y-%m-%d");
// sql.Format("Select * from user_data where ChangeTime like cdate(Time1)");
// sql.Format("Select * from user_data where ChangeTime between '1970/01/01' and'1971/01/01");
sql.Format("Select * from user_data where ChangeTime=1970-01-01");
// sql.Format("Select * from user_data where ChangeTime >=cdate('1970-01-01' ) AND ChangeTime <=cdate('2009-01-10' ) ");
// sql.Format("Select * from user_data where ChangeTime between cdate('"+Time1+"') AND cdate('"+Time2+"')");
// sql.Format("Select * from user_data where ChangeTime like '%s%s%s'",temp,Time1,temp);
}
break;
}
p=new char[200];
strcpy(p,sql);
::SendMessage(hWnd,UM_UpdateData,0,0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -