📄 student.cpp
字号:
// Student.cpp : implementation file
//
#include "stdafx.h"
#include "StuChgManager.h"
#include "Student.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CStuChgManagerApp theApp;
/////////////////////////////////////////////////////////////////////////////
// CStudent dialog
CStudent::CStudent(CWnd* pParent /*=NULL*/)
: CDialog(CStudent::IDD, pParent)
{
//{{AFX_DATA_INIT(CStudent)
m_cashid = _T("");
m_stucode = _T("");
m_isforign = FALSE;
m_stuid = _T("");
m_stuname = _T("");
m_penkun = FALSE;
m_sex = _T("");
m_stuspe = _T("");
m_zhusu = FALSE;
m_stucountry = _T("");
m_stuiyear = 0;
m_stunewspe = _T("");
m_stuclassnumber = 0;
//}}AFX_DATA_INIT
}
void CStudent::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStudent)
DDX_Control(pDX, IDC_STUnumber, m_ctrlstuclassnum);
DDX_Control(pDX, IDC_STUnewspe, m_ctrlstunewspe);
DDX_Control(pDX, IDC_STUcountry, m_ctrlstucountry);
DDX_Control(pDX, IDC_STUzhusu, m_ctrlzhusu);
DDX_Control(pDX, IDC_STUspe, m_ctrlstuspe);
DDX_Control(pDX, IDC_STUsex, m_ctrlsex);
DDX_Control(pDX, IDC_STUpinkun, m_ctrlpenkun);
DDX_Control(pDX, IDC_STUname, m_ctrlstuname);
DDX_Control(pDX, IDC_STUiyear, m_ctrlstuiyear);
DDX_Control(pDX, IDC_STUid, m_ctrlstuid);
DDX_Control(pDX, IDC_STUforeign, m_ctrlisforign);
DDX_Control(pDX, IDC_STUcode, m_ctrlstucode);
DDX_Control(pDX, IDC_STUcashnum, m_ctrlcashid);
DDX_Control(pDX, IDC_DATAGRID4, m_stugrid);
DDX_Text(pDX, IDC_STUcashnum, m_cashid);
DDX_Text(pDX, IDC_STUcode, m_stucode);
DDX_Check(pDX, IDC_STUforeign, m_isforign);
DDX_Text(pDX, IDC_STUid, m_stuid);
DDX_Text(pDX, IDC_STUname, m_stuname);
DDX_Check(pDX, IDC_STUpinkun, m_penkun);
DDX_CBString(pDX, IDC_STUsex, m_sex);
DDX_Text(pDX, IDC_STUspe, m_stuspe);
DDX_Check(pDX, IDC_STUzhusu, m_zhusu);
DDX_Text(pDX, IDC_STUcountry, m_stucountry);
DDX_Text(pDX, IDC_STUiyear, m_stuiyear);
DDX_Text(pDX, IDC_STUnewspe, m_stunewspe);
DDX_Text(pDX, IDC_STUnumber, m_stuclassnumber);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStudent, CDialog)
//{{AFX_MSG_MAP(CStudent)
ON_BN_CLICKED(IDC_STUENQUIR, OnStuenquir)
ON_BN_CLICKED(IDC_STUINSERT, OnStuinsert)
ON_BN_CLICKED(IDC_STUMODIFY, OnStumodify)
ON_BN_CLICKED(IDC_STUDELETE, OnStudelete)
ON_BN_CLICKED(IDC_STUSUBMIT, OnStusubmit)
ON_BN_CLICKED(IDC_STUNEW, OnStunew)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStudent message handlers
BOOL CStudent::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//赋初值
m_stuiyear = 1001;
UpdateData(false);
deleteItem = false; //初始操作失效
insertItem = false;
modifyItem = false;
queryItem = false;
m_ctrlcashid.EnableWindow(false); //编辑框失效
m_ctrlsex.EnableWindow(false);
m_ctrlstucode.EnableWindow(false);
m_ctrlstuid.EnableWindow(false);
m_ctrlstuiyear.EnableWindow(false);
m_ctrlstuname.EnableWindow(false);
m_ctrlstuspe.EnableWindow(false);
m_ctrlstucountry.EnableWindow(false);
m_ctrlstunewspe.EnableWindow(false);
m_ctrlstuclassnum.EnableWindow(false);
m_ctrlisforign.EnableWindow(false);
m_ctrlzhusu.EnableWindow(false);
m_ctrlpenkun.EnableWindow(false);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CStudent::RefreshInfo()
{
m_ctrlcashid.SetWindowText(""); //清空Edit框
m_ctrlsex.SetWindowText("");
m_ctrlstucode.SetWindowText("");
m_ctrlstuid.SetWindowText("");
m_ctrlstuiyear.SetWindowText("");
m_ctrlstuname.SetWindowText("");
m_ctrlstuspe.SetWindowText("");
m_ctrlstucountry.SetWindowText("");
m_ctrlstunewspe.SetWindowText("");
m_ctrlisforign.SetCheck(0); //check 框失效
m_ctrlzhusu.SetCheck(0);
m_ctrlpenkun.SetCheck(0);
//赋初值
m_stuiyear = 1001;
UpdateData(false);
m_stugrid.SetRefDataSource(NULL);
CString sql;
sql = "select stuID as 学生学号,Stuname as 学生姓名,sex as 性别,SpeID as 所属专业代号,iyear as 入学年份,idCard as 身份证号,CashCardID as 银行卡号,Isforeign as 留学生,Zhusu as 住宿,Penkun as 贫困生 from StuInfo";
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_stugrid.SetRefDataSource((LPUNKNOWN)theApp.record->DataSource); //将查询结果显示到DataGrid控件
m_stugrid.Refresh();
}
}
void CStudent::OnStuenquir()
{
// TODO: Add your control notification handler code here
deleteItem = false; //查询有效
insertItem = false;
modifyItem = false;
queryItem = true;
m_ctrlcashid.SetWindowText(""); //清空
m_ctrlsex.SetWindowText("");
m_ctrlstucode.SetWindowText("");
m_ctrlstuid.SetWindowText("");
// m_ctrlstuiyear.SetWindowText("");
m_ctrlstuname.SetWindowText("");
m_ctrlstuspe.SetWindowText("");
m_ctrlstucountry.SetWindowText("");
m_ctrlstunewspe.SetWindowText("");
m_ctrlisforign.SetCheck(0);//框失效
m_ctrlzhusu.SetCheck(0);
m_ctrlpenkun.SetCheck(0);
m_ctrlcashid.EnableWindow(false);
m_ctrlsex.EnableWindow(false);
m_ctrlstucode.EnableWindow(true);
m_ctrlstuid.EnableWindow(false);
m_ctrlstuiyear.EnableWindow(false);
m_ctrlstuname.EnableWindow(false);
m_ctrlstuspe.EnableWindow(false);
m_ctrlstucountry.EnableWindow(false);
m_ctrlstunewspe.EnableWindow(false);
m_ctrlstuclassnum.EnableWindow(false);
m_ctrlisforign.EnableWindow(false);
m_ctrlzhusu.EnableWindow(false);
m_ctrlpenkun.EnableWindow(false);
m_ctrlstucode.SetFocus();
}
void CStudent::OnStuinsert()
{
// TODO: Add your control notification handler code here
deleteItem = false; //插入失效
insertItem = true;
modifyItem = false;
queryItem = false;
m_ctrlcashid.SetWindowText(""); //清空Edit框
m_ctrlsex.SetWindowText("");
m_ctrlstucode.SetWindowText("");
m_ctrlstuid.SetWindowText("");
// m_ctrlstuiyear.SetWindowText("");
m_ctrlstuname.SetWindowText("");
m_ctrlstuspe.SetWindowText("");
m_ctrlstucountry.SetWindowText("");
m_ctrlstunewspe.SetWindowText("");
m_ctrlisforign.SetCheck(0); //框失效
m_ctrlzhusu.SetCheck(0);
m_ctrlpenkun.SetCheck(0);
m_ctrlcashid.EnableWindow(true);
m_ctrlsex.EnableWindow(true);
m_ctrlstucode.EnableWindow(true);
m_ctrlstuid.EnableWindow(true);
m_ctrlstuiyear.EnableWindow(true);
m_ctrlstuname.EnableWindow(true);
m_ctrlstuspe.EnableWindow(true);
m_ctrlstucountry.EnableWindow(true);
m_ctrlstunewspe.EnableWindow(false);
m_ctrlstuclassnum.EnableWindow(true);
m_ctrlisforign.EnableWindow(true);
m_ctrlzhusu.EnableWindow(true);
m_ctrlpenkun.EnableWindow(true);
m_ctrlstucode.SetFocus();
}
void CStudent::OnStumodify()
{
// TODO: Add your control notification handler code here
deleteItem = false; //修改有效
insertItem = false;
modifyItem = true;
queryItem = false;
m_ctrlcashid.SetWindowText(""); //清空Edit 框
m_ctrlsex.SetWindowText("");
m_ctrlstucode.SetWindowText("");
m_ctrlstuid.SetWindowText("");
// m_ctrlstuiyear.SetWindowText("");
m_ctrlstuname.SetWindowText("");
m_ctrlstuspe.SetWindowText("");
m_ctrlstucountry.SetWindowText("");
m_ctrlstunewspe.SetWindowText("");
m_ctrlisforign.SetCheck(0); //check失效
m_ctrlzhusu.SetCheck(0);
m_ctrlpenkun.SetCheck(0);
m_ctrlcashid.EnableWindow(true); //Edit失效
m_ctrlsex.EnableWindow(true);
m_ctrlstucode.EnableWindow(true);
m_ctrlstuid.EnableWindow(true);
m_ctrlstuiyear.EnableWindow(true);
m_ctrlstuname.EnableWindow(true);
m_ctrlstuspe.EnableWindow(true);
m_ctrlstucountry.EnableWindow(true);
m_ctrlstunewspe.EnableWindow(true);
m_ctrlstuclassnum.EnableWindow(true);
m_ctrlisforign.EnableWindow(true);
m_ctrlzhusu.EnableWindow(true);
m_ctrlpenkun.EnableWindow(true);
m_ctrlstucode.SetFocus();
}
void CStudent::OnStudelete()
{
// TODO: Add your control notification handler code here
deleteItem = true; //删除有效
insertItem = false;
modifyItem = false;
queryItem = false;
m_ctrlcashid.SetWindowText(""); //清空Edit框
m_ctrlsex.SetWindowText("");
m_ctrlstucode.SetWindowText("");
m_ctrlstuid.SetWindowText("");
// m_ctrlstuiyear.SetWindowText("");
m_ctrlstuname.SetWindowText("");
m_ctrlstuspe.SetWindowText("");
m_ctrlstucountry.SetWindowText("");
m_ctrlstunewspe.SetWindowText("");
m_ctrlisforign.SetCheck(0);//chenk失效
m_ctrlzhusu.SetCheck(0);
m_ctrlpenkun.SetCheck(0);
m_ctrlcashid.EnableWindow(false);//Edit失效
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -