5.0 Source Code

Committing 5.0 Source Code
This commit is contained in:
2023-04-06 18:58:04 +01:00
parent 0f3ede77fa
commit 0282345603
1680 changed files with 241310 additions and 0 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="750" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="500" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
</Form>
@@ -0,0 +1,53 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
// CSV Import Panel added by JDL - February 2013
// Additonal library required - javacsv
package com.unicenta.pos.imports;
public class JPanelCSV extends javax.swing.JPanel {
public JPanelCSV() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 750, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 500, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}
@@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[450, 240]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Group type="102" attributes="0">
<Component id="jEnableButton" pref="0" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jBtnCleardb" min="-2" pref="218" max="-2" attributes="0"/>
</Group>
<Component id="jScrollPane1" min="-2" pref="400" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" pref="127" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jBtnCleardb" min="-2" max="-2" attributes="0"/>
<Component id="jEnableButton" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.csvresetimport" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[250, 30]"/>
</Property>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextPane" name="jMessageBox">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JCheckBox" name="jEnableButton">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.csvenableclear" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[250, 30]"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="jEnableButtonStateChanged"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jEnableButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jBtnCleardb">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/unicenta/images/sale_delete.png"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.clearimport" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="actionCommand" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.csvclearlog" replaceFormat="AppLocal.getIntString(&quot;button.exit&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[160, 45]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBtnCleardbActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>
@@ -0,0 +1,238 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
// CSV Import Panel added by JDL - February 2013
// Additonal library required - javacsv
package com.unicenta.pos.imports;
import com.unicenta.basic.BasicException;
import com.unicenta.pos.forms.*;
import com.unicenta.pos.util.AltEncrypter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import javax.swing.*;
public class JPanelCSVCleardb extends JPanel implements JPanelView {
private Connection con;
private Statement stmt;
private String SQL;
private AppConfig config;
/**
*
* @param oApp
*/
public JPanelCSVCleardb(AppView oApp) {
this(oApp.getProperties());
}
/**
*
* @param props
*/
public JPanelCSVCleardb(AppProperties props) {
initComponents();
config = new AppConfig(props.getConfigFile());
config.load();
jMessageBox.setText("Performing this action, will clear all "
+ "data in the CSVImport table. \n\n"
+ "It is recommended that this is performed before "
+ "running a new import. \n");
}
/**
*
* @return
*/
@Override
public String getTitle() {
return AppLocal.getIntString("Menu.CSVReset");
}
/**
*
* @return
*/
@Override
public JComponent getComponent() {
return this;
}
/**
*
* @throws BasicException
*/
@Override
public void activate() throws BasicException {
String db_user =(config.getProperty("db.user"));
String db_url = (config.getProperty("db.URL"));
String db_password = (config.getProperty("db.password"));
if (db_user != null && db_password != null && db_password.startsWith("crypt:")) {
AltEncrypter cypher = new AltEncrypter("cypherkey" + db_user);
db_password = cypher.decrypt(db_password.substring(6));
}
try{
con = DriverManager.getConnection(db_url,db_user,db_password);
stmt = (Statement) con.createStatement();
} catch (Exception e) {
}
}
/**
*
* @return
*/
@Override
public boolean deactivate() {
try{
stmt.close();
con.close();
}catch (Exception e){}
return (true);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jMessageBox = new javax.swing.JTextPane();
jEnableButton = new javax.swing.JCheckBox();
jBtnCleardb = new javax.swing.JButton();
setPreferredSize(new java.awt.Dimension(450, 240));
jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N
jLabel1.setText(bundle.getString("label.csvresetimport")); // NOI18N
jLabel1.setPreferredSize(new java.awt.Dimension(250, 30));
jMessageBox.setEditable(false);
jMessageBox.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jScrollPane1.setViewportView(jMessageBox);
jEnableButton.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jEnableButton.setText(bundle.getString("label.csvenableclear")); // NOI18N
jEnableButton.setPreferredSize(new java.awt.Dimension(250, 30));
jEnableButton.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
jEnableButtonStateChanged(evt);
}
});
jEnableButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jEnableButtonActionPerformed(evt);
}
});
jBtnCleardb.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jBtnCleardb.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/sale_delete.png"))); // NOI18N
jBtnCleardb.setText(bundle.getString("label.clearimport")); // NOI18N
jBtnCleardb.setActionCommand(AppLocal.getIntString("button.exit")); // NOI18N
jBtnCleardb.setEnabled(false);
jBtnCleardb.setPreferredSize(new java.awt.Dimension(160, 45));
jBtnCleardb.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jBtnCleardbActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addGap(16, 16, 16)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(jEnableButton, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jBtnCleardb, javax.swing.GroupLayout.PREFERRED_SIZE, 218, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jBtnCleardb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jEnableButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void jEnableButtonStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jEnableButtonStateChanged
if (jEnableButton.isSelected()){
jBtnCleardb.setEnabled(true);
}else {
jBtnCleardb.setEnabled(false);
}
}//GEN-LAST:event_jEnableButtonStateChanged
private void jBtnCleardbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnCleardbActionPerformed
SQL="DELETE FROM csvimport";
try{
stmt.executeUpdate(SQL);
}catch (Exception e){
}
}//GEN-LAST:event_jBtnCleardbActionPerformed
private void jEnableButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jEnableButtonActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jEnableButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jBtnCleardb;
private javax.swing.JCheckBox jEnableButton;
private javax.swing.JLabel jLabel1;
private javax.swing.JTextPane jMessageBox;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,443 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="opaque" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[700, 350]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jFileChooserPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="m_jLocation" min="-2" pref="295" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="jFileRead" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jImport" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jbtnReset" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="webPBar" min="-2" pref="284" max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jFileChooserPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="m_jLocation" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jFileRead" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jImport" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jbtnReset" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="webPBar" min="-2" pref="32" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
<Component id="jLabel2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jFileChooserPanel">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel1" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jFileName" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel18" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jComboSeparator" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jbtnFileChoose" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jFileName" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel18" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jComboSeparator" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jbtnFileChoose" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.csvfile" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 30]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jFileName">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[300, 30]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jFileNameActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel18">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.csvdelimit" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 30]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jbtnFileChoose">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
<Image iconType="3" name="/com/unicenta/images/fileopen.png"/>
</Property>
<Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[64, 32]"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[64, 32]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[80, 45]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnFileChooseActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JComboBox" name="jComboSeparator">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[50, 30]"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="jFileRead">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.csvread" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[85, 45]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jFileReadActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_SerializeTo" type="java.lang.String" value="JPanelCSVSelect_jHeaderRead"/>
</AuxValues>
</Component>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Status">
<Border PropertyName="innerBorder" info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder roundedCorners="true">
<Color PropertyName="color" blue="99" green="99" red="99" type="rgb"/>
</LineBorder>
</Border>
<ResourceString PropertyName="titleX" bundle="pos_messages.properties" key="title.CSVImport" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
<Font PropertyName="font" name="Arial" size="14" style="1"/>
<Color PropertyName="color" blue="66" green="66" red="66" type="rgb"/>
</TitledBorder>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel9" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jTextRecords" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jTextUpdates" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jTextUpdate" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jTextRecords" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jTextUpdates" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jTextUpdate" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="47" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.csvrecordsfound" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[150, 30]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jTextUpdates">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.csvchanged" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[150, 30]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTextRecords">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="66" green="66" red="66" type="rgb"/>
</Property>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="0" type="rgb"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 30]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTextUpdate">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="66" green="66" red="66" type="rgb"/>
</Property>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="0" type="rgb"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 30]"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="com.alee.laf.progressbar.WebProgressBar" name="webPBar">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="13" style="0"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[240, 30]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="m_jLocation">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.location" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 30]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="jImport">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.csvimpostbtn" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[85, 45]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jImportActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jbtnReset">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="button.reset" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[85, 45]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jbtnResetActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="ff" green="ff" red="ff" type="rgb"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="12" style="0"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="pos_messages.properties" key="label.csvnotice" replaceFormat="java.util.ResourceBundle.getBundle(&quot;{bundleNameSlashes}&quot;).getString(&quot;{key}&quot;)"/>
</Property>
<Property name="verticalAlignment" type="int" value="1"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
<LineBorder>
<Color PropertyName="color" blue="99" green="99" red="99" type="rgb"/>
</LineBorder>
</Border>
</Property>
<Property name="opaque" type="boolean" value="true"/>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[710, 110]"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form>
@@ -0,0 +1,897 @@
// uniCenta oPOS - Touch Friendly Point Of Sale
// Copyright (c) 2009-2018 uniCenta
// https://unicenta.com
//
// This file is part of uniCenta oPOS
//
// uniCenta oPOS is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// uniCenta oPOS is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with uniCenta oPOS. If not, see <http://www.gnu.org/licenses/>.
package com.unicenta.pos.imports;
import com.csvreader.CsvReader;
import com.unicenta.basic.BasicException;
import com.unicenta.data.loader.Datas;
import com.unicenta.data.loader.PreparedSentence;
import com.unicenta.data.loader.SerializerWriteBasicExt;
import com.unicenta.data.loader.Session;
import com.unicenta.pos.forms.*;
import com.unicenta.pos.inventory.ProductStock;
import com.unicenta.pos.ticket.ProductInfoExt;
import lombok.extern.slf4j.Slf4j;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Properties;
import java.util.UUID;
/**
* User Interface and code for CSV type data import to update Products
* Current Stock quantity levels in table: stockcurrent
*/
@Slf4j
public class StockQtyImport extends JPanel implements JPanelView {
// the workspace
private AppProperties m_props;
private Properties m_propsdb = null;
private CsvReader products;
private DocumentListener documentListener;
// the db connection session
private Session s;
private Connection con;
private DataLogicSales m_dlSales;
private DataLogicSystem m_dlSystem;
private ProductInfoExt prodInfo;
private ProductStock prodStock;
// Location
private String Location = "0";
private String m_sInventoryLocation;
// Product properties
private String productBarcode;
private Double productQty;
private double oldQty = 0;
private double newQty = 0;
private String recordType = null;
// the csv filename
private String last_folder;
private File config_file;
private String csvFileName;
//Status area messages
private Integer progress = 0;
private int currentRecord;
private int rowCount = 0;
private int qtyUpdates = 0;
/**
* Constructs a new StockQtyImport object
*
* @param oApp AppView
*/
public StockQtyImport(AppView oApp) {
this(oApp.getProperties());
}
/**
* Constructs a new StockQtyImport object
*
* @param props AppProperties
*/
@SuppressWarnings("empty-statement")
public StockQtyImport(AppProperties props) {
initComponents();
// Get current db session connection
AppProperties m_props = props;
try {
s = AppViewConnection.createSession(props);
con = s.getConnection();
} catch (BasicException | SQLException e) {
;
}
// Set db tables
m_dlSales = new DataLogicSales();
m_dlSales.init(s);
m_dlSystem = new DataLogicSystem();
m_dlSystem.init(s);
// Get terminal's current resource property settings
Properties m_propsdb = m_dlSystem.getResourceAsProperties(m_props.getHost() + "/properties");
// Get terminal's set Location property <entry key="location">0</entry>
m_sInventoryLocation = m_propsdb.getProperty("location");
try {
Location = m_dlSystem.findLocationName(m_sInventoryLocation);
} catch (BasicException ex) {
log.error(ex.getMessage());
}
// last used folder stored in unicentaopos.properties
last_folder = props.getProperty("CSV.last_folder");
config_file = props.getConfigFile();
jFileName.getDocument().addDocumentListener(documentListener);
documentListener = new DocumentListener() {
@Override
public void changedUpdate(DocumentEvent documentEvent) {
jFileRead.setEnabled(true);
}
@Override
public void insertUpdate(DocumentEvent documentEvent) {
if (!"".equals(jFileName.getText().trim())) {
jFileRead.setEnabled(true);
}
}
@Override
public void removeUpdate(DocumentEvent documentEvent) {
if (jFileName.getText().trim().equals("")) {
jFileRead.setEnabled(false);
}
}
};
}
/**
* Enables form components
*/
private void enableForm() {
jFileRead.setEnabled(true);
jImport.setEnabled(true);
jbtnReset.setEnabled(true);
m_jLocation.setEnabled(true);
}
/**
* This forms Title
*
* @return The name of the panel
*/
@Override
public String getTitle() {
return AppLocal.getIntString("Menu.CSVImport");
}
/**
* Returns this object
*
* @return
*/
@Override
public JComponent getComponent() {
return this;
}
/**
* Get this form object ready
*
* @throws com.unicenta.basic.BasicException
*/
@Override
public void activate() throws BasicException {
// Current Location
m_jLocation.setText("Current Location : " + Location);
// Set the column delimiter
jComboSeparator.removeAllItems();
jComboSeparator.addItem(",");
jComboSeparator.addItem(";");
jComboSeparator.addItem("~");
jComboSeparator.addItem("^");
}
/**
* Resets all the form fields
*/
public void resetForm() {
m_jLocation.setEnabled(false);
jImport.setEnabled(false);
jbtnReset.setEnabled(true);
jFileRead.setEnabled(false);
jFileName.setText(null);
csvFileName = "";
// Status area
progress = 0;
webPBar.setValue(progress);
jTextUpdate.setText("");
jTextRecords.setText("");
qtyUpdates = 0;
}
/**
* Deactivates and resets all form fields.
*
* @return
*/
@Override
public boolean deactivate() {
resetForm();
return (true);
}
/**
* Check file can be opened, read and closed
* No Headers in the CSVFileName are required,
*
* @param CSVFileName Name of the file (including the path) to open and read
* @throws IOException If there is an issue reading the CSV file
*/
private void checkFile(String CSVFileName) throws IOException {
File f = new File(CSVFileName);
if (f.exists()) {
products = new CsvReader(CSVFileName, ',', Charset.forName("UTF-8"));
products.setDelimiter(((String) jComboSeparator.getSelectedItem()).charAt(0));
rowCount = 0;
int i = 0;
while (products.readRecord()) {
++rowCount;
}
jTextRecords.setText(Long.toString(rowCount));
products.close();
JOptionPane.showMessageDialog(null, "File Check "
+ CSVFileName,
"File read OK",
JOptionPane.WARNING_MESSAGE);
enableForm();
} else {
JOptionPane.showMessageDialog(null, "Unable to locate "
+ CSVFileName,
"File not found",
JOptionPane.WARNING_MESSAGE);
}
}
/**
* Imports the external file
*
* @param CSVFileName Name of the file (including path) to import.
* @throws IOException If there are file reading issues.
*/
private void ImportCsvFile(String CSVFileName) throws IOException {
File f = new File(CSVFileName);
if (f.exists()) {
webPBar.setString("Starting...");
webPBar.setVisible(true);
jImport.setEnabled(true);
// Read file
products = new CsvReader(CSVFileName, ',', Charset.forName("UTF-8"));
products.setDelimiter(((String) jComboSeparator.getSelectedItem()).charAt(0));
currentRecord = 0;
// Prime: read the csv record and update to zero matching stockcurrent values
while (products.readRecord()) {
recordType = "delete";
deleteRecord(recordType);
}
products.close();
// Work: read the file again and update stockcurrent values
products = new CsvReader(CSVFileName, ',', Charset.forName("UTF-8"));
products.setDelimiter(((String) jComboSeparator.getSelectedItem()).charAt(0));
currentRecord = 0;
while (products.readRecord()) {
currentRecord++;
progress = currentRecord;
recordType = "update";
updateRecord(recordType);
}
products.close();
} else {
JOptionPane.showMessageDialog(null,
"Unable to locate "
+ CSVFileName,
"File not found",
JOptionPane.WARNING_MESSAGE);
}
jTextUpdate.setText(Integer.toString(qtyUpdates));
JOptionPane.showMessageDialog(null,
"Import Complete",
"Imported",
JOptionPane.WARNING_MESSAGE);
progress = 100;
webPBar.setValue(progress);
webPBar.setString("Imported" + progress);
}
/**
* Update the record in the database with the new Quantities
*
* @param pId Unique product id of the record to be updated
*/
private void updateRecord(String pId) throws IOException {
prodInfo = new ProductInfoExt();
prodStock = new ProductStock();
try {
String sCode = products.get(0);
prodInfo = m_dlSales.getProductInfoByCode(sCode);
if (prodInfo != null) {
prodStock = m_dlSales.getProductStockState(prodInfo.getID(), m_sInventoryLocation);
productBarcode = products.get(0);
oldQty = prodStock.getUnits();
newQty = Double.valueOf(products.get(1));
productQty = oldQty + newQty;
updateStockCurrent(m_sInventoryLocation, prodInfo.getID(), productQty);
CSVStockUpdate(Location, productBarcode, newQty);
qtyUpdates++;
}
} catch (BasicException ex) {
log.error(ex.getMessage());
}
}
/**
* Delete the record in the database with the new Quantities
*
* @param pId Unique product id of the record to be updated
*/
private void deleteRecord(String pId) throws IOException {
prodInfo = new ProductInfoExt();
prodStock = new ProductStock();
try {
String sCode = products.get(0);
prodInfo = m_dlSales.getProductInfoByCode(sCode);
if (prodInfo != null) {
prodStock = m_dlSales.getProductStockState(prodInfo.getID(), m_sInventoryLocation);
productQty = 0.;
deleteStockCurrent(m_sInventoryLocation, prodInfo.getID(), productQty);
}
} catch (BasicException ex) {
log.error(ex.getMessage());
}
}
/**
* FUTURE - Add non existing minimal Products
*
* @param LocationID
* @param ProductID
* @param Units
* @throws com.unicenta.basic.BasicException
*/
public void addStockCurrent(String LocationID, String ProductID, Double Units) throws BasicException {
Object[] values = new Object[3];
values[0] = LocationID;
values[1] = ProductID;
values[2] = (double) Units;
PreparedSentence sentence = new PreparedSentence(s,
"INSERT INTO stockcurrent ( "
+ "LOCATION, PRODUCT, UNITS) VALUES (?, ?, ?)"
, new SerializerWriteBasicExt((new Datas[]{
Datas.STRING,
Datas.STRING,
Datas.DOUBLE
}),
new int[]{0, 1, 2
}));
sentence.exec(values);
}
/**
* Update existing Product Current Quantity
*
* @param LocationID
* @param ProductID
* @param Units
* @throws com.unicenta.basic.BasicException
*/
public void updateStockCurrent(String LocationID, String ProductID, Double Units) throws BasicException {
Object[] newValues = new Object[3];
newValues[0] = (double) Units;
newValues[1] = LocationID;
newValues[2] = ProductID;
PreparedSentence sentence = new PreparedSentence(s,
"UPDATE stockcurrent SET "
+ "UNITS = ? "
+ "WHERE LOCATION = ? "
+ "AND PRODUCT = ?"
, new SerializerWriteBasicExt((new Datas[]{
Datas.DOUBLE,
Datas.STRING,
Datas.STRING
}),
new int[]{
0, 1, 2}
));
sentence.exec(newValues);
}
/**
* Reset existing Product Current Quantity to Zero
*
* @param LocationID
* @param ProductID
* @param Units
* @throws com.unicenta.basic.BasicException
*/
public void deleteStockCurrent(String LocationID, String ProductID, Double Units) throws BasicException {
Object[] oldValues = new Object[3];
oldValues[0] = (double) Units;
oldValues[1] = LocationID;
oldValues[2] = ProductID;
PreparedSentence sentence = new PreparedSentence(s,
"UPDATE stockcurrent SET "
+ "UNITS = ? "
+ "WHERE LOCATION = ? "
+ "AND PRODUCT = ?"
, new SerializerWriteBasicExt((new Datas[]{
Datas.DOUBLE,
Datas.STRING,
Datas.STRING
}),
new int[]{
0, 1, 2}
));
sentence.exec(oldValues);
}
/**
* Add Product Update log entry - Updates only
*
* @param LocationID
* @param Units
*/
public void CSVStockUpdate(String LocationID, String Code, Double Units) {
Object[] myprod = new Object[6];
myprod[0] = UUID.randomUUID().toString(); // ID string
myprod[1] = Integer.toString(currentRecord); // Record number
myprod[2] = "Qty update"; // Error description
myprod[3] = Location; // Location ID
myprod[4] = productBarcode; // Product Barcode
myprod[5] = newQty; // Product Quantity
try {
m_dlSystem.execCSVStockUpdate(myprod);
} catch (BasicException ex) {
log.error(ex.getMessage());
}
}
/**
* Pushes the Import process into a new thread so it doesn't interfere with
* the UI responsiveness.
*/
private void setWorker() {
progress = 0;
webPBar.setStringPainted(true);
final SwingWorker<Integer, Integer> pbWorker;
pbWorker = new SwingWorker<Integer, Integer>() {
@Override
protected final Integer doInBackground() throws Exception {
while ((progress >= 0) && (progress < 100)) {
Thread.sleep(50);
this.publish(progress);
}
this.publish(100);
this.done();
return 100;
}
@Override
protected final void process(final List<Integer> chunks) {
webPBar.setValue(chunks.get(0));
if (progress > 100) {
progress = 100;
webPBar.setString("Imported 100%");
} else {
webPBar.setString("Imported " + progress + "%");
}
}
};
pbWorker.execute();
}
/**
* Runs the setWorker.
*/
private class workProcess implements Runnable {
@Override
public void run() {
try {
ImportCsvFile(jFileName.getText());
} catch (IOException ex) {
log.error(ex.getMessage());
}
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jFileChooserPanel = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jFileName = new javax.swing.JTextField();
jLabel18 = new javax.swing.JLabel();
jbtnFileChoose = new javax.swing.JButton();
jComboSeparator = new javax.swing.JComboBox();
jFileRead = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
jLabel9 = new javax.swing.JLabel();
jTextUpdates = new javax.swing.JLabel();
jTextRecords = new javax.swing.JTextField();
jTextUpdate = new javax.swing.JTextField();
webPBar = new com.alee.laf.progressbar.WebProgressBar();
m_jLocation = new javax.swing.JLabel();
jImport = new javax.swing.JButton();
jbtnReset = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
setOpaque(false);
setPreferredSize(new java.awt.Dimension(700, 350));
jLabel1.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle("pos_messages"); // NOI18N
jLabel1.setText(bundle.getString("label.csvfile")); // NOI18N
jLabel1.setPreferredSize(new java.awt.Dimension(100, 30));
jFileName.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jFileName.setPreferredSize(new java.awt.Dimension(300, 30));
jFileName.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jFileNameActionPerformed(evt);
}
});
jLabel18.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jLabel18.setText(bundle.getString("label.csvdelimit")); // NOI18N
jLabel18.setPreferredSize(new java.awt.Dimension(100, 30));
jbtnFileChoose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/unicenta/images/fileopen.png"))); // NOI18N
jbtnFileChoose.setMaximumSize(new java.awt.Dimension(64, 32));
jbtnFileChoose.setMinimumSize(new java.awt.Dimension(64, 32));
jbtnFileChoose.setPreferredSize(new java.awt.Dimension(80, 45));
jbtnFileChoose.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnFileChooseActionPerformed(evt);
}
});
jComboSeparator.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jComboSeparator.setPreferredSize(new java.awt.Dimension(50, 30));
javax.swing.GroupLayout jFileChooserPanelLayout = new javax.swing.GroupLayout(jFileChooserPanel);
jFileChooserPanel.setLayout(jFileChooserPanelLayout);
jFileChooserPanelLayout.setHorizontalGroup(
jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jFileChooserPanelLayout.createSequentialGroup()
.addGroup(jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jFileChooserPanelLayout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jFileName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jFileChooserPanelLayout.createSequentialGroup()
.addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jbtnFileChoose, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jFileChooserPanelLayout.setVerticalGroup(
jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jFileChooserPanelLayout.createSequentialGroup()
.addGroup(jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jFileName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jFileChooserPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboSeparator, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jbtnFileChoose, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jFileRead.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jFileRead.setText(bundle.getString("label.csvread")); // NOI18N
jFileRead.setEnabled(false);
jFileRead.setPreferredSize(new java.awt.Dimension(85, 45));
jFileRead.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jFileReadActionPerformed(evt);
}
});
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 153, 153), 1, true), bundle.getString("title.CSVImport"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 1, 14), new java.awt.Color(102, 102, 102))); // NOI18N
jLabel9.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jLabel9.setText(bundle.getString("label.csvrecordsfound")); // NOI18N
jLabel9.setPreferredSize(new java.awt.Dimension(150, 30));
jTextUpdates.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jTextUpdates.setText(bundle.getString("label.csvchanged")); // NOI18N
jTextUpdates.setPreferredSize(new java.awt.Dimension(150, 30));
jTextRecords.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jTextRecords.setForeground(new java.awt.Color(102, 102, 102));
jTextRecords.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextRecords.setBorder(null);
jTextRecords.setDisabledTextColor(new java.awt.Color(0, 0, 0));
jTextRecords.setEnabled(false);
jTextRecords.setPreferredSize(new java.awt.Dimension(100, 30));
jTextUpdate.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
jTextUpdate.setForeground(new java.awt.Color(102, 102, 102));
jTextUpdate.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
jTextUpdate.setBorder(null);
jTextUpdate.setDisabledTextColor(new java.awt.Color(0, 0, 0));
jTextUpdate.setEnabled(false);
jTextUpdate.setPreferredSize(new java.awt.Dimension(100, 30));
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextRecords, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jTextUpdates, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTextUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(0, 0, 0)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextRecords, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTextUpdates, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTextUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(47, 47, 47))
);
webPBar.setFont(new java.awt.Font("Arial", 0, 13)); // NOI18N
webPBar.setPreferredSize(new java.awt.Dimension(240, 30));
m_jLocation.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
m_jLocation.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
m_jLocation.setText(bundle.getString("label.location")); // NOI18N
m_jLocation.setPreferredSize(new java.awt.Dimension(100, 30));
jImport.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jImport.setText(bundle.getString("label.csvimpostbtn")); // NOI18N
jImport.setEnabled(false);
jImport.setPreferredSize(new java.awt.Dimension(85, 45));
jImport.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jImportActionPerformed(evt);
}
});
jbtnReset.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jbtnReset.setText(bundle.getString("button.reset")); // NOI18N
jbtnReset.setPreferredSize(new java.awt.Dimension(85, 45));
jbtnReset.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnResetActionPerformed(evt);
}
});
jLabel2.setBackground(new java.awt.Color(255, 255, 255));
jLabel2.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
jLabel2.setText(bundle.getString("label.csvnotice")); // NOI18N
jLabel2.setVerticalAlignment(javax.swing.SwingConstants.TOP);
jLabel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(153, 153, 153)));
jLabel2.setOpaque(true);
jLabel2.setPreferredSize(new java.awt.Dimension(710, 110));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jFileChooserPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, 0)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(m_jLocation, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jFileRead, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jImport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(webPBar, javax.swing.GroupLayout.PREFERRED_SIZE, 284, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jFileChooserPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(m_jLocation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jFileRead, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jImport, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jbtnReset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(webPBar, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(10, 10, 10)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void jFileReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileReadActionPerformed
try {
checkFile(jFileName.getText());
webPBar.setString("Source file OK");
m_jLocation.setEnabled(true);
} catch (IOException ex) {
log.error(ex.getMessage());
webPBar.setString("Source file error!");
m_jLocation.setEnabled(false);
}
}//GEN-LAST:event_jFileReadActionPerformed
private void jFileNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileNameActionPerformed
jImport.setEnabled(false);
jFileRead.setEnabled(true);
}//GEN-LAST:event_jFileNameActionPerformed
private void jbtnFileChooseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnFileChooseActionPerformed
resetForm();
setWorker();
JFileChooser chooser = new JFileChooser(last_folder == null ? "C:\\" : last_folder);
FileNameExtensionFilter filter = new FileNameExtensionFilter("csv files", "csv");
chooser.setFileFilter(filter);
chooser.showOpenDialog(null);
File csvFile = chooser.getSelectedFile();
if (csvFile == null) {
return;
}
File current_folder = chooser.getCurrentDirectory();
if (last_folder == null || !last_folder.equals(current_folder.getAbsolutePath())) {
AppConfig CSVConfig = new AppConfig(config_file);
CSVConfig.load();
CSVConfig.setProperty("CSV.last_folder", current_folder.getAbsolutePath());
last_folder = current_folder.getAbsolutePath();
try {
CSVConfig.save();
} catch (IOException ex) {
log.error(ex.getMessage());
}
}
String csv = csvFile.getName();
if (!(csv.trim().equals(""))) {
csvFileName = csvFile.getAbsolutePath();
jFileName.setText(csvFileName);
jFileRead.setEnabled(true);
}
}//GEN-LAST:event_jbtnFileChooseActionPerformed
private void jbtnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnResetActionPerformed
resetForm();
progress = 0;
webPBar.setString("Waiting...");
}//GEN-LAST:event_jbtnResetActionPerformed
private void jImportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jImportActionPerformed
jFileRead.setEnabled(false);
jImport.setEnabled(false);
workProcess work = new workProcess();
Thread thread2 = new Thread(work);
thread2.start();
}//GEN-LAST:event_jImportActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox jComboSeparator;
private javax.swing.JPanel jFileChooserPanel;
private javax.swing.JTextField jFileName;
private javax.swing.JButton jFileRead;
private javax.swing.JButton jImport;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel2;
private javax.swing.JTextField jTextRecords;
private javax.swing.JTextField jTextUpdate;
private javax.swing.JLabel jTextUpdates;
private javax.swing.JButton jbtnFileChoose;
private javax.swing.JButton jbtnReset;
private javax.swing.JLabel m_jLocation;
private com.alee.laf.progressbar.WebProgressBar webPBar;
// End of variables declaration//GEN-END:variables
}