A simple student score management software (ODBC development)

xiaoxiao2021-03-06  62

A simple student score management software (ODBC development) download this article attached to the code

Screenshot of the program operation: I have written a "a perfect ODBC database program", everyone may have seen, encourage, and criticism, but all this is only one purpose is to learn VC. I have learned that VC has been close to a year, the horizontal rookie, and the VC knowledge base provides you with a place where exchanges, everyone study together, and improves together. Thanks to VC Knowledge Base Various version of the master! ! ! In the "a perfect ODBC database program" I mentioned many aspects of it, be a small software. I made some basic functions according to this idea. The program is divided into two parts by dialog box, and the interface is divided into two parts: "Class Grade" and "Grade Grade". The program interface is as shown in the figure: First introduce it: 1. When "Class Grade Results", first choose the class, here I only achieve two class management. Press the start button, three list boxes display three record sets of the selected class. The "Start" button is forbidden, and the buttons for the rest of the record set are allowed. Enhance records, delete records, modify records, search records, and record sorting functions. Sort in search records and recordings than before the previous perfect place. Search can be in multi-middle, and sort by clicking on the list header, can be sorted in ascending order and descending, each column can be sorted. Because of the multi-record set, there is a lot of trouble in the functionality, you can see the source program. After you have seen it, you may feel that the list of subjects, the teacher list is more easily implemented, because they record a limited number, fixed. The reason why I use the database, I want to learn ODBC, master multi-record set programming. Increase records, delete records, modified records are the same as previous ideas, but because changes in students' grades have caused changes in subject grades, everyone will look at the process in the source program. Let's take a look at the search record and record sorting.

Search record 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 (" No qualified record "); m_set.close ); return;} else this-> Show ();}} sorting records 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 2 (m_set.isopen ()) m_set.close (); this-> select (); m_bset.close (); CODBCFIELDINFO FIELDINFO; M_SET.GETO DBCFieldInfo (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 ( ); } 2. Select the "grade level", first select "All Records", the whole grade is displayed. At this time, the lowermost "display button" is forbidden to cancel, press, and the level of the grade is displayed. Here is "All Records" and "Show Record".

All record void cnadilarog :: onall () {// Todo: add your control notification handler code here if (m_set.isopen ()) m_set.close (); m_listctrlx.deleteallItems (); m_set.m_strfilter.empty (); m_set .Open (); m_nrecordcount = this-> show (); m_set.open (AFX_DB_USE_DEFAULT_TYPE, "[NO2STUDENT]"); m_nrecordcount = this-> show (); cstring s; s.format ("% d", m_nrecordcount) Getdlgitem (IDC_STATICALL) -> setWindowText (s); getdlgitem (idc_show) -> EnableWindow (TRUE);} where show () is used to be displayed in the list, as follows: int Cnadilaalog :: show () {INT K = 0; Do {cstring s; s.format ("% d", m_set.m_column1); m_listctrlx.insertitem (k, s, 0); m_listctrlx.setitemtext (k, 1, m_set.m_column2); s.format ("%. 1f ", m_set.m_column3); M_ListCtrlx.SetItemText (k, 2, s); s.format ("%. 1f ", m_set.m_column4); m_listctrlx.setItemText (k, 3, s); s.format (" % .1f ", m_set.m_column5); M_ListCtrlx.SetItemText (k, 4, s); s.format ("%. 1f ", m_set.m_column6); M_ListCtrlx.SetItemText (k, 5, s); s.Format ("% .1f", m_set.m_column7); m_listctrlx.setitemtext (k, 6, s); s.format ("%. 1f", m_set.m_column8); M_ListCtrlx.SetItemText (k, 7, s); s.format ("%. 2f", m_set.m_column9); m_listctrlx.setItemtemtext (k, 8, s); k ; m_set.movenext ();} while (! m_set) .Iseof ()); m_set.close (); Return K;} Display record void cnadilaalog :: onshow () {// Todo: add your control notification handler code herE m_listctrlj.deleteallItems (); cstring s; m_bset.open ); INT i = 0; m_bset.movefirst (); do {m_listctrlj.insertitem (i, m_bset.m_column1 ,0); i ; m_bset.movenext ();} while (! M_bset.iseof ()); m_bset.movefirst (); For (i = 0; i <= 4; i ) {score [i] [1] = m_bset.m_column2; score [i] [3] =

转载请注明原文地址:https://www.9cbs.com/read-84622.html

New Post(0)