gongzhi.cpp

来自「员工管理系统,基本的数据库操作,数据库类的设计,基本的查询等」· C++ 代码 · 共 137 行

CPP
137
字号
// Gongzhi.cpp : implementation file
//

#include "stdafx.h"
#include "数据库.h"
#include "Gongzhi.h"
#include "column.h"
#include "columns.h"
#include "COMDEF.H"
#include "Addgongzhi.h"
#include "Modygongzhi.h"
#include "ADOConn.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CGongzhi dialog


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


void CGongzhi::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CGongzhi)
	DDX_Control(pDX, IDC_DATAGRID1, m_datagridg);
	DDX_Control(pDX, IDC_ADODC1, m_adodcg);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CGongzhi, CDialog)
	//{{AFX_MSG_MAP(CGongzhi)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGongzhi message handlers

void CGongzhi::RefreshData()
{

	m_adodcg.SetRecordSource("select * from 工资表");
	m_adodcg.Refresh();
	_variant_t vindex;
	vindex=long(0);
	m_datagridg.GetColumns().GetItem(vindex).SetWidth(55);
	vindex=long(1);
	m_datagridg.GetColumns().GetItem(vindex).SetWidth(40);

	vindex=long(2);
	m_datagridg.GetColumns().GetItem(vindex).SetWidth(60);
    vindex=long(3);
	m_datagridg.GetColumns().GetItem(vindex).SetWidth(45);
	vindex=long(4);
	m_datagridg.GetColumns().GetItem(vindex).SetWidth(45);
	vindex=long(5);
	m_datagridg.GetColumns().GetItem(vindex).SetWidth(60);
}

BOOL CGongzhi::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	RefreshData();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CGongzhi::OnButton1() 
{
	// TODO: Add your control notification handler code here
	CAddgongzhi dlg;
	if(dlg.DoModal()==IDOK)
	  RefreshData();
	else
		return;

	
}

void CGongzhi::OnButton2() 
{
	// TODO: Add your control notification handler code here
	CModygongzhi dlg;
    dlg.m_name=m_datagridg.GetItem(0);
	dlg.m_month=(int)atof(m_datagridg.GetItem(1));
	dlg.m_jiben=(int)atof(m_datagridg.GetItem(2));
	dlg.m_jiang=(int)atof(m_datagridg.GetItem(3));
    dlg.m_fa=(int)atof(m_datagridg.GetItem(4));
    dlg.m_id=(int)atof(m_datagridg.GetItem(6));
    
	if(dlg.DoModal()==IDOK)
		RefreshData();
}

void CGongzhi::OnButton3() 
{
	// TODO: Add your control notification handler code here
	ADOConn m_Adoconn;
	m_Adoconn.OnInitADOConn();
	CString sql;
	CString nname;
	int month;
	nname=m_datagridg.GetItem(0);
	month=(int)atof(m_datagridg.GetItem(1));
    sql.Format("delete from 工资表 where 姓名=\'%s\' and 月份=%d",nname,month);
	_bstr_t vsql;
	vsql=(_bstr_t)sql;
	
	
	m_Adoconn.ExecuteSQL(vsql);
	m_Adoconn.ExitConnect();
	RefreshData();
}

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

⌨️ 快捷键说明

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