예제 #1
0
 public string excluirCliente(Cliente c)
 {
     string erro = null;
     try
     {
         db.Cliente.DeleteObject(c);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         erro = ex.Message;
     }
     return erro;
 }
예제 #2
0
 public string adicionarCliente(Cliente c)
 {
     string erro = null;
     try
     {
         db.Cliente.AddObject(c);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         erro = ex.Message;
     }
     return erro;
 }
예제 #3
0
 public ActionResult Edit(int id)
 {
     if (Roles.IsUserInRole(User.Identity.Name, "administrador") || (System.Web.Security.Roles.IsUserInRole(User.Identity.Name, "gerencia")))
     {
         Cliente c = new Cliente();
         ViewBag.Titulo = "Novo Cliente";
         if (id != 0)
         {
             c = clienteModel.obterCliente(id);
             ViewBag.Titulo = "Editar Cliente";
         }
         return View(c);
     }
     return Redirect("/Shared/Error");
 }
예제 #4
0
 public ActionResult Edit(Cliente c)
 {
     string erro = clienteModel.validarCliente(c);
     if (c.IdCliente == 0)
         erro = clienteModel.adicionarCliente(c);
     else
         erro = clienteModel.editarCliente(c);
     if (erro == null)
     {
         return RedirectToAction("Index");
     }
     else
     {
         ViewBag.Erro = erro;
         return View(c);
     }
 }
예제 #5
0
 public string editarCliente(Cliente c)
 {
     string erro = null;
     try
     {
         if (c.EntityState == System.Data.EntityState.Detached)
         {
             db.Cliente.Attach(c);
         }
         db.ObjectStateManager.ChangeObjectState(c, System.Data.EntityState.Modified);
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         erro = ex.Message;
     }
     return erro;
 }
예제 #6
0
 /// <summary>
 /// Create a new Cliente object.
 /// </summary>
 /// <param name="idCliente">Initial value of the IdCliente property.</param>
 /// <param name="nome">Initial value of the Nome property.</param>
 /// <param name="cpf">Initial value of the Cpf property.</param>
 public static Cliente CreateCliente(global::System.Int32 idCliente, global::System.String nome, global::System.String cpf)
 {
     Cliente cliente = new Cliente();
     cliente.IdCliente = idCliente;
     cliente.Nome = nome;
     cliente.Cpf = cpf;
     return cliente;
 }
예제 #7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Cliente EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCliente(Cliente cliente)
 {
     base.AddObject("Cliente", cliente);
 }
예제 #8
0
        public string validarCliente(Cliente c)
        {
            string erro = null;

            if (c.Nome == null || c.Nome == "")
            {
                return "Nome obrigatório!";
            }
            if (c.Cpf == null || c.Cpf == "")
            {
                return "CPF obrigatório!";
            }

            return erro;
        }