📄 renyuan.cpp
字号:
// RenYuan.cpp : implementation file
//
#include "stdafx.h"
#include "横店集团保卫人员管理系统.h"
#include "RenYuan.h"
#include "DetailInfor.h"
#include "search.h"
#include "editpas.h"
#include "add.h"
#include "shop.h"
#include "addname.h"
#include "deletename.h"
#include "server.h"
#include "server1.h"
#include "addcompany.h"
#include "about.h"
#include "retiredworker.h"
#include "retiredworker1.h"
#include "retiretype.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CString SearchType;
extern int Index;
extern int SearchMode;
extern CString SearchValue;
extern int Eq;
extern int RetireType;
extern CString Server;
/////////////////////////////////////////////////////////////////////////////
// CRenYuan dialog
CRenYuan::CRenYuan(CWnd* pParent /*=NULL*/)
: CDialog(CRenYuan::IDD, pParent)
{
//{{AFX_DATA_INIT(CRenYuan)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CRenYuan::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CRenYuan)
DDX_Control(pDX, IDC_TREE1, m_tree);
DDX_Control(pDX, IDC_COMBO1, m_type);
DDX_Control(pDX, IDC_LIST2, m_result);
DDX_Control(pDX, IDC_LIST1, m_all);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CRenYuan, CDialog)
//{{AFX_MSG_MAP(CRenYuan)
ON_COMMAND(ID_quit, Onquit)
ON_NOTIFY(NM_RCLICK, IDC_LIST1, OnRclickList1)
ON_COMMAND(ID_Search, OnSearch)
ON_COMMAND(ID_Add, OnAdd)
ON_COMMAND(ID_Edit, OnEdit)
ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
ON_COMMAND(ID_Detail, OnDetail)
ON_BN_CLICKED(IDC_BUTTON1, OnFresh)
ON_WM_TIMER()
ON_NOTIFY(NM_RCLICK, IDC_LIST2, OnRclickList2)
ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)
ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
ON_COMMAND(ID_ToolbarAdd, OnToolbarAdd)
ON_COMMAND(ID_ToolbarDel, OnToolbarDel)
ON_COMMAND(ID_ToolbarEdit, OnToolbarEdit)
ON_COMMAND(ID_ToolbarInfor, OnToolbarInfor)
ON_COMMAND(ID_ToolbarSearch, OnToolbarSearch)
ON_WM_MOUSEMOVE()
ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnSelchangedTree1)
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, OnDblclkList1)
ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnDblclkList2)
ON_COMMAND(ID_RAdd, OnRAdd)
ON_COMMAND(ID_RSearch, OnRSearch)
ON_COMMAND(ID_Show, OnShow)
ON_COMMAND(ID_ABOUT, OnAbout)
ON_COMMAND(ID_Delete, OnDelete)
ON_COMMAND(ID_DataBackup, OnDataBackup)
ON_COMMAND(ID_DataRecover, OnDataRecover)
ON_COMMAND(ID_ADDCOMPANY, OnAddcompany)
ON_COMMAND(ID_EDITPAS, OnEditpas)
ON_COMMAND(ID_DELETEMAN, OnDeleteman)
ON_COMMAND(ID_ADDMAN, OnAddman)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
UINT ThreadOne(LPVOID lpvoid)
{
CRenYuan *ren=(CRenYuan*)lpvoid;
if(SearchMode!=-1)
{
ren->Result_m_result();
SearchMode=-1;
return true;
}
//ThreadOne(ren);
return false;
}
/////////////////////////////////////////////////////////////////////////////
// CRenYuan message handlers
BOOL CRenYuan::OnInitDialog()
{
CDialog::OnInitDialog();
this->Important=1;
/*
pSub[0] = GetDlgItem(ID_ToolbarEdit);
pSub[1] = GetDlgItem(ID_ToolbarDel);
pSub[2] = GetDlgItem(ID_ToolbarInfor);
pSub[3] = GetDlgItem(ID_ToolbarAdd);
pSub[4] = GetDlgItem(ID_ToolbarSearch);
m_tip[0].Create(pSub[0],TTS_ALWAYSTIP);
m_tip[0].AddTool(pSub[0]);
m_tip[1].Create(pSub[1],TTS_ALWAYSTIP);
m_tip[1].AddTool(pSub[1]);
m_tip[2].Create(pSub[2],TTS_ALWAYSTIP);
m_tip[2].AddTool(pSub[2]);
m_tip[3].Create(pSub[3],TTS_ALWAYSTIP);
m_tip[3].AddTool(pSub[3]);
m_tip[4].Create(pSub[4],TTS_ALWAYSTIP);
m_tip[4].AddTool(pSub[4]);
m_tip[0].SetTipTextColor(RGB(0,0,255));m_tip[0].SetDelayTime(150);
m_tip[1].SetTipTextColor(RGB(0,0,255));m_tip[1].SetDelayTime(150);
m_tip[2].SetTipTextColor(RGB(0,0,255));m_tip[2].SetDelayTime(150);
m_tip[3].SetTipTextColor(RGB(0,0,255));m_tip[3].SetDelayTime(150);
m_tip[4].SetTipTextColor(RGB(0,0,255));m_tip[4].SetDelayTime(150);
*/
m_tree.SetTextColor(RGB(139,175,59));
HTREEITEM re=m_tree.InsertItem("选择单位");
m_tree.SetCheck(re,true);
CShop shop;
shop.Open();
while (!shop.IsEOF())
{
m_tree.InsertItem(shop.m_column1,re);
shop.MoveNext();
}
shop.Close();
m_tree.SetItemState(re/*选中的节点*/,TVIS_EXPANDED |TVIS_SELECTED ,TVIS_SELECTED);
m_tree.InsertItem("全部单位");
this->SetWindowText("横店集团保卫处管理信息系统");
if(!(m_wndtoolbar.Create(this)&&m_wndtoolbar.LoadToolBar(IDR_TOOLBAR2)))
{
TRACE0("failed to create toolbar\n");
return FALSE;
}
/*
if (!m_wndtoolbar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndtoolbar.LoadToolBar(IDR_TOOLBAR2))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndtoolbar.CreateEx( this,TBSTYLE_FLAT , WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS,
CRect(4,4,0,0)) || !m_wndtoolbar.LoadToolBar(IDR_TOOLBAR2) )
{
TRACE0("failed to create toolbar\n");
return FALSE;
}*/
m_wndtoolbar.ShowWindow(SW_SHOW);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
m_wndtoolbar.MoveWindow(190,0,240,60,true);
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="照片";
SearchType=g_ID;
// TODO: Add extra initialization here
this->ShowWindow(SW_SHOWMAXIMIZED);
//m_all.SetTextColor(RGB(255,0,0));
m_all.SetBkColor(RGB(208,249,255));
m_all.SetTextBkColor(RGB(208,249,255));
m_all.InsertColumn(0,g_ID,LVCFMT_LEFT,100);
m_all.InsertColumn(1,g_Name,LVCFMT_LEFT,100);
m_all.InsertColumn(2,g_Sex,LVCFMT_LEFT,80);
m_all.InsertColumn(3,g_Birthday,LVCFMT_LEFT,150);
m_all.InsertColumn(4,g_Card_ID,LVCFMT_LEFT,150);
m_all.InsertColumn(5,g_Phone,LVCFMT_LEFT,150);
m_all.InsertColumn(6,g_Shop,LVCFMT_LEFT,100);
m_result.SetBkColor(RGB(208,249,255));
m_result.SetTextBkColor(RGB(208,249,255));
m_result.InsertColumn(0,g_ID,LVCFMT_LEFT,100);
m_result.InsertColumn(1,g_Name,LVCFMT_LEFT,100);
m_result.InsertColumn(2,g_Sex,LVCFMT_LEFT,80);
m_result.InsertColumn(3,g_Birthday,LVCFMT_LEFT,150);
m_result.InsertColumn(4,g_Card_ID,LVCFMT_LEFT,150);
m_result.InsertColumn(5,g_Phone,LVCFMT_LEFT,150);
m_result.InsertColumn(6,g_Shop,LVCFMT_LEFT,100);
m_all.SetExtendedStyle(m_all.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
ListView_SetExtendedListViewStyle(m_all.m_hWnd,LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_FLATSB|LVS_EX_HEADERDRAGDROP );
m_result.SetExtendedStyle(m_result.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
ListView_SetExtendedListViewStyle(m_result.m_hWnd,LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_FLATSB|LVS_EX_HEADERDRAGDROP );
this->Init_m_all();
SetTimer(1,100,NULL);
this->tool_enable=false;
//pThread=AfxBeginThread(ThreadOne,this);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CRenYuan::Onquit()
{
this->OnOK();
// TODO: Add your command handler code here
}
void CRenYuan::Init_m_all()
{
m_all.DeleteAllItems();
CDetailInfor detail;
detail.Open();
int i=0;
while(!detail.IsEOF())
{
m_all.InsertItem(i,NULL);
m_all.SetItemText(i,0,detail.m_ID);
m_all.SetItemText(i,1,detail.m_Name);
m_all.SetItemText(i,2,detail.m_Sex);
m_all.SetItemText(i,3,detail.m_Birthday);
m_all.SetItemText(i,4,detail.m_Card_ID);
m_all.SetItemText(i,5,detail.m_Phone);
m_all.SetItemText(i,6,detail.m_Shop);
detail.MoveNext();
i++;
}
detail.Close();
}
void CRenYuan::Result_m_result()
{
m_result.DeleteAllItems();
CDetailInfor detail;
if(Eq==1)
{
if(this->itemText=="全部单位"||this->itemText.IsEmpty())
detail.m_strFilter.Format("%s='%s'",SearchType,SearchValue);
else
detail.m_strFilter.Format("%s='%s'and %s='%s'",SearchType,SearchValue,g_Shop,itemText);
}
else
{
if(SearchMode==0)
{
if(this->itemText=="全部单位"||this->itemText.IsEmpty())
detail.m_strFilter.Format("%s like '%%%s%%'",SearchType,SearchValue);
else
detail.m_strFilter.Format("%s like '%%%s%%'and %s='%s'",SearchType,SearchValue,g_Shop,itemText);
}
else if(SearchMode==1)
{
if(this->itemText=="全部单位"||this->itemText.IsEmpty())
detail.m_strFilter.Format("%s='%s'",SearchType,SearchValue);
else
detail.m_strFilter.Format("%s='%s'and %s='%s'",SearchType,SearchValue,g_Shop,itemText);
}
else
{
}
}
detail.Open();
if(detail.IsEOF())
{
this->Important=0;
MessageBox("没有找到想符合的纪录");
this->Important=1;
}
else
{
int i=0;
while(!detail.IsEOF())
{
m_result.InsertItem(i,NULL);
m_result.SetItemText(i,0,detail.m_ID);
m_result.SetItemText(i,1,detail.m_Name);
m_result.SetItemText(i,2,detail.m_Sex);
m_result.SetItemText(i,3,detail.m_Birthday);
m_result.SetItemText(i,4,detail.m_Card_ID);
m_result.SetItemText(i,5,detail.m_Phone);
m_result.SetItemText(i,6,detail.m_Shop);
detail.MoveNext();
i++;
}
}
detail.Close();
SearchType="";
SearchValue="";
SearchMode=-1;
}
void CRenYuan::OnRclickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
char str[256];
LVCOLUMN col;
col.fmt = LVIF_TEXT;
col.cchTextMax = 256;
col.pszText = str;
if (! m_all.GetColumn(pNMListView->iSubItem, &col))
return;
SearchType=col.pszText;
SearchType.TrimRight("");
POSITION pos;
pos=m_all.GetFirstSelectedItemPosition();
Position=m_all.GetNextSelectedItem(pos);
r_ID=m_all.GetItemText(Position,0);
SearchValue=r_ID;
POINT point;
GetCursorPos(&point);
ScreenToClient(&point);
CMenu menu;
menu.LoadMenu(IDR_Detail);
CMenu *me=menu.GetSubMenu(0);
me->EnableMenuItem(ID_Search,MF_GRAYED|MF_DISABLED);
if(SearchValue.IsEmpty())
{
this->tool_enable=false;
me->EnableMenuItem(ID_Delelte,MF_GRAYED|MF_DISABLED);
me->EnableMenuItem(ID_Edit,MF_GRAYED|MF_DISABLED);
me->EnableMenuItem(ID_Detail,MF_GRAYED|MF_DISABLED);
}
me->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this);
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -