/// <summary> /// Insert Student record who logged in through Google /// </summary> /// <param name="studentName"></param> /// <param name="charId"></param> /// <param name="studentEmail"></param> /// <param name="studentUsername"></param> /// <param name="studentPassword"></param> /// <returns>Return int result 1 if insertion query has executed successfully</returns> public int InsertGoogleStudent(string studentName, string studentEmail, string googleId) { StudentDaoImpl studentDao = new StudentDaoImpl(); int result = studentDao.InsertGoogleStudent(studentName, studentEmail, googleId); return(result); }
/// <summary> /// Check if Student who has logged in with Facebook account has an existing Chrracter /// </summary> /// <param name="fbId"></param> /// <returns>Return true if Student has existing Character</returns> public bool CheckFacebookCharExist(string fbId) { StudentDaoImpl studentDao = new StudentDaoImpl(); bool exist = studentDao.CheckFacebookCharExist(fbId); return(exist); }
/// <summary> /// Check if there is an existing Student's Facebook account /// </summary> /// <param name="googleId"></param> /// <returns>Return true if Student's Facebook account exists</returns> public bool CheckFacebookExist(string googleId) { StudentDaoImpl studentDao = new StudentDaoImpl(); bool exist = studentDao.CheckFacebookExist(googleId); return(exist); }
/// <summary> /// Insert Student record who logged in through Facebook /// </summary> /// <param name="studentName"></param> /// <param name="studentEmail"></param> /// <param name="fbId"></param> /// <returns>Return int result 1 if insertion query has executed successfully</returns> public int InsertFacebookStudent(string studentName, string studentEmail, string fbId) { StudentDaoImpl studentDao = new StudentDaoImpl(); int result = studentDao.InsertFacebookStudent(studentName, studentEmail, fbId); return(result); }
/// <summary> /// Check if Student has an existing account /// </summary> /// <param name="studentId"></param> /// <returns>Return true if Student's record exist</returns> public bool CheckStudentCharExist(int studentId) { StudentDaoImpl studentDao = new StudentDaoImpl(); bool exist = studentDao.CheckStudentExist(studentId); return(exist); }
public void Main() { IStudentDao studentDao = new StudentDaoImpl(); //输出所有的学生 for (int i = 0; i < studentDao.GetAllStudents().Count; i++) { Console.WriteLine("student rollNo:" + studentDao.GetAllStudents()[i].GetRollNo() + "student name:" + studentDao.GetAllStudents()[i].GetName()); } //更新学生 Student student = studentDao.GetAllStudents()[0]; student.SetName("Michael"); studentDao.UpdateStudent(student); //获取学生 student = studentDao.GetStudent(0); Console.WriteLine("student rollNo:" + student.GetRollNo() + "student name:" + student.GetName()); }
static void Main(string[] args) { IStudentDao studentDao = new StudentDaoImpl(); //输出所有的学生 foreach (Student student1 in studentDao.getAllStudents()) { Console.WriteLine("Student: [RollNo : " + student1.getRollNo() + ", Name : " + student1.getName() + " ]"); } //更新学生 Student student = studentDao.getAllStudents()[0]; student.setName("Michael"); studentDao.updateStudent(student); //获取学生 studentDao.getStudent(0); Console.WriteLine("Student: [RollNo : " + student.getRollNo() + ", Name : " + student.getName() + " ]"); Console.ReadLine(); }
protected void btnUpload_Click(object sender, EventArgs e) { string existingStudent = ""; string failedStudent = ""; bool studentExists = false; try { List <StudentMajorVO> studentPgmVOList = new List <StudentMajorVO>(); List <StudentVO> studentVOList = new List <StudentVO>(); List <UserVO> users = new List <UserVO>(); UserDaoImpl userDaoImpl = new UserDaoImpl(); UserVO userVO = null; IStudentDao studentDao = new StudentDaoImpl(); List <string> existingStudentIDList = studentDao.GetAllStudentIDAsList(); string filepath = Server.MapPath("~/Files/") + Path.GetFileName(fuBulkCourseUpload.PostedFile.FileName); if (fuBulkCourseUpload.HasFile) { fuBulkCourseUpload.SaveAs(filepath); string data = File.ReadAllText(filepath); Boolean headerRowHasBeenSkipped = false; foreach (string row in data.Split('\n')) { if (headerRowHasBeenSkipped) { string programme = ""; studentExists = false; if (!string.IsNullOrEmpty(row)) { userVO = new UserVO(); StudentVO studentVO = new StudentVO(); StudentMajorVO studentMajorVO = new StudentMajorVO(); List <string> pgmList = new List <string>(); int i = 0; foreach (string cell in row.Split(',')) { if (!studentExists) { string celltemp = ""; if (cell.Contains("\r")) { celltemp = cell.Replace("\r", ""); } else { celltemp = cell; } celltemp = celltemp.Trim(); switch (i) { case 0: { if (existingStudentIDList.Contains(celltemp)) { existingStudent += celltemp + ","; studentExists = true; } else { studentVO.StudentId = Convert.ToInt32(celltemp); studentMajorVO.studentId = Convert.ToInt32(celltemp);; userVO.StudentID = Convert.ToInt32(celltemp); } break; } case 1: { studentVO.FirstName = celltemp; break; } case 2: { studentVO.LastName = celltemp; break; } case 3: { /* if (celltemp.Contains("&")) * { * foreach (string pgm in celltemp.Split('&')) * { * pgmList.Add(pgm); * } * } * else * { * pgmList.Add(celltemp); * }*/ programme = celltemp; break; } case 4: { if (celltemp.Contains("&")) { StudentMajorVO sm; // foreach (string pgm in pgmList) //{ foreach (string mjr in celltemp.Split('&')) { sm = new StudentMajorVO(); sm.StudentId = studentMajorVO.StudentId; sm.ProgrammeID = programme; sm.MajorID = mjr.Trim(); studentPgmVOList.Add(sm); } // } } else { StudentMajorVO sm; // foreach (string pgm in pgmList) //{ sm = new StudentMajorVO(); sm.StudentId = studentMajorVO.StudentId; sm.ProgrammeID = programme; sm.MajorID = celltemp; studentPgmVOList.Add(sm); //} } break; } case 5: { if (!celltemp.EndsWith("@ess.ais.ac.nz")) { existingStudent += celltemp + ","; studentExists = true; } else { userVO.EmailID = celltemp; } break; } } } i++; } if (!studentExists) { studentVO.Program = studentPgmVOList; users.Add(userVO); studentVOList.Add(studentVO); } } } headerRowHasBeenSkipped = true; } if (studentVOList.Count > 0) { foreach (StudentVO studentVO in studentVOList) { studentVO.Status = "Studying"; studentVO.CreatedDate = DateTime.Now; studentVO.LastUpdatedDate = DateTime.Now; string status = (studentBO.AddStudent(studentVO)).ToString(); if (status.Contains("fail")) { failedStudent += studentVO.StudentID; } } foreach (StudentMajorVO studentMajorVO in studentPgmVOList) { studentMajorVO.Active = "Yes"; string status = (studentMajorBO.AddStudent(studentMajorVO)).ToString(); if (status.Contains("fail")) { failedStudent += studentMajorVO.StudentId; } } userDaoImpl.AddStudentUsers(users); string usermessage = " Students upload completed."; if (failedStudent != "") { usermessage += " FailedStudentList " + failedStudent; } if (existingStudent != "") { usermessage += " Skipped existing student. " + existingStudent; } ScriptManager.RegisterClientScriptBlock(this.Page, this.Page.GetType(), "alert", "alert('" + usermessage + "');", true); } } } catch (Exception ex) { ExceptionUtility.LogException(ex, "Error Page"); Response.Write("<script>alert('" + ex.Message + "');</script>"); } finally { if (DBConnection.conn != null) { DBConnection.conn.Close(); } } }
/// <summary> /// Get Character that belongs to selected Student /// </summary> /// <param name="studentId"></param> /// <returns>Return Student object containing Character object</returns> public Student GetStudentCharacter(int studentId) { StudentDaoImpl studentDao = new StudentDaoImpl(); return(studentDao.GetStudentCharacter(studentId)); }
/// <summary> /// Updates Student's Character /// </summary> /// <param name="charId"></param> /// <param name="studentId"></param> /// <returns>Return 1 if update query has executed successfully</returns> public int UpdateStudentCharacter(int charId, int studentId) { StudentDaoImpl studentDao = new StudentDaoImpl(); return(studentDao.UpdateStudentCharacter(charId, studentId)); }
/// <summary> /// Get existing Student's Facebook account /// </summary> /// <param name="fbId"></param> /// <returns>Retrun Student Object</returns> public int GetFacebookStudentId(string fbId) { StudentDaoImpl studentDao = new StudentDaoImpl(); return(studentDao.GetFacebookStudent(fbId).StudentId); }
/// <summary> /// Get existing Student's Google account /// </summary> /// <param name="googleId"></param> /// <returns>Return Student Object</returns> public int GetGoogleStudentId(string googleId) { StudentDaoImpl studentDao = new StudentDaoImpl(); return(studentDao.GetGoogleStudent(googleId).StudentId); }