📄 teachdlg.cpp
字号:
// TeachDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TeacherMIS.h"
#include "TeachDlg.h"
#include "column.h"
#include "columns.h"
#include "AddTeachDlg.h"
#include "User.h"
#include "Course.h"
#include "TeacherBase.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTeachDlg dialog
CTeachDlg::CTeachDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTeachDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTeachDlg)
m_strCourseID = _T("");
m_strTchID = _T("");
//}}AFX_DATA_INIT
}
void CTeachDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTeachDlg)
DDX_Control(pDX, IDC_BUTTON_ADDTEACH, m_btnAdd);
DDX_Control(pDX, IDC_ADODC1, m_adodcTeach);
DDX_Control(pDX, IDC_DATAGRID1, m_datagridTeach);
DDX_Text(pDX, IDC_EDIT_COURSEID, m_strCourseID);
DDX_Text(pDX, IDC_EDIT_TCHID, m_strTchID);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTeachDlg, CDialog)
//{{AFX_MSG_MAP(CTeachDlg)
ON_BN_CLICKED(IDC_BUTTON_QUERY, OnButtonQuery)
ON_BN_CLICKED(IDC_BUTTON_ADDTEACH, OnButtonAddteach)
ON_BN_CLICKED(IDC_BUTTON_QUERYCOURSE, OnButtonQuerycourse)
// ON_EN_CHANGE(IDC_EDIT_COURSENAME, OnChangeEditCoursename)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTeachDlg message handlers
void CTeachDlg::ResetCol()
{
CColumns allCols;
CColumn onecol;
allCols=m_datagridTeach.GetColumns();
//设置各列标题和宽度
onecol=allCols.GetItem(COleVariant(long(0)));
onecol.SetCaption("编号");
onecol.SetWidth(50);
onecol=allCols.GetItem(COleVariant(long(1)));
onecol.SetCaption("教师编号");
onecol.SetWidth(50);
onecol=allCols.GetItem(COleVariant(long(2)));
onecol.SetCaption("课程编号");
onecol.SetWidth(50);
onecol=allCols.GetItem(COleVariant(long(3)));
onecol.SetCaption("开课学期");
onecol.SetWidth(70);
onecol=allCols.GetItem(COleVariant(long(4)));
onecol.SetCaption("上课班级");
onecol.SetWidth(70);
onecol=allCols.GetItem(COleVariant(long(5)));
onecol.SetCaption("周时数");
onecol.SetWidth(50);
onecol=allCols.GetItem(COleVariant(long(6)));
onecol.SetCaption("总时数");
onecol.SetWidth(50);
}
BOOL CTeachDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
ResetCol();
extern CUser curUser;
int type=curUser.GetUser_type();
if(type==2)
{
m_btnAdd.EnableWindow(FALSE);
m_datagridTeach.EnableWindow(FALSE);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CTeachDlg::OnButtonQuery()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
//如果没有该教师编号,给出提示
//使用TeacherBase类
if (m_strTchID.IsEmpty())
{
MessageBox("请输入教师编号!");
return;
}
CTeacherBase TchID;
if (TchID.HaveID(m_strTchID)<0)
{
MessageBox("该教师没代课!");
return;
}
CString strSQL;
strSQL.Format("select * from tbTeach where TchID='%s'",m_strTchID);
m_adodcTeach.SetRecordSource(strSQL);
m_adodcTeach.Refresh();
ResetCol();
}
void CTeachDlg::OnButtonAddteach()
{
// TODO: Add your control notification handler code here
CAddTeachDlg dlg;
//如果添加了记录,则刷新数据
if (dlg.DoModal()==IDOK)
{
m_adodcTeach.Refresh();
ResetCol();
}
}
void CTeachDlg::OnButtonQuerycourse()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if (m_strCourseID.IsEmpty())
{
MessageBox("请输入课程编号!");
return;
}
CString strSQL;
strSQL.Format("select * from tbTeach where TchID='%s'",m_strCourseID);
//如果没有该课程名,给出提示
CCourse TchID;
if (TchID.HaveID(m_strCourseID)<0)
{
MessageBox("该门课没开设!");
return;
}
m_adodcTeach.SetRecordSource(strSQL);
m_adodcTeach.Refresh();
ResetCol();
}
void CTeachDlg::OnChangeEditCoursename()
{
// 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
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -