?? markview.cpp
字號:
// markView.cpp : implementation file
//
#include "stdafx.h"
#include "biyesheji.h"
#include "markView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CmarkView
IMPLEMENT_DYNCREATE(CmarkView, CRecordView)
CmarkView::CmarkView()
: CRecordView(CmarkView::IDD)
{
//{{AFX_DATA_INIT(CmarkView)
m_pSet = NULL;
m_cgxuehao = 0;
m_kemu = _T("");
m_class = _T("");
m_avle = 0;
//}}AFX_DATA_INIT
}
CmarkView::~CmarkView()
{
((CBiyeshejiApp*)AfxGetApp())->m_cmarkviews=0;//啟用菜單 允許打開新窗口
if (m_pSet)
delete m_pSet;
}
void CmarkView::DoDataExchange(CDataExchange* pDX)
{
CRecordView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CmarkView)
DDX_Control(pDX, IDC_EDIT8, m_objyx);
DDX_Control(pDX, IDC_EDIT7, m_objlh);
DDX_Control(pDX, IDC_EDIT6, m_objnopass);
DDX_Control(pDX, IDC_EDIT5, m_objavle);
DDX_Control(pDX, IDC_EDIT4, m_objclass);
DDX_Control(pDX, IDC_EDIT3, m_objkemu);
DDX_Control(pDX, IDC_EDIT2, m_objxuehao);
DDX_Control(pDX, IDC_LIST2, m_Grid2);
DDX_Control(pDX, IDC_LIST1, m_Grid1);
DDX_Text(pDX, IDC_EDIT2, m_cgxuehao);
DDX_Text(pDX, IDC_EDIT3, m_kemu);
DDX_Text(pDX, IDC_EDIT4, m_class);
DDX_Text(pDX, IDC_EDIT5, m_avle);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CmarkView, CRecordView)
//{{AFX_MSG_MAP(CmarkView)
ON_BN_CLICKED(IDC_CHAXUN1, OnChaxun1)
ON_BN_CLICKED(IDC_CHAXUN2, OnChaxun2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CmarkView diagnostics
#ifdef _DEBUG
void CmarkView::AssertValid() const
{
CRecordView::AssertValid();
}
void CmarkView::Dump(CDumpContext& dc) const
{
CRecordView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CmarkView message handlers
CRecordset* CmarkView::OnGetRecordset()
{
if (m_pSet != NULL)
return m_pSet;
m_pSet = new CmarkSet(NULL);
m_pSet->Open();
return m_pSet;
}
CmarkSet* CmarkView::GetRecordset()
{
CmarkSet* pData = (CmarkSet*) OnGetRecordset();
ASSERT(pData == NULL || pData->IsKindOf(RUNTIME_CLASS(CmarkSet)));
return pData;
}
void CmarkView::OnInitialUpdate()
{
BeginWaitCursor();
GetRecordset();
CRecordView::OnInitialUpdate();
CODBCFieldInfo DbFi;
LV_COLUMN m_Lc;
m_Lc.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
m_Grid1.DeleteAllItems();
m_Grid1.InsertColumn(0,"學號",LVCFMT_CENTER,60);
m_Grid1.InsertColumn(1,"課程",LVCFMT_CENTER,80);
m_Grid1.InsertColumn(2,"成績",LVCFMT_CENTER,60);
m_Grid2.DeleteAllItems();
m_Grid2.InsertColumn(0,"學號",LVCFMT_CENTER,60);
m_Grid2.InsertColumn(1,"課程",LVCFMT_CENTER,60);
m_Grid2.InsertColumn(2,"成績",LVCFMT_CENTER,60);
if (m_pSet->IsOpen())
{
CString strTitle = m_pSet->m_pDatabase->GetDatabaseName();
CString strTable = m_pSet->GetTableName();
if (!strTable.IsEmpty())
strTitle += _T(":") + strTable;
GetDocument()->SetTitle(strTitle);
}
EndWaitCursor();
}
//int a=0;
void CmarkView::OnChaxun1()
{
CString cstr1;
m_Grid1.DeleteAllItems();
int i=0,j=0,ab=0,abcd=0;
char chr2[10];
CString string;
UpdateData(TRUE);
LV_ITEM m_item;
int ab1;
m_objxuehao.GetWindowText(cstr1);
ab1=atoi(cstr1);
if(ab1==0)
{MessageBox("請輸入查詢條件");}
else
{
while(m_pSet->IsEOF()==0)
{
if(m_pSet->m_stuid!=m_cgxuehao)
{
m_pSet->MoveNext();
}
else
{
abcd++;
ab=ab+m_pSet->m_mark;
m_item.mask=LVIF_TEXT;
m_item.iItem=i;
m_item.iSubItem=0;
m_pSet->GetFieldValue((short)0,string);
m_item.pszText=string.GetBuffer(string.GetLength());
m_Grid1.InsertItem(&m_item);//插入條目
//顯示列數據
for(j=1;j<m_pSet->m_nFields;j++)
{
m_pSet->GetFieldValue((short)j,string);
m_Grid1.SetItemText(i,j,string.GetBuffer(string.GetLength()));
}
m_pSet->MoveNext();//下移記錄
i++;
}
UpdateData(FALSE);
}
}
if(abcd!=0)
{
itoa(ab/abcd,chr2,10);
m_objavle.SetWindowText(chr2);
}
else
{MessageBox("沒有找到相關記錄");}
m_pSet->MoveFirst();
}
void CmarkView::OnChaxun2()
{
m_Grid2.DeleteAllItems();
int a=0,b=0,xy1=0,xy2=0,xy3=0,xy4=0,xy5=0;
CString string1;
char cha2[10],cha3[10],cha4[10],cha5[10];
//int a=0;
UpdateData(TRUE);
LV_ITEM m_item;
m_pSet->MoveFirst();
CString cstr;
m_objkemu.GetWindowText(cstr);
if(cstr=="")
{MessageBox("請輸入查詢條件");}
else{
while(m_pSet->IsEOF()==0)
{
if(m_pSet->m_couname!=m_kemu)
{
m_pSet->MoveNext();
}
else
{
xy1++;//年級總人數
xy2=xy2+m_pSet->m_mark;//年級科目總分數
if(m_pSet->m_mark<60 )
{xy3++;}//不及格人數
if(m_pSet->m_mark>70 )
{xy4++;}//良好人數
if(m_pSet->m_mark>90)
{xy5++;}//優秀人數
m_item.mask=LVIF_TEXT;
m_item.iItem=a;
m_item.iSubItem=0;
m_pSet->GetFieldValue((short)0,string1);
m_item.pszText=string1.GetBuffer(string1.GetLength());
m_Grid2.InsertItem(&m_item);//插入條目
//顯示列數據
for(b=1;b<m_pSet->m_nFields;b++)
{
m_pSet->GetFieldValue((short)b,string1);
m_Grid2.SetItemText(a,b,string1.GetBuffer(string1.GetLength()));
}
m_pSet->MoveNext();//下移記錄
a++;
}
UpdateData(FALSE);
}
if(xy1!=0)
{
itoa(xy2/xy1,cha2,10);
itoa(xy3,cha3,10);
itoa(xy4,cha4,10);
itoa(xy5,cha5,10);
m_objavle.SetWindowText(cha2);
m_objnopass.SetWindowText(cha3);
m_objlh.SetWindowText(cha4);
m_objyx.SetWindowText(cha5);
}
else
{MessageBox("沒有找到相關記錄");}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -