📄 hsearch.cpp
字号:
// HSearch.cpp : implementation file
//
#include "stdafx.h"
#include "DATABASE.h"
#include "HSearch.h"
#include "AllSet.h"
#include "CjSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHSearch dialog
CHSearch::CHSearch(CWnd* pParent /*=NULL*/)
: CDialog(CHSearch::IDD, pParent)
{
//{{AFX_DATA_INIT(CHSearch)
m_stuid = _T("");
m_name = _T("");
m_profcode = _T("");
m_sex = _T("");
m_relation = _T("");
m_ave = 0.0f;
m_relation2 = _T("");
m_credit = 0.0f;
m_class = _T("");
m_native = _T("");
m_type = _T("");
m_year = 0;
//}}AFX_DATA_INIT
}
void CHSearch::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CHSearch)
DDX_Control(pDX, IDC_MSFLEXGRID1, m_MSFGrid);
DDX_Text(pDX, IDC_EDIT1, m_stuid);
DDX_Text(pDX, IDC_EDIT2, m_name);
DDX_Text(pDX, IDC_EDIT3, m_profcode);
DDX_CBString(pDX, IDC_COMBO1, m_sex);
DDX_CBString(pDX, IDC_COMBO3, m_relation);
DDX_Text(pDX, IDC_AVE, m_ave);
DDX_CBString(pDX, IDC_COMBO4, m_relation2);
DDX_Text(pDX, IDC_CREDIT, m_credit);
DDX_Text(pDX, IDC_CLASS, m_class);
DDX_Text(pDX, IDC_NATIVE, m_native);
DDX_Text(pDX, IDC_TYPE, m_type);
DDX_Text(pDX, IDC_reg, m_year);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CHSearch, CDialog)
//{{AFX_MSG_MAP(CHSearch)
ON_BN_CLICKED(IDC_SEARCH, OnSearch)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHSearch message handlers
BOOL CHSearch::OnInitDialog()
{
CDialog::OnInitDialog();
CAllSet m_pSet;
m_pSet.Open();
while(!m_pSet.IsEOF())
{
m_pSet.MoveNext();
m_pSet.GetRecordCount();
}
m_pSet.MoveFirst();
m_MSFGrid.SetCols(12);
m_MSFGrid.SetRows(1);
m_MSFGrid.SetColWidth(1,1000);
m_MSFGrid.SetColWidth(2,1100);
m_MSFGrid.SetColWidth(3,700);
m_MSFGrid.SetColWidth(4,1000);
m_MSFGrid.SetColWidth(5,3000);
m_MSFGrid.SetColWidth(6,1400);
m_MSFGrid.SetColWidth(7,1400);
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(1);
m_MSFGrid.SetText(" 学号");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(2);
m_MSFGrid.SetText(" 姓名");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(3);
m_MSFGrid.SetText("性别");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(4);
m_MSFGrid.SetText("专业代号");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(5);
m_MSFGrid.SetText(" 联系方式");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(6);
m_MSFGrid.SetText("加权平均分");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(7);
m_MSFGrid.SetText("选修课学分");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(8);
m_MSFGrid.SetText(" 班级");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(9);
m_MSFGrid.SetText(" 籍贯");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(10);
m_MSFGrid.SetText("注册类型");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(11);
m_MSFGrid.SetText("入学年份");
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CHSearch::OnSearch()
{
int iRow=1;
CAllSet m_pSet;
m_pSet.Open();
//cjSet.Open();
m_pSet.MoveFirst();
UpdateData(TRUE);
CString s1,s2,s3,s4,s5,s6,s7,s8,s9,s10;
if(m_stuid=="")
s1="1";
else
s1.Format("xs.stuid='%s'",m_stuid);
if(m_name=="")
s2="1";
else
s2.Format("name='%s'",m_name);
if(m_profcode=="")
s3="1";
else
s3.Format("profcode='%s'",m_profcode);
if(m_sex=="")
s4="1";
else
s4.Format("sex='%s'",m_sex);
if(m_class=="")
s5="1";
else
s5.Format("class='%s'",m_class);
if(m_native=="")
s6="1";
else
s6.Format("native='%s'",m_native);
if(m_year==0)
s7="1";
else
s7.Format("year=%d",m_year);
if(m_type=="")
s8="1";
else
s8.Format("type='%s'",m_type);
if(m_relation==""||m_ave==0)
s9="1";
else
s9.Format("cj.ave %s %f",m_relation,m_ave);
if(m_relation2==""||m_credit==0)
s10="1";
else
s10.Format("xx.credit %s %f",m_relation2,m_credit);
m_pSet.m_strFilter.Format("%s and %s and %s and %s and %s and %s and %s and %s and %s and %s and xs.stuid=xj.stuid and xs.stuid=xx.stuid and xs.stuid=cj.stuid",s1,s2,s3,s4,s5,s6,s7,s8,s9,s10);
m_pSet.Requery();
m_MSFGrid.Clear();
while(!m_pSet.IsEOF())
{
m_pSet.MoveNext();
m_pSet.GetRecordCount();
}
//m_MSFGrid.SetCols(m_pSet.m_nFields+1);
m_MSFGrid.SetRows(m_pSet.GetRecordCount()+2);
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(1);
m_MSFGrid.SetText(" 学号");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(2);
m_MSFGrid.SetText(" 姓名");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(3);
m_MSFGrid.SetText("性别");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(4);
m_MSFGrid.SetText("专业代号");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(5);
m_MSFGrid.SetText(" 联系方式");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(6);
m_MSFGrid.SetText("加权平均分");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(7);
m_MSFGrid.SetText("选修课学分");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(8);
m_MSFGrid.SetText(" 班级");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(9);
m_MSFGrid.SetText(" 籍贯");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(10);
m_MSFGrid.SetText("注册类型");
m_MSFGrid.SetRow(0);
m_MSFGrid.SetCol(11);
m_MSFGrid.SetText("入学年份");
m_pSet.Requery();
while(!m_pSet.IsEOF())
{
CString str;
str.Format("记录%d",iRow);
m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(0);
m_MSFGrid.SetText(str);
m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(1);
m_MSFGrid.SetText(m_pSet.m_stuid3);
m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(2);
m_MSFGrid.SetText(m_pSet.m_name);
m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(3);
m_MSFGrid.SetText(m_pSet.m_sex);
m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(4);
m_MSFGrid.SetText(m_pSet.m_profcode);
m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(5);
m_MSFGrid.SetText(m_pSet.m_address);
m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(6);
str.Format("%f",m_pSet.m_ave);
m_MSFGrid.SetText(str);
m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(7);
str.Format("%f",m_pSet.m_credit);
m_MSFGrid.SetText(str);
m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(8);
m_MSFGrid.SetText(m_pSet.m_class);
m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(9);
m_MSFGrid.SetText(m_pSet.m_native);
m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(10);
m_MSFGrid.SetText(m_pSet.m_type);
m_MSFGrid.SetRow(iRow);m_MSFGrid.SetCol(11);
str.Format("%d",m_pSet.m_year);
m_MSFGrid.SetText(str);
iRow++;
if(!m_pSet.IsEOF())m_pSet.MoveNext();
}
m_MSFGrid.SetRow(1);
m_MSFGrid.SetCol(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -