当前位置: 首页>>代码示例>>C#>>正文


C# Student.getAllCourses方法代码示例

本文整理汇总了C#中Student.getAllCourses方法的典型用法代码示例。如果您正苦于以下问题:C# Student.getAllCourses方法的具体用法?C# Student.getAllCourses怎么用?C# Student.getAllCourses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Student的用法示例。


在下文中一共展示了Student.getAllCourses方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(HttpContext.Current.User.Identity.IsAuthenticated))
        {

            FormsAuthentication.SignOut();
            Session.Clear();
            Response.Redirect("~/Default");
        }
        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {

            //\ gets userName and UserID
            String currentUserName = HttpContext.Current.User.Identity.Name;
            userId = Membership.GetUser(currentUserName).ProviderUserKey.ToString();

            student = new Student(userId);
            comment = new Comment(userId);

            allCourses = student.getAllCourses();
            allCourses.Sort();

            foreach(String s in allCourses)
            {
                courseDropBox.Items.Add(s);
            }

            //\sets currentcourse to whats selected in dropbox on load
            strCurrentCourse = courseDropBox.SelectedValue;
            currentCourse = student.getCourseName(strCurrentCourse);

        }
        else
        {
            Response.Redirect("NotLoggedIn.aspx");
            Server.Transfer("NotLoggedIn.aspx");
        }

            if (!IsPostBack)
        {
            BindComment();
        }
    }
开发者ID:CaSimpson,项目名称:CourseHunterV2,代码行数:43,代码来源:RateMyCourse.aspx.cs

示例2: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!(HttpContext.Current.User.Identity.IsAuthenticated))
        {

            FormsAuthentication.SignOut();
            Session.Clear();
            Response.Redirect("~/Default");
        }

        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {

            //\ gets userName and UserID
            String userName = HttpContext.Current.User.Identity.Name;
            String userId = Membership.GetUser(userName).ProviderUserKey.ToString();

            student = new Student(userId);

            strTakenList = student.getTakenCourses();
            takenList = student.getTakenInt();
            strAllList = student.getAllCourses();
            allList = student.getCourseName(strAllList);

            //\ creates need list and Creates resultbuilder object
            needList = student.getNeededInt();
            ResultsBuilder rs = new ResultsBuilder(needList, takenList);
            //\ finds possible courses and inits possible list
            rs.findPossible();
            possibleList = rs.getPossible();
            rs.findRecommended();
            //recIntList = rs.getRecommended();
            int[][] recArray =   rs.getRecommended();

            String currentCourseName;

            //\ gets course name for possible courses
            SqlConnection conGetName = new SqlConnection(myDatabase);

            SqlCommand cmdGetName = new SqlCommand("getCourseName", conGetName);
            cmdGetName.CommandType = CommandType.StoredProcedure;

            foreach (int c in possibleList)
            {

                cmdGetName.Parameters.AddWithValue("@courseID", c);
                conGetName.Open();
                currentCourseName = Convert.ToString(cmdGetName.ExecuteScalar());
                formattedList.Add(currentCourseName);
                cmdGetName.Parameters.Clear();
                conGetName.Close();
            }

            //\ gets course name for recommended courses
            SqlConnection conGetRec = new SqlConnection(myDatabase);

            SqlCommand cmdGetRec = new SqlCommand("getCourseName", conGetRec);
            cmdGetRec.CommandType = CommandType.StoredProcedure;

            for (int i = 0; i < 5; i++)
            {

                cmdGetRec.Parameters.AddWithValue("@courseID", recArray[i][0]);
                conGetRec.Open();
                currentCourseName = Convert.ToString(cmdGetRec.ExecuteScalar());
                recList[i] = currentCourseName;
                cmdGetRec.Parameters.Clear();
                conGetRec.Close();
            }

            rec1.Text = " 1.  " + recList[0];
            rec2.Text = " 2.  " + recList[1];
            rec3.Text = " 3.  " + recList[2];
            rec4.Text = " 4.  " + recList[3];
            rec5.Text = " 5.  " + recList[4];

            formattedList.Sort();

            foreach (String i in formattedList)
            {
               allPosListBox.Items.Add(i.ToString());
            }

            foreach (String i in formattedList)
            {
                //allPosListBox.Items.Add(i);
            }

        }
        else
        {
            Response.Redirect("NotLoggedIn.aspx");
            Server.Transfer("NotLoggedIn.aspx");
        }
    }
开发者ID:CaSimpson,项目名称:CourseHunterV2,代码行数:95,代码来源:Results.aspx.cs


注:本文中的Student.getAllCourses方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。