示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataClasses1DataContext db = new DataClasses1DataContext();
            //添加学生-课程关系
            #region
            var query = (from students in db.student
                         where students.Student_classid == classbox.Text
                         select students.Student_id).ToList();
            int right = 0;
            int wrong = 0;
            int num = 0;
            foreach (var a in query)
            {
                sutdent_course temp = new sutdent_course();
                temp.id = a + coursebox.Text;
                temp.Course_id = coursebox.Text;
                temp.Student_id = a;
                db.sutdent_course.InsertOnSubmit(temp);
                try { db.SubmitChanges(); right++; }
                catch { wrong++; }

            }
            num = query.Count;
            String text = this.classbox.Text + "班共" + Convert.ToString(num) + "人,提交成功:" + Convert.ToString(right) + "条 ,提交失败:" + Convert.ToString(wrong) + "条";
            MessageBox.Show(text);
            #endregion
        }
示例#2
0
 partial void Deletesutdent_course(sutdent_course instance);
示例#3
0
 partial void Updatesutdent_course(sutdent_course instance);
示例#4
0
 partial void Insertsutdent_course(sutdent_course instance);