/// <summary> /// เรียกดูข้อมูลจากตาราง STUDENT_ENGLISH_TEST /// </summary> /// <param name="sql">SQL Command</param> /// <returns>ข้อมูลจากตาราง STUDENT_ENGLISH_TEST</returns> public List <StudentEnglishTestData> getStudentEnglishTestManual(string sql) { List <StudentEnglishTestData> data = new List <StudentEnglishTestData>(); ConnectDB db = new ConnectDB(); SqlDataSource oracleObj = db.ConnectionOracle(); oracleObj.SelectCommand = sql; DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty); foreach (DataRowView rowData in allData) { StudentEnglishTestData row = new StudentEnglishTestData(); row.StudentEnglishTestId = rowData["STUDENT_ENGLISH_TEST_ID"].ToString(); row.StudentId = rowData["STUDENT_ID"].ToString(); row.EnglishDbId = rowData["ENGLISH_DB_ID"].ToString(); row.StudentEnglishTestScore = rowData["STUDENT_ENGLISH_TEST_SCORE"].ToString(); data.Add(row); } return(data); }
/// <summary> /// แก้ไขข้อมูลจากตาราง STUDENT_ENGLISH_TEST /// เฉพาะข้อมูล ENGLISH_DB_ID, STUDENT_ENGLISH_TEST_SCORE /// </summary> /// <param name="updateData">StudentEnglishTest Object</param> /// <returns>OK</returns> public string updateStudentEnglishTest(StudentEnglishTestData updateData) { string response = ""; ConnectDB db = new ConnectDB(); SqlDataSource oracleObj = db.ConnectionOracle(); string sql = "Update STUDENT_ENGLISH_TEST Set ENGLISH_DB_ID = '" + updateData.EnglishDbId + "', STUDENT_ENGLISH_TEST_SCORE = '" + updateData.StudentEnglishTestScore + "' Where STUDENT_ENGLISH_TEST_ID = '" + updateData.StudentEnglishTestId + "'"; oracleObj.UpdateCommand = sql; try { if (oracleObj.Update() == 1) { response = "OK"; } } catch (Exception e) { string exception = e.Message; HttpContext.Current.Session["response"] = "updateStudentEnglishTest: " + exception; HttpContext.Current.Response.Redirect("../err_response.aspx"); } return(response); }
/// <summary> /// เพิ่มข้อมูลลงตาราง STUDENT_ENGLISH_TEST /// </summary> /// <param name="dataInsert">StudentEnglishTest Object</param> /// <returns>OK</returns> public string insertStudentEnglishTest(StudentEnglishTestData dataInsert) { string response = ""; int sleepTime = 5000; string StudentEnglishTestId = dataInsert.StudentEnglishTestId; for (int i = 0; i < 10; i++) { if (getStudentEnglishTest(StudentEnglishTestId).StudentEnglishTestId != null) { Thread.Sleep(sleepTime); StudentEnglishTestId = getMaxIdStudentEnglishTest(); sleepTime += 5000; } else { dataInsert.StudentEnglishTestId = StudentEnglishTestId; break; } } ConnectDB db = new ConnectDB(); SqlDataSource oracleObj = db.ConnectionOracle(); string sql = "Insert into STUDENT_ENGLISH_TEST (STUDENT_ENGLISH_TEST_ID, STUDENT_ID, ENGLISH_DB_ID, STUDENT_ENGLISH_TEST_SCORE) values ('" + dataInsert.StudentEnglishTestId + "','" + dataInsert.StudentId + "','" + dataInsert.EnglishDbId + "','" + dataInsert.StudentEnglishTestScore + "')"; oracleObj.InsertCommand = sql; try { if (oracleObj.Insert() == 1) { response = "OK"; } } catch (Exception e) { string exception = e.Message; HttpContext.Current.Session["response"] = "insertStudentEnglishTest: " + exception; HttpContext.Current.Response.Redirect("../err_response.aspx"); } return(response); }
/// <summary> /// เรียกดูข้อมูลจากตาราง STUDENT_ENGLISH_TEST /// </summary> /// <param name="StudentEnglishTestId">ลำดับ</param> /// <returns>ข้อมูลจากตาราง STUDENT_ENGLISH_TEST</returns> public StudentEnglishTestData getStudentEnglishTest(string StudentEnglishTestId) { StudentEnglishTestData data = new StudentEnglishTestData(); ConnectDB db = new ConnectDB(); SqlDataSource oracleObj = db.ConnectionOracle(); oracleObj.SelectCommand = "Select * From STUDENT_ENGLISH_TEST Where STUDENT_ENGLISH_TEST_ID ='" + StudentEnglishTestId + "'"; DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty); foreach (DataRowView rowData in allData) { data.StudentEnglishTestId = rowData["STUDENT_ENGLISH_TEST_ID"].ToString(); data.StudentId = rowData["STUDENT_ID"].ToString(); data.EnglishDbId = rowData["ENGLISH_DB_ID"].ToString(); data.StudentEnglishTestScore = rowData["STUDENT_ENGLISH_TEST_SCORE"].ToString(); } return(data); }