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

📄 stucharge.cpp

📁 自己弄得一个学生管理系统
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// StuCharge.cpp : implementation file
//

#include "stdafx.h"
#include "StuChgManager.h"
#include "StuCharge.h"

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

extern CStuChgManagerApp theApp; //引入外部变量
/////////////////////////////////////////////////////////////////////////////
// CStuCharge dialog


CStuCharge::CStuCharge(CWnd* pParent /*=NULL*/)
	: CDialog(CStuCharge::IDD, pParent)
{
	//{{AFX_DATA_INIT(CStuCharge)
	m_stuchgbook = 0.0f;
	m_stuchgdorm = 0.0f;
	m_stuchgfile = 0.0f;
	m_stuchgincid = 0.0f;
	m_stuchginsur = 0.0f;
	m_stuchgmac = 0.0f;
	m_stuchgtatol = 0.0f;
	m_stuchgtuition = 0.0f;
	m_stuchgcode = _T("");
	m_stuchgdate = _T("");
	m_stuchgdemo = _T("");
	m_stuchgid = _T("");
	m_stuchgitem = _T("");
	m_stuchgperson = _T("");
	//}}AFX_DATA_INIT
}


void CStuCharge::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CStuCharge)
	DDX_Control(pDX, IDC_STUCHGperson, m_ctrlstuchgperson);
	DDX_Control(pDX, IDC_STUCHGitem, m_ctrlstuchgitem);
	DDX_Control(pDX, IDC_STUCHGid, m_ctrlstuchgid);
	DDX_Control(pDX, IDC_STUCHGdemo, m_ctrlstuchgdemo);
	DDX_Control(pDX, IDC_STUCHGdate, m_ctrlstuchgdate);
	DDX_Control(pDX, IDC_STUCHGcode, m_ctrlstuchgcode);
	DDX_Control(pDX, IDC_STUCHGtuition, m_ctrlstuchgtuition);
	DDX_Control(pDX, IDC_STUCHGtotal, m_ctrlstuchgtatol);
	DDX_Control(pDX, IDC_STUCHGmactime, m_ctrlstuchgmac);
	DDX_Control(pDX, IDC_STUCHGinsurance, m_ctrlstuchginsur);
	DDX_Control(pDX, IDC_STUCHGincidental, m_ctrlstuchgincid);
	DDX_Control(pDX, IDC_STUCHGfile, m_ctrlstuchgfile);
	DDX_Control(pDX, IDC_STUCHGdorm, m_ctrlstuchgdorm);
	DDX_Control(pDX, IDC_STUCHGbook, m_ctrlstuchgbook);
	DDX_Text(pDX, IDC_STUCHGbook, m_stuchgbook);
	DDX_Text(pDX, IDC_STUCHGdorm, m_stuchgdorm);
	DDX_Text(pDX, IDC_STUCHGfile, m_stuchgfile);
	DDX_Text(pDX, IDC_STUCHGincidental, m_stuchgincid);
	DDX_Text(pDX, IDC_STUCHGinsurance, m_stuchginsur);
	DDX_Text(pDX, IDC_STUCHGmactime, m_stuchgmac);
	DDX_Text(pDX, IDC_STUCHGtotal, m_stuchgtatol);
	DDX_Text(pDX, IDC_STUCHGtuition, m_stuchgtuition);
	DDX_Text(pDX, IDC_STUCHGcode, m_stuchgcode);
	DDX_Text(pDX, IDC_STUCHGdate, m_stuchgdate);
	DDX_Text(pDX, IDC_STUCHGdemo, m_stuchgdemo);
	DDX_Text(pDX, IDC_STUCHGid, m_stuchgid);
	DDX_Text(pDX, IDC_STUCHGitem, m_stuchgitem);
	DDX_Text(pDX, IDC_STUCHGperson, m_stuchgperson);
	DDX_Control(pDX, IDC_DATAGRID9, m_stuchggrid);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CStuCharge, CDialog)
	//{{AFX_MSG_MAP(CStuCharge)
	ON_BN_CLICKED(IDC_STUCHGITEMINSERT, OnStuchgiteminsert)
	ON_BN_CLICKED(IDC_STUCHGITEMSELECT, OnStuchgitemselect)
	ON_BN_CLICKED(IDC_STUCHGITEMDELE, OnStuchgitemdele)
	ON_BN_CLICKED(IDC_STUCHGITEMSUBMIT, OnStuchgitemsubmit)
	ON_BN_CLICKED(IDC_STUCHGITEMNEW, OnStuchgitemnew)
	ON_BN_CLICKED(IDC_STUCHGMODIFY, OnStuchgmodify)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CStuCharge message handlers

BOOL CStuCharge::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	insertItem = false; //初始操作失效
	deleteItem = false;
	modifyItem = false;
	queryItem  = false;
	m_ctrlstuchgid.SetWindowText(""); //清空Edit框
	m_ctrlstuchgitem.SetWindowText("");
	m_ctrlstuchgcode.SetWindowText("");

	m_ctrlstuchgdate.SetWindowText("");
	m_ctrlstuchgperson.SetWindowText("");
	m_ctrlstuchgdemo.SetWindowText("");
    //交费信息
	m_ctrlstuchgtuition.EnableWindow(false);
	m_ctrlstuchgbook.EnableWindow(false);
    m_ctrlstuchgdorm.EnableWindow(false);
	m_ctrlstuchgfile.EnableWindow(false);
	m_ctrlstuchgincid.EnableWindow(false);
	m_ctrlstuchginsur.EnableWindow(false);
	m_ctrlstuchgmac.EnableWindow(false);
	m_ctrlstuchgtatol.EnableWindow(false);
    //交费项目信息
	m_ctrlstuchgid.EnableWindow(false);
	m_ctrlstuchgcode.EnableWindow(false);
	m_ctrlstuchgitem.EnableWindow(false);
	//交费其他信息
	m_ctrlstuchgperson.EnableWindow(false);
	m_ctrlstuchgdate.EnableWindow(false);
	m_ctrlstuchgdemo.EnableWindow(false);

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

void CStuCharge::OnStuchgiteminsert() 
{
	// TODO: Add your control notification handler code here
	insertItem = true; //插入操作有效
	deleteItem = false;
	modifyItem = false;
	queryItem  = false;
	m_ctrlstuchgid.SetWindowText(""); //清空Edit框
	m_ctrlstuchgitem.SetWindowText("");
	m_ctrlstuchgcode.SetWindowText("");

	m_ctrlstuchgdate.SetWindowText("");
	m_ctrlstuchgperson.SetWindowText("");
	m_ctrlstuchgdemo.SetWindowText("");
    //交费信息
	m_ctrlstuchgtuition.EnableWindow(true);
	m_ctrlstuchgbook.EnableWindow(true);
    m_ctrlstuchgdorm.EnableWindow(true);
	m_ctrlstuchgfile.EnableWindow(true);
	m_ctrlstuchgincid.EnableWindow(true);
	m_ctrlstuchginsur.EnableWindow(true);
	m_ctrlstuchgmac.EnableWindow(true);
	m_ctrlstuchgtatol.EnableWindow(true);
    //交费项目信息
	m_ctrlstuchgid.EnableWindow(true);
	m_ctrlstuchgcode.EnableWindow(true);
	m_ctrlstuchgitem.EnableWindow(true);
	//交费其他信息
	m_ctrlstuchgperson.EnableWindow(true);
	m_ctrlstuchgdate.EnableWindow(true);
	m_ctrlstuchgdemo.EnableWindow(true);

	m_ctrlstuchgid.SetFocus();
}

void CStuCharge::OnStuchgitemselect() 
{
	// TODO: Add your control notification handler code here
	insertItem = false;
	deleteItem = false; //查询有效
	modifyItem = false;
	queryItem  = true;
	m_ctrlstuchgid.SetWindowText(""); //清空Edit框
	m_ctrlstuchgitem.SetWindowText("");
	m_ctrlstuchgcode.SetWindowText("");

	m_ctrlstuchgdate.SetWindowText("");
	m_ctrlstuchgperson.SetWindowText("");
	m_ctrlstuchgdemo.SetWindowText("");
    //交费信息
	m_ctrlstuchgtuition.EnableWindow(false);
	m_ctrlstuchgbook.EnableWindow(false);
    m_ctrlstuchgdorm.EnableWindow(false);
	m_ctrlstuchgfile.EnableWindow(false);
	m_ctrlstuchgincid.EnableWindow(false);
	m_ctrlstuchginsur.EnableWindow(false);
	m_ctrlstuchgmac.EnableWindow(false);
	m_ctrlstuchgtatol.EnableWindow(false);
    //交费项目信息
	m_ctrlstuchgid.EnableWindow(true);
	m_ctrlstuchgcode.EnableWindow(false);
	m_ctrlstuchgitem.EnableWindow(false);
	//交费其他信息
	m_ctrlstuchgperson.EnableWindow(false);
	m_ctrlstuchgdate.EnableWindow(false);
	m_ctrlstuchgdemo.EnableWindow(false);

	m_ctrlstuchgid.SetFocus();
}

void CStuCharge::OnStuchgmodify() 
{
	// TODO: Add your control notification handler code here
	insertItem = false; //修改有效
	deleteItem = false;
	modifyItem = true;
	queryItem  = false;
	m_ctrlstuchgid.SetWindowText(""); //清空Edit框
	m_ctrlstuchgitem.SetWindowText("");
	m_ctrlstuchgcode.SetWindowText("");

	m_ctrlstuchgdate.SetWindowText("");
	m_ctrlstuchgperson.SetWindowText("");
	m_ctrlstuchgdemo.SetWindowText("");
    //交费信息
	m_ctrlstuchgtuition.EnableWindow(true);
	m_ctrlstuchgbook.EnableWindow(true);
    m_ctrlstuchgdorm.EnableWindow(true);
	m_ctrlstuchgfile.EnableWindow(true);
	m_ctrlstuchgincid.EnableWindow(true);
	m_ctrlstuchginsur.EnableWindow(true);
	m_ctrlstuchgmac.EnableWindow(true);
	m_ctrlstuchgtatol.EnableWindow(true);
    //交费项目信息
	m_ctrlstuchgid.EnableWindow(true);
	m_ctrlstuchgcode.EnableWindow(false);
	m_ctrlstuchgitem.EnableWindow(false);
	//交费其他信息
	m_ctrlstuchgperson.EnableWindow(false);
	m_ctrlstuchgdate.EnableWindow(false);
	m_ctrlstuchgdemo.EnableWindow(true);

	m_ctrlstuchgid.SetFocus();
}

void CStuCharge::OnStuchgitemdele() 
{
	// TODO: Add your control notification handler code here
	insertItem = false; //删除有效
	deleteItem = true;
	modifyItem = false;
	queryItem  = false;
	m_ctrlstuchgid.SetWindowText(""); //清空Edit框
	m_ctrlstuchgitem.SetWindowText("");
	m_ctrlstuchgcode.SetWindowText("");

	m_ctrlstuchgdate.SetWindowText("");
	m_ctrlstuchgperson.SetWindowText("");
	m_ctrlstuchgdemo.SetWindowText("");
    //交费信息
	m_ctrlstuchgtuition.EnableWindow(false);
	m_ctrlstuchgbook.EnableWindow(false);
    m_ctrlstuchgdorm.EnableWindow(false);
	m_ctrlstuchgfile.EnableWindow(false);
	m_ctrlstuchgincid.EnableWindow(false);
	m_ctrlstuchginsur.EnableWindow(false);
	m_ctrlstuchgmac.EnableWindow(false);
	m_ctrlstuchgtatol.EnableWindow(false);
    //交费项目信息
	m_ctrlstuchgid.EnableWindow(true);
	m_ctrlstuchgcode.EnableWindow(false);
	m_ctrlstuchgitem.EnableWindow(false);
	//交费其他信息
	m_ctrlstuchgperson.EnableWindow(false);
	m_ctrlstuchgdate.EnableWindow(false);
	m_ctrlstuchgdemo.EnableWindow(false);

	m_ctrlstuchgid.SetFocus();
}

void CStuCharge::RefreshInfo()
{
	 //赋初值
	m_stuchgtuition=0;
	m_stuchgbook=0;
    m_stuchgdorm=0;
	m_stuchgfile=0;
	m_stuchgincid=0;
	m_stuchginsur=0;
	m_stuchgmac=0;
	m_stuchgtatol=0;

    UpdateData(false);
//将Edit框清空
	m_ctrlstuchgid.SetWindowText("");
	m_ctrlstuchgitem.SetWindowText("");
	m_ctrlstuchgcode.SetWindowText("");

	m_ctrlstuchgdate.SetWindowText("");
	m_ctrlstuchgperson.SetWindowText("");
	m_ctrlstuchgdemo.SetWindowText("");

	m_stuchggrid.SetRefDataSource(NULL);

	CString sql;
	sql = "select ChgID,StuID,ItemID,Fact_Tuition,Fact_Incidental,Fact_MacTimeFee,Fact_Insurance,Fact_DormFee,Fact_BookFee,Fact_FileFee,Fact_TotalFee,ChargePerson,ChargeDate,Demo from StuCharge";
    theApp.record->raw_Close();          //关闭当前的数据集
	theApp.record->CursorLocation = adUseClient;
		
	try   //捕捉异常
	{
		theApp.record->Open((_bstr_t)sql,theApp.connection.GetInterfacePtr(),adOpenKeyset,adLockPessimistic,adCmdText);
		
	}
	catch(_com_error & e)
	{
		AfxMessageBox(e.Description());
		return;                          //捕捉到异常后就不在继续执行
	}

	if(theApp.record->RecordCount > 0)   //非空集合
	{
		m_stuchggrid.SetRefDataSource((LPUNKNOWN)theApp.record->DataSource);    //将查询结果显示到DataGrid控件
		m_stuchggrid.Refresh();
	}

⌨️ 快捷键说明

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