?? 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("==專業(yè)信息==");
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
}
// 改變專業(yè)選擇框
void CChargeItemEditDlg::OnSelchangeSpecialityCombo()
{
// TODO: Add your control notification handler code here
// 得到當(dāng)前專業(yè)名稱
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));
}
}
}
// 學(xué)費(fè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);
}
// 雜費(fèi)改變
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);
}
// 機(jī)時(shí)費(fèi)改變
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);
}
// 保險(xiǎn)費(fèi)改變
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);
}
// 住宿費(fèi)改變
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);
}
// 存車費(fèi)改變
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);
}
// 書費(fèi)改變
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);
}
// 資料費(fèi)改變
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("請輸入收費(fèi)信息");
return;
}
if(SpeId == 0)
{
if(m_speciality.GetCurSel() == 0)
{
MessageBox("請選擇專業(yè)!");
return;
}
}
if(m_Year == 0)
{
MessageBox("請輸入收費(fèi)年度");
return;
}
//將用戶輸入的數(shù)據(jù)賦值到對象cur中,為更新數(shù)據(jù)庫做準(zhǔn)備
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;
// 判斷此專業(yè)收費(fèi)信息是否存在
if(cItemId == "")
{
CString cYear;
CString cSpeId;
cYear.Format("%d", m_Year);
cSpeId.Format("%ld", SpeId);
if(cur.HaveSpe(cSpeId,cYear))
{
MessageBox("已經(jīng)存在此專業(yè)在此年度的收費(fèi)信息");
return;
}
else
cur.SqlInsert();
}
else //根據(jù)cItemId的值更新記錄
cur.SqlUpdate(cItemId);
CDialog::OnOK();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -