⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dsel.cpp

📁 一个有关人事系统的所有代码和有关文件包括里面小量数据库。
💻 CPP
字号:
// DSel.cpp : implementation file
//

#include "stdafx.h"
#include "Rsglxt.h"
#include "DSel.h"
#include "DHoliday.h"
#include "DCont.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDSel dialog


CDSel::CDSel(CWnd* pParent /*=NULL*/)
	: CDialog(CDSel::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDSel)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CDSel::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDSel)
	DDX_Control(pDX, IDC_GRID, m_Grid);
	DDX_Control(pDX, IDC_EDITNAME, m_EdtName);
	DDX_Control(pDX, IDC_EDITID, m_EdtID);
	DDX_Control(pDX, IDC_COMDEP, m_Comdep);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDSel, CDialog)
	//{{AFX_MSG_MAP(CDSel)
	ON_BN_CLICKED(IDC_BUTSEL, OnButsel)
	ON_NOTIFY(NM_DBLCLK, IDC_GRID, OnDblclkDselGrid)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDSel message handlers

BOOL CDSel::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	CString sdep;
	rst.Open("员工查询视图");
    RxRecordset rs,ts;
	rs.Open("部门视图");
    m_Comdep.SetRecordset(rs,"部门名称");
	m_Grid.ReadOnly(true);
	m_Grid.SetDataBase("员工查询视图",adCmdTable);
	CString FieldName;
	ts.Open("select 部门名称 from 部门视图");
	m_Comdep.SetFieldset(ts);
	m_Comdep.SelectString(0,"所有部门");
	this->m_Comdep.m_CurrentFieldType="字符型";
	this->m_EdtName.SetFocus();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDSel::OnButsel() 
{
	// TODO: Add your control notification handler code here
	CString sSQL,sName,sSID,sSdep;
	this->m_EdtName.GetWindowText(sName);
	this->m_EdtID.GetWindowText(sSID);
	this->m_Comdep.GetWindowText(sSdep);
	if(sSdep=="所有部门")
	{
	if(sName.IsEmpty() && sSID.IsEmpty())
			sSQL.Format("SELECT * FROM 员工查询视图");

	    if(!sName.IsEmpty())
		{
			if(sSID.IsEmpty())
			sSQL.Format("SELECT * FROM 员工查询视图 where 姓名 LIKE '%%%s%%'",sName);
			else
				sSQL.Format("SELECT * FROM 员工查询视图 where 编号 LIKE '%%%s%%' OR 姓名 LIKE '%%%s%%'",sSID,sName);
		}
		else
		{
			if(!sSID.IsEmpty())
				sSQL.Format("SELECT * FROM 员工查询视图 where 编号 LIKE '%%%s%%'",sSID);
		}
	}
	
	if(sSdep!="所有部门")
	{
		if(sName.IsEmpty() && sSID.IsEmpty())
			sSQL.Format("SELECT * FROM 员工查询视图 where 部门='%s'",sSdep);
		if(!sName.IsEmpty())
		{
			if(sSID.IsEmpty())
			sSQL.Format("SELECT * FROM 员工查询视图 where 姓名 LIKE '%%%s%%' AND 部门='%s'",sName,sSdep);
			else
				sSQL.Format("SELECT * FROM 员工查询视图 where 编号 LIKE '%%%s%%' OR 姓名 LIKE '%%%s%%' AND 部门='%s'",sSID,sName,sSdep);
		}
		else
		{
			if(!sSID.IsEmpty())
				sSQL.Format("SELECT * FROM 员工查询视图 where 编号 LIKE '%%%s%%' AND 部门='%s'",sSID,sSdep);
		}
	}
	rst.Open(sSQL,adCmdText);
	m_Grid.AddCellValue(rst);
}

void CDSel::OnDblclkDselGrid(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	CString sSql,sID,sname;
	RxRecordset rRst;
	if(m_Grid.GetHotItem()<0)
		return;		
	m_sID=this->m_Grid.GetItemText(m_Grid.GetHotItem(),0);
	sSql.Format("select * from 员工查询视图 where 编号='%s'",m_sID);
	rRst.Open(sSql,adCmdText);

	sID=rRst.GetFieldValue("编号");
	sname=rRst.GetFieldValue("姓名");

	
	*pResult = 0;

}

bool CDSel::Show(CString sCaption,CString sDateBaseName,CDialog *NextWnd)
{
	m_pDlg=NextWnd;
	m_sDataBase=sDateBaseName;
	m_Caption=sCaption;
	return true;

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -