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

📄 shanchu.cpp

📁 物业管理系统 Delphi开发
💻 CPP
字号:
// Shanchu.cpp : implementation file
//

#include "stdafx.h"
#include "物业管理系统.h"
#include "Shanchu.h"
#include"Inf.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CShanchu dialog


CShanchu::CShanchu(CWnd* pParent /*=NULL*/)
	: CDialog(CShanchu::IDD, pParent)
{
	//{{AFX_DATA_INIT(CShanchu)
	m_nname = _T("");
	m_nmonth = _T("");
	m_nmang = _T("");
	m_nwater = _T("");
	//}}AFX_DATA_INIT
}


void CShanchu::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CShanchu)
	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(CShanchu, CDialog)
	//{{AFX_MSG_MAP(CShanchu)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_NOTIFY(NM_CLICK, IDC_LIST1, OnClickList1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CShanchu message handlers

BOOL CShanchu::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();	
     GetDlgItem(IDC_EDIT1)->EnableWindow(FALSE);
    GetDlgItem(IDC_EDIT2)->EnableWindow(FALSE);
    GetDlgItem(IDC_EDIT3)->EnableWindow(FALSE);
    GetDlgItem(IDC_EDIT4)->EnableWindow(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CShanchu::OnButton1() 
{
	// TODO: Add your control notification handler code here
	int i=m_Mylist.GetSelectionMark();
	if(i<0)
	{
	 	MessageBox("请选择一种类型:");
        return ;
	}
	CString str,str1;
	str=m_Mylist.GetItemText(i,0);
	str1.Format("你确定要删除 %s 民族类型吗?",str);
	if(AfxMessageBox(str1,MB_YESNO)==IDNO)
	{
		return ;
	}
	CInf recordset;
	CString strSQL;
	strSQL.Format("select * from inf WHERE name='%s'",str);
	if(!recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
	{
		MessageBox("打开数据失败!");
	    return ;	
	}
	recordset.Delete();
	m_Mylist.DeleteItem(i);
	MessageBox("删除成功!");
}

void CShanchu::OnButton3() 
{
	// TODO: Add your control notification handler code here
	CDialog::OnCancel();
}

void CShanchu::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	// TODO: Add your control notification handler code here
	int i=m_Mylist.GetSelectionMark();
    CString str,str1;
	str=m_Mylist.GetItemText(i,0);
	if(i<0)
	{
	  return ;
	}
	CInf recordset;
	CString strSQL;
	strSQL.Format("select * from inf WHERE name='%s'",str);
	if(!recordset.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL))
	{
		MessageBox("打开数据失败!");
	    return ;	
	}
  
	m_nname=recordset.m_name;
    m_nmonth=recordset.m_month;
	m_nmang=recordset.m_mang;
    m_nwater=recordset.m_water;

	recordset.Close();
	UpdateData(FALSE);
	*pResult = 0;
}

⌨️ 快捷键说明

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