Ejemplo n.º 1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn có chắc chắn xóa !", "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                int id = int.Parse(txtId.Text);
                if (manager.Delete(id))
                {
                    MessageBox.Show("Xóa thành công !", "Thông báo");
                }
                else
                {
                    MessageBox.Show("Xóa không thành công. Có danh mục đang sử dụng nên không xóa được", "Thông báo");
                }

                LoadData(Searching, PageIndex, PageSize);
            }
        }
        public void DeleteById()
        {
            var manager = new AuthorManager(new UnitOfWork("development"));

            manager.DeleteAll();
            manager.Add(new BusinessLayer.Models.Author("test-first", "test-Last"));
            var authors = manager.GetAll();

            Assert.AreEqual(authors.Count, 1);
            var author = manager.Get(authors[0].ID);

            Assert.AreEqual(author.Firstname, "test-first");
            Assert.AreEqual(author.Surname, "test-Last");
            manager.Delete(author.ID);
            authors = manager.GetAll();
            Assert.AreEqual(authors.Count, 0);
            manager.DeleteAll();
        }
Ejemplo n.º 3
0
        private void DeleteButtonEvent(object sender, RoutedEventArgs e)
        {
            List <Author> selected = this.GetSelected();

            if (MessageUtil.ShowYesNoMessage("Delete (" + selected.Count + ") " + ((selected.Count > 1) ? "Authors" : "Author"), "You won't be able to revert!"))
            {
                int           succeeded = 0;
                AuthorManager am        = new AuthorManager(new UnitOfWork());
                foreach (Author a in selected)
                {
                    try
                    {
                        am.Delete(a.ID);
                        int i = this.Authors.IndexOf(a);
                        this.Table.Rows.RemoveAt(i);
                        this.Authors.Remove(a);
                        succeeded++;
                    }
                    catch (Exception) { }
                }
                MessageUtil.ShowMessage("Deleted (" + succeeded + ") " + ((succeeded > 1) ? "Authors" : "Author") + " and (" + (selected.Count - succeeded) + ") failed!");
            }
        }
Ejemplo n.º 4
0
 public void Delete(DeleteAuthorInput input)
 {
     _authorManager.Delete(input.Id);
 }