📄 managerdlg.cpp
字号:
// managerDlg.cpp : implementation file
//
#include "stdafx.h"
#include "managerDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// managerDlg dialog
managerDlg::managerDlg(CWnd* pParent /*=NULL*/)
: CDialog(managerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(managerDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void managerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(managerDlg)
DDX_Control(pDX, IDC_EDIT3, m_ID2);
DDX_Control(pDX, IDC_EDIT2, m_pwd);
DDX_Control(pDX, IDC_EDIT1, m_ID1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(managerDlg, CDialog)
//{{AFX_MSG_MAP(managerDlg)
ON_BN_CLICKED(IDC_Create, OnCreate )
ON_BN_CLICKED(IDC_Delete, OnDelete )
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// managerDlg message handlers
void managerDlg::OnCreate()
{
// TODO: Add your control notification handler code here
C_Connection m_connection;
m_connection.open("Hotel");
CString sql,s1,s2;
m_ID1.GetWindowText(s1); //获取帐号和密码
m_pwd.GetWindowText(s2);
if(s1 == "" || s2 =="")
{
AfxMessageBox("请输入完整信息!!!");
return ;
}
sql.Format("select * from operator WHERE 用户名 = '%s'",s1);
m_connection.ExcuteSql(sql);
if(!m_connection.rs->IsEOF())
{
AfxMessageBox("用户名重复!!!");
return ;
}
m_connection.rs->Close();
sql.Format("INSERT INTO operator (用户名,密码)VALUES ('%s','%s') ",s1,s2);
m_connection.WriteSql(sql);
m_connection.close();
AfxMessageBox("成功创建一个新帐户!!!!!");
}
void managerDlg::OnDelete()
{
// TODO: Add your control notification handler code here
C_Connection m_connection;
m_connection.open("Hotel");
CString sql,s1;
m_ID2.GetWindowText(s1);
if(s1 == "")
{
AfxMessageBox("请输入完整信息!!!");
m_connection.close();
return ;
}
sql.Format("select * from operator WHERE 用户名 = '%s'",s1);
m_connection.ExcuteSql(sql);
if(m_connection.rs->IsEOF())
{
AfxMessageBox("无此用户名!!!");
m_connection.close();
return ;
}
m_connection.rs->Close();
sql.Format("delete from operator where 用户名='%s' ",s1);
m_connection.WriteSql(sql);
m_connection.close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -