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

📄 reg.cpp

📁 LTMS软件说明 软件名称:LTMS(Luinse Teaching Management System)
💻 CPP
字号:
// REG.cpp : implementation file
//

#include "stdafx.h"
#include "LMTS.h"
#include "REG.h"
#include "LMTSDlg.h"
#include "odbcinst.h"
#include "user.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// REG dialog

CString REGCOMMAND;
REG::REG(CWnd* pParent /*=NULL*/)
	: CDialog(REG::IDD, pParent)
{
	//{{AFX_DATA_INIT(REG)
	reg_id=_T("");
	reg_name=_T("");
	reg_psw=_T("");
	reg_repsw=_T("");// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void REG::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(REG)
	DDX_Text(pDX, IDC_EDIT1, reg_id);
	DDX_Text(pDX, IDC_EDIT2, reg_name);
	DDX_Text(pDX, IDC_EDIT3, reg_psw);
	DDX_Text(pDX, IDC_EDIT4, reg_repsw);// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(REG, CDialog)
	//{{AFX_MSG_MAP(REG)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// REG message handlers

void REG::OnOK() 
{
	AfxEnableControlContainer();

	CLMTSDlg login_form;
	CString input_psw,input_re_psw,input_id,login_flg="false",input_name;
	GetDlgItem(IDC_EDIT3)->GetWindowText(input_psw);
	GetDlgItem(IDC_EDIT4)->GetWindowText(input_re_psw);
	GetDlgItem(IDC_EDIT1)->GetWindowText(input_id);
	GetDlgItem(IDC_EDIT2)->GetWindowText(input_name);



	CString str,strSQL,login_id;

	int reg_flg=0,i=1;
	if(input_psw==input_re_psw)
	{
		user reg_user(&reg_db);			
		str.Format("select * from user");
		reg_user.Open(AFX_DB_USE_DEFAULT_TYPE,str);
		reg_user.MoveFirst();
		while(!reg_user.IsEOF())
		{
			login_id=input_id;
			if(login_id==reg_user.m_id)
			{
				AfxMessageBox("用户名重复,请重新输入");
				GetDlgItem(IDC_EDIT1)->SetWindowText("");
				GetDlgItem(IDC_EDIT2)->SetWindowText("");
				GetDlgItem(IDC_EDIT3)->SetWindowText("");
				GetDlgItem(IDC_EDIT4)->SetWindowText("");
				reg_flg=1;
				break;
			}
			reg_user.MoveNext();
		}
		while(!reg_flg){
			AfxMessageBox("注册成功,请重新登录");
			reg_user.MoveLast();
			i=reg_user.m_column1+1;
			//if(reg_user.GetRecordCount()==0){
				strSQL.Format("insert into user values(%d,'%s','%s','%s','%s','%s')",i,input_id,input_name,"student",input_psw,"no");
				reg_db.ExecuteSQL(strSQL);
				reg_db.Close();
				CDialog::OnOK();
				reg_flg=1;
		}

	}
	else
	{
		AfxMessageBox("密码不正确,请重新输入");
		GetDlgItem(IDC_EDIT3)->SetWindowText("");
		GetDlgItem(IDC_EDIT4)->SetWindowText("");
	}
}
void REG::OnCancel()
{

	CDialog::OnCancel();
}

⌨️ 快捷键说明

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