コード例 #1
0
ファイル: ClienteBll.cs プロジェクト: LucazDenadai/PIM
        public bool Delete(int id)
        {
            if (id == default)
            {
                return(false);
            }

            var comand = $"DELETE FROM TbCliente WHERE IDCLIENTE = '{id}'";

            return(_dal.Delete(comand));
        }
コード例 #2
0
        public void Delete(Cliente o)
        {
            using (var dal = DatabaseConnection.GetDataAccessLayer())
            {
                var dao = new ClienteDal(dal);

                try
                {
                    dao.Delete(o);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
コード例 #3
0
        public JsonResult ExcluirCliente(int id)
        {
            try
            {
                ClienteDal d = new ClienteDal();
                Cliente    c = d.FindById(id); //buscar o cliente pelo id..

                //excluindo..
                d.Delete(c);

                return(Json("Cliente " + c.Nome + ", excluido com sucesso."));
            }
            catch (Exception e)
            {
                return(Json("Erro ao excluir Cliente: " + e.Message));
            }
        }
コード例 #4
0
        public ActionResult Exclusao(int id)
        {
            try
            {
                ClienteDal d = new ClienteDal();

                Cliente cliente = d.FindById(id);

                d.Delete(cliente);

                ViewBag.Mensagem = $"Cliente {cliente.Nome} Excluido com sucesso";
            }
            catch (Exception erro)
            {
                ViewBag.Mensagem = erro.Message;
            }

            return(RedirectToAction("Consulta"));
        }
コード例 #5
0
        //Ação para excluir um cliente selecionado..
        // GET: /Cliente/Exclusao/id
        public ActionResult Exclusao(int id)
        {
            try
            {
                ClienteDal d = new ClienteDal(); //persistencia..
                //buscar o cliente pelo id..
                Cliente c = d.FindById(id);
                //excluir o cliente
                d.Delete(c);

                ViewBag.Mensagem = "Cliente " + c.Nome + ", excluido com sucesso.";
            }
            catch (Exception e)
            {
                //imprimir mensagem de erro..
                ViewBag.Mensagem = e.Message;
            }

            return(View());
        }
コード例 #6
0
        public ActionResult Exclusao(int id)
        {
            try
            {
                ClienteDal d = new ClienteDal();
                Cliente    c = d.FindById(id);

                if (c != null)
                {
                    d.Delete(id);
                    ViewBag.Mensagem = "Cliente " + c.Nome + " excluído com sucesso!";
                }
                else
                {
                    throw new Exception("Cliente não encontrado.");
                }
            }
            catch (Exception e)
            {
                ViewBag.Mensagem = e.Message;
            }

            return(View());
        }