📄 teacher_form.cpp
字号:
// teacher_form.cpp : implementation file
//
#include "stdafx.h"
#include "LMTS.h"
#include "teacher_form.h"
#include "student_db.h"
#include "teacher.h"
#include "edit_mark.h"
#include "change_pro.h"
#include "communicate.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// teacher_form dialog
teacher_form::teacher_form(CWnd* pParent /*=NULL*/)
: CDialog(teacher_form::IDD, pParent)
{
//{{AFX_DATA_INIT(teacher_form)
user_id=_T(""); // NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void teacher_form::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(teacher_form)
DDX_Text(pDX, IDC_EDIT1, user_id);
//DDX_Text(pDX, IDC_EDIT2, student_id);
DDX_Control(pDX, IDC_LIST1, show_teacher);// NOTE: the ClassWizard will add DDX and DDV calls here
DDX_Control(pDX, IDC_LIST2, show_class);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(teacher_form, CDialog)
//{{AFX_MSG_MAP(teacher_form)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// teacher_form message handlers
BOOL teacher_form::OnInitDialog()
{
CDialog::OnInitDialog();
show_teacher.SetTextColor(RGB(100,0,100));
show_teacher.SetTextBkColor(RGB(240,247,233));
show_teacher.InsertColumn(0,"科目");
show_teacher.InsertColumn(1,"学生");
show_teacher.InsertColumn(2,"分数");
show_teacher.SetColumnWidth(0,120);
show_teacher.SetColumnWidth(1,120);
show_teacher.SetColumnWidth(2,120);
show_teacher.SetExtendedStyle(LVS_EX_FULLROWSELECT| LVS_EX_GRIDLINES);
student_db stu_db;
teacher tea_db;
CString get_id,str1,str2;
GetDlgItem(IDC_EDIT1)->GetWindowText(get_id);
str1.Format("select * from teacher where name='%s'",get_id);
tea_db.Open(AFX_DB_USE_DEFAULT_TYPE,str1);
int i=0;
CString temp[100];
while(!tea_db.IsEOF())
{
temp[i]=tea_db.m_course;
show_class.InsertItem(i,tea_db.m_course);
tea_db.MoveNext();
i++;
}
int count=i;
i=0;
for(int j=0;j<count;j++)
{
str2.Format("select * from student where course='%s'",temp[j]);
stu_db.Open(AFX_DB_USE_DEFAULT_TYPE,str2);
while(!stu_db.IsEOF())
{
show_teacher.InsertItem(i,stu_db.m_course,0);
show_teacher.SetItemText(i,1,stu_db.m_name);
show_teacher.SetItemText(i,2,stu_db.m_mark);
i++;
stu_db.MoveNext();
}
stu_db.Close();
}
return TRUE;
}
void teacher_form::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void teacher_form::OnButton2()
{
change_pro chg_pro;
CString id;
GetDlgItem(IDC_EDIT1)->GetWindowText(id);
chg_pro.id=id;
chg_pro.DoModal();
// TODO: Add your control notification handler code here
}
void teacher_form::OnButton1()
{
communicate com_form;
CString sender_id;
GetDlgItem(IDC_EDIT1)->GetWindowText(sender_id);
com_form.sender=sender_id;
com_form.DoModal();
// TODO: Add your control notification handler code here
}
int select;
void teacher_form::OnButton3()
{
edit_mark edit_mark_form;
int i =show_teacher.GetSelectionMark();
select=i;
if(i==-1)
{
MessageBox("选择一项","!!",MB_OK|MB_ICONINFORMATION);
}
else{
CString student_name=show_teacher.GetItemText(i,1),str;
student_db edit_db;
str.Format("select * from student where name='%s'",student_name);
edit_db.Open(AFX_DB_USE_DEFAULT_TYPE,str);
edit_mark_form.name=edit_db.m_name;
edit_mark_form.course=edit_db.m_course;
edit_mark_form.mark=edit_db.m_mark;
edit_mark_form.DoModal();
// TODO: Add your control notification handler code here
}
}
void teacher_form::OnButton4()
{
show_teacher.DeleteAllItems();
student_db stu_db;
teacher tea_db;
CString get_id,str1,str2;
GetDlgItem(IDC_EDIT1)->GetWindowText(get_id);
str1.Format("select * from teacher where name='%s'",get_id);
tea_db.Open(AFX_DB_USE_DEFAULT_TYPE,str1);
int i=0;
CString temp[100];
while(!tea_db.IsEOF())
{
temp[i]=tea_db.m_course;
//show_class.InsertItem(i,tea_db.m_course);
tea_db.MoveNext();
i++;
}
int count=i;
i=0;
for(int j=0;j<count;j++)
{
str2.Format("select * from student where course='%s'",temp[j]);
stu_db.Open(AFX_DB_USE_DEFAULT_TYPE,str2);
while(!stu_db.IsEOF())
{
show_teacher.InsertItem(i,stu_db.m_course,0);
show_teacher.SetItemText(i,1,stu_db.m_name);
show_teacher.SetItemText(i,2,stu_db.m_mark);
i++;
stu_db.MoveNext();
}
stu_db.Close();
}
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -