Exemplo n.º 1
0
 // 添加学生
 public bool AddStudent(Student stu)
 {
     DataClassesDataContext da = new DataClassesDataContext();
     Student student = new Student();
     student = stu;
     da.Student.InsertOnSubmit(student);
     da.SubmitChanges();
     return true;
 }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(Request.Form["name"]) && !string.IsNullOrEmpty(Request.Form["password"]))//获取form中的参数
                {
                    string UserName = Request.Form["name"].ToString();
                    string UserPassword = Request.Form["password"].ToString();
                    string Identity = Request["status"];
                    string Major = Request["account"];

                    if (Identity == student.ID)
                    {
                        StudentManager StudentMan = new StudentManager();
                        Student stu = new Student();

                        stu.username = UserName;
                        stu.passwd = UserPassword;
                        stu.name = UserName;
                        if (Major == null)
                        {
                            Major = string.Empty;
                        }
                        stu.major = Major;
                        //stu.grade = string.Empty;
                        StudentMan.AddStudent(stu);
                        Session["student"] = stu;
                        Session["UserRole"] = "Student";
                        Response.Redirect("StudentMainForm.aspx");
                    }

                    else if (Identity == teacher.ID)
                    {
                        TeacherManager TeacherMan = new TeacherManager();
                        Teacher tea = new Teacher();
                        tea.username = UserName;
                        tea.passwd = UserPassword;
                        tea.name = UserName;

                        TeacherMan.AddTeacher(tea);
                        Session["teacher"] = tea;
                        Session["UserRole"] = "Teacher";
                        Response.Redirect("AddCourse.aspx");
                    }

                }

            }
            catch (Exception ex)
            {
                Response.Write("<Script Language=JavaScript>alert('用户名已存在!');</Script>");
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserRole"] == null || Session["UserRole"].ToString() != "Student")
            {
                Response.Write("<Script language='javascript'>alert('您无权访问此页面,请重新登录!');window.history.go(-1);</Script>");
                return;
            }

            CourseManager CourseMan = new CourseManager();
            List<Course> CourseList = new List<Course>();

            SystemTime.Text = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToShortTimeString();
            stu = (Student)Session["student"];
            CourseList = CourseMan.GetCourseForStudent(stu.username);
            Session["CourseList"] = CourseList;
            if (CourseList.Count == 0)
                Response.Redirect("SelectCourse.aspx");

            foreach (Course course in CourseList)
            {
                AssignmentList.AddRange(AssignmentMan.getAssignment(course.num));
            }
            if (!IsPostBack)
            {
                GridView3.DataBind();

                foreach (Assignment assignment in AssignmentList)
                {
                    TimeSpan ts = Convert.ToDateTime(assignment.end_time) - DateTime.Now;
                    if ((assignment.end_time > DateTime.Now) && (ts.Days < 1))
                    {
                        myArray.Add(assignment);
                    }

                    TimeSpan ts2 = DateTime.Now - Convert.ToDateTime(assignment.start_time);
                    if ((assignment.start_time < DateTime.Now) && (ts2.Days < 7))
                    {
                        myArray2.Add(assignment);
                    }
                }
                GridView2.DataBind();
                GridView1.DataBind();
            }
        }
Exemplo n.º 4
0
        //String SelectedCourses = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserRole"] == null || Session["UserRole"].ToString() != "Student")
            {
                Response.Write("<Script language='javascript'>alert('您无权访问此页面,请重新登录!');window.history.go(-1);</Script>");
                return;
            }

            stu = (Student)Session["student"];
            //CourseList = (List<Course>)Session["CourseList"];
            ViewCourses.Value = string.Empty;
            if (!IsPostBack)   //首次加载时
            {
                SelectTeachers.AutoPostBack = true;
                TeacherCourses.AutoPostBack = true;
                initTeachersList();
                ViewCourses.Value = string.Empty;
            }
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserRole"] == null || Session["UserRole"].ToString() != "Student")
            {
                Response.Write("<Script language='javascript'>alert('您无权访问此页面,请重新登录!');window.history.go(-1);</Script>");
                return;
            }

            //获取作业id
            id = Request.QueryString["AssignmentId"];
            header_text.Text = Request.QueryString["AssignmentTitle"];
            ProblemManager ProblemMan = new ProblemManager();

            stu = (Student)Session["student"];
            ProblemList = ProblemMan.GetProblem(System.Int32.Parse(id));

            if (ProblemList.Count != 0)
            {
                //动态创建问题及回答区域
                //加载上次答案
                AnswerList = AnswerMan.GetAnswerList(stu.username, System.Int32.Parse(id));
                accessory = AccessoryMan.GetAccessory(stu.username, System.Int32.Parse(id));

                for (int i = 0; i < ProblemList.Count; i++)
                {
                    string pro = "<p>" + ProblemList[i].title + "</p>";
                    Control ct = ParseControl(pro);
                    PlaceHolder1.Controls.Add(ct);

                    string an = "<p><textarea cols='120' rows='15' name='TA' id='TA" + i + "'></textarea></p>";

                    //加载已有答案
                    if (AnswerList != null)
                    {
                        an = "<p><textarea cols='120' rows='15' name='TA' id='TA" + i + "'>" + AnswerList[i].content + "</textarea></p>";
                        submitFlag = false;
                    }

                    Control ct2 = ParseControl(an);
                    PlaceHolder1.Controls.Add(ct2);
                }

                //加载已有附件
                if (accessory != null)
                {
                    fileTips.Text = "已有附件,无需再添加!";
                    FileUpload2.Enabled = false;
                }
            }
            else
            {
                header_text.Text = "   逗你玩呢,哈哈哈哈。";
                submit.Enabled = false;
                submit2.Enabled = false;
                export.Enabled = false;
                export2.Enabled = false;
                fileTips.Enabled = false;
                FileUpload2.Enabled = false;
            }
        }
Exemplo n.º 6
0
 partial void DeleteStudent(Student instance);
Exemplo n.º 7
0
 partial void UpdateStudent(Student instance);
Exemplo n.º 8
0
 partial void InsertStudent(Student instance);
Exemplo n.º 9
0
 //bool firstNodeExpandFlag = false;
 protected void Page_Load(object sender, EventArgs e)
 {
     foreach (string str in Session.Keys)
     {
         if (str.Equals("student"))
         {
             stu = (Student)Session["student"];
             welcome.Text = "欢迎" + stu.username;
             initTreeView();
         }
         else if (str.Equals("teacher"))
         {
             tea = (Teacher)Session["teacher"];
             welcome.Text = "欢迎您," + tea.username;
             initTeacherTreeView();
         }
     }
 }