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

📄 vcsqlview.cpp

📁 学生成绩管理程序
💻 CPP
字号:
// VCSQLView.cpp : implementation of the CVCSQLView class
//

#include "stdafx.h"
#include "VCSQL.h"

#include "VCSQLSet.h"
#include "VCSQLDoc.h"
#include "VCSQLView.h"

#include "StuaddDlg.h"
#include "haxunDlg.h"
#include "PaixuDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CVCSQLView

IMPLEMENT_DYNCREATE(CVCSQLView, CRecordView)

BEGIN_MESSAGE_MAP(CVCSQLView, CRecordView)
	//{{AFX_MSG_MAP(CVCSQLView)
	ON_BN_CLICKED(IDC_ADD, OnAdd)
	ON_BN_CLICKED(IDC_DELETE, OnDelete)
	ON_BN_CLICKED(IDC_MODEFY, OnModefy)
	ON_BN_CLICKED(IDC_FEIDULIADD, OnFeiduliadd)
	ON_BN_CLICKED(IDC_CHAXUN, OnChaxun)
	ON_BN_CLICKED(IDC_PAIXU, OnPaixu)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CRecordView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CRecordView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CVCSQLView construction/destruction

CVCSQLView::CVCSQLView()
	: CRecordView(CVCSQLView::IDD)
{
	m_adding=false;
	//{{AFX_DATA_INIT(CVCSQLView)
	m_pSet = NULL;
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CVCSQLView::~CVCSQLView()
{
}

void CVCSQLView::DoDataExchange(CDataExchange* pDX)
{
	CRecordView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CVCSQLView)
	DDX_FieldText(pDX, IDC_AGES, m_pSet->m_ages, m_pSet);
	DDX_FieldText(pDX, IDC_CAOZUOXITONG, m_pSet->m_caozuoxitong, m_pSet);
	DDX_FieldText(pDX, IDC_COMEFROM, m_pSet->m_comefrom, m_pSet);
	DDX_FieldText(pDX, IDC_ENG, m_pSet->m_eng, m_pSet);
	DDX_FieldText(pDX, IDC_GAODAI, m_pSet->m_gaodai, m_pSet);
	DDX_FieldText(pDX, IDC_JOB, m_pSet->m_job, m_pSet);
	DDX_FieldText(pDX, IDC_NAME, m_pSet->m_name, m_pSet);
	DDX_FieldText(pDX, IDC_SEX, m_pSet->m_sex, m_pSet);
	DDX_FieldText(pDX, IDC_SHUJUJIEGOU, m_pSet->m_shujujiegou, m_pSet);
	DDX_FieldText(pDX, IDC_TELPHONE, m_pSet->m_telphone, m_pSet);
	DDX_FieldText(pDX, IDC_XINGGE, m_pSet->m_xingge, m_pSet);
	DDX_FieldText(pDX, IDC_ZHENGZHI, m_pSet->m_zhengzhi, m_pSet);
	DDX_FieldText(pDX, IDC_COMPUTER, m_pSet->m_computer, m_pSet);
	DDX_FieldText(pDX, IDC_WAIYU, m_pSet->m_waiyu, m_pSet);
	DDX_FieldText(pDX, IDC_XIANDAI, m_pSet->m_xingdai, m_pSet);
	//}}AFX_DATA_MAP
}

BOOL CVCSQLView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CRecordView::PreCreateWindow(cs);
}

void CVCSQLView::OnInitialUpdate()
{
	m_pSet = &GetDocument()->m_vCSQLSet;
	CRecordView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

}

/////////////////////////////////////////////////////////////////////////////
// CVCSQLView printing

BOOL CVCSQLView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CVCSQLView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CVCSQLView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CVCSQLView diagnostics

#ifdef _DEBUG
void CVCSQLView::AssertValid() const
{
	CRecordView::AssertValid();
}

void CVCSQLView::Dump(CDumpContext& dc) const
{
	CRecordView::Dump(dc);
}

CVCSQLDoc* CVCSQLView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CVCSQLDoc)));
	return (CVCSQLDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CVCSQLView database support
CRecordset* CVCSQLView::OnGetRecordset()
{
	return m_pSet;
}


/////////////////////////////////////////////////////////////////////////////
// CVCSQLView message handlers

void CVCSQLView::OnAdd() 
{
	UpdateData();
	StuaddDlg dlg;
	if(dlg.DoModal()==IDOK)
	{
		m_pSet->AddNew();
        m_pSet->m_name=dlg.m_stuname;
		m_pSet->m_sex=dlg.m_stusex;
	    m_pSet->m_comefrom=dlg.m_stucomefrom;
		m_pSet->m_ages=dlg.m_stuages;
		m_pSet->m_xingge=dlg.m_stuxingge;
		m_pSet->m_waiyu=dlg.m_stuwaiyu;
		m_pSet->m_computer=dlg.m_stucomputer;
		m_pSet->m_job=dlg.m_stujob;
		m_pSet->m_telphone=dlg.m_stutelphone;
		m_pSet->m_gaodai=dlg.m_stugaodai;
		m_pSet->m_xingdai=dlg.m_stuxiandai;
		m_pSet->m_eng=dlg.m_stueng;
		m_pSet->m_shujujiegou=dlg.m_stushujujiegou;
		m_pSet->m_caozuoxitong=dlg.m_stucaozuoxitong;
		m_pSet->m_zhengzhi=dlg.m_stuzhengzhi;
	    
		m_pSet->Update();
		m_pSet->Requery();
		m_pSet->MoveLast();
	}
	UpdateData(false);
	// TODO: Add your control notification handler code here
	
}

void CVCSQLView::OnDelete() 
{
	CRecordsetStatus status;
	m_pSet->GetStatus(status);
	m_pSet->Delete();
	if(status.m_lCurrentRecord==0)
	{
		m_pSet->MoveNext();
	}
	else
	{
		m_pSet->MoveFirst();
	}
	UpdateData(FALSE);
	// TODO: Add your control notification handler code here
	
}



void CVCSQLView::OnModefy() 
{
	    StuaddDlg dlg;
	    dlg.m_stuname=m_pSet->m_name;
	    dlg.m_stusex=m_pSet->m_sex;
	    dlg.m_stucomefrom=m_pSet->m_comefrom;
		dlg.m_stuages=m_pSet->m_ages;
		dlg.m_stuxingge=m_pSet->m_xingge;
		dlg.m_stuwaiyu=m_pSet->m_waiyu;
		dlg.m_stucomputer=m_pSet->m_computer;
		dlg.m_stujob=m_pSet->m_job;
		dlg.m_stutelphone=m_pSet->m_telphone;
		dlg.m_stugaodai=m_pSet->m_gaodai;
		dlg.m_stuxiandai=m_pSet->m_xingdai;
		dlg.m_stueng=m_pSet->m_eng;
		dlg.m_stushujujiegou=m_pSet->m_shujujiegou;
		dlg.m_stucaozuoxitong=m_pSet->m_caozuoxitong;
		dlg.m_stuzhengzhi=m_pSet->m_zhengzhi;
		if(dlg.DoModal()==IDOK)
		{
			UpdateData();
			m_pSet->Edit();
            m_pSet->m_name=dlg.m_stuname;
		    m_pSet->m_sex=dlg.m_stusex;
	        m_pSet->m_comefrom=dlg.m_stucomefrom;
		    m_pSet->m_ages=dlg.m_stuages;
		    m_pSet->m_xingge=dlg.m_stuxingge;
		    m_pSet->m_waiyu=dlg.m_stuwaiyu;
	    	m_pSet->m_computer=dlg.m_stucomputer;
	    	m_pSet->m_job=dlg.m_stujob;
		    m_pSet->m_telphone=dlg.m_stutelphone;
	    	m_pSet->m_gaodai=dlg.m_stugaodai;
		    m_pSet->m_xingdai=dlg.m_stuxiandai;
		    m_pSet->m_eng=dlg.m_stueng;
		    m_pSet->m_shujujiegou=dlg.m_stushujujiegou;
		    m_pSet->m_caozuoxitong=dlg.m_stucaozuoxitong;
			m_pSet->m_zhengzhi=dlg.m_stuzhengzhi;
			m_pSet->Update();
			m_pSet->Requery();
			UpdateData(FALSE);
		}
	// TODO: Add your control notification handler code here
	
}


void CVCSQLView::OnFeiduliadd() 
{
	m_pSet->AddNew();
	m_adding=true;
	CEdit *pedit=(CEdit *)GetDlgItem(IDC_NAME);
	pedit->SetReadOnly(false);
    UpdateData(false);

	// TODO: Add your control notification handler code here
	
}



BOOL CVCSQLView::OnMove(UINT nIDMoveCommand) 
{
if(m_adding)
	{
		m_adding=false;
		UpdateData(true);
		if(m_pSet->CanUpdate())
			m_pSet->Update();
		m_pSet->Requery();
		UpdateData(false);
		CEdit *pedit=(CEdit *)GetDlgItem(IDC_NAME);
		pedit->SetReadOnly(true);
		return true;
	}	
	return CRecordView::OnMove(nIDMoveCommand);
}

void CVCSQLView::OnChaxun() 
{

	ChaxunDlg dlg;
	CString str;
	if(dlg.DoModal()==IDOK)
	{
		str="姓名=+'"+dlg.m_query+"'";
		m_pSet->m_strFilter=str;
		m_pSet->Requery();
		UpdateData(false);
	}
}

void CVCSQLView::OnPaixu() 
{
	PaixuDlg dlg;
	CString str;
	if(dlg.DoModal()==IDOK)
	{
		str=dlg.temp;
		m_pSet->m_strSort=str;
		m_pSet->Requery();
		UpdateData(false);
	}
}

⌨️ 快捷键说明

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