📄 insertuser.cpp
字号:
// InsertUser.cpp : implementation file
//
#include "stdafx.h"
#include "jmChat_S.h"
#include "InsertUser.h"
#include "UserInfo.h"
#include "JmDB.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CInsertUser dialog
CInsertUser::CInsertUser(CWnd* pParent /*=NULL*/)
: CDialog(CInsertUser::IDD, pParent)
{
//{{AFX_DATA_INIT(CInsertUser)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
nOperate=0;
}
void CInsertUser::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CInsertUser)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CInsertUser, CDialog)
//{{AFX_MSG_MAP(CInsertUser)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CInsertUser message handlers
void CInsertUser::OnOK()
{
GetDlgItem(IDC_EDIT_UID)->GetWindowText(m_info.uID);
GetDlgItem(IDC_EDIT_UNAME)->GetWindowText(m_info.uName);
GetDlgItem(IDC_EDIT_UPWD)->GetWindowText(m_info.uPwd);
if(m_info.uID.IsEmpty())
{
AfxMessageBox("用户ID不能为空");
return;
}
switch(nOperate)
{
case 0:
Insertdb();
break;
case 5:
Modifydb();
break;
case 10:
delDb();
break;
default:
AfxMessageBox("不合法的输入");
break;
}
//CDialog::OnOK();
}
BOOL CInsertUser::OnInitDialog()
{
CDialog::OnInitDialog();
switch(nOperate)
{
case 5:
this->SetWindowText("修改记录");
GetDlgItem(IDOK)->SetWindowText("修改");
break;
case 10:
this->SetWindowText("删除记录");
GetDlgItem(IDOK)->SetWindowText("删除");
GetDlgItem(IDC_STC1_UNAME)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STC1_UPWD)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_UNAME)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT_UPWD)->ShowWindow(SW_HIDE);
break;
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CInsertUser::Insertdb()
{
if(m_info.uName.IsEmpty())
{
AfxMessageBox("用户名称不能为空");
return;
}
if(m_info.uPwd.IsEmpty())
{
AfxMessageBox("用户密码不能为空");
return;
}
if(m_db.bExist(m_info.uID)==FALSE)
{
m_db.Insertdb(m_info);
AfxMessageBox("插入成功");
}
else
AfxMessageBox("此条记录已存在,不能插入");
}
void CInsertUser::Modifydb()
{
if(m_info.uName.IsEmpty())
{
AfxMessageBox("用户名称不能为空");
return;
}
if(m_info.uPwd.IsEmpty())
{
AfxMessageBox("用户密码不能为空");
return;
}
if(m_db.bExist(m_info.uID)==TRUE)
{
m_db.ModifyDb(m_info);
AfxMessageBox("修改成功");
}
else
AfxMessageBox("此条记录不存在,不能修改");
}
void CInsertUser::delDb()
{
if(m_db.bExist(m_info.uID)==TRUE)
{
m_db.DelDb(m_info.uID);
AfxMessageBox("删除成功");
}
else
AfxMessageBox("此条记录不存在,不能删除");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -