学生信息管理系统

源代码在线查看: 学生信息管理系统view.cpp

软件大小: 1995 K
上传用户: billhu
关键词: 信息管理系统
下载地址: 免注册下载 普通下载 VIP

相关代码

				// 学生信息管理系统View.cpp : implementation of the CMyView class
				//
				
				#include "stdafx.h"
				#include "学生信息管理系统.h"
				
				#include "学生信息管理系统Set.h"
				#include "学生信息管理系统Doc.h"
				#include "学生信息管理系统View.h"
				
				#ifdef _DEBUG
				#define new DEBUG_NEW
				#undef THIS_FILE
				static char THIS_FILE[] = __FILE__;
				#endif
				
				/////////////////////////////////////////////////////////////////////////////
				// CMyView
				
				IMPLEMENT_DYNCREATE(CMyView, CRecordView)
				
				BEGIN_MESSAGE_MAP(CMyView, CRecordView)
					//{{AFX_MSG_MAP(CMyView)
					ON_EN_CHANGE(IDC_ID, OnChangeId)
					ON_EN_CHANGE(IDC_NAME, OnChangeName)
					ON_EN_CHANGE(IDC_ADDRESS, OnChangeAddress)
					ON_EN_CHANGE(IDC_TEL, OnChangeTel)
					ON_BN_CLICKED(IDC_BUTTON2, OnUPDATE)
					ON_BN_CLICKED(IDC_BUTTON1, OnADD)
					ON_BN_CLICKED(IDC_BUTTON3, OnDEL)
					//}}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()
				
				/////////////////////////////////////////////////////////////////////////////
				// CMyView construction/destruction
				
				CMyView::CMyView()
					: CRecordView(CMyView::IDD)
				{
					//{{AFX_DATA_INIT(CMyView)
					m_pSet = NULL;
					m_nStudentid = _T("");
					m_nName = _T("");
					m_nAddress = _T("");
					m_nTel = _T("");
					//}}AFX_DATA_INIT
					// TODO: add construction code here
				
				}
				
				CMyView::~CMyView()
				{
				}
				
				void CMyView::DoDataExchange(CDataExchange* pDX)
				{
					CRecordView::DoDataExchange(pDX);
					//{{AFX_DATA_MAP(CMyView)
					DDX_Text(pDX, IDC_ID, m_nStudentid);
					DDX_Text(pDX, IDC_NAME, m_nName);
					DDX_Text(pDX, IDC_ADDRESS, m_nAddress);
					DDX_Text(pDX, IDC_TEL, m_nTel);
					//}}AFX_DATA_MAP
					DDX_FieldText(pDX,IDC_ID,m_pSet->m_studentid,m_pSet);
					DDX_FieldText(pDX,IDC_NAME,m_pSet->m_name,m_pSet);
					DDX_FieldText(pDX,IDC_ADDRESS,m_pSet->m_address,m_pSet);
					DDX_FieldText(pDX,IDC_TEL,m_pSet->m_tel,m_pSet);
				}
				
				BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs)
				{
					// TODO: Modify the Window class or styles here by modifying
					//  the CREATESTRUCT cs
				
					return CRecordView::PreCreateWindow(cs);
				}
				
				void CMyView::OnInitialUpdate()
				{
					m_pSet = &GetDocument()->m_mySet;
					CRecordView::OnInitialUpdate();
					GetParentFrame()->RecalcLayout();
					ResizeParentToFit();
				
				}
				
				/////////////////////////////////////////////////////////////////////////////
				// CMyView printing
				
				BOOL CMyView::OnPreparePrinting(CPrintInfo* pInfo)
				{
					// default preparation
					return DoPreparePrinting(pInfo);
				}
				
				void CMyView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
				{
					// TODO: add extra initialization before printing
				}
				
				void CMyView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
				{
					// TODO: add cleanup after printing
				}
				
				/////////////////////////////////////////////////////////////////////////////
				// CMyView diagnostics
				
				#ifdef _DEBUG
				void CMyView::AssertValid() const
				{
					CRecordView::AssertValid();
				}
				
				void CMyView::Dump(CDumpContext& dc) const
				{
					CRecordView::Dump(dc);
				}
				
				CMyDoc* CMyView::GetDocument() // non-debug version is inline
				{
					ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMyDoc)));
					return (CMyDoc*)m_pDocument;
				}
				#endif //_DEBUG
				
				/////////////////////////////////////////////////////////////////////////////
				// CMyView database support
				CRecordset* CMyView::OnGetRecordset()
				{
					return m_pSet;
				}
				
				
				/////////////////////////////////////////////////////////////////////////////
				// CMyView message handlers
				
				void CMyView::OnRecordFirst()
				{
					m_pSet->MoveFirst();
					UpdateData(false);
				}
				
				void CMyView::OnRecordPrev()
				{
					if(!m_pSet->IsBOF())
					{
						m_pSet->MovePrev();
					}
					UpdateData(false);
				}
				
				void CMyView::OnRecordNext()
				{
					if(!m_pSet->IsEOF())
					{
						m_pSet->MoveNext();
					}
					UpdateData(false);
				}
				
				void CMyView::OnRecordLast()
				{
					m_pSet->MoveLast();
					UpdateData(false);
				}
				
				void CMyView::OnChangeId() 
				{
					// TODO: If this is a RICHEDIT control, the control will not
					// send this notification unless you override the CRecordView::OnInitDialog()
					// function and call CRichEditCtrl().SetEventMask()
					// with the ENM_CHANGE flag ORed into the mask.
					
					// TODO: Add your control notification handler code here
					UpdateData(true);
					
				}
				
				void CMyView::OnChangeName() 
				{
					// TODO: If this is a RICHEDIT control, the control will not
					// send this notification unless you override the CRecordView::OnInitDialog()
					// function and call CRichEditCtrl().SetEventMask()
					// with the ENM_CHANGE flag ORed into the mask.
					
					// TODO: Add your control notification handler code here
					UpdateData(true);
				}
				
				void CMyView::OnChangeAddress() 
				{
					// TODO: If this is a RICHEDIT control, the control will not
					// send this notification unless you override the CRecordView::OnInitDialog()
					// function and call CRichEditCtrl().SetEventMask()
					// with the ENM_CHANGE flag ORed into the mask.
					
					// TODO: Add your control notification handler code here
					UpdateData(true);
					
				}
				
				void CMyView::OnChangeTel() 
				{
					// TODO: If this is a RICHEDIT control, the control will not
					// send this notification unless you override the CRecordView::OnInitDialog()
					// function and call CRichEditCtrl().SetEventMask()
					// with the ENM_CHANGE flag ORed into the mask.
					
					// TODO: Add your control notification handler code here
					UpdateData(true);
					
				}
				
				
				void CMyView::OnADD() 
				{
					// TODO: Add your control notification handler code here
					if(!m_pSet->CanAppend())
					{
						return ;
					}
					m_pSet->AddNew();
					m_pSet->m_studentid=m_nStudentid;
					m_pSet->m_name=m_nName;
					m_pSet->m_address=m_nAddress;
					m_pSet->m_tel=m_nTel;
					if(!m_pSet->Update())
					{
						AfxMessageBox("添加记录失败");
					}
					UpdateData(false);
					
				}
				
				void CMyView::OnUPDATE() 
				{
					// TODO: Add your control notification handler code here
					if(!m_pSet->CanUpdate())
					{
						return ;
					}
					m_pSet->Edit();
					m_pSet->m_studentid=m_nStudentid;
					m_pSet->m_name=m_nName;
					m_pSet->m_address=m_nAddress;
					m_pSet->m_tel=m_nTel;
						if(!m_pSet->Update())
					{
						AfxMessageBox("修改记录失败");
					}
						UpdateData(false);
				
				}
				
				void CMyView::OnDEL() 
				{
					// TODO: Add your control notification handler code here
					m_pSet->Delete();
					m_pSet->MoveNext();
					if(m_pSet->IsEOF())
						m_pSet->MoveLast();
					UpdateData(false);
				}
							

相关资源