📄 chargeitemeditdlg.cpp
字号:
// ChargeItemEditDlg.cpp : implementation file
//
#include "stdafx.h"
#include "ChargeManage.h"
#include "ChargeItemEditDlg.h"
#include "ChargeItem.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CChargeItemEditDlg dialog
CChargeItemEditDlg::CChargeItemEditDlg(CWnd* pParent /*=NULL*/)
: CDialog(CChargeItemEditDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CChargeItemEditDlg)
m_BookFee = 0.0;
m_DormFee = 0.0;
m_FileFee = 0.0;
m_incidental = 0.0;
m_insurance = 0.0;
m_MacTimeFee = 0.0;
m_total = 0.0;
m_tuition = 0.0;
m_BicycleFee = 0.0;
m_Year = 0;
//}}AFX_DATA_INIT
}
void CChargeItemEditDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CChargeItemEditDlg)
DDX_Control(pDX, IDC_SPECIALITY_COMBO, m_speciality);
DDX_Text(pDX, IDC_BOOK_FEE_EDIT, m_BookFee);
DDX_Text(pDX, IDC_DORM_FEE_EDIT, m_DormFee);
DDX_Text(pDX, IDC_FILE_FEE_EDIT, m_FileFee);
DDX_Text(pDX, IDC_INCIDENTAL_EDIT, m_incidental);
DDX_Text(pDX, IDC_INSURANCE_EDIT, m_insurance);
DDX_Text(pDX, IDC_MAC_TIME_FEE_EDIT, m_MacTimeFee);
DDX_Text(pDX, IDC_TOTAL_EDIT, m_total);
DDX_Text(pDX, IDC_TUITION_EDIT, m_tuition);
DDX_Text(pDX, IDC_BICYCLE_FEE_EDIT, m_BicycleFee);
DDX_Text(pDX, IDC_YEAR_EDIT, m_Year);
DDV_MinMaxInt(pDX, m_Year, 1980, 2100);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CChargeItemEditDlg, CDialog)
//{{AFX_MSG_MAP(CChargeItemEditDlg)
ON_CBN_SELCHANGE(IDC_SPECIALITY_COMBO, OnSelchangeSpecialityCombo)
ON_EN_CHANGE(IDC_TUITION_EDIT, OnChangeTuitionEdit)
ON_EN_CHANGE(IDC_INCIDENTAL_EDIT, OnChangeIncidentalEdit)
ON_EN_CHANGE(IDC_MAC_TIME_FEE_EDIT, OnChangeMacTimeFeeEdit)
ON_EN_CHANGE(IDC_INSURANCE_EDIT, OnChangeInsuranceEdit)
ON_EN_CHANGE(IDC_DORM_FEE_EDIT, OnChangeDormFeeEdit)
ON_EN_CHANGE(IDC_BICYCLE_FEE_EDIT, OnChangeBicycleFeeEdit)
ON_EN_CHANGE(IDC_BOOK_FEE_EDIT, OnChangeBookFeeEdit)
ON_EN_CHANGE(IDC_FILE_FEE_EDIT, OnChangeFileFeeEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CChargeItemEditDlg message handlers
BOOL CChargeItemEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
if(cItemId == "")
{
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);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
// 改变专业选择框
void CChargeItemEditDlg::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 CChargeItemEditDlg::OnChangeTuitionEdit()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_total = m_tuition + m_incidental + m_MacTimeFee + m_insurance + m_DormFee
+ m_BicycleFee + m_BookFee + m_FileFee;
UpdateData(FALSE);
}
// 杂费改变
void CChargeItemEditDlg::OnChangeIncidentalEdit()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_total = m_tuition + m_incidental + m_MacTimeFee + m_insurance + m_DormFee
+ m_BicycleFee + m_BookFee + m_FileFee;
UpdateData(FALSE);
}
// 机时费改变
void CChargeItemEditDlg::OnChangeMacTimeFeeEdit()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_total = m_tuition + m_incidental + m_MacTimeFee + m_insurance + m_DormFee
+ m_BicycleFee + m_BookFee + m_FileFee;
UpdateData(FALSE);
}
// 保险费改变
void CChargeItemEditDlg::OnChangeInsuranceEdit()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_total = m_tuition + m_incidental + m_MacTimeFee + m_insurance + m_DormFee
+ m_BicycleFee + m_BookFee + m_FileFee;
UpdateData(FALSE);
}
// 住宿费改变
void CChargeItemEditDlg::OnChangeDormFeeEdit()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_total = m_tuition + m_incidental + m_MacTimeFee + m_insurance + m_DormFee
+ m_BicycleFee + m_BookFee + m_FileFee;
UpdateData(FALSE);
}
// 存车费改变
void CChargeItemEditDlg::OnChangeBicycleFeeEdit()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_total = m_tuition + m_incidental + m_MacTimeFee + m_insurance + m_DormFee
+ m_BicycleFee + m_BookFee + m_FileFee;
UpdateData(FALSE);
}
// 书费改变
void CChargeItemEditDlg::OnChangeBookFeeEdit()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_total = m_tuition + m_incidental + m_MacTimeFee + m_insurance + m_DormFee
+ m_BicycleFee + m_BookFee + m_FileFee;
UpdateData(FALSE);
}
// 资料费改变
void CChargeItemEditDlg::OnChangeFileFeeEdit()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
m_total = m_tuition + m_incidental + m_MacTimeFee + m_insurance + m_DormFee
+ m_BicycleFee + m_BookFee + m_FileFee;
UpdateData(FALSE);
}
// 确定按钮
void CChargeItemEditDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
// 有效性判断
if(m_total == 0.0)
{
MessageBox("请输入收费信息");
return;
}
if(SpeId == 0)
{
if(m_speciality.GetCurSel() == 0)
{
MessageBox("请选择专业!");
return;
}
}
if(m_Year == 0)
{
MessageBox("请输入收费年度");
return;
}
//将用户输入的数据赋值到对象cur中,为更新数据库做准备
CChargeItem cur;
cur.SpeId = SpeId;
cur.iYear = m_Year;
cur.Tuition = m_tuition;
cur.Incidental = m_incidental;
cur.MacTimeFee = m_MacTimeFee;
cur.Insurance = m_insurance;
cur.DormFee = m_DormFee;
cur.BicycleFee = m_BicycleFee;
cur.BookFee = m_BookFee;
cur.FileFee = m_FileFee;
// 判断此专业收费信息是否存在
if(cItemId == "")
{
CString cYear;
CString cSpeId;
cYear.Format("%d", m_Year);
cSpeId.Format("%ld", SpeId);
if(cur.HaveSpe(cSpeId,cYear))
{
MessageBox("已经存在此专业在此年度的收费信息");
return;
}
else
cur.SqlInsert();
}
else //根据cItemId的值更新记录
cur.SqlUpdate(cItemId);
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -