protected void Page_Load(object sender, EventArgs e) { ////insert a datum to ScoreDetailTB table //string ID = "112"; //string grade = "\"100/2/50/50\""; //Response.Write("<script>console.log(" + CsDBOp.InsertScore(ID, grade) + ");</script>"); //取得資料 List <ScoreAnalysisM> ScoreAnalysisList = new List <ScoreAnalysisM>(); //下方3個變數的值之後會由DB取得 //get all the data from ScoreDetailTB table DataTable dt = CsDBOp.GetAllTBData(); //get the retrieved data from each row of the retrieved data table. ////update a student's grade //string aID = "113"; //string NewGrade = "\"78/5/0/20/20/20/18\""; //Response.Write("<script>console.log(" + CsDBOp.UpdateScore(aID, NewGrade) + ");</script>"); /////////////////////////////////////// ////delete a student's grade //Response.Write("<script>console.log(" + CsDBOp.DeleteScore(ID) + ");</script>"); }
protected void Page_Load(object sender, EventArgs e) { //下方3個變數的值之後會由DB取得 //get all the data from ScoreDetailTB table DataTable dt = CsDBOp.GetAllTBData(); //Get the retrieved data from each row of the retrieved data table. foreach (DataRow dr in dt.Rows) { ScoreAnalysisM log = new ScoreAnalysisM(); log.StuCouHWDe_ID = dr.Field <string>("StuCouHWDe_ID"); log.Grade = dr.Field <string>("Grade").Split(',').ToList <string>(); log.QuestionNum = Convert.ToInt16(log.Grade[1]); log.Grade.RemoveAt(1); ScoreAnalysisList.Add(log); } //Initalize the member variable table_cols = FirstColDefault.Length + ScoreAnalysisList[0].Grade.Count - 1; table_rows = ScoreAnalysisList.Count; studentNum = table_rows; QuestionNum = ScoreAnalysisList[0].Grade.Count - 1; // Add a row named Avg AddRow("Avg"); GenerateTable(table_cols, table_rows); StringBuilder sb = new StringBuilder(); for (int i = 0; i < QuestionNum; i++) { string temp2; temp2 = "['第" + (i + 1) + "題'," + QuestionAvg[i] + "],"; sb.Append(temp2); } chart.InnerHtml = "<script>var chart = c3.generate({bindto: '#chart',data: {columns: [" + sb.ToString() + "],type : 'pie'}});</script>"; }
protected void Page_Load(object sender, EventArgs e) { //insert a datum to ScoreDetailTB table string ID = "112"; string grade = "\"100/2/50/50\""; Response.Write("<script>console.log(" + CsDBOp.InsertScore(ID, grade) + ");</script>"); //get all the data from ScoreDetailTB table DataTable dt = CsDBOp.GetAllTBData(); //get the retrieved data from each row of the retrieved data table. foreach (DataRow dr in dt.Rows) { //get the value of field StuCouHWDe_ID from ScoreDetailTB table Response.Write("<script>console.log(" + dr.Field <string>("StuCouHWDe_ID") + ");</script> "); //get the value of field Grade from ScoreDetailTB table Response.Write("<script>console.log(" + dr.Field <string>("Grade") + ");</script> "); } //update a student's grade string aID = "113"; string NewGrade = "\"78/5/0/20/20/20/18\""; Response.Write("<script>console.log(" + CsDBOp.UpdateScore(aID, NewGrade) + ");</script>"); ///////////////////////////////////// //delete a student's grade Response.Write("<script>console.log(" + CsDBOp.DeleteScore(ID) + ");</script>"); }