📄 xuanke.cpp
字号:
// XUANKE.cpp : implementation file
//
#include "stdafx.h"
#include "YJSYS_HD.h"
#include "XUANKE.h"
#include "Columns.h"
#include "Column.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CXUANKE dialog
extern CYJSYS_HDApp theApp;
CXUANKE::CXUANKE(CWnd* pParent /*=NULL*/)
: CDialog(CXUANKE::IDD, pParent)
{
//{{AFX_DATA_INIT(CXUANKE)
m_strBBK1 = _T("");
m_strBBK2 = _T("");
m_strBBK3 = _T("");
m_strXWK1 = _T("");
m_strXWK2 = _T("");
m_strXWK3 = _T("");
m_strXWK4 = _T("");
m_strXXK1 = _T("");
m_strXXK2 = _T("");
m_strXXK3 = _T("");
m_strXXK4 = _T("");
m_strXXK5 = _T("");
m_strXXK6 = _T("");
m_strXXK7 = _T("");
m_strXXK8 = _T("");
m_strCode = _T("");
//}}AFX_DATA_INIT
}
void CXUANKE::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CXUANKE)
DDX_CBString(pDX, IDC_COMBO_BBK1, m_strBBK1);
DDX_CBString(pDX, IDC_COMBO_BBK2, m_strBBK2);
DDX_CBString(pDX, IDC_COMBO_BBK3, m_strBBK3);
DDX_CBString(pDX, IDC_COMBO_XWK1, m_strXWK1);
DDX_CBString(pDX, IDC_COMBO_XWK2, m_strXWK2);
DDX_CBString(pDX, IDC_COMBO_XWK3, m_strXWK3);
DDX_CBString(pDX, IDC_COMBO_XWK4, m_strXWK4);
DDX_CBString(pDX, IDC_COMBO_XXK1, m_strXXK1);
DDX_CBString(pDX, IDC_COMBO_XXK2, m_strXXK2);
DDX_CBString(pDX, IDC_COMBO_XXK3, m_strXXK3);
DDX_CBString(pDX, IDC_COMBO_XXK4, m_strXXK4);
DDX_CBString(pDX, IDC_COMBO_XXK5, m_strXXK5);
DDX_CBString(pDX, IDC_COMBO_XXK6, m_strXXK6);
DDX_CBString(pDX, IDC_COMBO_XXK7, m_strXXK7);
DDX_CBString(pDX, IDC_COMBO_XXK8, m_strXXK8);
DDX_Text(pDX, IDC_EDIT_XKCode, m_strCode);
DDX_Control(pDX, IDC_DATAGRID_XKList, m_dgXKList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CXUANKE, CDialog)
//{{AFX_MSG_MAP(CXUANKE)
ON_BN_CLICKED(IDC_XUANKEBTN_CHOOSE, OnXuankebtnChoose)
ON_BN_CLICKED(IDC_XUANKEBTN_COMMIT, OnXuankebtnCommit)
ON_BN_CLICKED(IDC_XUANKEBTN_MODIFY, OnXuankebtnModify)
ON_BN_CLICKED(IDC_XUANKEBTN_QUERY, OnXuankebtnQuery)
ON_BN_CLICKED(IDC_XUANKEBTN_QUEREN, OnXuankebtnQueren)
ON_BN_CLICKED(IDC_XUANKEBTN_QLESSON, OnXuankebtnQlesson)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CXUANKE message handlers
BOOL CXUANKE::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
GetDlgItem(IDC_COMBO_XWK1)->EnableWindow(false);
GetDlgItem(IDC_COMBO_XXK1)->EnableWindow(false);
GetDlgItem(IDC_COMBO_BBK1)->EnableWindow(false);
GetDlgItem(IDC_EDIT_XKCode)->EnableWindow(true);
m_Commit_Ischoose=false;//用户是否点击了选课按纽
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CXUANKE::OnXuankebtnChoose()
{
// TODO: Add your control notification handler code here
CString str1,str2,sql;
BOOL ischoose,isexist;
ischoose=false;//ischoose 为数据库中,标记学生是否已注册课程
isexist=false;//isexist 表示该用户是否存在!
UpdateData(true);
m_pRecordset_PYFANGAN.CreateInstance("ADODB.Recordset");//打开用户信息基本表
m_pRecordset_PYFANGAN->Open("select * from PYFANGAN",_variant_t((IDispatch *)theApp.m_pconnection,true),adOpenDynamic,adLockPessimistic,adCmdText);
if(m_strCode.IsEmpty())
{
MessageBox("请输入你的学号");
return;
}
else
{
m_pRecordset_PYFANGAN->MoveFirst();
while(!m_pRecordset_PYFANGAN->rsEOF)
{
ischoose=m_pRecordset_PYFANGAN->GetCollect("PY_ISCHOOSE").boolVal;
str1=m_pRecordset_PYFANGAN->GetCollect("CODE").bstrVal;
if(-1==ischoose && 0==str1.CompareNoCase(m_strCode))//此学员已选过课程
{MessageBox("你的课程已经注册,修改请找相关人员"); return;}
if(0==str1.CompareNoCase(m_strCode))
{isexist=true;m_strPY_code=m_pRecordset_PYFANGAN->GetCollect("PY_CODE").bstrVal;}
m_pRecordset_PYFANGAN->MoveNext();
}
if(!isexist) {MessageBox("你的培养计划尚未建立,不能选棵");return;}
}
sql.Format("select * from LESSON2");// 初始化各列表--
m_pRecordset_LESSON2.CreateInstance("ADODB.Recordset");//打开用户信息基本表
m_pRecordset_LESSON2->Open((_variant_t)sql,_variant_t((IDispatch *)theApp.m_pconnection,true),adOpenDynamic,adLockPessimistic,adCmdText);
m_pRecordset_LESSON2->MoveFirst();
//---------------------
GetDlgItem(IDC_COMBO_XWK1)->EnableWindow(true);
GetDlgItem(IDC_COMBO_XXK1)->EnableWindow(true);
GetDlgItem(IDC_COMBO_BBK1)->EnableWindow(true);
GetDlgItem(IDC_EDIT_XKCode)->EnableWindow(true);
//-------------------------
while(!m_pRecordset_LESSON2->rsEOF)
{
str1=m_pRecordset_LESSON2->GetCollect("LESSON_TYPE").bstrVal;
str2=m_pRecordset_LESSON2->GetCollect("LESSON_NAME").bstrVal;
if(0==str1.CompareNoCase("学位课 "))
{
((CComboBox*)GetDlgItem(IDC_COMBO_XWK1))->AddString(str2);
((CComboBox*)GetDlgItem(IDC_COMBO_XWK2))->AddString(str2);
((CComboBox*)GetDlgItem(IDC_COMBO_XWK3))->AddString(str2);
((CComboBox*)GetDlgItem(IDC_COMBO_XWK4))->AddString(str2);
}
else if(0==str1.CompareNoCase("选修课 "))
{
((CComboBox*)GetDlgItem(IDC_COMBO_XXK1))->AddString(str2);
((CComboBox*)GetDlgItem(IDC_COMBO_XXK2))->AddString(str2);
((CComboBox*)GetDlgItem(IDC_COMBO_XXK3))->AddString(str2);
((CComboBox*)GetDlgItem(IDC_COMBO_XXK4))->AddString(str2);
((CComboBox*)GetDlgItem(IDC_COMBO_XXK5))->AddString(str2);
((CComboBox*)GetDlgItem(IDC_COMBO_XXK6))->AddString(str2);
((CComboBox*)GetDlgItem(IDC_COMBO_XXK7))->AddString(str2);
((CComboBox*)GetDlgItem(IDC_COMBO_XXK8))->AddString(str2);
}
else if(0==str1.CompareNoCase("补本课 "))
{
((CComboBox*)GetDlgItem(IDC_COMBO_BBK1))->AddString(str2);
((CComboBox*)GetDlgItem(IDC_COMBO_BBK2))->AddString(str2);
((CComboBox*)GetDlgItem(IDC_COMBO_BBK3))->AddString(str2);
}
m_pRecordset_LESSON2->MoveNext();
}
//-----------------------
MessageBox("请认真一次性输入自己所选择的全部课程!");
m_Commit_Ischoose=true;
}
void CXUANKE::OnXuankebtnCommit()
{
// TODO: Add your control notification handler code here
CString sql,str,str2;
UpdateData(true);
if(!m_Commit_Ischoose || m_strXWK1=="" || m_strXXK1.IsEmpty())
{
MessageBox("请选择你的课程,然后提交!");return;
}
//sql.Format("select * from PYFA_DETAIL");//更新PY_DETAILB table,注册课程
m_pRecordset_PYFA_DETAIL.CreateInstance("ADODB.Recordset");
m_pRecordset_PYFA_DETAIL->Open("select * from PYFA_DEDAIL",_variant_t((IDispatch *)theApp.m_pconnection,true),adOpenDynamic,adLockPessimistic,adCmdText);
if(m_strXWK1!="")
{
m_pRecordset_PYFA_DETAIL->AddNew();
m_pRecordset_PYFA_DETAIL->PutCollect("CODE",(_variant_t)m_strCode);
m_pRecordset_PYFA_DETAIL->PutCollect("PY_CODE",(_variant_t)m_strPY_code);
m_pRecordset_PYFA_DETAIL->PutCollect("LESSON_NAME2",(_variant_t)m_strXWK1);
m_pRecordset_PYFA_DETAIL->PutCollect("LESSON_TYPE2",(_variant_t)"学位课 ");
}
if(m_strXWK2!="")
{
m_pRecordset_PYFA_DETAIL->AddNew();
m_pRecordset_PYFA_DETAIL->PutCollect("CODE",(_variant_t)m_strCode);
m_pRecordset_PYFA_DETAIL->PutCollect("PY_CODE",(_variant_t)m_strPY_code);
m_pRecordset_PYFA_DETAIL->PutCollect("LESSON_NAME2",(_variant_t)m_strXWK2);
m_pRecordset_PYFA_DETAIL->PutCollect("LESSON_TYPE2",(_variant_t)"学位课 ");
}
if(m_strXWK3!="")
{
m_pRecordset_PYFA_DETAIL->AddNew();
m_pRecordset_PYFA_DETAIL->PutCollect("CODE",(_variant_t)m_strCode);
m_pRecordset_PYFA_DETAIL->PutCollect("PY_CODE",(_variant_t)m_strPY_code);
m_pRecordset_PYFA_DETAIL->PutCollect("LESSON_NAME2",(_variant_t)m_strXWK3);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -