Exemplo n.º 1
0
 public Major(String name, Department Parent, School school)
 {
     ID = -1;
     Name = name;
     ParentSchoolID = Parent.ParentSchoolID;
     ParentDepartmentID = Parent.ID;
     ParentDepartment = Parent.Name;
     ParentSchool = school.Name;
 }
Exemplo n.º 2
0
 /// <summary>
 /// 获取指定院系下的所有专业
 /// </summary>
 /// <param name="depart">所属院系</param>
 /// <param name="auth">授权人员</param>
 /// <returns>指定院系下的专业列表</returns>
 public static Major[] GetMajor(Department depart, Authentication auth)
 {
     if (auth.CheckAllows("MajorView", Permission.SELECT))
     {
         List<Major> majors = new List<Major>();
         String SQL = @"SELECT  * FROM [dbo].[MajorView] WHERE [departid] = {0};";
         SQL = String.Format(SQL, depart.ID);
         SqlCommand cmd = new SqlCommand(SQL, auth.Connection);
         using (SqlDataReader data = cmd.ExecuteReader())
         {
             while (data.Read())
             {
                 majors.Add(new Major(data));
             }
         }
         return majors.ToArray();
     }
     return new Major[0];
 }
Exemplo n.º 3
0
        /// <summary>
        /// 通过ID查找院系
        /// </summary>
        /// <param name="id">院系ID</param>
        /// <param name="auth">授权人员</param>
        /// <returns>查找到的院系实例或者查找失败返回默认实例</returns>
        public static Department Search(Int32 id, Authentication auth)
        {
            if (auth.CheckAllows("departments", Permission.SELECT))
            {
                String SQL = @"SELECT TOP 1 * FROM [dbo].[schools]  WHERE [schoolid] = {0};";
                SQL = String.Format(SQL, id);
                SqlCommand cmd = new SqlCommand(SQL, auth.Connection);
                Department s = null;
                using (SqlDataReader data = cmd.ExecuteReader())
                {

                    if (data.Read())
                    {
                        s = new Department(data);
                    }
                    else
                    {
                        s = new Department();
                    }
                }
                return s;
            }
            throw new NoPermissionException();
        }