📄 teacherbasedlg.cpp
字号:
// TeacherBaseDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TeacherMIS.h"
#include "TeacherBaseDlg.h"
#include "column.h"
#include "columns.h"
#include "AddTeacherBaseDlg.h"
#include "User.h"
#include "TeacherBase.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTeacherBaseDlg dialog
CTeacherBaseDlg::CTeacherBaseDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTeacherBaseDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTeacherBaseDlg)
m_strName = _T("");
m_strID = _T("");
//}}AFX_DATA_INIT
}
void CTeacherBaseDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTeacherBaseDlg)
DDX_Control(pDX, IDC_BUTTON_IDQUERTY, m_btnIDQuery);
DDX_Control(pDX, IDC_BUTTON_QUERY, m_btnQuery);
DDX_Control(pDX, IDC_BUTTON_ADDTCHBASE, m_btnAdd);
DDX_Control(pDX, IDC_ADODC1, m_adodcTch);
DDX_Control(pDX, IDC_DATAGRID1, m_datagridTch);
DDX_Text(pDX, IDC_EDIT_NAME, m_strName);
DDX_Text(pDX, IDC_EDIT_TCHID, m_strID);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTeacherBaseDlg, CDialog)
//{{AFX_MSG_MAP(CTeacherBaseDlg)
ON_BN_CLICKED(IDC_BUTTON_QUERY, OnButtonQuery)
ON_BN_CLICKED(IDC_BUTTON_ADDTCHBASE, OnButtonAddtchbase)
ON_BN_CLICKED(IDC_BUTTON_IDQUERTY, OnButtonIdquerty)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTeacherBaseDlg message handlers
void CTeacherBaseDlg::ResetCol()
{
CColumns allCols;
CColumn onecol;
allCols=m_datagridTch.GetColumns();
//设置各列标题和宽度
onecol=allCols.GetItem(COleVariant(long(0)));
onecol.SetCaption("教师编号");
onecol.SetWidth(40);
onecol=allCols.GetItem(COleVariant(long(1)));
onecol.SetCaption("姓名");
onecol.SetWidth(50);
onecol=allCols.GetItem(COleVariant(long(2)));
onecol.SetCaption("性别");
onecol.SetWidth(30);
onecol=allCols.GetItem(COleVariant(long(3)));
onecol.SetCaption("出生日期");
onecol.SetWidth(70);
onecol=allCols.GetItem(COleVariant(long(4)));
onecol.SetCaption("民族");
onecol.SetWidth(30);
onecol=allCols.GetItem(COleVariant(long(5)));
onecol.SetCaption("政治面貌");
onecol.SetWidth(60);
onecol=allCols.GetItem(COleVariant(long(6)));
onecol.SetCaption("籍贯");
onecol.SetWidth(50);
onecol=allCols.GetItem(COleVariant(long(7)));
onecol.SetCaption("职称");
onecol.SetWidth(50);
onecol=allCols.GetItem(COleVariant(long(8)));
onecol.SetCaption("所学专业");
onecol.SetWidth(80);
onecol=allCols.GetItem(COleVariant(long(9)));
onecol.SetCaption("学历");
onecol.SetWidth(60);
onecol=allCols.GetItem(COleVariant(long(10)));
onecol.SetCaption("毕业学校");
onecol.SetWidth(100);
onecol=allCols.GetItem(COleVariant(long(11)));
onecol.SetCaption("婚姻状况");
onecol.SetWidth(40);
onecol=allCols.GetItem(COleVariant(long(12)));
onecol.SetCaption("教师类别");
onecol.SetWidth(50);
onecol=allCols.GetItem(COleVariant(long(13)));
onecol.SetCaption("办公电话");
onecol.SetWidth(100);
onecol=allCols.GetItem(COleVariant(long(14)));
onecol.SetCaption("手机号码");
onecol.SetWidth(80);
onecol=allCols.GetItem(COleVariant(long(15)));
onecol.SetCaption("家庭住址");
onecol.SetWidth(150);
onecol=allCols.GetItem(COleVariant(long(16)));
onecol.SetCaption("邮编");
onecol.SetWidth(50);
onecol=allCols.GetItem(COleVariant(long(17)));
onecol.SetCaption("电子邮箱");
onecol.SetWidth(120);
}
BOOL CTeacherBaseDlg::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_datagridTch.EnableWindow(FALSE);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CTeacherBaseDlg::OnButtonQuery()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if (m_strName.IsEmpty())
{
MessageBox("请输入教师姓名!");
return;
}
CString strSQL="select * from tbTeacherBase where Name like'%"+m_strName+"%'";
//如果没有该教师名,给出提示
//使用TeacherBase类
CTeacherBase name;
if (name.HaveName(m_strName)<0)
{
MessageBox("该教师不存在!");
return;
}
m_adodcTch.SetRecordSource(strSQL);
m_adodcTch.Refresh();
ResetCol();
}
void CTeacherBaseDlg::OnButtonAddtchbase()
{
// TODO: Add your control notification handler code here
CAddTeacherBaseDlg dlg;
//如果添加了记录,则刷新数据
if (dlg.DoModal()==IDOK)
{
m_adodcTch.Refresh();
ResetCol();
}
}
void CTeacherBaseDlg::OnButtonIdquerty()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if (m_strID.IsEmpty())
{
MessageBox("请输入教师编号!");
return;
}
// CString strSQL="select * from tbTeacherBase where TchID like'%"+m_strID+"%'";
CString strSQL;
strSQL.Format("select * from tbTeacherBase where TchID='%s'",m_strID);
//如果没有该教师编号,给出提示
//使用TeacherBase类
CTeacherBase TchID;
if (TchID.HaveID(m_strID)<0)
{
MessageBox("该教师不存在!");
return;
}
m_adodcTch.SetRecordSource(strSQL);
m_adodcTch.Refresh();
ResetCol();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -