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

📄 xibiemanage.cpp

📁 学生成绩管理系统 在VCsql的开发环境下编写的
💻 CPP
字号:
// XibieManage.cpp : implementation file
//

#include "stdafx.h"
#include "cj.h"
#include "XibieManage.h"

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

/////////////////////////////////////////////////////////////////////////////
// CXibieManage dialog


CXibieManage::CXibieManage(CWnd* pParent /*=NULL*/)
	: CDialog(CXibieManage::IDD, pParent)
{
	//{{AFX_DATA_INIT(CXibieManage)
	m_xibiename = _T("");
	m_sXibieID = _T("");
	//}}AFX_DATA_INIT
}


void CXibieManage::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CXibieManage)
	DDX_Control(pDX, IDC_cob_XibieID, m_xibieID);
	DDX_Text(pDX, IDC_EDIT_XibieName, m_xibiename);
	DDX_CBString(pDX, IDC_cob_XibieID, m_sXibieID);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CXibieManage, CDialog)
	//{{AFX_MSG_MAP(CXibieManage)
	ON_CBN_SELCHANGE(IDC_cob_XibieID, OnSelchangecobXibieID)
	ON_BN_CLICKED(IDC_Delete, OnDelete)
	ON_BN_CLICKED(IDC_Find, OnFind)
	ON_BN_CLICKED(IDC_Modif, OnModif)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CXibieManage message handlers

BOOL CXibieManage::OnInitDialog() 
{
	CDialog::OnInitDialog();
	if(!m_database.Open(_T("student")))  return false;
	CRecordset rs(&m_database);
	CString str;
    rs.Open(CRecordset::forwardOnly,"select 系别ID from 系别");
	 while(!rs.IsEOF())
	 {
		 rs.GetFieldValue("系别ID",str);
		 m_xibieID.AddString(str);
		 rs.MoveNext();
	 }
	 rs.Close();

	
	
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CXibieManage::OnSelchangecobXibieID() 
{
	CRecordset rs(&m_database);
	 m_xibieID.GetLBText(m_xibieID.GetCurSel(),strXibieID);
	 rs.Open(CRecordset::forwardOnly,"select 系别名称 from 系别 where 系别ID='"+strXibieID+"'");
	 if(!rs.IsEOF())
	 {
		 rs.GetFieldValue("系别名称",strname);
		 m_xibiename=strname;
		 UpdateData(FALSE);
	 }
	 rs.Close();
	
}

void CXibieManage::OnDelete() 
{
	// TODO: Add your control notification handler code here
	
}

void CXibieManage::OnFind() 
{
	// TODO: Add your control notification handler code here
	
}

void CXibieManage::OnModif() 
{
	// TODO: Add your control notification handler code here
	
}

void CXibieManage::OnOK() 
{
	CRecordset rs(&m_database);
	UpdateData();
	if(m_sXibieID.IsEmpty()||m_xibiename.IsEmpty())
	{
		MessageBox("操作有误!您不能添加空信息!","系统提示:",MB_OK|MB_ICONASTERISK);
	}
	else
	{
		rs.Open(CRecordset::forwardOnly,
			"select * from 系别 where 系别ID='"+m_sXibieID+"' or 系别名称='"+m_xibiename+"'");
			icount=rs.GetRecordCount();
		rs.Close();
		if(icount!=0)
		{
			MessageBox("操作有误!已经存在重复信息!","系统提示:",MB_OK|MB_ICONASTERISK);
		}
		else
		{
			SQL="insert into 系别 (系别ID,系别名称) \
                values('"+m_sXibieID+"','"+m_xibiename+"')";
			    m_database.ExecuteSQL(SQL);
				MessageBox("完成操作!","系统提示:",MB_OK|MB_ICONASTERISK);
                UpData();
		}
	
}
}

void CXibieManage::UpData()
{
   m_xibieID.ResetContent();
   CRecordset rs(&m_database);
	CString str;
    rs.Open(CRecordset::forwardOnly,"select 系别ID from 系别");
	 while(!rs.IsEOF())
	 {
		 rs.GetFieldValue("系别ID",str);
		 m_xibieID.AddString(str);
		 rs.MoveNext();
	 }
	 rs.Close();
	 m_xibiename=_T("");
	 m_sXibieID=_T("");
	 UpdateData(FALSE);
	
}

⌨️ 快捷键说明

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