📄 search.cpp
字号:
// Search.cpp : implementation file
//
#include "stdafx.h"
#include "横店集团保卫人员管理系统.h"
#include "Search.h"
#include "detailinfor.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString SearchType;
extern CString SearchValue;
extern int SearchMode;
extern int Eq;
/////////////////////////////////////////////////////////////////////////////
// CSearch dialog
CSearch::CSearch(CWnd* pParent /*=NULL*/)
: CDialog(CSearch::IDD, pParent)
{
//{{AFX_DATA_INIT(CSearch)
m_value = _T("");
m_val = _T("");
//}}AFX_DATA_INIT
}
void CSearch::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSearch)
DDX_Control(pDX, IDC_COMBO2, m_Type);
DDX_Control(pDX, IDC_COMBO1, m_combo);
DDX_Text(pDX, IDC_Value, m_value);
DDX_Text(pDX, IDC_EDIT2, m_val);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSearch, CDialog)
//{{AFX_MSG_MAP(CSearch)
ON_BN_CLICKED(IDC_BUTTON1, OnSearch)
ON_WM_PAINT()
ON_WM_CTLCOLOR()
ON_CBN_SELCHANGE(IDC_COMBO2, OnSelchangeCombo2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSearch message handlers
BOOL CSearch::OnInitDialog()
{
CDialog::OnInitDialog();
Type=-1;
m_Type.SetWindowText(SearchType);
int i=m_Type.FindString(-1,SearchType);
m_Type.SetCurSel(i);
m_value=SearchType;
UpdateData(false);
g_ID="编号";
g_Name="姓名";
g_Sex="性别";
g_Birthday="出生年月";
g_Card_ID="身份证号码";
g_Edu="文化程度";
g_Policy="政治面貌";
g_Graduate="毕业学校";
g_Address="家庭住址";
//g_Resume="个人简历";
g_Punish="奖励和处分情况";
g_Prefere="特长";
//g_Change="变动情况";
g_Phone="联系电话";
g_Shop="单位";
//g_Photo="照片";
g_Equal="完全匹配";
g_Include="部分匹配";
// TODO: Add extra initialization here
this->Change();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSearch::OnSearch()
{
UpdateData(true);
if(m_val.IsEmpty())
MessageBox("请输入"+SearchType);
else
{
SearchMode=m_combo.GetCurSel();
SearchValue=m_val;
this->OnOK();
}
// TODO: Add your control notification handler code here
}
void CSearch::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
GetClientRect(rect);
dc.FillSolidRect(rect,RGB(245,200,173));
// TODO: Add your message handler code here
// Do not call CDialog::OnPaint() for painting messages
}
HBRUSH CSearch::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
if(pWnd->GetDlgCtrlID()==IDC_STATIC1||pWnd->GetDlgCtrlID()==IDC_Type||pWnd->GetDlgCtrlID()==IDC_Value||pWnd->GetDlgCtrlID()==IDC_STATIC2||pWnd->GetDlgCtrlID()==IDC_STATIC3)
{
static HBRUSH hbrEdit = ::CreateSolidBrush( RGB(245,200,173) );
pDC->SetBkMode ( TRANSPARENT );
return hbrEdit;
}
/*
if ( nCtlColor == CTLCOLOR_STATIC )
{
pDC->SetBkMode ( TRANSPARENT );
}
*/
// TODO: Return a different brush if the default is not desired
return hbr;
}
BOOL CSearch::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN)
if(pMsg->wParam==VK_RETURN)
OnSearch();
return CDialog::PreTranslateMessage(pMsg);
}
void CSearch::OnSelchangeCombo2()
{
int i=m_Type.GetCurSel();
m_Type.GetLBText(i,SearchType);
m_value=SearchType;
UpdateData(false);
this->Change();
}
void CSearch::Change()
{
int num=m_combo.GetCount();
for(int i=0;i<num;i++)
m_combo.DeleteString(0);
if(SearchType==g_ID||SearchType==g_Name||SearchType==g_Card_ID||SearchType==g_Graduate||
SearchType==g_Address||SearchType==g_Punish||SearchType==g_Prefere||SearchType==g_Phone||g_Birthday)
{
m_combo.AddString(g_Equal);
m_combo.AddString(g_Include);
m_combo.SetCurSel(1);
Eq=0;
}
else if(SearchType==g_Sex||SearchType==g_Edu||SearchType==g_Policy)
{
m_combo.AddString(g_Equal);
m_combo.SetCurSel(0);
Eq=1;
}
}
/*
void CSearch::OnButton2()
{
//还原数据库
CString currpath;
currpath.Format("driver={SQL Server};Server=APPLE; DATABASE=Information;");
//"Provider = sqloledb;User Id=sa;password=sa密码;data source=sky;initial catalog=master"
CString cmdText;
cmdText.Format("RESTORE DATABASE [Problems] FROM DISK= 'c:\\problems_backup.dat'");
_ConnectionPtr pConnection;
pConnection.CreateInstance(__uuidof(Connection));
pConnection->ConnectionTimeout = 5; // 设置超时时间为5秒
pConnection->Open(_bstr_t(currpath),
_bstr_t("sa"),
_bstr_t(""),
adModeUnknown);
if(pConnection == NULL)
{
AfxMessageBox("连接数据库时出错!");
return;
}
pConnection->Execute((_bstr_t)cmdText, NULL, adCmdText);
if(pConnection->State)
{
pConnection->Close();
}
AfxMessageBox("还原成功!");
}
catch(_com_error &e)
{
_bstr_t bstrError(e.ErrorMessage());
CString strError;
strError.Format("发生错误:%s",(char*)bstrError);
AfxMessageBox(strError);
}
catch(...)
{
AfxMessageBox("未知错误!");
}
}*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -