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

📄 managedlg.cpp

📁 中介机构会员管理软件
💻 CPP
字号:
// ManageDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Manage.h"
#include "ManageDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
		// No message handlers
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CManageDlg dialog

CManageDlg::CManageDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CManageDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CManageDlg)
	m_a1 = _T("");
	m_a10 = _T("");
	m_a11 = _T("");
	m_a12 = _T("");
	m_a13 = _T("");
	m_a9 = _T("");
	m_a2 = _T("");
	m_a3 = _T("");
	m_a4 = _T("");
	m_a5 = _T("");
	m_a6 = _T("");
	m_a7 = _T("");
	m_a8 = _T("");
	m_b1 = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CManageDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CManageDlg)
	DDX_Text(pDX, IDC_EDIT1, m_a1);
	DDX_Text(pDX, IDC_EDIT10, m_a10);
	DDX_Text(pDX, IDC_EDIT11, m_a11);
	DDX_Text(pDX, IDC_EDIT12, m_a12);
	DDX_Text(pDX, IDC_EDIT13, m_a13);
	DDX_Text(pDX, IDC_EDIT9, m_a9);
	DDX_Text(pDX, IDC_EDIT2, m_a2);
	DDX_Text(pDX, IDC_EDIT3, m_a3);
	DDX_Text(pDX, IDC_EDIT4, m_a4);
	DDX_Text(pDX, IDC_EDIT5, m_a5);
	DDX_Text(pDX, IDC_EDIT6, m_a6);
	DDX_Text(pDX, IDC_EDIT7, m_a7);
	DDX_Text(pDX, IDC_EDIT8, m_a8);
	DDX_Text(pDX, IDC_EDIT14, m_b1);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CManageDlg, CDialog)
	//{{AFX_MSG_MAP(CManageDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CManageDlg message handlers

BOOL CManageDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	::CoInitialize(NULL);
	try
	{
       m_pConnection.CreateInstance("ADODB.Connection");
	   CString strConnect="Provider=Microsoft.Jet.OLEDB.4.0;\
	   Data Source=./shujuku.mdb;Persist Security Info=False";
	   m_pConnection->Open((_bstr_t)strConnect,"","",adModeUnknown);
	}
	catch(_com_error e)
	{
		AfxMessageBox("数据库连接错误",0,0);
	}
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CManageDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CManageDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CManageDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CManageDlg::OnButton1() 
{
	UpdateData(true);
	if ((m_a1.IsEmpty() || m_a2.IsEmpty() || m_a3.IsEmpty() || m_a4.IsEmpty()||
		m_a5.IsEmpty() || m_a6.IsEmpty() || m_a7.IsEmpty() || m_a8.IsEmpty()||
		m_a9.IsEmpty() || m_a10.IsEmpty() || m_a11.IsEmpty() || m_a12.IsEmpty()||
		m_a13.IsEmpty()))
	{
		MessageBox("信息不能为空.","提示");
		return;
	}
	m_pRecordset.CreateInstance(__uuidof(Recordset));
	m_pRecordset->Open("select * from data",m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
	try
	{
		m_pRecordset->AddNew();//添加新行
			
		m_pRecordset->GetFields()->GetItem("编号")->Value = (_bstr_t)m_a1;
		m_pRecordset->GetFields()->GetItem("姓名")->Value = (_bstr_t)m_a2;
		m_pRecordset->GetFields()->GetItem("性别")->Value = (_bstr_t)m_a3;
		m_pRecordset->GetFields()->GetItem("学校")->Value = (_bstr_t)m_a4;
		m_pRecordset->GetFields()->GetItem("年级")->Value = (_bstr_t)m_a5;
		m_pRecordset->GetFields()->GetItem("专业")->Value = (_bstr_t)m_a6;
		m_pRecordset->GetFields()->GetItem("联系电话")->Value = (_bstr_t)m_a7;
		m_pRecordset->GetFields()->GetItem("电子邮件")->Value = (_bstr_t)m_a8;
		m_pRecordset->GetFields()->GetItem("英语水平")->Value = (_bstr_t)m_a9;
		m_pRecordset->GetFields()->GetItem("计算机水平")->Value = (_bstr_t)m_a10;
		m_pRecordset->GetFields()->GetItem("申卡日期")->Value = (_bstr_t)m_a11;
		m_pRecordset->GetFields()->GetItem("申卡类型")->Value = (_bstr_t)m_a12;
		m_pRecordset->GetFields()->GetItem("工作记录")->Value = (_bstr_t)m_a13;
		
		m_pRecordset->Update();
		
	}
	catch(...)
	{
		MessageBox("操作失败");
		return;
	}
	MessageBox("操作成功.");
	m_pRecordset->Close();
	m_pRecordset.Release();

}

void CManageDlg::OnButton2() 
{
	UpdateData(true);
	m_pRecordset.CreateInstance(__uuidof(Recordset));
	m_pRecordset->Open("select * from data where 编号='"+(_bstr_t)m_b1+"'",m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
	try
	{
			
		m_a1=(char*)(_bstr_t)m_pRecordset->GetCollect("编号");
		m_a2=(char*)(_bstr_t)m_pRecordset->GetCollect("姓名");
		m_a3=(char*)(_bstr_t)m_pRecordset->GetCollect("性别");
		m_a4=(char*)(_bstr_t)m_pRecordset->GetCollect("学校");
		m_a5=(char*)(_bstr_t)m_pRecordset->GetCollect("年级");
		m_a6=(char*)(_bstr_t)m_pRecordset->GetCollect("专业");
		m_a7=(char*)(_bstr_t)m_pRecordset->GetCollect("联系电话");
		m_a8=(char*)(_bstr_t)m_pRecordset->GetCollect("电子邮件");
		m_a9=(char*)(_bstr_t)m_pRecordset->GetCollect("英语水平");
		m_a10=(char*)(_bstr_t)m_pRecordset->GetCollect("计算机水平");
		m_a11=(char*)(_bstr_t)m_pRecordset->GetCollect("申卡日期");
		m_a12=(char*)(_bstr_t)m_pRecordset->GetCollect("申卡类型");
		m_a13=(char*)(_bstr_t)m_pRecordset->GetCollect("工作记录");
		
		UpdateData(0);
		
	}
	catch(...)
	{
		MessageBox("不存在");
		m_pRecordset->Close();
		m_pRecordset.Release();
		return;
	}
	//MessageBox("操作成功.");
	m_pRecordset->Close();
	m_pRecordset.Release();
}

void CManageDlg::OnButton3() 
{
	UpdateData(true);
	if ((m_a1.IsEmpty() || m_a2.IsEmpty() || m_a3.IsEmpty() || m_a4.IsEmpty()||
		m_a5.IsEmpty() || m_a6.IsEmpty() || m_a7.IsEmpty() || m_a8.IsEmpty()||
		m_a9.IsEmpty() || m_a10.IsEmpty() || m_a11.IsEmpty() || m_a12.IsEmpty()||
		m_a13.IsEmpty()))
	{
		MessageBox("信息不能为空.","提示");

		return;
	}
	m_pRecordset.CreateInstance(__uuidof(Recordset));
	m_pRecordset->Open("select * from data where 编号='"+(_bstr_t)m_b1+"'",m_pConnection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
	try
	{
		//m_pRecordset->AddNew();//添加新行
			
		m_pRecordset->GetFields()->GetItem("编号")->Value = (_bstr_t)m_a1;
		m_pRecordset->GetFields()->GetItem("姓名")->Value = (_bstr_t)m_a2;
		m_pRecordset->GetFields()->GetItem("性别")->Value = (_bstr_t)m_a3;
		m_pRecordset->GetFields()->GetItem("学校")->Value = (_bstr_t)m_a4;
		m_pRecordset->GetFields()->GetItem("年级")->Value = (_bstr_t)m_a5;
		m_pRecordset->GetFields()->GetItem("专业")->Value = (_bstr_t)m_a6;
		m_pRecordset->GetFields()->GetItem("联系电话")->Value = (_bstr_t)m_a7;
		m_pRecordset->GetFields()->GetItem("电子邮件")->Value = (_bstr_t)m_a8;
		m_pRecordset->GetFields()->GetItem("英语水平")->Value = (_bstr_t)m_a9;
		m_pRecordset->GetFields()->GetItem("计算机水平")->Value = (_bstr_t)m_a10;
		m_pRecordset->GetFields()->GetItem("申卡日期")->Value = (_bstr_t)m_a11;
		m_pRecordset->GetFields()->GetItem("申卡类型")->Value = (_bstr_t)m_a12;
		m_pRecordset->GetFields()->GetItem("工作记录")->Value = (_bstr_t)m_a13;
		
		m_pRecordset->Update();
		
	}
	catch(...)
	{
		MessageBox("操作失败");
		m_pRecordset->Close();
		m_pRecordset.Release();
		return;
	}
	MessageBox("操作成功.");
	m_pRecordset->Close();
	m_pRecordset.Release();

}

void CManageDlg::OnButton4() 
{
	UpdateData(true);
	m_pRecordset.CreateInstance(__uuidof(Recordset));
	m_pRecordset=m_pConnection->Execute("delete from data  where 编号='"+(_bstr_t)m_b1+"' ",NULL,adCmdText);
	m_a1=m_a2=m_a3=m_a4=m_a5=m_a6=m_a7=m_a8=m_a9=m_a10=m_a11=m_a12=m_a13="";
	UpdateData(0);
	MessageBox("操作成功.");
}

⌨️ 快捷键说明

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