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

📄 teacherdialog.cpp

📁 学生选课系统,功能齐全,什么登陆,查询,选课,删除课程,什么都有,有数据库
💻 CPP
字号:
// TeacherDialog.cpp : implementation file
//

#include "stdafx.h"
#include "CourseChose.h"
#include "TeacherDialog.h"
#include ".\teacherdialog.h"
#include "MysqlOperat.h"
#include <iostream>
#include <string>

#include "LoadDialog.h"

using namespace std;


extern CMysqlOperat MysqlOp;
// CTeacherDialog dialog

IMPLEMENT_DYNAMIC(CTeacherDialog, CDialog)
CTeacherDialog::CTeacherDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CTeacherDialog::IDD, pParent)
	, m_strChose(_T(""))
	, m_strCourseName(_T(""))
	, m_strCourseHour(_T(""))
	, m_strCourseTime(_T(""))
{
	m_bcomInit = FALSE;
}

CTeacherDialog::~CTeacherDialog()
{
}

void CTeacherDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_COMBO1, m_comChose);
	DDX_CBString(pDX, IDC_COMBO1, m_strChose);
	DDX_Text(pDX, IDC_EDIT1, m_strCourseName);
	DDX_Text(pDX, IDC_EDIT3, m_strCourseHour);
	DDX_Text(pDX, IDC_EDIT6, m_strCourseTime);
}


BEGIN_MESSAGE_MAP(CTeacherDialog, CDialog)
	ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedButton2)
	ON_CBN_DROPDOWN(IDC_COMBO1, OnCbnDropdownCombo1)
END_MESSAGE_MAP()


// CTeacherDialog message handlers
//ok
void CTeacherDialog::OnBnClickedButton1()
{
	// TODO: Add your control notification handler code here

	char	szTemp[21] = "\0";

	this->UpdateData();

	if (this->m_strChose.IsEmpty())
	{
		MessageBox("请选择操作方式!");

		return;
	}

	if (this->m_strCourseName.IsEmpty())
	{
		MessageBox("请输入课程名!");

		return;
	}
	
	if (this->m_strCourseHour.IsEmpty())
	{
		MessageBox("请输入学时!");

		return;
	}

	if (this->m_strCourseTime.IsEmpty())
	{
		MessageBox("请输入上课时间!");

		return;
	}
	
	int nIndex = this->m_comChose.GetCurSel();
	if (nIndex == 0) //insert
	{
		string	str = "insert into course(cname, cfen, ctime, tid) values(";

		strcpy(szTemp, this->m_strCourseName);
		str += '\'';
		str += szTemp;
		str += '\'';
		str += ",";

		strcpy(szTemp, this->m_strCourseHour);
		str += '\'';
		str += szTemp;
		str += '\'';
		str += ",";

		strcpy(szTemp, this->m_strCourseTime);
		str += '\'';
		str += szTemp;
		str += '\'';
		str += ",";

		sprintf(szTemp, "%ld", CLoadDialog::m_dwID);
		str += szTemp;

		str += ");";

		MysqlOp.RunSQL(str.c_str(), 1);
	}
	else //delete
	{
		string str = "delete from course where cname = \'";

		strcpy(szTemp, this->m_strCourseHour);
		str += szTemp;
		str += "\' and tid = ";

		sprintf(szTemp, "%ld", CLoadDialog::m_dwID);
		str += szTemp;

		str += ";";

		MysqlOp.RunSQL(str.c_str(), 1);
	}	
	
	OnOK();

	return;
}


void CTeacherDialog::OnBnClickedButton2()
{

	// TODO: Add your control notification handler code here
	if (IDYES == MessageBox(TEXT("真的要退出吗?"), 0, MB_YESNO))
	{
		OnCancel();
	}
}

void CTeacherDialog::OnCbnDropdownCombo1()
{
	// TODO: Add your control notification handler code here
	if (!m_bcomInit)
	{
		this->m_comChose.InsertString(0, "插入");
		this->m_comChose.InsertString(1, "删除");

		this->m_comChose.SetCurSel(0);

		m_bcomInit = TRUE;
	}
}

⌨️ 快捷键说明

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