📄 xinzeng.cpp
字号:
// Xinzeng.cpp : implementation file
//
#include "stdafx.h"
#include "物业管理系统.h"
#include "Xinzeng.h"
#include"Inf.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CXinzeng dialog
CXinzeng::CXinzeng(CWnd* pParent /*=NULL*/)
: CDialog(CXinzeng::IDD, pParent)
{
//{{AFX_DATA_INIT(CXinzeng)
m_nname = _T("");
m_nmonth = _T("");
m_nmang = _T("");
m_nwater = _T("");
//}}AFX_DATA_INIT
}
void CXinzeng::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CXinzeng)
DDX_Control(pDX, IDC_EDIT1, m_name);
DDX_Control(pDX, IDC_LIST1, m_Mylist);
DDX_Text(pDX, IDC_EDIT1, m_nname);
DDX_Text(pDX, IDC_EDIT2, m_nmonth);
DDX_Text(pDX, IDC_EDIT3, m_nmang);
DDX_Text(pDX, IDC_EDIT4, m_nwater);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CXinzeng, CDialog)
//{{AFX_MSG_MAP(CXinzeng)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CXinzeng message handlers
BOOL CXinzeng::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
DWORD dwStyle=::GetWindowLong(m_Mylist.m_hWnd,GWL_STYLE);
SetWindowLong(m_Mylist.m_hWnd,GWL_STYLE,dwStyle|LVS_REPORT);
DWORD ExStyle=m_Mylist.GetExtendedStyle();
m_Mylist.SetExtendedStyle(ExStyle|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
m_Mylist.InsertColumn(0,"用户名",LVCFMT_CENTER,110,0);
m_Mylist.InsertColumn(1,"月份",LVCFMT_CENTER,100,0);
CInf recordset;
CString strSQL;
strSQL.Format("select * from inf");
if(!recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
MessageBox("打开数据失败!");
}
int i=0,n=1;
CString str;
int ipos;
while(!recordset.IsEOF())
{
str.Format("%d",n);
ipos=m_Mylist.InsertItem(n,recordset.m_name);
m_Mylist.SetItemText(ipos,1,recordset.m_month);
i++;
n++;
recordset.MoveNext();
}
recordset.Close();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CXinzeng::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_nname.IsEmpty())
{
MessageBox("用户不能为空!");
return;
}
if(m_nmonth.IsEmpty())
{
MessageBox("月份不能为空!");
return ;
}
CInf recordset;
CString strSQL;
strSQL.Format("select * from inf");
if(!recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
{
MessageBox("打开数据失败!");
return ;
}
recordset.AddNew();
recordset.m_name=m_nname;
recordset.m_month=m_nmonth;
recordset.m_mang=m_nmang;
recordset.m_water=m_nwater;
recordset.Update();
recordset.Close();
if(AfxMessageBox("填加数据成功!是否继续添加!",MB_YESNO)==IDNO)
{
CDialog::OnCancel();
}
m_nname="";
m_nmonth="";
m_nmang="";
m_nwater="";
UpdateData(FALSE);
m_name.SetFocus();
int ipos=m_Mylist.InsertItem(1,m_nname);
m_Mylist.SetItemText(ipos,1,m_nmonth);
}
void CXinzeng::OnButton3()
{
// TODO: Add your control notification handler code here
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -