internal List <studentDetails> getStudentDetails(string studentID) { SqlConnection con = new SqlConnection(db_connection_string); string sql = "select * from studentDetails where studentID=@studentID"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@studentID", studentID); con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); List <studentDetails> list = new List <studentDetails>(); while (rdr.Read()) { studentDetails s = new studentDetails(); s.studentID = studentID; s.first_name = Convert.ToString(rdr["first_name"]); s.last_name = Convert.ToString(rdr["last_name"]); s.email = Convert.ToString(rdr["email"]); s.address = Convert.ToString(rdr["address"]); s.course_name = Convert.ToString(rdr["course_name"]); s.year_name = Convert.ToString(rdr["year_name"]); s.phone = Convert.ToString(rdr["phone"]); s.city = Convert.ToString(rdr["city"]); s.state = Convert.ToString(rdr["state"]); s.zip = Convert.ToString(rdr["zip"]); s.role = Convert.ToString(rdr["role"]); s.note_on_user = Convert.ToString(rdr["note_on_user"]); list.Add(s); } con.Close(); return(list); }
internal ReturnData validateIssueingBook(bookIssuingDetails bookIssuingDetails) { ReturnData rd = new ReturnData(); ReturnData isStudent = new studentDetails().validateStudentID(bookIssuingDetails.studentID); if (isStudent.status == 1) { ReturnData isStudentEligibleToBorrowBook = studentBookRecodeCount(bookIssuingDetails.studentID); if (isStudentEligibleToBorrowBook.status == 1) { ReturnData isBookAlreadyBorrowed = new BookCodeDetails().isBookAlreadyBorrowed(bookIssuingDetails.bookID); if (isBookAlreadyBorrowed.status == 1) { addBookIssuingDetails(); } else { rd.message = "Check the BookCode."; } } else { rd.message = "Student Has borrowed 2 Books"; } } else { rd.message = "Student ID is not Valid"; } return(rd); }
internal List <studentDetails> getStudentDetailsinlineFormUserID(string inlineFormUserID, string inlineFormUserName, string inlineFormEmailAddress, string inlineFormPhone) { SqlCommand cmd = new SqlCommand(); List <studentDetails> list = new List <studentDetails>(); inlineFormUserID = "%" + inlineFormUserID + "%"; inlineFormUserName = "******" + inlineFormUserName + "%"; inlineFormEmailAddress = "%" + inlineFormEmailAddress + "%"; inlineFormPhone = "%" + inlineFormPhone + "%"; SqlConnection con = new SqlConnection(db_connection_string); string sql = "select * from studentDetails where studentID Like @inlineFormUserID and (first_name Like @inlineFormUserName or last_name Like @inlineFormUserName) and email Like @inlineFormEmailAddress and phone Like @inlineFormPhone"; cmd.Parameters.AddWithValue("@inlineFormUserID", inlineFormUserID); cmd.Parameters.AddWithValue("@inlineFormUserName", inlineFormUserName); cmd.Parameters.AddWithValue("@inlineFormEmailAddress", inlineFormEmailAddress); cmd.Parameters.AddWithValue("@inlineFormPhone", inlineFormPhone); cmd.CommandText = sql; cmd.Connection = con; con.Open(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { studentDetails s = new studentDetails(); s.studentID = Convert.ToString(rdr["studentID"]); s.first_name = Convert.ToString(rdr["first_name"]); s.last_name = Convert.ToString(rdr["last_name"]); s.email = Convert.ToString(rdr["email"]); s.address = Convert.ToString(rdr["address"]); s.course_name = Convert.ToString(rdr["course_name"]); s.year_name = Convert.ToString(rdr["year_name"]); s.phone = Convert.ToString(rdr["phone"]); s.city = Convert.ToString(rdr["city"]); s.state = Convert.ToString(rdr["state"]); s.zip = Convert.ToString(rdr["zip"]); s.role = Convert.ToString(rdr["role"]); s.note_on_user = Convert.ToString(rdr["note_on_user"]); list.Add(s); } con.Close(); return(list); }