Working Assistant--Data Read implementation function
1) The user can choose to obtain information about all the courses that have been taken since admission: Course code, course name, course attributes, credits, scores, etc.
2) The user can choose to obtain the relevant information of a specific course: Course code, course name, course attributes, credits, scores, etc.
3) The user can obtain a weighted average (1 semesters, 1 academic year, all) within a specific time period.
Team members
13070003 Sail
13070046 Sun Yuchen
13070004 Cui Wei
13070006 Wang Nai
13070002 sheets of rain sail
13070045 Wang Tianmi
Data read-In
In the last blog, I talked about my work is data processing, in this module, mainly divided into three parts, data reading, query data and Weighted average division calculation. Considering that there is only one user involved in handling the data after each user login, there is no need to instantiate the class for the processing, so I will design it as a static class to handle.
In the Python side, I saved the acquired data to Excel, so I first read the data from Excel to the DataTable defined in the class, and the code is implemented as follows:
1 #region----------Read Data----------2 /// <summary>3 ///reading score data from Excel, results deposited Gradeset, success sign Hasloaddata4 /// </summary>5 Public Static voidLoaddatafromexcel ()6 {7 Try8 {9 stringstrconn;Tenstrconn ="Provider=Microsoft.Jet.OLEDB.4.0;Data source="+ FilePath +"; Extended properties= ' Excel 8.0; Hdr=false;imex=1 '"; OneOleDbConnection oleconn =NewOleDbConnection (strconn); A Oleconn.open (); -String sql ="SELECT * FROM ["+sheetname+"$]"; - theOleDbDataAdapter oledaexcel =NewOleDbDataAdapter (SQL, oleconn); -Gradestable =NewDataTable (); -DataSet ds =NewDataSet (); -Oledaexcel.fill (DS,"Gradesheet"); + oleconn.close (); -Gradestable = ds. tables[0]; +Hasloaddata =true; A return; at } - Catch(Exception Err) - { - MessageBox.Show (Err. Message); - //Console.WriteLine ("{0}", err. Message); -Hasloaddata =false; in return; - } to } + #endregion
In this code, oleconn establishes the C # connection to the Excel file, and then defines the SQL statement to read the data in the table named SheetName in Excel into the OleDbDataAdapter object. The data is then stored in the gradestable of the defined DataTable object. As a result of learning this part of the content of the DataTable found such a good thing, so save a lot of follow-up work. A lot of methods are encapsulated in the DataTable class, so it is very convenient to operate them.
Work Assistant--data read