📄 studan.cpp
字号:
// STUDAN.cpp : implementation file
//
#include "stdafx.h"
#include "YJSYS_HD.h"
#include "STUDAN.h"
#include "Columns.h"
#include "Column.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSTUDAN dialog
extern CYJSYS_HDApp theApp;
CSTUDAN::CSTUDAN(CWnd* pParent /*=NULL*/)
: CDialog(CSTUDAN::IDD, pParent)
{
//{{AFX_DATA_INIT(CSTUDAN)
m_strClassQuery = _T("");
m_strCodeQuery = _T("");
m_strSex = _T("");
m_strClass = _T("");
m_strCode = _T("");
m_strFolk = _T("");
m_strIdentity = _T("");
m_strSTUName = _T("");
m_strPhone = _T("");
m_strPolitical = _T("");
m_strTeach = _T("");
m_nQueryContent = -1;
m_dtBirth = 0;
m_dtStartTime = 0;
m_strPYCode = _T("");
m_dtEndTime = 0;
m_strField = _T("");
m_strText = _T("");
//}}AFX_DATA_INIT
}
void CSTUDAN::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSTUDAN)
DDX_Control(pDX, IDC_DATETIMEPICKER_BIRTH, m_dtCtrlBirth);
DDX_CBString(pDX, IDC_COMBO_STUDANCLASS, m_strClassQuery);
DDX_CBString(pDX, IDC_COMBO_STUDANCODE, m_strCodeQuery);
DDX_Control(pDX, IDC_DATAGRID_STUDANList, m_dgSTUDANList);
DDX_CBString(pDX, IDC_STUDANCOMBOSEX, m_strSex);
DDX_Text(pDX, IDC_STUDANEDIT_CLASS, m_strClass);
DDX_Text(pDX, IDC_STUDANEDIT_CODE, m_strCode);
DDX_Text(pDX, IDC_STUDANEDIT_FOLK, m_strFolk);
DDX_Text(pDX, IDC_STUDANEDIT_IDENTIFY, m_strIdentity);
DDX_Text(pDX, IDC_STUDANEDIT_NAME, m_strSTUName);
DDX_Text(pDX, IDC_STUDANEDIT_PHONE, m_strPhone);
DDX_Text(pDX, IDC_STUDANEDIT_POLITICAL, m_strPolitical);
DDX_Text(pDX, IDC_STUDANEDIT_TEACH, m_strTeach);
DDX_Radio(pDX, IDC_RADIO_QueryContent, m_nQueryContent);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_BIRTH, m_dtBirth);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_STARTTIME, m_dtStartTime);
DDX_Text(pDX, IDC_PYEDIT_PYCODE, m_strPYCode);
DDX_DateTimeCtrl(pDX, IDC_DATETIMEPICKER_ENDTIME, m_dtEndTime);
DDX_Text(pDX, IDC_PYEDIT_FIELD, m_strField);
DDX_Text(pDX, IDC_PYEDIT_TEXT, m_strText);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSTUDAN, CDialog)
//{{AFX_MSG_MAP(CSTUDAN)
ON_BN_CLICKED(IDC_STUDANBTN_CREATPYFA, OnStudanbtnCreatpyfa)
ON_BN_CLICKED(IDC_STUDANBTN_DELETE, OnStudanbtnDelete)
ON_BN_CLICKED(IDC_STUDANBTN_LURU, OnStudanbtnLuru)
ON_BN_CLICKED(IDC_STUDANBTN_MODIFY, OnStudanbtnModify)
ON_BN_CLICKED(IDC_STUDANBTN_QUERY, OnStudanbtnQuery)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSTUDAN message handlers
BOOL CSTUDAN::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString sql,str;
sql.Format("select * FROM CLASS");
m_pRecordset_CLASS.CreateInstance("ADODB.Recordset");
m_pRecordset_CLASS->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pconnection,true),adOpenDynamic,adLockPessimistic,adCmdText);
m_pRecordset_CLASS->MoveFirst();
while(!m_pRecordset_CLASS->rsEOF)
{
str=m_pRecordset_CLASS->GetCollect("CLASS_CODE").bstrVal;
((CComboBox *)GetDlgItem(IDC_COMBO_STUDANCLASS))->AddString(str);
m_pRecordset_CLASS->MoveNext();
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSTUDAN::OnStudanbtnCreatpyfa()
{
// TODO: Add your control notification handler code here
CString sql,str;
if(theApp.loginstatus != 2)
{
MessageBox("你没有此权限","提示"); return;
}
UpdateData(true);
if("" == m_strCode)
{
MessageBox("请查询并点击列表框中你预创建学生的信息");
return;
}
if("" == m_strPYCode)
{
MessageBox("请设置你的培养方案代码!","提示");
return;
}
else
{
MessageBox("你现在创建的是"+m_strCode+"的培养方案信息");
sql = "select * from PYFANGAN ";
m_pRecordset_PYFA.CreateInstance("ADODB.Recordset");//建立数据集
m_pRecordset_PYFA->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pconnection,true),adOpenDynamic,adLockPessimistic,adCmdText);
//---------------
m_pRecordset_PYFA->AddNew();
m_pRecordset_PYFA->PutCollect("CODE",(_variant_t)m_strCode);
m_pRecordset_PYFA->PutCollect("PY_CODE",(_variant_t)m_strPYCode);
m_pRecordset_PYFA->PutCollect("STUDY_FEILD",(_variant_t)m_strField);
m_pRecordset_PYFA->PutCollect("PY_TEXT",(_variant_t)m_strText);
GetDlgItemText(IDC_DATETIMEPICKER_STARTTIME,str);//转换时间格式
m_pRecordset_PYFA->PutCollect("PY_BEGIN_DATE",(_variant_t)str);
GetDlgItemText(IDC_DATETIMEPICKER_ENDTIME,str);//转换时间格式
m_pRecordset_PYFA->PutCollect("PY_END_TATE",(_variant_t)str);
MessageBox("用户的培养方案信息已经创建");
m_pRecordset_PYFA->Update();
}
}
void CSTUDAN::OnStudanbtnDelete()
{
// TODO: Add your control notification handler code here
CString str,sql;
if(theApp.loginstatus != 2)
{
MessageBox("你没有此权限","提示"); return;
}
UpdateData(true);
if("" == m_strCode)
{
MessageBox("请从列表框中点击预预删除的学生信息");
}
else
{
sql = "select * from STUD ";
m_pRecordset_STUD.CreateInstance("ADODB.Recordset");//建立数据集
m_pRecordset_STUD->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pconnection,true),adOpenDynamic,adLockPessimistic,adCmdText);
m_pRecordset_STUD->MoveFirst();
while(!m_pRecordset_STUD->rsEOF)
{
str = m_pRecordset_STUD->GetCollect("CODE").bstrVal;
if(0 == str.CompareNoCase(m_strCode))
{
str = m_pRecordset_STUD->GetCollect("NAME").bstrVal;
if(AfxMessageBox("确定删除用户"+str+"吗?",MB_YESNO)==IDYES)
{
m_pRecordset_STUD->Delete(adAffectCurrent);
m_pRecordset_STUD->Update();
}
else return;
MessageBox("用户的信息已经删除");
return;
}
m_pRecordset_STUD->MoveNext();
}
}
}
void CSTUDAN::OnStudanbtnLuru()
{
// TODO: Add your control notification handler code here
if(theApp.m_level != 2)
{
MessageBox("您不能添加记录");
return;
}
UpdateData(TRUE);
if(m_strCode.IsEmpty())//如果学号输入为空
{
MessageBox("请输入新生的学号");
return;
}
if ((m_strCode=="") || (m_strSTUName=="" ) ||(m_strSex=="")||(m_strTeach=="") || (m_strClass=="") )
{
MessageBox("请将学生信息输入完整","基本信息",MB_OK);
return;
}
else
{
CString sql,str;
sql = "select * from STUD ";
m_pRecordset_STUD.CreateInstance("ADODB.Recordset");//建立数据集
m_pRecordset_STUD->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pconnection,true),adOpenDynamic,adLockPessimistic,adCmdText);
if(m_pRecordset_STUD->GetRecordCount()!= 0)//如果纪录集(STUD表)不为空—防止重复插入记录
{
m_pRecordset_STUD->MoveFirst();
while(!m_pRecordset_STUD->rsEOF)//循环测试每条记录是否和待插入条目匹配
{
str = m_pRecordset_STUD->GetCollect("CODE").bstrVal;
if(str.CompareNoCase(m_strCode) == 0)//插入学生的学号已存在
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -