commit 091df3d229ce1082d0c5967e422f2ed84f1d5091 Author: jp.av.dev Date: Sat Aug 1 02:28:21 2020 -0400 inicio repo Sist.V.LSR diff --git a/README.md b/README.md new file mode 100644 index 0000000..358bee0 --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +## Sistema De Ventas (GUI) +Aplicación utílizada con un lector de códigos de barra, se puede usar teclado. +Boleta simulada en consola. + +Descargas: +- []() +- []() + diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..1c8cd87 --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project Sistema_de_Ventas_LSR_Pi. + + + diff --git a/lib/AbsoluteLayout.jar b/lib/AbsoluteLayout.jar new file mode 100644 index 0000000..6106c0c Binary files /dev/null and b/lib/AbsoluteLayout.jar differ diff --git a/lib/JTattoo-1.6.11.jar b/lib/JTattoo-1.6.11.jar new file mode 100644 index 0000000..1324fb6 Binary files /dev/null and b/lib/JTattoo-1.6.11.jar differ diff --git a/manifest.mf b/manifest.mf new file mode 100644 index 0000000..1574df4 --- /dev/null +++ b/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..46a72d8 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1769 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/configs/ConfigRemotePi.properties b/nbproject/configs/ConfigRemotePi.properties new file mode 100644 index 0000000..554136a --- /dev/null +++ b/nbproject/configs/ConfigRemotePi.properties @@ -0,0 +1,2 @@ +compile.on.save.unsupported.remote.platform=true +debug-transport=dt_socket diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..7b29cc6 --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=2de7ada0 +build.xml.script.CRC32=04a34e5f +build.xml.stylesheet.CRC32=f85dc8f2@1.90.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=2de7ada0 +nbproject/build-impl.xml.script.CRC32=e288e195 +nbproject/build-impl.xml.stylesheet.CRC32=3a2fa800@1.90.1.48 diff --git a/nbproject/private/config.properties b/nbproject/private/config.properties new file mode 100644 index 0000000..e69de29 diff --git a/nbproject/private/private.properties b/nbproject/private/private.properties new file mode 100644 index 0000000..54237fb --- /dev/null +++ b/nbproject/private/private.properties @@ -0,0 +1,8 @@ +compile.on.save=true +do.depend=false +do.jar=true +do.jlink=false +javac.debug=true +javadoc.preview=true +jlink.strip=false +user.properties.file=/home/fuzantoko/.netbeans/10.0/build.properties diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml new file mode 100644 index 0000000..4750962 --- /dev/null +++ b/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..7fe3bb0 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,117 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.desc= +application.homepage=jpdev.kickto.net +application.title=Sistema_de_Ventas_LSR_Pi +application.vendor=jp.av.dev@gmail.com +auxiliary.org-netbeans-spi-editor-hints-projects.perProjectHintSettingsFile=nbproject/cfg_hints.xml +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/Sistema_de_Ventas_LSR_Pi.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +file.reference.AbsoluteLayout.jar=lib/AbsoluteLayout.jar +file.reference.JTattoo-1.6.11.jar=lib/JTattoo-1.6.11.jar +includes=** +jar.archive.disabled=${jnlp.enabled} +jar.compress=false +jar.index=${jnlp.enabled} +javac.classpath=\ + ${file.reference.AbsoluteLayout.jar}:\ + ${file.reference.JTattoo-1.6.11.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +jlink.launcher=false +jlink.launcher.name=Sistema_de_Ventas_LSR_Pi +jnlp.codebase.type=no.codebase +jnlp.descriptor=application +jnlp.enabled=false +jnlp.mixed.code=default +jnlp.offline-allowed=false +jnlp.signed=false +jnlp.signing= +jnlp.signing.alias= +jnlp.signing.keystore= +main.class=sistema_de_ventas_lsr.Sistema_de_Ventas_LSR +# Optional override of default Application-Library-Allowable-Codebase attribute identifying the locations where your signed RIA is expected to be found. +manifest.custom.application.library.allowable.codebase= +# Optional override of default Caller-Allowable-Codebase attribute identifying the domains from which JavaScript code can make calls to your RIA without security prompts. +manifest.custom.caller.allowable.codebase= +# Optional override of default Codebase manifest attribute, use to prevent RIAs from being repurposed +manifest.custom.codebase= +# Optional override of default Permissions manifest attribute (supported values: sandbox, all-permissions) +manifest.custom.permissions= +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..dd84bdd --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,18 @@ + + + org.netbeans.modules.java.j2seproject + + + + + + Sistema_de_Ventas_LSR_Pi + + + + + + + + + diff --git a/nbproject/remote-platform-impl.xml b/nbproject/remote-platform-impl.xml new file mode 100644 index 0000000..064cf1f --- /dev/null +++ b/nbproject/remote-platform-impl.xml @@ -0,0 +1,234 @@ + + + + + + + + + + + Runtime platform (platform.runtime) must be set. + + + + + + + + + Must set remote.platform.home.dir + Must set remote.platform.work.dir + Must set remote.platform.host + Must set remote.platform.port + Must set remote.platform.user + Must set remote.platform.auth + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set remote.platform.keyfile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set remote.platform.keyfile + + + + + + + + + + + + + + diff --git a/nbproject/remote-platform-impl_backup.xml b/nbproject/remote-platform-impl_backup.xml new file mode 100644 index 0000000..f0be15f --- /dev/null +++ b/nbproject/remote-platform-impl_backup.xml @@ -0,0 +1,253 @@ + + + + + + + + + + + Runtime platform (platform.runtime) must be set. + + + + + + + + + Must set remote.platform.home.dir + Must set remote.platform.work.dir + Must set remote.platform.host + Must set remote.platform.port + Must set remote.platform.user + Must set remote.platform.auth + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set remote.platform.keyfile + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set remote.platform.keyfile + + + + + + + + + + + + + + diff --git a/src/Vista/LogInUser.form b/src/Vista/LogInUser.form new file mode 100644 index 0000000..8964713 --- /dev/null +++ b/src/Vista/LogInUser.form @@ -0,0 +1,237 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Vista/LogInUser.java b/src/Vista/LogInUser.java new file mode 100644 index 0000000..6936fbe --- /dev/null +++ b/src/Vista/LogInUser.java @@ -0,0 +1,219 @@ +package Vista; /** @author jp.av.dev@gmail.com */ + +import java.awt.event.KeyEvent; +import javax.swing.JOptionPane; + + +public class LogInUser extends javax.swing.JFrame { + String usuario; + String pass; + + public LogInUser() { + initComponents(); + this.usuario ="admin"; + this.pass ="admin"; + } + + public String getAdmin() { + return usuario; + } + + public void setAdmin(String usuario) { + this.usuario = usuario; + } + + public String getPass() { + return pass; + } + + public void setPass(String pass) { + this.pass = pass; + } + + + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel3 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + txtUser = new javax.swing.JTextField(); + jPass = new javax.swing.JPasswordField(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + btnEnt = new javax.swing.JButton(); + btnSalir = new javax.swing.JButton(); + jLabel6 = new javax.swing.JLabel(); + jLabel1 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setLocation(new java.awt.Point(0, 0)); + setUndecorated(true); + setResizable(false); + getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel3.setBackground(new java.awt.Color(0, 204, 255)); + jLabel3.setFont(new java.awt.Font("SamsungImaginationBold", 1, 36)); // NOI18N + jLabel3.setForeground(new java.awt.Color(255, 255, 255)); + jLabel3.setText("Bienvenido a Ventas LSR"); + jLabel3.setFocusable(false); + getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 370, 50)); + + jLabel2.setBackground(new java.awt.Color(0, 204, 255)); + jLabel2.setFont(new java.awt.Font("SamsungImaginationBold", 1, 36)); // NOI18N + jLabel2.setForeground(new java.awt.Color(27, 0, 114)); + jLabel2.setText("Bienvenido a Ventas LSR"); + jLabel2.setFocusable(false); + getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 370, 60)); + + txtUser.setFont(new java.awt.Font("Verdana", 1, 18)); // NOI18N + txtUser.setForeground(new java.awt.Color(14, 0, 0)); + txtUser.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + txtUser.setOpaque(false); + txtUser.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txtUserActionPerformed(evt); + } + }); + txtUser.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + txtUserKeyPressed(evt); + } + }); + getContentPane().add(txtUser, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 130, 170, 30)); + + jPass.setFont(new java.awt.Font("Verdana", 1, 18)); // NOI18N + jPass.setForeground(new java.awt.Color(14, 0, 0)); + jPass.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + jPass.setOpaque(false); + jPass.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jPassKeyPressed(evt); + } + }); + getContentPane().add(jPass, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 210, 170, 30)); + + jLabel4.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N + jLabel4.setForeground(new java.awt.Color(255, 255, 255)); + jLabel4.setText("Nombre"); + getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 100, 110, 20)); + + jLabel5.setFont(new java.awt.Font("Dialog", 1, 18)); // NOI18N + jLabel5.setForeground(new java.awt.Color(255, 255, 255)); + jLabel5.setText("Contraseña"); + getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 180, 100, 20)); + + btnEnt.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N + btnEnt.setForeground(new java.awt.Color(255, 255, 255)); + btnEnt.setText("Entrar"); + btnEnt.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + btnEnt.setContentAreaFilled(false); + btnEnt.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnEntActionPerformed(evt); + } + }); + getContentPane().add(btnEnt, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 290, 70, 30)); + + btnSalir.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N + btnSalir.setForeground(new java.awt.Color(255, 255, 255)); + btnSalir.setText("Salir"); + btnSalir.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED)); + btnSalir.setContentAreaFilled(false); + btnSalir.setMaximumSize(new java.awt.Dimension(49, 25)); + btnSalir.setMinimumSize(new java.awt.Dimension(49, 25)); + btnSalir.setPreferredSize(new java.awt.Dimension(49, 25)); + btnSalir.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnSalirActionPerformed(evt); + } + }); + getContentPane().add(btnSalir, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 290, 70, 30)); + + jLabel6.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jLabel6MouseClicked(evt); + } + }); + getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, 20, 30)); + + jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagenes/braingridcircuitboard.png"))); // NOI18N + jLabel1.setText("jLabel1"); + getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 398, 350)); + + pack(); + }// //GEN-END:initComponents + + private void txtUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtUserActionPerformed + + }//GEN-LAST:event_txtUserActionPerformed + + private void btnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSalirActionPerformed + System.exit(0); + }//GEN-LAST:event_btnSalirActionPerformed + + private void btnEntActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEntActionPerformed + if (validarUsuario()) { + MenuPrincipal mP = new MenuPrincipal(usuario); + mP.setVisible(true); + mP.setLocationRelativeTo(null); + this.dispose(); + } else { + JOptionPane.showMessageDialog(this, "Favor verificar datos", "Log-In",JOptionPane.WARNING_MESSAGE); + txtUser.setText(""); + jPass.setText(""); + } + }//GEN-LAST:event_btnEntActionPerformed + + private void jLabel6MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel6MouseClicked + if (evt.getClickCount() == 2) { + MenuPrincipal mP = new MenuPrincipal(usuario); + mP.setVisible(true); + mP.setLocationRelativeTo(null); + this.dispose(); + } + }//GEN-LAST:event_jLabel6MouseClicked + + private void jPassKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jPassKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + if (validarUsuario()) { + MenuPrincipal mP = new MenuPrincipal(usuario); + mP.setVisible(true); + mP.setLocationRelativeTo(null); + this.dispose(); + } else { + JOptionPane.showMessageDialog(this, "Favor verificar datos", "Log-In",JOptionPane.WARNING_MESSAGE); + jPass.setText(""); + txtUser.setText(""); + txtUser.requestFocus(); + } + } + }//GEN-LAST:event_jPassKeyPressed + + private void txtUserKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtUserKeyPressed + if(evt.getKeyCode() == KeyEvent.VK_ENTER) jPass.requestFocus(); + }//GEN-LAST:event_txtUserKeyPressed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnEnt; + private javax.swing.JButton btnSalir; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JPasswordField jPass; + private javax.swing.JTextField txtUser; + // End of variables declaration//GEN-END:variables + + private boolean validarUsuario() { + String password = ""; + char[] passw = jPass.getPassword(); + for (int i=0; i + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Vista/MantenedorProductos.java b/src/Vista/MantenedorProductos.java new file mode 100644 index 0000000..48bd654 --- /dev/null +++ b/src/Vista/MantenedorProductos.java @@ -0,0 +1,477 @@ +package Vista; /** @author jp.av.dev@gmail.com */ + +import java.awt.event.KeyEvent; +import java.util.ArrayList; +import javax.swing.JOptionPane; +import static javax.swing.SwingConstants.CENTER; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import static jdk.nashorn.internal.objects.NativeString.trim; +import modelo.ListaProductos; +import modelo.Producto; + + +public class MantenedorProductos extends javax.swing.JFrame { + private static ListaProductos lp; + private final ArrayList productos; //Declarada final por recomendación de NetBeans + private DefaultTableModel modeloProductos; + private DefaultTableCellRenderer centrar; + + public MantenedorProductos() { + MantenedorProductos.lp = new ListaProductos(); + this.productos = new ArrayList<>(); + cargarModeloTabla(); + initComponents(); + limpiar(); + } + + public static ListaProductos getLp() { + return lp; + } + + private void FormatoTabla() { + centrar = new DefaultTableCellRenderer(); + centrar.setHorizontalAlignment(CENTER); + tablaProductos.getColumnModel().getColumn(0).setPreferredWidth(30); + tablaProductos.getColumnModel().getColumn(0).setCellRenderer(centrar); + tablaProductos.getColumnModel().getColumn(1).setPreferredWidth(120); + tablaProductos.getColumnModel().getColumn(2).setPreferredWidth(40); + tablaProductos.getColumnModel().getColumn(3).setPreferredWidth(40); + tablaProductos.getColumnModel().getColumn(3).setCellRenderer(centrar); + tablaProductos.getColumnModel().getColumn(4).setPreferredWidth(50); + tablaProductos.getColumnModel().getColumn(4).setCellRenderer(centrar); + } + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + txtCod = new javax.swing.JTextField(); + txtPrec = new javax.swing.JTextField(); + txtDesc = new javax.swing.JTextField(); + jLabel1 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + btnCrear = new javax.swing.JButton(); + jScrollPane1 = new javax.swing.JScrollPane(); + tablaProductos = new javax.swing.JTable(); + btnConsulta = new javax.swing.JButton(); + btnEdit = new javax.swing.JButton(); + btnElmininar = new javax.swing.JButton(); + jLabel6 = new javax.swing.JLabel(); + txtStockMin = new javax.swing.JTextField(); + jLabel7 = new javax.swing.JLabel(); + txtStock = new javax.swing.JTextField(); + jSeparator1 = new javax.swing.JSeparator(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setResizable(false); + addWindowStateListener(new java.awt.event.WindowStateListener() { + public void windowStateChanged(java.awt.event.WindowEvent evt) { + formWindowStateChanged(evt); + } + }); + + txtCod.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txtCodActionPerformed(evt); + } + }); + txtCod.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + txtCodKeyPressed(evt); + } + }); + + txtPrec.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txtPrecActionPerformed(evt); + } + }); + + txtDesc.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txtDescActionPerformed(evt); + } + }); + + jLabel1.setText("Precio :"); + + jLabel3.setText("Descripción :"); + + jLabel4.setText("Código :"); + + jLabel5.setFont(new java.awt.Font("MS UI Gothic", 0, 18)); // NOI18N + jLabel5.setText("Mantenedor Productos"); + + btnCrear.setText("Crear"); + btnCrear.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCrearActionPerformed(evt); + } + }); + + tablaProductos.setModel(modeloProductos); + tablaProductos.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + tablaProductosMouseClicked(evt); + } + }); + jScrollPane1.setViewportView(tablaProductos); + + btnConsulta.setText("Consulta"); + btnConsulta.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnConsultaActionPerformed(evt); + } + }); + + btnEdit.setText("Editar"); + btnEdit.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnEditActionPerformed(evt); + } + }); + + btnElmininar.setText("Eliminar"); + btnElmininar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnElmininarActionPerformed(evt); + } + }); + + jLabel6.setText("Stock :"); + + txtStockMin.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + txtStockMinActionPerformed(evt); + } + }); + + jLabel7.setText("Stock Mínimo :"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(jSeparator1) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(34, 34, 34)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addGap(50, 50, 50) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(37, 37, 37) + .addComponent(jLabel7)) + .addGroup(layout.createSequentialGroup() + .addComponent(txtPrec, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(txtStock, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(txtStockMin, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4) + .addGap(48, 48, 48)) + .addGroup(layout.createSequentialGroup() + .addComponent(txtCod) + .addGap(19, 19, 19))) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3) + .addComponent(txtDesc, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(btnCrear, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(btnEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addComponent(btnConsulta, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(btnElmininar, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(14, 14, 14) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(jLabel4)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtDesc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtCod, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtStockMin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtStock, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(txtPrec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnElmininar, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnConsulta, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(btnCrear, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnEdit, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + pack(); + }// //GEN-END:initComponents + + private void txtCodActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtCodActionPerformed + }//GEN-LAST:event_txtCodActionPerformed + + private void txtPrecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPrecActionPerformed + }//GEN-LAST:event_txtPrecActionPerformed + + private void txtDescActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtDescActionPerformed + }//GEN-LAST:event_txtDescActionPerformed + + private void btnCrearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCrearActionPerformed + if (validarTxt()) { + crearProducto(); + } else { + JOptionPane.showMessageDialog(this, "Debes llenar todos los campos", "Advertencia", JOptionPane.WARNING_MESSAGE); + } + }//GEN-LAST:event_btnCrearActionPerformed + + private void btnConsultaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultaActionPerformed + String consulta = JOptionPane.showInputDialog(this, "Ingresar Código de Producto :", "Buscar", JOptionPane.QUESTION_MESSAGE); + consultaPrecio(consulta); + }//GEN-LAST:event_btnConsultaActionPerformed + + private void txtStockMinActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtStockMinActionPerformed + }//GEN-LAST:event_txtStockMinActionPerformed + + private void txtCodKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtCodKeyPressed + if(evt.getKeyCode() == KeyEvent.VK_ENTER) { + String consulta = txtCod.getText(); + consultaPrecio(consulta); + } + }//GEN-LAST:event_txtCodKeyPressed + + private void btnElmininarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnElmininarActionPerformed + if (!txtCod.getText().equals("")){ + borrarProducto(txtCod.getText()); + } else { + JOptionPane.showMessageDialog(this, "Debes ingresar un código de producto válido", "Error al eliminar", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_btnElmininarActionPerformed + + private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditActionPerformed + if (validarTxt()) { + editProd(); + } else { + JOptionPane.showMessageDialog(this, "Debes llenar todos los campos", "Advertencia", JOptionPane.WARNING_MESSAGE); + } + }//GEN-LAST:event_btnEditActionPerformed + + private void tablaProductosMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaProductosMouseClicked + ClickTabla(evt); + }//GEN-LAST:event_tablaProductosMouseClicked + + private void formWindowStateChanged(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowStateChanged + System.out.println(evt.toString()); + }//GEN-LAST:event_formWindowStateChanged + + private void ClickTabla(java.awt.event.MouseEvent evt) { + int row = tablaProductos.rowAtPoint(evt.getPoint()); + if (row >= 0) { + txtCod.setText(tablaProductos.getValueAt(row,0).toString()); + txtDesc.setText(tablaProductos.getValueAt(row,1).toString()); + txtPrec.setText(tablaProductos.getValueAt(row,2).toString()); + txtStock.setText(tablaProductos.getValueAt(row,3).toString()); + txtStockMin.setText(tablaProductos.getValueAt(row,4).toString()); + } + } + + private boolean validarTxt() { + return ( (!txtCod.getText().equals("")) && (!txtPrec.getText().equals("")) && (!txtDesc.getText().equals("")) + && (!txtStockMin.getText().equals("")) && (!txtStock.getText().equals("")) ); + } + + private void limpiar(){ + txtCod.setText(""); txtStock.setText(""); txtStockMin.setText(""); + txtPrec.setText(""); txtDesc.setText(""); + cargaTablaModelo(lp.getLp()); + tablaProductos.setModel(modeloProductos); + txtCod.requestFocus(); + FormatoTabla(); + } + + private void consultaPrecio(String consulta) { + if (!"".equals(consulta)) { + if (!"".equals(lp.buscarProducto(consulta).getCodigo())) { + Producto prodTemp = lp.buscarProducto(consulta); + txtCod.setText(prodTemp.getCodigo()); + txtDesc.setText(prodTemp.getDescripcion()); + txtPrec.setText(Integer.toString(prodTemp.getPrecio())); + txtStock.setText(Integer.toString(prodTemp.getStock())); + txtStockMin.setText(Integer.toString(prodTemp.getStockMin())); + } else { + JOptionPane.showMessageDialog(rootPane, "Producto no encontrado, completar datos para Crear"); + limpiar(); + txtCod.setText(consulta); + txtDesc.requestFocus(); + } + } else { + JOptionPane.showMessageDialog(this, "Debes ingresar un código", "Advertencia", JOptionPane.WARNING_MESSAGE); + } + } + + private void cargaTablaModelo(ArrayList productos) { + String columnas[] = new String[]{"Código", "Descripción", "Precio", "Stock Actual", "Stock Mínimo"}; + modeloProductos = new DefaultTableModel(null, columnas); + for (int cont = 0;cont < productos.size(); cont++) { + Object datos[]=new Object[5]; + datos[0]=productos.get(cont).getCodigo(); + datos[1]=productos.get(cont).getDescripcion(); + datos[2]="$ "+productos.get(cont).getPrecio()+ ".-"; + datos[3]=productos.get(cont).getStock(); + datos[4]=productos.get(cont).getStockMin(); + modeloProductos.addRow(datos); + } + } + + private void crearProducto() { + if ( validarPrecio() && validarStock() ) { + if ( "".equals(lp.buscarProducto(txtCod.getText()).getCodigo())) { + try { + Producto prodTemp = new Producto(txtCod.getText(), txtDesc.getText(), Integer.parseInt(txtPrec.getText()), Integer.parseInt(txtStock.getText()), Integer.parseInt(txtStockMin.getText())); + lp.crearProducto(txtCod.getText(), txtDesc.getText(), Integer.parseInt(txtPrec.getText()), Integer.parseInt(txtStock.getText()), Integer.parseInt(txtStockMin.getText())); + JOptionPane.showMessageDialog(this, prodTemp.toString(), "Producto Creado", 1 ); + cargaTablaModelo(lp.getLp()); + limpiar(); + } catch (NumberFormatException e) { + JOptionPane.showMessageDialog(this, "Favor verificar datos ingresados", "Error!", JOptionPane.ERROR_MESSAGE); + } + } else { + JOptionPane.showMessageDialog(this, "El código ingresado ya existe", "Advertencia", JOptionPane.WARNING_MESSAGE); + limpiar(); + } + } else { + JOptionPane.showMessageDialog(this, "Favor verificar datos ingresados", "Error!", JOptionPane.ERROR_MESSAGE); + } + } + + private void cargarModeloTabla() { + productos.add(new Producto("0001", "Perejíl sin hojas", 65000, 630, 400)); + productos.add(new Producto("0002", "Volantín de Cuero", 50, 3, 5)); + productos.add(new Producto("0003", "Hoyo del queque", 780000, 16, 10)); + productos.add(new Producto("0004", "Tarro con mas duraznos", 1200, 478, 300)); + lp.setLp(productos); + cargaTablaModelo(lp.getLp()); + } + + private void borrarProducto(String cod) { + if (lp.eliminarProducto(cod)) { + JOptionPane.showMessageDialog(rootPane, "Producto eliminado!", "Borrar Producto", JOptionPane.INFORMATION_MESSAGE); + limpiar(); + } else { + JOptionPane.showMessageDialog(rootPane, "Código ingresado no existe", "Advertencia", JOptionPane.WARNING_MESSAGE); + } + } + + private void editProd() { + if (validarPrecio() && validarStock()) { + try { + Producto editar = new Producto(txtCod.getText(), txtDesc.getText(), Integer.parseInt(txtPrec.getText()), Integer.parseInt(txtStock.getText()), Integer.parseInt(txtStockMin.getText())); + if (lp.editarProducto(editar)) { + JOptionPane.showMessageDialog(this, "Producto editado", "Editar Producto", JOptionPane.INFORMATION_MESSAGE); + limpiar(); + } else { + JOptionPane.showMessageDialog(this, "Producto no existe", "Advertencia", JOptionPane.WARNING_MESSAGE); + } + } catch ( NumberFormatException e) { + JOptionPane.showMessageDialog(this, "Favor verificar datos ingresados", "Error!", JOptionPane.ERROR_MESSAGE); + } + } + } + + private boolean validarPrecio() { + boolean intValid = false; + try { + Integer.parseInt(txtPrec.getText()); + intValid = true; + return intValid; + } catch (NumberFormatException e){ + try { + if (txtPrec.getText().charAt(1) == ' ') { + txtPrec.setText(txtPrec.getText().replace("$ ", "")); + txtPrec.setText(txtPrec.getText().replace(".-", "")); + txtPrec.setText(trim(txtPrec.getText())); + intValid = true; + return intValid; + } + } catch (Exception e2) { + JOptionPane.showMessageDialog(this, "Formato Precio no admitido.\nIngresar solo números", "Advertencia", JOptionPane.WARNING_MESSAGE); + return intValid; + } + } + JOptionPane.showMessageDialog(this, "Formato Precio no admitido.\nIngresar solo números", "Advertencia", JOptionPane.WARNING_MESSAGE); + return intValid; + } + + private boolean validarStock() { + boolean intStockValid = false; + try { + Integer.parseInt(txtStock.getText()); + Integer.parseInt(txtStockMin.getText()); + intStockValid = true; + return intStockValid; + } catch (NumberFormatException e) { + JOptionPane.showMessageDialog(this, "Formato de Stock o Stock Mínimo no admitidos.\nIngresar solo números", "Advertencia", JOptionPane.WARNING_MESSAGE); + return intStockValid; + } + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton btnConsulta; + private javax.swing.JButton btnCrear; + private javax.swing.JButton btnEdit; + private javax.swing.JButton btnElmininar; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel7; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JSeparator jSeparator1; + private javax.swing.JTable tablaProductos; + private javax.swing.JTextField txtCod; + private javax.swing.JTextField txtDesc; + private javax.swing.JTextField txtPrec; + private javax.swing.JTextField txtStock; + private javax.swing.JTextField txtStockMin; + // End of variables declaration//GEN-END:variables +} diff --git a/src/Vista/MantenedorUsuarios.form b/src/Vista/MantenedorUsuarios.form new file mode 100644 index 0000000..931d5b6 --- /dev/null +++ b/src/Vista/MantenedorUsuarios.form @@ -0,0 +1,53 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Vista/MantenedorUsuarios.java b/src/Vista/MantenedorUsuarios.java new file mode 100644 index 0000000..173d68d --- /dev/null +++ b/src/Vista/MantenedorUsuarios.java @@ -0,0 +1,69 @@ +package Vista; /** @author jp.av.dev@gmail.com */ + + +public class MantenedorUsuarios extends javax.swing.JFrame { + + /** + * Creates new form MantenedorProducto + */ + public MantenedorUsuarios() { + initComponents(); + } + + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + + jLabel1.setFont(new java.awt.Font("MS UI Gothic", 0, 18)); // NOI18N + jLabel1.setText("Mantenedor Usuarios"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addContainerGap(230, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(308, Short.MAX_VALUE)) + ); + + pack(); + }// //GEN-END:initComponents + + /** + public static void main(String args[]) { + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(MantenedorProducto.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + + //Create and display the form + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new MantenedorProducto().setVisible(true); + } + }); + } +*/ + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + // End of variables declaration//GEN-END:variables +} diff --git a/src/Vista/MenuPrincipal.form b/src/Vista/MenuPrincipal.form new file mode 100644 index 0000000..7a808fd --- /dev/null +++ b/src/Vista/MenuPrincipal.form @@ -0,0 +1,420 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="false" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="btnQuitar"> + <Properties> + <Property name="text" type="java.lang.String" value="Quitar Producto"/> + <Property name="enabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuitarActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="btnGnrVenta"> + <Properties> + <Property name="text" type="java.lang.String" value="Generar Venta"/> + <Property name="enabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnGnrVentaActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="btnBrrVnta"> + <Properties> + <Property name="text" type="java.lang.String" value="Desechar"/> + <Property name="enabled" type="boolean" value="false"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnBrrVntaActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Producto : "/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="TOTAL :"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Efectivo :"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="12" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Vuelto :"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnCalc"> + <Properties> + <Property name="text" type="java.lang.String" value="Calculadora"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCalcActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel6"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Cantidad :"/> + </Properties> + </Component> + <Component class="javax.swing.JSpinner" name="jspCant"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + <Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor"> + <SpinnerModel initial="1" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/> + </Property> + <Property name="enabled" type="boolean" value="false"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="btnNvaVenta"> + <Properties> + <Property name="text" type="java.lang.String" value="Nueva Venta"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnNvaVentaActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JFormattedTextField" name="jfEfectivo"> + <Properties> + <Property name="formatterFactory" type="javax.swing.JFormattedTextField$AbstractFormatterFactory" editor="org.netbeans.modules.form.editors.AbstractFormatterFactoryEditor"> + <Format subtype="1" type="0"/> + </Property> + <Property name="horizontalAlignment" type="int" value="0"/> + <Property name="enabled" type="boolean" value="false"/> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Dialog" size="14" style="0"/> + </Property> + </Properties> + <Events> + <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jfEfectivoFocusGained"/> + <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="jfEfectivoKeyPressed"/> + <EventHandler event="keyTyped" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="jfEfectivoKeyTyped"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="btnConsulta"> + <Properties> + <Property name="text" type="java.lang.String" value="Consulta"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnConsultaActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/src/Vista/MenuPrincipal.java b/src/Vista/MenuPrincipal.java new file mode 100644 index 0000000..a0514be --- /dev/null +++ b/src/Vista/MenuPrincipal.java @@ -0,0 +1,598 @@ +package Vista; /** @author jp.av.dev@gmail.com */ + +import java.awt.Toolkit; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.io.IOException; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.ImageIcon; +import javax.swing.JOptionPane; +import static javax.swing.SwingConstants.CENTER; +import javax.swing.SwingUtilities; +import javax.swing.table.DefaultTableCellRenderer; +import javax.swing.table.DefaultTableModel; +import modelo.ListaProdsVenta; +import modelo.ListaProductos; +import modelo.Producto; +import modelo.ProductoVenta; +import modelo.Venta; + + +public class MenuPrincipal extends javax.swing.JFrame { + private static MantenedorProductos mp; + private Venta venta; // {<ProductosVenta>, total, efectivo, usuario} + private ProductoVenta prodVent; // {Codigo, descripcion, cantidad, precio} + private ArrayList<ProductoVenta> productosVenta; + private ListaProdsVenta lpv; + private final String usuario; + private DefaultTableModel modeloTabla; + private ListaProductos lp; + private int total; + private DefaultTableCellRenderer centrar; + + public MenuPrincipal(String usuario) { + this.usuario = usuario; + initComponents(); + TablaVacia(); + lp = new ListaProductos(); + mp = new MantenedorProductos(); + mp.setVisible(false); + btnNvaVenta.requestFocus(); + jspCant.getEditor().getComponent(0).addKeyListener(new KeyListener() { + @Override + public void keyPressed(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER){ + txtProd.requestFocus(); + } + } + @Override + public void keyTyped(KeyEvent e) {} + @Override + public void keyReleased(KeyEvent e) {} + }); + } + + private void cargarModeloTablaVenta(ArrayList<ProductoVenta> lpv) { + total = 0; + String columnas[] = new String[]{"Código", "Producto", "Cantidad", "Precio", "SubTotal"}; + modeloTabla = new DefaultTableModel(null, columnas); + for (int cont = 0;cont < lpv.size(); cont++) { + Object datos[]=new Object[5]; + datos[0]= lpv.get(cont).getCod(); + datos[1]= lpv.get(cont).getDescrip(); + datos[2]= lpv.get(cont).getCant(); + datos[3]= "$ "+lpv.get(cont).getPrecio()+ ".-"; + datos[4]= "$ "+ (lpv.get(cont).getPrecio() * lpv.get(cont).getCant()) +".-"; + total = total + (lpv.get(cont).getPrecio() * lpv.get(cont).getCant()); + modeloTabla.addRow(datos); + txtTotal.setText("$ "+ String.valueOf(total) +".-"); + tbVenta.setModel(modeloTabla); + FormatoTabla(); + } + } + + private void TablaVacia() { + tbVenta.setModel(new DefaultTableModel(null, new String[]{"Código", "Producto", "Cantidad", "Precio", "SubTotal"})); + FormatoTabla(); + } + + private void FormatoTabla() { + centrar = new DefaultTableCellRenderer(); + centrar.setHorizontalAlignment(CENTER); + tbVenta.getColumnModel().getColumn(0).setPreferredWidth(40); + tbVenta.getColumnModel().getColumn(0).setCellRenderer(centrar); + tbVenta.getColumnModel().getColumn(1).setPreferredWidth(150); + tbVenta.getColumnModel().getColumn(2).setPreferredWidth(40); + tbVenta.getColumnModel().getColumn(2).setCellRenderer(centrar); + tbVenta.getColumnModel().getColumn(3).setPreferredWidth(50); + tbVenta.getColumnModel().getColumn(3).setCellRenderer(centrar); + tbVenta.getColumnModel().getColumn(4).setPreferredWidth(50); + tbVenta.getColumnModel().getColumn(4).setCellRenderer(centrar); + } + + private void nuevaVenta() { + productosVenta = new ArrayList<>(); + lpv = new ListaProdsVenta(productosVenta); + txtProd.setEnabled(true); + jspCant.setEnabled(true); + txtProd.requestFocus(); + btnNvaVenta.setEnabled(false); + btnGnrVenta.setEnabled(true); + txtTotal.setText("$ 0.-"); + jfEfectivo.setValue((int)0); + jfEfectivo.setEnabled(true); + txtVuelto.setText("0"); + btnBrrVnta.setEnabled(true); + } + + private void generarVenta() throws Exception { + if (productosVenta.size() > 0) { + Venta detalleVenta = new Venta(productosVenta, this.usuario); + int efectivo = Integer.parseInt(jfEfectivo.getValue().toString()); + detalleVenta.setTotal(total); + detalleVenta.setEfectivo(efectivo); + txtVuelto.setText(String.valueOf(efectivo - total)); + System.out.println(detalleVenta.toString()); + txtProd.setText(""); + jspCant.setValue(1); + txtProd.setEnabled(false); + jspCant.setEnabled(false); + btnQuitar.setEnabled(false); + btnGnrVenta.setEnabled(false); + btnNvaVenta.setEnabled(true); + btnNvaVenta.requestFocus(); + total = 0; + txtTotal.setText("$ 0.-"); + jfEfectivo.setValue(0); + jfEfectivo.setEnabled(false); + btnBrrVnta.setEnabled(false); + TablaVacia(); + } else { + Toolkit.getDefaultToolkit().beep(); + } + } + + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jMenuBar2 = new javax.swing.JMenuBar(); + jMenu3 = new javax.swing.JMenu(); + jMenu4 = new javax.swing.JMenu(); + jMenuItem2 = new javax.swing.JMenuItem(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTable1 = new javax.swing.JTable(); + txtProd = new javax.swing.JTextField(); + txtTotal = new javax.swing.JTextField(); + txtVuelto = new javax.swing.JTextField(); + jScrollPane2 = new javax.swing.JScrollPane(); + tbVenta = new javax.swing.JTable(); + btnQuitar = new javax.swing.JButton(); + btnGnrVenta = new javax.swing.JButton(); + btnBrrVnta = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + btnCalc = new javax.swing.JButton(); + jLabel6 = new javax.swing.JLabel(); + jspCant = new javax.swing.JSpinner(); + btnNvaVenta = new javax.swing.JButton(); + jfEfectivo = new javax.swing.JFormattedTextField(); + btnConsulta = new javax.swing.JButton(); + jMenuBar1 = new javax.swing.JMenuBar(); + jMenu1 = new javax.swing.JMenu(); + menuProd = new javax.swing.JMenuItem(); + menuUser = new javax.swing.JMenuItem(); + jMenu2 = new javax.swing.JMenu(); + jMenuItem1 = new javax.swing.JMenuItem(); + jMenu5 = new javax.swing.JMenu(); + acercaDe = new javax.swing.JMenuItem(); + + jMenu3.setText("File"); + jMenuBar2.add(jMenu3); + + jMenu4.setText("Edit"); + jMenuBar2.add(jMenu4); + + jMenuItem2.setText("jMenuItem2"); + + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null} + }, + new String [] { + "Title 1", "Title 2", "Title 3", "Title 4" + } + )); + jScrollPane1.setViewportView(jTable1); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("Sistema de Ventas L.S.R. v 1.0"); + setResizable(false); + + txtProd.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + txtProd.setEnabled(false); + txtProd.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + txtProdKeyPressed(evt); + } + }); + + txtTotal.setEditable(false); + txtTotal.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N + txtTotal.setHorizontalAlignment(javax.swing.JTextField.CENTER); + + txtVuelto.setEditable(false); + txtVuelto.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + txtVuelto.setHorizontalAlignment(javax.swing.JTextField.CENTER); + + tbVenta.getTableHeader().setReorderingAllowed(false); + jScrollPane2.setViewportView(tbVenta); + + btnQuitar.setText("Quitar Producto"); + btnQuitar.setEnabled(false); + btnQuitar.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnQuitarActionPerformed(evt); + } + }); + + btnGnrVenta.setText("Generar Venta"); + btnGnrVenta.setEnabled(false); + btnGnrVenta.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnGnrVentaActionPerformed(evt); + } + }); + + btnBrrVnta.setText("Desechar"); + btnBrrVnta.setEnabled(false); + btnBrrVnta.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnBrrVntaActionPerformed(evt); + } + }); + + jLabel1.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + jLabel1.setText("Producto : "); + + jLabel2.setFont(new java.awt.Font("Dialog", 1, 14)); // NOI18N + jLabel2.setText("TOTAL :"); + + jLabel3.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N + jLabel3.setText("Efectivo :"); + + jLabel4.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N + jLabel4.setText("Vuelto :"); + + btnCalc.setText("Calculadora"); + btnCalc.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnCalcActionPerformed(evt); + } + }); + + jLabel6.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + jLabel6.setText("Cantidad :"); + + jspCant.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + jspCant.setModel(new javax.swing.SpinnerNumberModel(1, 1, null, 1)); + jspCant.setEnabled(false); + + btnNvaVenta.setText("Nueva Venta"); + btnNvaVenta.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnNvaVentaActionPerformed(evt); + } + }); + + jfEfectivo.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(java.text.NumberFormat.getIntegerInstance()))); + jfEfectivo.setHorizontalAlignment(javax.swing.JTextField.CENTER); + jfEfectivo.setEnabled(false); + jfEfectivo.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N + jfEfectivo.addFocusListener(new java.awt.event.FocusAdapter() { + public void focusGained(java.awt.event.FocusEvent evt) { + jfEfectivoFocusGained(evt); + } + }); + jfEfectivo.addKeyListener(new java.awt.event.KeyAdapter() { + public void keyPressed(java.awt.event.KeyEvent evt) { + jfEfectivoKeyPressed(evt); + } + public void keyTyped(java.awt.event.KeyEvent evt) { + jfEfectivoKeyTyped(evt); + } + }); + + btnConsulta.setText("Consulta"); + btnConsulta.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + btnConsultaActionPerformed(evt); + } + }); + + jMenu1.setText("Mantenedores"); + + menuProd.setText("de Productos"); + menuProd.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + menuProdActionPerformed(evt); + } + }); + jMenu1.add(menuProd); + + menuUser.setText("de Usuarios"); + menuUser.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + menuUserActionPerformed(evt); + } + }); + jMenu1.add(menuUser); + + jMenuBar1.add(jMenu1); + + jMenu2.setText("Editor"); + + jMenuItem1.setText("Anular Venta"); + jMenuItem1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jMenuItem1ActionPerformed(evt); + } + }); + jMenu2.add(jMenuItem1); + + jMenuBar1.add(jMenu2); + + jMenu5.setText("Ayuda"); + + acercaDe.setText("Acerca de"); + acercaDe.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + acercaDeActionPerformed(evt); + } + }); + jMenu5.add(acercaDe); + + jMenuBar1.add(jMenu5); + + setJMenuBar(jMenuBar1); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(9, 9, 9) + .addComponent(jLabel1) + .addGap(3, 3, 3) + .addComponent(txtProd, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel6) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jspCant, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 56, Short.MAX_VALUE) + .addComponent(btnQuitar)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(btnCalc) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnConsulta, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(btnNvaVenta) + .addGap(18, 18, 18) + .addComponent(btnBrrVnta, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(txtTotal, javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel3) + .addComponent(jLabel2) + .addComponent(jLabel4)) + .addGap(0, 66, Short.MAX_VALUE)) + .addComponent(jfEfectivo) + .addComponent(txtVuelto) + .addComponent(btnGnrVenta, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(txtProd, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1) + .addComponent(jLabel6)) + .addComponent(jspCant) + .addComponent(btnQuitar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txtTotal, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jfEfectivo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(txtVuelto, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(23, 23, 23))) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(btnGnrVenta, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(btnBrrVnta, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(btnCalc, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnConsulta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(btnNvaVenta, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void menuProdActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuProdActionPerformed + mp.setLocationRelativeTo(null); + mp.setVisible(true); + }//GEN-LAST:event_menuProdActionPerformed + + private void menuUserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuUserActionPerformed + MantenedorUsuarios mu = new MantenedorUsuarios(); + mu.setVisible(true); + mu.setLocationRelativeTo(null); + }//GEN-LAST:event_menuUserActionPerformed + + private void acercaDeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_acercaDeActionPerformed + ImageIcon iconoAyuda = new ImageIcon(getClass().getResource("/imagenes/asia.gif")); + JOptionPane.showMessageDialog(this, "Sistema de Ventas \"LSR\" v1.0\n /** author */\n jp.av.dev@gmail.com\n","Acerca de", JOptionPane.INFORMATION_MESSAGE, iconoAyuda); + }//GEN-LAST:event_acercaDeActionPerformed + + private void btnCalcActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCalcActionPerformed + try { + Runtime rt = Runtime.getRuntime(); + Process p = rt.exec("calc"); + p.waitFor(); + } catch (IOException | InterruptedException ex) { + Logger.getLogger(MenuPrincipal.class.getName()).log(Level.SEVERE, null, ex); + } + }//GEN-LAST:event_btnCalcActionPerformed + + private void txtProdKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtProdKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + if (!"".equals(txtProd.getText())) { + if (!"".equals( (MantenedorProductos.getLp().buscarProducto( txtProd.getText()).getCodigo()) )) { + Producto prodTemp = MantenedorProductos.getLp().buscarProducto(txtProd.getText()); + prodVent = new ProductoVenta(prodTemp.getCodigo(), prodTemp.getDescripcion(), (int)jspCant.getValue(), prodTemp.getPrecio()); + lpv.agregarProdVenta(prodVent); + cargarModeloTablaVenta(lpv.getLpv()); + btnQuitar.setEnabled(true); + } else { + Toolkit.getDefaultToolkit().beep(); + } + txtProd.setText(""); + jspCant.setValue(1); + } else { + Toolkit.getDefaultToolkit().beep(); + } + } + }//GEN-LAST:event_txtProdKeyPressed + + private void btnNvaVentaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNvaVentaActionPerformed + nuevaVenta(); + }//GEN-LAST:event_btnNvaVentaActionPerformed + + private void btnGnrVentaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGnrVentaActionPerformed + try { + generarVenta(); + } catch (Exception ex) { + System.out.println("Excepcion! en generar venta"); // COMPROBAR Y ELIMINAR *********************************** //////////////////////// + } + }//GEN-LAST:event_btnGnrVentaActionPerformed + + private void btnConsultaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConsultaActionPerformed + Producto p = lp.buscarProducto(JOptionPane.showInputDialog(this, "Ingresar Código de producto :", "Consulta Producto", JOptionPane.QUESTION_MESSAGE)); + if (!"".equals(p.getCodigo())) { + JOptionPane.showMessageDialog(this, p.toString(), "Detalle Producto ", JOptionPane.INFORMATION_MESSAGE); + } else { + JOptionPane.showMessageDialog(this, " Producto no existe", "No encontrado",JOptionPane.WARNING_MESSAGE); + } if (txtProd.isEnabled()) { + txtProd.requestFocus(); + } else { + btnNvaVenta.requestFocus(); + } + }//GEN-LAST:event_btnConsultaActionPerformed + + private void jfEfectivoFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jfEfectivoFocusGained + SwingUtilities.invokeLater(() -> { + jfEfectivo.selectAll(); + }); + }//GEN-LAST:event_jfEfectivoFocusGained + + private void btnBrrVntaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrrVntaActionPerformed + TablaVacia(); + txtTotal.setText("$ 0.-"); + productosVenta.clear(); + btnBrrVnta.setEnabled(false); + btnGnrVenta.setEnabled(false); + btnNvaVenta.setEnabled(true); + btnQuitar.setEnabled(false); + txtProd.setEnabled(false); + jspCant.setEnabled(false); + btnNvaVenta.requestFocus(); + jfEfectivo.setEnabled(false); + txtProd.setText(""); + jspCant.setValue(1); + }//GEN-LAST:event_btnBrrVntaActionPerformed + + private void jfEfectivoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jfEfectivoKeyPressed + if (evt.getKeyCode() == KeyEvent.VK_ENTER) { + SwingUtilities.invokeLater(() -> { try {generarVenta();} catch (Exception ex) {} }); + } + }//GEN-LAST:event_jfEfectivoKeyPressed + + private void jfEfectivoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jfEfectivoKeyTyped + char caracter = evt.getKeyChar(); + if(((caracter < '0') || (caracter > '9')) && (caracter != '\b')) { + evt.consume(); // ignorar el evento de teclado + } + }//GEN-LAST:event_jfEfectivoKeyTyped + + private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed + // Al anular una venta id_venta - 1 + }//GEN-LAST:event_jMenuItem1ActionPerformed + + private void btnQuitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitarActionPerformed + if (!"".equals(txtProd.getText())) { + char result = lpv.quitarProdVenta(txtProd.getText()); + switch (result) { + case 'v': // si el array está vacio + btnQuitar.setEnabled(false); + TablaVacia(); + txtTotal.setText("$ 0.-"); + jfEfectivo.setValue(0); + break; + case 'b': // si se eliminó un producto del array + cargarModeloTablaVenta(lpv.getLpv()); + break; + default: // si nó se encontró el producto + Toolkit.getDefaultToolkit().beep(); + txtProd.requestFocus(); + } + } else { + Toolkit.getDefaultToolkit().beep(); + } + txtProd.setText(""); + txtProd.requestFocus(); + }//GEN-LAST:event_btnQuitarActionPerformed + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JMenuItem acercaDe; + private javax.swing.JButton btnBrrVnta; + private javax.swing.JButton btnCalc; + private javax.swing.JButton btnConsulta; + private javax.swing.JButton btnGnrVenta; + private javax.swing.JButton btnNvaVenta; + private javax.swing.JButton btnQuitar; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel6; + private javax.swing.JMenu jMenu1; + private javax.swing.JMenu jMenu2; + private javax.swing.JMenu jMenu3; + private javax.swing.JMenu jMenu4; + private javax.swing.JMenu jMenu5; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JMenuBar jMenuBar2; + private javax.swing.JMenuItem jMenuItem1; + private javax.swing.JMenuItem jMenuItem2; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JTable jTable1; + private javax.swing.JFormattedTextField jfEfectivo; + private javax.swing.JSpinner jspCant; + private javax.swing.JMenuItem menuProd; + private javax.swing.JMenuItem menuUser; + private javax.swing.JTable tbVenta; + private javax.swing.JTextField txtProd; + private javax.swing.JTextField txtTotal; + private javax.swing.JTextField txtVuelto; + // End of variables declaration//GEN-END:variables +} \ No newline at end of file diff --git a/src/imagenes/asia.gif b/src/imagenes/asia.gif new file mode 100644 index 0000000..6585eb8 Binary files /dev/null and b/src/imagenes/asia.gif differ diff --git a/src/imagenes/braingridcircuitboard.png b/src/imagenes/braingridcircuitboard.png new file mode 100644 index 0000000..ec14d88 Binary files /dev/null and b/src/imagenes/braingridcircuitboard.png differ diff --git a/src/modelo/ListaProdsVenta.java b/src/modelo/ListaProdsVenta.java new file mode 100644 index 0000000..87af3d8 --- /dev/null +++ b/src/modelo/ListaProdsVenta.java @@ -0,0 +1,63 @@ +package modelo; /** @author jp.av.dev@gmail.com */ + +import java.util.ArrayList; + + +public class ListaProdsVenta { //El proposito de esta clase es gestionar las cantidades de productos del array... + + private ArrayList<ProductoVenta> lpv; + + public ListaProdsVenta() {} + + public ListaProdsVenta(ArrayList<ProductoVenta> lpv) { + this.lpv = lpv; + } + + public ArrayList<ProductoVenta> getLpv() { + return lpv; + } + + public void setLpv(ArrayList<ProductoVenta> lpv) { + this.lpv = lpv; + } + + public char quitarProdVenta(String codigo) { + char result = 'a'; + for (int i = 0; i < lpv.size(); i++) { + if ( lpv.get(i).getCod().equals(codigo) ) { + lpv.remove(i); + result = 'b'; + } else { + result = 'n'; + } + } + if (lpv.isEmpty()) { + result = 'v'; + } + return result; + } + + public void agregarProdVenta(ProductoVenta prodVenta) { // Busca si existe el producto en el ArrayProductosVenta lpv + boolean nuevo = true; + if (lpv.isEmpty()) { + lpv.add(prodVenta); + } else { + for (int i = 0; i < lpv.size(); i++) { + if ( lpv.get(i).getCod().equals(prodVenta.getCod()) ) { + nuevo = false; + lpv.get(i).setCant(lpv.get(i).getCant() + prodVenta.getCant()); // Si existe suma sus cantidades + } + } if (nuevo == true) { + lpv.add(prodVenta); // Si no existe agrega el productoVenta al ArrayProductosVenta lpv + } + } + } + + @Override + public String toString() { + return "ListaProdsVenta{" + "lpv=" + lpv + '}'; + } + + + +} diff --git a/src/modelo/ListaProductos.java b/src/modelo/ListaProductos.java new file mode 100644 index 0000000..5376af9 --- /dev/null +++ b/src/modelo/ListaProductos.java @@ -0,0 +1,57 @@ +package modelo; /** @author jp.av.dev@gmail.com */ + +import java.util.ArrayList; + + +public class ListaProductos { + + private static ArrayList<Producto> lp; + + public ListaProductos() { + } + + public ListaProductos(ArrayList<Producto> lp) { + ListaProductos.lp = lp; + } + + public ArrayList<Producto> getLp() { + return lp; + } + + public void setLp(ArrayList<Producto> lp) { + ListaProductos.lp = lp; + } + + public void crearProducto(String codigo, String descripcion, int precio, int stock, int stockMin ) { + Producto prod = new Producto(codigo, descripcion, precio, stock, stockMin); + ListaProductos.lp.add(prod); + } + + public Producto buscarProducto(String codigo) { + for (int i = 0; i < lp.size(); i++) { + if ( lp.get(i).getCodigo().equals(codigo) ) { + return lp.get(i); + } + } + Producto productoNoExiste = new Producto("","",0,0,0); + return productoNoExiste; + } + + public boolean eliminarProducto(String codigo) { + return lp.remove(buscarProducto(codigo)); + } + + public boolean editarProducto(Producto editarProd) { + if ( !"".equals((buscarProducto(editarProd.getCodigo())).getCodigo()) ) { + buscarProducto(editarProd.getCodigo()).setDescripcion(editarProd.getDescripcion()); + buscarProducto(editarProd.getCodigo()).setPrecio(editarProd.getPrecio()); + buscarProducto(editarProd.getCodigo()).setStock(editarProd.getStock()); + buscarProducto(editarProd.getCodigo()).setStockMin(editarProd.getStockMin()); + return true; + } else { + return false; + } + } + + +} diff --git a/src/modelo/Producto.java b/src/modelo/Producto.java new file mode 100644 index 0000000..824ec3d --- /dev/null +++ b/src/modelo/Producto.java @@ -0,0 +1,70 @@ +package modelo; /** @author jp.av.dev@gmail.com */ + + +public class Producto { + private String codigo; + private String descripcion; + private int stock; + private int stockMin;// Stock mínimo + private int precio; + + public Producto() { + } + + public Producto(String codigo, String descripcion, int precio, int stock, int stockMin) { + this.codigo = codigo; + this.descripcion = descripcion; + this.precio = precio; + this.stock = stock; + this.stockMin = stockMin; + } + + + @Override + public String toString() { + return "Producto Código: " + codigo + "\nDescripcion: " + descripcion + "\nPrecio: $ " + precio + ".-"+ "\nStock Actual: " + stock + "\nStock Mínimo: " + stockMin; + } + + public String getCodigo() { + return codigo; + } + + public void setCodigo(String codigo) { + this.codigo = codigo; + } + + public String getDescripcion() { + return descripcion; + } + + public void setDescripcion(String descripcion) { + this.descripcion = descripcion; + } + + public int getStock() { + return stock; + } + + public void setStock(int stock) { + this.stock = stock; + } + + public int getStockMin() { + return stockMin; + } + + public void setStockMin(int stockMin) { + this.stockMin = stockMin; + } + + public int getPrecio() { + return precio; + } + + public void setPrecio(int precio) { + this.precio = precio; + } + + + +} \ No newline at end of file diff --git a/src/modelo/ProductoVenta.java b/src/modelo/ProductoVenta.java new file mode 100644 index 0000000..add55ac --- /dev/null +++ b/src/modelo/ProductoVenta.java @@ -0,0 +1,55 @@ +package modelo; /** @author jp.av.dev@gmail.com */ + +public class ProductoVenta { + private String cod; + private String descrip; + private int cant; + private int precio; + + public ProductoVenta(String cod, String descrip, int cant, int precio) { + this.cod = cod; + this.descrip = descrip; + this.cant = cant; + this.precio = precio; + } + + @Override + public String toString() { + return "\bItem Código: " + cod +"\n"+ descrip + "\nDetalle: " + cant + " x $ " + precio + ".-\n\n"; + } + + public String getCod() { + return cod; + } + + public void setCod(String cod) { + this.cod = cod; + } + + public String getDescrip() { + return descrip; + } + + public void setDescrip(String descrip) { + this.descrip = descrip; + } + + public int getCant() { + return cant; + } + + public void setCant(int cant) { + this.cant = cant; + } + + public int getPrecio() { + return precio; + } + + public void setPrecio(int precio) { + this.precio = precio; + } + + + +} diff --git a/src/modelo/Usuario.java b/src/modelo/Usuario.java new file mode 100644 index 0000000..576d6b0 --- /dev/null +++ b/src/modelo/Usuario.java @@ -0,0 +1,22 @@ +package modelo; /** @author jp.av.dev@gmail.com */ + +import java.util.ArrayList; + + +public class Usuario { + + String nombre; + char[] pass; + ArrayList<Usuario> ListaUsuarios = new ArrayList<>(); + + public Usuario(String nombre, char[] pass) { + this.nombre = nombre; + this.pass = pass; + addUser(this); + } + + public void addUser(Usuario user) { + ListaUsuarios.add(user); + } + +} diff --git a/src/modelo/Venta.java b/src/modelo/Venta.java new file mode 100644 index 0000000..15be949 --- /dev/null +++ b/src/modelo/Venta.java @@ -0,0 +1,72 @@ +package modelo; /** @author jp.av.dev@gmail.com */ + +import java.util.ArrayList; +import java.util.Calendar; + + +public class Venta { + + private ArrayList<ProductoVenta> ProductosVenta; + private int total; + private final String fecha; + private int efectivo; + private final String usuario; + private static int idVenta = 0; + + public Venta(ArrayList<ProductoVenta> ProductosVenta, String usuario) { + this.ProductosVenta = ProductosVenta; + this.total = 0; + this.efectivo = 0; + this.fecha = (Calendar.getInstance().getTime().toString()).replace("CLST", ""); + this.usuario = usuario; + Venta.idVenta = ++idVenta; + } + + public void setProductosVenta(ArrayList<ProductoVenta> ProductosVenta) { + this.ProductosVenta = ProductosVenta; + } + + public void setTotal(int total) { + this.total = total; + } + + public void setEfectivo(int efectivo) { + this.efectivo = efectivo; + } + + public ArrayList<ProductoVenta> getProductosVenta() { + return ProductosVenta; + } + + public int getTotal() { + return total; + } + + public String getFecha() { + return fecha; + } + + public int getEfectivo() { + return efectivo; + } + + public String getUsuario() { + return usuario; + } + + @Override + public String toString() { + return "Venta N° "+ idVenta +" Vend. "+ usuario +"\n"+ fecha +"\n______________________________\n"+ + "\nProductos :\n," + + ProductosVenta + "\b" + + "\n\tTOTAL = $ "+ total +".-\n\n"+ + "Monto Cancelado = $ "+ efectivo +".-\n"+ + "Vuelto = $ "+ (efectivo - total) +".-\n______________________________\n"+ + "Gracias por preferirnos.\nHasta pronto!\n\n"; + } + + public int getIdVenta() { + return idVenta; + } + +} diff --git a/src/sistema_de_ventas_lsr/Sistema_de_Ventas_LSR.java b/src/sistema_de_ventas_lsr/Sistema_de_Ventas_LSR.java new file mode 100644 index 0000000..6aa0ebd --- /dev/null +++ b/src/sistema_de_ventas_lsr/Sistema_de_Ventas_LSR.java @@ -0,0 +1,23 @@ +package sistema_de_ventas_lsr; /** @author jp.av.dev@gmail.com */ + +import Vista.LogInUser; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.UIManager; +import javax.swing.UnsupportedLookAndFeelException; + + +public class Sistema_de_Ventas_LSR { + + public static void main(String[] args) { + LogInUser p = new LogInUser(); + p.setVisible(true); + p.setLocationRelativeTo(null); + try { + UIManager.setLookAndFeel("com.jtattoo.plaf.aluminium.AluminiumLookAndFeel");//aluminium.AluminiumLookAndFeel //hifi.HiFiLookAndFeel //noire.NoireLookAndFeel //acryl.AcrylLookAndFeel //graphite.GraphiteLookAndFeel //texture.TextureLookAndFeel //luna.LunaLookAndFeel //smart.SmartLookAndFeel //mint.MintLookAndFeel //mcwin.McWinLookAndFeel + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { + Logger.getLogger(Sistema_de_Ventas_LSR.class.getName()).log(Level.SEVERE, null, ex); + } + } + +}