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

📄 modifystuinfermation.cpp

📁 学生成绩管理系统
💻 CPP
字号:
// modifystuinfermation.cpp : implementation file
//

#include "stdafx.h"
#include "mystudent.h"
#include "modifystuinfermation.h"

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

/////////////////////////////////////////////////////////////////////////////
// Cmodifystuinfermation dialog


Cmodifystuinfermation::Cmodifystuinfermation(CWnd* pParent /*=NULL*/)
	: CDialog(Cmodifystuinfermation::IDD, pParent)
{
	//{{AFX_DATA_INIT(Cmodifystuinfermation)
	m_stuname = _T("");
	m_stuno = _T("");
	m_stuname1 = _T("");
	m_stuno1 = _T("");
	m_xb = _T("");
	m_birthday = _T("");
	m_native = _T("");
	m_classno = _T("");
	m_studyyear = _T("");
	m_entertime = _T("");
	m_homeadd = _T("");
	m_depart = _T("");
	m_special = _T("");
	//}}AFX_DATA_INIT
}


void Cmodifystuinfermation::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Cmodifystuinfermation)
	DDX_Text(pDX, IDC_EDIT1, m_stuname);
	DDX_Text(pDX, IDC_EDIT2, m_stuno);
	DDX_Text(pDX, IDC_STATIC3, m_stuname1);
	DDX_Text(pDX, IDC_STATIC4, m_stuno1);
	DDX_Text(pDX, IDC_STATIC5, m_xb);
	DDX_Text(pDX, IDC_STATIC6, m_birthday);
	DDX_Text(pDX, ID_EDIT7, m_native);
	DDX_Text(pDX, IDC_EDIT8, m_classno);
	DDX_Text(pDX, IDC_STATIC11, m_studyyear);
	DDX_Text(pDX, IDC_STATIC12, m_entertime);
	DDX_Text(pDX, IDC_EDIT13, m_homeadd);
	DDX_Text(pDX, IDC_STATIC9, m_depart);
	DDX_Text(pDX, IDC_STATIC10, m_special);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Cmodifystuinfermation, CDialog)
	//{{AFX_MSG_MAP(Cmodifystuinfermation)
	ON_BN_CLICKED(IDCANCEL2, OnCancel2)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Cmodifystuinfermation message handlers

void Cmodifystuinfermation::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

void Cmodifystuinfermation::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(true);
	CDatabase m_database;//连接数据库
	Cstudentset student;
	Cclassinfo classinfo;
	if(student.IsOpen())
		student.Close();
	CString sql;
	sql.Format("select * from student where stuno='%s' or stuname='%s'",m_stuno,m_stuname);//m_stuname,
	student.m_pDatabase=&m_database;
	student.Open(AFX_DB_USE_DEFAULT_TYPE,sql);
	if(student.IsEOF())
	{
		MessageBox("没有该学生的信息!","提示");
		return;
	}
	else
	{
		sql.Format("select * from classinfo where classno='%s'",student.m_classno);
		classinfo.m_pDatabase=&m_database;
		classinfo.Open(AFX_DB_USE_DEFAULT_TYPE,sql);
		m_stuname1.Format("%s",student.m_stuname);
		m_stuno1.Format("%s",student.m_stuno);
		m_xb.Format("%s",student.m_xb);
		sql.Format("%d-%d-%d",student.m_birthday.GetYear(),student.m_birthday.GetMonth(),student.m_birthday.GetDay());
		m_birthday.Format("%s",sql);
		m_native.Format("%s",student.m_native);
		m_homeadd.Format("%s",student.m_homeadd);
		m_classno.Format("%s",student.m_classno);
		m_depart.Format("%s",classinfo.m_depart);
		m_special.Format("%s",classinfo.m_special);
		m_studyyear.Format("%s",classinfo.m_studyyear);
		sql.Format("%d-%d-%d",classinfo.m_entertime.GetYear(),classinfo.m_entertime.GetMonth(),classinfo.m_entertime.GetDay());
		m_entertime.Format("%s",sql);
		UpdateData(false);
	}

	
//	CDialog::OnOK();
}

void Cmodifystuinfermation::OnCancel2() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	CDatabase m_database;//连接数据库
	Cstudentset student;
	Cclassinfo classinfo;
	if(student.IsOpen())
		student.Close();
	CString sql;
	sql.Format("select * from student where stuno='%s' or stuname='%s'",m_stuno,m_stuname);//m_stuname,
	student.m_pDatabase=&m_database;
	student.Open(AFX_DB_USE_DEFAULT_TYPE,sql);
	if(student.IsEOF())
	{
		MessageBox("请输入正确的信息!","提示");
		return;
	}
	else
	{
		sql.Format("select * from classinfo where classno='%s'",m_classno);
		classinfo.m_pDatabase=&m_database;
		classinfo.Open(AFX_DB_USE_DEFAULT_TYPE,sql);
		if(classinfo.IsEOF())
		{
			MessageBox("请输入正确的班级号!","提示");
			return;
		}
		sql.Format("update student set native='%s',homeadd='%s',classno='%s' where stuno='%s'",
			m_native,m_homeadd,m_classno,m_stuno1);
		m_database.ExecuteSQL(sql);	
	//	sql.Format("你对姓名为%s的修改已成功!",student.m_stuname);
		MessageBox("你对该学生的修改已成功!","提示");
		CDialog::OnOK();
	}


	
}

void Cmodifystuinfermation::OnButton1() 
{
	// TODO: Add your control notification handler code here
	UpdateData(true);
	CDatabase m_database;//连接数据库
	Cstudentset student;
	Cscore score;
	if(student.IsOpen())
		student.Close();
	CString sql;
	sql.Format("select * from student where stuno='%s' or stuname='%s'",m_stuno,m_stuname);//m_stuname,
	student.m_pDatabase=&m_database;
	student.Open(AFX_DB_USE_DEFAULT_TYPE,sql);
	if(student.IsEOF())
	{
		MessageBox("请输入正确的信息!","提示");
		return;
	}
	else
	{
		sql.Format("select * from score where studentno='%s'",student.m_stuno);
		score.m_pDatabase=&m_database;
		score.Open(AFX_DB_USE_DEFAULT_TYPE,sql);
		sql.Format("delete score where studentno='%s'",student.m_stuno);
		m_database.ExecuteSQL(sql);
		sql.Format("delete student where stuno='%s' or stuname='%s'",m_stuno,m_stuname);
		m_database.ExecuteSQL(sql);
		MessageBox("删除成功!","提示");
		CDialog::OnOK();
	}
}

⌨️ 快捷键说明

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