📄 personinfoview.cpp
字号:
// PersoninfoView.cpp : implementation file
//
#include "stdafx.h"
#include "ADDRESS.h"
#include "PersoninfoView.h"
#include "ADDRESSDoc.h"
#include "Address_list.H"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPersoninfoView
IMPLEMENT_DYNCREATE(CPersoninfoView, CFormView)
CPersoninfoView::CPersoninfoView()
: CFormView(CPersoninfoView::IDD)
{
//{{AFX_DATA_INIT(CPersoninfoView)
m_Name = _T("");
m_Mobilnumber = _T("");
m_Hometel = _T("");
m_Email = _T("");
m_Companytel = _T("");
m_Company = _T("");
m_Address = _T("");
m_Qqnumber = _T("");
m_Group = _T("");
//}}AFX_DATA_INIT
}
CPersoninfoView::~CPersoninfoView()
{
}
void CPersoninfoView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPersoninfoView)
DDX_Text(pDX, IDC_EDIT_name, m_Name);
DDX_Text(pDX, IDC_EDIT_mobil, m_Mobilnumber);
DDX_Text(pDX, IDC_EDIT_hometel, m_Hometel);
DDX_Text(pDX, IDC_EDIT_email, m_Email);
DDX_Text(pDX, IDC_EDIT_companytel, m_Companytel);
DDX_Text(pDX, IDC_EDIT_company, m_Company);
DDX_Text(pDX, IDC_EDIT_address, m_Address);
DDX_Text(pDX, IDC_EDIT_qq, m_Qqnumber);
DDX_Text(pDX, IDC_EDIT_GROUP, m_Group);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPersoninfoView, CFormView)
//{{AFX_MSG_MAP(CPersoninfoView)
ON_BN_CLICKED(IDC_CHANGE, OnChange)
ON_BN_CLICKED(IDC_OK, OnOk)
ON_BN_CLICKED(IDC_Cacel, OnCacel)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPersoninfoView diagnostics
#ifdef _DEBUG
void CPersoninfoView::AssertValid() const
{
CFormView::AssertValid();
}
void CPersoninfoView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPersoninfoView message handlers
void CPersoninfoView::UpdatePersonInfo(CString strGroupName, CString PersonName)
{
//查询
CString strSql;
strSql.Format("select * from addresslist where groups = '%s' and name = '%s'",\
strGroupName,PersonName);
CADDRESSDoc* pDoc = (CADDRESSDoc*)GetDocument();
CCommand<CAccessor<CAddress_listAccessor> > dbaddresslist;
long* pCount = new long;
if(dbaddresslist.Open(pDoc->m_dbaddresslist.m_session,strSql,NULL,pCount) != S_OK)
{
AfxMessageBox("error");
delete pCount;
return;
}
//显示信息
if(dbaddresslist.MoveFirst() == S_OK)
{
Person.strName=m_Name = dbaddresslist.m_name;
Person.strMobile=m_Mobilnumber = dbaddresslist.m_mobile;
Person.strHomeTel=m_Hometel = dbaddresslist.m_housetel;
Person.strEmail=m_Email = dbaddresslist.m_email;
Person.strOfficeTel=m_Companytel = dbaddresslist.m_officetel;
Person.strOffice=m_Company = dbaddresslist.m_office;
Person.strAddress=m_Address = dbaddresslist.m_address;
Person.strQq=m_Qqnumber = dbaddresslist.m_qq;
Person.strGroupName=m_Group = dbaddresslist.m_groups;
}
dbaddresslist.Close();
UpdateData(FALSE);
}
void CPersoninfoView::OnChange()
{
// TODO: Add your control notification handler code here
/*CWnd* wnd1=GetDlgItem(IDC_EDIT_name);
wnd1->EnableWindow(TRUE );
CWnd* wnd2=GetDlgItem(IDC_EDIT_GROUP);
wnd2->EnableWindow(TRUE );
CWnd* wnd3=GetDlgItem(IDC_EDIT_address);
wnd3->EnableWindow(TRUE );
CWnd* wnd4=GetDlgItem(IDC_EDIT_hometel);
wnd4->EnableWindow(TRUE );
CWnd* wnd5=GetDlgItem(IDC_EDIT_company);
wnd5->EnableWindow(TRUE );
CWnd* wnd6=GetDlgItem(IDC_EDIT_companytel);
wnd6->EnableWindow(TRUE );
CWnd* wnd7=GetDlgItem(IDC_EDIT_qq);
wnd7->EnableWindow(TRUE );
CWnd* wnd8=GetDlgItem(IDC_EDIT_mobil);
wnd8->EnableWindow(TRUE );
CWnd* wnd9=GetDlgItem(IDC_EDIT_email);
wnd9->EnableWindow(TRUE );*/
CWnd* wnd10=GetDlgItem(IDC_OK);
wnd10->EnableWindow(TRUE );
CWnd* wnd11=GetDlgItem(IDC_Cacel);
wnd11->EnableWindow(TRUE );
}
void CPersoninfoView::OnOk()
{
// TODO: Add your control notification handler code here
CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
CADDRESSDoc* pDoc = (CADDRESSDoc*)pFrame->GetActiveDocument();
CString strSql,strGroupName,strName,strMobile,strQQ,strAddress,strHousetel,strOffice,strOfficetel,strEmail;
strGroupName=m_Group;
strName=m_Name;
strMobile=m_Mobilnumber;
strQQ=m_Qqnumber;
strAddress=m_Address;
strHousetel=m_Hometel;
strOffice=m_Company;
strOfficetel=m_Companytel;
strEmail=m_Email;
strSql.Format("delete * from addresslist where groups = '%s' and name = '%s' and mobile = '%s' and qq = '%s' and \
address ='%s' and housetel = '%s' and office = '%s' and officetel = '%s' and email = '%s'",
strGroupName,strName,strMobile,strQQ,strAddress,strHousetel,strOffice,strOfficetel,strEmail);
pDoc->DeletePerson(strSql);
UpdateData(TRUE);
CEdit* p;
if( m_Name == "" )
{
AfxMessageBox("请填联系人姓名");
p = (CEdit*)GetDlgItem(IDC_EDIT_name);
p->SetFocus();
return;
}
if( m_Group == "" )
{
AfxMessageBox("请填类别");
p = (CEdit*)GetDlgItem(IDC_EDIT_GROUP);
p->SetFocus();
return;
}
//CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
//CADDRESSDoc* pDoc = (CADDRESSDoc*)pFrame->GetActiveDocument();
PERSON person;
person.strGroupName = m_Group;
person.strName = m_Name;
person.strHomeTel = m_Hometel;
person.strOffice = m_Company;
person.strOfficeTel = m_Companytel;
person.strMobile = m_Mobilnumber;
person.strQq = m_Qqnumber;
person.strEmail = m_Email;
person.strAddress = m_Address;
/*CWnd* wnd1=GetDlgItem(IDC_EDIT_name);
wnd1->EnableWindow(FALSE );
CWnd* wnd2=GetDlgItem(IDC_EDIT_GROUP);
wnd2->EnableWindow(FALSE );
CWnd* wnd3=GetDlgItem(IDC_EDIT_address);
wnd3->EnableWindow(FALSE );
CWnd* wnd4=GetDlgItem(IDC_EDIT_hometel);
wnd4->EnableWindow(FALSE );
CWnd* wnd5=GetDlgItem(IDC_EDIT_company);
wnd5->EnableWindow(FALSE );
CWnd* wnd6=GetDlgItem(IDC_EDIT_companytel);
wnd6->EnableWindow(FALSE );
CWnd* wnd7=GetDlgItem(IDC_EDIT_qq);
wnd7->EnableWindow(FALSE );
CWnd* wnd8=GetDlgItem(IDC_EDIT_mobil);
wnd8->EnableWindow(FALSE );
CWnd* wnd9=GetDlgItem(IDC_EDIT_email);
wnd9->EnableWindow(FALSE );*/
CWnd* wnd10=GetDlgItem(IDC_OK);
wnd10->EnableWindow(FALSE );
CWnd* wnd11=GetDlgItem(IDC_Cacel);
wnd11->EnableWindow(FALSE );
pDoc->AddPerson(person);
//pFrame->m_pLeftView->AddPersonToTree(m_Group, m_Name);
//CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
pFrame->m_pLeftView->AddPersonsToTree();
}
void CPersoninfoView::OnCacel()
{
// TODO: Add your control notification handler code here
/*CWnd* wnd1=GetDlgItem(IDC_EDIT_name);
wnd1->EnableWindow(FALSE );
CWnd* wnd2=GetDlgItem(IDC_EDIT_GROUP);
wnd2->EnableWindow(FALSE );
CWnd* wnd3=GetDlgItem(IDC_EDIT_address);
wnd3->EnableWindow(FALSE );
CWnd* wnd4=GetDlgItem(IDC_EDIT_hometel);
wnd4->EnableWindow(FALSE );
CWnd* wnd5=GetDlgItem(IDC_EDIT_company);
wnd5->EnableWindow(FALSE );
CWnd* wnd6=GetDlgItem(IDC_EDIT_companytel);
wnd6->EnableWindow(FALSE );
CWnd* wnd7=GetDlgItem(IDC_EDIT_qq);
wnd7->EnableWindow(FALSE );
CWnd* wnd8=GetDlgItem(IDC_EDIT_mobil);
wnd8->EnableWindow(FALSE );
CWnd* wnd9=GetDlgItem(IDC_EDIT_email);
wnd9->EnableWindow(FALSE );*/
CWnd* wnd10=GetDlgItem(IDC_OK);
wnd10->EnableWindow(FALSE );
CWnd* wnd11=GetDlgItem(IDC_Cacel);
wnd11->EnableWindow(FALSE );
CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
CADDRESSDoc* pDoc = (CADDRESSDoc*)pFrame->GetActiveDocument();
pDoc->AddPerson(Person);
pFrame->m_pLeftView->AddPersonsToTree();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -