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

📄 txlview.cpp

📁 通讯录软件
💻 CPP
字号:
// TXLView.cpp : implementation of the CTXLView class
//

#include "stdafx.h"
#include "TXL.h"

#include "TXLSet.h"
#include "TXLDoc.h"
#include "TXLView.h"
#include "ADDDLG.h"
#include "browdlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTXLView

IMPLEMENT_DYNCREATE(CTXLView, CDaoRecordView)

BEGIN_MESSAGE_MAP(CTXLView, CDaoRecordView)
	//{{AFX_MSG_MAP(CTXLView)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON8, OnButton8)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
	ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
	ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
	ON_BN_CLICKED(IDC_BUTTON9, OnButton9)
	ON_BN_CLICKED(IDC_BUTTON10, OnButton10)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CDaoRecordView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CDaoRecordView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CDaoRecordView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTXLView construction/destruction

CTXLView::CTXLView()
	: CDaoRecordView(CTXLView::IDD)
{
	//{{AFX_DATA_INIT(CTXLView)
	m_pSet = NULL;
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CTXLView::~CTXLView()
{
}

void CTXLView::DoDataExchange(CDataExchange* pDX)
{
	CDaoRecordView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTXLView)
	DDX_Control(pDX, IDC_BUTTON4, m_prev);
	DDX_Control(pDX, IDC_BUTTON7, m_last);
	DDX_Control(pDX, IDC_BUTTON6, m_first);
	DDX_Control(pDX, IDC_BUTTON5, m_next);
	DDX_FieldText(pDX, IDC_EDIT1, m_pSet->m_name, m_pSet);
	DDX_FieldText(pDX, IDC_EDIT2, m_pSet->m_phone, m_pSet);
	DDX_FieldText(pDX, IDC_EDIT3, m_pSet->m_qq, m_pSet);
	DDX_FieldText(pDX, IDC_EDIT4, m_pSet->m_address, m_pSet);
	DDX_FieldText(pDX, IDC_EDIT5, m_pSet->m_other, m_pSet);
	//}}AFX_DATA_MAP
}

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

	return CDaoRecordView::PreCreateWindow(cs);
}

void CTXLView::OnInitialUpdate()
{
	m_pSet = &GetDocument()->m_tXLSet;
	CDaoRecordView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

}

/////////////////////////////////////////////////////////////////////////////
// CTXLView printing

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

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

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

/////////////////////////////////////////////////////////////////////////////
// CTXLView diagnostics

#ifdef _DEBUG
void CTXLView::AssertValid() const
{
	CDaoRecordView::AssertValid();
}

void CTXLView::Dump(CDumpContext& dc) const
{
	CDaoRecordView::Dump(dc);
}

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

/////////////////////////////////////////////////////////////////////////////
// CTXLView database support
CDaoRecordset* CTXLView::OnGetRecordset()
{
	return m_pSet;
}


/////////////////////////////////////////////////////////////////////////////
// CTXLView message handlers

void CTXLView::OnButton1() 
{
	CADDDLG dlg;
	if (dlg.DoModal()==IDOK);
	{	
 	m_pSet->AddNew();
	m_pSet->m_name=dlg.m_name;
	m_pSet->m_phone=dlg.m_phone;
	m_pSet->m_qq=dlg.m_qq;
	m_pSet->m_address=dlg.m_address;
	m_pSet->m_other=dlg.m_other;
	m_pSet->Update();
	m_pSet->MoveLast();
	UpdateData(FALSE);
	}
}

void CTXLView::OnButton2() 
{
	CADDDLG dlg;
    dlg.m_name=m_pSet->m_name;
	dlg.m_phone=m_pSet->m_phone;
	dlg.m_qq=m_pSet->m_qq;
	dlg.m_address=m_pSet->m_address;
	dlg.m_other=m_pSet->m_other;
	if (dlg.DoModal()==IDOK);
	{	
 	m_pSet->Edit();
	m_pSet->m_name=dlg.m_name;
	m_pSet->m_phone=dlg.m_phone;
	m_pSet->m_qq=dlg.m_qq;
	m_pSet->m_address=dlg.m_address;
	m_pSet->m_other=dlg.m_other;
	m_pSet->Update();
	UpdateData(FALSE);
	}
	
}

void CTXLView::OnButton3() 
{
	CADDDLG dlg;
   int   result=dlg.DoModal();   
      if   (result==IDOK)   
  {   
 //	CString str=col+"="""+dlg.m_name+"";
	          m_pSet->Close();   
   //       m_pSet->m_strFilter=str;   
          m_pSet->Open();   
        //  int   recCount=m_pSet->GetRecordcount();   
         // if   (recCount==0)   
      {   
              MessageBox("无符合的数据。");   
              m_pSet->Close();   
      //        m_pSet->m_strFilter="";   
         //     m_pSet->Open();   
      }   


      UpdateData(FALSE);   
  }   

}

void CTXLView::OnButton8() 
{
int a=AfxMessageBox(( "是否确认删除?" ),MB_YESNOCANCEL|MB_ICONQUESTION);
if (a==6) 
{
m_pSet->Delete();
m_pSet->Requery();
UpdateData(FALSE);	
}
	
}

void CTXLView::OnButton4() 
{
  m_pSet->MovePrev();   
  this->m_last.EnableWindow(true);   
  this->m_next.EnableWindow(true);   
  if(m_pSet->IsBOF())   
  {   
  this->m_first.EnableWindow(false);   
  this->m_prev.EnableWindow(false);   
  m_pSet->MoveNext();   
  }    
  UpdateData(false); 	
}

void CTXLView::OnButton5() 
{
  m_pSet->MoveNext();   
  m_first.EnableWindow(true);   
  m_prev.EnableWindow(true);   
  if(m_pSet->IsEOF())   
  {   
  m_last.EnableWindow(false);   
  m_next.EnableWindow(false);   
  m_pSet->MovePrev();   
  }     
  UpdateData(false);
}
void CTXLView::OnButton6() 
{
  m_pSet->MoveFirst();   
  this->m_first.EnableWindow(false);   
  this->m_prev.EnableWindow(false);   
  this->m_last.EnableWindow(true);   
  this->m_next.EnableWindow(true);      
  UpdateData(false); 	
}

void CTXLView::OnButton7() 
{
  m_pSet->MoveLast();   
  this->m_first.EnableWindow(true);   
  this->m_prev.EnableWindow(true);   
  this->m_last.EnableWindow(false);   
  this->m_next.EnableWindow(false);      
  UpdateData(false); 	
}

void CTXLView::OnButton9() 
{
		m_pSet->Close();
		m_pSet->m_strSort="name";
		m_pSet->Open();
 		UpdateData(FALSE);			
}

void CTXLView::OnButton10() 
{
Cbrowdlg dlg;
dlg.DoModal();
}

⌨️ 快捷键说明

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