public String UpdateStudentChange(String sc_id, String org_tg_id, String new_tg_id, String s_id, String t_id, String thesis_state, String sc_allapproval, int accept) { getRoleInfo(); int max_student = adminHelper.GetMaxStudentNum(t_id, s_id); //取得老師可指導學生上限 int current_student = adminHelper.GetCurrentStudentNum(t_id, s_id); //取得目前學生 int i = adminHelper.IsNewTeacher(s_id, t_id); //如果是新老師則需要補正 if (current_student >= max_student + i & accept == 1) { return("100"); } //update teacher accpet according to allapprove JObject update_change = adminHelper.UpdateChange(sc_id, org_tg_id, s_id, t_id, adminId, thesis_state, sc_allapproval, accept); if (accept == 1) { /*check if all original teacher agree for change advisor*/ // update allapproval to 1 if all org teacher approved if (sc_allapproval.Equals("0") && adminHelper.IsAllOrgTeacherApprove(org_tg_id)) { adminHelper.UpdateStudentChangeApproval(new_tg_id); } if (adminHelper.IsAllTeacherApprove(new_tg_id, org_tg_id)) { String time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //update original pair since it's expired adminHelper.UpdateOrgPair(org_tg_id, time); //add new paired adminHelper.AddChangePair(new_tg_id, s_id, time); //update student change history adminHelper.UpdateStudentChangeHistory(org_tg_id, 1, time); //state=1 means success //update student apply status adminHelper.UpdateStudentApplyStatus(s_id, state: 0); } } else if (accept == 2) { String time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //update student change history adminHelper.UpdateStudentChangeHistory(org_tg_id, 3, time); //state=3 means reject //update student apply status adminHelper.UpdateStudentApplyStatus(s_id, state: 0); } return(update_change["status"].ToString(Formatting.None)); }