There are hundreds of records in the curriculum of our Language Learning Lab every semester and every record has several important properties. It takes too much time to manage the information in the traditional way and it always makes mistakes. Managing the information with database technology, designing program to access the database with Visual c tool, setting a combobox in the application UI and inquiring curriculum information by selecting the room name in the combobox. It is easy to operate the program for the staff members. The result is accurate, this way promotes the efficiency of managing information.
Foreign language is an important course for college students and all the freshmen need to study language course in learning center. There are more than 200 language courses in learning center every semester. Every course includes day of the week, lesson time, room, teacher, lesson name, class name. We got the excel file includes course information from the office of academic affairs at the beginning of the semester. We can see the
Lab technicians get the course information. They need to order the informa-
tion by day of the week, lesson time, room number and then they can use it conveniently. It takes 1 day to order the hundreds of records manually. The paper applies database technology [
When we sort the course records of the learning center, we can know the room which is available sometime. We can maintain the equipment of the room in the vacant time, so query function is very important.
Introduction of SQL sentence [
SELECT column name FROM table name. We can add other condition, such as where, order by [
Example of SELECT sentence (query course information of room 505 and order by day of week).
Select sentence is as follows. SELECT * FROM room where 教室 = “教5楼505” order by 星期asc. Select is query. Room is the table name, 教室、星期is the attribute of the table. The data is order by day of week ascending. The result is shown as
In
column for Monday shows “第3, 4节”, “第1, 2节”, “第9 - 11节”, “第5, 6节”, “第7, 8节”. The information is unordered. It is used inconveniently.
Example of SELECT sentence (course records query of room 505 and order by day of week, lesson), SELECT sentence is as follows.
SELECT * FROM room where 教室 = “教5楼505” order by 星期, 节次asc “Order by星期,节次asc” [
In
When a teacher wants to change a room, the technician needs to know the vacant room at a time. We need to query the course records order by “星期、节次、教室号”. The SQL sentence is as follows. SELECT * FROM room order by 星期,节次, 教室asc. The result is shown as
When we use the SQL sentence, we can see which room is occupied at a time, and the records are sorted by day of week, lesson time, room. It’s very convenient to modify the course information. If a room is vacant at a time, a teacher can add a lesson in the room.
We can query data in database and it is very efficient. When lab technician wants to use it easily, we need to design software with MFC structure. The paper design an MFC program to query the course database, and it is easily for lab technician to operate [
Visual studio is a developing toolkit and is a developing environment pushed out by Microsoft Company. We design the program with MFC library. MFC means Microsoft Foundation Classes. When we create an MFC project, the project will generate 4 classes [
CDocument: it is a document class [
We add a combobox in the toolbar. The combox accesses the database and gets the course information. When the program is initiated, it adds the room number in the combobox. The user doesn’t need to type the room number.
CStringsel = “SELECT 教室 FROM room group by 教室”. The SQL sentence can query the room number and the records of same room number can generate one room number. The number is sorted.
The variable frame is the pointer of Mainframe in view class, frame->m_wndToolBar.m_combo_room. AddString (strRoom). Add the room number in the combobox, room number is queried form database. strRoom is the room number from database.
When user chooses room number, the room number will be the variable m_strobj Room. The program will operate invalidate (TRUE) to call the On Draw function, then the visual region will be refreshed [
1) Opening database
_ConnectionPtr m_pConnection; Define the variable to connect the database.
m_pConnection->Open(“Provider = Microsoft.Jet.OLEDB.4.0;Data Source = room.mdb”,”“,”“,adModeUnknown);
The second parameter DataSource is the database name.
(2) Generatingsqlsentenceautomatically according the user’s demand.
if(strcmp(m_strobjRoom,”全部”)==0)
{
sel.Format(“SELECT * FROM room order by 星期, 节次, 教室”);
}
else
{
sel.Format(“SELECT * FROM room where 教室=‘%s’ order by 星期,节次 “,m_strobjRoom);
}
According the user’s choice the program generates the SQL sentence. If the user chooses all the room, we query all the room in the course database. If the user chooses one room, the program generates the SQL sentence to query the course information for the room. The variable m_strobjRoom is the selected room number. When the user chooses all the room, the program generate the first SQL sentence. When the user chooses one room, the program generates the second SQL sentence.
3) Query data from the database and get result.
_RecordsetPtrm_pRecordset; Define the variable to receive data
m_pRecordset.CreateInstance(__uuidof(Recordset));
m_pRecordset->Open(_bstr_t(sel), //sel is the SQL sentence.
m_pConnection.GetInterfacePtr(), //get the database connection pointer
adOpenDynamic,
adLockOptimistic,
adCmdText);
Through opening operation, we can get result in variable m_pRecordset.
4) Traverse all the record
m_pRecordset->MoveNext(), move tothe next record.
m_pRecordset->adoEOF. The function checks whether the record is the last one. It always used in while circulation to traverse data [
There is a function called on draw in view class. The result is shown with the function. In order to make it easy to be found for user, the record in a day of week is set a color. For example the data of Monday is green, Tuesday is red.
pDC->SetTextColor(RGB(255,0,0)). The function set text color can set color for data. The value in RGB is different then the color is different.
pDC->TextOut(ptorigin.x+xnstep1,ptorigin.y,strClass). The function prints the records in the view. The variable ptorigin is the origin point. When the next record is shown, ptorigin. y is added a step length. When we traverse the data, all the records are shown in the view with different color.
The program includes several steps.
1) The program initiates MFC frame and generates the mainframe and the view.
2) The program Accesses the database and gets the course information. It adds the room number in the combobox.
3) The user chooses the choice in the combobox. The program generates SQL sentence.
4) The program opens the Room database, queries the information and gets result.
5) The result is shown in the view. The record’s color of different day is different. Close the database. If the user continues to query, go to step 3.
The flow chart is shown as
The program’s interface and the result is shown as
We design a program to access database with Visual studio; it can manage the course information efficiently. When the program query the database, the query time is less than 1 second (the count of records is several hundred). It is more convenient than the traditional way. The course information’s color is different, so we can find information easily. The user doesn’t need to study the database knowledge and SQL sentence. It can run in OS win 7 win 10 and so on. It solves
the problem efficiently. The program is appropriate for managing curriculum for the office of academic affairs.
The paper is supported by China University of Geosciences (Beijing) basic research funding (2-9-2017-096).
Mao, W., Chen, T. and Jiang, Y. (2017) Database Development Based on MFC Application in Management of Curriculum Information. Intelligent Information Management, 9, 236-244. https://doi.org/10.4236/iim.2017.96013