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

📄 classroomidlg.cpp

📁 这是一个学生管理系统 包含学生基本信息 选课信息 宿舍信息 教师信息 课程信息 班机信息 教师信息等录入 查询 修改删除等强大功能
💻 CPP
字号:
// ClassroomIdlg.cpp : implementation file
//

#include "stdafx.h"
#include "Student.h"
#include "ClassroomIdlg.h"
#include "ClassRoomSet.h"

#include "myrecord.h"

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

/////////////////////////////////////////////////////////////////////////////
// CClassroomIdlg dialog


CClassroomIdlg::CClassroomIdlg(CWnd* pParent /*=NULL*/)
	: CDialog(CClassroomIdlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CClassroomIdlg)
	m_help = _T("");
	m_kind = _T("");
	m_capacity = _T("");
	m_classroom_no = _T("");
	//}}AFX_DATA_INIT
}


void CClassroomIdlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CClassroomIdlg)
	DDX_Text(pDX, IDC_EDIT_HELP, m_help);
	DDX_Text(pDX, IDC_EDIT_KIND, m_kind);
	DDX_Text(pDX, IDC_EDIT_CAPACITY, m_capacity);
	DDX_Text(pDX, IDC_EDIT_CLASSROOM_NO, m_classroom_no);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CClassroomIdlg, CDialog)
	//{{AFX_MSG_MAP(CClassroomIdlg)
	ON_BN_CLICKED(IDC_BTN_OK, OnBtnOk)
	ON_EN_SETFOCUS(IDC_EDIT_CAPACITY, OnSetfocusEditCapacity)
	ON_EN_SETFOCUS(IDC_EDIT_KIND, OnSetfocusEditKind)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CClassroomIdlg message handlers

void CClassroomIdlg::OnBtnOk() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(m_classroom_no.IsEmpty())
	{
		//MessageBeep(MB_ICONEXCLAMATION);
		this->GetDlgItem(IDC_EDIT_CLASSROOM_NO)->SetFocus();
		return;
	}
	if(m_kind.IsEmpty())
	{
		//MessageBeep(MB_ICONEXCLAMATION);
		this->GetDlgItem(IDC_EDIT_KIND)->SetFocus();
		return;
	}
	if(m_capacity.IsEmpty())
	{
		//MessageBeep(MB_ICONEXCLAMATION);
		this->GetDlgItem(IDC_EDIT_CAPACITY)->SetFocus();
		return;
	}
	if(!UpdateDB())
		return;
	GenNext();
	UpdateData(FALSE);
	this->GetDlgItem(IDC_EDIT_KIND)->SetFocus();
	CDialog::OnOK();
}

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

BOOL CClassroomIdlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	GenNext();
	UpdateData(FALSE);
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CClassroomIdlg::OnSetfocusEditCapacity() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	m_help="请输入容量信息";
	UpdateData(FALSE);
}

void CClassroomIdlg::OnSetfocusEditKind() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	m_help="请输入教室类型信息";
	UpdateData(FALSE);
}
void CClassroomIdlg::GenNext()
{
	CClassroomSet rs;
	CString strValue;
	CString strFileName;
	
	static HBITMAP hBitmap=NULL;
	// TODO: Add extra initialization here
	
	
	m_classroom_no =GetNextNo();
	
	m_kind ="";
	m_capacity ="";
}

CString CClassroomIdlg::GetNextNo()
{
	UpdateData(true);
	static int num=0;
	CClassroomSet rs;
	CString strValue,strSQL;
	BOOL Success;
		

	if(num==0)
	{
		strSQL.Format("select max(substr(classroom_no,5)) from classroom where substr(class_no,1,4)=\'%s\'",m_Type);
		Success=rs.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
		if (Success && rs.GetRecordCount()>0)
		{
			if(m_Type==0)
			rs.GetFieldValue((short)0,strValue);
			else if(m_Type==1)
			rs.GetFieldValue((short)1,strValue);
		}
		else
			strValue="0";
		num=atoi(strValue);
	}
	num++;
	
		strValue.Format("%s%03d",m_Type,num);
	
	 //普教编号生成以0开始
	 //电教编号生成以1开始
	return strValue;
	
}

BOOL CClassroomIdlg::UpdateDB()
{
	CString strSQL,strValue,strTemp;
	
	//strTemp.Format("%d,to_date(\'%4d-%2d-%2d\',\'yyyy-mm-dd\')",m_score,m_birth_year,m_birth_month,m_birth_day);
	strSQL="insert into Classroom(classroom_no,kind,capacity";
	strValue="\'"+m_classroom_no+"\',\'"+m_kind+"\',\'"+m_capacity;
	
	
	strSQL+=") values("+strValue+")";
	//MessageBox(strSQL);
	m_pDB->ExecuteSQL(strSQL);
	return TRUE;
}
void CClassroomIdlg::GenHelp(CString tCategory)
{
	CClassroomSet rs;
	CString strSQL,strValue,strZero;
	BOOL Success;
	int nLen;

	//UpdateData();
	strSQL.Format("select length(trim(ccode)) from userdict where category=\'%s\' and rownum<2",tCategory);
	Success=rs.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
	if(!Success)
		return ;
	rs.GetFieldValue((short)0,strValue);
	nLen=atoi(strValue);
	rs.Close();

	strSQL.Format("select trim(ccode)||\'-\'||trim(ctext) from userdict where category=\'%s\'",tCategory);
	Success=rs.Open(AFX_DB_USE_DEFAULT_TYPE,strSQL);
	if(Success)
	{
		strZero="";
		for(int i=0;i<nLen;i++)
			strZero+="0";
		while (!rs.IsEOF())
		{
			rs.GetFieldValue((short)0,strValue);
			
			
			if (strValue.Left(nLen)==strZero)
				m_help="  "+strValue.Mid(nLen+1);
			else
				m_help+="\r\n\t"+strValue;
			rs.MoveNext();
		}
		rs.Close();
	}
	UpdateData(FALSE);
}

⌨️ 快捷键说明

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