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

📄 dlgagency.cpp

📁 1.解压后在sql2000中建立数据库flight,然后用本文件中的flight文件进行还原 2.数据库连接是用ADO实现的,如果更改连接,打开后对两个程序的ADOConn.cpp进行修改就行(t
💻 CPP
字号:
// DlgAgency.cpp : implementation file
//

#include "stdafx.h"
#include "AirServer.h"
#include "DlgAgency.h"
#include "ADOConn.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgAgency dialog


CDlgAgency::CDlgAgency(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgAgency::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgAgency)
	m_name = _T("");
	m_pwd1 = _T("");
	m_pwd2 = _T("");
	//}}AFX_DATA_INIT
}


void CDlgAgency::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgAgency)
	DDX_Text(pDX, IDC_EDIT1, m_name);
	DDX_Text(pDX, IDC_EdtPWD1, m_pwd1);
	DDX_Text(pDX, IDC_EdtPWD2, m_pwd2);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgAgency, CDialog)
	//{{AFX_MSG_MAP(CDlgAgency)
	ON_BN_CLICKED(IDC_ADD, OnAdd)
	ON_BN_CLICKED(IDC_DEL, OnDel)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgAgency message handlers

BOOL CDlgAgency::OnInitDialog() 
{
	CDialog::OnInitDialog();
	if(flage=="add")
		GetDlgItem(IDC_DEL)->ShowWindow(SW_HIDE);
	else
	{
		GetDlgItem(IDC_ADD)->ShowWindow(SW_HIDE);
		GetDlgItem(IDC_SPWD1)->ShowWindow(SW_HIDE);
		GetDlgItem(IDC_SPWD2)->ShowWindow(SW_HIDE);
		GetDlgItem(IDC_EdtPWD1)->ShowWindow(SW_HIDE);
		GetDlgItem(IDC_EdtPWD2)->ShowWindow(SW_HIDE);
	}
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}


void CDlgAgency::UpdateAgency()
{
	ADOConn adoConn;
	adoConn.OnInitADOConn();
	_bstr_t vsql;
	if(flage=="add")
		vsql="insert into agency values('"+m_name+"','"+m_pwd1+"');";
	else
		vsql="delete agency where 名称='"+m_name+"'";
	try{
		adoConn.ExecuteSQL(vsql);
	}catch(_com_error e){
		AfxMessageBox(e.Description());
	}
	MessageBox("更新成功!");
	adoConn.ExitConnect();
}

void CDlgAgency::OnAdd() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_name=="" || m_pwd1!=m_pwd2)
	{
		MessageBox("请输入正确信息");
	}
	else
	{
		UpdateAgency();
	}
	CDialog::OnOK();
}

void CDlgAgency::OnDel() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_name!="")
		UpdateAgency();
	else
	{
		MessageBox("请输入正确信息");
	}
	CDialog::OnOK();
}

⌨️ 快捷键说明

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