Пример #1
0
    private void LoadGridview()
    {
        ASSEntities assen = new ASSEntities();
        result = from sc in assen.SetCourses
                     select new myBinding { SCID= sc.SCID,ClassName= sc.Classes.ClassName,CourseName= sc.Courses.CourseName,TeaName= sc.Teachers.TeaName };

        GridView1.DataSource = result;
        GridView1.DataBind();
    }
Пример #2
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (TextBox2.Text == "")
        {
            return;
        }
        string[] arrcourse = TextBox2.Text.Split(',');

        ASSEntities assen = new ASSEntities();
        
        foreach(string course in arrcourse)
        {
            Courses c = new Courses();
            c.CourseName = course;
            assen.AddToCourses(c);
        }
        assen.SaveChanges();
    }
Пример #3
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     if (TextBox1.Text == "" || TextBox2.Text == "")
     {
         return;
     }
     string[] arrclass = TextBox2.Text.Split(',');
     ASSEntities assen = new ASSEntities();
     foreach (string classsh in arrclass)
     {
         string classname = TextBox1.Text + classsh;
         
         Classes c = new Classes();
         c.ClassName = classname;
         assen.AddToClasses(c);
     }
     assen.SaveChanges();
 }
Пример #4
0
    protected void btn_givesc_Click(object sender, EventArgs e)
    {
        if (tb_class.Text == "" || tb_course.Text == "" || tb_teaer.Text == "")
        {
            Exception ex = new Exception();
            ex.Data["tbnull"] = "数据不完整。";
            throw ex;
        }

        ASSEntities assen = new ASSEntities();
        SetCourses sc = new SetCourses();


        int ncint = int.Parse(tb_class.Text);
        int ncoint = int.Parse(tb_course.Text);
        int ntint = int.Parse(tb_teaer.Text);
        var newclass = (from nc in assen.Classes
                        where nc.ClassID == ncint
                        select nc).First();
        var newcourse = (from nco in assen.Courses
                         where nco.CourseID == ncoint
                         select nco).First();
        var newteacher = (from nt in assen.Teachers
                          where nt.TeaID == ntint
                          select nt).First();

        sc.SCID = 1;
        sc.Classes = newclass;
        sc.Courses = newcourse;
        sc.Teachers = newteacher;
        if (tb_semester.Text != "")
        {
            sc.Semester = tb_semester.Text;
        }
        else
        {
            sc.Semester = Session["schoolsemester"].ToString();
        }

        assen.AddToSetCourses(sc);
        assen.SaveChanges();

    }
Пример #5
0
    protected void btn_change_Click(object sender, EventArgs e)
    {
        if (tb_change.Text == "")
        {
            return;
        }
        string[] inf = tb_change.Text.Split(',');
        string inf_1 = inf[1].Trim();
        int inf_2 = int.Parse(inf[0].Trim());
        ASSEntities assen = new ASSEntities();
        var teacher = (from t in assen.Teachers
                       where t.TeaName == inf_1
                       select t).First();

        var setcourse = (from sc in assen.SetCourses
                         where sc.SCID == inf_2
                         select sc).First();

        setcourse.Teachers = teacher;
        assen.SaveChanges();
    }