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

📄 studentdialog.cpp

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

#include "stdafx.h"
#include "CourseChose.h"
#include "StudentDialog.h"
#include ".\studentdialog.h"
#include "MysqlOperat.h"
#include "LoadDialog.h"

#include <string>
#include <iostream>

using namespace std;


extern CMysqlOperat MysqlOp;


// CStudentDialog dialog

IMPLEMENT_DYNAMIC(CStudentDialog, CDialog)
CStudentDialog::CStudentDialog(CWnd* pParent /*=NULL*/)
	: CDialog(CStudentDialog::IDD, pParent)
	, m_strChose(_T(""))
	, m_dwCid(0)
	, m_dwTid(0)
{
	m_bcomInit = FALSE;
}

CStudentDialog::~CStudentDialog()
{
}

void CStudentDialog::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_dwCid);
	DDX_Text(pDX, IDC_EDIT2, m_dwTid);
}


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


// CStudentDialog message handlers

void CStudentDialog::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_dwCid == 0)
	{
		MessageBox("请输入课程ID!");

		return;
	}
	
	if (this->m_dwTid == 0)
	{
		MessageBox("请输入教师ID!");

		return;
	}

	int nIndex = this->m_comChose.GetCurSel();
	if (nIndex == 0) //insert
	{
		string	str = "insert into C_student(cid, tid, sid) values(";

		sprintf(szTemp, "%ld", this->m_dwCid);
		str += szTemp;
		str += ",";

		sprintf(szTemp, "%ld", this->m_dwTid);
		str += szTemp;
		str += ",";
		
		sprintf(szTemp, "%ld", CLoadDialog::m_dwID);
		str += szTemp;

		str += ");";

		MysqlOp.RunSQL(str.c_str(), 1);
	}
	else //delete
	{
		string str = "delete from C_student where cid = ";
		
		sprintf(szTemp, "%ld", this->m_dwCid);
		str += szTemp;
		str += "and tid = ";

		sprintf(szTemp, "%ld", this->m_dwTid);
		str += szTemp;

		str += ";";

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

	return;
}

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

void CStudentDialog::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 + -