📄 exam7view.cpp
字号:
// Exam7View.cpp : implementation of the CExam7View class
//
#include "stdafx.h"
#include "Exam7.h"
#include "Exam7Doc.h"
#include "Exam7View.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CExam7View
IMPLEMENT_DYNCREATE(CExam7View, CFormView)
BEGIN_MESSAGE_MAP(CExam7View, CFormView)
//{{AFX_MSG_MAP(CExam7View)
ON_BN_CLICKED(IDC_SEEK, OnSeek)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_BN_CLICKED(IDC_NEXT, OnNext)
ON_BN_CLICKED(IDC_GY, OnGy)
ON_BN_CLICKED(IDC_APPEND, OnAppend)
ON_BN_CLICKED(IDC_PROV, OnProv)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CExam7View construction/destruction
CExam7View::CExam7View()
: CFormView(CExam7View::IDD)
{
//{{AFX_DATA_INIT(CExam7View)
m_CSRQ = _T("");
m_XM = _T("");
m_XW = _T("");
m_XY = _T("");
m_ZY = _T("");
m_MZ = _T("");
m_RXSJ = _T("");
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CExam7View::~CExam7View()
{
}
void CExam7View::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CExam7View)
DDX_Text(pDX, IDC_CSRQ, m_CSRQ);
DDX_Text(pDX, IDC_XM, m_XM);
DDX_Text(pDX, IDC_XW, m_XW);
DDX_Text(pDX, IDC_XY, m_XY);
DDX_Text(pDX, IDC_ZY, m_ZY);
DDX_Text(pDX, IDC_MZ, m_MZ);
DDX_Text(pDX, IDC_RXSJ, m_RXSJ);
//}}AFX_DATA_MAP
}
BOOL CExam7View::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CExam7View::OnInitialUpdate()
{
if(! db1.Open(_T("MyDataBase"),FALSE,FALSE,_T("ODBC;"),FALSE))
{
AfxMessageBox("No DB!");
}
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
/////////////////////////////////////////////////////////////////////////////
// CExam7View printing
BOOL CExam7View::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CExam7View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CExam7View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CExam7View::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add customized printing code here
}
/////////////////////////////////////////////////////////////////////////////
// CExam7View diagnostics
#ifdef _DEBUG
void CExam7View::AssertValid() const
{
CFormView::AssertValid();
}
void CExam7View::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CExam7Doc* CExam7View::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CExam7Doc)));
return (CExam7Doc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CExam7View message handlers
void CExam7View::OnSeek()
{
// TODO: Add your control notification handler code here
CString temp1,temp2;BOOL flag=FALSE;
CRecordset rd1(&db1);
if(! rd1.Open(CRecordset::dynaset, "Select * from XS"))//打开XS数据表
{
AfxMessageBox("查无此人!");
GetDlgItem(IDC_SEEK_NAME)->GetWindowText(temp1);//获取查询依据
if(temp1!=_T("")){
while(!rd1.IsEOF())//从学生表中一一查询
{
rd1.GetFieldValue("XM",temp2);//获取姓名字段值
if(temp2==temp1)//是否找到
{
flag=TRUE; break;}
rd1.MoveNext();
}
if(flag)//如果找到则显示在文本框中
{
rd1.GetFieldValue("XY",m_XY);
m_XM=temp2;
rd1.GetFieldValue("CSRQ",m_CSRQ);
rd1.GetFieldValue("MZ",m_MZ);
rd1.GetFieldValue("RXSJ",m_RXSJ);
rd1.GetFieldValue("ZY",m_ZY);
rd1.GetFieldValue("XW",m_XW);
UpdateData(FALSE);
}
}
rd1.Close();//关闭动态记忆库
}
}
void CExam7View::OnDelete()
{
// TODO: Add your control notification handler code here
CString temp1,temp2="'";
GetDlgItem(IDC_SEEK_NAME)->GetWindowText(temp1);
if(temp1!=_T(""))
{
db1.ExecuteSQL("Delete From XS Where XM="+temp2+temp1+temp2);
}
}
void CExam7View::OnNext()
{
// TODO: Add your control notification handler code here
}
void CExam7View::OnGy()
{
// TODO: Add your control notification handler code here
AfxMessageBox("版权所有 秦玲设计");
}
void CExam7View::OnAppend()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString temp1="','";
CString tempSQL="'"+m_XY+temp1+m_MZ+temp1+m_CSRQ+temp1+m_MZ+temp1+m_RXSJ+temp1+m_ZY+temp1+m_XW+"'";
tempSQL="INSERT INTO XS VALUES("+tempSQL+")";
db1.ExecuteSQL(tempSQL);
}
void CExam7View::OnProv()
{
// TODO: Add your control notification handler code here
!m_rsDataSet.IsBOF())
{
m_rsDataSet.MovePrev();
DisplayRecord();
SetButtonState();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -