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

📄 add_class.cpp

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

#include "stdafx.h"
#include "LMTS.h"
#include "add_class.h"
#include "teacher.h"
#include "user.h"
#include "student_db.h"

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

/////////////////////////////////////////////////////////////////////////////
// add_class dialog


add_class::add_class(CWnd* pParent /*=NULL*/)
	: CDialog(add_class::IDD, pParent)
{
	//{{AFX_DATA_INIT(add_class)
	class_name=_T("");
	class_teacher=_T("");// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void add_class::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(add_class)
	DDX_Text(pDX, IDC_EDIT1, class_name);
	DDX_Text(pDX, IDC_EDIT2, class_teacher);
// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


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

/////////////////////////////////////////////////////////////////////////////
// add_class message handlers

void add_class::OnOK() 
{
	AfxEnableControlContainer();
	CString str,strSQL,get_class_name,get_class_teacher,get_name,add_u,add_u2;
	GetDlgItem(IDC_EDIT1)->GetWindowText(get_class_name);
	GetDlgItem(IDC_EDIT2)->GetWindowText(get_class_teacher);
	teacher tea_db(&tea);
	user add_tea(&add);          //<--add user

	
	str.Format("select * from teacher");

	tea_db.Open(AFX_DB_USE_DEFAULT_TYPE,str);

	add_u.Format("select * from user");
	add_tea.Open(AFX_DB_USE_DEFAULT_TYPE,add_u);
	if(add_tea.GetRecordCount()!=0){

	int add_flg=0,i,j;

	while(!tea_db.IsEOF())
	{
		get_name=get_class_name;
		if(get_name==tea_db.m_course)
		{
			AfxMessageBox("课程重复,请重新输入");
			GetDlgItem(IDC_EDIT1)->SetWindowText("");
			GetDlgItem(IDC_EDIT2)->SetWindowText("");
			add_flg=1;
			break;
		}
		tea_db.MoveNext();
	}
	while(!add_flg)
	{
		AfxMessageBox("注册成功,请重新登录");
		tea_db.MoveLast();
		i=tea_db.m_column1+1;
		//if(reg_user.GetRecordCount()==0){
		strSQL.Format("insert into teacher values(%d,'%s','%s','%s')",i,get_class_name,get_class_teacher,"");//,input_psw,"no");

		tea.ExecuteSQL(strSQL);	
		
		add_tea.MoveLast();
			j=add_tea.m_column1+1;
			//if(reg_user.GetRecordCount()==0){
			add_u2.Format("insert into teacher values(%d,'%s','%s','%s')",j,get_class_name,get_class_teacher,"");//,input_psw,"no");
		add.ExecuteSQL(add_u2);

/*
		add_student_class.MoveLast();
		k=add_student_class.m_column1+1;
		student_str2.Format("insert into student values(%d,'%s','%s','%s','%s')",k,"aa",get_class_name,"","");
		add_db.ExecuteSQL(student_str2);	
		add_db.Close();
*/
		tea.Close();
		add.Close();	
		CDialog::OnOK();	
		add_flg=1;
	}
	CDialog::OnOK();
	}
}

⌨️ 快捷键说明

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