private void Static_Course_Load(object sender, EventArgs e) { Courses course = new Courses(); // Course_Chart Course_Chart.Series.RemoveAt(0); var data = course.GetAvgScoreByCourse(); if (data.Rows.Count < 1) { XtraMessageBox.Show("No score infomation!"); return; } Course_Chart.DataSource = data; var seri = Course_Chart.Series.Add("Average Score"); seri.XValueMember = "label"; seri.YValueMembers = "AverageGrade"; seri.IsValueShownAsLabel = true; Course_Chart.Titles.Add("Average Score"); //passFail_chart Scores score = new Scores(); Students student = new Students(); double total = Convert.ToDouble(student.TotalStudent()); int pass = score.GetPassNumber(); int fail = score.GetFailNumber(); int Total = pass + fail; Label_Total.Text = "Total: " + Total; Label_Pass.Text = "Pass: "******" (" + (pass * 100 / Total) + ")%"; Label_fail.Text = "Fail: " + fail + " (" + (pass * 100 / Total) + ")%"; ResultChart.Series.RemoveAt(0); seri = ResultChart.Series.Add("Average Score"); seri.Points.AddXY("Pass", (Math.Truncate(pass * 100.0) / total)); seri.Points.AddXY("Fail", (Math.Truncate(fail * 100.0) / total)); seri.IsValueShownAsLabel = true; seri.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie; ResultChart.Titles.Add("Academic Statistics"); }
private void Add_bt_Click(object sender, EventArgs e) { try { Scores score = new Scores(); int sid = Convert.ToInt32(Id_tb.Text); int cid = Convert.ToInt32(ComboBox_Course.SelectedValue); float score_stu = (float)Convert.ToDouble(Score_tb.Text); string des = Des_tb.Text; if (score_stu > 10 || score_stu < 0) { XtraMessageBox.Show("Score can not over 10. Please anter again!", "Score", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (!score.Student_Score_Exist(sid, cid)) { if (score.Add_Score(sid, cid, score_stu, des)) { XtraMessageBox.Show("Add score successful!", "Add Score", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { XtraMessageBox.Show("Add score failed !", "Add Score", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { XtraMessageBox.Show("The Student ID and Course ID already", "All Score", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch { XtraMessageBox.Show("The textbox is blank. Please enter again", "Add Score", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Average_Load(object sender, EventArgs e) { Scores score = new Scores(); GridControl1.DataSource = score.GetAvg_byStudent(); }
public DataTable MakeStudentScoreResultTable() { try { SqlCommand command = new SqlCommand("select * from Score", data.GetConnection); Students student = new Students(); Courses course = new Courses(); Scores score = new Scores(); //create column DataTable result = student.GetAllBriefInfo(); result.Columns[0].ColumnName = "ID"; result.Columns[1].ColumnName = "Firt Name"; result.Columns[2].ColumnName = "Last Name"; DataTable coursesLabel = course.AllLabel_IdOrder(); DataTable scores = score.GetALL_IdCourseOrder(); DataTable avgScore = score.GetAvg_byStudent(); for (int i = 0; i < coursesLabel.Rows.Count; i++) { result.Columns.Add(coursesLabel.Rows[i][1].ToString().Trim()); } result.Columns.Add("Average"); result.Columns.Add("Result"); //test empty if (scores.Rows.Count < 1) { return(result); } //fill score to table int scoreRow = 0; for (int row = 0; row < result.Rows.Count; row++) { try { int courseIndex = 0; while (result.Rows[row][0].ToString().Trim() == scores.Rows[scoreRow][0].ToString().Trim()) { result.Rows[row][courseIndex + 3] = scores.Rows[scoreRow][2].ToString().Trim(); courseIndex++; scoreRow++; if (scoreRow > scores.Rows.Count - 1) { break; } } } catch (Exception) { continue; } } // fill avg score for (int row = 0; row < result.Rows.Count; row++) { try { result.Rows[row][result.Columns.Count - 2] = avgScore.Rows[row][1].ToString().Trim(); float avg = (float)Convert.ToDouble(avgScore.Rows[row][1]); if (avg < 4.99999) { result.Rows[row][result.Columns.Count - 1] = "Fail"; } else { { result.Rows[row][result.Columns.Count - 1] = "Pass"; } } } catch (Exception) { continue; } } //DataTable table = score.GetScore(command); //for (int row = 0; row < result.Rows.Count; row++) //{ // try // { // result.Rows[row][result.Columns.Count - 1] // = table.Rows[row][3].ToString().Trim(); // } // catch (Exception) // { // continue; // } //} return(result); } catch (Exception) { throw; } }
public void LoadScore() { Scores score = new Scores(); DataGridView_Score.DataSource = score.GetStudentScore(); }
private void Results_Load(object sender, EventArgs e) { Scores scores = new Scores(); DataGridView_Score.DataSource = scores.MakeStudentScoreResultTable(); }