예제 #1
0
        /*
         * public bool IsCourseExist(int courseID)
         * {
         *  bool isCourseExists = false;
         *
         *  SqlConnection connection = new SqlConnection(connectionString);
         *
         *  string query = "SELECT CourseID FROM courseAssignToTeacher_tbl WHERE CourseID= @CourseID";
         *  SqlCommand command = new SqlCommand(query, connection);
         *
         *  command.Parameters.Clear();
         *
         *  //            command.Parameters.Add("DeptCode", SqlDbType.NVarChar);
         *  //            command.Parameters["DeptCode"].Value = DeptCode;
         *  command.Parameters.AddWithValue("@CourseID", courseID);
         *
         *  connection.Open();
         *  SqlDataReader reader = command.ExecuteReader();
         *  if (reader.Read())
         *  {
         *      isCourseExists = true;
         *  }
         *  connection.Close();
         *
         *  return isCourseExists;
         * }
         */

        /// <summary>
        /// to get all courseAssignedToTeacherData
        /// </summary>
        /// <returns>returns all courseAssignedToTeacherData</returns>
        public List <CourseAssignToTeacherModel> GetAllCourseAssignedTeachers()
        {
            List <CourseAssignToTeacherModel> coursesAssignToTeacher = new List <CourseAssignToTeacherModel>();
            SqlConnection con   = new SqlConnection(connectionString);
            string        query = "SELECT * FROM courseAssignToTeacher_tbl";
            SqlCommand    cmd   = new SqlCommand(query, con);

            cmd.Parameters.Clear();
            con.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                CourseAssignToTeacherModel aCourseAssignToTeacherModel = new CourseAssignToTeacherModel();
                aCourseAssignToTeacherModel.CourseAssignToTeacherId = Convert.ToInt32(reader["id"].ToString());
                aCourseAssignToTeacherModel.DepartmentId            = Convert.ToInt32(reader["departmentID"].ToString());
                aCourseAssignToTeacherModel.TeacherId              = Convert.ToInt32(reader["teacherID"].ToString());
                aCourseAssignToTeacherModel.CourseId               = Convert.ToInt32(reader["courseID"].ToString());
                aCourseAssignToTeacherModel.Department             = aCourseAssignManager.GetSingleDepartmentByDeptId(aCourseAssignToTeacherModel.DepartmentId);
                aCourseAssignToTeacherModel.Teacher                = aCourseAssignManager.GetSingleTeacherByTeacherId(aCourseAssignToTeacherModel.TeacherId);
                aCourseAssignToTeacherModel.Course                 = aCourseAssignManager.GetSingleCourseByCourseId(aCourseAssignToTeacherModel.CourseId);
                aCourseAssignToTeacherModel.TeacherRemainingCredit = aCourseAssignManager.GetRemainingCreditFromAssignedTeachers(aCourseAssignToTeacherModel.TeacherId);
                coursesAssignToTeacher.Add(aCourseAssignToTeacherModel);
            }
            con.Close();
            return(coursesAssignToTeacher);
        }