A simple student performance management Software (ODBC development)

Source: Internet
Author: User
Tags odbc sort knowledge base

Before I wrote a "Perfect ODBC database program", we may have seen, there are encouragement, there are criticisms, but all of this only one purpose is to learn VC. I have been learning VC has nearly a year of time, level rookie level, and the VC knowledge Base for everyone to provide a place to communicate, we learn from each other and improve together. Thanks VC Knowledge Base each edition moderator!!!

In "A Perfect ODBC database program" I mentioned many aspects of perfecting it, making a small software. I follow this way of thinking, to achieve a number of basic functions. The Program adopts dialog box, the interface is divided into two parts by the way of property page: "Class Grade" and "Grade Score".

The program interface is shown below:

Let's first describe its use:

1. Select "Class Results", first select the class, here I have only achieved two class management. Press the Start button and the three list boxes show three recordsets for the selected class. The Start button is disabled, and the rest of the button on the recordset operation is allowed. To achieve the addition of records, delete records, modify records, search records, record sorting function. Better than before the place is mainly in the search records, record sorting. The lookup can be in multiple cases, and the sort is implemented by clicking the list header, in ascending and descending order, each column can be sorted. Because of the use of multiple recordsets, so in the implementation of the function of a lot of trouble, we can see the source program. After you've seen it, you may feel that the list of classes and teacher lists is easier to implement with files or arrays because they have a limited number of records and are fixed. I use the database, is to learn ODBC, master multiple recordset programming. Add records, delete records, change the record with the same idea, just because of the changes in student performance list caused by changes in the subject, everyone in the source program to see the process. Here is a look at Search records and record sorting.

Search Records

void CBaDialog::OnFind()
{
  // TODO: Add your control notification handler code here
CFinDialog dlg;
if( dlg.DoModal()==IDOK)
{
this->Select();
m_bSet.Close();
if(dlg.m_Getstring2==">=")
m_Set.m_strFilter.Format("[%s]>=%.2f",dlg.m_Getstring1,dlg.m_find);
if(dlg.m_Getstring2=="=")
m_Set.m_strFilter.Format("[%s]=%.2f",dlg.m_Getstring1,dlg.m_find);
if(dlg.m_Getstring2=="<=")
m_Set.m_strFilter.Format("[%s]<=%.2f",dlg.m_Getstring1,dlg.m_find);
m_ListCtrlx.DeleteAllItems();
m_Set.Requery();
if(m_Set.IsEOF())
{
AfxMessageBox("没有符合条件的记录");
m_Set.Close();
return ;
}
else
this->Show();
}
}

Record sorting

void CBaDialog::OnColumnclickList3(NMHDR* pNMHDR, LRESULT* pResult)
{
  NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  if(FALSE== m_bS)
  {
   int k= pNMListView->iSubItem;
   Sort(!m_bIsAsc,k);
   m_ListCtrlx.DeleteAllItems();
   this->Show();
  }
  *pResult = 0;
}
void CBaDialog::Sort(BOOL isAsc,int secol)
{ 
  if(m_Set.IsOpen())
   m_Set.Close();
  this->Select();
  m_bSet.Close();
  CODBCFieldInfo fieldInfo;
  m_Set.GetODBCFieldInfo(secol,fieldInfo);
  if(isAsc)
  {
    m_Set.m_strSort=fieldInfo.m_strName+" ASC";
    m_bIsAsc=TRUE;
  }
  else
  {
    m_Set.m_strSort=fieldInfo.m_strName+" DESC";
    m_bIsAsc=FALSE;
  }
  m_Set.Requery();  
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.