public Dictionary <string, int> turnToOldScore(Gsat gsat) { string sqlCom = null; SqlDataAdapter buffer = null; Dictionary <string, int> oldScore = new Dictionary <string, int>(); int[] newScore = changeToArray(gsat); string[] subject = { "國文", "英文", "數學", "自然", "社會", "總級分" }; oldScore.Clear(); this.conn.Open(); for (int i = 0; i < subject.Length; i++) { sqlCom = "SELECT Max(OldScoreData.Score) As Score FROM OldScoreData,NewScoreData WHERE OldScoreData.Ename = '" + subject[i] + "' " + "AND NewScoreData.Ename = '" + subject[i] + "' AND NewScoreData.Score = " + newScore[i].ToString() + " AND NewScoreData.Percentage >= OldScoreData.Percentage;"; buffer = new SqlDataAdapter(sqlCom, this.conn); buffer.Fill(dt); if (dt.Rows[0].IsNull("Score")) { oldScore.Add(subject[i], 0); } else { oldScore.Add(subject[i], Convert.ToInt32(dt.Rows[0]["Score"])); } dt.Clear(); } buffer.Dispose(); conn.Close(); return(oldScore); }
/// <summary> /// 將學測級分轉換成等級 /// </summary> /// <param name="gsat">學測成績</param> /// <returns>學測等級</returns> public ArrayList changeScoreOfGSAT2Level(Gsat gsat) { string sqlCom = null; int LV = 0; int sum = gsat.Chinese + gsat.English + gsat.Math + gsat.Science + gsat.Society; int[] score104OfGSAT = {gsat.Chinese, gsat.English, gsat.Math, gsat.Science, gsat.Society,sum }; string[] subjectOfGSAT = { "國文", "英文", "數學", "自然", "社會" ,"總級分"}; SqlDataAdapter buffer = null; ArrayList level = new ArrayList(); this.conn.Open(); for (int i = 0; i < 6; i++) { sqlCom = "SELECT Grade1,Grade2,Grade3,Grade4,Grade5 " + "FROM T WHERE Tname = '" + subjectOfGSAT[i] + "'"; buffer = new SqlDataAdapter(sqlCom, this.conn); buffer.Fill(dt); this.conn.Close(); if (score104OfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade1"].ToString())) LV = 0; else if (score104OfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade2"].ToString())) LV = 1; else if (score104OfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade3"].ToString())) LV = 2; else if (score104OfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade4"].ToString())) LV = 3; else if (score104OfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade5"].ToString())) LV = 4; else LV = 5; level.Add(LV); dt.Clear(); } buffer.Dispose(); this.conn.Close(); return level; }
private int[] changeToArray(Gsat gsat) { int sum = (gsat.Chinese == null ? 0 : Convert.ToInt32(gsat.Chinese)) + (gsat.English == null ? 0 : Convert.ToInt32(gsat.English)) + (gsat.Math == null ? 0 : Convert.ToInt32(gsat.Math)) + (gsat.Science == null ? 0 : Convert.ToInt32(gsat.Science)) + (gsat.Society == null ? 0 : Convert.ToInt32(gsat.Society)); int[] score = { gsat.Chinese == null ? 0 : Convert.ToInt32(gsat.Chinese), gsat.English == null ? 0 : Convert.ToInt32(gsat.English), gsat.Math == null ? 0 :Convert.ToInt32(gsat.Math), gsat.Science == null ? 0 : Convert.ToInt32(gsat.Science), gsat.Society == null ? 0 : Convert.ToInt32(gsat.Society), sum }; return(score); }
/// <summary> /// 將學測級分轉換成等級 /// </summary> /// <param name="gsat">學測成績</param> /// <returns>學測等級</returns> public ArrayList changeScoreOfGSAT2Level(Gsat gsat) { string sqlCom = null; int LV = 0; int[] scoreOfGSAT = changeToArray(gsat); //string[] subjectOfGSAT = { "國文", "英文", "數學", "自然", "社會" ,"總級分"}; string[] subjectOfGSAT = { "國文", "英文", "數學", "自然", "社會" }; SqlDataAdapter buffer = null; ArrayList level = new ArrayList(); this.conn.Open(); for (int i = 0; i < subjectOfGSAT.Length; i++) { sqlCom = "SELECT Grade1,Grade2,Grade3,Grade4,Grade5 " + "FROM T WHERE Tname = '" + subjectOfGSAT[i] + "'"; buffer = new SqlDataAdapter(sqlCom, this.conn); buffer.Fill(dt); if (scoreOfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade1"].ToString())) { LV = 0; } else if (scoreOfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade2"].ToString())) { LV = 1; } else if (scoreOfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade3"].ToString())) { LV = 2; } else if (scoreOfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade4"].ToString())) { LV = 3; } else if (scoreOfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade5"].ToString())) { LV = 4; } else { LV = 5; } level.Add(LV); dt.Clear(); } buffer.Dispose(); this.conn.Close(); return(level); }
/// <summary> /// 將學測級分轉換成等級 /// </summary> /// <param name="gsat">學測成績</param> /// <returns>學測等級</returns> public ArrayList changeScoreOfGSAT2Level(Gsat gsat) { string sqlCom = null; int LV = 0; //int sum = gsat.Chinese + gsat.English + gsat.Math + gsat.Science + gsat.Society; int[] scoreOfGSAT = { gsat.Chinese, gsat.English, gsat.Math, gsat.Science, gsat.Society }; string[] subjectOfGSAT = { "國文", "英文", "數學", "自然", "社會" }; ArrayList level = new ArrayList(); for (int i = 0; i < 5; i++) { sqlCom = "SELECT Grade1,Grade2,Grade3,Grade4,Grade5 " + "FROM T WHERE TName = '" + subjectOfGSAT[i] + "'"; dt = query.search(sqlCom); if (scoreOfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade1"].ToString())) { LV = 0; } else if (scoreOfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade2"].ToString())) { LV = 1; } else if (scoreOfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade3"].ToString())) { LV = 2; } else if (scoreOfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade4"].ToString())) { LV = 3; } else if (scoreOfGSAT[i] < Convert.ToInt32(dt.Rows[0]["Grade5"].ToString())) { LV = 4; } else { LV = 5; } level.Add(LV); dt.Clear(); } return(level); }