예제 #1
0
        //Hàm xoá
        public JsonResult DeleteCate(int?id)
        {
            var dao = new CategoriesDAO();
            var j   = new JsonAdminController();

            if (dao.Delete(id))
            {
                List <Category>    categories = db.Categories.Where(n => n.category_bin == true).OrderByDescending(n => n.category_datecreate).ToList();
                List <jCategories> list       = categories.Select(n => new jCategories
                {
                    category_active     = n.category_active,
                    category_bin        = n.category_bin,
                    category_datecreate = n.category_datecreate.Value.ToString("dd/MM/yyyy"),
                    category_dateupdate = n.category_dateupdate.Value.ToString("dd/MM/yyyy"),
                    category_id         = n.category_id,
                    category_img        = n.category_img,
                    category_name       = n.category_name,
                    category_note       = n.category_note,
                    category_view       = n.category_view,
                }).ToList();
                return(Json(list, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(null));
            }
        }
예제 #2
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            bool result = false;

            try
            {
                DialogResult res = MessageBox.Show("¿Desea eliminar la categoria?",
                                                   "My Store Desktop", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (res == DialogResult.Yes)
                {
                    int fila = dgvDatos.CurrentRow.Index;
                    categoria = categorias.ElementAt(fila);
                    CategoriesDAO cDAO = new CategoriesDAO();
                    result = cDAO.Delete(categoria.CategoryID);
                    if (result)
                    {
                        GetCategorias();
                    }
                    else
                    {
                        MessageBox.Show("Error al eliminar la categoria",
                                        "My Store Desktop", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error al eliminar la categoria: " + ex.Message, "My Store Desktop",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #3
0
 /// <summary>
 /// Delete registers based on class values informed. MinValues and nulls are skipped.
 /// Must have "MultipleActiveResultSets=True" on connection string.
 /// </summary>
 /// <param name="parCategoriesInfo">Item to delete</param>
 /// <param name="transaction">Transaction context</param>
 /// <param name="errorMessage">Error message</param>
 public virtual void Delete(CategoriesInfo parCategoriesInfo, DbTransaction transaction, out string errorMessage)
 {
     errorMessage = string.Empty;
     CategoriesDAO.Delete(parCategoriesInfo, transaction, out errorMessage);
     //By default, the caller of this method will do the commit.
     //motor.Commit();
     //motor.CloseConnection();
 }
        public void DeleteTest()
        {
            MemorySQLConnection <Category> connection = new MemorySQLConnection <Category>();
            var categoria = new CategoriesDAO(connection);
            var result    = categoria.Delete(11);

            Assert.IsTrue(result);
            Assert.AreEqual(1, categoria.Get().Count());
            Assert.AreNotEqual(11, categoria.Get().First().Id);
        }
예제 #5
0
 public void DeleteCategories(int id)
 {
     if (categoriesDAO.Delete(id))
     {
         //do not thing
     }
     else
     {
         throw new Exception("Delete Fail!");
     }
 }