示例#1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Student selStudent = this.GetFirstSelectedStudent();

            StuDbAccessor.Delete(selStudent.ID);
            this.ViewAllStudent();
        }
示例#2
0
        static void TestDAL()
        {
            using (Model1 en = new Model1())
            {
                Console.WriteLine("默认记录数量:{0}", en.Students.Count());

                Student stu = new Student {
                    Name = "LY", Sex = "M", Age = 28, Pwd = "L38"
                };
                StuDbAccessor.Add(stu);
                Console.WriteLine("添加了一条记录后记录数量:{0}", en.Students.Count());

                StuDbAccessor.Delete(2);
                Console.WriteLine("删除了一条记录后记录数量:{0}", en.Students.Count());

                Student stuUpdate = new Student {
                    Name = "name1", Sex = "M", Age = 1, Pwd = "pwd1"
                };
                StuDbAccessor.Update(1, stuUpdate);
                Console.WriteLine("更新了第一条记录,下面是更新后的属性");
                Student updated1 = StuDbAccessor.SelectById(1);
                Console.WriteLine(string.Format("{0}\t{1}\t{2}\t{3}",
                                                updated1.Name, updated1.Pwd, updated1.Sex, updated1.Pwd));
            }
        }
示例#3
0
 public void TestDelete()
 {
     using (Model1 en = new Model1())
     {
         StuDbAccessor.Delete(2);
         Assert.AreEqual(en.Students.Count(), 4);
     }
 }