Skip to content

Commit

Permalink
alterações
Browse files Browse the repository at this point in the history
  • Loading branch information
MatheusNCarvalho committed Aug 13, 2017
1 parent 0c361f7 commit bc2b423
Show file tree
Hide file tree
Showing 57 changed files with 66,117 additions and 180 deletions.
Binary file modified ProjetoFlavio/.vs/ProjetoFlavio/v15/.suo
Binary file not shown.
19 changes: 19 additions & 0 deletions ProjetoFlavio/ProjetoFlavio/App_Start/BundleConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Web.Optimization;

namespace ProjetoFlavio.App_Start
{
public class BundleConfig
{

public static void RegisterBundles(BundleCollection bundles)
{
BundleTable.EnableOptimizations = true; //Habilitar o manificar os arquivos ll
bundles.Add(new ScriptBundle("~/teste")
.IncludeDirectory("~/Content/js",".js",true));
bundles.Add(new ScriptBundle("~/bundles/comum")
.Include("~/Content/js/*.js"));

//Sempre usar o diretorio virtual "~/Content/css" quando tiver imagem no css, pois só assim para funcionar
}
}
}
4 changes: 3 additions & 1 deletion ProjetoFlavio/ProjetoFlavio/App_Start/RouteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapMvcAttributeRoutes();//Habilita no caso se quiser pernosalizar as rotas
//routes.MapMvcAttributeRoutes();//Habilita no caso se quiser pernosalizar as rotas

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");



routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
124 changes: 72 additions & 52 deletions ProjetoFlavio/ProjetoFlavio/Controllers/ClientesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using ProjetoFlavio.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Net;
using System.Web;
Expand All @@ -17,103 +18,122 @@ public class ClientesController : Controller
private readonly ClienteDao _clienteDao = new ClienteDao();
private readonly ClienteEnderecoDao _clienteEnderecoDao = new ClienteEnderecoDao();
// GET: Clientes


[Route("clientes/novo", Name ="NovosClientes")]
public ActionResult Novo()

/// [Route("clientes/novo", Name = "NovosClientes")]
public ActionResult Index()
{

return View();

var clientes = _clienteDao.Lista();
return View(clientes);

}


public ActionResult Adicionar()
{
return View(new ViewModelClienteEndereco());
}


[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Salvar(ViewModelClienteEndereco viewCadastrado)
[ValidateAntiForgeryToken]
public ActionResult Adicionar(ViewModelClienteEndereco viewCadastrado)
{
try {

if (ModelState.IsValid)
{
_clienteDao.Salva(viewCadastrado.Clientes);
viewCadastrado.ClientesEnderecos.ClientesId = viewCadastrado.Clientes.ClienteId;
_clienteEnderecoDao.Salva(viewCadastrado.ClientesEnderecos);
try
{

return RedirectToAction("Listar");
}
else
if (!ModelState.IsValid)
{
return View("Novo", viewCadastrado);
return View(viewCadastrado);
}


_clienteDao.Salva(viewCadastrado.Clientes);
viewCadastrado.ClientesEnderecos.ClientesId = viewCadastrado.Clientes.ClienteId;
_clienteEnderecoDao.Salva(viewCadastrado.ClientesEnderecos);

return RedirectToAction("Index");


}
catch (Exception ex)
catch (Exception e)
{
return View("Error", new HandleErrorInfo(ex, "Cadastrado", "Salvar"));
TempData.Add("Erro", e.Message);
return View(viewCadastrado);
}

}

[Route("clientes", Name ="ListarClientes")]
public ActionResult Listar()
{
var clientes = _clienteDao.Lista();
return View(clientes);
}


[Route("clientes/{id}", Name ="EditarClientes")]
public ActionResult Editar(int id)

// [Route("clientes/{id}", Name = "EditarClientes")]
public ActionResult Detalhes(int id)
{

if(id == null)
{
return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
}
var retornoDaConsulta = _clienteEnderecoDao.BuscaPorClienteEndereco(id);

if(retornoDaConsulta == null)

try
{
return RedirectToAction("NaoEncontrado", "Erro");
ViewModelClienteEndereco viewModelClienteEndereco = new ViewModelClienteEndereco(_clienteEnderecoDao.BuscaPorClienteEndereco(id));
return View(viewModelClienteEndereco);
}
else
catch (Exception e)
{
ViewModelClienteEndereco viewModelClienteEndereco = new ViewModelClienteEndereco(_clienteEnderecoDao.BuscaPorClienteEndereco(id));
return View("Editar", viewModelClienteEndereco);
}
TempData.Add("Erro", e.Message);
return RedirectToAction("Index");
}

}

[Route("Salvar",Name ="SalvarEditar")]

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult EditarSalvar(ViewModelClienteEndereco viewCadastrado)
public ActionResult Detalhes(ViewModelClienteEndereco viewCadastrado)
{
if (ModelState.IsValid)

try
{

if (!ModelState.IsValid)
{
return View(viewCadastrado);
}

_clienteDao.Atualiza(viewCadastrado.Clientes);
viewCadastrado.ClientesEnderecos.ClientesId = viewCadastrado.Clientes.ClienteId;
viewCadastrado.ClientesEnderecos.ClientesId = viewCadastrado.Clientes.ClienteId;
_clienteEnderecoDao.Atualiza(viewCadastrado.ClientesEnderecos);

return RedirectToAction("Listar");
return RedirectToAction("Index");
}
else
catch (Exception e)
{
return View("Editar", viewCadastrado);
TempData.Add("Erro", e.Message);
return View(viewCadastrado);
}



}

[Route("busca/{id}", Name ="busca")]
// [Route("busca/{id}", Name = "busca")]
public JsonResult BuscaCliente(int id)
{
var retornoPesquisa= _clienteEnderecoDao.BuscaPorClienteEndereco(id);
var retornoPesquisa = _clienteEnderecoDao.BuscaPorClienteEndereco(id);

return Json(retornoPesquisa, JsonRequestBehavior.AllowGet);
}

public ActionResult ValidaCPFCNPJ(string cpf)
{
var teste = new Collection<string>
{
"11111111",
"55555555",
""

};

return Json(teste.All(x => string.Equals(x, cpf, StringComparison.CurrentCultureIgnoreCase)), JsonRequestBehavior.AllowGet);
}


}
}
2 changes: 1 addition & 1 deletion ProjetoFlavio/ProjetoFlavio/Models/Cliente.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@ public class Cliente




//[Compare("Nomde do Campo",ErrorMessage="")]
}
}
20 changes: 17 additions & 3 deletions ProjetoFlavio/ProjetoFlavio/ProjetoFlavio.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<WebGreaseLibPath>..\packages\WebGrease.1.5.2\lib</WebGreaseLibPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -43,6 +44,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Antlr3.Runtime, Version=3.4.1.9004, Culture=neutral, PublicKeyToken=eb42632606e9261f, processorArchitecture=MSIL">
<HintPath>..\packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -110,6 +114,9 @@
<Reference Include="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\packages\MicrosoftReportViewerWebForms.11.0.0.0\lib\Microsoft.ReportViewer.WebForms.DLL</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.5.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Remotion.Linq, Version=2.0.0.0, Culture=neutral, PublicKeyToken=fee00910d6e5f53b, processorArchitecture=MSIL">
<HintPath>..\packages\Remotion.Linq.2.0.1\lib\net45\Remotion.Linq.dll</HintPath>
</Reference>
Expand All @@ -136,13 +143,19 @@
<Reference Include="System.Core" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Optimization, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.AspNet.Web.Optimization.1.1.3\lib\net40\System.Web.Optimization.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Xml" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.Services" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="WebGrease, Version=1.5.2.14234, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\WebGrease.1.5.2\lib\WebGrease.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Reference Include="System.Web.Razor">
Expand Down Expand Up @@ -173,6 +186,7 @@
<DependentUpon>projeto.mdf</DependentUpon>
</Content>
<Content Include="Content\img\american-express.png" />
<Content Include="Content\img\Capturar.JPG" />
<Content Include="Content\img\cropper.jpg" />
<Content Include="Content\img\img.jpg" />
<Content Include="Content\img\inbox.png" />
Expand Down Expand Up @@ -1191,6 +1205,7 @@
</Content>
</ItemGroup>
<ItemGroup>
<Compile Include="App_Start\BundleConfig.cs" />
<Compile Include="App_Start\FilterConfig.cs" />
<Compile Include="App_Start\RouteConfig.cs" />
<Compile Include="Controllers\ClientesController.cs" />
Expand Down Expand Up @@ -1595,9 +1610,8 @@
<Content Include="Views\Home\Index.cshtml" />
<Content Include="Views\Shared\_Layout.cshtml" />
<Content Include="Views\_ViewStart.cshtml" />
<Content Include="Views\Clientes\Novo.cshtml" />
<Content Include="Views\Clientes\Adicionar.cshtml" />
<Content Include="Views\Clientes\Index.cshtml" />
<Content Include="Views\Clientes\Listar.cshtml" />
<Content Include="Views\Relatorio\GeraLaudo.cshtml" />
<Content Include="Views\Relatorio\Index.cshtml" />
<Content Include="Views\Teste\Index.cshtml" />
Expand Down Expand Up @@ -1636,7 +1650,7 @@
<DependentUpon>DataSetImagem.xsd</DependentUpon>
</Content>
<Content Include="Views\Error.cshtml" />
<Content Include="Views\Clientes\Editar.cshtml" />
<Content Include="Views\Clientes\Detalhes.cshtml" />
<None Include="Web.Debug.config">
<DependentUpon>Web.config</DependentUpon>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,11 @@
<div class="x_content">
<br />

@using (Html.BeginForm("Salvar", "Clientes", FormMethod.Post, new { @class = "form-horizontal form-label-left", id = "demo-form2" }))
@using (Html.BeginForm("Adicionar", "Clientes", FormMethod.Post, new { @class = "form-horizontal form-label-left", id = "demo-form2" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })

<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="Nome">
Nome Completo <span class="required">*</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div class="x_content">
<br />

@using (Html.BeginRouteForm("SalvarEditar", FormMethod.Post, new { @class = "form-horizontal form-label-left", id = "demo-form2" }))
@using (Html.BeginForm("Detalhes","Clientes", FormMethod.Post, new { @class = "form-horizontal form-label-left", id = "demo-form2" }))
{
@Html.AntiForgeryToken()
@Html.HiddenFor(model => model.Clientes.ClienteId);
Expand All @@ -57,7 +57,7 @@
<div class="col-md-3 col-sm-6 col-xs-12">
@Html.EditorFor(model => model.Clientes.CpfCnpj, new { htmlAttributes = new { @class = "form-control col-md-7 col-xs-12", placeholder = "CPF", disabled= "disabled" } })
@Html.ValidationMessageFor(model => model.Clientes.CpfCnpj, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.Clientes.CpfCnpj);
@Html.HiddenFor(model => model.Clientes.CpfCnpj)
</div>
</div>

Expand Down
Loading

0 comments on commit bc2b423

Please sign in to comment.