├── .gitattributes ├── .gitignore ├── LICENSE.txt ├── SistemaVentaAngular.sln ├── SistemaVentaAngular ├── .gitignore ├── ClientApp │ ├── .browserslistrc │ ├── .editorconfig │ ├── .gitignore │ ├── README.md │ ├── angular.json │ ├── karma.conf.js │ ├── package-lock.json │ ├── package.json │ ├── proxy.conf.js │ ├── src │ │ ├── app │ │ │ ├── app-routing.module.ts │ │ │ ├── app.component.css │ │ │ ├── app.component.html │ │ │ ├── app.component.ts │ │ │ ├── app.module.ts │ │ │ ├── components │ │ │ │ ├── login │ │ │ │ │ ├── login.component.css │ │ │ │ │ ├── login.component.html │ │ │ │ │ └── login.component.ts │ │ │ │ ├── not-found │ │ │ │ │ ├── not-found.component.css │ │ │ │ │ ├── not-found.component.html │ │ │ │ │ └── not-found.component.ts │ │ │ │ ├── pages │ │ │ │ │ ├── dashboard │ │ │ │ │ │ ├── dashboard.component.css │ │ │ │ │ │ ├── dashboard.component.html │ │ │ │ │ │ └── dashboard.component.ts │ │ │ │ │ ├── historialventa │ │ │ │ │ │ ├── historialventa.component.css │ │ │ │ │ │ ├── historialventa.component.html │ │ │ │ │ │ └── historialventa.component.ts │ │ │ │ │ ├── modals │ │ │ │ │ │ ├── dialog-delete-producto │ │ │ │ │ │ │ ├── dialog-delete-producto.component.css │ │ │ │ │ │ │ ├── dialog-delete-producto.component.html │ │ │ │ │ │ │ └── dialog-delete-producto.component.ts │ │ │ │ │ │ ├── dialog-delete-usuario │ │ │ │ │ │ │ ├── dialog-delete-usuario.component.css │ │ │ │ │ │ │ ├── dialog-delete-usuario.component.html │ │ │ │ │ │ │ └── dialog-delete-usuario.component.ts │ │ │ │ │ │ ├── dialog-detalle-venta │ │ │ │ │ │ │ ├── dialog-detalle-venta.component.css │ │ │ │ │ │ │ ├── dialog-detalle-venta.component.html │ │ │ │ │ │ │ └── dialog-detalle-venta.component.ts │ │ │ │ │ │ ├── dialog-producto │ │ │ │ │ │ │ ├── dialog-producto.component.css │ │ │ │ │ │ │ ├── dialog-producto.component.html │ │ │ │ │ │ │ └── dialog-producto.component.ts │ │ │ │ │ │ ├── dialog-resultado-venta │ │ │ │ │ │ │ ├── dialog-resultado-venta.component.css │ │ │ │ │ │ │ ├── dialog-resultado-venta.component.html │ │ │ │ │ │ │ └── dialog-resultado-venta.component.ts │ │ │ │ │ │ └── dialog-usuario │ │ │ │ │ │ │ ├── dialog-usuario.component.css │ │ │ │ │ │ │ ├── dialog-usuario.component.html │ │ │ │ │ │ │ └── dialog-usuario.component.ts │ │ │ │ │ ├── navigation │ │ │ │ │ │ ├── navigation.component.css │ │ │ │ │ │ ├── navigation.component.html │ │ │ │ │ │ └── navigation.component.ts │ │ │ │ │ ├── pages-routing.module.ts │ │ │ │ │ ├── pages.component.css │ │ │ │ │ ├── pages.component.html │ │ │ │ │ ├── pages.component.ts │ │ │ │ │ ├── pages.module.ts │ │ │ │ │ ├── productos │ │ │ │ │ │ ├── productos.component.css │ │ │ │ │ │ ├── productos.component.html │ │ │ │ │ │ └── productos.component.ts │ │ │ │ │ ├── reportes │ │ │ │ │ │ ├── reportes.component.css │ │ │ │ │ │ ├── reportes.component.html │ │ │ │ │ │ └── reportes.component.ts │ │ │ │ │ ├── usuarios │ │ │ │ │ │ ├── usuarios.component.css │ │ │ │ │ │ ├── usuarios.component.html │ │ │ │ │ │ └── usuarios.component.ts │ │ │ │ │ └── vender │ │ │ │ │ │ ├── vender.component.css │ │ │ │ │ │ ├── vender.component.html │ │ │ │ │ │ └── vender.component.ts │ │ │ │ └── reusable │ │ │ │ │ └── reusable.module.ts │ │ │ ├── interfaces │ │ │ │ ├── categoria.ts │ │ │ │ ├── detalle-venta.ts │ │ │ │ ├── producto.ts │ │ │ │ ├── reporte-venta.ts │ │ │ │ ├── reporte.ts │ │ │ │ ├── response-api.ts │ │ │ │ ├── rol.ts │ │ │ │ ├── usuario.ts │ │ │ │ └── venta.ts │ │ │ └── services │ │ │ │ ├── categoria.service.ts │ │ │ │ ├── dashboard.service.spec.ts │ │ │ │ ├── dashboard.service.ts │ │ │ │ ├── producto.service.ts │ │ │ │ ├── rol-servicio.service.ts │ │ │ │ ├── usuario-servicio.service.ts │ │ │ │ └── venta.service.ts │ │ ├── assets │ │ │ └── .gitkeep │ │ ├── environments │ │ │ ├── environment.prod.ts │ │ │ └── environment.ts │ │ ├── favicon.ico │ │ ├── index.html │ │ ├── main.ts │ │ ├── polyfills.ts │ │ ├── styles.css │ │ └── test.ts │ ├── tsconfig.app.json │ ├── tsconfig.json │ └── tsconfig.spec.json ├── Controllers │ ├── CategoriaController.cs │ ├── DashBoardController.cs │ ├── ProductoController.cs │ ├── RolController.cs │ ├── UsuarioController.cs │ ├── VentaController.cs │ └── WeatherForecastController.cs ├── DTOs │ ├── CategoriaDTO.cs │ ├── DashBoardDTO.cs │ ├── DetalleVentaDTO.cs │ ├── ProductoDTO.cs │ ├── ReporteDTO.cs │ ├── RolDTO.cs │ ├── UsuarioDTO.cs │ ├── VentaDTO.cs │ └── VentasSemanaDTO.cs ├── Models │ ├── Categoria.cs │ ├── DBVentaAngularContext.cs │ ├── DetalleVenta.cs │ ├── NumeroDocumento.cs │ ├── Producto.cs │ ├── Rol.cs │ ├── Usuario.cs │ └── Venta.cs ├── Pages │ ├── Error.cshtml │ ├── Error.cshtml.cs │ └── _ViewImports.cshtml ├── Program.cs ├── Properties │ └── launchSettings.json ├── Repository │ ├── Contratos │ │ ├── ICategoriaRepositorio.cs │ │ ├── IDashBoardRepositorio.cs │ │ ├── IProductoRepositorio.cs │ │ ├── IRolRepositorio.cs │ │ ├── IUsuarioRepositorio.cs │ │ └── IVentaRepositorio.cs │ └── Implementacion │ │ ├── CategoriaRepositorio.cs │ │ ├── DashBoardRepositorio.cs │ │ ├── ProductoRepositorio.cs │ │ ├── RolRepositorio.cs │ │ ├── UsuarioRepositorio.cs │ │ └── VentaRepositorio.cs ├── SistemaVentaAngular.csproj ├── Utilidades │ ├── AutoMapperProfile.cs │ └── Response.cs ├── WeatherForecast.cs ├── appsettings.Development.json ├── appsettings.json └── wwwroot │ └── favicon.ico └── Utilidad ├── Scripts to BD ├── script_db.txt └── script_insert.txt └── Utilidad.csproj /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [year] [fullname] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SistemaVentaAngular.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32014.148 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SistemaVentaAngular", "SistemaVentaAngular\SistemaVentaAngular.csproj", "{B04CABB2-39CE-402F-8E5C-2974620CF791}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Utilidad", "Utilidad\Utilidad.csproj", "{54E8A081-CA8E-4F42-B77B-486C66A82550}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {B04CABB2-39CE-402F-8E5C-2974620CF791}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {B04CABB2-39CE-402F-8E5C-2974620CF791}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {B04CABB2-39CE-402F-8E5C-2974620CF791}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {B04CABB2-39CE-402F-8E5C-2974620CF791}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {54E8A081-CA8E-4F42-B77B-486C66A82550}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {54E8A081-CA8E-4F42-B77B-486C66A82550}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {54E8A081-CA8E-4F42-B77B-486C66A82550}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {54E8A081-CA8E-4F42-B77B-486C66A82550}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {0F340528-A461-4F2B-9143-1F768B4396F1} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /SistemaVentaAngular/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.userosscache 8 | *.sln.docstates 9 | 10 | # User-specific files (MonoDevelop/Xamarin Studio) 11 | *.userprefs 12 | 13 | # Build results 14 | [Dd]ebug/ 15 | [Dd]ebugPublic/ 16 | [Rr]elease/ 17 | [Rr]eleases/ 18 | x64/ 19 | x86/ 20 | build/ 21 | bld/ 22 | bin/ 23 | Bin/ 24 | obj/ 25 | Obj/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | 30 | # MSTest test Results 31 | [Tt]est[Rr]esult*/ 32 | [Bb]uild[Ll]og.* 33 | 34 | # NUNIT 35 | *.VisualState.xml 36 | TestResult.xml 37 | 38 | # Build Results of an ATL Project 39 | [Dd]ebugPS/ 40 | [Rr]eleasePS/ 41 | dlldata.c 42 | 43 | *_i.c 44 | *_p.c 45 | *_i.h 46 | *.ilk 47 | *.meta 48 | *.obj 49 | *.pch 50 | *.pdb 51 | *.pgc 52 | *.pgd 53 | *.rsp 54 | *.sbr 55 | *.tlb 56 | *.tli 57 | *.tlh 58 | *.tmp 59 | *.tmp_proj 60 | *.log 61 | *.vspscc 62 | *.vssscc 63 | .builds 64 | *.pidb 65 | *.svclog 66 | *.scc 67 | 68 | # Chutzpah Test files 69 | _Chutzpah* 70 | 71 | # Visual C++ cache files 72 | ipch/ 73 | *.aps 74 | *.ncb 75 | *.opendb 76 | *.opensdf 77 | *.sdf 78 | *.cachefile 79 | 80 | # Visual Studio profiler 81 | *.psess 82 | *.vsp 83 | *.vspx 84 | *.sap 85 | 86 | # TFS 2012 Local Workspace 87 | $tf/ 88 | 89 | # Guidance Automation Toolkit 90 | *.gpState 91 | 92 | # ReSharper is a .NET coding add-in 93 | _ReSharper*/ 94 | *.[Rr]e[Ss]harper 95 | *.DotSettings.user 96 | 97 | # JustCode is a .NET coding add-in 98 | .JustCode 99 | 100 | # TeamCity is a build add-in 101 | _TeamCity* 102 | 103 | # DotCover is a Code Coverage Tool 104 | *.dotCover 105 | 106 | # NCrunch 107 | _NCrunch_* 108 | .*crunch*.local.xml 109 | nCrunchTemp_* 110 | 111 | # MightyMoose 112 | *.mm.* 113 | AutoTest.Net/ 114 | 115 | # Web workbench (sass) 116 | .sass-cache/ 117 | 118 | # Installshield output folder 119 | [Ee]xpress/ 120 | 121 | # DocProject is a documentation generator add-in 122 | DocProject/buildhelp/ 123 | DocProject/Help/*.HxT 124 | DocProject/Help/*.HxC 125 | DocProject/Help/*.hhc 126 | DocProject/Help/*.hhk 127 | DocProject/Help/*.hhp 128 | DocProject/Help/Html2 129 | DocProject/Help/html 130 | 131 | # Click-Once directory 132 | publish/ 133 | 134 | # Publish Web Output 135 | *.[Pp]ublish.xml 136 | *.azurePubxml 137 | # TODO: Comment the next line if you want to checkin your web deploy settings 138 | # but database connection strings (with potential passwords) will be unencrypted 139 | *.pubxml 140 | *.publishproj 141 | 142 | # NuGet Packages 143 | *.nupkg 144 | # The packages folder can be ignored because of Package Restore 145 | **/packages/* 146 | # except build/, which is used as an MSBuild target. 147 | !**/packages/build/ 148 | # Uncomment if necessary however generally it will be regenerated when needed 149 | #!**/packages/repositories.config 150 | 151 | # Microsoft Azure Build Output 152 | csx/ 153 | *.build.csdef 154 | 155 | # Microsoft Azure Emulator 156 | ecf/ 157 | rcf/ 158 | 159 | # Microsoft Azure ApplicationInsights config file 160 | ApplicationInsights.config 161 | 162 | # Windows Store app package directory 163 | AppPackages/ 164 | BundleArtifacts/ 165 | 166 | # Visual Studio cache files 167 | # files ending in .cache can be ignored 168 | *.[Cc]ache 169 | # but keep track of directories ending in .cache 170 | !*.[Cc]ache/ 171 | 172 | # Others 173 | ClientBin/ 174 | ~$* 175 | *~ 176 | *.dbmdl 177 | *.dbproj.schemaview 178 | *.pfx 179 | *.publishsettings 180 | orleans.codegen.cs 181 | 182 | /node_modules 183 | 184 | # RIA/Silverlight projects 185 | Generated_Code/ 186 | 187 | # Backup & report files from converting an old project file 188 | # to a newer Visual Studio version. Backup files are not needed, 189 | # because we have git ;-) 190 | _UpgradeReport_Files/ 191 | Backup*/ 192 | UpgradeLog*.XML 193 | UpgradeLog*.htm 194 | 195 | # SQL Server files 196 | *.mdf 197 | *.ldf 198 | 199 | # Business Intelligence projects 200 | *.rdl.data 201 | *.bim.layout 202 | *.bim_*.settings 203 | 204 | # Microsoft Fakes 205 | FakesAssemblies/ 206 | 207 | # GhostDoc plugin setting file 208 | *.GhostDoc.xml 209 | 210 | # Node.js Tools for Visual Studio 211 | .ntvs_analysis.dat 212 | 213 | # Visual Studio 6 build log 214 | *.plg 215 | 216 | # Visual Studio 6 workspace options file 217 | *.opt 218 | 219 | # Visual Studio LightSwitch build output 220 | **/*.HTMLClient/GeneratedArtifacts 221 | **/*.DesktopClient/GeneratedArtifacts 222 | **/*.DesktopClient/ModelManifest.xml 223 | **/*.Server/GeneratedArtifacts 224 | **/*.Server/ModelManifest.xml 225 | _Pvt_Extensions 226 | 227 | # Paket dependency manager 228 | .paket/paket.exe 229 | 230 | # FAKE - F# Make 231 | .fake/ 232 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/.browserslistrc: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # For the full list of supported browsers by the Angular framework, please see: 6 | # https://angular.io/guide/browser-support 7 | 8 | # You can see what browsers were selected by your queries by running: 9 | # npx browserslist 10 | 11 | last 1 Chrome version 12 | last 1 Firefox version 13 | last 2 Edge major versions 14 | last 2 Safari major versions 15 | last 2 iOS major versions 16 | Firefox ESR 17 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/.editorconfig: -------------------------------------------------------------------------------- 1 | # Editor configuration, see https://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.ts] 12 | quote_type = single 13 | 14 | [*.md] 15 | max_line_length = off 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/.gitignore: -------------------------------------------------------------------------------- 1 | # See http://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # Compiled output 4 | /dist 5 | /tmp 6 | /out-tsc 7 | /bazel-out 8 | 9 | # Node 10 | /node_modules 11 | npm-debug.log 12 | yarn-error.log 13 | 14 | # IDEs and editors 15 | .idea/ 16 | .project 17 | .classpath 18 | .c9/ 19 | *.launch 20 | .settings/ 21 | *.sublime-workspace 22 | 23 | # Visual Studio Code 24 | .vscode/* 25 | !.vscode/settings.json 26 | !.vscode/tasks.json 27 | !.vscode/launch.json 28 | !.vscode/extensions.json 29 | .history/* 30 | 31 | # Miscellaneous 32 | /.angular/cache 33 | .sass-cache/ 34 | /connect.lock 35 | /coverage 36 | /libpeerconnection.log 37 | testem.log 38 | /typings 39 | 40 | # System files 41 | .DS_Store 42 | Thumbs.db 43 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/README.md: -------------------------------------------------------------------------------- 1 | # ClientApp 2 | 3 | This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 14.2.4. 4 | 5 | ## Development server 6 | 7 | Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files. 8 | 9 | ## Code scaffolding 10 | 11 | Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. 12 | 13 | ## Build 14 | 15 | Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. 16 | 17 | ## Running unit tests 18 | 19 | Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). 20 | 21 | ## Running end-to-end tests 22 | 23 | Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. 24 | 25 | ## Further help 26 | 27 | To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. 28 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "newProjectRoot": "projects", 5 | "projects": { 6 | "SistemaVentaAngular": { 7 | "projectType": "application", 8 | "schematics": { 9 | "@schematics/angular:application": { 10 | "strict": true 11 | } 12 | }, 13 | "root": "", 14 | "sourceRoot": "src", 15 | "prefix": "app", 16 | "architect": { 17 | "build": { 18 | "builder": "@angular-devkit/build-angular:browser", 19 | "options": { 20 | "progress": false, 21 | "outputPath": "dist", 22 | "index": "src/index.html", 23 | "main": "src/main.ts", 24 | "polyfills": "src/polyfills.ts", 25 | "tsConfig": "tsconfig.app.json", 26 | "assets": [ 27 | "src/assets" 28 | ], 29 | "styles": [ 30 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 31 | "src/styles.css" 32 | ], 33 | "scripts": [] 34 | }, 35 | "configurations": { 36 | "production": { 37 | "budgets": [ 38 | { 39 | "type": "initial", 40 | "maximumWarning": "500kb", 41 | "maximumError": "1mb" 42 | }, 43 | { 44 | "type": "anyComponentStyle", 45 | "maximumWarning": "2kb", 46 | "maximumError": "4kb" 47 | } 48 | ], 49 | "fileReplacements": [ 50 | { 51 | "replace": "src/environments/environment.ts", 52 | "with": "src/environments/environment.prod.ts" 53 | } 54 | ], 55 | "outputHashing": "all" 56 | }, 57 | "development": { 58 | "buildOptimizer": false, 59 | "optimization": false, 60 | "vendorChunk": true, 61 | "extractLicenses": false, 62 | "sourceMap": true, 63 | "namedChunks": true 64 | } 65 | }, 66 | "defaultConfiguration": "production" 67 | }, 68 | "serve": { 69 | "builder": "@angular-devkit/build-angular:dev-server", 70 | "configurations": { 71 | "production": { 72 | "browserTarget": "SistemaVentaAngular:build:production" 73 | }, 74 | "development": { 75 | "browserTarget": "SistemaVentaAngular:build:development", 76 | "proxyConfig": "proxy.conf.js" 77 | } 78 | }, 79 | "defaultConfiguration": "development" 80 | }, 81 | "extract-i18n": { 82 | "builder": "@angular-devkit/build-angular:extract-i18n", 83 | "options": { 84 | "browserTarget": "SistemaVentaAngular:build" 85 | } 86 | }, 87 | "test": { 88 | "builder": "@angular-devkit/build-angular:karma", 89 | "options": { 90 | "main": "src/test.ts", 91 | "polyfills": "src/polyfills.ts", 92 | "tsConfig": "tsconfig.spec.json", 93 | "karmaConfig": "karma.conf.js", 94 | "assets": [ 95 | "src/assets" 96 | ], 97 | "styles": [ 98 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css", 99 | "src/styles.css" 100 | ], 101 | "scripts": [] 102 | } 103 | }, 104 | "server": { 105 | "builder": "@angular-devkit/build-angular:server", 106 | "options": { 107 | "outputPath": "dist-server", 108 | "main": "src/main.ts", 109 | "tsConfig": "tsconfig.server.json" 110 | }, 111 | "configurations": { 112 | "dev": { 113 | "optimization": true, 114 | "outputHashing": "all", 115 | "sourceMap": false, 116 | "namedChunks": false, 117 | "extractLicenses": true, 118 | "vendorChunk": true 119 | }, 120 | "production": { 121 | "optimization": true, 122 | "outputHashing": "all", 123 | "sourceMap": false, 124 | "namedChunks": false, 125 | "extractLicenses": true, 126 | "vendorChunk": false 127 | } 128 | } 129 | } 130 | } 131 | } 132 | }, 133 | "defaultProject": "SistemaVentaAngular", 134 | "cli": { 135 | "analytics": false 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | jasmine: { 17 | // you can add configuration options for Jasmine here 18 | // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html 19 | // for example, you can disable the random execution with `random: false` 20 | // or set a specific seed with `seed: 4321` 21 | }, 22 | clearContext: false // leave Jasmine Spec Runner output visible in browser 23 | }, 24 | jasmineHtmlReporter: { 25 | suppressAll: true // removes the duplicated traces 26 | }, 27 | coverageReporter: { 28 | dir: require('path').join(__dirname, './coverage/client-app'), 29 | subdir: '.', 30 | reporters: [ 31 | { type: 'html' }, 32 | { type: 'text-summary' } 33 | ] 34 | }, 35 | reporters: ['progress', 'kjhtml'], 36 | port: 9876, 37 | colors: true, 38 | logLevel: config.LOG_INFO, 39 | autoWatch: true, 40 | browsers: ['Chrome'], 41 | singleRun: false, 42 | restartOnFileChange: true 43 | }); 44 | }; 45 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sistemaventaangular", 3 | "version": "0.0.0", 4 | "scripts": { 5 | "ng": "ng", 6 | "start": "ng serve --port 44496", 7 | "build": "ng build", 8 | "build:ssr": "ng run SistemaVentaAngular:server:dev", 9 | "watch": "ng build --watch --configuration development", 10 | "test": "ng test" 11 | }, 12 | "private": true, 13 | "dependencies": { 14 | "@angular/animations": "^14.2.0", 15 | "@angular/cdk": "^14.2.5", 16 | "@angular/common": "^14.2.0", 17 | "@angular/compiler": "^14.2.0", 18 | "@angular/core": "^14.2.0", 19 | "@angular/forms": "^14.2.0", 20 | "@angular/material": "^14.2.5", 21 | "@angular/material-moment-adapter": "^14.2.6", 22 | "@angular/platform-browser": "^14.2.0", 23 | "@angular/platform-browser-dynamic": "^14.2.0", 24 | "@angular/router": "^14.2.0", 25 | "chart.js": "^3.9.1", 26 | "moment": "^2.29.4", 27 | "ngx-mask": "^14.2.4", 28 | "rxjs": "~7.5.0", 29 | "tslib": "^2.3.0", 30 | "xlsx": "^0.18.5", 31 | "zone.js": "~0.11.4" 32 | }, 33 | "devDependencies": { 34 | "@angular-devkit/build-angular": "^14.2.4", 35 | "@angular/cli": "~14.2.4", 36 | "@angular/compiler-cli": "^14.2.0", 37 | "@types/jasmine": "~4.0.0", 38 | "jasmine-core": "~4.3.0", 39 | "karma": "~6.4.0", 40 | "karma-chrome-launcher": "~3.1.0", 41 | "karma-coverage": "~2.2.0", 42 | "karma-jasmine": "~5.1.0", 43 | "karma-jasmine-html-reporter": "~2.0.0", 44 | "typescript": "~4.7.2" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/proxy.conf.js: -------------------------------------------------------------------------------- 1 | const { env } = require('process'); 2 | 3 | const target = env.ASPNETCORE_HTTPS_PORT ? `https://localhost:${env.ASPNETCORE_HTTPS_PORT}` : 4 | env.ASPNETCORE_URLS ? env.ASPNETCORE_URLS.split(';')[0] : 'http://localhost:64159'; 5 | 6 | const PROXY_CONFIG = [ 7 | { 8 | context: [ 9 | "/weatherforecast", 10 | "/api/rol", 11 | "/api/usuario", 12 | "/api/categoria", 13 | "/api/producto", 14 | "/api/venta", 15 | "/api/dashboard", 16 | ], 17 | target: target, 18 | secure: false 19 | } 20 | ] 21 | 22 | module.exports = PROXY_CONFIG; 23 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | import { LoginComponent } from './components/login/login.component'; 4 | import { NotFoundComponent } from './components/not-found/not-found.component'; 5 | 6 | const routes: Routes = [ 7 | {path:'',redirectTo:'login',pathMatch:'full'}, 8 | { path: 'login', component: LoginComponent }, 9 | { path: 'pages', loadChildren: () => import('./components/pages/pages.module').then(x => x.PagesModule) }, 10 | {path:'**',component:NotFoundComponent,pathMatch:'full'} 11 | ]; 12 | 13 | @NgModule({ 14 | imports: [RouterModule.forRoot(routes)], 15 | exports: [RouterModule] 16 | }) 17 | export class AppRoutingModule { } 18 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/app.component.css: -------------------------------------------------------------------------------- 1 | /*.content-body { 2 | min-height:100vh; 3 | padding:60px 1rem; 4 | background-color: #16bca8; 5 | display:block; 6 | } 7 | */ 8 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-root', 5 | templateUrl: './app.component.html', 6 | styleUrls: ['./app.component.css'] 7 | }) 8 | export class AppComponent { 9 | title = 'ClientApp'; 10 | } 11 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | 4 | import { AppRoutingModule } from './app-routing.module'; 5 | import { AppComponent } from './app.component'; 6 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 7 | 8 | import { LoginComponent } from './components/login/login.component'; 9 | import { NotFoundComponent } from './components/not-found/not-found.component'; 10 | import { ReusableModule } from './components/reusable/reusable.module'; 11 | import { NgxMaskModule, IConfig } from 'ngx-mask' 12 | 13 | export const options: Partial | (() => Partial) = null; 14 | 15 | 16 | @NgModule({ 17 | declarations: [ 18 | AppComponent, 19 | LoginComponent, 20 | NotFoundComponent 21 | ], 22 | imports: [ 23 | BrowserModule, 24 | AppRoutingModule, 25 | BrowserAnimationsModule, 26 | 27 | ReusableModule, 28 | NgxMaskModule.forRoot() 29 | ], 30 | providers: [], 31 | bootstrap: [AppComponent] 32 | }) 33 | export class AppModule { } 34 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/login/login.component.css: -------------------------------------------------------------------------------- 1 | .loginCard { 2 | max-width:328px !important; 3 | margin:2em auto; 4 | text-align:center; 5 | max-height:600px; 6 | } 7 | .body { 8 | display: flex; 9 | justify-content: center; 10 | height: 100%; 11 | align-items: center; 12 | background-color: #f5f5f5; 13 | } 14 | 15 | .header { 16 | text-align: center; 17 | } 18 | 19 | .full-width { 20 | width: 80%; 21 | } 22 | 23 | 24 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/login/login.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
5 |

Login

6 |
7 | 8 |
9 |
10 | 11 | Email 12 | 13 | mail 14 | 15 | 16 | Contraseña 17 | 18 | 21 | 22 | 26 |
27 |
28 | 29 |
30 | 31 | 32 | 33 |
34 |
35 | 36 | 37 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/login/login.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; 3 | import { Router } from '@angular/router'; 4 | import { UsuarioServicioService } from '../../services/usuario-servicio.service'; 5 | import { MatSnackBar } from '@angular/material/snack-bar'; 6 | 7 | @Component({ 8 | selector: 'app-login', 9 | templateUrl: './login.component.html', 10 | styleUrls: ['./login.component.css'] 11 | }) 12 | export class LoginComponent implements OnInit { 13 | formLogin: FormGroup; 14 | hidePassword:boolean = true; 15 | loading: boolean = false; 16 | 17 | 18 | constructor( 19 | private fb: FormBuilder, 20 | private router: Router, 21 | private _snackBar: MatSnackBar, 22 | private _usuarioServicio: UsuarioServicioService 23 | ) { 24 | this.formLogin = this.fb.group({ 25 | email: ['', Validators.required], 26 | password: ['', Validators.required] 27 | }) 28 | } 29 | 30 | ngOnInit(): void { 31 | } 32 | 33 | onLogin() { 34 | this.loading = true; 35 | 36 | const correo = this.formLogin.value.email; 37 | const clave = this.formLogin.value.password; 38 | 39 | this._usuarioServicio.getIniciarSesion(correo, clave).subscribe({ 40 | next: (data) => { 41 | 42 | if (data.status) { 43 | this.router.navigate(['pages']) 44 | } else { 45 | this._snackBar.open("No se encontraron coincidencias", 'Oops!', { duration: 3000 }); 46 | } 47 | 48 | }, 49 | error: (e) => { 50 | this._snackBar.open("hubo un error", 'Oops!', { duration:3000 }); 51 | }, 52 | complete: () => { 53 | this.loading = false; 54 | } 55 | }) 56 | 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/not-found/not-found.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodigoEstudiante/085_SistemaVentaAngularNet/55ab2e653be7ff98d9df49f4a1a5e96bd059a876/SistemaVentaAngular/ClientApp/src/app/components/not-found/not-found.component.css -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/not-found/not-found.component.html: -------------------------------------------------------------------------------- 1 |

not-found works!

2 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/not-found/not-found.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-not-found', 5 | templateUrl: './not-found.component.html', 6 | styleUrls: ['./not-found.component.css'] 7 | }) 8 | export class NotFoundComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | ngOnInit(): void { 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/dashboard/dashboard.component.css: -------------------------------------------------------------------------------- 1 | .example-card { 2 | width:80% 3 | } 4 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/dashboard/dashboard.component.html: -------------------------------------------------------------------------------- 1 | 2 |

DashBoard - resumen última semana

3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | payments 15 |
16 | Total Ingresos 17 | S/. {{totalIngresos}} 18 |
19 |
20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 |
28 | sell 29 |
30 | Total Ventas 31 | {{totalVentas}} 32 |
33 |
34 | 35 |
36 | 37 | 38 | 39 | 40 | 41 |
42 | collections_bookmark 43 |
44 | Total Productos 45 | {{totalProductos}} 46 |
47 |
48 |
49 | 50 | 51 |
52 | 53 | 54 | 55 |
56 | 57 |
58 |
59 |
60 | 61 | 62 | 63 |
64 | 65 |
66 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/dashboard/dashboard.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | import { Chart, registerables } from 'node_modules/chart.js'; 4 | import { DashboardService } from '../../../services/dashboard.service'; 5 | Chart.register(...registerables); 6 | 7 | @Component({ 8 | selector: 'app-dashboard', 9 | templateUrl: './dashboard.component.html', 10 | styleUrls: ['./dashboard.component.css'] 11 | }) 12 | export class DashboardComponent implements OnInit { 13 | totalIngresos: string = "0"; 14 | totalVentas: string = "0"; 15 | totalProductos: string = "0"; 16 | 17 | constructor( 18 | private _dashboardServicio: DashboardService, 19 | ) { 20 | 21 | 22 | } 23 | 24 | ngOnInit(): void { 25 | 26 | this._dashboardServicio.resumen().subscribe({ 27 | next: (data) => { 28 | if (data.status) { 29 | 30 | this.totalIngresos = data.value.totalIngresos; 31 | this.totalVentas = data.value.totalVentas; 32 | this.totalProductos = data.value.totalProductos; 33 | 34 | const arrayData: any[] = data.value.ventasUltimaSemana; 35 | 36 | const labelTemp = arrayData.map((value) => value.fecha); 37 | const dataTemp = arrayData.map((value) => value.total); 38 | this.mostrarGrafico(labelTemp, dataTemp) 39 | 40 | } 41 | }, 42 | error: (e) => { }, 43 | complete: () => { } 44 | }) 45 | 46 | } 47 | 48 | mostrarGrafico(labelsGrafico:any[],dataGrafico:any[]) { 49 | const myChart = new Chart('myChart', { 50 | type: 'bar', 51 | data: { 52 | labels: labelsGrafico, 53 | datasets: [{ 54 | label: '# de Ventas', 55 | data: dataGrafico, 56 | backgroundColor: [ 57 | 'rgba(54, 162, 235, 0.2)' 58 | ], 59 | borderColor: [ 60 | 'rgba(54, 162, 235, 1)' 61 | ], 62 | borderWidth: 1 63 | }] 64 | }, 65 | options: { 66 | maintainAspectRatio: false, 67 | responsive: true, 68 | scales: { 69 | y: { 70 | beginAtZero: true 71 | } 72 | } 73 | } 74 | }); 75 | } 76 | 77 | 78 | } 79 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/historialventa/historialventa.component.css: -------------------------------------------------------------------------------- 1 | 2 | table { 3 | width: 100%; 4 | } 5 | 6 | .input-filter { 7 | font-size: 14px; 8 | width: 100%; 9 | } 10 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/historialventa/historialventa.component.html: -------------------------------------------------------------------------------- 1 | 2 |

Historial Venta

3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | Buscar Por 15 | 16 | 17 | {{item.descripcion}} 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | Número Orden 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | Fecha Inicio 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | Fecha Fin 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
60 | 61 | 62 | 63 | 64 | Filter 65 | 66 | 67 |
68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 |
Fecha Registro {{element.fechaRegistro }} Numero de Venta {{element.numeroDocumento}} Tipo de Pago {{element.tipoPago}} Total {{element.totalTexto}} 96 | 99 |
No data matching the filter "{{input.value}}"
111 | 114 | 115 | 116 |
117 | 118 |
119 | 120 |
121 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/historialventa/historialventa.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ViewChild } from '@angular/core'; 2 | import { FormBuilder, FormGroup } from '@angular/forms'; 3 | import { MatTableDataSource } from '@angular/material/table'; 4 | import { MatPaginator } from '@angular/material/paginator'; 5 | import { MatDialog } from '@angular/material/dialog'; 6 | import { MAT_DATE_FORMATS } from '@angular/material/core'; 7 | import { Venta } from '../../../interfaces/venta'; 8 | import { DialogDetalleVentaComponent } from '../modals/dialog-detalle-venta/dialog-detalle-venta.component'; 9 | import { VentaService } from '../../../services/venta.service'; 10 | import { MatSnackBar } from '@angular/material/snack-bar'; 11 | import * as moment from 'moment'; 12 | 13 | export const MY_DATE_FORMATS = { 14 | parse: { 15 | dateInput: 'DD/MM/YYYY', 16 | }, 17 | display: { 18 | dateInput: 'DD/MM/YYYY', 19 | monthYearLabel: 'MMMM YYYY', 20 | dateA11yLabel: 'LL', 21 | monthYearA11yLabel: 'MMMM YYYY' 22 | }, 23 | }; 24 | 25 | 26 | @Component({ 27 | selector: 'app-historialventa', 28 | templateUrl: './historialventa.component.html', 29 | styleUrls: ['./historialventa.component.css'], 30 | providers: [ 31 | { provide: MAT_DATE_FORMATS, useValue: MY_DATE_FORMATS } 32 | ] 33 | }) 34 | export class HistorialventaComponent implements OnInit { 35 | formGroup: FormGroup; 36 | buscarItem: any[] = [ 37 | { value: "fecha", descripcion: "Por Fechas" }, 38 | { value: "numero", descripcion: "Numero Venta" } 39 | ] 40 | 41 | ELEMENT_DATA: Venta[] = []; 42 | displayedColumns: string[] = ['numeroVenta', 'fechaRegistro', 'tipoPago', 'total', 'accion']; 43 | dataSource = new MatTableDataSource(this.ELEMENT_DATA); 44 | @ViewChild(MatPaginator) paginator!: MatPaginator; 45 | 46 | constructor( 47 | private fb: FormBuilder, 48 | private dialog: MatDialog, 49 | private _ventaServicio: VentaService, 50 | private _snackBar: MatSnackBar, 51 | ) { 52 | 53 | this.formGroup = this.fb.group({ 54 | buscarPor: ['fecha'], 55 | numero:[''], 56 | fechaInicio: [''], 57 | fechaFin: [''] 58 | }) 59 | 60 | this.formGroup.get('buscarPor')?.valueChanges.subscribe(value => { 61 | this.formGroup.patchValue({ 62 | numero: "", 63 | fechaInicio: "", 64 | fechaFin: "" 65 | }) 66 | }) 67 | 68 | } 69 | 70 | ngOnInit(): void { 71 | } 72 | 73 | ngAfterViewInit() { 74 | this.dataSource.paginator = this.paginator; 75 | } 76 | 77 | applyFilter(event: Event) { 78 | const filterValue = (event.target as HTMLInputElement).value; 79 | this.dataSource.filter = filterValue.trim().toLowerCase(); 80 | } 81 | 82 | onSubmitForm() { 83 | 84 | const _fechaInicio: any = moment(this.formGroup.value.fechaInicio).format('DD/MM/YYYY') 85 | const _fechaFin: any = moment(this.formGroup.value.fechaFin).format('DD/MM/YYYY') 86 | if (_fechaInicio === "Invalid date" || _fechaFin === "Invalid date") { 87 | this._snackBar.open("Debe ingresar ambas fechas", 'Oops!', { duration: 2000 }); 88 | return; 89 | } 90 | 91 | this._ventaServicio.historal( 92 | this.formGroup.value.buscarPor, 93 | this.formGroup.value.numero, 94 | _fechaInicio, 95 | _fechaFin, 96 | ).subscribe({ 97 | next: (data) => { 98 | 99 | if (data.status) { 100 | 101 | this.dataSource.data = data.value; 102 | 103 | } 104 | else 105 | this._snackBar.open("No se encontraron datos", 'Oops!', { duration: 2000 }); 106 | }, 107 | error: (e) => { 108 | }, 109 | complete: () => { 110 | 111 | } 112 | }) 113 | 114 | } 115 | 116 | verDetalle(_venta: Venta) { 117 | this.dialog.open(DialogDetalleVentaComponent, { 118 | data: _venta, 119 | disableClose: true, 120 | width: '700px', 121 | }) 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-delete-producto/dialog-delete-producto.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodigoEstudiante/085_SistemaVentaAngularNet/55ab2e653be7ff98d9df49f4a1a5e96bd059a876/SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-delete-producto/dialog-delete-producto.component.css -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-delete-producto/dialog-delete-producto.component.html: -------------------------------------------------------------------------------- 1 |

Eliminar Producto

2 |
3 | ¿Desea eliminar el producto "{{productoEliminar.nombre}}"? 4 |
5 |
6 | 7 | 8 |
9 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-delete-producto/dialog-delete-producto.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, Inject } from '@angular/core'; 2 | import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; 3 | import { Producto } from '../../../../interfaces/producto'; 4 | 5 | @Component({ 6 | selector: 'app-dialog-delete-producto', 7 | templateUrl: './dialog-delete-producto.component.html', 8 | styleUrls: ['./dialog-delete-producto.component.css'] 9 | }) 10 | export class DialogDeleteProductoComponent implements OnInit { 11 | 12 | constructor( 13 | private dialogoReferencia: MatDialogRef, 14 | @Inject(MAT_DIALOG_DATA) public productoEliminar: Producto 15 | ) { } 16 | 17 | ngOnInit(): void { 18 | } 19 | 20 | 21 | eliminarProducto() { 22 | if (this.productoEliminar) { 23 | this.dialogoReferencia.close('eliminar') 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-delete-usuario/dialog-delete-usuario.component.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodigoEstudiante/085_SistemaVentaAngularNet/55ab2e653be7ff98d9df49f4a1a5e96bd059a876/SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-delete-usuario/dialog-delete-usuario.component.css -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-delete-usuario/dialog-delete-usuario.component.html: -------------------------------------------------------------------------------- 1 |

Eliminar Usuario

2 |
3 | ¿Desea eliminar el usuario "{{usuarioEliminar.nombreApellidos}}"? 4 |
5 |
6 | 7 | 8 |
9 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-delete-usuario/dialog-delete-usuario.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, Inject } from '@angular/core'; 2 | import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; 3 | import { Usuario } from '../../../../interfaces/usuario'; 4 | 5 | @Component({ 6 | selector: 'app-dialog-delete-usuario', 7 | templateUrl: './dialog-delete-usuario.component.html', 8 | styleUrls: ['./dialog-delete-usuario.component.css'] 9 | }) 10 | export class DialogDeleteUsuarioComponent implements OnInit { 11 | 12 | constructor( 13 | private dialogoReferencia: MatDialogRef, 14 | @Inject(MAT_DIALOG_DATA) public usuarioEliminar: Usuario 15 | ) { 16 | 17 | } 18 | 19 | ngOnInit(): void { 20 | } 21 | 22 | eliminarUsuario() { 23 | if (this.usuarioEliminar) { 24 | this.dialogoReferencia.close('eliminar') 25 | } 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-detalle-venta/dialog-detalle-venta.component.css: -------------------------------------------------------------------------------- 1 | 2 | table { 3 | width: 100%; 4 | } 5 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-detalle-venta/dialog-detalle-venta.component.html: -------------------------------------------------------------------------------- 1 | 2 |

Detalle Venta

3 | 4 | 5 | 6 | 7 | 8 | 9 | Fecha Registro 10 | 11 | 12 | 13 | 14 | 15 | 16 | Numero Venta 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Tipo de Pago 25 | 26 | 27 | 28 | 29 | 30 | 31 | Total 32 | 33 | 34 | 35 | 36 | 37 | 38 |

Lista de productos

39 | 40 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 |
Producto {{element.descripcionProducto}} Cantidad {{element.cantidad}} Precio {{element.precioTexto}} Total {{element.totalTexto}}
71 | 72 |
73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-detalle-venta/dialog-detalle-venta.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Inject, OnInit } from '@angular/core'; 2 | import { MAT_DIALOG_DATA } from '@angular/material/dialog'; 3 | import { DetalleVenta } from '../../../../interfaces/detalle-venta'; 4 | import { Venta } from '../../../../interfaces/venta'; 5 | @Component({ 6 | selector: 'app-dialog-detalle-venta', 7 | templateUrl: './dialog-detalle-venta.component.html', 8 | styleUrls: ['./dialog-detalle-venta.component.css'] 9 | }) 10 | export class DialogDetalleVentaComponent implements OnInit { 11 | 12 | 13 | fechaRegistro?: string = ""; 14 | numero?: string = ""; 15 | tipoPago?: string = ""; 16 | total?: string = ""; 17 | detalleVenta: DetalleVenta[] = [ 18 | {idProducto:1,descripcionProducto:"",cantidad:0,precioTexto:"0",totalTexto:"0"}, 19 | ] 20 | displayedColumns: string[] = ['producto', 'cantidad', 'precio', 'total']; 21 | 22 | 23 | constructor(@Inject(MAT_DIALOG_DATA) public _venta: Venta) { 24 | this.fechaRegistro = _venta.fechaRegistro; 25 | this.numero = _venta.numeroDocumento; 26 | this.tipoPago = _venta.tipoPago; 27 | this.total = _venta.totalTexto; 28 | this.detalleVenta = _venta.detalleVenta == null ? [ 29 | { idProducto: 1, descripcionProducto: "", cantidad: 0, precioTexto: "0", totalTexto: "0" }, 30 | ] : _venta.detalleVenta; 31 | } 32 | 33 | ngOnInit(): void { 34 | 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-producto/dialog-producto.component.css: -------------------------------------------------------------------------------- 1 | mat-form-field { 2 | width: 100%; 3 | margin: 10px 0px; 4 | } 5 | 6 | form { 7 | width: 350px; 8 | } 9 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-producto/dialog-producto.component.html: -------------------------------------------------------------------------------- 1 | 2 |

{{accion}} Producto

3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | Nombre 11 | 12 | fit_screen 13 | 14 | 15 | 16 | 17 | 18 | Categoria 19 | 20 | 21 | {{item.descripcion}} 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | Stock 31 | 32 | edit_square 33 | 34 | 35 | 36 | 37 | 38 | Precio 39 | 40 | attach_money 41 | 42 | 43 | 44 | 45 | 46 |
47 | 48 | 49 |
50 | 51 | 52 | 58 | 59 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-producto/dialog-producto.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Inject, OnInit } from '@angular/core'; 2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; 3 | import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; 4 | import { MatSnackBar } from '@angular/material/snack-bar'; 5 | import { Categoria } from '../../../../interfaces/categoria'; 6 | import { Producto } from '../../../../interfaces/producto'; 7 | import { CategoriaService } from '../../../../services/categoria.service'; 8 | import { ProductoService } from '../../../../services/producto.service'; 9 | 10 | @Component({ 11 | selector: 'app-dialog-producto', 12 | templateUrl: './dialog-producto.component.html', 13 | styleUrls: ['./dialog-producto.component.css'] 14 | }) 15 | export class DialogProductoComponent implements OnInit { 16 | formProducto: FormGroup; 17 | accion: string = "Agregar" 18 | accionBoton: string = "Guardar"; 19 | listaCategorias: Categoria[] = []; 20 | 21 | 22 | 23 | 24 | constructor( 25 | private dialogoReferencia: MatDialogRef, 26 | @Inject(MAT_DIALOG_DATA) public productoEditar: Producto, 27 | private fb: FormBuilder, 28 | private _snackBar: MatSnackBar, 29 | private _categoriaServicio: CategoriaService, 30 | private _productoServicio: ProductoService 31 | ) { 32 | this.formProducto = this.fb.group({ 33 | nombre: ['', Validators.required], 34 | idCategoria: ['', Validators.required], 35 | stock: ['', Validators.required], 36 | precio: ['', Validators.required], 37 | }) 38 | 39 | 40 | if (this.productoEditar) { 41 | 42 | this.accion = "Editar"; 43 | this.accionBoton = "Actualizar"; 44 | } 45 | 46 | this._categoriaServicio.getCategorias().subscribe({ 47 | next: (data) => { 48 | 49 | if (data.status) { 50 | 51 | this.listaCategorias = data.value; 52 | 53 | if (this.productoEditar) 54 | this.formProducto.patchValue({ 55 | idCategoria: this.productoEditar.idCategoria 56 | }) 57 | 58 | } 59 | }, 60 | error: (e) => { 61 | }, 62 | complete: () => { 63 | } 64 | }) 65 | 66 | } 67 | 68 | 69 | ngOnInit(): void { 70 | 71 | if (this.productoEditar) { 72 | console.log(this.productoEditar) 73 | this.formProducto.patchValue({ 74 | nombre: this.productoEditar.nombre, 75 | idCategoria: String(this.productoEditar.idCategoria), 76 | stock: this.productoEditar.stock, 77 | precio:this.productoEditar.precio 78 | }) 79 | } 80 | } 81 | 82 | agregarEditarProducto() { 83 | 84 | const _producto: Producto = { 85 | idProducto: this.productoEditar == null ? 0 : this.productoEditar.idProducto, 86 | nombre: this.formProducto.value.nombre, 87 | idCategoria: this.formProducto.value.idCategoria, 88 | descripcionCategoria : "", 89 | precio: this.formProducto.value.precio, 90 | stock: this.formProducto.value.stock 91 | } 92 | 93 | 94 | 95 | if (this.productoEditar) { 96 | 97 | this._productoServicio.edit(_producto).subscribe({ 98 | next: (data) => { 99 | 100 | if (data.status) { 101 | this.mostrarAlerta("El producto fue editado", "Exito"); 102 | this.dialogoReferencia.close('editado') 103 | } else { 104 | this.mostrarAlerta("No se pudo editar el producto", "Error"); 105 | } 106 | 107 | }, 108 | error: (e) => { 109 | console.log(e) 110 | }, 111 | complete: () => { 112 | } 113 | }) 114 | 115 | 116 | } else { 117 | 118 | this._productoServicio.save(_producto).subscribe({ 119 | next: (data) => { 120 | 121 | if (data.status) { 122 | this.mostrarAlerta("El producto fue registrado", "Exito"); 123 | this.dialogoReferencia.close('agregado') 124 | } else { 125 | this.mostrarAlerta("No se pudo registrar el producto", "Error"); 126 | } 127 | 128 | }, 129 | error: (e) => { 130 | }, 131 | complete: () => { 132 | } 133 | }) 134 | 135 | 136 | } 137 | } 138 | 139 | mostrarAlerta(mensaje: string, tipo: string) { 140 | this._snackBar.open(mensaje, tipo, { 141 | horizontalPosition: "end", 142 | verticalPosition: "top", 143 | duration: 3000 144 | }); 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-resultado-venta/dialog-resultado-venta.component.css: -------------------------------------------------------------------------------- 1 | .mat-icon { 2 | font-size: 50px !important; 3 | height:50px !important; 4 | width:50px !important; 5 | } 6 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-resultado-venta/dialog-resultado-venta.component.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | 5 |

Venta Registrada!

6 |
Numero de venta: {{data.numero}}
7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-resultado-venta/dialog-resultado-venta.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Inject, OnInit } from '@angular/core'; 2 | import { MAT_DIALOG_DATA } from '@angular/material/dialog'; 3 | 4 | @Component({ 5 | selector: 'app-dialog-resultado-venta', 6 | templateUrl: './dialog-resultado-venta.component.html', 7 | styleUrls: ['./dialog-resultado-venta.component.css'] 8 | }) 9 | export class DialogResultadoVentaComponent implements OnInit { 10 | 11 | constructor(@Inject(MAT_DIALOG_DATA) public data: any) { } 12 | 13 | ngOnInit(): void { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-usuario/dialog-usuario.component.css: -------------------------------------------------------------------------------- 1 | mat-form-field { 2 | width:100%; 3 | margin:10px 0px; 4 | } 5 | form { 6 | width:350px; 7 | } 8 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-usuario/dialog-usuario.component.html: -------------------------------------------------------------------------------- 1 |

{{accion}} Usuario

2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | Nombre y apellidos 10 | 11 | account_box 12 | 13 | 14 | 15 | 16 | 17 | Correo 18 | 19 | mail 20 | 21 | 22 | 23 | 24 | 25 | Rol 26 | 27 | 28 | {{item.descripcion}} 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | Contraseña 37 | 38 | 41 | 42 | 43 | 44 | 45 |
46 | 47 | 48 |
49 | 50 | 51 | 57 | 58 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/modals/dialog-usuario/dialog-usuario.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, Inject, OnInit, AfterViewInit, ViewChild } from '@angular/core'; 2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; 3 | import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; 4 | import { MatSnackBar } from '@angular/material/snack-bar'; 5 | import { Rol } from '../../../../interfaces/rol'; 6 | import { Usuario } from '../../../../interfaces/usuario'; 7 | import { RolServicioService } from '../../../../services/rol-servicio.service'; 8 | import { UsuarioServicioService } from '../../../../services/usuario-servicio.service'; 9 | 10 | @Component({ 11 | selector: 'app-dialog-usuario', 12 | templateUrl: './dialog-usuario.component.html', 13 | styleUrls: ['./dialog-usuario.component.css'] 14 | }) 15 | export class DialogUsuarioComponent implements OnInit, AfterViewInit { 16 | formUsuario: FormGroup; 17 | hide: boolean = true; 18 | accion:string ="Agregar" 19 | accionBoton: string = "Guardar"; 20 | listaRoles: Rol[] = []; 21 | 22 | constructor( 23 | private dialogoReferencia: MatDialogRef, 24 | @Inject(MAT_DIALOG_DATA) public usuarioEditar: Usuario, 25 | private fb: FormBuilder, 26 | private _snackBar: MatSnackBar, 27 | private _rolServicio: RolServicioService, 28 | private _usuarioServicio: UsuarioServicioService 29 | ) 30 | { 31 | 32 | this.formUsuario = this.fb.group({ 33 | nombreApellido: ['', Validators.required], 34 | correo: ['', Validators.required], 35 | idRol: ['', Validators.required], 36 | clave: ['', Validators.required], 37 | }) 38 | 39 | 40 | if (this.usuarioEditar) { 41 | this.accion = "Editar"; 42 | this.accionBoton = "Actualizar"; 43 | } 44 | 45 | this._rolServicio.getRoles().subscribe({ 46 | next: (data) => { 47 | 48 | if (data.status) { 49 | 50 | this.listaRoles = data.value; 51 | 52 | if (this.usuarioEditar) 53 | this.formUsuario.patchValue({ 54 | idRol: this.usuarioEditar.idRol 55 | }) 56 | 57 | } 58 | }, 59 | error: (e) => { 60 | }, 61 | complete: () => { 62 | } 63 | }) 64 | 65 | 66 | } 67 | 68 | ngOnInit(): void { 69 | 70 | if (this.usuarioEditar) { 71 | 72 | this.formUsuario.patchValue({ 73 | nombreApellido: this.usuarioEditar.nombreApellidos, 74 | correo: this.usuarioEditar.correo, 75 | /*idRol: this.usuarioEditar.idRol,*/ 76 | clave: this.usuarioEditar.clave 77 | }) 78 | } 79 | 80 | } 81 | 82 | ngAfterViewInit() { 83 | 84 | } 85 | 86 | 87 | agregarEditarUsuario() { 88 | 89 | 90 | const _usuario: Usuario = { 91 | idUsuario: this.usuarioEditar == null ? 0 : this.usuarioEditar.idUsuario, 92 | nombreApellidos: this.formUsuario.value.nombreApellido, 93 | correo: this.formUsuario.value.correo, 94 | idRol: this.formUsuario.value.idRol, 95 | rolDescripcion : "", 96 | clave: this.formUsuario.value.clave 97 | } 98 | 99 | 100 | if (this.usuarioEditar) { 101 | 102 | this._usuarioServicio.editUsuario(_usuario).subscribe({ 103 | next: (data) => { 104 | 105 | if (data.status) { 106 | this.mostrarAlerta("El usuario fue editado", "Exito"); 107 | this.dialogoReferencia.close('editado') 108 | } else { 109 | this.mostrarAlerta("No se pudo editar el usuario", "Error"); 110 | } 111 | 112 | }, 113 | error: (e) => { 114 | console.log(e) 115 | }, 116 | complete: () => { 117 | } 118 | }) 119 | 120 | 121 | } else { 122 | 123 | this._usuarioServicio.saveUsuario(_usuario).subscribe({ 124 | next: (data) => { 125 | 126 | if (data.status) { 127 | this.mostrarAlerta("El usuario fue registrado", "Exito"); 128 | this.dialogoReferencia.close('agregado') 129 | } else { 130 | this.mostrarAlerta("No se pudo registrar el usuario", "Error"); 131 | } 132 | 133 | }, 134 | error: (e) => { 135 | }, 136 | complete: () => { 137 | } 138 | }) 139 | 140 | 141 | } 142 | } 143 | 144 | mostrarAlerta(mensaje: string, tipo: string) { 145 | this._snackBar.open(mensaje, tipo, { 146 | horizontalPosition: "end", 147 | verticalPosition: "top", 148 | duration: 3000 149 | }); 150 | } 151 | 152 | } 153 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/navigation/navigation.component.css: -------------------------------------------------------------------------------- 1 | .sidenav-container { 2 | height: 100%; 3 | } 4 | 5 | .sidenav { 6 | width: 200px; 7 | } 8 | 9 | .sidenav .mat-toolbar { 10 | background: inherit; 11 | } 12 | 13 | .mat-toolbar.mat-primary { 14 | position: sticky; 15 | top: 0; 16 | z-index: 1; 17 | } 18 | .example-spacer { 19 | flex: 1 1 auto; 20 | } 21 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/navigation/navigation.component.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | Mi Tienda 9 | 10 | 11 | 12 | 13 | 14 | dashboard 15 |
DashBoard
16 |
17 | 18 | 19 | group 20 |
Usuarios
21 |
22 | 23 | 24 | collections_bookmark 25 |
Productos
26 |
27 | 28 | 29 | currency_exchange 30 |
Vender
31 |
32 | 33 | 34 | edit_note 35 |
Historial Ventas
36 |
37 | 38 | 39 | receipt 40 |
Reportes
41 |
42 | 43 |
44 | 45 | 46 | 47 |
48 | 49 | 50 | 57 | 58 | 62 | 63 | 64 | 65 | 66 |
67 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/navigation/navigation.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout'; 3 | import { Observable } from 'rxjs'; 4 | import { map, shareReplay } from 'rxjs/operators'; 5 | 6 | @Component({ 7 | selector: 'app-navigation', 8 | templateUrl: './navigation.component.html', 9 | styleUrls: ['./navigation.component.css'] 10 | }) 11 | export class NavigationComponent { 12 | 13 | isHandset$: Observable = this.breakpointObserver.observe(Breakpoints.Handset) 14 | .pipe( 15 | map(result => result.matches), 16 | shareReplay() 17 | ); 18 | 19 | constructor(private breakpointObserver: BreakpointObserver) {} 20 | 21 | } 22 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/pages-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { RouterModule, Routes } from '@angular/router'; 3 | import { DashboardComponent } from './dashboard/dashboard.component'; 4 | import { HistorialventaComponent } from './historialventa/historialventa.component'; 5 | import { PagesComponent } from './pages.component'; 6 | import { ProductosComponent } from './productos/productos.component'; 7 | import { ReportesComponent } from './reportes/reportes.component'; 8 | import { UsuariosComponent } from './usuarios/usuarios.component'; 9 | import { VenderComponent } from './vender/vender.component'; 10 | 11 | const routes: Routes = [ 12 | { 13 | path: '', component: PagesComponent, children: [ 14 | {path:'dashboard',component:DashboardComponent}, 15 | {path:'usuarios',component:UsuariosComponent}, 16 | {path:'productos',component:ProductosComponent}, 17 | {path:'vender',component:VenderComponent}, 18 | {path:'historialventas',component:HistorialventaComponent}, 19 | {path:'reportes',component:ReportesComponent} 20 | ] 21 | } 22 | ]; 23 | 24 | @NgModule({ 25 | imports: [RouterModule.forChild(routes)], 26 | exports: [RouterModule] 27 | }) 28 | export class PagesRoutingModule { } 29 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/pages.component.css: -------------------------------------------------------------------------------- 1 | .grid-container { 2 | margin: 20px; 3 | } 4 | 5 | .dashboard-card { 6 | position: absolute; 7 | top: 15px; 8 | left: 15px; 9 | right: 15px; 10 | bottom: 15px; 11 | } 12 | 13 | 14 | .dashboard-card-content { 15 | text-align: center; 16 | } 17 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/pages.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/pages.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | 3 | @Component({ 4 | selector: 'app-pages', 5 | templateUrl: './pages.component.html', 6 | styleUrls: ['./pages.component.css'] 7 | }) 8 | export class PagesComponent implements OnInit { 9 | 10 | constructor() { } 11 | 12 | 13 | ngOnInit(): void { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/pages.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | import { PagesRoutingModule } from './pages-routing.module'; 5 | import { NavigationComponent } from './navigation/navigation.component'; 6 | import { PagesComponent } from './pages.component'; 7 | 8 | import { ReusableModule } from '../reusable/reusable.module'; 9 | import { DashboardComponent } from './dashboard/dashboard.component'; 10 | import { UsuariosComponent } from './usuarios/usuarios.component'; 11 | import { ProductosComponent } from './productos/productos.component'; 12 | import { VenderComponent } from './vender/vender.component'; 13 | import { HistorialventaComponent } from './historialventa/historialventa.component'; 14 | import { ReportesComponent } from './reportes/reportes.component'; 15 | import { DialogUsuarioComponent } from './modals/dialog-usuario/dialog-usuario.component'; 16 | import { DialogProductoComponent } from './modals/dialog-producto/dialog-producto.component'; 17 | import { DialogDeleteUsuarioComponent } from './modals/dialog-delete-usuario/dialog-delete-usuario.component'; 18 | import { DialogDeleteProductoComponent } from './modals/dialog-delete-producto/dialog-delete-producto.component'; 19 | import { DialogDetalleVentaComponent } from './modals/dialog-detalle-venta/dialog-detalle-venta.component'; 20 | import { DialogResultadoVentaComponent } from './modals/dialog-resultado-venta/dialog-resultado-venta.component'; 21 | 22 | 23 | @NgModule({ 24 | declarations: [ 25 | PagesComponent, 26 | NavigationComponent, 27 | DashboardComponent, 28 | UsuariosComponent, 29 | ProductosComponent, 30 | VenderComponent, 31 | HistorialventaComponent, 32 | ReportesComponent, 33 | DialogUsuarioComponent, 34 | DialogProductoComponent, 35 | DialogDeleteUsuarioComponent, 36 | DialogDeleteProductoComponent, 37 | DialogDetalleVentaComponent, 38 | DialogResultadoVentaComponent, 39 | ], 40 | imports: [ 41 | CommonModule, 42 | PagesRoutingModule, 43 | 44 | ReusableModule 45 | ] 46 | }) 47 | export class PagesModule { } 48 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/productos/productos.component.css: -------------------------------------------------------------------------------- 1 | 2 | table { 3 | width: 100%; 4 | } 5 | 6 | .mat-form-field { 7 | font-size: 14px; 8 | width: 100%; 9 | } 10 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/productos/productos.component.html: -------------------------------------------------------------------------------- 1 | 2 |

Productos

3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | Filter 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 |
Nombre {{element.nombre}} Categoria {{element.descripcionCategoria}} Stock {{element.stock}} Precio {{element.precio}} 46 | 49 | 52 |
No data matching the filter "{{input.value}}"
64 | 67 | 68 | 69 |
70 | 71 |
72 | 73 |
74 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/productos/productos.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ViewChild} from '@angular/core'; 2 | 3 | import { MatTableDataSource } from '@angular/material/table'; 4 | import { MatPaginator } from '@angular/material/paginator'; 5 | import { MatDialog } from '@angular/material/dialog'; 6 | import { DialogProductoComponent } from '../modals/dialog-producto/dialog-producto.component'; 7 | import { MatSnackBar } from '@angular/material/snack-bar'; 8 | import { Producto } from '../../../interfaces/producto'; 9 | import { DialogDeleteProductoComponent } from '../modals/dialog-delete-producto/dialog-delete-producto.component'; 10 | import { ProductoService } from '../../../services/producto.service'; 11 | 12 | 13 | const ELEMENT_DATA: Producto[] = [ 14 | { idProducto: 1, nombre: "yougur gloria", idCategoria: 1, descripcionCategoria:"Lacteos", stock: 30, precio: "2.5" }, 15 | { idProducto: 2, nombre: "Detergente sapolio", idCategoria: 2, descripcionCategoria:"Productos de Limpieza", stock: 23, precio: "3.5" }, 16 | { idProducto: 3, nombre: "Mantequilla lavie", idCategoria: 3, descripcionCategoria:"Abarrotes", stock: 25, precio: "4.5" }, 17 | 18 | ]; 19 | 20 | @Component({ 21 | selector: 'app-productos', 22 | templateUrl: './productos.component.html', 23 | styleUrls: ['./productos.component.css'] 24 | }) 25 | export class ProductosComponent implements OnInit { 26 | displayedColumns: string[] = ['nombre', 'categoria', 'stock','precio', 'acciones']; 27 | dataSource = new MatTableDataSource(ELEMENT_DATA); 28 | @ViewChild(MatPaginator) paginator!: MatPaginator; 29 | 30 | constructor( 31 | private dialog: MatDialog, 32 | private _snackBar: MatSnackBar, 33 | private _productoServicio: ProductoService 34 | ) { 35 | 36 | } 37 | 38 | ngOnInit(): void { 39 | this.mostrarProductos(); 40 | } 41 | 42 | ngAfterViewInit() { 43 | this.dataSource.paginator = this.paginator; 44 | } 45 | 46 | applyFilter(event: Event) { 47 | const filterValue = (event.target as HTMLInputElement).value; 48 | this.dataSource.filter = filterValue.trim().toLowerCase(); 49 | } 50 | 51 | mostrarProductos() { 52 | this._productoServicio.getProductos().subscribe({ 53 | next: (data) => { 54 | if (data.status) 55 | this.dataSource.data = data.value; 56 | else 57 | this._snackBar.open("No se encontraron datos", 'Oops!', { duration: 2000 }); 58 | }, 59 | error: (e) => { 60 | }, 61 | complete: () => { 62 | 63 | } 64 | }) 65 | } 66 | 67 | 68 | agregarProducto() { 69 | this.dialog.open(DialogProductoComponent, { 70 | disableClose: true 71 | }).afterClosed().subscribe(result => { 72 | if (result === "agregado") { 73 | this.mostrarProductos(); 74 | } 75 | }); 76 | } 77 | 78 | editarProducto(producto: Producto) { 79 | this.dialog.open(DialogProductoComponent, { 80 | disableClose: true, 81 | data: producto 82 | }).afterClosed().subscribe(result => { 83 | 84 | if (result === "editado") 85 | this.mostrarProductos(); 86 | 87 | }); 88 | } 89 | 90 | 91 | eliminarProducto(producto: Producto) { 92 | this.dialog.open(DialogDeleteProductoComponent, { 93 | disableClose: true, 94 | data: producto 95 | }).afterClosed().subscribe(result => { 96 | 97 | if (result === "eliminar") { 98 | 99 | this._productoServicio.delete(producto.idProducto).subscribe({ 100 | next: (data) => { 101 | 102 | if (data.status) { 103 | this.mostrarAlerta("El producto fue eliminado", "Listo!") 104 | this.mostrarProductos(); 105 | } else { 106 | this.mostrarAlerta("No se pudo eliminar el producto", "Error"); 107 | } 108 | 109 | }, 110 | error: (e) => { 111 | }, 112 | complete: () => { 113 | } 114 | }) 115 | 116 | } 117 | 118 | 119 | 120 | }); 121 | } 122 | 123 | mostrarAlerta(mensaje: string, tipo: string) { 124 | this._snackBar.open(mensaje, tipo, { 125 | horizontalPosition: "end", 126 | verticalPosition: "top", 127 | duration: 3000 128 | }); 129 | } 130 | 131 | } 132 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/reportes/reportes.component.css: -------------------------------------------------------------------------------- 1 | 2 | table { 3 | width: 100%; 4 | } 5 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/reportes/reportes.component.html: -------------------------------------------------------------------------------- 1 | 2 |

Reporte Venta

3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | Fecha Inicio 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | Fecha Fin 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 |
41 | 42 | 48 | 49 |
50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 |
Fecha Registro {{element.fechaRegistro }} Numero de Venta {{element.numeroDocumento}} Tipo de Pago {{element.tipoPago}} Total {{element.totalVenta}} Producto {{element.producto}} Cantidad {{element.cantidad}} Precio {{element.precio}} Total por producto {{element.total}}
95 | 98 | 99 | 100 |
101 | 102 |
103 | 104 |
105 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/reportes/reportes.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, ViewChild } from '@angular/core'; 2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; 3 | import { MatTableDataSource } from '@angular/material/table'; 4 | import { MatPaginator } from '@angular/material/paginator'; 5 | import { MAT_DATE_FORMATS } from '@angular/material/core'; 6 | import { ReporteVenta } from '../../../interfaces/reporte-venta'; 7 | import * as XLSX from 'xlsx'; 8 | import * as moment from 'moment'; 9 | import { MatSnackBar } from '@angular/material/snack-bar'; 10 | import { VentaService } from '../../../services/venta.service'; 11 | import { Reporte } from '../../../interfaces/reporte'; 12 | 13 | export const MY_DATE_FORMATS = { 14 | parse: { 15 | dateInput: 'DD/MM/YYYY', 16 | }, 17 | display: { 18 | dateInput: 'DD/MM/YYYY', 19 | monthYearLabel: 'MMMM YYYY', 20 | dateA11yLabel: 'LL', 21 | monthYearA11yLabel: 'MMMM YYYY' 22 | } 23 | }; 24 | 25 | 26 | @Component({ 27 | selector: 'app-reportes', 28 | templateUrl: './reportes.component.html', 29 | styleUrls: ['./reportes.component.css'], 30 | providers: [ 31 | { provide: MAT_DATE_FORMATS, useValue: MY_DATE_FORMATS } 32 | ] 33 | }) 34 | 35 | 36 | export class ReportesComponent implements OnInit { 37 | formGroup: FormGroup; 38 | ELEMENT_DATA: Reporte[] = []; 39 | displayedColumns: string[] = ['fechaRegistro','numeroVenta', 'tipoPago', 'total', 'producto','cantidad','precio','totalProducto']; 40 | dataSource = new MatTableDataSource(this.ELEMENT_DATA); 41 | @ViewChild(MatPaginator) paginator!: MatPaginator; 42 | 43 | 44 | 45 | constructor( 46 | private fb: FormBuilder, 47 | private _ventaServicio: VentaService, 48 | private _snackBar: MatSnackBar, 49 | ) { 50 | this.formGroup = this.fb.group({ 51 | fechaInicio: ['', Validators.required], 52 | fechaFin: ['', Validators.required] 53 | }) 54 | 55 | } 56 | 57 | ngOnInit(): void { 58 | } 59 | 60 | ngAfterViewInit() { 61 | this.dataSource.paginator = this.paginator; 62 | } 63 | onSubmitForm() { 64 | 65 | const _fechaInicio: any = moment(this.formGroup.value.fechaInicio).format('DD/MM/YYYY') 66 | const _fechaFin: any = moment(this.formGroup.value.fechaFin).format('DD/MM/YYYY') 67 | if (_fechaInicio === "Invalid date" || _fechaFin === "Invalid date") { 68 | this._snackBar.open("Debe ingresar ambas fechas", 'Oops!', { duration: 2000 }); 69 | return; 70 | } 71 | 72 | this._ventaServicio.reporte( 73 | _fechaInicio, 74 | _fechaFin, 75 | ).subscribe({ 76 | next: (data) => { 77 | 78 | if (data.status) { 79 | 80 | this.ELEMENT_DATA = data.value; 81 | this.dataSource.data = data.value; 82 | 83 | } 84 | else { 85 | this.ELEMENT_DATA = []; 86 | this.dataSource.data = []; 87 | this._snackBar.open("No se encontraron datos", 'Oops!', { duration: 2000 }); 88 | } 89 | 90 | }, 91 | error: (e) => { 92 | }, 93 | complete: () => { 94 | 95 | } 96 | }) 97 | 98 | } 99 | 100 | exportarExcel() { 101 | const wb = XLSX.utils.book_new(); 102 | const ws = XLSX.utils.json_to_sheet(this.ELEMENT_DATA); 103 | 104 | XLSX.utils.book_append_sheet(wb, ws, "Reporte"); 105 | XLSX.writeFile(wb, "Reporte Ventas.xlsx") 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/usuarios/usuarios.component.css: -------------------------------------------------------------------------------- 1 | 2 | table { 3 | width: 100%; 4 | } 5 | 6 | .mat-form-field { 7 | font-size: 14px; 8 | width: 100%; 9 | } 10 | 11 | 12 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/usuarios/usuarios.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

Usuarios

5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Filter 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 |
Nombre y Apellidos {{element.nombreApellidos}} Correo {{element.correo}} Rol {{element.rolDescripcion}} 43 | 46 | 49 |
No data matching the filter "{{input.value}}"
61 | 64 | 65 | 66 |
67 | 68 |
69 | 70 |
71 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/usuarios/usuarios.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, AfterViewInit, ViewChild} from '@angular/core'; 2 | 3 | import { MatTableDataSource } from '@angular/material/table'; 4 | import { MatPaginator } from '@angular/material/paginator'; 5 | import { MatDialog } from '@angular/material/dialog'; 6 | import { DialogUsuarioComponent } from '../modals/dialog-usuario/dialog-usuario.component'; 7 | import { DialogDeleteUsuarioComponent } from '../modals/dialog-delete-usuario/dialog-delete-usuario.component'; 8 | import { Usuario } from '../../../interfaces/usuario'; 9 | import {MatSnackBar} from '@angular/material/snack-bar'; 10 | import { UsuarioServicioService } from '../../../services/usuario-servicio.service'; 11 | 12 | const ELEMENT_DATA: Usuario[] = [ 13 | //{ idUsuario: 1, nombreApellidos: "jose mendez", correo: "jose@gmail.com", idRol: 1,rolDescripcion:"Administrador",clave:"1233"}, 14 | //{ idUsuario: 2, nombreApellidos: "leo muñoz", correo: "leo@gmail.com", idRol: 2, rolDescripcion: "Empleado",clave:"4566"}, 15 | //{ idUsuario: 3, nombreApellidos: "yamile pinto", correo: "yamile@gmail.com", idRol: 2, rolDescripcion: "Empleado",clave:"6788"}, 16 | 17 | ]; 18 | 19 | @Component({ 20 | selector: 'app-usuarios', 21 | templateUrl: './usuarios.component.html', 22 | styleUrls: ['./usuarios.component.css'] 23 | }) 24 | export class UsuariosComponent implements OnInit, AfterViewInit { 25 | displayedColumns: string[] = ['nombreApellidos', 'correo', 'rolDescripcion','acciones']; 26 | dataSource = new MatTableDataSource(ELEMENT_DATA); 27 | @ViewChild(MatPaginator) paginator!: MatPaginator; 28 | 29 | constructor( 30 | private dialog: MatDialog, 31 | private _snackBar: MatSnackBar, 32 | private _usuarioServicio: UsuarioServicioService 33 | ) 34 | { 35 | 36 | } 37 | 38 | ngOnInit(): void { 39 | this.mostrarUsuarios(); 40 | } 41 | 42 | ngAfterViewInit() { 43 | this.dataSource.paginator = this.paginator; 44 | } 45 | 46 | applyFilter(event: Event) { 47 | const filterValue = (event.target as HTMLInputElement).value; 48 | this.dataSource.filter = filterValue.trim().toLowerCase(); 49 | } 50 | 51 | mostrarUsuarios() { 52 | this._usuarioServicio.getUsuarios().subscribe({ 53 | next: (data) => { 54 | if(data.status) 55 | this.dataSource.data = data.value; 56 | else 57 | this._snackBar.open("No se encontraron datos", 'Oops!', { duration: 2000 }); 58 | }, 59 | error: (e) => { 60 | }, 61 | complete: () => { 62 | 63 | } 64 | }) 65 | } 66 | 67 | agregarUsuario() { 68 | this.dialog.open(DialogUsuarioComponent, { 69 | disableClose: true 70 | }).afterClosed().subscribe(result => { 71 | 72 | if (result === "agregado") { 73 | this.mostrarUsuarios(); 74 | } 75 | }); 76 | } 77 | 78 | editarUsuario(usuario: Usuario) { 79 | this.dialog.open(DialogUsuarioComponent, { 80 | disableClose: true, 81 | data: usuario 82 | }).afterClosed().subscribe(result => { 83 | 84 | if (result === "editado") 85 | this.mostrarUsuarios(); 86 | 87 | }); 88 | } 89 | 90 | eliminarUsuario(usuario: Usuario) { 91 | this.dialog.open(DialogDeleteUsuarioComponent, { 92 | disableClose: true, 93 | data: usuario 94 | }).afterClosed().subscribe(result => { 95 | 96 | if (result === "eliminar") { 97 | 98 | this._usuarioServicio.deleteUsuario(usuario.idUsuario).subscribe({ 99 | next: (data) => { 100 | 101 | if (data.status) { 102 | this.mostrarAlerta("El usuario fue eliminado", "Listo!") 103 | this.mostrarUsuarios(); 104 | } else { 105 | this.mostrarAlerta("No se pudo eliminar el usuario", "Error"); 106 | } 107 | 108 | }, 109 | error: (e) => { 110 | }, 111 | complete: () => { 112 | } 113 | }) 114 | 115 | } 116 | 117 | 118 | }); 119 | } 120 | 121 | mostrarAlerta(mensaje:string,tipo:string) { 122 | this._snackBar.open(mensaje, tipo, { 123 | horizontalPosition: "end", 124 | verticalPosition: "top", 125 | duration:3000 126 | }); 127 | } 128 | 129 | 130 | } 131 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/vender/vender.component.css: -------------------------------------------------------------------------------- 1 | .example-form { 2 | /* min-width: 150px; 3 | max-width: 500px;*/ 4 | width: 100%; 5 | } 6 | 7 | .example-full-width { 8 | width: 100%; 9 | } 10 | 11 | table { 12 | width: 100%; 13 | } 14 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/vender/vender.component.html: -------------------------------------------------------------------------------- 1 | 2 |

Nueva Venta

3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | Producto 14 | 20 | 23 | 24 | {{option.nombre}} 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | Cantidad 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Tipo de pago 54 | 55 | Efectivo 56 | Tarjeta 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 |
67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 99 | 100 | 101 | 102 | 103 | 104 |
Producto {{element.descripcionProducto}} Cantidad {{element.cantidad}} Precio {{element.precioTexto}} Total {{element.totalTexto}} 95 | 98 |
105 | 106 |
107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 120 | 121 | 122 | 123 |
124 | 125 |
126 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/pages/vender/vender.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { FormBuilder, FormGroup, Validators } from '@angular/forms'; 3 | import { MatTableDataSource } from '@angular/material/table'; 4 | import { DetalleVenta } from '../../../interfaces/detalle-venta'; 5 | import { Producto } from '../../../interfaces/producto'; 6 | import { Venta } from '../../../interfaces/venta'; 7 | import { ProductoService } from '../../../services/producto.service'; 8 | import { VentaService } from '../../../services/venta.service'; 9 | import { MatDialog } from '@angular/material/dialog'; 10 | import { DialogResultadoVentaComponent } from '../modals/dialog-resultado-venta/dialog-resultado-venta.component'; 11 | import { MatSnackBar } from '@angular/material/snack-bar'; 12 | 13 | 14 | 15 | @Component({ 16 | selector: 'app-vender', 17 | templateUrl: './vender.component.html', 18 | styleUrls: ['./vender.component.css'] 19 | }) 20 | export class VenderComponent implements OnInit { 21 | options: Producto[] = []; 22 | ELEMENT_DATA: DetalleVenta[] = []; 23 | deshabilitado: boolean = false; 24 | 25 | filteredOptions!: Producto[]; 26 | agregarProducto!: Producto; 27 | tipodePago: string = "Efectivo"; 28 | totalPagar: number = 0; 29 | 30 | formGroup: FormGroup; 31 | displayedColumns: string[] = ['producto', 'cantidad', 'precio', 'total','accion']; 32 | dataSource = new MatTableDataSource(this.ELEMENT_DATA); 33 | 34 | constructor( 35 | private fb: FormBuilder, 36 | private _productoServicio: ProductoService, 37 | private _ventaServicio: VentaService, 38 | private dialog: MatDialog, 39 | private _snackBar: MatSnackBar, 40 | ) { 41 | 42 | this.formGroup = this.fb.group({ 43 | producto: ['', Validators.required], 44 | cantidad: ['', Validators.required] 45 | }) 46 | 47 | this.formGroup.get('producto')?.valueChanges.subscribe(value => { 48 | this.filteredOptions = this._filter(value) 49 | }) 50 | 51 | this._productoServicio.getProductos().subscribe({ 52 | next: (data) => { 53 | if (data.status) 54 | this.options = data.value; 55 | }, 56 | error: (e) => { 57 | }, 58 | complete: () => { 59 | 60 | } 61 | }) 62 | 63 | } 64 | 65 | ngOnInit(): void { 66 | 67 | } 68 | 69 | private _filter(value: any): Producto[] { 70 | const filterValue = typeof value === "string" ? value.toLowerCase() : value.nombre.toLowerCase(); 71 | return this.options.filter(option => option.nombre.toLowerCase().includes(filterValue)); 72 | } 73 | 74 | 75 | displayProducto(producto: Producto): string { 76 | return producto.nombre; 77 | } 78 | 79 | productoSeleccionado(event: any) { 80 | this.agregarProducto = event.option.value; 81 | } 82 | 83 | onSubmitForm() { 84 | 85 | const _cantidad: number = this.formGroup.value.cantidad; 86 | const _precio: number = parseFloat(this.agregarProducto.precio); 87 | const _total: number = _cantidad * _precio; 88 | this.totalPagar = this.totalPagar + _total; 89 | 90 | this.ELEMENT_DATA.push( 91 | { 92 | idProducto: this.agregarProducto.idProducto, 93 | descripcionProducto: this.agregarProducto.nombre, 94 | cantidad: _cantidad, 95 | precioTexto: String(_precio.toFixed(2)), 96 | totalTexto: String(_total.toFixed(2)) 97 | }) 98 | this.dataSource = new MatTableDataSource(this.ELEMENT_DATA); 99 | 100 | this.formGroup.patchValue({ 101 | producto: '', 102 | cantidad: '' 103 | }) 104 | 105 | } 106 | 107 | eliminarProducto(item: DetalleVenta) { 108 | 109 | this.totalPagar = this.totalPagar - parseFloat(item.totalTexto); 110 | this.ELEMENT_DATA = this.ELEMENT_DATA.filter(p => p.idProducto != item.idProducto) 111 | 112 | this.dataSource = new MatTableDataSource(this.ELEMENT_DATA); 113 | } 114 | 115 | registrarVenta() { 116 | 117 | if (this.ELEMENT_DATA.length > 0) { 118 | 119 | this.deshabilitado = true; 120 | 121 | 122 | const ventaDto: Venta = { 123 | tipoPago: this.tipodePago, 124 | totalTexto: String(this.totalPagar.toFixed(2)), 125 | detalleVenta: this.ELEMENT_DATA 126 | } 127 | 128 | this._ventaServicio.registrar(ventaDto).subscribe({ 129 | next: (data) => { 130 | 131 | if (data.status) { 132 | this.totalPagar = 0.00; 133 | this.ELEMENT_DATA = []; 134 | this.dataSource = new MatTableDataSource(this.ELEMENT_DATA); 135 | this.tipodePago = "Efectivo"; 136 | 137 | this.dialog.open(DialogResultadoVentaComponent, { 138 | data: { 139 | numero: data.value.numeroDocumento 140 | }, 141 | }); 142 | 143 | } else { 144 | this._snackBar.open("No se pudo registrar la venta", "Oops", { 145 | horizontalPosition: "end", 146 | verticalPosition: "top", 147 | duration: 3000 148 | }); 149 | } 150 | }, 151 | error: (e) => { 152 | }, 153 | complete: () => { 154 | this.deshabilitado = false; 155 | } 156 | }) 157 | 158 | 159 | } 160 | } 161 | 162 | 163 | } 164 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/components/reusable/reusable.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | 4 | //Modulos 5 | import { ReactiveFormsModule } from '@angular/forms'; 6 | import { HttpClientModule } from '@angular/common/http'; 7 | import { FormsModule } from '@angular/forms'; 8 | 9 | //angular material 10 | import { MatCardModule } from '@angular/material/card'; 11 | import { MatInputModule } from '@angular/material/input'; 12 | import { MatSelectModule } from '@angular/material/select'; 13 | import { MatProgressBarModule } from '@angular/material/progress-bar'; 14 | import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; 15 | import { MatGridListModule } from '@angular/material/grid-list'; 16 | import { MatExpansionModule } from '@angular/material/expansion'; 17 | 18 | import { LayoutModule } from '@angular/cdk/layout'; 19 | import { MatToolbarModule } from '@angular/material/toolbar'; 20 | import { MatButtonModule } from '@angular/material/button'; 21 | import { MatSidenavModule } from '@angular/material/sidenav'; 22 | import { MatIconModule } from '@angular/material/icon'; 23 | import { MatListModule } from '@angular/material/list'; 24 | 25 | import { MatTableModule } from '@angular/material/table'; 26 | import { MatPaginatorModule } from '@angular/material/paginator'; 27 | import { MatDialogModule } from '@angular/material/dialog'; 28 | import { MatSnackBarModule } from '@angular/material/snack-bar'; 29 | import { MatTooltipModule } from '@angular/material/tooltip'; 30 | import { MatAutocompleteModule } from '@angular/material/autocomplete'; 31 | 32 | //controles para la fecha 33 | import { MatDatepickerModule } from '@angular/material/datepicker'; 34 | import { MatNativeDateModule } from '@angular/material/core'; 35 | import { MomentDateModule } from '@angular/material-moment-adapter'; /*npm install moment --save | npm i @angular/material-moment-adapter*/ 36 | 37 | 38 | 39 | 40 | @NgModule({ 41 | declarations: [], 42 | imports: [ 43 | HttpClientModule, 44 | ReactiveFormsModule, 45 | FormsModule, 46 | 47 | CommonModule, 48 | MatCardModule, 49 | MatButtonModule, 50 | MatInputModule, 51 | MatSelectModule, 52 | MatIconModule, 53 | MatProgressBarModule, 54 | MatProgressSpinnerModule, 55 | MatGridListModule, 56 | MatExpansionModule, 57 | LayoutModule, 58 | MatToolbarModule, 59 | MatSidenavModule, 60 | MatListModule, 61 | MatTooltipModule, 62 | 63 | MatTableModule, 64 | MatPaginatorModule, 65 | MatDialogModule, 66 | MatSnackBarModule, 67 | MatAutocompleteModule, 68 | MatDatepickerModule, 69 | MatNativeDateModule, 70 | MomentDateModule 71 | ], 72 | exports: [ 73 | HttpClientModule, 74 | ReactiveFormsModule, 75 | FormsModule, 76 | 77 | CommonModule, 78 | MatCardModule, 79 | MatButtonModule, 80 | MatInputModule, 81 | MatSelectModule, 82 | MatIconModule, 83 | MatProgressBarModule, 84 | MatProgressSpinnerModule, 85 | MatGridListModule, 86 | MatExpansionModule, 87 | LayoutModule, 88 | MatToolbarModule, 89 | MatSidenavModule, 90 | MatListModule, 91 | MatTooltipModule, 92 | 93 | MatTableModule, 94 | MatPaginatorModule, 95 | MatDialogModule, 96 | MatSnackBarModule, 97 | MatAutocompleteModule, 98 | MatDatepickerModule, 99 | MatNativeDateModule, 100 | MomentDateModule 101 | ], 102 | providers: [ 103 | MatDatepickerModule, 104 | MatNativeDateModule 105 | ] 106 | }) 107 | export class ReusableModule { } 108 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/interfaces/categoria.ts: -------------------------------------------------------------------------------- 1 | export interface Categoria { 2 | idCategoria: number, 3 | descripcion:string 4 | } 5 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/interfaces/detalle-venta.ts: -------------------------------------------------------------------------------- 1 | export interface DetalleVenta { 2 | idProducto: number, 3 | descripcionProducto: string, 4 | cantidad: number, 5 | precioTexto: string, 6 | totalTexto:string 7 | } 8 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/interfaces/producto.ts: -------------------------------------------------------------------------------- 1 | export interface Producto { 2 | idProducto: number, 3 | nombre: string, 4 | idCategoria: number, 5 | descripcionCategoria: string, 6 | stock: number, 7 | precio:string 8 | } 9 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/interfaces/reporte-venta.ts: -------------------------------------------------------------------------------- 1 | export interface ReporteVenta { 2 | fechaRegistro: string, 3 | numero: string, 4 | tipoPago: string, 5 | total: string, 6 | producto: string, 7 | cantidad: string, 8 | precio: string, 9 | totalProducto: string 10 | } 11 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/interfaces/reporte.ts: -------------------------------------------------------------------------------- 1 | export interface Reporte { 2 | numeroDocumento:string, 3 | tipoPago: string, 4 | fechaRegistro: string, 5 | totalVenta: string, 6 | producto: string, 7 | cantidad:number, 8 | precio: string, 9 | total: string 10 | } 11 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/interfaces/response-api.ts: -------------------------------------------------------------------------------- 1 | export interface ResponseApi { 2 | status: boolean, 3 | msg: string, 4 | value: any 5 | } 6 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/interfaces/rol.ts: -------------------------------------------------------------------------------- 1 | export interface Rol { 2 | idRol: number, 3 | descripcion:string 4 | } 5 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/interfaces/usuario.ts: -------------------------------------------------------------------------------- 1 | export interface Usuario { 2 | idUsuario: number; 3 | nombreApellidos: string; 4 | correo: string; 5 | idRol: number; 6 | rolDescripcion: string; 7 | clave: string; 8 | } 9 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/interfaces/venta.ts: -------------------------------------------------------------------------------- 1 | import { DetalleVenta } from "./detalle-venta"; 2 | 3 | export interface Venta { 4 | idVenta?: number, 5 | numeroDocumento?: string, 6 | fechaRegistro?: string, 7 | tipoPago?: string, 8 | totalTexto?: string, 9 | detalleVenta?:DetalleVenta[] 10 | } 11 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/services/categoria.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient } from '@angular/common/http'; 3 | import { Observable } from 'rxjs'; 4 | import { ResponseApi } from '../interfaces/response-api'; 5 | 6 | @Injectable({ 7 | providedIn: 'root' 8 | }) 9 | export class CategoriaService { 10 | apiBase: string = '/api/categoria/' 11 | constructor(private http: HttpClient) { } 12 | 13 | getCategorias(): Observable { 14 | return this.http.get(`${this.apiBase}Lista`) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/services/dashboard.service.spec.ts: -------------------------------------------------------------------------------- 1 | import { TestBed } from '@angular/core/testing'; 2 | 3 | import { DashboardService } from './dashboard.service'; 4 | 5 | describe('DashboardService', () => { 6 | let service: DashboardService; 7 | 8 | beforeEach(() => { 9 | TestBed.configureTestingModule({}); 10 | service = TestBed.inject(DashboardService); 11 | }); 12 | 13 | it('should be created', () => { 14 | expect(service).toBeTruthy(); 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/services/dashboard.service.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient } from '@angular/common/http'; 2 | import { Injectable } from '@angular/core'; 3 | import { Observable } from 'rxjs'; 4 | import { ResponseApi } from '../interfaces/response-api'; 5 | 6 | @Injectable({ 7 | providedIn: 'root' 8 | }) 9 | export class DashboardService { 10 | 11 | apiBase: string = '/api/dashboard/' 12 | constructor(private http: HttpClient) { } 13 | 14 | resumen(): Observable { 15 | return this.http.get(`${this.apiBase}Resumen`) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/services/producto.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient } from '@angular/common/http'; 3 | import { Observable } from 'rxjs'; 4 | import { Producto } from '../interfaces/producto'; 5 | import { ResponseApi } from '../interfaces/response-api'; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class ProductoService { 11 | apiBase: string = '/api/producto/' 12 | constructor(private http: HttpClient) { 13 | } 14 | 15 | 16 | getProductos(): Observable { 17 | 18 | return this.http.get(`${this.apiBase}Lista`) 19 | 20 | } 21 | 22 | save(request: Producto): Observable { 23 | 24 | return this.http.post(`${this.apiBase}Guardar`, request, { headers: { 'Content-Type': 'application/json;charset=utf-8' } }) 25 | 26 | } 27 | 28 | edit(request: Producto): Observable { 29 | 30 | return this.http.put(`${this.apiBase}Editar`, request, { headers: { 'Content-Type': 'application/json;charset=utf-8' } }) 31 | 32 | } 33 | 34 | delete(id: number): Observable { 35 | 36 | return this.http.delete(`${this.apiBase}Eliminar/${id}`); 37 | 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/services/rol-servicio.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient } from '@angular/common/http'; 3 | import { Observable } from 'rxjs'; 4 | import { ResponseApi } from '../interfaces/response-api'; 5 | 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class RolServicioService { 11 | apiBase: string = '/api/rol/' 12 | constructor(private http: HttpClient) { } 13 | 14 | getRoles(): Observable { 15 | return this.http.get(`${this.apiBase}Lista`) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/services/usuario-servicio.service.ts: -------------------------------------------------------------------------------- 1 | import { Injectable } from '@angular/core'; 2 | import { HttpClient } from '@angular/common/http'; 3 | import { Observable } from 'rxjs'; 4 | import { Usuario } from '../interfaces/usuario'; 5 | import { ResponseApi } from '../interfaces/response-api'; 6 | 7 | 8 | @Injectable({ 9 | providedIn: 'root' 10 | }) 11 | export class UsuarioServicioService { 12 | apiBase: string = '/api/usuario/' 13 | constructor(private http: HttpClient) { 14 | } 15 | 16 | getIniciarSesion(correo: string, clave: string): Observable { 17 | 18 | return this.http.get(`${this.apiBase}IniciarSesion?correo=${correo}&clave=${clave}`) 19 | } 20 | 21 | getUsuarios(): Observable { 22 | 23 | return this.http.get (`${this.apiBase}Lista`) 24 | 25 | } 26 | 27 | saveUsuario(request:Usuario): Observable { 28 | 29 | return this.http.post(`${this.apiBase}Guardar`, request, { headers: { 'Content-Type': 'application/json;charset=utf-8' }}) 30 | 31 | } 32 | 33 | editUsuario(request: Usuario): Observable { 34 | 35 | return this.http.put(`${this.apiBase}Editar`, request, { headers: { 'Content-Type': 'application/json;charset=utf-8' } }) 36 | 37 | } 38 | 39 | deleteUsuario(id: number): Observable { 40 | 41 | return this.http.delete(`${this.apiBase}Eliminar/${id}`); 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/app/services/venta.service.ts: -------------------------------------------------------------------------------- 1 | import { HttpClient } from '@angular/common/http'; 2 | import { Injectable } from '@angular/core'; 3 | import { Observable } from 'rxjs'; 4 | import { ResponseApi } from '../interfaces/response-api'; 5 | import { Venta } from '../interfaces/venta'; 6 | 7 | @Injectable({ 8 | providedIn: 'root' 9 | }) 10 | export class VentaService { 11 | apiBase: string = '/api/venta/' 12 | constructor(private http: HttpClient) { } 13 | 14 | registrar(request: Venta): Observable { 15 | 16 | return this.http.post(`${this.apiBase}Registrar`, request, { headers: { 'Content-Type': 'application/json;charset=utf-8' } }) 17 | 18 | } 19 | 20 | historal(buscarPor:string,numeroVenta:string,fechaInicio:string,fechaFin:string): Observable { 21 | 22 | return this.http.get(`${this.apiBase}Historial?buscarPor=${buscarPor}&numeroVenta=${numeroVenta}&fechaInicio=${fechaInicio}&fechaFin=${fechaFin}`); 23 | 24 | } 25 | 26 | reporte(fechaInicio: string, fechaFin: string): Observable { 27 | 28 | return this.http.get(`${this.apiBase}Reporte?fechaInicio=${fechaInicio}&fechaFin=${fechaFin}`); 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/assets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodigoEstudiante/085_SistemaVentaAngularNet/55ab2e653be7ff98d9df49f4a1a5e96bd059a876/SistemaVentaAngular/ClientApp/src/assets/.gitkeep -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/plugins/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodigoEstudiante/085_SistemaVentaAngularNet/55ab2e653be7ff98d9df49f4a1a5e96bd059a876/SistemaVentaAngular/ClientApp/src/favicon.ico -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ClientApp 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.error(err)); 13 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes recent versions of Safari, Chrome (including 12 | * Opera), Edge on the desktop, and iOS and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** 22 | * By default, zone.js will patch all possible macroTask and DomEvents 23 | * user can disable parts of macroTask/DomEvents patch by setting following flags 24 | * because those flags need to be set before `zone.js` being loaded, and webpack 25 | * will put import in the top of bundle, so user need to create a separate file 26 | * in this directory (for example: zone-flags.ts), and put the following flags 27 | * into that file, and then add the following code before importing zone.js. 28 | * import './zone-flags'; 29 | * 30 | * The flags allowed in zone-flags.ts are listed here. 31 | * 32 | * The following flags will work for all browsers. 33 | * 34 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 35 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 36 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 37 | * 38 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 39 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 40 | * 41 | * (window as any).__Zone_enable_cross_context_check = true; 42 | * 43 | */ 44 | 45 | /*************************************************************************************************** 46 | * Zone JS is required by default for Angular itself. 47 | */ 48 | import 'zone.js'; // Included with Angular CLI. 49 | 50 | 51 | /*************************************************************************************************** 52 | * APPLICATION IMPORTS 53 | */ 54 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/styles.css: -------------------------------------------------------------------------------- 1 | /* You can add global styles to this file, and also import other style files */ 2 | 3 | html, body { height: 100%; } 4 | body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; } 5 | 6 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: { 11 | context(path: string, deep?: boolean, filter?: RegExp): { 12 | (id: string): T; 13 | keys(): string[]; 14 | }; 15 | }; 16 | 17 | // First, initialize the Angular testing environment. 18 | getTestBed().initTestEnvironment( 19 | BrowserDynamicTestingModule, 20 | platformBrowserDynamicTesting(), 21 | ); 22 | 23 | // Then we find all the tests. 24 | const context = require.context('./', true, /\.spec\.ts$/); 25 | // And load the modules. 26 | context.keys().forEach(context); 27 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/tsconfig.app.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/app", 6 | "types": [] 7 | }, 8 | "files": [ 9 | "src/main.ts", 10 | "src/polyfills.ts" 11 | ], 12 | "include": [ 13 | "src/**/*.d.ts" 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/tsconfig.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "compileOnSave": false, 4 | "compilerOptions": { 5 | "baseUrl": "./", 6 | "outDir": "./dist/out-tsc", 7 | "forceConsistentCasingInFileNames": true, 8 | "strict": true, 9 | "noImplicitOverride": true, 10 | "noPropertyAccessFromIndexSignature": true, 11 | "noImplicitReturns": true, 12 | "noFallthroughCasesInSwitch": true, 13 | "sourceMap": true, 14 | "declaration": false, 15 | "downlevelIteration": true, 16 | "experimentalDecorators": true, 17 | "moduleResolution": "node", 18 | "importHelpers": true, 19 | "target": "es2020", 20 | "module": "es2020", 21 | "lib": [ 22 | "es2020", 23 | "dom" 24 | ] 25 | }, 26 | "angularCompilerOptions": { 27 | "enableI18nLegacyMessageIdFormat": false, 28 | "strictInjectionParameters": true, 29 | "strictInputAccessModifiers": true, 30 | "strictTemplates": true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SistemaVentaAngular/ClientApp/tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | /* To learn more about this file see: https://angular.io/config/tsconfig. */ 2 | { 3 | "extends": "./tsconfig.json", 4 | "compilerOptions": { 5 | "outDir": "./out-tsc/spec", 6 | "types": [ 7 | "jasmine" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/polyfills.ts" 13 | ], 14 | "include": [ 15 | "src/**/*.spec.ts", 16 | "src/**/*.d.ts" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Controllers/CategoriaController.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.AspNetCore.Mvc; 4 | using SistemaVentaAngular.DTOs; 5 | using SistemaVentaAngular.Repository.Contratos; 6 | using SistemaVentaAngular.Utilidades; 7 | 8 | namespace SistemaVentaAngular.Controllers 9 | { 10 | [Route("api/[controller]")] 11 | [ApiController] 12 | public class CategoriaController : ControllerBase 13 | { 14 | private readonly IMapper _mapper; 15 | private readonly ICategoriaRepositorio _categoriaRepositorio; 16 | public CategoriaController(ICategoriaRepositorio categoriaRepositorio, IMapper mapper) 17 | { 18 | _mapper = mapper; 19 | _categoriaRepositorio = categoriaRepositorio; 20 | } 21 | 22 | [HttpGet] 23 | [Route("Lista")] 24 | public async Task Lista() 25 | { 26 | Response> _response = new Response>(); 27 | 28 | try 29 | { 30 | List _listaCategorias = new List(); 31 | _listaCategorias = _mapper.Map>(await _categoriaRepositorio.Lista()); 32 | 33 | if (_listaCategorias.Count > 0) 34 | _response = new Response>() { status = true, msg = "ok", value = _listaCategorias }; 35 | else 36 | _response = new Response>() { status = false, msg = "sin resultados", value = null }; 37 | 38 | 39 | return StatusCode(StatusCodes.Status200OK, _response); 40 | } 41 | catch (Exception ex) 42 | { 43 | _response = new Response>() { status = false, msg = ex.Message, value = null }; 44 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Controllers/DashBoardController.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.AspNetCore.Mvc; 4 | using SistemaVentaAngular.DTOs; 5 | using SistemaVentaAngular.Repository.Contratos; 6 | using SistemaVentaAngular.Utilidades; 7 | 8 | namespace SistemaVentaAngular.Controllers 9 | { 10 | [Route("api/[controller]")] 11 | [ApiController] 12 | public class DashBoardController : ControllerBase 13 | { 14 | private readonly IMapper _mapper; 15 | private readonly IDashBoardRepositorio _dashboardRepositorio; 16 | public DashBoardController(IDashBoardRepositorio dashboardRepositorio, IMapper mapper) 17 | { 18 | _mapper = mapper; 19 | _dashboardRepositorio = dashboardRepositorio; 20 | } 21 | 22 | [HttpGet] 23 | [Route("Resumen")] 24 | public async Task Resumen() 25 | { 26 | Response _response = new Response(); 27 | 28 | try 29 | { 30 | 31 | DashBoardDTO vmDashboard = new DashBoardDTO(); 32 | 33 | vmDashboard.TotalVentas = await _dashboardRepositorio.TotalVentasUltimaSemana(); 34 | vmDashboard.TotalIngresos = await _dashboardRepositorio.TotalIngresosUltimaSemana(); 35 | vmDashboard.TotalProductos = await _dashboardRepositorio.TotalProductos(); 36 | 37 | List listaVentasSemana = new List(); 38 | 39 | foreach (KeyValuePair item in await _dashboardRepositorio.VentasUltimaSemana()) 40 | { 41 | listaVentasSemana.Add(new VentasSemanaDTO() 42 | { 43 | Fecha = item.Key, 44 | Total = item.Value 45 | }); 46 | } 47 | vmDashboard.VentasUltimaSemana = listaVentasSemana; 48 | 49 | _response = new Response() { status = true, msg = "ok", value = vmDashboard }; 50 | return StatusCode(StatusCodes.Status200OK, _response); 51 | 52 | } 53 | catch (Exception ex) 54 | { 55 | _response = new Response() { status = false, msg = ex.Message, value = null }; 56 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 57 | } 58 | 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Controllers/ProductoController.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.AspNetCore.Mvc; 4 | using Microsoft.EntityFrameworkCore; 5 | using SistemaVentaAngular.DTOs; 6 | using SistemaVentaAngular.Models; 7 | using SistemaVentaAngular.Repository.Contratos; 8 | using SistemaVentaAngular.Utilidades; 9 | 10 | namespace SistemaVentaAngular.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class ProductoController : ControllerBase 15 | { 16 | private readonly IMapper _mapper; 17 | private readonly IProductoRepositorio _productoRepositorio; 18 | public ProductoController(IProductoRepositorio productoRepositorio, IMapper mapper) 19 | { 20 | _mapper = mapper; 21 | _productoRepositorio = productoRepositorio; 22 | } 23 | 24 | [HttpGet] 25 | [Route("Lista")] 26 | public async Task Lista() 27 | { 28 | Response> _response = new Response>(); 29 | 30 | try 31 | { 32 | List ListaProductos = new List(); 33 | IQueryable query = await _productoRepositorio.Consultar(); 34 | query = query.Include(r => r.IdCategoriaNavigation); 35 | 36 | ListaProductos = _mapper.Map>(query.ToList()); 37 | 38 | if (ListaProductos.Count > 0) 39 | _response = new Response>() { status = true, msg = "ok", value = ListaProductos }; 40 | else 41 | _response = new Response>() { status = false, msg = "", value = null }; 42 | 43 | return StatusCode(StatusCodes.Status200OK, _response); 44 | } 45 | catch (Exception ex) 46 | { 47 | _response = new Response>() { status = false, msg = ex.Message, value = null }; 48 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 49 | } 50 | } 51 | 52 | 53 | [HttpPost] 54 | [Route("Guardar")] 55 | public async Task Guardar([FromBody] ProductoDTO request) 56 | { 57 | Response _response = new Response(); 58 | try 59 | { 60 | Producto _producto = _mapper.Map(request); 61 | 62 | Producto _productoCreado = await _productoRepositorio.Crear(_producto); 63 | 64 | if (_productoCreado.IdProducto != 0) 65 | _response = new Response() { status = true, msg = "ok", value = _mapper.Map(_productoCreado) }; 66 | else 67 | _response = new Response() { status = false, msg = "No se pudo crear el producto" }; 68 | 69 | return StatusCode(StatusCodes.Status200OK, _response); 70 | } 71 | catch (Exception ex) 72 | { 73 | _response = new Response() { status = false, msg = ex.Message }; 74 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 75 | } 76 | } 77 | 78 | [HttpPut] 79 | [Route("Editar")] 80 | public async Task Editar([FromBody] ProductoDTO request) 81 | { 82 | Response _response = new Response(); 83 | try 84 | { 85 | Producto _producto = _mapper.Map(request); 86 | Producto _productoParaEditar = await _productoRepositorio.Obtener(u => u.IdProducto == _producto.IdProducto); 87 | 88 | if (_productoParaEditar != null) 89 | { 90 | 91 | _productoParaEditar.Nombre = _producto.Nombre; 92 | _productoParaEditar.IdCategoria = _producto.IdCategoria; 93 | _productoParaEditar.Stock = _producto.Stock; 94 | _productoParaEditar.Precio = _producto.Precio; 95 | 96 | bool respuesta = await _productoRepositorio.Editar(_productoParaEditar); 97 | 98 | if (respuesta) 99 | _response = new Response() { status = true, msg = "ok", value = _mapper.Map(_productoParaEditar) }; 100 | else 101 | _response = new Response() { status = false, msg = "No se pudo editar el producto" }; 102 | } 103 | else 104 | { 105 | _response = new Response() { status = false, msg = "No se encontró el producto" }; 106 | } 107 | 108 | return StatusCode(StatusCodes.Status200OK, _response); 109 | } 110 | catch (Exception ex) 111 | { 112 | _response = new Response() { status = false, msg = ex.Message }; 113 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 114 | } 115 | } 116 | 117 | 118 | 119 | [HttpDelete] 120 | [Route("Eliminar/{id:int}")] 121 | public async Task Eliminar(int id) 122 | { 123 | Response _response = new Response(); 124 | try 125 | { 126 | Producto _productoEliminar = await _productoRepositorio.Obtener(u => u.IdProducto == id); 127 | 128 | if (_productoEliminar != null) 129 | { 130 | 131 | bool respuesta = await _productoRepositorio.Eliminar(_productoEliminar); 132 | 133 | if (respuesta) 134 | _response = new Response() { status = true, msg = "ok", value = "" }; 135 | else 136 | _response = new Response() { status = false, msg = "No se pudo eliminar el producto", value = "" }; 137 | } 138 | 139 | return StatusCode(StatusCodes.Status200OK, _response); 140 | } 141 | catch (Exception ex) 142 | { 143 | _response = new Response() { status = false, msg = ex.Message }; 144 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 145 | } 146 | } 147 | 148 | 149 | 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Controllers/RolController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using SistemaVentaAngular.DTOs; 4 | using SistemaVentaAngular.Repository.Contratos; 5 | using AutoMapper; 6 | using SistemaVentaAngular.Models; 7 | using Microsoft.EntityFrameworkCore; 8 | using SistemaVentaAngular.Utilidades; 9 | 10 | namespace SistemaVentaAngular.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class RolController : ControllerBase 15 | { 16 | private readonly IMapper _mapper; 17 | private readonly IRolRepositorio _rolRepositorio; 18 | public RolController(IRolRepositorio rolRepositorio, IMapper mapper) 19 | { 20 | _mapper = mapper; 21 | _rolRepositorio = rolRepositorio; 22 | } 23 | 24 | [HttpGet] 25 | [Route("Lista")] 26 | public async Task Lista() 27 | { 28 | Response> _response = new Response>(); 29 | 30 | try 31 | { 32 | List _listaRoles = new List(); 33 | _listaRoles = _mapper.Map>(await _rolRepositorio.Lista()); 34 | 35 | if (_listaRoles.Count > 0) 36 | _response = new Response>() { status = true, msg= "ok", value = _listaRoles }; 37 | else 38 | _response = new Response>() { status = false, msg = "sin resultados", value = null }; 39 | 40 | 41 | return StatusCode(StatusCodes.Status200OK, _response); 42 | } 43 | catch (Exception ex) 44 | { 45 | _response = new Response>() { status = false, msg = ex.Message, value = null }; 46 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Controllers/UsuarioController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Http; 2 | using Microsoft.AspNetCore.Mvc; 3 | using SistemaVentaAngular.DTOs; 4 | using SistemaVentaAngular.Repository.Contratos; 5 | using AutoMapper; 6 | using SistemaVentaAngular.Models; 7 | using Microsoft.EntityFrameworkCore; 8 | using SistemaVentaAngular.Utilidades; 9 | 10 | namespace SistemaVentaAngular.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class UsuarioController : ControllerBase 15 | { 16 | private readonly IMapper _mapper; 17 | private readonly IUsuarioRepositorio _usuarioRepositorio; 18 | public UsuarioController(IUsuarioRepositorio usuarioRepositorio,IMapper mapper) 19 | { 20 | _mapper = mapper; 21 | _usuarioRepositorio = usuarioRepositorio; 22 | } 23 | 24 | [HttpGet] 25 | [Route("Lista")] 26 | public async Task Lista() { 27 | Response> _response = new Response>(); 28 | 29 | try 30 | { 31 | List ListaUsuarios = new List(); 32 | IQueryable query = await _usuarioRepositorio.Consultar(); 33 | query = query.Include(r => r.IdRolNavigation); 34 | 35 | ListaUsuarios = _mapper.Map>(query.ToList()); 36 | 37 | if (ListaUsuarios.Count > 0) 38 | _response = new Response>() { status = true, msg = "ok", value = ListaUsuarios }; 39 | else 40 | _response = new Response>() { status = false, msg = "", value = null }; 41 | 42 | return StatusCode(StatusCodes.Status200OK, _response); 43 | } 44 | catch (Exception ex) { 45 | _response = new Response>() { status = false, msg = ex.Message, value = null }; 46 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 47 | } 48 | } 49 | 50 | [HttpGet] 51 | [Route("IniciarSesion")] 52 | public async Task IniciarSesion(string correo,string clave) 53 | { 54 | Response _response = new Response (); 55 | try 56 | { 57 | Usuario _usuario = await _usuarioRepositorio.Obtener(u => u.Correo == correo && u.Clave == clave); 58 | 59 | if (_usuario != null) 60 | _response = new Response() { status = true,msg="ok",value = _usuario }; 61 | else 62 | _response = new Response() { status = false, msg = "no encontrado", value = null }; 63 | 64 | return StatusCode(StatusCodes.Status200OK, _response); 65 | } 66 | catch (Exception ex) 67 | { 68 | _response = new Response() { status = false, msg = ex.Message, value = null }; 69 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 70 | } 71 | } 72 | 73 | [HttpPost] 74 | [Route("Guardar")] 75 | public async Task Guardar([FromBody] UsuarioDTO request) 76 | { 77 | Response _response = new Response(); 78 | try 79 | { 80 | Usuario _usuario = _mapper.Map(request); 81 | 82 | Usuario _usuarioCreado = await _usuarioRepositorio.Crear(_usuario); 83 | 84 | if(_usuarioCreado.IdUsuario != 0) 85 | _response = new Response() { status = true, msg= "ok", value = _mapper.Map(_usuarioCreado) }; 86 | else 87 | _response = new Response() { status = false, msg = "No se pudo crear el usuario" }; 88 | 89 | return StatusCode(StatusCodes.Status200OK, _response); 90 | } 91 | catch (Exception ex) 92 | { 93 | _response = new Response() { status = false, msg = ex.Message }; 94 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 95 | } 96 | } 97 | 98 | [HttpPut] 99 | [Route("Editar")] 100 | public async Task Editar([FromBody] UsuarioDTO request) 101 | { 102 | Response _response = new Response(); 103 | try 104 | { 105 | Usuario _usuario = _mapper.Map(request); 106 | Usuario _usuarioParaEditar = await _usuarioRepositorio.Obtener(u => u.IdUsuario == _usuario.IdUsuario); 107 | 108 | if (_usuarioParaEditar != null) 109 | { 110 | 111 | _usuarioParaEditar.NombreApellidos = _usuario.NombreApellidos; 112 | _usuarioParaEditar.Correo = _usuario.Correo; 113 | _usuarioParaEditar.IdRol = _usuario.IdRol; 114 | _usuarioParaEditar.Clave = _usuario.Clave; 115 | 116 | bool respuesta = await _usuarioRepositorio.Editar(_usuarioParaEditar); 117 | 118 | if (respuesta) 119 | _response = new Response() { status = true, msg = "ok", value = _mapper.Map(_usuarioParaEditar) }; 120 | else 121 | _response = new Response() { status = false, msg = "No se pudo editar el usuario" }; 122 | } 123 | else { 124 | _response = new Response() { status = false, msg = "No se encontró el usuario" }; 125 | } 126 | 127 | return StatusCode(StatusCodes.Status200OK, _response); 128 | } 129 | catch (Exception ex) 130 | { 131 | _response = new Response() { status = false, msg = ex.Message }; 132 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 133 | } 134 | } 135 | 136 | 137 | 138 | [HttpDelete] 139 | [Route("Eliminar/{id:int}")] 140 | public async Task Eliminar(int id) 141 | { 142 | Response _response = new Response(); 143 | try 144 | { 145 | Usuario _usuarioEliminar = await _usuarioRepositorio.Obtener(u => u.IdUsuario == id); 146 | 147 | if (_usuarioEliminar != null) { 148 | 149 | bool respuesta = await _usuarioRepositorio.Eliminar(_usuarioEliminar); 150 | 151 | if (respuesta) 152 | _response = new Response() { status = true, msg = "ok", value = "" }; 153 | else 154 | _response = new Response() { status = false, msg = "No se pudo eliminar el usuario", value = "" }; 155 | } 156 | 157 | return StatusCode(StatusCodes.Status200OK, _response); 158 | } 159 | catch (Exception ex) 160 | { 161 | _response = new Response() { status = false, msg = ex.Message }; 162 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 163 | } 164 | } 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Controllers/VentaController.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using Microsoft.AspNetCore.Http; 3 | using Microsoft.AspNetCore.Mvc; 4 | using SistemaVentaAngular.DTOs; 5 | using SistemaVentaAngular.Models; 6 | using SistemaVentaAngular.Repository.Contratos; 7 | using SistemaVentaAngular.Utilidades; 8 | using System.Globalization; 9 | 10 | namespace SistemaVentaAngular.Controllers 11 | { 12 | [Route("api/[controller]")] 13 | [ApiController] 14 | public class VentaController : ControllerBase 15 | { 16 | 17 | private readonly IMapper _mapper; 18 | private readonly IVentaRepositorio _ventaRepositorio; 19 | 20 | public VentaController(IVentaRepositorio ventaRepositorio, IMapper mapper) 21 | { 22 | _mapper = mapper; 23 | _ventaRepositorio = ventaRepositorio; 24 | } 25 | 26 | 27 | [HttpPost] 28 | [Route("Registrar")] 29 | public async Task Registrar([FromBody] VentaDTO request) 30 | { 31 | Response _response = new Response(); 32 | try 33 | { 34 | 35 | Venta venta_creada = await _ventaRepositorio.Registrar(_mapper.Map(request)); 36 | request = _mapper.Map(venta_creada); 37 | 38 | if(venta_creada.IdVenta != 0) 39 | _response = new Response() { status = true, msg = "ok", value = request }; 40 | else 41 | _response = new Response() { status = false, msg = "No se pudo registrar la venta" }; 42 | 43 | return StatusCode(StatusCodes.Status200OK, _response); 44 | } 45 | catch (Exception ex) 46 | { 47 | _response = new Response() { status = false, msg = ex.Message }; 48 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 49 | } 50 | } 51 | 52 | [HttpGet] 53 | [Route("Historial")] 54 | public async Task Historial(string buscarPor,string? numeroVenta, string? fechaInicio, string? fechaFin) 55 | { 56 | Response> _response = new Response>(); 57 | 58 | numeroVenta = numeroVenta is null ? "" : numeroVenta; 59 | fechaInicio = fechaInicio is null ? "" : fechaInicio; 60 | fechaFin = fechaInicio is null ? "" : fechaFin; 61 | 62 | try { 63 | 64 | List vmHistorialVenta = _mapper.Map>(await _ventaRepositorio.Historial(buscarPor, numeroVenta, fechaInicio, fechaFin)); 65 | 66 | if (vmHistorialVenta.Count > 0) 67 | _response = new Response>() { status = true, msg = "ok", value = vmHistorialVenta }; 68 | else 69 | _response = new Response>() { status = false, msg = "No se pudo registrar la venta" }; 70 | 71 | return StatusCode(StatusCodes.Status200OK, _response); 72 | } 73 | catch (Exception ex) 74 | { 75 | _response = new Response>() { status = false, msg = ex.Message }; 76 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 77 | 78 | } 79 | 80 | } 81 | 82 | [HttpGet] 83 | [Route("Reporte")] 84 | public async Task Reporte(string? fechaInicio, string? fechaFin) 85 | { 86 | Response> _response = new Response>(); 87 | DateTime _fechaInicio = DateTime.ParseExact(fechaInicio, "dd/MM/yyyy", new CultureInfo("es-PE")); 88 | DateTime _fechaFin = DateTime.ParseExact(fechaFin, "dd/MM/yyyy", new CultureInfo("es-PE")); 89 | 90 | try 91 | { 92 | 93 | List listaReporte = _mapper.Map>(await _ventaRepositorio.Reporte(_fechaInicio,_fechaFin)); 94 | 95 | if (listaReporte.Count > 0) 96 | _response = new Response>() { status = true, msg = "ok", value = listaReporte }; 97 | else 98 | _response = new Response>() { status = false, msg = "No se pudo registrar la venta" }; 99 | 100 | return StatusCode(StatusCodes.Status200OK, _response); 101 | } 102 | catch (Exception ex) 103 | { 104 | _response = new Response>() { status = false, msg = ex.Message }; 105 | return StatusCode(StatusCodes.Status500InternalServerError, _response); 106 | 107 | } 108 | 109 | } 110 | 111 | 112 | 113 | 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Controllers/WeatherForecastController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | 3 | namespace SistemaVentaAngular.Controllers 4 | { 5 | [ApiController] 6 | [Route("[controller]")] 7 | public class WeatherForecastController : ControllerBase 8 | { 9 | private static readonly string[] Summaries = new[] 10 | { 11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 12 | }; 13 | 14 | private readonly ILogger _logger; 15 | 16 | public WeatherForecastController(ILogger logger) 17 | { 18 | _logger = logger; 19 | } 20 | 21 | [HttpGet] 22 | public IEnumerable Get() 23 | { 24 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast 25 | { 26 | Date = DateTime.Now.AddDays(index), 27 | TemperatureC = Random.Shared.Next(-20, 55), 28 | Summary = Summaries[Random.Shared.Next(Summaries.Length)] 29 | }) 30 | .ToArray(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /SistemaVentaAngular/DTOs/CategoriaDTO.cs: -------------------------------------------------------------------------------- 1 | namespace SistemaVentaAngular.DTOs 2 | { 3 | public class CategoriaDTO 4 | { 5 | public int IdCategoria { get; set; } 6 | public string? Descripcion { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /SistemaVentaAngular/DTOs/DashBoardDTO.cs: -------------------------------------------------------------------------------- 1 | namespace SistemaVentaAngular.DTOs 2 | { 3 | public class DashBoardDTO 4 | { 5 | public int TotalVentas { get; set; } 6 | public string? TotalIngresos { get; set; } 7 | public int TotalProductos { get; set; } 8 | 9 | public List? VentasUltimaSemana { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SistemaVentaAngular/DTOs/DetalleVentaDTO.cs: -------------------------------------------------------------------------------- 1 | namespace SistemaVentaAngular.DTOs 2 | { 3 | public class DetalleVentaDTO 4 | { 5 | public int? IdProducto { get; set; } 6 | public string? DescripcionProducto { get; set; } 7 | public int? Cantidad { get; set; } 8 | public string? PrecioTexto { get; set; } 9 | public string? TotalTexto { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SistemaVentaAngular/DTOs/ProductoDTO.cs: -------------------------------------------------------------------------------- 1 | namespace SistemaVentaAngular.DTOs 2 | { 3 | public class ProductoDTO 4 | { 5 | public int IdProducto { get; set; } 6 | public string? Nombre { get; set; } 7 | public int? IdCategoria { get; set; } 8 | public string? DescripcionCategoria { get; set; } 9 | public int? Stock { get; set; } 10 | public string? Precio { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SistemaVentaAngular/DTOs/ReporteDTO.cs: -------------------------------------------------------------------------------- 1 | namespace SistemaVentaAngular.DTOs 2 | { 3 | public class ReporteDTO 4 | { 5 | public string? NumeroDocumento { get; set; } 6 | public string? TipoPago { get; set; } 7 | public string? FechaRegistro { get; set; } 8 | public string? TotalVenta{ get; set; } 9 | 10 | public string? Producto { get; set; } 11 | public int? Cantidad { get; set; } 12 | public string? Precio { get; set; } 13 | public string? Total { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SistemaVentaAngular/DTOs/RolDTO.cs: -------------------------------------------------------------------------------- 1 | namespace SistemaVentaAngular.DTOs 2 | { 3 | public class RolDTO 4 | { 5 | public int IdRol { get; set; } 6 | public string? Descripcion { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /SistemaVentaAngular/DTOs/UsuarioDTO.cs: -------------------------------------------------------------------------------- 1 | namespace SistemaVentaAngular.DTOs 2 | { 3 | 4 | public class UsuarioDTO 5 | { 6 | public int IdUsuario { get; set; } 7 | public string NombreApellidos { get; set; } 8 | public string Correo { get; set; } 9 | public int IdRol { get; set; } 10 | public string rolDescripcion { get; set; } 11 | public string Clave { get; set; } 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SistemaVentaAngular/DTOs/VentaDTO.cs: -------------------------------------------------------------------------------- 1 | namespace SistemaVentaAngular.DTOs 2 | { 3 | public class VentaDTO 4 | { 5 | public int IdVenta { get; set; } 6 | public string? NumeroDocumento { get; set; } 7 | public string? TipoPago { get; set; } 8 | public string? FechaRegistro { get; set; } 9 | public string? TotalTexto { get; set; } 10 | public virtual ICollection? DetalleVenta { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SistemaVentaAngular/DTOs/VentasSemanaDTO.cs: -------------------------------------------------------------------------------- 1 | namespace SistemaVentaAngular.DTOs 2 | { 3 | public class VentasSemanaDTO 4 | { 5 | public string? Fecha { get; set; } 6 | public int Total { get; set; } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Models/Categoria.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SistemaVentaAngular.Models 5 | { 6 | public partial class Categoria 7 | { 8 | public Categoria() 9 | { 10 | Productos = new HashSet(); 11 | } 12 | 13 | public int IdCategoria { get; set; } 14 | public string? Descripcion { get; set; } 15 | public bool? EsActivo { get; set; } 16 | public DateTime? FechaRegistro { get; set; } 17 | 18 | public virtual ICollection Productos { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Models/DetalleVenta.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SistemaVentaAngular.Models 5 | { 6 | public partial class DetalleVenta 7 | { 8 | public int IdDetalleVenta { get; set; } 9 | public int? IdVenta { get; set; } 10 | public int? IdProducto { get; set; } 11 | public int? Cantidad { get; set; } 12 | public decimal? Precio { get; set; } 13 | public decimal? Total { get; set; } 14 | 15 | public virtual Producto? IdProductoNavigation { get; set; } 16 | public virtual Venta? IdVentaNavigation { get; set; } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Models/NumeroDocumento.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SistemaVentaAngular.Models 5 | { 6 | public partial class NumeroDocumento 7 | { 8 | public int IdNumeroDocumento { get; set; } 9 | public int UltimoNumero { get; set; } 10 | public DateTime? FechaRegistro { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Models/Producto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SistemaVentaAngular.Models 5 | { 6 | public partial class Producto 7 | { 8 | public Producto() 9 | { 10 | DetalleVenta = new HashSet(); 11 | } 12 | 13 | public int IdProducto { get; set; } 14 | public string? Nombre { get; set; } 15 | public int? IdCategoria { get; set; } 16 | public int? Stock { get; set; } 17 | public decimal? Precio { get; set; } 18 | public bool? EsActivo { get; set; } 19 | public DateTime? FechaRegistro { get; set; } 20 | 21 | public virtual Categoria? IdCategoriaNavigation { get; set; } 22 | public virtual ICollection DetalleVenta { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Models/Rol.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SistemaVentaAngular.Models 5 | { 6 | public partial class Rol 7 | { 8 | public Rol() 9 | { 10 | Usuarios = new HashSet(); 11 | } 12 | 13 | public int IdRol { get; set; } 14 | public string? Descripcion { get; set; } 15 | public bool? EsActivo { get; set; } 16 | public DateTime? FechaRegistro { get; set; } 17 | 18 | public virtual ICollection Usuarios { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Models/Usuario.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SistemaVentaAngular.Models 5 | { 6 | public partial class Usuario 7 | { 8 | public int IdUsuario { get; set; } 9 | public string? NombreApellidos { get; set; } 10 | public string? Correo { get; set; } 11 | public int? IdRol { get; set; } 12 | public string? Clave { get; set; } 13 | public bool? EsActivo { get; set; } 14 | 15 | public virtual Rol? IdRolNavigation { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Models/Venta.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace SistemaVentaAngular.Models 5 | { 6 | public partial class Venta 7 | { 8 | public Venta() 9 | { 10 | DetalleVenta = new HashSet(); 11 | } 12 | 13 | public int IdVenta { get; set; } 14 | public string? NumeroDocumento { get; set; } 15 | public string? TipoPago { get; set; } 16 | public DateTime? FechaRegistro { get; set; } 17 | public decimal? Total { get; set; } 18 | 19 | public virtual ICollection DetalleVenta { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model ErrorModel 3 | @{ 4 | ViewData["Title"] = "Error"; 5 | } 6 | 7 |

Error.

8 |

An error occurred while processing your request.

9 | 10 | @if (Model.ShowRequestId) 11 | { 12 |

13 | Request ID: @Model.RequestId 14 |

15 | } 16 | 17 |

Development Mode

18 |

19 | Swapping to the Development environment displays detailed information about the error that occurred. 20 |

21 |

22 | The Development environment shouldn't be enabled for deployed applications. 23 | It can result in displaying sensitive information from exceptions to end users. 24 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 25 | and restarting the app. 26 |

27 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using System.Diagnostics; 4 | 5 | namespace SistemaVentaAngular.Pages 6 | { 7 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 8 | public class ErrorModel : PageModel 9 | { 10 | private readonly ILogger _logger; 11 | 12 | public ErrorModel(ILogger logger) 13 | { 14 | _logger = logger; 15 | } 16 | 17 | public string? RequestId { get; set; } 18 | 19 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 20 | 21 | public void OnGet() 22 | { 23 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /SistemaVentaAngular/Pages/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using SistemaVentaAngular 2 | @namespace SistemaVentaAngular.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using SistemaVentaAngular.Models; 3 | using SistemaVentaAngular.Repository.Contratos; 4 | using SistemaVentaAngular.Repository.Implementacion; 5 | using SistemaVentaAngular.Utilidades; 6 | 7 | var builder = WebApplication.CreateBuilder(args); 8 | 9 | // Add services to the container. 10 | 11 | builder.Services.AddControllersWithViews(); 12 | 13 | 14 | builder.Services.AddDbContext(options => 15 | { 16 | options.UseSqlServer(builder.Configuration.GetConnectionString("sqlConection")); 17 | }); 18 | builder.Services.AddAutoMapper(typeof(AutoMapperProfile)); 19 | 20 | builder.Services.AddScoped(); 21 | builder.Services.AddScoped(); 22 | builder.Services.AddScoped(); 23 | builder.Services.AddScoped(); 24 | builder.Services.AddScoped(); 25 | builder.Services.AddScoped(); 26 | 27 | var app = builder.Build(); 28 | 29 | // Configure the HTTP request pipeline. 30 | if (!app.Environment.IsDevelopment()) 31 | { 32 | } 33 | 34 | app.UseStaticFiles(); 35 | app.UseRouting(); 36 | 37 | 38 | app.MapControllerRoute( 39 | name: "default", 40 | pattern: "{controller}/{action=Index}/{id?}"); 41 | 42 | app.MapFallbackToFile("index.html"); ; 43 | 44 | app.Run(); 45 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:64159", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "SistemaVentaAngular": { 12 | "commandName": "Project", 13 | "launchBrowser": true, 14 | "applicationUrl": "http://localhost:5293", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development", 17 | "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" 18 | } 19 | }, 20 | "IIS Express": { 21 | "commandName": "IISExpress", 22 | "launchBrowser": true, 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development", 25 | "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.SpaProxy" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Repository/Contratos/ICategoriaRepositorio.cs: -------------------------------------------------------------------------------- 1 | using SistemaVentaAngular.Models; 2 | 3 | namespace SistemaVentaAngular.Repository.Contratos 4 | { 5 | public interface ICategoriaRepositorio 6 | { 7 | Task> Lista(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Repository/Contratos/IDashBoardRepositorio.cs: -------------------------------------------------------------------------------- 1 | namespace SistemaVentaAngular.Repository.Contratos 2 | { 3 | public interface IDashBoardRepositorio 4 | { 5 | Task TotalVentasUltimaSemana(); 6 | Task TotalIngresosUltimaSemana(); 7 | Task TotalProductos(); 8 | Task> VentasUltimaSemana(); 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Repository/Contratos/IProductoRepositorio.cs: -------------------------------------------------------------------------------- 1 | using SistemaVentaAngular.Models; 2 | using System.Linq.Expressions; 3 | 4 | namespace SistemaVentaAngular.Repository.Contratos 5 | { 6 | public interface IProductoRepositorio 7 | { 8 | Task Obtener(Expression> filtro = null); 9 | Task Crear(Producto entidad); 10 | Task Editar(Producto entidad); 11 | Task Eliminar(Producto entidad); 12 | Task> Consultar(Expression> filtro = null); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Repository/Contratos/IRolRepositorio.cs: -------------------------------------------------------------------------------- 1 | using SistemaVentaAngular.Models; 2 | 3 | namespace SistemaVentaAngular.Repository.Contratos 4 | { 5 | public interface IRolRepositorio 6 | { 7 | Task> Lista(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Repository/Contratos/IUsuarioRepositorio.cs: -------------------------------------------------------------------------------- 1 | using SistemaVentaAngular.Models; 2 | using System.Linq.Expressions; 3 | 4 | namespace SistemaVentaAngular.Repository.Contratos 5 | { 6 | public interface IUsuarioRepositorio 7 | { 8 | Task> Lista(); 9 | Task Obtener(Expression> filtro = null); 10 | Task Crear(Usuario entidad); 11 | Task Editar(Usuario entidad); 12 | Task Eliminar(Usuario entidad); 13 | Task> Consultar(Expression> filtro = null); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Repository/Contratos/IVentaRepositorio.cs: -------------------------------------------------------------------------------- 1 | using SistemaVentaAngular.Models; 2 | 3 | namespace SistemaVentaAngular.Repository.Contratos 4 | { 5 | public interface IVentaRepositorio 6 | { 7 | Task Registrar(Venta entidad); 8 | Task> Historial(string buscarPor,string numeroVenta, string fechaInicio, string fechaFin); 9 | Task> Reporte(DateTime FechaInicio, DateTime FechaFin); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Repository/Implementacion/CategoriaRepositorio.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using SistemaVentaAngular.Models; 3 | using SistemaVentaAngular.Repository.Contratos; 4 | 5 | namespace SistemaVentaAngular.Repository.Implementacion 6 | { 7 | public class CategoriaRepositorio : ICategoriaRepositorio 8 | { 9 | private readonly DBVentaAngularContext _dbContext; 10 | 11 | public CategoriaRepositorio(DBVentaAngularContext dbContext) 12 | { 13 | _dbContext = dbContext; 14 | } 15 | public async Task> Lista() 16 | { 17 | try 18 | { 19 | return await _dbContext.Categoria.ToListAsync(); 20 | } 21 | catch 22 | { 23 | throw; 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Repository/Implementacion/DashBoardRepositorio.cs: -------------------------------------------------------------------------------- 1 | using SistemaVentaAngular.Models; 2 | using SistemaVentaAngular.Repository.Contratos; 3 | using System.Globalization; 4 | 5 | namespace SistemaVentaAngular.Repository.Implementacion 6 | { 7 | public class DashBoardRepositorio : IDashBoardRepositorio 8 | { 9 | private readonly DBVentaAngularContext _dbcontext; 10 | public DashBoardRepositorio(DBVentaAngularContext context) 11 | { 12 | _dbcontext = context; 13 | } 14 | 15 | public async Task TotalVentasUltimaSemana() 16 | { 17 | int total = 0; 18 | try 19 | { 20 | IQueryable _ventaQuery = _dbcontext.Venta.AsQueryable(); 21 | 22 | if (_ventaQuery.Count() > 0) { 23 | DateTime? ultimaFecha = _dbcontext.Venta.OrderByDescending(v => v.FechaRegistro).Select(v => v.FechaRegistro).First(); 24 | 25 | ultimaFecha = ultimaFecha.Value.AddDays(-7); 26 | 27 | IQueryable query = _dbcontext.Venta.Where(v => v.FechaRegistro.Value.Date >= ultimaFecha.Value.Date); 28 | total = query.Count(); 29 | } 30 | 31 | return total; 32 | } 33 | catch 34 | { 35 | throw; 36 | } 37 | } 38 | public async Task TotalIngresosUltimaSemana() 39 | { 40 | decimal resultado = 0; 41 | try 42 | { 43 | IQueryable _ventaQuery = _dbcontext.Venta.AsQueryable(); 44 | 45 | if (_ventaQuery.Count() > 0) 46 | { 47 | DateTime? ultimaFecha = _dbcontext.Venta.OrderByDescending(v => v.FechaRegistro).Select(v => v.FechaRegistro).First(); 48 | ultimaFecha = ultimaFecha.Value.AddDays(-7); 49 | IQueryable query = _dbcontext.Venta.Where(v => v.FechaRegistro.Value.Date >= ultimaFecha.Value.Date); 50 | 51 | resultado = query 52 | .Select(v => v.Total) 53 | .Sum(v => v.Value); 54 | } 55 | 56 | 57 | return Convert.ToString(resultado, new CultureInfo("es-PE")); 58 | } 59 | catch 60 | { 61 | throw; 62 | } 63 | 64 | 65 | } 66 | public async Task TotalProductos() 67 | { 68 | try 69 | { 70 | IQueryable query = _dbcontext.Productos; 71 | int total = query.Count(); 72 | return total; 73 | } 74 | catch 75 | { 76 | throw; 77 | } 78 | } 79 | 80 | public async Task> VentasUltimaSemana() 81 | { 82 | Dictionary resultado = new Dictionary(); 83 | try 84 | { 85 | IQueryable _ventaQuery = _dbcontext.Venta.AsQueryable(); 86 | if (_ventaQuery.Count() > 0) { 87 | DateTime? ultimaFecha = _dbcontext.Venta.OrderByDescending(v => v.FechaRegistro).Select(v => v.FechaRegistro).First(); 88 | ultimaFecha = ultimaFecha.Value.AddDays(-7); 89 | 90 | IQueryable query = _dbcontext.Venta.Where(v => v.FechaRegistro.Value.Date >= ultimaFecha.Value.Date); 91 | 92 | resultado = query 93 | .GroupBy(v => v.FechaRegistro.Value.Date).OrderBy(g => g.Key) 94 | .Select(dv => new { fecha = dv.Key.ToString("dd/MM/yyyy"), total = dv.Count() }) 95 | .ToDictionary(keySelector: r => r.fecha, elementSelector: r => r.total); 96 | } 97 | 98 | 99 | return resultado; 100 | 101 | } 102 | catch 103 | { 104 | throw; 105 | } 106 | 107 | } 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Repository/Implementacion/ProductoRepositorio.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using SistemaVentaAngular.Models; 3 | using SistemaVentaAngular.Repository.Contratos; 4 | using System.Linq.Expressions; 5 | 6 | namespace SistemaVentaAngular.Repository.Implementacion 7 | { 8 | public class ProductoRepositorio : IProductoRepositorio 9 | { 10 | private readonly DBVentaAngularContext _dbContext; 11 | 12 | public ProductoRepositorio(DBVentaAngularContext dbContext) 13 | { 14 | _dbContext = dbContext; 15 | } 16 | public async Task> Consultar(Expression> filtro = null) 17 | { 18 | IQueryable queryEntidad = filtro == null ? _dbContext.Productos : _dbContext.Productos.Where(filtro); 19 | return queryEntidad; 20 | } 21 | 22 | public async Task Crear(Producto entidad) 23 | { 24 | try 25 | { 26 | _dbContext.Set().Add(entidad); 27 | await _dbContext.SaveChangesAsync(); 28 | return entidad; 29 | } 30 | catch 31 | { 32 | throw; 33 | } 34 | } 35 | 36 | public async Task Editar(Producto entidad) 37 | { 38 | try 39 | { 40 | _dbContext.Update(entidad); 41 | await _dbContext.SaveChangesAsync(); 42 | return true; 43 | } 44 | catch 45 | { 46 | throw; 47 | } 48 | } 49 | 50 | public async Task Eliminar(Producto entidad) 51 | { 52 | try 53 | { 54 | _dbContext.Remove(entidad); 55 | await _dbContext.SaveChangesAsync(); 56 | return true; 57 | } 58 | catch 59 | { 60 | throw; 61 | } 62 | } 63 | 64 | public async Task Obtener(Expression> filtro = null) 65 | { 66 | try 67 | { 68 | return await _dbContext.Productos.Where(filtro).FirstOrDefaultAsync(); 69 | } 70 | catch 71 | { 72 | throw; 73 | } 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Repository/Implementacion/RolRepositorio.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using SistemaVentaAngular.Models; 3 | using SistemaVentaAngular.Repository.Contratos; 4 | using System.Linq.Expressions; 5 | 6 | namespace SistemaVentaAngular.Repository.Implementacion 7 | { 8 | public class RolRepositorio : IRolRepositorio 9 | { 10 | private readonly DBVentaAngularContext _dbContext; 11 | 12 | public RolRepositorio(DBVentaAngularContext dbContext) 13 | { 14 | _dbContext = dbContext; 15 | } 16 | public async Task> Lista() 17 | { 18 | try 19 | { 20 | return await _dbContext.Rols.ToListAsync(); 21 | } 22 | catch 23 | { 24 | throw; 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Repository/Implementacion/UsuarioRepositorio.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using SistemaVentaAngular.Models; 3 | using SistemaVentaAngular.Repository.Contratos; 4 | using System.Linq.Expressions; 5 | 6 | namespace SistemaVentaAngular.Repository.Implementacion 7 | { 8 | public class UsuarioRepositorio : IUsuarioRepositorio 9 | { 10 | private readonly DBVentaAngularContext _dbContext; 11 | 12 | public UsuarioRepositorio(DBVentaAngularContext dbContext) 13 | { 14 | _dbContext = dbContext; 15 | } 16 | 17 | public async Task> Consultar(Expression> filtro = null) 18 | { 19 | IQueryable queryEntidad = filtro == null ? _dbContext.Usuarios : _dbContext.Usuarios.Where(filtro); 20 | return queryEntidad; 21 | } 22 | 23 | public async Task Crear(Usuario entidad) 24 | { 25 | try 26 | { 27 | _dbContext.Set().Add(entidad); 28 | await _dbContext.SaveChangesAsync(); 29 | return entidad; 30 | } 31 | catch 32 | { 33 | throw; 34 | } 35 | } 36 | 37 | public async Task Editar(Usuario entidad) 38 | { 39 | try 40 | { 41 | _dbContext.Update(entidad); 42 | await _dbContext.SaveChangesAsync(); 43 | return true; 44 | } 45 | catch 46 | { 47 | throw; 48 | } 49 | } 50 | 51 | public async Task Eliminar(Usuario entidad) 52 | { 53 | try 54 | { 55 | _dbContext.Remove(entidad); 56 | await _dbContext.SaveChangesAsync(); 57 | return true; 58 | } 59 | catch 60 | { 61 | throw; 62 | } 63 | } 64 | 65 | public async Task> Lista() 66 | { 67 | try 68 | { 69 | return await _dbContext.Usuarios.ToListAsync(); 70 | } 71 | catch 72 | { 73 | throw; 74 | } 75 | } 76 | 77 | public async Task Obtener(Expression> filtro = null) 78 | { 79 | try 80 | { 81 | return await _dbContext.Usuarios.Where(filtro).FirstOrDefaultAsync(); 82 | } 83 | catch 84 | { 85 | throw; 86 | } 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Repository/Implementacion/VentaRepositorio.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.EntityFrameworkCore; 2 | using SistemaVentaAngular.Models; 3 | using SistemaVentaAngular.Repository.Contratos; 4 | using System.Globalization; 5 | 6 | namespace SistemaVentaAngular.Repository.Implementacion 7 | { 8 | public class VentaRepositorio : IVentaRepositorio 9 | { 10 | private readonly DBVentaAngularContext _dbcontext; 11 | public VentaRepositorio(DBVentaAngularContext context) 12 | { 13 | _dbcontext = context; 14 | } 15 | 16 | public async Task Registrar(Venta entidad) 17 | { 18 | Venta VentaGenerada = new Venta(); 19 | 20 | //usaremos transacion, ya que si ocurre un error en algun insert a una tabla, debe reestablecer todo a cero, como si no hubo o no existió ningun insert 21 | using (var transaction = _dbcontext.Database.BeginTransaction()) 22 | { 23 | int CantidadDigitos = 4; 24 | try 25 | { 26 | foreach (DetalleVenta dv in entidad.DetalleVenta) 27 | { 28 | Producto producto_encontrado = _dbcontext.Productos.Where(p => p.IdProducto == dv.IdProducto).First(); 29 | 30 | producto_encontrado.Stock = producto_encontrado.Stock - dv.Cantidad; 31 | _dbcontext.Productos.Update(producto_encontrado); 32 | } 33 | await _dbcontext.SaveChangesAsync(); 34 | 35 | 36 | NumeroDocumento correlativo = _dbcontext.NumeroDocumentos.First(); 37 | 38 | correlativo.UltimoNumero = correlativo.UltimoNumero + 1; 39 | correlativo.FechaRegistro = DateTime.Now; 40 | 41 | _dbcontext.NumeroDocumentos.Update(correlativo); 42 | await _dbcontext.SaveChangesAsync(); 43 | 44 | 45 | string ceros = string.Concat(Enumerable.Repeat("0", CantidadDigitos)); 46 | string numeroVenta = ceros + correlativo.UltimoNumero.ToString(); 47 | numeroVenta = numeroVenta.Substring(numeroVenta.Length - CantidadDigitos, CantidadDigitos); 48 | 49 | entidad.NumeroDocumento = numeroVenta; 50 | 51 | await _dbcontext.Venta.AddAsync(entidad); 52 | await _dbcontext.SaveChangesAsync(); 53 | 54 | VentaGenerada = entidad; 55 | 56 | transaction.Commit(); 57 | } 58 | catch (Exception ex) 59 | { 60 | transaction.Rollback(); 61 | throw; 62 | } 63 | } 64 | 65 | return VentaGenerada; 66 | } 67 | 68 | public async Task> Historial(string buscarPor,string numeroVenta, string fechaInicio, string fechaFin) 69 | { 70 | IQueryable query = _dbcontext.Venta; 71 | 72 | if (buscarPor == "fecha") 73 | { 74 | 75 | DateTime fech_Inicio = DateTime.ParseExact(fechaInicio, "dd/MM/yyyy", new CultureInfo("es-PE")); 76 | DateTime fech_Fin = DateTime.ParseExact(fechaFin, "dd/MM/yyyy", new CultureInfo("es-PE")); 77 | 78 | return query.Where(v => 79 | v.FechaRegistro.Value.Date >= fech_Inicio.Date && 80 | v.FechaRegistro.Value.Date <= fech_Fin.Date 81 | ) 82 | .Include(dv => dv.DetalleVenta) 83 | .ThenInclude(p => p.IdProductoNavigation) 84 | .ToList(); 85 | 86 | } 87 | else { 88 | return query.Where(v => v.NumeroDocumento == numeroVenta) 89 | .Include(dv => dv.DetalleVenta) 90 | .ThenInclude(p => p.IdProductoNavigation) 91 | .ToList(); 92 | } 93 | 94 | 95 | } 96 | 97 | public async Task> Reporte(DateTime FechaInicio, DateTime FechaFin) 98 | { 99 | List listaResumen = await _dbcontext.DetalleVenta 100 | .Include(p => p.IdProductoNavigation) 101 | .Include(v => v.IdVentaNavigation) 102 | .Where(dv => dv.IdVentaNavigation.FechaRegistro.Value.Date >= FechaInicio.Date && dv.IdVentaNavigation.FechaRegistro.Value.Date <= FechaFin.Date) 103 | .ToListAsync(); 104 | 105 | return listaResumen; 106 | } 107 | 108 | 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /SistemaVentaAngular/SistemaVentaAngular.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | enable 6 | false 7 | ClientApp\ 8 | http://localhost:44496 9 | npm start 10 | enable 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | all 20 | runtime; build; native; contentfiles; analyzers; buildtransitive 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | wwwroot\%(RecursiveDir)%(FileName)%(Extension) 57 | PreserveNewest 58 | true 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Utilidades/AutoMapperProfile.cs: -------------------------------------------------------------------------------- 1 | using AutoMapper; 2 | using SistemaVentaAngular.DTOs; 3 | using SistemaVentaAngular.Models; 4 | using System.Globalization; 5 | 6 | namespace SistemaVentaAngular.Utilidades 7 | { 8 | public class AutoMapperProfile : Profile 9 | { 10 | public AutoMapperProfile() 11 | { 12 | #region Rol 13 | CreateMap().ReverseMap(); 14 | #endregion Rol 15 | 16 | #region Usuario 17 | CreateMap() 18 | .ForMember(destino => 19 | destino.rolDescripcion, 20 | opt => opt.MapFrom(origen => origen.IdRolNavigation.Descripcion) 21 | ); 22 | 23 | CreateMap() 24 | .ForMember(destino => 25 | destino.IdRolNavigation, 26 | opt => opt.Ignore() 27 | ); 28 | #endregion Usuario 29 | 30 | #region Categoria 31 | CreateMap().ReverseMap(); 32 | #endregion Categoria 33 | 34 | 35 | #region Producto 36 | CreateMap() 37 | .ForMember(destino => 38 | destino.DescripcionCategoria, 39 | opt => opt.MapFrom(origen => origen.IdCategoriaNavigation.Descripcion) 40 | ) 41 | .ForMember(destino => 42 | destino.Precio, 43 | opt => opt.MapFrom(origen => Convert.ToString(origen.Precio.Value, new CultureInfo("es-PE"))) 44 | ); 45 | 46 | CreateMap() 47 | .ForMember(destino => 48 | destino.IdCategoriaNavigation, 49 | opt => opt.Ignore() 50 | ) 51 | .ForMember(destiono => 52 | destiono.Precio, 53 | opt => opt.MapFrom(origen => Convert.ToDecimal(origen.Precio, new CultureInfo("es-PE"))) 54 | ); 55 | #endregion Producto 56 | 57 | 58 | #region Venta 59 | CreateMap() 60 | .ForMember(destino => 61 | destino.TotalTexto, 62 | opt => opt.MapFrom(origen => Convert.ToString(origen.Total.Value, new CultureInfo("es-PE"))) 63 | ).ForMember(destino => 64 | destino.FechaRegistro, 65 | opt => opt.MapFrom(origen => origen.FechaRegistro.Value.ToString("dd/MM/yyyy")) 66 | ); 67 | 68 | CreateMap() 69 | .ForMember(destino => 70 | destino.Total, 71 | opt => opt.MapFrom(origen => Convert.ToDecimal(origen.TotalTexto, new CultureInfo("es-PE"))) 72 | ); 73 | 74 | #endregion Venta 75 | 76 | 77 | #region DetalleVenta 78 | CreateMap() 79 | .ForMember(destino => 80 | destino.DescripcionProducto, 81 | opt => opt.MapFrom(origen => origen.IdProductoNavigation.Nombre) 82 | ) 83 | .ForMember(destino => 84 | destino.PrecioTexto, 85 | opt => opt.MapFrom(origen => Convert.ToString(origen.Precio.Value, new CultureInfo("es-PE"))) 86 | ) 87 | .ForMember(destino => 88 | destino.TotalTexto, 89 | opt => opt.MapFrom(origen => Convert.ToString(origen.Total.Value, new CultureInfo("es-PE"))) 90 | ); 91 | 92 | CreateMap() 93 | .ForMember(destino => 94 | destino.Precio, 95 | opt => opt.MapFrom(origen => Convert.ToDecimal(origen.PrecioTexto, new CultureInfo("es-PE"))) 96 | ) 97 | .ForMember(destino => 98 | destino.Total, 99 | opt => opt.MapFrom(origen => Convert.ToDecimal(origen.TotalTexto, new CultureInfo("es-PE"))) 100 | ); 101 | #endregion 102 | 103 | #region Reporte 104 | CreateMap() 105 | .ForMember(destino => 106 | destino.FechaRegistro, 107 | opt => opt.MapFrom(origen => origen.IdVentaNavigation.FechaRegistro.Value.ToString("dd/MM/yyyy")) 108 | ) 109 | .ForMember(destino => 110 | destino.NumeroDocumento, 111 | opt => opt.MapFrom(origen => origen.IdVentaNavigation.NumeroDocumento) 112 | ) 113 | .ForMember(destino => 114 | destino.TipoPago, 115 | opt => opt.MapFrom(origen => origen.IdVentaNavigation.TipoPago) 116 | ) 117 | .ForMember(destino => 118 | destino.TotalVenta, 119 | opt => opt.MapFrom(origen => Convert.ToString(origen.IdVentaNavigation.Total.Value, new CultureInfo("es-PE"))) 120 | ) 121 | .ForMember(destino => 122 | destino.Producto, 123 | opt => opt.MapFrom(origen => origen.IdProductoNavigation.Nombre) 124 | ) 125 | .ForMember(destino => 126 | destino.Precio, 127 | opt => opt.MapFrom(origen => Convert.ToString(origen.Precio.Value, new CultureInfo("es-PE"))) 128 | ) 129 | .ForMember(destino => 130 | destino.Total, 131 | opt => opt.MapFrom(origen => Convert.ToString(origen.Total.Value, new CultureInfo("es-PE"))) 132 | ); 133 | #endregion Reporte 134 | } 135 | 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /SistemaVentaAngular/Utilidades/Response.cs: -------------------------------------------------------------------------------- 1 | namespace SistemaVentaAngular.Utilidades 2 | { 3 | public class Response 4 | { 5 | public bool status { get; set; } 6 | public string? msg { get; set; } 7 | public T? value { get; set; } 8 | 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SistemaVentaAngular/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | namespace SistemaVentaAngular 2 | { 3 | public class WeatherForecast 4 | { 5 | public DateTime Date { get; set; } 6 | 7 | public int TemperatureC { get; set; } 8 | 9 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 10 | 11 | public string? Summary { get; set; } 12 | } 13 | } -------------------------------------------------------------------------------- /SistemaVentaAngular/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.AspNetCore.SpaProxy": "Information", 7 | "Microsoft.Hosting.Lifetime": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /SistemaVentaAngular/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "ConnectionStrings": { 3 | "sqlConection": "Server=(local); DataBase=DBVentaAngular;Integrated Security=true" 4 | }, 5 | "Logging": { 6 | "LogLevel": { 7 | "Default": "Information", 8 | "Microsoft": "Warning", 9 | "Microsoft.Hosting.Lifetime": "Information" 10 | } 11 | }, 12 | "AllowedHosts": "*" 13 | } 14 | -------------------------------------------------------------------------------- /SistemaVentaAngular/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CodigoEstudiante/085_SistemaVentaAngularNet/55ab2e653be7ff98d9df49f4a1a5e96bd059a876/SistemaVentaAngular/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Utilidad/Scripts to BD/script_db.txt: -------------------------------------------------------------------------------- 1 |  2 | create database DBVentaAngular 3 | 4 | go 5 | 6 | use DBVentaAngular 7 | 8 | go 9 | 10 | create table Rol( 11 | idRol int primary key identity(1,1), 12 | descripcion varchar(50), 13 | esActivo bit, 14 | fechaRegistro datetime default getdate() 15 | ) 16 | 17 | go 18 | 19 | create table Usuario( 20 | idUsuario int primary key identity(1,1), 21 | nombreApellidos varchar(100), 22 | correo varchar(40), 23 | idRol int references Rol(idRol), 24 | clave varchar(40), 25 | esActivo bit 26 | ) 27 | 28 | go 29 | 30 | create table Categoria( 31 | idCategoria int primary key identity(1,1), 32 | descripcion varchar(50), 33 | esActivo bit, 34 | fechaRegistro datetime default getdate() 35 | ) 36 | 37 | 38 | go 39 | create table Producto ( 40 | idProducto int primary key identity(1,1), 41 | nombre varchar(100), 42 | idCategoria int references Categoria(idCategoria), 43 | stock int, 44 | precio decimal(10,2), 45 | esActivo bit, 46 | fechaRegistro datetime default getdate() 47 | ) 48 | 49 | go 50 | 51 | create table NumeroDocumento( 52 | idNumeroDocumento int primary key identity(1,1), 53 | ultimo_Numero int not null, 54 | fechaRegistro datetime default getdate() 55 | ) 56 | go 57 | 58 | create table Venta( 59 | idVenta int primary key identity(1,1), 60 | numeroDocumento varchar(40), 61 | tipoPago varchar(50), 62 | fechaRegistro datetime default getdate(), 63 | total decimal(10,2) 64 | ) 65 | go 66 | 67 | create table DetalleVenta( 68 | idDetalleVenta int primary key identity(1,1), 69 | idVenta int references Venta(idVenta), 70 | idProducto int references Producto(idProducto), 71 | cantidad int, 72 | precio decimal(10,2), 73 | total decimal(10,2) 74 | ) 75 | -------------------------------------------------------------------------------- /Utilidad/Scripts to BD/script_insert.txt: -------------------------------------------------------------------------------- 1 |  2 | 3 | --INSERTAR ROLES 4 | insert into rol(descripcion,esActivo) values 5 | ('Administrador',1), 6 | ('Empleado',1) 7 | 8 | go 9 | 10 | --INSERTAR USUARIOS 11 | insert into usuario(nombreApellidos,correo,idRol,Clave,esActivo) values 12 | ('jose smith','admin@example.com',1,'12345',1), 13 | ('luis smith','employe@example.com',2,'12345',1) 14 | 15 | go 16 | --INSERTAR CATEGORIAS 17 | insert into Categoria(descripcion,esActivo) values ('Laptops',1) 18 | insert into Categoria(descripcion,esActivo) values ('Monitores',1) 19 | insert into Categoria(descripcion,esActivo) values ('Teclados',1) 20 | insert into Categoria(descripcion,esActivo) values ('Auriculares',1) 21 | insert into Categoria(descripcion,esActivo) values ('Memorias',1) 22 | insert into Categoria(descripcion,esActivo) values ('Accesorios',1) 23 | 24 | go 25 | 26 | --INSERTAR PRODUCTOS 27 | 28 | insert into Producto(nombre,idCategoria,stock,precio,esActivo) values 29 | ('laptop samsung book pro',1,20,2500,1), 30 | ('laptop lenovo idea pad',1,30,2200,1), 31 | ('laptop asus zenbook duo',1,30,2100,1), 32 | ('monitor teros gaming te-2',2,25,1050,1), 33 | ('monitor samsung curvo',2,15,1400,1), 34 | ('monitor huawei gamer',2,10,1350,1), 35 | ('teclado seisen gamer',3,10,800,1), 36 | ('teclado antryx gamer',3,10,1000,1), 37 | ('teclado logitech',3,10,1000,1), 38 | ('auricular logitech gamer',4,15,800,1), 39 | ('auricular hyperx gamer',4,20,680,1), 40 | ('auricular redragon rgb',4,25,950,1), 41 | ('memoria kingston rgb',5,10,200,1), 42 | ('ventilador cooler master',6,20,200,1), 43 | ('mini ventilador lenono',6,15,200,1) 44 | 45 | go 46 | 47 | --INSERTAR NUMERO VENTA INICIAL 48 | insert into NumeroDocumento(ultimo_Numero) values(0) 49 | -------------------------------------------------------------------------------- /Utilidad/Utilidad.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | --------------------------------------------------------------------------------