?? yheditdlg.cpp
字號:
// YHEditDlg.cpp : implementation file
//
#include "stdafx.h"
#include "BySys.h"
#include "User.h"
#include "YHEditDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CYHEditDlg dialog
CYHEditDlg::CYHEditDlg(CWnd* pParent /*=NULL*/)
: CDialog(CYHEditDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CYHEditDlg)
m_Pwd1 = _T("");
m_Pwd2 = _T("");
m_UserName1 = _T("");
m_UserName2 = _T("");
m_UserName3 = _T("");
m_Qx1 = 0;
m_Qx2 = 0;
//}}AFX_DATA_INIT
}
void CYHEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CYHEditDlg)
DDX_Text(pDX, IDC_PWD1_EDIT, m_Pwd1);
DDX_Text(pDX, IDC_PWD2_EDIT, m_Pwd2);
DDX_Text(pDX, IDC_USERNAME1_EDIT, m_UserName1);
DDX_Text(pDX, IDC_USERNAME2_EDIT, m_UserName2);
DDX_Text(pDX, IDC_USERNAME3_EDIT, m_UserName3);
DDX_Text(pDX, IDC_QX1_EDIT, m_Qx1);
DDV_MinMaxInt(pDX, m_Qx1, 0, 4);
DDX_Text(pDX, IDC_QX2_EDIT, m_Qx2);
DDV_MinMaxInt(pDX, m_Qx2, 0, 4);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CYHEditDlg, CDialog)
//{{AFX_MSG_MAP(CYHEditDlg)
ON_BN_CLICKED(IDC_ADD_BUTTON, OnAddButton)
ON_BN_CLICKED(IDC_DEL_BUTTON, OnDelButton)
ON_BN_CLICKED(IDC_MODI_BUTTON, OnModiButton)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CYHEditDlg message handlers
void CYHEditDlg::OnAddButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
//檢查數據有效性
if (m_UserName1 == "")
{
MessageBox("請輸入用戶名");
return;
}
if (m_Pwd1 == "")
{
MessageBox("請輸入密碼");
return;
}
/*if (m_Qx1 == "")
{
MessageBox("請輸入權限");
return;
}*/
//定義CUsers對象,用于從表Users中讀取數據
CUser user;
if (user.GetUserName() == m_UserName1)
{
MessageBox("該用戶已經存在,無法注冊!");
return;
}
user.SetUserName(m_UserName1);
user.SetPwd(m_Pwd1);
user.SetUser_type(m_Qx1);
user.sql_insert();
MessageBox("添加成功!");
return;
//關閉對話框
CDialog::OnOK();
}
void CYHEditDlg::OnDelButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
//檢查數據有效性
if (m_UserName3 == "")
{
MessageBox("請輸入用戶名");
return;
}
CUser user;
if (user.GetUserName() != m_UserName3)
{
MessageBox("該用戶不存在,無法刪除!");
return;
}
user.sql_delete(m_UserName3);
MessageBox("刪除成功!");
//關閉對話框
CDialog::OnOK();
}
void CYHEditDlg::OnModiButton()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
//檢查數據有效性
if (m_UserName2 == "")
{
MessageBox("請輸入用戶名");
return;
}
if (m_Pwd2 == "")
{
MessageBox("請輸入密碼");
return;
}
/* if (m_Qx2 == "")
{
MessageBox("請輸入權限");
return;
}*/
CUser user;
user.SetUserName(m_UserName2);
user.SetPwd(m_Pwd2);
user.SetUser_type(m_Qx2);
user.sql_update(m_UserName2);
MessageBox("修改成功!");
return;
//關閉對話框
CDialog::OnOK();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -