public void DeleteTest()
        {
            List <Student> students  = manager.Read();
            int            idToCheck = students[testRowIndex].Id;

            manager.Delete(idToCheck);
            Student testStudent = manager.SelectStudentById(idToCheck);

            Assert.IsTrue(testStudent == null);
        }
Ejemplo n.º 2
0
        public void Delete(string Name, string Surname, DateTime DateofBirth, string StudentId, string typo)
        {
            Student student = new Student();

            student.Name        = Name;
            student.Surname     = Surname;
            student.DateofBirth = DateofBirth.ToString();
            student.StudentId   = Int32.Parse(StudentId);
            StudentDao studenCreator = FactoryProvider.GetFactory(typo).Creator(typo);

            studenCreator.Delete(student);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 删除学生
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_delete_Click(object sender, EventArgs e)
        {
            if (this.grid_students.SelectedRows.Count == 0)
            {
                MessageBox.Show("请选择要删除的行");
                return;
            }
            var selectRow = this.grid_students.SelectedRows[0];

            var        studentId  = (int)selectRow.Cells["studentID"].Value;
            StudentDao studentDao = new StudentDao();

            studentDao.Delete(studentId);
            //C# Linq
            var selectStudent = students.FirstOrDefault(x => x.Id == studentId);

            if (selectStudent != null)
            {
                students.Remove(selectStudent);
            }
        }