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

📄 modipeople.cpp

📁 人事管理系统.SQL的数据库.所用密码和用户名均是531
💻 CPP
字号:
// MODIPeople.cpp : implementation file
//

#include "stdafx.h"
#include "people2.h"
#include "people.h"
#include "MODIPeople.h"
#include "column.h"
#include "columns.h"
#include "_recordset.h"
#include "Insert.h"
#include "COMDEF.H"
#include "Infor.h"

#include "Main.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// MODIPeople dialog


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


void MODIPeople::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(MODIPeople)
	DDX_Control(pDX, IDC_ADODC1, m_adodc);
	DDX_Control(pDX, IDC_DATAGRID1, m_datagrid);
	DDX_Control(pDX, IDC_ADODC2, m_adodc2);
	DDX_Control(pDX, IDC_DATACOMBO1, m_datacombo);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(MODIPeople, CDialog)
	//{{AFX_MSG_MAP(MODIPeople)
	ON_BN_CLICKED(IDC_Insert_BUTTON1, OnInsertBUTTON1)
	ON_BN_CLICKED(IDC_Update_BUTTON2, OnUpdateBUTTON2)
	ON_BN_CLICKED(IDC_Delete_BUTTON3, OnDeleteBUTTON3)
	ON_BN_CLICKED(IDC_Return_BUTTON4, OnReturnBUTTON4)
	ON_BN_CLICKED(IDC_InformationBUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_select_BUTTON1, OnselectBUTTON1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)

	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// MODIPeople message handlers

BOOL MODIPeople::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here

//m_adodc.SetRecordSource("select 员工编号As 编号,个人密码 As 密码,姓名 As 姓名,性别 As 性别,年龄 As 年龄,所属部门 As 部门,学历 As 学历,职位 As 职位,电话 As 电话,电子邮箱 As E-mail,个人备注 As 备注,部门编号 As 部门编号 from 职工信息");
//m_adodc.SetRecordSource("SELECT 员工编号As 编号,个人密码 As 密码,姓名 As 姓名,性别 As 性别,年龄 As 年龄,所属部门 As 部门,学历 As 学历,职位 As 职位,电话 As 电话FROM 职工信息");

	m_adodc.Refresh();

	_variant_t vIndex;
vIndex=long(0);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(70);
vIndex=long(1);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(70);
vIndex=long(2);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(50);
vIndex=long(3);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(70);
vIndex=long(4);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(70);
vIndex=long(5);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(80); 
vIndex=long(6);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(60);		
vIndex=long(7);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(100);
vIndex=long(8);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(70);
vIndex=long(9);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(140);
vIndex=long(10);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(80);
vIndex=long(11);
m_datagrid.GetColumns().GetItem(vIndex).SetWidth(80);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

BEGIN_EVENTSINK_MAP(MODIPeople, CDialog)
    //{{AFX_EVENTSINK_MAP(MODIPeople)
	ON_EVENT(MODIPeople, IDC_DATAGRID1, -600 /* Click */, OnClickDatagrid1, VTS_NONE)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void MODIPeople::OnClickDatagrid1() 
{
	// TODO: Add your control notification handler code here
	
}

void MODIPeople::OnInsertBUTTON1() 
{
	// TODO: Add your control notification handler code here
    Insert dlg;
	dlg.vNumber="";
	dlg.strSex="男";
	if(dlg.DoModal()==IDOK)
	OnInitDialog();
m_adodc2.Refresh();
		//RefreshData();	
}

void MODIPeople::OnUpdateBUTTON2() 
{
	// TODO: Add your control notification handler code here
	if(m_adodc.GetRecordset().GetEof()==1)
	{
		MessageBox("没有数据");
		return;}
	Insert dlg;

	dlg.m_Number=m_datagrid.GetItem(0);
	dlg.m_Name=m_datagrid.GetItem(2);
	dlg.strSex=m_datagrid.GetItem(3);
	dlg.m_Age=m_datagrid.GetItem(4);
	dlg.m_Department=m_datagrid.GetItem(5);
	dlg.m_Edulevel=m_datagrid.GetItem(6);
	dlg.m_Job=m_datagrid.GetItem(7);
	dlg.m_Phone=m_datagrid.GetItem(8);
	dlg.m_Email=m_datagrid.GetItem(9);
	dlg.m_Remark=m_datagrid.GetItem(10);
	dlg.m_Departnum=m_datagrid.GetItem(11);
	Cpeople emp;
	emp.sql_delete(m_datagrid.GetItem(0));
	if(dlg.DoModal()==IDOK)
	OnInitDialog();
	m_adodc2.Refresh();
}

void MODIPeople::OnDeleteBUTTON3() 
{
	// TODO: Add your control notification handler code here
	if(m_adodc.GetRecordset().GetEof()==1)
	{
		MessageBox("请选择要删除的数据");
		return;
	}
	if(MessageBox(" 是否删除当前记录?","请确认",MB_YESNO)==IDYES)
	{
		Cpeople emp;
		emp.sql_delete(m_datagrid.GetItem(0));
		OnInitDialog();
	}
m_adodc2.Refresh();
}

void MODIPeople::OnReturnBUTTON4() 
{
	// TODO: Add your control notification handler code here
	CDialog::OnCancel();
	MODIPeople a;
    a.DoModal();
}


void MODIPeople::OnButton1() 
{
	// TODO: Add your control notification handler code here
	
if(m_adodc.GetRecordset().GetEof()==1)
{
	MessageBox("没有数据");
	return;
}
	CInfor dlg;
			dlg.DoModal();

}

void MODIPeople::OnselectBUTTON1() 
{
	// TODO: Add your control notification handler code here
	CString vDepId;
	CString vSql ;
	vDepId=m_datacombo.GetBoundText();
	if(vDepId!="")
	{
	  vSql="SELECT * FROM 职工信息 WHERE PDepartnum="+vDepId;
      m_adodc.SetRecordSource(vSql);
	  m_adodc.Refresh();
	}
	if(vDepId=="") MessageBox("请选择部门");
}

void MODIPeople::OnButton2() 
{
	// TODO: Add your control notification handler code here
	CDialog::OnCancel();
}

⌨️ 快捷键说明

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