├── .gitignore ├── LICENSE ├── README.md ├── build.xml ├── manifest.mf ├── mysql-connector-java-8.0.28.jar ├── nbproject ├── build-impl.xml ├── genfiles.properties ├── project.properties └── project.xml ├── src ├── Controlador │ └── CtrlProducto.java ├── Modelo │ ├── Conexion.java │ ├── ConsultasProducto.java │ └── Producto.java ├── Recursos │ ├── add.png │ ├── clear.png │ ├── delete.png │ ├── edit.png │ ├── icon.png │ └── search.png ├── Vista │ ├── frmProducto.form │ └── frmProducto.java └── crudmvc │ └── CRUDMVC.java └── tienda.sql /.gitignore: -------------------------------------------------------------------------------- 1 | **/nbproject/private/ 2 | **/nbproject/Makefile-*.mk 3 | **/nbproject/Package-*.bash 4 | build/ 5 | nbbuild/ 6 | dist/ 7 | nbdist/ 8 | .nb-gradle/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Marco Robles 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CRUD MVC Java MySQL 2 | CRUD usando Java (JForm) con MVC y conectado a la base de datos (MySQL) 3 | 4 | ![imagen](https://user-images.githubusercontent.com/78062855/214745636-66a94376-e4c1-4a61-9aba-a7a9b06fcc7c.png) 5 | 6 | 7 | ## Requerimientos 📋 8 | - JDK 8.0 o superior 9 | - MySQL 5.7 o superior 10 | - [Connector/J 8.0](https://dev.mysql.com/downloads/connector/j/) 11 | 12 | *Desarrollado en Apache Netbeans* 13 | 14 | ## Instrucciones de uso 15 | 16 | 1. Descargar e importar el proyecto al IDE (Netbeans, Eclipse u otro). 17 | 2. Agregar a las bibliotecas del proyecto el conector de Java a MySQL. 18 | 3. Cargar la base de datos ```Tienda.sql``` a MySQL. 19 | 4. Editar las variables de conexión en la clase ```Conexion.java``` del paquete ```Modelo```, por los datos de acceso de MySQL 20 | 5. Compilar y ejecutar la aplicación. 21 | 22 | ## Autores ✒️ 23 | - **Marco Robles** - *Desarrollo* - [mroblesdev](https://github.com/mroblesdev) 24 | 25 | ## Licencia 📄 26 | 27 | Este proyecto está bajo la Licencia MIT License - mira el archivo [LICENSE](LICENSE) para más detalles. 28 | 29 | ## Expresiones de Gratitud 🎁 30 | 31 | * Comenta a otros sobre este proyecto 📢 32 | * Invita una cerveza 🍺 o un café ☕ [Da clic aquí](https://www.paypal.com/paypalme/markorobles?locale.x=es_XC.) 33 | * Da las gracias públicamente 🤓. 34 | -------------------------------------------------------------------------------- /build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Builds, tests, and runs the project CRUDMVC. 12 | 13 | 73 | 74 | -------------------------------------------------------------------------------- /manifest.mf: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | X-COMMENT: Main-Class will be added automatically by build 3 | 4 | -------------------------------------------------------------------------------- /mysql-connector-java-8.0.28.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mroblesdev/CRUD-MVC-Java-MySQL/1289cd985481e21b54646c43148d6d47aef88eee/mysql-connector-java-8.0.28.jar -------------------------------------------------------------------------------- /nbproject/build-impl.xml: -------------------------------------------------------------------------------- 1 | 2 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 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 | 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 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | Must set src.dir 292 | Must set test.src.dir 293 | Must set build.dir 294 | Must set dist.dir 295 | Must set build.classes.dir 296 | Must set dist.javadoc.dir 297 | Must set build.test.classes.dir 298 | Must set build.test.results.dir 299 | Must set build.classes.excludes 300 | Must set dist.jar 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | Must set javac.includes 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | 535 | 536 | 537 | 538 | 539 | 540 | 541 | 542 | 543 | 544 | 545 | 546 | 547 | 548 | 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | 560 | 561 | 562 | 563 | 564 | 565 | 566 | 567 | 568 | 569 | 570 | 571 | 572 | 573 | 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | No tests executed. 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | 681 | 682 | 683 | 684 | 685 | 686 | 687 | 688 | 689 | 690 | 691 | 692 | 693 | 694 | 695 | 696 | 697 | 698 | 699 | 700 | 701 | 702 | 703 | 704 | 705 | 706 | 707 | 708 | 709 | 710 | 711 | 712 | 713 | 714 | 715 | 716 | 717 | 718 | 719 | 720 | 721 | 722 | 723 | 724 | 725 | 726 | 727 | 728 | 729 | 730 | 731 | 732 | 733 | 734 | 735 | 736 | 737 | 738 | 739 | 740 | 741 | 742 | 743 | 744 | 745 | 746 | 747 | 748 | 749 | 750 | 751 | 752 | 753 | 754 | 755 | 756 | 757 | 758 | 759 | 760 | 761 | 762 | 763 | 764 | 765 | 766 | 767 | 768 | 769 | 770 | 771 | 772 | 773 | 774 | 775 | 776 | 777 | 778 | 779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 | 787 | 788 | 791 | 792 | 793 | 794 | 795 | 796 | 797 | 798 | 799 | 800 | 801 | 802 | 803 | 804 | 805 | 806 | 807 | 808 | 809 | 810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 | 821 | 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | 830 | 831 | 832 | 833 | Must set JVM to use for profiling in profiler.info.jvm 834 | Must set profiler agent JVM arguments in profiler.info.jvmargs.agent 835 | 836 | 839 | 840 | 841 | 842 | 843 | 844 | 845 | 846 | 847 | 848 | 849 | 850 | 851 | 852 | 853 | 854 | 855 | 856 | 857 | 858 | 859 | 860 | 861 | 862 | 863 | 864 | 865 | 866 | 867 | 868 | 869 | 870 | 871 | 872 | 873 | 874 | 875 | 876 | 877 | 878 | 879 | 880 | 881 | 882 | 883 | 884 | 885 | 886 | 887 | 888 | 889 | 890 | 891 | 892 | 893 | 894 | 895 | 896 | 897 | 898 | 899 | 900 | 901 | 902 | 903 | 904 | 905 | 906 | 907 | 908 | 909 | 910 | 911 | 912 | 913 | 914 | 915 | 916 | 917 | 918 | 919 | 920 | 921 | 922 | 923 | 924 | 925 | 926 | 927 | 928 | 929 | 930 | 931 | 932 | 933 | 934 | 935 | 936 | 937 | 938 | 939 | 940 | 941 | 942 | 943 | 944 | 945 | 946 | 947 | 948 | 949 | 950 | 951 | 952 | 953 | 954 | 955 | 956 | 957 | 958 | 959 | 960 | 961 | 962 | 963 | 964 | 965 | 966 | 967 | 968 | 969 | 970 | 971 | 972 | 973 | 974 | 975 | 976 | 977 | 978 | 979 | 980 | 981 | 982 | 983 | 984 | 985 | 986 | 987 | 988 | 989 | 990 | 991 | 992 | 993 | 994 | 995 | 996 | 997 | 998 | 999 | 1000 | 1001 | 1002 | 1003 | 1004 | 1005 | 1006 | 1007 | 1008 | 1009 | 1010 | 1011 | 1012 | 1013 | 1014 | 1015 | 1016 | 1017 | 1018 | 1019 | 1020 | 1021 | 1022 | 1023 | 1024 | 1025 | 1026 | 1027 | 1028 | 1029 | 1030 | 1031 | 1032 | 1033 | 1034 | 1035 | 1036 | 1037 | 1038 | 1039 | 1040 | 1041 | 1042 | 1043 | 1044 | 1045 | 1046 | 1047 | 1048 | 1049 | 1050 | 1055 | 1056 | 1057 | 1058 | 1059 | 1060 | 1061 | 1062 | 1063 | 1064 | 1065 | 1066 | 1067 | 1068 | 1069 | 1070 | 1071 | 1072 | 1073 | 1074 | 1075 | 1076 | 1077 | 1078 | 1079 | 1080 | 1081 | 1082 | 1083 | 1084 | 1085 | 1086 | 1087 | 1088 | 1089 | 1090 | 1091 | 1092 | 1093 | 1094 | 1095 | 1096 | 1097 | 1098 | 1099 | 1100 | 1101 | 1102 | 1103 | 1104 | 1105 | 1106 | 1107 | 1108 | 1109 | 1110 | 1111 | 1112 | 1113 | 1114 | 1115 | 1116 | 1117 | Must select some files in the IDE or set javac.includes 1118 | 1119 | 1120 | 1121 | 1122 | 1123 | 1124 | 1125 | 1126 | 1131 | 1132 | 1133 | 1134 | 1135 | 1136 | 1137 | 1138 | 1139 | 1140 | 1141 | 1142 | 1143 | 1144 | 1145 | 1146 | 1147 | 1148 | 1149 | 1150 | 1151 | 1152 | 1153 | 1154 | 1155 | 1156 | 1157 | 1158 | 1159 | 1160 | 1161 | 1162 | 1163 | 1164 | 1165 | 1166 | 1167 | 1168 | 1169 | 1170 | 1171 | 1172 | 1173 | 1174 | 1175 | 1176 | 1177 | 1178 | 1179 | 1180 | 1181 | 1182 | 1183 | 1184 | 1185 | 1186 | 1187 | 1188 | 1189 | 1190 | 1191 | 1192 | 1193 | 1194 | 1195 | 1196 | 1197 | 1198 | 1199 | 1200 | To run this application from the command line without Ant, try: 1201 | 1202 | java -jar "${dist.jar.resolved}" 1203 | 1204 | 1205 | 1206 | 1207 | 1208 | 1209 | 1210 | 1211 | 1212 | 1213 | 1214 | 1215 | 1216 | 1217 | 1218 | 1219 | 1220 | 1221 | 1222 | 1223 | 1224 | 1225 | 1226 | 1227 | 1228 | 1229 | 1230 | 1231 | 1232 | 1233 | 1234 | 1235 | 1236 | 1237 | 1238 | 1239 | 1240 | 1241 | 1242 | 1243 | 1244 | 1245 | 1246 | 1247 | 1248 | 1249 | 1250 | 1251 | 1252 | 1253 | 1254 | 1255 | 1256 | 1257 | 1258 | 1259 | 1264 | 1265 | 1266 | 1267 | 1268 | 1269 | 1270 | 1271 | 1272 | 1273 | 1274 | 1275 | 1276 | 1277 | 1278 | 1279 | 1280 | 1281 | 1282 | 1283 | 1284 | 1285 | 1286 | 1287 | 1288 | 1289 | 1290 | 1291 | 1292 | 1293 | 1294 | 1295 | 1296 | 1297 | 1298 | 1299 | 1300 | 1301 | 1302 | 1303 | 1304 | 1305 | 1306 | 1307 | 1308 | 1309 | 1310 | 1311 | 1312 | 1313 | 1314 | 1315 | 1316 | 1317 | 1318 | 1319 | 1320 | 1321 | 1322 | 1323 | 1324 | 1329 | 1330 | 1331 | 1332 | 1333 | 1334 | 1335 | 1336 | 1337 | 1338 | 1339 | 1340 | Must select one file in the IDE or set run.class 1341 | 1342 | 1343 | 1344 | Must select one file in the IDE or set run.class 1345 | 1346 | 1347 | 1352 | 1353 | 1354 | 1355 | 1356 | 1357 | 1358 | 1359 | 1360 | 1361 | 1362 | 1363 | 1364 | 1365 | 1366 | 1367 | 1368 | 1369 | 1370 | 1371 | Must select one file in the IDE or set debug.class 1372 | 1373 | 1374 | 1375 | 1376 | Must select one file in the IDE or set debug.class 1377 | 1378 | 1379 | 1380 | 1381 | Must set fix.includes 1382 | 1383 | 1384 | 1385 | 1386 | 1387 | 1388 | 1393 | 1396 | 1397 | This target only works when run from inside the NetBeans IDE. 1398 | 1399 | 1400 | 1401 | 1402 | 1403 | 1404 | 1405 | 1406 | Must select one file in the IDE or set profile.class 1407 | This target only works when run from inside the NetBeans IDE. 1408 | 1409 | 1410 | 1411 | 1412 | 1413 | 1414 | 1415 | 1416 | This target only works when run from inside the NetBeans IDE. 1417 | 1418 | 1419 | 1420 | 1421 | 1422 | 1423 | 1424 | 1425 | 1426 | 1427 | 1428 | 1429 | This target only works when run from inside the NetBeans IDE. 1430 | 1431 | 1432 | 1433 | 1434 | 1435 | 1436 | 1437 | 1438 | 1439 | 1440 | 1441 | 1442 | 1443 | 1444 | 1445 | 1446 | 1447 | 1450 | 1451 | 1452 | 1453 | 1454 | 1455 | 1456 | 1457 | 1458 | 1459 | 1460 | 1461 | 1462 | 1463 | Must select one file in the IDE or set run.class 1464 | 1465 | 1466 | 1467 | 1468 | 1469 | Must select some files in the IDE or set test.includes 1470 | 1471 | 1472 | 1473 | 1474 | Must select one file in the IDE or set run.class 1475 | 1476 | 1477 | 1478 | 1479 | Must select one file in the IDE or set applet.url 1480 | 1481 | 1482 | 1483 | 1488 | 1489 | 1490 | 1491 | 1492 | 1493 | 1494 | 1495 | 1496 | 1497 | 1498 | 1499 | 1500 | 1501 | 1502 | 1503 | 1504 | 1505 | 1506 | 1507 | 1508 | 1509 | 1510 | 1511 | 1512 | 1513 | 1514 | 1515 | 1516 | 1517 | 1518 | 1519 | 1520 | 1521 | 1522 | 1523 | 1524 | 1525 | 1526 | 1527 | 1528 | 1529 | 1530 | 1531 | 1532 | 1533 | 1534 | 1539 | 1540 | 1541 | 1542 | 1543 | 1544 | 1545 | 1546 | 1547 | 1548 | 1549 | 1550 | 1551 | 1552 | 1553 | 1554 | 1555 | 1556 | 1557 | 1558 | 1559 | 1560 | 1561 | 1562 | 1563 | 1564 | 1565 | 1566 | 1567 | 1568 | 1569 | 1570 | 1571 | 1572 | 1573 | 1574 | 1575 | 1576 | 1577 | 1578 | 1579 | 1580 | 1581 | 1582 | 1583 | 1584 | 1585 | 1586 | 1587 | 1588 | 1589 | 1590 | 1591 | 1592 | 1593 | 1594 | 1595 | 1596 | 1597 | 1598 | 1599 | 1600 | 1601 | 1602 | 1603 | 1604 | 1605 | 1606 | 1607 | 1608 | 1609 | 1610 | 1611 | 1612 | 1613 | 1614 | 1615 | 1616 | 1617 | Must select some files in the IDE or set javac.includes 1618 | 1619 | 1620 | 1621 | 1622 | 1623 | 1624 | 1625 | 1626 | 1627 | 1628 | 1629 | 1630 | 1631 | 1632 | 1633 | 1638 | 1639 | 1640 | 1641 | 1642 | 1643 | 1644 | 1645 | Some tests failed; see details above. 1646 | 1647 | 1648 | 1649 | 1650 | 1651 | 1652 | 1653 | 1654 | Must select some files in the IDE or set test.includes 1655 | 1656 | 1657 | 1658 | Some tests failed; see details above. 1659 | 1660 | 1661 | 1662 | Must select some files in the IDE or set test.class 1663 | Must select some method in the IDE or set test.method 1664 | 1665 | 1666 | 1667 | Some tests failed; see details above. 1668 | 1669 | 1670 | 1675 | 1676 | Must select one file in the IDE or set test.class 1677 | 1678 | 1679 | 1680 | Must select one file in the IDE or set test.class 1681 | Must select some method in the IDE or set test.method 1682 | 1683 | 1684 | 1685 | 1686 | 1687 | 1688 | 1689 | 1690 | 1691 | 1692 | 1693 | 1694 | 1699 | 1700 | Must select one file in the IDE or set applet.url 1701 | 1702 | 1703 | 1704 | 1705 | 1706 | 1707 | 1712 | 1713 | Must select one file in the IDE or set applet.url 1714 | 1715 | 1716 | 1717 | 1718 | 1719 | 1720 | 1721 | 1726 | 1727 | 1728 | 1729 | 1730 | 1731 | 1732 | 1733 | 1734 | 1735 | 1736 | 1737 | 1738 | 1739 | 1740 | 1741 | 1742 | 1743 | 1744 | 1745 | 1746 | 1747 | 1748 | 1749 | 1750 | 1751 | 1752 | 1753 | 1754 | 1755 | 1756 | 1757 | 1758 | 1759 | 1760 | 1761 | 1762 | 1763 | 1764 | 1765 | 1766 | 1767 | 1768 | 1769 | 1770 | 1771 | 1772 | -------------------------------------------------------------------------------- /nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=acbcfdbf 2 | build.xml.script.CRC32=deae234d 3 | build.xml.stylesheet.CRC32=f85dc8f2@1.99.0.48 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=acbcfdbf 7 | nbproject/build-impl.xml.script.CRC32=6f2df4bf 8 | nbproject/build-impl.xml.stylesheet.CRC32=d549e5cc@1.99.0.48 9 | -------------------------------------------------------------------------------- /nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processors.list= 4 | annotation.processing.run.all.processors=true 5 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 6 | application.title=CRUD MVC 7 | application.vendor=MRoblesDev 8 | auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml 9 | build.classes.dir=${build.dir}/classes 10 | build.classes.excludes=**/*.java,**/*.form 11 | # This directory is removed when the project is cleaned: 12 | build.dir=build 13 | build.generated.dir=${build.dir}/generated 14 | build.generated.sources.dir=${build.dir}/generated-sources 15 | # Only compile against the classpath explicitly listed here: 16 | build.sysclasspath=ignore 17 | build.test.classes.dir=${build.dir}/test/classes 18 | build.test.results.dir=${build.dir}/test/results 19 | # Uncomment to specify the preferred debugger connection transport: 20 | #debug.transport=dt_socket 21 | debug.classpath=\ 22 | ${run.classpath} 23 | debug.modulepath=\ 24 | ${run.modulepath} 25 | debug.test.classpath=\ 26 | ${run.test.classpath} 27 | debug.test.modulepath=\ 28 | ${run.test.modulepath} 29 | # Files in build.classes.dir which should be excluded from distribution jar 30 | dist.archive.excludes= 31 | # This directory is removed when the project is cleaned: 32 | dist.dir=dist 33 | dist.jar=${dist.dir}/CRUDMVC.jar 34 | dist.javadoc.dir=${dist.dir}/javadoc 35 | endorsed.classpath= 36 | excludes= 37 | file.reference.mysql-connector-java-8.0.28.jar=mysql-connector-java-8.0.28.jar 38 | includes=** 39 | jar.archive.disabled=${jnlp.enabled} 40 | jar.compress=false 41 | jar.index=${jnlp.enabled} 42 | javac.classpath=\ 43 | ${file.reference.mysql-connector-java-8.0.28.jar} 44 | # Space-separated list of extra javac options 45 | javac.compilerargs= 46 | javac.deprecation=false 47 | javac.external.vm=true 48 | javac.modulepath= 49 | javac.processormodulepath= 50 | javac.processorpath=\ 51 | ${javac.classpath} 52 | javac.source=1.8 53 | javac.target=1.8 54 | javac.test.classpath=\ 55 | ${javac.classpath}:\ 56 | ${build.classes.dir} 57 | javac.test.modulepath=\ 58 | ${javac.modulepath} 59 | javac.test.processorpath=\ 60 | ${javac.test.classpath} 61 | javadoc.additionalparam= 62 | javadoc.author=false 63 | javadoc.encoding=${source.encoding} 64 | javadoc.html5=false 65 | javadoc.noindex=false 66 | javadoc.nonavbar=false 67 | javadoc.notree=false 68 | javadoc.private=false 69 | javadoc.splitindex=true 70 | javadoc.use=true 71 | javadoc.version=false 72 | javadoc.windowtitle= 73 | jlink.launcher=false 74 | jlink.launcher.name=CRUDMVC 75 | jnlp.codebase.type=no.codebase 76 | jnlp.descriptor=application 77 | jnlp.enabled=false 78 | jnlp.mixed.code=default 79 | jnlp.offline-allowed=false 80 | jnlp.signed=false 81 | jnlp.signing= 82 | jnlp.signing.alias= 83 | jnlp.signing.keystore= 84 | main.class=crudmvc.CRUDMVC 85 | # Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found. 86 | manifest.custom.application.library.allowable.codebase= 87 | # Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts. 88 | manifest.custom.caller.allowable.codebase= 89 | # Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed 90 | manifest.custom.codebase= 91 | # Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) 92 | manifest.custom.permissions= 93 | manifest.file=manifest.mf 94 | meta.inf.dir=${src.dir}/META-INF 95 | mkdist.disabled=false 96 | platform.active=default_platform 97 | run.classpath=\ 98 | ${javac.classpath}:\ 99 | ${build.classes.dir} 100 | # Space-separated list of JVM arguments used when running the project. 101 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. 102 | # To set system properties for unit tests define test-sys-prop.name=value: 103 | run.jvmargs= 104 | run.modulepath=\ 105 | ${javac.modulepath} 106 | run.test.classpath=\ 107 | ${javac.test.classpath}:\ 108 | ${build.test.classes.dir} 109 | run.test.modulepath=\ 110 | ${javac.test.modulepath} 111 | source.encoding=UTF-8 112 | src.dir=src 113 | test.src.dir=test 114 | -------------------------------------------------------------------------------- /nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | CRUDMVC 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Controlador/CtrlProducto.java: -------------------------------------------------------------------------------- 1 | package Controlador; 2 | 3 | import Modelo.ConsultasProducto; 4 | import Modelo.Producto; 5 | import Vista.frmProducto; 6 | import java.awt.event.ActionEvent; 7 | import java.awt.event.ActionListener; 8 | import javax.swing.JOptionPane; 9 | 10 | /** 11 | * 12 | * @author MRoblesDev 13 | */ 14 | public class CtrlProducto implements ActionListener { 15 | 16 | private final Producto modelo; 17 | private final ConsultasProducto consultas; 18 | private final frmProducto vista; 19 | 20 | public CtrlProducto(Producto modelo, ConsultasProducto consultas, frmProducto vista) { 21 | this.modelo = modelo; 22 | this.consultas = consultas; 23 | this.vista = vista; 24 | this.vista.btnGuardar.addActionListener(this); 25 | this.vista.btnModificar.addActionListener(this); 26 | this.vista.btnEliminar.addActionListener(this); 27 | this.vista.btnLimpiar.addActionListener(this); 28 | this.vista.btnBuscar.addActionListener(this); 29 | } 30 | 31 | public void iniciar() { 32 | vista.setTitle("Productos"); 33 | vista.setLocationRelativeTo(null); 34 | vista.txtId.setVisible(false); 35 | } 36 | 37 | @Override 38 | public void actionPerformed(ActionEvent e) { 39 | 40 | if (e.getSource() == vista.btnGuardar) { 41 | modelo.setCodigo(vista.txtCodigo.getText()); 42 | modelo.setNombre(vista.txtNombre.getText()); 43 | modelo.setPrecio(Double.parseDouble(vista.txtPrecio.getText())); 44 | modelo.setCantidad(Integer.parseInt(vista.txtCantidad.getText())); 45 | 46 | if (consultas.registrar(modelo)) { 47 | JOptionPane.showMessageDialog(null, "Registro Guardado"); 48 | limpiar(); 49 | } else { 50 | JOptionPane.showMessageDialog(null, "Error al Guardar"); 51 | limpiar(); 52 | } 53 | } 54 | 55 | if (e.getSource() == vista.btnModificar) { 56 | modelo.setId(Integer.parseInt(vista.txtId.getText())); 57 | modelo.setCodigo(vista.txtCodigo.getText()); 58 | modelo.setNombre(vista.txtNombre.getText()); 59 | modelo.setPrecio(Double.parseDouble(vista.txtPrecio.getText())); 60 | modelo.setCantidad(Integer.parseInt(vista.txtCantidad.getText())); 61 | 62 | if (consultas.modificar(modelo)) { 63 | JOptionPane.showMessageDialog(null, "Registro Modificado"); 64 | limpiar(); 65 | } else { 66 | JOptionPane.showMessageDialog(null, "Error al Modificar"); 67 | limpiar(); 68 | } 69 | } 70 | 71 | if (e.getSource() == vista.btnEliminar) { 72 | modelo.setId(Integer.parseInt(vista.txtId.getText())); 73 | 74 | if (consultas.eliminar(modelo)) { 75 | JOptionPane.showMessageDialog(null, "Registro Eliminado"); 76 | limpiar(); 77 | } else { 78 | JOptionPane.showMessageDialog(null, "Error al Eliminar"); 79 | limpiar(); 80 | } 81 | } 82 | 83 | if (e.getSource() == vista.btnBuscar) { 84 | modelo.setCodigo(vista.txtCodigo.getText()); 85 | 86 | if (consultas.buscar(modelo)) { 87 | vista.txtId.setText(String.valueOf(modelo.getId())); 88 | vista.txtCodigo.setText(modelo.getCodigo()); 89 | vista.txtNombre.setText(modelo.getNombre()); 90 | vista.txtPrecio.setText(String.valueOf(modelo.getPrecio())); 91 | vista.txtCantidad.setText(String.valueOf(modelo.getCantidad())); 92 | 93 | } else { 94 | JOptionPane.showMessageDialog(null, "No se encontro registro"); 95 | limpiar(); 96 | } 97 | } 98 | 99 | if (e.getSource() == vista.btnLimpiar) { 100 | limpiar(); 101 | } 102 | } 103 | 104 | public void limpiar() { 105 | vista.txtId.setText(null); 106 | vista.txtCodigo.setText(null); 107 | vista.txtNombre.setText(null); 108 | vista.txtPrecio.setText(null); 109 | vista.txtCantidad.setText(null); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/Modelo/Conexion.java: -------------------------------------------------------------------------------- 1 | package Modelo; 2 | 3 | import java.sql.Connection; 4 | import java.sql.DriverManager; 5 | import java.sql.SQLException; 6 | 7 | /** 8 | * 9 | * @author MRoblesDev 10 | */ 11 | public class Conexion { 12 | 13 | Connection con = null; 14 | 15 | String base = "tienda"; //Nombre de la base de datos 16 | String url = "jdbc:mysql://localhost:3306/" + base; //Direccion, puerto y nombre de la Base de Datos 17 | String user = "root"; //Usuario de Acceso a MySQL 18 | String password = "password"; //Password del usuario 19 | 20 | public Connection getConexion() { 21 | 22 | try { 23 | Class.forName("com.mysql.cj.jdbc.Driver"); 24 | con = DriverManager.getConnection(url, user, password); 25 | } catch (ClassNotFoundException | SQLException e) { 26 | System.err.println(e); 27 | } 28 | return con; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Modelo/ConsultasProducto.java: -------------------------------------------------------------------------------- 1 | package Modelo; 2 | 3 | import java.sql.Connection; 4 | import java.sql.PreparedStatement; 5 | import java.sql.ResultSet; 6 | import java.sql.SQLException; 7 | 8 | /** 9 | * 10 | * @author MRoblesDev 11 | */ 12 | public class ConsultasProducto extends Conexion { 13 | 14 | public boolean registrar(Producto pro) { 15 | PreparedStatement ps = null; 16 | Connection con = getConexion(); 17 | 18 | String sql = "INSERT INTO producto (codigo, nombre, precio , cantidad) VALUES(?,?,?,?)"; 19 | 20 | try { 21 | ps = con.prepareStatement(sql); 22 | ps.setString(1, pro.getCodigo()); 23 | ps.setString(2, pro.getNombre()); 24 | ps.setDouble(3, pro.getPrecio()); 25 | ps.setInt(4, pro.getCantidad()); 26 | ps.execute(); 27 | return true; 28 | } catch (SQLException e) { 29 | System.err.println(e); 30 | return false; 31 | } finally { 32 | try { 33 | con.close(); 34 | } catch (SQLException e) { 35 | System.err.println(e); 36 | } 37 | } 38 | } 39 | 40 | public boolean modificar(Producto pro) { 41 | PreparedStatement ps = null; 42 | Connection con = getConexion(); 43 | 44 | String sql = "UPDATE producto SET codigo=?, nombre=?, precio=?, cantidad=? WHERE id=? "; 45 | 46 | try { 47 | ps = con.prepareStatement(sql); 48 | ps.setString(1, pro.getCodigo()); 49 | ps.setString(2, pro.getNombre()); 50 | ps.setDouble(3, pro.getPrecio()); 51 | ps.setInt(4, pro.getCantidad()); 52 | ps.setInt(5, pro.getId()); 53 | ps.execute(); 54 | return true; 55 | } catch (SQLException e) { 56 | System.err.println(e); 57 | return false; 58 | } finally { 59 | try { 60 | con.close(); 61 | } catch (SQLException e) { 62 | System.err.println(e); 63 | } 64 | } 65 | } 66 | 67 | public boolean eliminar(Producto pro) { 68 | PreparedStatement ps = null; 69 | Connection con = getConexion(); 70 | 71 | String sql = "DELETE FROM producto WHERE id=? "; 72 | 73 | try { 74 | ps = con.prepareStatement(sql); 75 | ps.setInt(1, pro.getId()); 76 | ps.execute(); 77 | return true; 78 | } catch (SQLException e) { 79 | System.err.println(e); 80 | return false; 81 | } finally { 82 | try { 83 | con.close(); 84 | } catch (SQLException e) { 85 | System.err.println(e); 86 | } 87 | } 88 | } 89 | 90 | public boolean buscar(Producto pro) { 91 | PreparedStatement ps = null; 92 | ResultSet rs = null; 93 | Connection con = getConexion(); 94 | 95 | String sql = "SELECT * FROM producto WHERE codigo=? "; 96 | 97 | try { 98 | ps = con.prepareStatement(sql); 99 | ps.setString(1, pro.getCodigo()); 100 | rs = ps.executeQuery(); 101 | 102 | if (rs.next()) { 103 | pro.setId(Integer.parseInt(rs.getString("id"))); 104 | pro.setCodigo(rs.getString("codigo")); 105 | pro.setNombre(rs.getString("nombre")); 106 | pro.setPrecio(Double.parseDouble(rs.getString("precio"))); 107 | pro.setCantidad(Integer.parseInt(rs.getString("cantidad"))); 108 | return true; 109 | } 110 | return false; 111 | } catch (SQLException e) { 112 | System.err.println(e); 113 | return false; 114 | } finally { 115 | try { 116 | con.close(); 117 | } catch (SQLException e) { 118 | System.err.println(e); 119 | } 120 | } 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /src/Modelo/Producto.java: -------------------------------------------------------------------------------- 1 | package Modelo; 2 | 3 | /** 4 | * 5 | * @author MRoblesDev 6 | */ 7 | public class Producto { 8 | 9 | private int id; 10 | private String codigo; 11 | private String nombre; 12 | private Double precio; 13 | private int cantidad; 14 | 15 | public int getId() { 16 | return id; 17 | } 18 | 19 | public void setId(int id) { 20 | this.id = id; 21 | } 22 | 23 | public String getCodigo() { 24 | return codigo; 25 | } 26 | 27 | public void setCodigo(String codigo) { 28 | this.codigo = codigo; 29 | } 30 | 31 | public String getNombre() { 32 | return nombre; 33 | } 34 | 35 | public void setNombre(String nombre) { 36 | this.nombre = nombre; 37 | } 38 | 39 | public Double getPrecio() { 40 | return precio; 41 | } 42 | 43 | public void setPrecio(Double precio) { 44 | this.precio = precio; 45 | } 46 | 47 | public int getCantidad() { 48 | return cantidad; 49 | } 50 | 51 | public void setCantidad(int cantidad) { 52 | this.cantidad = cantidad; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/Recursos/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mroblesdev/CRUD-MVC-Java-MySQL/1289cd985481e21b54646c43148d6d47aef88eee/src/Recursos/add.png -------------------------------------------------------------------------------- /src/Recursos/clear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mroblesdev/CRUD-MVC-Java-MySQL/1289cd985481e21b54646c43148d6d47aef88eee/src/Recursos/clear.png -------------------------------------------------------------------------------- /src/Recursos/delete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mroblesdev/CRUD-MVC-Java-MySQL/1289cd985481e21b54646c43148d6d47aef88eee/src/Recursos/delete.png -------------------------------------------------------------------------------- /src/Recursos/edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mroblesdev/CRUD-MVC-Java-MySQL/1289cd985481e21b54646c43148d6d47aef88eee/src/Recursos/edit.png -------------------------------------------------------------------------------- /src/Recursos/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mroblesdev/CRUD-MVC-Java-MySQL/1289cd985481e21b54646c43148d6d47aef88eee/src/Recursos/icon.png -------------------------------------------------------------------------------- /src/Recursos/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mroblesdev/CRUD-MVC-Java-MySQL/1289cd985481e21b54646c43148d6d47aef88eee/src/Recursos/search.png -------------------------------------------------------------------------------- /src/Vista/frmProducto.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 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 | 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 | 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 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | -------------------------------------------------------------------------------- /src/Vista/frmProducto.java: -------------------------------------------------------------------------------- 1 | package Vista; 2 | 3 | import java.awt.Image; 4 | import java.awt.Toolkit; 5 | 6 | /** 7 | * 8 | * @author MRoblesDev 9 | */ 10 | public class frmProducto extends javax.swing.JFrame { 11 | 12 | /** 13 | * Creates new form frmProducto 14 | */ 15 | public frmProducto() { 16 | initComponents(); 17 | Image icono = Toolkit.getDefaultToolkit().getImage(getClass().getResource("../Recursos/icon.png")); 18 | this.setIconImage(icono); 19 | 20 | } 21 | 22 | /** 23 | * This method is called from within the constructor to initialize the form. 24 | * WARNING: Do NOT modify this code. The content of this method is always 25 | * regenerated by the Form Editor. 26 | */ 27 | @SuppressWarnings("unchecked") 28 | // //GEN-BEGIN:initComponents 29 | private void initComponents() { 30 | 31 | jLabel1 = new javax.swing.JLabel(); 32 | jLabel2 = new javax.swing.JLabel(); 33 | jLabel3 = new javax.swing.JLabel(); 34 | txtCodigo = new javax.swing.JTextField(); 35 | jLabel4 = new javax.swing.JLabel(); 36 | txtNombre = new javax.swing.JTextField(); 37 | txtPrecio = new javax.swing.JTextField(); 38 | txtCantidad = new javax.swing.JTextField(); 39 | btnGuardar = new javax.swing.JButton(); 40 | btnModificar = new javax.swing.JButton(); 41 | btnEliminar = new javax.swing.JButton(); 42 | btnLimpiar = new javax.swing.JButton(); 43 | btnBuscar = new javax.swing.JButton(); 44 | txtId = new javax.swing.JTextField(); 45 | 46 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 47 | setTitle("CRUD MVC"); 48 | 49 | jLabel1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N 50 | jLabel1.setText("Código"); 51 | 52 | jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N 53 | jLabel2.setText("Nombre"); 54 | 55 | jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N 56 | jLabel3.setText("Precio"); 57 | 58 | txtCodigo.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N 59 | 60 | jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N 61 | jLabel4.setText("Cantidad"); 62 | 63 | txtNombre.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N 64 | 65 | txtPrecio.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N 66 | 67 | txtCantidad.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N 68 | 69 | btnGuardar.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N 70 | btnGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/add.png"))); // NOI18N 71 | btnGuardar.setText("Guardar"); 72 | 73 | btnModificar.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N 74 | btnModificar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/edit.png"))); // NOI18N 75 | btnModificar.setText("Modificar"); 76 | 77 | btnEliminar.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N 78 | btnEliminar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/delete.png"))); // NOI18N 79 | btnEliminar.setText("Eliminar"); 80 | 81 | btnLimpiar.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N 82 | btnLimpiar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/clear.png"))); // NOI18N 83 | btnLimpiar.setText("Limpiar"); 84 | 85 | btnBuscar.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N 86 | btnBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Recursos/search.png"))); // NOI18N 87 | btnBuscar.setText("Buscar"); 88 | btnBuscar.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); 89 | 90 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 91 | getContentPane().setLayout(layout); 92 | layout.setHorizontalGroup( 93 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 94 | .addGroup(layout.createSequentialGroup() 95 | .addContainerGap() 96 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 97 | .addComponent(jLabel4) 98 | .addComponent(jLabel3) 99 | .addComponent(jLabel2) 100 | .addComponent(jLabel1)) 101 | .addGap(18, 18, 18) 102 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 103 | .addComponent(txtCantidad, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE) 104 | .addGroup(layout.createSequentialGroup() 105 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) 106 | .addGroup(layout.createSequentialGroup() 107 | .addComponent(txtPrecio, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE) 108 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 109 | .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)) 110 | .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() 111 | .addComponent(txtCodigo, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE) 112 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) 113 | .addComponent(btnBuscar)) 114 | .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)) 115 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 116 | .addComponent(btnLimpiar))) 117 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 118 | .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() 119 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 120 | .addComponent(btnGuardar) 121 | .addGap(36, 36, 36) 122 | .addComponent(btnModificar) 123 | .addGap(34, 34, 34) 124 | .addComponent(btnEliminar) 125 | .addGap(29, 29, 29)) 126 | ); 127 | layout.setVerticalGroup( 128 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 129 | .addGroup(layout.createSequentialGroup() 130 | .addGap(43, 43, 43) 131 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 132 | .addComponent(jLabel1) 133 | .addComponent(btnBuscar) 134 | .addComponent(btnLimpiar) 135 | .addComponent(txtCodigo)) 136 | .addGap(18, 18, 18) 137 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 138 | .addComponent(jLabel2) 139 | .addComponent(txtNombre)) 140 | .addGap(18, 18, 18) 141 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 142 | .addComponent(jLabel3) 143 | .addComponent(txtPrecio) 144 | .addComponent(txtId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) 145 | .addGap(18, 18, 18) 146 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 147 | .addComponent(jLabel4) 148 | .addComponent(txtCantidad)) 149 | .addGap(57, 57, 57) 150 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 151 | .addComponent(btnGuardar) 152 | .addComponent(btnModificar) 153 | .addComponent(btnEliminar)) 154 | .addGap(51, 51, 51)) 155 | ); 156 | 157 | pack(); 158 | }// //GEN-END:initComponents 159 | 160 | /** 161 | * @param args the command line arguments 162 | */ 163 | public static void main(String args[]) { 164 | /* Set the Nimbus look and feel */ 165 | // 166 | /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. 167 | * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 168 | */ 169 | try { 170 | for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { 171 | if ("Nimbus".equals(info.getName())) { 172 | javax.swing.UIManager.setLookAndFeel(info.getClassName()); 173 | break; 174 | } 175 | } 176 | } catch (ClassNotFoundException ex) { 177 | java.util.logging.Logger.getLogger(frmProducto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 178 | } catch (InstantiationException ex) { 179 | java.util.logging.Logger.getLogger(frmProducto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 180 | } catch (IllegalAccessException ex) { 181 | java.util.logging.Logger.getLogger(frmProducto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 182 | } catch (javax.swing.UnsupportedLookAndFeelException ex) { 183 | java.util.logging.Logger.getLogger(frmProducto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); 184 | } 185 | // 186 | 187 | /* Create and display the form */ 188 | java.awt.EventQueue.invokeLater(() -> { 189 | new frmProducto().setVisible(true); 190 | }); 191 | } 192 | 193 | // Variables declaration - do not modify//GEN-BEGIN:variables 194 | public javax.swing.JButton btnBuscar; 195 | public javax.swing.JButton btnEliminar; 196 | public javax.swing.JButton btnGuardar; 197 | public javax.swing.JButton btnLimpiar; 198 | public javax.swing.JButton btnModificar; 199 | private javax.swing.JLabel jLabel1; 200 | private javax.swing.JLabel jLabel2; 201 | private javax.swing.JLabel jLabel3; 202 | private javax.swing.JLabel jLabel4; 203 | public javax.swing.JTextField txtCantidad; 204 | public javax.swing.JTextField txtCodigo; 205 | public javax.swing.JTextField txtId; 206 | public javax.swing.JTextField txtNombre; 207 | public javax.swing.JTextField txtPrecio; 208 | // End of variables declaration//GEN-END:variables 209 | } 210 | -------------------------------------------------------------------------------- /src/crudmvc/CRUDMVC.java: -------------------------------------------------------------------------------- 1 | package crudmvc; 2 | 3 | import Controlador.CtrlProducto; 4 | import Modelo.ConsultasProducto; 5 | import Modelo.Producto; 6 | import Vista.frmProducto; 7 | 8 | /** 9 | * 10 | * @author MRoblesDev 11 | */ 12 | public class CRUDMVC { 13 | 14 | /** 15 | * @param args the command line arguments 16 | */ 17 | public static void main(String[] args) { 18 | 19 | Producto mod = new Producto(); 20 | ConsultasProducto modC = new ConsultasProducto(); 21 | frmProducto frm = new frmProducto(); 22 | 23 | CtrlProducto ctrl = new CtrlProducto(mod, modC, frm); 24 | ctrl.iniciar(); 25 | frm.setVisible(true); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /tienda.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 5.2.0 3 | -- https://www.phpmyadmin.net/ 4 | -- 5 | -- Servidor: localhost 6 | -- Tiempo de generación: 24-01-2023 a las 23:12:17 7 | -- Versión del servidor: 8.0.23 8 | -- Versión de PHP: 8.1.12 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | START TRANSACTION; 12 | SET time_zone = "+00:00"; 13 | 14 | 15 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 16 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 17 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 18 | /*!40101 SET NAMES utf8mb4 */; 19 | 20 | -- 21 | -- Base de datos: `tienda` 22 | -- 23 | CREATE DATABASE IF NOT EXISTS `tienda` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; 24 | USE `tienda`; 25 | 26 | -- -------------------------------------------------------- 27 | 28 | -- 29 | -- Estructura de tabla para la tabla `producto` 30 | -- 31 | 32 | CREATE TABLE `producto` ( 33 | `id` int NOT NULL, 34 | `codigo` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL, 35 | `nombre` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, 36 | `precio` decimal(10,2) NOT NULL, 37 | `cantidad` int NOT NULL 38 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; 39 | 40 | -- 41 | -- Índices para tablas volcadas 42 | -- 43 | 44 | -- 45 | -- Indices de la tabla `producto` 46 | -- 47 | ALTER TABLE `producto` 48 | ADD PRIMARY KEY (`id`); 49 | 50 | -- 51 | -- AUTO_INCREMENT de las tablas volcadas 52 | -- 53 | 54 | -- 55 | -- AUTO_INCREMENT de la tabla `producto` 56 | -- 57 | ALTER TABLE `producto` 58 | MODIFY `id` int NOT NULL AUTO_INCREMENT; 59 | COMMIT; 60 | 61 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 62 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 63 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 64 | --------------------------------------------------------------------------------