📄 student_form.cpp
字号:
// student_form.cpp : implementation file
//
#include "stdafx.h"
#include "LMTS.h"
#include "LMTSDlg.h"
#include "student_form.h"
#include "student_db.h"
#include "teacher.h"
#include "user.h"
#include "communicate.h"
#include "change_pro.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// student_form dialog
student_form::student_form(CWnd* pParent /*=NULL*/)
: CDialog(student_form::IDD, pParent)
{
//{{AFX_DATA_INIT(student_form)
user_id=_T(""); // NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void student_form::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(student_form)
DDX_Text(pDX, IDC_EDIT1, user_id);
DDX_Control(pDX, IDC_LIST1, student_mark);
DDX_Control(pDX,IDC_LIST2,show_class);
DDX_Control(pDX,IDC_LIST3,show_select);// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
void student_form::OnButton3()
{
CString id;
GetDlgItem(IDC_EDIT1)->GetWindowText(id);
int i;
i=show_class.GetSelectedCount();
CString sel_class=show_class.GetItemText(i,0);
if(i!=-1){
student_db count_student,sel_student(&stc);//define a function
CString str,strSQL,str1;
str.Format("select * from student");
count_student.Open(AFX_DB_USE_DEFAULT_TYPE,str);
if(count_student.GetRecordCount()!=0){
count_student.MoveLast();
int j=count_student.m_column1+1;
str1.Format("select * from student");
sel_student.Open(AFX_DB_USE_DEFAULT_TYPE,str1);
strSQL.Format("insert into student values(%d,'%s','%s','%s','%s')",j,id,sel_class,"","");//,input_psw,"no");
AfxMessageBox("欢迎使用LTMS");
stc.ExecuteSQL(strSQL);
/**/
} count_student.Close();
stc.Close();
}
// TODO: Add your control notification handler code here
}
BOOL student_form::OnInitDialog()
{
CDialog::OnInitDialog();
student_mark.SetTextColor(RGB(100,0,100));
student_mark.SetTextBkColor(RGB(240,247,233));
student_mark.InsertColumn(0,"科目");
student_mark.InsertColumn(1,"分数");
show_select.InsertColumn(0,"已选科目");
show_select.SetExtendedStyle(LVS_EX_FULLROWSELECT| LVS_EX_GRIDLINES);
show_select.SetColumnWidth(0,90);
show_class.InsertColumn(0,"所有科目");
show_class.SetExtendedStyle(LVS_EX_FULLROWSELECT| LVS_EX_GRIDLINES);
show_class.SetColumnWidth(0,75);
student_mark.SetColumnWidth(0,150);
student_mark.SetColumnWidth(1,200);
student_mark.SetExtendedStyle(LVS_EX_FULLROWSELECT| LVS_EX_GRIDLINES);
student_db stu_db;
CString get_id,str;
GetDlgItem(IDC_EDIT1)->GetWindowText(get_id);
str.Format("select * from student where name='%s'",get_id);
stu_db.Open(AFX_DB_USE_DEFAULT_TYPE,str);
int i=0;
while(!stu_db.IsEOF())
{
student_mark.InsertItem(i,stu_db.m_course,0);
show_select.InsertItem(i,stu_db.m_course,0);
student_mark.SetItemText(i,1,stu_db.m_mark);
stu_db.MoveNext();
i++;
}
teacher tea_db;
CString str1;
str1.Format("select * from teacher",str1);
tea_db.Open(AFX_DB_USE_DEFAULT_TYPE,str1);
i=0;
while(!tea_db.IsEOF())
{
show_class.InsertItem(i,tea_db.m_course,0);
tea_db.MoveNext();
i++;
}
stu_db.Close();
tea_db.Close();
return TRUE;
}
BEGIN_MESSAGE_MAP(student_form, CDialog)
//{{AFX_MSG_MAP(student_form)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// student_form message handlers
void student_form::OnButton1()
{
change_pro chg_pro;
//CDialog::OnOK();
CString id;
GetDlgItem(IDC_EDIT1)->GetWindowText(id);
chg_pro.id=id;
chg_pro.DoModal();
// TODO: Add your control notification handler code here
}
void student_form::OnOK()
{
// TODO: Add extra validation here
CDialog::OnOK();
}
void student_form::OnButton2()
{
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
}
void student_form::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -