├── .gitignore
├── dominio
├── Elemento.cs
├── Entrenador.cs
├── Pokemon.cs
├── Properties
│ └── AssemblyInfo.cs
└── dominio.csproj
├── ejemplos-ado-net.sln
├── negocio
├── AccesoDatos.cs
├── ElementoNegocio.cs
├── PokemonNegocio.cs
├── Properties
│ └── AssemblyInfo.cs
├── negocio.csproj
└── script_db
│ └── POKEDEX_DB.sql
└── winform-app
├── App.config
├── Program.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── frmAltaPokemon.Designer.cs
├── frmAltaPokemon.cs
├── frmAltaPokemon.resx
├── frmPokemons.Designer.cs
├── frmPokemons.cs
├── frmPokemons.resx
└── winform-app.csproj
/.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 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/dominio/Elemento.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace dominio
8 | {
9 | public class Elemento
10 | {
11 | public int Id { get; set; }
12 | public string Descripcion { get; set; }
13 |
14 | public override string ToString()
15 | {
16 | return Descripcion;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/dominio/Entrenador.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace dominio
8 | {
9 | public class Entrenador
10 | {
11 |
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/dominio/Pokemon.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace dominio
9 | {
10 | public class Pokemon
11 | {
12 | public int Id { get; set; }
13 | [DisplayName("Número")]
14 | public int Numero { get; set; }
15 | public string Nombre { get; set; }
16 | [DisplayName("Descripción")]
17 | public string Descripcion { get; set; }
18 | public string UrlImagen { get; set; }
19 | public Elemento Tipo { get; set; }
20 | public Elemento Debilidad { get; set; }
21 |
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/dominio/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("dominio")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("dominio")]
13 | [assembly: AssemblyCopyright("Copyright © 2021")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("1123f810-ef66-4379-8221-7d0bfe96c701")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/dominio/dominio.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {1123F810-EF66-4379-8221-7D0BFE96C701}
8 | Library
9 | Properties
10 | dominio
11 | dominio
12 | v4.8
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
--------------------------------------------------------------------------------
/ejemplos-ado-net.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31112.23
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "winform-app", "winform-app\winform-app.csproj", "{1C5B0226-704A-46A3-982D-400CCE1BBC1E}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dominio", "dominio\dominio.csproj", "{1123F810-EF66-4379-8221-7D0BFE96C701}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "negocio", "negocio\negocio.csproj", "{974D539C-098C-4E52-89FB-7B433F91DC0C}"
11 | EndProject
12 | Global
13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
14 | Debug|Any CPU = Debug|Any CPU
15 | Release|Any CPU = Release|Any CPU
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {1C5B0226-704A-46A3-982D-400CCE1BBC1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19 | {1C5B0226-704A-46A3-982D-400CCE1BBC1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
20 | {1C5B0226-704A-46A3-982D-400CCE1BBC1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
21 | {1C5B0226-704A-46A3-982D-400CCE1BBC1E}.Release|Any CPU.Build.0 = Release|Any CPU
22 | {1123F810-EF66-4379-8221-7D0BFE96C701}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {1123F810-EF66-4379-8221-7D0BFE96C701}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {1123F810-EF66-4379-8221-7D0BFE96C701}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {1123F810-EF66-4379-8221-7D0BFE96C701}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {974D539C-098C-4E52-89FB-7B433F91DC0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {974D539C-098C-4E52-89FB-7B433F91DC0C}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {974D539C-098C-4E52-89FB-7B433F91DC0C}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {974D539C-098C-4E52-89FB-7B433F91DC0C}.Release|Any CPU.Build.0 = Release|Any CPU
30 | EndGlobalSection
31 | GlobalSection(SolutionProperties) = preSolution
32 | HideSolutionNode = FALSE
33 | EndGlobalSection
34 | GlobalSection(ExtensibilityGlobals) = postSolution
35 | SolutionGuid = {3BEE3B63-C876-4947-8BA3-3C0824FABA7E}
36 | EndGlobalSection
37 | EndGlobal
38 |
--------------------------------------------------------------------------------
/negocio/AccesoDatos.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Data.SqlClient;
7 |
8 | namespace negocio
9 | {
10 | public class AccesoDatos
11 | {
12 | private SqlConnection conexion;
13 | private SqlCommand comando;
14 | private SqlDataReader lector;
15 | public SqlDataReader Lector
16 | {
17 | get { return lector; }
18 | }
19 |
20 | public AccesoDatos()
21 | {
22 | conexion = new SqlConnection("server=.\\SQLEXPRESS; database=POKEDEX_DB; integrated security=true");
23 | comando = new SqlCommand();
24 | }
25 |
26 | public void setearConsulta(string consulta)
27 | {
28 | comando.CommandType = System.Data.CommandType.Text;
29 | comando.CommandText = consulta;
30 | }
31 |
32 | public void ejecutarLectura()
33 | {
34 | comando.Connection = conexion;
35 | try
36 | {
37 | conexion.Open();
38 | lector = comando.ExecuteReader();
39 | }
40 | catch (Exception ex)
41 | {
42 | throw ex;
43 | }
44 | }
45 |
46 | public void ejecutarAccion()
47 | {
48 | comando.Connection = conexion;
49 | try
50 | {
51 | conexion.Open();
52 | comando.ExecuteNonQuery();
53 | }
54 | catch (Exception ex)
55 | {
56 | throw ex;
57 | }
58 | }
59 |
60 | public void setearParametro(string nombre, object valor)
61 | {
62 | comando.Parameters.AddWithValue(nombre, valor);
63 | }
64 |
65 | public void cerrarConexion()
66 | {
67 | if (lector != null)
68 | lector.Close();
69 | conexion.Close();
70 | }
71 |
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/negocio/ElementoNegocio.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using dominio;
7 |
8 | namespace negocio
9 | {
10 | public class ElementoNegocio
11 | {
12 | public List listar()
13 | {
14 | List lista = new List();
15 | AccesoDatos datos = new AccesoDatos();
16 |
17 | try
18 | {
19 | datos.setearConsulta("Select Id, Descripcion From ELEMENTOS");
20 | datos.ejecutarLectura();
21 |
22 | while (datos.Lector.Read())
23 | {
24 | Elemento aux = new Elemento();
25 | aux.Id = (int)datos.Lector["Id"];
26 | aux.Descripcion = (string)datos.Lector["Descripcion"];
27 |
28 | lista.Add(aux);
29 | }
30 |
31 | return lista;
32 | }
33 | catch (Exception ex)
34 | {
35 | throw ex;
36 | }
37 | finally
38 | {
39 | datos.cerrarConexion();
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/negocio/PokemonNegocio.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Data.SqlClient;
7 | using dominio;
8 |
9 | namespace negocio
10 | {
11 | public class PokemonNegocio
12 | {
13 |
14 | public List listar()
15 | {
16 | List lista = new List();
17 | SqlConnection conexion = new SqlConnection();
18 | SqlCommand comando = new SqlCommand();
19 | SqlDataReader lector;
20 |
21 | try
22 | {
23 | conexion.ConnectionString = "server=.\\SQLEXPRESS; database=POKEDEX_DB; integrated security=true";
24 | comando.CommandType = System.Data.CommandType.Text;
25 | comando.CommandText = "Select Numero, Nombre, P.Descripcion, UrlImagen, E.Descripcion Tipo, D.Descripcion Debilidad, P.IdTipo, P.IdDebilidad, P.Id From POKEMONS P, ELEMENTOS E, ELEMENTOS D Where E.Id = P.IdTipo And D.Id = P.IdDebilidad And P.Activo = 1";
26 | comando.Connection = conexion;
27 |
28 | conexion.Open();
29 | lector = comando.ExecuteReader();
30 |
31 | while (lector.Read())
32 | {
33 | Pokemon aux = new Pokemon();
34 | aux.Id = (int)lector["Id"];
35 | aux.Numero = lector.GetInt32(0);
36 | aux.Nombre = (string)lector["Nombre"];
37 | aux.Descripcion = (string)lector["Descripcion"];
38 |
39 | //if(!(lector.IsDBNull(lector.GetOrdinal("UrlImagen"))))
40 | // aux.UrlImagen = (string)lector["UrlImagen"];
41 | if(!(lector["UrlImagen"] is DBNull))
42 | aux.UrlImagen = (string)lector["UrlImagen"];
43 |
44 | aux.Tipo = new Elemento();
45 | aux.Tipo.Id = (int)lector["IdTipo"];
46 | aux.Tipo.Descripcion = (string)lector["Tipo"];
47 | aux.Debilidad = new Elemento();
48 | aux.Debilidad.Id = (int)lector["IdDebilidad"];
49 | aux.Debilidad.Descripcion = (string)lector["Debilidad"];
50 |
51 | lista.Add(aux);
52 | }
53 |
54 | conexion.Close();
55 | return lista;
56 | }
57 | catch (Exception ex)
58 | {
59 | throw ex;
60 | }
61 |
62 | }
63 |
64 | public void agregar(Pokemon nuevo)
65 | {
66 | AccesoDatos datos = new AccesoDatos();
67 |
68 | try
69 | {
70 | datos.setearConsulta("Insert into POKEMONS (Numero, Nombre, Descripcion, Activo, IdTipo, IdDebilidad, UrlImagen)values(" + nuevo.Numero + ", '" + nuevo.Nombre + "', '" + nuevo.Descripcion + "', 1, @idTipo, @idDebilidad, @urlImagen)");
71 | datos.setearParametro("@idTipo", nuevo.Tipo.Id);
72 | datos.setearParametro("@idDebilidad", nuevo.Debilidad.Id);
73 | datos.setearParametro("@urlImagen", nuevo.UrlImagen);
74 | datos.ejecutarAccion();
75 | }
76 | catch (Exception ex)
77 | {
78 | throw ex;
79 | }
80 | finally
81 | {
82 | datos.cerrarConexion();
83 | }
84 | }
85 |
86 | public void modificar(Pokemon poke)
87 | {
88 | AccesoDatos datos = new AccesoDatos();
89 | try
90 | {
91 | datos.setearConsulta("update POKEMONS set Numero = @numero, Nombre = @nombre, Descripcion = @desc, UrlImagen = @img, IdTipo = @idTipo, IdDebilidad = @idDebilidad Where Id = @id");
92 | datos.setearParametro("@numero", poke.Numero);
93 | datos.setearParametro("@nombre", poke.Nombre);
94 | datos.setearParametro("@desc", poke.Descripcion);
95 | datos.setearParametro("@img", poke.UrlImagen);
96 | datos.setearParametro("@idTipo", poke.Tipo.Id);
97 | datos.setearParametro("@idDebilidad", poke.Debilidad.Id);
98 | datos.setearParametro("@id", poke.Id);
99 |
100 | datos.ejecutarAccion();
101 | }
102 | catch (Exception ex)
103 | {
104 | throw ex;
105 | }
106 | finally
107 | {
108 | datos.cerrarConexion();
109 | }
110 | }
111 |
112 | public List filtrar(string campo, string criterio, string filtro)
113 | {
114 | List lista = new List();
115 | AccesoDatos datos = new AccesoDatos();
116 | try
117 | {
118 | string consulta = "Select Numero, Nombre, P.Descripcion, UrlImagen, E.Descripcion Tipo, D.Descripcion Debilidad, P.IdTipo, P.IdDebilidad, P.Id From POKEMONS P, ELEMENTOS E, ELEMENTOS D Where E.Id = P.IdTipo And D.Id = P.IdDebilidad And P.Activo = 1 And ";
119 | if(campo == "Número")
120 | {
121 | switch (criterio)
122 | {
123 | case "Mayor a":
124 | consulta += "Numero > " + filtro;
125 | break;
126 | case "Menor a":
127 | consulta += "Numero < " + filtro;
128 | break;
129 | default:
130 | consulta += "Numero = " + filtro;
131 | break;
132 | }
133 | }
134 | else if(campo == "Nombre")
135 | {
136 | switch (criterio)
137 | {
138 | case "Comienza con":
139 | consulta += "Nombre like '" + filtro + "%' ";
140 | break;
141 | case "Termina con":
142 | consulta += "Nombre like '%" + filtro + "'";
143 | break;
144 | default:
145 | consulta += "Nombre like '%" + filtro + "%'";
146 | break;
147 | }
148 | }
149 | else
150 | {
151 | switch (criterio)
152 | {
153 | case "Comienza con":
154 | consulta += "P.Descripcion like '" + filtro + "%' ";
155 | break;
156 | case "Termina con":
157 | consulta += "P.Descripcion like '%" + filtro + "'";
158 | break;
159 | default:
160 | consulta += "P.Descripcion like '%" + filtro + "%'";
161 | break;
162 | }
163 | }
164 |
165 | datos.setearConsulta(consulta);
166 | datos.ejecutarLectura();
167 | while (datos.Lector.Read())
168 | {
169 | Pokemon aux = new Pokemon();
170 | aux.Id = (int)datos.Lector["Id"];
171 | aux.Numero = datos.Lector.GetInt32(0);
172 | aux.Nombre = (string)datos.Lector["Nombre"];
173 | aux.Descripcion = (string)datos.Lector["Descripcion"];
174 | if (!(datos.Lector["UrlImagen"] is DBNull))
175 | aux.UrlImagen = (string)datos.Lector["UrlImagen"];
176 |
177 | aux.Tipo = new Elemento();
178 | aux.Tipo.Id = (int)datos.Lector["IdTipo"];
179 | aux.Tipo.Descripcion = (string)datos.Lector["Tipo"];
180 | aux.Debilidad = new Elemento();
181 | aux.Debilidad.Id = (int)datos.Lector["IdDebilidad"];
182 | aux.Debilidad.Descripcion = (string)datos.Lector["Debilidad"];
183 |
184 | lista.Add(aux);
185 | }
186 |
187 | return lista;
188 | }
189 | catch (Exception ex)
190 | {
191 | throw ex;
192 | }
193 | }
194 |
195 | public void eliminar(int id)
196 | {
197 | try
198 | {
199 | AccesoDatos datos = new AccesoDatos();
200 | datos.setearConsulta("delete from pokemons where id = @id");
201 | datos.setearParametro("@id",id);
202 | datos.ejecutarAccion();
203 |
204 | }
205 | catch (Exception ex)
206 | {
207 | throw ex;
208 | }
209 | }
210 |
211 | public void eliminarLogico(int id)
212 | {
213 | try
214 | {
215 | AccesoDatos datos = new AccesoDatos();
216 | datos.setearConsulta("update POKEMONS set Activo = 0 Where id = @id");
217 | datos.setearParametro("@id", id);
218 | datos.ejecutarAccion();
219 | }
220 | catch (Exception ex)
221 | {
222 | throw ex;
223 | }
224 | }
225 |
226 |
227 | }
228 | }
229 |
--------------------------------------------------------------------------------
/negocio/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("negocio")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("negocio")]
13 | [assembly: AssemblyCopyright("Copyright © 2021")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("974d539c-098c-4e52-89fb-7b433f91dc0c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/negocio/negocio.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {974D539C-098C-4E52-89FB-7B433F91DC0C}
8 | Library
9 | Properties
10 | negocio
11 | negocio
12 | v4.8
13 | 512
14 | true
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | {1123f810-ef66-4379-8221-7d0bfe96c701}
54 | dominio
55 |
56 |
57 |
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/negocio/script_db/POKEDEX_DB.sql:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/msarfernandez/ejemplos-ado-net/1e5edd38eeb6c6f2724b78719e7054d6681a08bb/negocio/script_db/POKEDEX_DB.sql
--------------------------------------------------------------------------------
/winform-app/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/winform-app/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace winform_app
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// The main entry point for the application.
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new frmPokemons());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/winform-app/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("winform-app")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("winform-app")]
13 | [assembly: AssemblyCopyright("Copyright © 2021")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("1c5b0226-704a-46a3-982d-400cce1bbc1e")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/winform-app/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 |
12 | namespace winform_app.Properties
13 | {
14 | ///
15 | /// A strongly-typed resource class, for looking up localized strings, etc.
16 | ///
17 | // This class was auto-generated by the StronglyTypedResourceBuilder
18 | // class via a tool like ResGen or Visual Studio.
19 | // To add or remove a member, edit your .ResX file then rerun ResGen
20 | // with the /str option, or rebuild your VS project.
21 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
22 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
23 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
24 | internal class Resources
25 | {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources()
33 | {
34 | }
35 |
36 | ///
37 | /// Returns the cached ResourceManager instance used by this class.
38 | ///
39 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
40 | internal static global::System.Resources.ResourceManager ResourceManager
41 | {
42 | get
43 | {
44 | if ((resourceMan == null))
45 | {
46 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("winform_app.Properties.Resources", typeof(Resources).Assembly);
47 | resourceMan = temp;
48 | }
49 | return resourceMan;
50 | }
51 | }
52 |
53 | ///
54 | /// Overrides the current thread's CurrentUICulture property for all
55 | /// resource lookups using this strongly typed resource class.
56 | ///
57 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
58 | internal static global::System.Globalization.CultureInfo Culture
59 | {
60 | get
61 | {
62 | return resourceCulture;
63 | }
64 | set
65 | {
66 | resourceCulture = value;
67 | }
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/winform-app/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/winform-app/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 |
12 | namespace winform_app.Properties
13 | {
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
17 | {
18 |
19 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
20 |
21 | public static Settings Default
22 | {
23 | get
24 | {
25 | return defaultInstance;
26 | }
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/winform-app/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/winform-app/frmAltaPokemon.Designer.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace winform_app
3 | {
4 | partial class frmAltaPokemon
5 | {
6 | ///
7 | /// Required designer variable.
8 | ///
9 | private System.ComponentModel.IContainer components = null;
10 |
11 | ///
12 | /// Clean up any resources being used.
13 | ///
14 | /// true if managed resources should be disposed; otherwise, false.
15 | protected override void Dispose(bool disposing)
16 | {
17 | if (disposing && (components != null))
18 | {
19 | components.Dispose();
20 | }
21 | base.Dispose(disposing);
22 | }
23 |
24 | #region Windows Form Designer generated code
25 |
26 | ///
27 | /// Required method for Designer support - do not modify
28 | /// the contents of this method with the code editor.
29 | ///
30 | private void InitializeComponent()
31 | {
32 | this.label1 = new System.Windows.Forms.Label();
33 | this.label2 = new System.Windows.Forms.Label();
34 | this.label3 = new System.Windows.Forms.Label();
35 | this.txtNumero = new System.Windows.Forms.TextBox();
36 | this.txtNombre = new System.Windows.Forms.TextBox();
37 | this.txtDescripcion = new System.Windows.Forms.TextBox();
38 | this.btnAceptar = new System.Windows.Forms.Button();
39 | this.btnCancelar = new System.Windows.Forms.Button();
40 | this.lblTipo = new System.Windows.Forms.Label();
41 | this.lblDebilidad = new System.Windows.Forms.Label();
42 | this.cboTipo = new System.Windows.Forms.ComboBox();
43 | this.cboDebilidad = new System.Windows.Forms.ComboBox();
44 | this.txtUrlImagen = new System.Windows.Forms.TextBox();
45 | this.lblUrlImagen = new System.Windows.Forms.Label();
46 | this.pbxPokemon = new System.Windows.Forms.PictureBox();
47 | this.btnAgregarImagen = new System.Windows.Forms.Button();
48 | ((System.ComponentModel.ISupportInitialize)(this.pbxPokemon)).BeginInit();
49 | this.SuspendLayout();
50 | //
51 | // label1
52 | //
53 | this.label1.AutoSize = true;
54 | this.label1.Location = new System.Drawing.Point(80, 36);
55 | this.label1.Name = "label1";
56 | this.label1.Size = new System.Drawing.Size(47, 13);
57 | this.label1.TabIndex = 0;
58 | this.label1.Text = "Número:";
59 | //
60 | // label2
61 | //
62 | this.label2.AutoSize = true;
63 | this.label2.Location = new System.Drawing.Point(77, 62);
64 | this.label2.Name = "label2";
65 | this.label2.Size = new System.Drawing.Size(50, 13);
66 | this.label2.TabIndex = 1;
67 | this.label2.Text = "Nombre: ";
68 | //
69 | // label3
70 | //
71 | this.label3.AutoSize = true;
72 | this.label3.Location = new System.Drawing.Point(61, 88);
73 | this.label3.Name = "label3";
74 | this.label3.Size = new System.Drawing.Size(66, 13);
75 | this.label3.TabIndex = 2;
76 | this.label3.Text = "Descripción:";
77 | //
78 | // txtNumero
79 | //
80 | this.txtNumero.Location = new System.Drawing.Point(133, 33);
81 | this.txtNumero.Name = "txtNumero";
82 | this.txtNumero.Size = new System.Drawing.Size(121, 20);
83 | this.txtNumero.TabIndex = 0;
84 | //
85 | // txtNombre
86 | //
87 | this.txtNombre.Location = new System.Drawing.Point(133, 59);
88 | this.txtNombre.Name = "txtNombre";
89 | this.txtNombre.Size = new System.Drawing.Size(121, 20);
90 | this.txtNombre.TabIndex = 1;
91 | //
92 | // txtDescripcion
93 | //
94 | this.txtDescripcion.Location = new System.Drawing.Point(133, 85);
95 | this.txtDescripcion.Name = "txtDescripcion";
96 | this.txtDescripcion.Size = new System.Drawing.Size(121, 20);
97 | this.txtDescripcion.TabIndex = 2;
98 | //
99 | // btnAceptar
100 | //
101 | this.btnAceptar.Location = new System.Drawing.Point(61, 205);
102 | this.btnAceptar.Name = "btnAceptar";
103 | this.btnAceptar.Size = new System.Drawing.Size(75, 23);
104 | this.btnAceptar.TabIndex = 6;
105 | this.btnAceptar.Text = "Aceptar";
106 | this.btnAceptar.UseVisualStyleBackColor = true;
107 | this.btnAceptar.Click += new System.EventHandler(this.btnAceptar_Click);
108 | //
109 | // btnCancelar
110 | //
111 | this.btnCancelar.Location = new System.Drawing.Point(179, 205);
112 | this.btnCancelar.Name = "btnCancelar";
113 | this.btnCancelar.Size = new System.Drawing.Size(75, 23);
114 | this.btnCancelar.TabIndex = 7;
115 | this.btnCancelar.Text = "Cancelar";
116 | this.btnCancelar.UseVisualStyleBackColor = true;
117 | this.btnCancelar.Click += new System.EventHandler(this.btnCancelar_Click);
118 | //
119 | // lblTipo
120 | //
121 | this.lblTipo.AutoSize = true;
122 | this.lblTipo.Location = new System.Drawing.Point(96, 140);
123 | this.lblTipo.Name = "lblTipo";
124 | this.lblTipo.Size = new System.Drawing.Size(31, 13);
125 | this.lblTipo.TabIndex = 8;
126 | this.lblTipo.Text = "Tipo:";
127 | //
128 | // lblDebilidad
129 | //
130 | this.lblDebilidad.AutoSize = true;
131 | this.lblDebilidad.Location = new System.Drawing.Point(73, 167);
132 | this.lblDebilidad.Name = "lblDebilidad";
133 | this.lblDebilidad.Size = new System.Drawing.Size(54, 13);
134 | this.lblDebilidad.TabIndex = 9;
135 | this.lblDebilidad.Text = "Debilidad:";
136 | //
137 | // cboTipo
138 | //
139 | this.cboTipo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
140 | this.cboTipo.FormattingEnabled = true;
141 | this.cboTipo.Location = new System.Drawing.Point(133, 137);
142 | this.cboTipo.Name = "cboTipo";
143 | this.cboTipo.Size = new System.Drawing.Size(121, 21);
144 | this.cboTipo.TabIndex = 4;
145 | //
146 | // cboDebilidad
147 | //
148 | this.cboDebilidad.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
149 | this.cboDebilidad.FormattingEnabled = true;
150 | this.cboDebilidad.Location = new System.Drawing.Point(133, 164);
151 | this.cboDebilidad.Name = "cboDebilidad";
152 | this.cboDebilidad.Size = new System.Drawing.Size(121, 21);
153 | this.cboDebilidad.TabIndex = 5;
154 | //
155 | // txtUrlImagen
156 | //
157 | this.txtUrlImagen.Location = new System.Drawing.Point(133, 111);
158 | this.txtUrlImagen.Name = "txtUrlImagen";
159 | this.txtUrlImagen.Size = new System.Drawing.Size(121, 20);
160 | this.txtUrlImagen.TabIndex = 3;
161 | this.txtUrlImagen.Leave += new System.EventHandler(this.txtUrlImagen_Leave);
162 | //
163 | // lblUrlImagen
164 | //
165 | this.lblUrlImagen.AutoSize = true;
166 | this.lblUrlImagen.Location = new System.Drawing.Point(63, 114);
167 | this.lblUrlImagen.Name = "lblUrlImagen";
168 | this.lblUrlImagen.Size = new System.Drawing.Size(61, 13);
169 | this.lblUrlImagen.TabIndex = 12;
170 | this.lblUrlImagen.Text = "Url Imagen:";
171 | //
172 | // pbxPokemon
173 | //
174 | this.pbxPokemon.Location = new System.Drawing.Point(305, 33);
175 | this.pbxPokemon.Name = "pbxPokemon";
176 | this.pbxPokemon.Size = new System.Drawing.Size(217, 195);
177 | this.pbxPokemon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
178 | this.pbxPokemon.TabIndex = 14;
179 | this.pbxPokemon.TabStop = false;
180 | //
181 | // btnAgregarImagen
182 | //
183 | this.btnAgregarImagen.Location = new System.Drawing.Point(260, 111);
184 | this.btnAgregarImagen.Name = "btnAgregarImagen";
185 | this.btnAgregarImagen.Size = new System.Drawing.Size(27, 23);
186 | this.btnAgregarImagen.TabIndex = 15;
187 | this.btnAgregarImagen.Text = "+";
188 | this.btnAgregarImagen.UseVisualStyleBackColor = true;
189 | this.btnAgregarImagen.Click += new System.EventHandler(this.btnAgregarImagen_Click);
190 | //
191 | // frmAltaPokemon
192 | //
193 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
194 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
195 | this.ClientSize = new System.Drawing.Size(554, 275);
196 | this.Controls.Add(this.btnAgregarImagen);
197 | this.Controls.Add(this.pbxPokemon);
198 | this.Controls.Add(this.txtUrlImagen);
199 | this.Controls.Add(this.lblUrlImagen);
200 | this.Controls.Add(this.cboDebilidad);
201 | this.Controls.Add(this.cboTipo);
202 | this.Controls.Add(this.lblDebilidad);
203 | this.Controls.Add(this.lblTipo);
204 | this.Controls.Add(this.btnCancelar);
205 | this.Controls.Add(this.btnAceptar);
206 | this.Controls.Add(this.txtDescripcion);
207 | this.Controls.Add(this.txtNombre);
208 | this.Controls.Add(this.txtNumero);
209 | this.Controls.Add(this.label3);
210 | this.Controls.Add(this.label2);
211 | this.Controls.Add(this.label1);
212 | this.Name = "frmAltaPokemon";
213 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
214 | this.Text = "Nuevo Pokemon";
215 | this.Load += new System.EventHandler(this.frmAltaPokemon_Load);
216 | ((System.ComponentModel.ISupportInitialize)(this.pbxPokemon)).EndInit();
217 | this.ResumeLayout(false);
218 | this.PerformLayout();
219 |
220 | }
221 |
222 | #endregion
223 |
224 | private System.Windows.Forms.Label label1;
225 | private System.Windows.Forms.Label label2;
226 | private System.Windows.Forms.Label label3;
227 | private System.Windows.Forms.TextBox txtNumero;
228 | private System.Windows.Forms.TextBox txtNombre;
229 | private System.Windows.Forms.TextBox txtDescripcion;
230 | private System.Windows.Forms.Button btnAceptar;
231 | private System.Windows.Forms.Button btnCancelar;
232 | private System.Windows.Forms.Label lblTipo;
233 | private System.Windows.Forms.Label lblDebilidad;
234 | private System.Windows.Forms.ComboBox cboTipo;
235 | private System.Windows.Forms.ComboBox cboDebilidad;
236 | private System.Windows.Forms.TextBox txtUrlImagen;
237 | private System.Windows.Forms.Label lblUrlImagen;
238 | private System.Windows.Forms.PictureBox pbxPokemon;
239 | private System.Windows.Forms.Button btnAgregarImagen;
240 | }
241 | }
--------------------------------------------------------------------------------
/winform-app/frmAltaPokemon.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.IO;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Forms;
11 | using dominio;
12 | using negocio;
13 | using System.Configuration;
14 |
15 | namespace winform_app
16 | {
17 | public partial class frmAltaPokemon : Form
18 | {
19 | private Pokemon pokemon = null;
20 | private OpenFileDialog archivo = null;
21 |
22 | public frmAltaPokemon()
23 | {
24 | InitializeComponent();
25 | }
26 | public frmAltaPokemon(Pokemon pokemon)
27 | {
28 | InitializeComponent();
29 | this.pokemon = pokemon;
30 | Text = "Modificar Pokemon";
31 | }
32 |
33 | private void btnCancelar_Click(object sender, EventArgs e)
34 | {
35 | Close();
36 | }
37 |
38 | private void btnAceptar_Click(object sender, EventArgs e)
39 | {
40 | PokemonNegocio negocio = new PokemonNegocio();
41 | try
42 | {
43 | if (pokemon == null)
44 | pokemon = new Pokemon();
45 |
46 | pokemon.Numero = int.Parse(txtNumero.Text);
47 | pokemon.Nombre = txtNombre.Text;
48 | pokemon.Descripcion = txtDescripcion.Text;
49 | pokemon.UrlImagen = txtUrlImagen.Text;
50 | pokemon.Tipo = (Elemento)cboTipo.SelectedItem;
51 | pokemon.Debilidad = (Elemento)cboDebilidad.SelectedItem;
52 |
53 | if(pokemon.Id != 0)
54 | {
55 | negocio.modificar(pokemon);
56 | MessageBox.Show("Modificado exitosamente");
57 | }
58 | else
59 | {
60 | negocio.agregar(pokemon);
61 | MessageBox.Show("Agregado exitosamente");
62 | }
63 |
64 | //Guardo imagen si la levantó localmente:
65 | if(archivo != null && !(txtUrlImagen.Text.ToUpper().Contains("HTTP")))
66 | File.Copy(archivo.FileName, ConfigurationManager.AppSettings["images-folder"] + archivo.SafeFileName);
67 |
68 | Close();
69 |
70 | }
71 | catch (Exception ex)
72 | {
73 | MessageBox.Show(ex.ToString());
74 | }
75 | }
76 |
77 | private void frmAltaPokemon_Load(object sender, EventArgs e)
78 | {
79 | ElementoNegocio elementoNegocio = new ElementoNegocio();
80 | try
81 | {
82 | cboTipo.DataSource = elementoNegocio.listar();
83 | cboTipo.ValueMember = "Id";
84 | cboTipo.DisplayMember = "Descripcion";
85 | cboDebilidad.DataSource = elementoNegocio.listar();
86 | cboDebilidad.ValueMember = "Id";
87 | cboDebilidad.DisplayMember = "Descripcion";
88 |
89 | if(pokemon != null)
90 | {
91 | txtNumero.Text = pokemon.Numero.ToString();
92 | txtNombre.Text = pokemon.Nombre;
93 | txtDescripcion.Text = pokemon.Descripcion;
94 | txtUrlImagen.Text = pokemon.UrlImagen;
95 | cargarImagen(pokemon.UrlImagen);
96 | cboTipo.SelectedValue = pokemon.Tipo.Id;
97 | cboDebilidad.SelectedValue = pokemon.Debilidad.Id;
98 | }
99 | }
100 | catch (Exception ex)
101 | {
102 | MessageBox.Show(ex.ToString());
103 | }
104 | }
105 |
106 | private void txtUrlImagen_Leave(object sender, EventArgs e)
107 | {
108 | cargarImagen(txtUrlImagen.Text);
109 | }
110 |
111 | private void cargarImagen(string imagen)
112 | {
113 | try
114 | {
115 | pbxPokemon.Load(imagen);
116 | }
117 | catch (Exception ex)
118 | {
119 | pbxPokemon.Load("https://efectocolibri.com/wp-content/uploads/2021/01/placeholder.png");
120 | }
121 | }
122 |
123 | private void btnAgregarImagen_Click(object sender, EventArgs e)
124 | {
125 | archivo = new OpenFileDialog();
126 | archivo.Filter = "jpg|*.jpg;|png|*.png";
127 | if(archivo.ShowDialog() == DialogResult.OK)
128 | {
129 | txtUrlImagen.Text = archivo.FileName;
130 | cargarImagen(archivo.FileName);
131 |
132 | //guardo la imagen
133 | //File.Copy(archivo.FileName, ConfigurationManager.AppSettings["images-folder"] + archivo.SafeFileName);
134 | }
135 |
136 | }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/winform-app/frmAltaPokemon.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/winform-app/frmPokemons.Designer.cs:
--------------------------------------------------------------------------------
1 |
2 | namespace winform_app
3 | {
4 | partial class frmPokemons
5 | {
6 | ///
7 | /// Required designer variable.
8 | ///
9 | private System.ComponentModel.IContainer components = null;
10 |
11 | ///
12 | /// Clean up any resources being used.
13 | ///
14 | /// true if managed resources should be disposed; otherwise, false.
15 | protected override void Dispose(bool disposing)
16 | {
17 | if (disposing && (components != null))
18 | {
19 | components.Dispose();
20 | }
21 | base.Dispose(disposing);
22 | }
23 |
24 | #region Windows Form Designer generated code
25 |
26 | ///
27 | /// Required method for Designer support - do not modify
28 | /// the contents of this method with the code editor.
29 | ///
30 | private void InitializeComponent()
31 | {
32 | this.dgvPokemons = new System.Windows.Forms.DataGridView();
33 | this.pbxPokemon = new System.Windows.Forms.PictureBox();
34 | this.btnAgregar = new System.Windows.Forms.Button();
35 | this.btnModificar = new System.Windows.Forms.Button();
36 | this.btnEliminarFisico = new System.Windows.Forms.Button();
37 | this.btnEliminarLogico = new System.Windows.Forms.Button();
38 |
39 | this.lblFiltro = new System.Windows.Forms.Label();
40 | this.txtFiltro = new System.Windows.Forms.TextBox();
41 | this.btnFiltro = new System.Windows.Forms.Button();
42 | this.lblCampo = new System.Windows.Forms.Label();
43 | this.cboCampo = new System.Windows.Forms.ComboBox();
44 | this.lblCriterio = new System.Windows.Forms.Label();
45 | this.cboCriterio = new System.Windows.Forms.ComboBox();
46 | this.lblFiltroAvanzado = new System.Windows.Forms.Label();
47 | this.txtFiltroAvanzado = new System.Windows.Forms.TextBox();
48 |
49 | ((System.ComponentModel.ISupportInitialize)(this.dgvPokemons)).BeginInit();
50 | ((System.ComponentModel.ISupportInitialize)(this.pbxPokemon)).BeginInit();
51 | this.SuspendLayout();
52 | //
53 | // dgvPokemons
54 | //
55 | this.dgvPokemons.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
56 | this.dgvPokemons.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
57 | this.dgvPokemons.Location = new System.Drawing.Point(12, 55);
58 | this.dgvPokemons.MultiSelect = false;
59 | this.dgvPokemons.Name = "dgvPokemons";
60 | this.dgvPokemons.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
61 | this.dgvPokemons.Size = new System.Drawing.Size(610, 232);
62 | this.dgvPokemons.TabIndex = 0;
63 | this.dgvPokemons.SelectionChanged += new System.EventHandler(this.dgvPokemons_SelectionChanged);
64 | //
65 | // pbxPokemon
66 | //
67 | this.pbxPokemon.Location = new System.Drawing.Point(628, 55);
68 | this.pbxPokemon.Name = "pbxPokemon";
69 | this.pbxPokemon.Size = new System.Drawing.Size(240, 232);
70 | this.pbxPokemon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
71 | this.pbxPokemon.TabIndex = 1;
72 | this.pbxPokemon.TabStop = false;
73 | //
74 | // btnAgregar
75 | //
76 | this.btnAgregar.Location = new System.Drawing.Point(12, 293);
77 | this.btnAgregar.Name = "btnAgregar";
78 | this.btnAgregar.Size = new System.Drawing.Size(75, 23);
79 | this.btnAgregar.TabIndex = 2;
80 | this.btnAgregar.Text = "Agregar";
81 | this.btnAgregar.UseVisualStyleBackColor = true;
82 | this.btnAgregar.Click += new System.EventHandler(this.btnAgregar_Click);
83 | //
84 | // btnModificar
85 | //
86 | this.btnModificar.Location = new System.Drawing.Point(93, 293);
87 | this.btnModificar.Name = "btnModificar";
88 | this.btnModificar.Size = new System.Drawing.Size(75, 23);
89 | this.btnModificar.TabIndex = 3;
90 | this.btnModificar.Text = "Modificar";
91 | this.btnModificar.UseVisualStyleBackColor = true;
92 | this.btnModificar.Click += new System.EventHandler(this.btnModificar_Click);
93 | //
94 | // btnEliminarFisico
95 | //
96 | this.btnEliminarFisico.Location = new System.Drawing.Point(174, 293);
97 | this.btnEliminarFisico.Name = "btnEliminarFisico";
98 | this.btnEliminarFisico.Size = new System.Drawing.Size(104, 23);
99 | this.btnEliminarFisico.TabIndex = 4;
100 | this.btnEliminarFisico.Text = "Eliminar Físico";
101 | this.btnEliminarFisico.UseVisualStyleBackColor = true;
102 | this.btnEliminarFisico.Click += new System.EventHandler(this.btnEliminarFisico_Click);
103 | //
104 | // btnEliminarLogico
105 | //
106 | this.btnEliminarLogico.Location = new System.Drawing.Point(284, 293);
107 | this.btnEliminarLogico.Name = "btnEliminarLogico";
108 | this.btnEliminarLogico.Size = new System.Drawing.Size(104, 23);
109 | this.btnEliminarLogico.TabIndex = 5;
110 | this.btnEliminarLogico.Text = "Eliminar Lógico";
111 | this.btnEliminarLogico.UseVisualStyleBackColor = true;
112 | this.btnEliminarLogico.Click += new System.EventHandler(this.btnEliminarLogico_Click);
113 | //
114 | // lblFiltro
115 | //
116 | this.lblFiltro.AutoSize = true;
117 | this.lblFiltro.Location = new System.Drawing.Point(12, 32);
118 | this.lblFiltro.Name = "lblFiltro";
119 | this.lblFiltro.Size = new System.Drawing.Size(69, 13);
120 | this.lblFiltro.TabIndex = 6;
121 | this.lblFiltro.Text = "Filtro Rápido:";
122 | //
123 | // txtFiltro
124 | //
125 | this.txtFiltro.Location = new System.Drawing.Point(87, 29);
126 | this.txtFiltro.Name = "txtFiltro";
127 | this.txtFiltro.Size = new System.Drawing.Size(185, 20);
128 | this.txtFiltro.TabIndex = 7;
129 | this.txtFiltro.TextChanged += new System.EventHandler(this.txtFiltro_TextChanged);
130 | this.txtFiltro.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtFiltro_KeyPress);
131 | //
132 | // btnFiltro
133 | //
134 | this.btnFiltro.Location = new System.Drawing.Point(579, 337);
135 | this.btnFiltro.Name = "btnFiltro";
136 | this.btnFiltro.Size = new System.Drawing.Size(75, 23);
137 | this.btnFiltro.TabIndex = 8;
138 | this.btnFiltro.Text = "Buscar";
139 | this.btnFiltro.UseVisualStyleBackColor = true;
140 | this.btnFiltro.Click += new System.EventHandler(this.btnFiltro_Click);
141 | //
142 | // lblCampo
143 | //
144 | this.lblCampo.AutoSize = true;
145 | this.lblCampo.Location = new System.Drawing.Point(11, 343);
146 | this.lblCampo.Name = "lblCampo";
147 | this.lblCampo.Size = new System.Drawing.Size(43, 13);
148 | this.lblCampo.TabIndex = 9;
149 | this.lblCampo.Text = "Campo:";
150 | //
151 | // cboCampo
152 | //
153 | this.cboCampo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
154 | this.cboCampo.FormattingEnabled = true;
155 | this.cboCampo.Location = new System.Drawing.Point(67, 339);
156 | this.cboCampo.Name = "cboCampo";
157 | this.cboCampo.Size = new System.Drawing.Size(121, 21);
158 | this.cboCampo.TabIndex = 10;
159 | this.cboCampo.SelectedIndexChanged += new System.EventHandler(this.cboCampo_SelectedIndexChanged);
160 | //
161 | // lblCriterio
162 | //
163 | this.lblCriterio.AutoSize = true;
164 | this.lblCriterio.Location = new System.Drawing.Point(207, 343);
165 | this.lblCriterio.Name = "lblCriterio";
166 | this.lblCriterio.Size = new System.Drawing.Size(42, 13);
167 | this.lblCriterio.TabIndex = 11;
168 | this.lblCriterio.Text = "Criterio:";
169 | //
170 | // cboCriterio
171 | //
172 | this.cboCriterio.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
173 | this.cboCriterio.FormattingEnabled = true;
174 | this.cboCriterio.Location = new System.Drawing.Point(263, 339);
175 | this.cboCriterio.Name = "cboCriterio";
176 | this.cboCriterio.Size = new System.Drawing.Size(121, 21);
177 | this.cboCriterio.TabIndex = 12;
178 | //
179 | // lblFiltroAvanzado
180 | //
181 | this.lblFiltroAvanzado.AutoSize = true;
182 | this.lblFiltroAvanzado.Location = new System.Drawing.Point(403, 343);
183 | this.lblFiltroAvanzado.Name = "lblFiltroAvanzado";
184 | this.lblFiltroAvanzado.Size = new System.Drawing.Size(29, 13);
185 | this.lblFiltroAvanzado.TabIndex = 13;
186 | this.lblFiltroAvanzado.Text = "Filtro";
187 | //
188 | // txtFiltroAvanzado
189 | //
190 | this.txtFiltroAvanzado.Location = new System.Drawing.Point(459, 340);
191 | this.txtFiltroAvanzado.Name = "txtFiltroAvanzado";
192 | this.txtFiltroAvanzado.Size = new System.Drawing.Size(100, 20);
193 | this.txtFiltroAvanzado.TabIndex = 14;
194 |
195 | //
196 | // frmPokemons
197 | //
198 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
199 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
200 | this.ClientSize = new System.Drawing.Size(880, 384);
201 | this.Controls.Add(this.txtFiltroAvanzado);
202 | this.Controls.Add(this.lblFiltroAvanzado);
203 | this.Controls.Add(this.cboCriterio);
204 | this.Controls.Add(this.lblCriterio);
205 | this.Controls.Add(this.cboCampo);
206 | this.Controls.Add(this.lblCampo);
207 | this.Controls.Add(this.btnFiltro);
208 | this.Controls.Add(this.txtFiltro);
209 | this.Controls.Add(this.lblFiltro);
210 |
211 | this.Controls.Add(this.btnEliminarLogico);
212 | this.Controls.Add(this.btnEliminarFisico);
213 | this.Controls.Add(this.btnModificar);
214 | this.Controls.Add(this.btnAgregar);
215 | this.Controls.Add(this.pbxPokemon);
216 | this.Controls.Add(this.dgvPokemons);
217 | this.Name = "frmPokemons";
218 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
219 | this.Text = "Pokemons";
220 | this.Load += new System.EventHandler(this.frmPokemons_Load);
221 | ((System.ComponentModel.ISupportInitialize)(this.dgvPokemons)).EndInit();
222 | ((System.ComponentModel.ISupportInitialize)(this.pbxPokemon)).EndInit();
223 | this.ResumeLayout(false);
224 | this.PerformLayout();
225 |
226 | }
227 |
228 | #endregion
229 |
230 | private System.Windows.Forms.DataGridView dgvPokemons;
231 | private System.Windows.Forms.PictureBox pbxPokemon;
232 | private System.Windows.Forms.Button btnAgregar;
233 | private System.Windows.Forms.Button btnModificar;
234 | private System.Windows.Forms.Button btnEliminarFisico;
235 | private System.Windows.Forms.Button btnEliminarLogico;
236 | private System.Windows.Forms.Label lblFiltro;
237 | private System.Windows.Forms.TextBox txtFiltro;
238 | private System.Windows.Forms.Button btnFiltro;
239 | private System.Windows.Forms.Label lblCampo;
240 | private System.Windows.Forms.ComboBox cboCampo;
241 | private System.Windows.Forms.Label lblCriterio;
242 | private System.Windows.Forms.ComboBox cboCriterio;
243 | private System.Windows.Forms.Label lblFiltroAvanzado;
244 | private System.Windows.Forms.TextBox txtFiltroAvanzado;
245 |
246 | }
247 | }
248 |
249 |
--------------------------------------------------------------------------------
/winform-app/frmPokemons.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using dominio;
11 | using negocio;
12 |
13 | namespace winform_app
14 | {
15 | public partial class frmPokemons : Form
16 | {
17 | private List listaPokemon;
18 | public frmPokemons()
19 | {
20 | InitializeComponent();
21 | }
22 |
23 | private void frmPokemons_Load(object sender, EventArgs e)
24 | {
25 | cargar();
26 | cboCampo.Items.Add("Número");
27 | cboCampo.Items.Add("Nombre");
28 | cboCampo.Items.Add("Descripción");
29 |
30 | }
31 |
32 | private void dgvPokemons_SelectionChanged(object sender, EventArgs e)
33 | {
34 | if(dgvPokemons.CurrentRow != null)
35 | {
36 | Pokemon seleccionado = (Pokemon)dgvPokemons.CurrentRow.DataBoundItem;
37 | cargarImagen(seleccionado.UrlImagen);
38 | }
39 |
40 | }
41 |
42 | private void cargar()
43 | {
44 | PokemonNegocio negocio = new PokemonNegocio();
45 | try
46 | {
47 | listaPokemon = negocio.listar();
48 | dgvPokemons.DataSource = listaPokemon;
49 | ocultarColumnas();
50 | cargarImagen(listaPokemon[0].UrlImagen);
51 | }
52 | catch (Exception ex)
53 | {
54 | MessageBox.Show(ex.ToString());
55 | }
56 | }
57 |
58 | private void ocultarColumnas()
59 | {
60 | dgvPokemons.Columns["UrlImagen"].Visible = false;
61 | dgvPokemons.Columns["Id"].Visible = false;
62 | }
63 |
64 | private void cargarImagen(string imagen)
65 | {
66 | try
67 | {
68 | pbxPokemon.Load(imagen);
69 | }
70 | catch (Exception ex)
71 | {
72 | pbxPokemon.Load("https://efectocolibri.com/wp-content/uploads/2021/01/placeholder.png");
73 | }
74 | }
75 |
76 | private void btnAgregar_Click(object sender, EventArgs e)
77 | {
78 | frmAltaPokemon alta = new frmAltaPokemon();
79 | alta.ShowDialog();
80 | cargar();
81 | }
82 |
83 | private void btnModificar_Click(object sender, EventArgs e)
84 | {
85 | Pokemon seleccionado;
86 | seleccionado = (Pokemon)dgvPokemons.CurrentRow.DataBoundItem;
87 |
88 | frmAltaPokemon modificar = new frmAltaPokemon(seleccionado);
89 | modificar.ShowDialog();
90 | cargar();
91 | }
92 |
93 | private void btnEliminarFisico_Click(object sender, EventArgs e)
94 | {
95 | eliminar();
96 | }
97 |
98 | private void btnEliminarLogico_Click(object sender, EventArgs e)
99 | {
100 | eliminar(true);
101 | }
102 |
103 | private void eliminar(bool logico = false)
104 | {
105 | PokemonNegocio negocio = new PokemonNegocio();
106 | Pokemon seleccionado;
107 | try
108 | {
109 | DialogResult respuesta = MessageBox.Show("¿De verdad querés eliminarlo?", "Eliminando", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
110 | if (respuesta == DialogResult.Yes)
111 | {
112 | seleccionado = (Pokemon)dgvPokemons.CurrentRow.DataBoundItem;
113 |
114 | if (logico)
115 | negocio.eliminarLogico(seleccionado.Id);
116 | else
117 | negocio.eliminar(seleccionado.Id);
118 |
119 | cargar();
120 | }
121 | }
122 | catch (Exception ex)
123 | {
124 | MessageBox.Show(ex.ToString());
125 | }
126 | }
127 |
128 | private bool validarFiltro()
129 | {
130 | if(cboCampo.SelectedIndex < 0)
131 | {
132 | MessageBox.Show("Por favor, seleccione el campo para filtrar.");
133 | return true;
134 | }
135 | if(cboCriterio.SelectedIndex < 0)
136 | {
137 | MessageBox.Show("Por favor, seleccione el criterio para filtrar.");
138 | return true;
139 | }
140 | if (cboCampo.SelectedItem.ToString() == "Número")
141 | {
142 | if (string.IsNullOrEmpty(txtFiltroAvanzado.Text))
143 | {
144 | MessageBox.Show("Debes cargar el filtro para numéricos...");
145 | return true;
146 | }
147 | if (!(soloNumeros(txtFiltroAvanzado.Text)))
148 | {
149 | MessageBox.Show("Solo nros para filtrar por un campo numérico...");
150 | return true;
151 | }
152 |
153 | }
154 |
155 | return false;
156 | }
157 |
158 | private bool soloNumeros(string cadena)
159 | {
160 | foreach (char caracter in cadena)
161 | {
162 | if (!(char.IsNumber(caracter)))
163 | return false;
164 | }
165 | return true;
166 | }
167 |
168 | private void btnFiltro_Click(object sender, EventArgs e)
169 | {
170 | PokemonNegocio negocio = new PokemonNegocio();
171 | try
172 | {
173 | if (validarFiltro())
174 | return;
175 |
176 | string campo = cboCampo.SelectedItem.ToString();
177 | string criterio = cboCriterio.SelectedItem.ToString();
178 | string filtro = txtFiltroAvanzado.Text;
179 | dgvPokemons.DataSource = negocio.filtrar(campo, criterio, filtro);
180 |
181 | }
182 | catch (Exception ex)
183 | {
184 | MessageBox.Show(ex.ToString());
185 | }
186 |
187 | }
188 |
189 | private void txtFiltro_KeyPress(object sender, KeyPressEventArgs e)
190 | {
191 |
192 | }
193 |
194 | private void txtFiltro_TextChanged(object sender, EventArgs e)
195 | {
196 | List listaFiltrada;
197 | string filtro = txtFiltro.Text;
198 |
199 | if (filtro.Length >= 3)
200 | {
201 | listaFiltrada = listaPokemon.FindAll(x => x.Nombre.ToUpper().Contains(filtro.ToUpper()) || x.Tipo.Descripcion.ToUpper().Contains(filtro.ToUpper()));
202 | }
203 | else
204 | {
205 | listaFiltrada = listaPokemon;
206 | }
207 |
208 | dgvPokemons.DataSource = null;
209 | dgvPokemons.DataSource = listaFiltrada;
210 | ocultarColumnas();
211 | }
212 |
213 | private void cboCampo_SelectedIndexChanged(object sender, EventArgs e)
214 | {
215 | string opcion = cboCampo.SelectedItem.ToString();
216 | if(opcion == "Número")
217 | {
218 | cboCriterio.Items.Clear();
219 | cboCriterio.Items.Add("Mayor a");
220 | cboCriterio.Items.Add("Menor a");
221 | cboCriterio.Items.Add("Igual a");
222 | }
223 | else
224 | {
225 | cboCriterio.Items.Clear();
226 | cboCriterio.Items.Add("Comienza con");
227 | cboCriterio.Items.Add("Termina con");
228 | cboCriterio.Items.Add("Contiene");
229 | }
230 |
231 | }
232 | }
233 | }
234 |
--------------------------------------------------------------------------------
/winform-app/frmPokemons.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
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 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/winform-app/winform-app.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {1C5B0226-704A-46A3-982D-400CCE1BBC1E}
8 | WinExe
9 | winform_app
10 | winform-app
11 | v4.8
12 | 512
13 | true
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | Form
52 |
53 |
54 | frmAltaPokemon.cs
55 |
56 |
57 | Form
58 |
59 |
60 | frmPokemons.cs
61 |
62 |
63 |
64 |
65 | frmAltaPokemon.cs
66 |
67 |
68 | frmPokemons.cs
69 |
70 |
71 | ResXFileCodeGenerator
72 | Resources.Designer.cs
73 | Designer
74 |
75 |
76 | True
77 | Resources.resx
78 |
79 |
80 | SettingsSingleFileGenerator
81 | Settings.Designer.cs
82 |
83 |
84 | True
85 | Settings.settings
86 | True
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 | {1123f810-ef66-4379-8221-7d0bfe96c701}
95 | dominio
96 |
97 |
98 | {974d539c-098c-4e52-89fb-7b433f91dc0c}
99 | negocio
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------