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

📄 stueditdlg.cpp

📁 本学期的一个小项目学校收费管理系统
💻 CPP
字号:
// StuEditDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ChargeManage.h"
#include "StuEditDlg.h"
#include "Student.h"
#include "ADOConn.h"

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

extern CUserInfo curUser;

/////////////////////////////////////////////////////////////////////////////
// CStuEditDlg dialog


CStuEditDlg::CStuEditDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CStuEditDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CStuEditDlg)
	m_ClassName = _T("");
	m_FillinPerson = _T("");
	m_FillinTime = _T("");
	m_IdCard = _T("");
	m_name = _T("");
	m_ZhuSu = FALSE;
	m_CunChe = FALSE;
	m_PinKun = FALSE;
	m_TeKun = FALSE;
	m_Year = 0;
	//}}AFX_DATA_INIT
}


void CStuEditDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CStuEditDlg)
	DDX_Control(pDX, IDC_SPECIALITY_COMBO, m_speciality);
	DDX_Control(pDX, IDC_SEX_COMBO, m_sex);
	DDX_Text(pDX, IDC_CLASS_NAME_EDIT, m_ClassName);
	DDX_Text(pDX, IDC_FILLIN_PERSON_STATIC, m_FillinPerson);
	DDX_Text(pDX, IDC_FILLIN_TIME_STATIC, m_FillinTime);
	DDX_Text(pDX, IDC_ID_CARD_EDIT, m_IdCard);
	DDX_Text(pDX, IDC_NAME_EDIT, m_name);
	DDX_Check(pDX, IDC_ZHU_SU_CHECK, m_ZhuSu);
	DDX_Check(pDX, IDC_CUN_CHE_CHECK, m_CunChe);
	DDX_Check(pDX, IDC_PIN_KUN_CHECK, m_PinKun);
	DDX_Check(pDX, IDC_TE_KUN_CHECK, m_TeKun);
	DDX_Text(pDX, IDC_YEAR_EDIT, m_Year);
	DDV_MinMaxInt(pDX, m_Year, 1980, 2100);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CStuEditDlg, CDialog)
	//{{AFX_MSG_MAP(CStuEditDlg)
	ON_CBN_SELCHANGE(IDC_SPECIALITY_COMBO, OnSelchangeSpecialityCombo)
	ON_BN_CLICKED(IDC_PIN_KUN_CHECK, OnPinKunCheck)
	ON_BN_CLICKED(IDC_TE_KUN_CHECK, OnTeKunCheck)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStuEditDlg message handlers

BOOL CStuEditDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	if(cStuId == "")
	{
		m_speciality.AddString("==专业信息==");
		spe.LoadSpe();

		for(int i=0; i<spe.a_SpeId.GetSize(); i++)
		{
			if (atol(spe.a_DepId.GetAt(i)) == DepId)
			{
				m_speciality.AddString(spe.a_Name.GetAt(i));
			}
		}
	}
	else
	{
		GetDlgItem(IDC_SPECIALITY_COMBO)->EnableWindow(FALSE);
		m_speciality.AddString(cSpe);
	}
	m_speciality.SetCurSel(0);

	//设置性别
	if (cSex == "男")
		m_sex.SetCurSel(0);
	else
		m_sex.SetCurSel(1);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
void CStuEditDlg::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(TRUE);

	// 有效性判断
	if(m_name == "")
	{
		MessageBox("请输入学生姓名");
		return;
	}
	if(cStuId == "")
	{
		if(m_speciality.GetCurSel() == 0)
		{
			MessageBox("请选择专业!");
			return;
		}
	}
	//将用户输入的数据赋值到对象cur中,为更新数据库做准备
	CStudent cur;
	cur.Name = m_name;
	if (m_sex.GetCurSel() == 0)
		cur.Sex = "男";
	else
		cur.Sex = "女";
	cur.DepId = DepId;
	cur.SpeId = SpeId;
	cur.ClassName = m_ClassName;
	cur.iYear = m_Year;
	cur.IdCard = m_IdCard;
	if(m_ZhuSu)
		cur.ZhuSu = "是";
	else
		cur.ZhuSu = "否";
	if(m_CunChe)
		cur.CunChe = "是";
	else
		cur.CunChe = "否";
	if(m_PinKun)
		cur.PinKun = "是";
	else
		cur.PinKun = "否";
	if(m_TeKun)
		cur.TeKun = "是";
	else
		cur.TeKun = "否";
	//自动保存填表人和填表时间
	m_FillinPerson = curUser.UserName;
	CTime CurrentTime = CTime::GetCurrentTime();
	m_FillinTime = CurrentTime.Format("%Y-%m-%d");

	cur.FillinPerson = m_FillinPerson;
	cur.FillinTime = m_FillinTime;

	if (cStuId == "")  //表示插入数据
		cur.SqlInsert();
	else
		cur.SqlUpdate(cStuId);

	CDialog::OnOK();
}

void CStuEditDlg::OnSelchangeSpecialityCombo() 
{
	// TODO: Add your control notification handler code here
	// 得到当前专业名称
	CString strCurSpe;
	m_speciality.GetLBText(m_speciality.GetCurSel(), strCurSpe);

	// 得到SpeId的值
	for(int i = 0 ; i < spe.a_SpeId.GetSize(); i++)
	{
		if(spe.a_Name.GetAt(i) == strCurSpe)
		{
			SpeId = atol(spe.a_SpeId.GetAt(i));
		}
	}
}

void CStuEditDlg::OnPinKunCheck() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	m_TeKun = FALSE;
	UpdateData(FALSE);
}

void CStuEditDlg::OnTeKunCheck() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	m_PinKun = FALSE;
	UpdateData(FALSE);
}

⌨️ 快捷键说明

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