package de.nplusc.upidgen;




import de.nplusc.izc.tools.IOtools.DBWriter;
import de.nplusc.izc.tools.baseTools.Tools;
import java.util.HashMap;
import javax.swing.DefaultListModel;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Ifatzeh.java
 *
 * Created on 01.12.2011, 18:47:36
 */
/**
 *
 * @author LH
 */
public class IfatzehChgFlag extends javax.swing.JFrame {
        HashMap<String,String> flags  = new  HashMap<>();
        HashMap<String,String> upid   = new  HashMap<>();
        HashMap<String,String> values = new  HashMap<>();
        private static DBWriter dbc = PublicStorage.dbc;
    /** Creates new form Ifatzeh */
    public IfatzehChgFlag() {
        initComponents();
        pPreview.setVisible(false);
        tpOVW.setEnabledAt(1,false);
        tpReadV2.setVisible(false);
        tpReadV1.setVisible(false);
        btnRefreshActionPerformed(null);
        cXoverride.setVisible(false);
        btnEnabOVR.setVisible(false);
    }
    String[] FlagsAvail = {"SRC","VIT","NSE1","NSE2","ALZR","Arights","Nonsellable","gaveAway","MDFY"};
    boolean Version1 = false;
    /** 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() {

        VIT1BG = new javax.swing.ButtonGroup();
        NSE1BG = new javax.swing.ButtonGroup();
        NSE2BG = new javax.swing.ButtonGroup();
        ALZRBG = new javax.swing.ButtonGroup();
        ArightsBG = new javax.swing.ButtonGroup();
        NonsellableBG = new javax.swing.ButtonGroup();
        GaveAWayBG = new javax.swing.ButtonGroup();
        MDFYBG = new javax.swing.ButtonGroup();
        jSeparator3 = new javax.swing.JSeparator();
        jScrollPane4 = new javax.swing.JScrollPane();
        tpOVW = new javax.swing.JTabbedPane();
        pIp = new javax.swing.JPanel();
        LowerCOntainer = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        Comment = new javax.swing.JTextArea();
        RegDate = new javax.swing.JLabel();
        regDAteN = new javax.swing.JTextField();
        internalValue = new javax.swing.JLabel();
        Sign = new javax.swing.JButton();
        internalValueN = new javax.swing.JTextField();
        FlagsnStuff = new javax.swing.JPanel();
        jScrollPane9 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLabel14 = new javax.swing.JLabel();
        txBDAT = new javax.swing.JTextField();
        lblBDAT = new javax.swing.JLabel();
        UpperArea = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        UPAssistant = new javax.swing.JButton();
        cxError = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        txfUPID = new javax.swing.JTextField();
        upidcsum = new javax.swing.JTextField();
        kkCsum = new javax.swing.JTextField();
        PreVerify = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        versTogg = new javax.swing.JToggleButton();
        btnPachUpidAssist = new javax.swing.JButton();
        cXoverride = new javax.swing.JCheckBox();
        btnEnabOVR = new javax.swing.JButton();
        pPreview = new javax.swing.JPanel();
        previewVers1 = new javax.swing.JTabbedPane();
        panelKKPreviewF = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        LBLMDIF = new javax.swing.JLabel();
        LBLUpidCsum = new javax.swing.JLabel();
        lblUPID8 = new javax.swing.JLabel();
        lblNumercArea = new javax.swing.JLabel();
        lblRegDate = new javax.swing.JLabel();
        lblFlagLine = new javax.swing.JLabel();
        lblKcode = new javax.swing.JLabel();
        lblCommentsLine1 = new javax.swing.JLabel();
        LBLCsum = new javax.swing.JLabel();
        lblV1AlzrUnselll = new javax.swing.JLabel();
        lblGenViaPHP = new javax.swing.JLabel();
        lblGaveAwayPr = new javax.swing.JLabel();
        panelKKPreviewB = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        txaCommRest = new javax.swing.JTextArea();
        btnSubmitToDb = new javax.swing.JButton();
        previewVers2 = new javax.swing.JTabbedPane();
        jPanel2 = new javax.swing.JPanel();
        mdfyrow = new javax.swing.JLabel();
        DependencyDataset = new javax.swing.JLabel();
        ival_alzr_src = new javax.swing.JLabel();
        CommExists = new javax.swing.JLabel();
        RwgDAteV2 = new javax.swing.JLabel();
        BuyDateV2 = new javax.swing.JLabel();
        FlagRow = new javax.swing.JLabel();
        KKV2 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        MFIDV2 = new javax.swing.JLabel();
        UpidCsum2 = new javax.swing.JLabel();
        upid8v2 = new javax.swing.JLabel();
        upidNumVals = new javax.swing.JLabel();
        jScrollPane5 = new javax.swing.JScrollPane();
        txaCsumV2 = new javax.swing.JTextArea();
        jLabel21 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        CommV2 = new javax.swing.JTextArea();
        pBrowse = new javax.swing.JPanel();
        tpReadV1 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        lblIVAl = new javax.swing.JLabel();
        lblSrcB = new javax.swing.JLabel();
        lblRegDatBrow = new javax.swing.JLabel();
        lblFlagsRow = new javax.swing.JLabel();
        upid20V1 = new javax.swing.JLabel();
        SCV1 = new javax.swing.JLabel();
        BCSUM1 = new javax.swing.JLabel();
        lblGaveAwayBrow = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane8 = new javax.swing.JScrollPane();
        CommV1b = new javax.swing.JTextArea();
        tpReadV2 = new javax.swing.JTabbedPane();
        panelViewV2vorne = new javax.swing.JPanel();
        lblTopFlagsV2 = new javax.swing.JLabel();
        lblIVAlFlagsV2 = new javax.swing.JLabel();
        lblCommFlag = new javax.swing.JLabel();
        lblDates = new javax.swing.JLabel();
        LblUPID20 = new javax.swing.JLabel();
        lblShortCode = new javax.swing.JLabel();
        lblCsumV2_14_28 = new javax.swing.JLabel();
        lblcsumv2_28 = new javax.swing.JLabel();
        lblCsumV20_14 = new javax.swing.JLabel();
        lblFlagsV = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        panehViewV2Hinten = new javax.swing.JPanel();
        jScrollPane7 = new javax.swing.JScrollPane();
        CommV2b = new javax.swing.JTextArea();
        jScrollPane6 = new javax.swing.JScrollPane();
        LSTUPids = new javax.swing.JList();
        jLabel19 = new javax.swing.JLabel();
        btnRefresh = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JSeparator();
        jPanel5 = new javax.swing.JPanel();
        jLabel18 = new javax.swing.JLabel();
        btnSwitchMode = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("UPIDMgr");

        jScrollPane4.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        pIp.setMaximumSize(new java.awt.Dimension(800, 800));
        pIp.setName("");
        pIp.setPreferredSize(new java.awt.Dimension(800, 800));
        pIp.setSize(800,800);

        Comment.setColumns(20);
        Comment.setRows(5);
        jScrollPane1.setViewportView(Comment);

        RegDate.setText("RegDate");

        regDAteN.setText("DD.MM.YY");
        regDAteN.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                regDAteNActionPerformed(evt);
            }
        });

        internalValue.setText("internalValue");

        Sign.setText("Sign and Create");
        Sign.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SignActionPerformed(evt);
            }
        });

        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"
            }
        ));
        jScrollPane9.setViewportView(jTable1);

        javax.swing.GroupLayout FlagsnStuffLayout = new javax.swing.GroupLayout(FlagsnStuff);
        FlagsnStuff.setLayout(FlagsnStuffLayout);
        FlagsnStuffLayout.setHorizontalGroup(
            FlagsnStuffLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FlagsnStuffLayout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 452, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(53, Short.MAX_VALUE))
        );
        FlagsnStuffLayout.setVerticalGroup(
            FlagsnStuffLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(FlagsnStuffLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 286, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        jLabel14.setText("Comments");

        txBDAT.setText("DD.MM.YY");

        lblBDAT.setText("BuyDate");

        javax.swing.GroupLayout LowerCOntainerLayout = new javax.swing.GroupLayout(LowerCOntainer);
        LowerCOntainer.setLayout(LowerCOntainerLayout);
        LowerCOntainerLayout.setHorizontalGroup(
            LowerCOntainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(LowerCOntainerLayout.createSequentialGroup()
                .addGap(93, 93, 93)
                .addComponent(FlagsnStuff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(LowerCOntainerLayout.createSequentialGroup()
                .addGap(69, 69, 69)
                .addGroup(LowerCOntainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel14)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 337, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(LowerCOntainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(LowerCOntainerLayout.createSequentialGroup()
                        .addGroup(LowerCOntainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(LowerCOntainerLayout.createSequentialGroup()
                                .addGap(2, 2, 2)
                                .addComponent(internalValue))
                            .addComponent(lblBDAT))
                        .addGap(18, 18, 18)
                        .addGroup(LowerCOntainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(internalValueN, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE)
                            .addComponent(txBDAT))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(LowerCOntainerLayout.createSequentialGroup()
                        .addGroup(LowerCOntainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(LowerCOntainerLayout.createSequentialGroup()
                                .addComponent(RegDate)
                                .addGap(18, 18, 18)
                                .addComponent(regDAteN, javax.swing.GroupLayout.PREFERRED_SIZE, 231, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 126, Short.MAX_VALUE))
                            .addComponent(Sign, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap())))
        );
        LowerCOntainerLayout.setVerticalGroup(
            LowerCOntainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(LowerCOntainerLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(FlagsnStuff, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(9, 9, 9)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(LowerCOntainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(LowerCOntainerLayout.createSequentialGroup()
                        .addGroup(LowerCOntainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(RegDate)
                            .addComponent(regDAteN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(LowerCOntainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(internalValue)
                            .addComponent(internalValueN, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(LowerCOntainerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblBDAT)
                            .addComponent(txBDAT, 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(Sign))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(35, Short.MAX_VALUE))
        );

        jLabel15.setText("V1-ONLY");

        jLabel3.setText("KK-Csum");

        UPAssistant.setText("Asistent");
        UPAssistant.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                UPAssistantActionPerformed(evt);
            }
        });

        cxError.setText("Error?");

        jLabel1.setText("Upid-20");

        PreVerify.setText("PreVerify");
        PreVerify.setEnabled(false);
        PreVerify.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PreVerifyActionPerformed(evt);
            }
        });

        jLabel4.setText("Checksum");

        versTogg.setText("Version 2");
        versTogg.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                versToggActionPerformed(evt);
            }
        });

        btnPachUpidAssist.setText("UPIDAssistant updaten");
        btnPachUpidAssist.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPachUpidAssistActionPerformed(evt);
            }
        });

        cXoverride.setText("IgnoreCsums");
        cXoverride.setEnabled(false);

        btnEnabOVR.setText("Manuell erzeugt?");
        btnEnabOVR.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEnabOVRActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout UpperAreaLayout = new javax.swing.GroupLayout(UpperArea);
        UpperArea.setLayout(UpperAreaLayout);
        UpperAreaLayout.setHorizontalGroup(
            UpperAreaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(UpperAreaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(UPAssistant)
                .addGap(24, 24, 24)
                .addGroup(UpperAreaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(UpperAreaLayout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(10, 10, 10)
                        .addComponent(upidcsum, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(PreVerify)
                        .addGap(27, 27, 27)
                        .addComponent(versTogg)
                        .addContainerGap())
                    .addGroup(UpperAreaLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(18, 18, 18)
                        .addComponent(txfUPID, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 151, Short.MAX_VALUE)
                        .addComponent(btnPachUpidAssist, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(51, 51, 51))
                    .addGroup(UpperAreaLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(kkCsum, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(cxError)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnEnabOVR)
                        .addGap(18, 18, 18)
                        .addComponent(cXoverride)
                        .addGap(84, 84, 84))))
        );
        UpperAreaLayout.setVerticalGroup(
            UpperAreaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(UpperAreaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(UpperAreaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(UPAssistant)
                    .addComponent(jLabel1)
                    .addComponent(txfUPID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGroup(UpperAreaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(UpperAreaLayout.createSequentialGroup()
                        .addGroup(UpperAreaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(PreVerify)
                            .addComponent(jLabel4)
                            .addComponent(upidcsum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(versTogg))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(UpperAreaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(kkCsum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(cxError)
                            .addComponent(cXoverride)
                            .addComponent(btnEnabOVR)))
                    .addGroup(UpperAreaLayout.createSequentialGroup()
                        .addGap(29, 29, 29)
                        .addComponent(jLabel3)))
                .addContainerGap())
            .addGroup(UpperAreaLayout.createSequentialGroup()
                .addComponent(btnPachUpidAssist)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout pIpLayout = new javax.swing.GroupLayout(pIp);
        pIp.setLayout(pIpLayout);
        pIpLayout.setHorizontalGroup(
            pIpLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pIpLayout.createSequentialGroup()
                .addGap(18, 18, 18)
                .addGroup(pIpLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(UpperArea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(LowerCOntainer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(558, Short.MAX_VALUE))
        );
        pIpLayout.setVerticalGroup(
            pIpLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pIpLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(UpperArea, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(LowerCOntainer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 180, Short.MAX_VALUE))
        );

        tpOVW.addTab("Input", null, pIp, "");

        jLabel16.setText("O");

        LBLMDIF.setText("|XXXX|");

        LBLUpidCsum.setText("XX|XX|");

        lblUPID8.setText("XXXX|XXXX|");

        lblNumercArea.setText("XX|XX");

        lblRegDate.setText("XX|XX|XX");

        lblFlagLine.setText("X|  |X|X|     |X|X|X|");

        lblKcode.setText("XXX");

        lblCommentsLine1.setText("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        LBLCsum.setText("XXXXX");

        lblV1AlzrUnselll.setText("X|XXX");

        lblGenViaPHP.setText("X");

        lblGaveAwayPr.setText("X");

        javax.swing.GroupLayout panelKKPreviewFLayout = new javax.swing.GroupLayout(panelKKPreviewF);
        panelKKPreviewF.setLayout(panelKKPreviewFLayout);
        panelKKPreviewFLayout.setHorizontalGroup(
            panelKKPreviewFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelKKPreviewFLayout.createSequentialGroup()
                .addComponent(lblGaveAwayPr)
                .addGap(40, 40, 40)
                .addComponent(lblV1AlzrUnselll)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(lblGenViaPHP, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(37, 37, 37))
            .addGroup(panelKKPreviewFLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelKKPreviewFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(LBLCsum)
                    .addGroup(panelKKPreviewFLayout.createSequentialGroup()
                        .addComponent(jLabel16)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(panelKKPreviewFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelKKPreviewFLayout.createSequentialGroup()
                                .addComponent(LBLMDIF)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(LBLUpidCsum))
                            .addComponent(lblRegDate))
                        .addGap(18, 18, 18)
                        .addGroup(panelKKPreviewFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(panelKKPreviewFLayout.createSequentialGroup()
                                .addComponent(lblUPID8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblNumercArea))
                            .addGroup(panelKKPreviewFLayout.createSequentialGroup()
                                .addComponent(lblFlagLine)
                                .addGap(45, 45, 45)
                                .addComponent(lblKcode)))))
                .addContainerGap(50, Short.MAX_VALUE))
            .addComponent(lblCommentsLine1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        panelKKPreviewFLayout.setVerticalGroup(
            panelKKPreviewFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelKKPreviewFLayout.createSequentialGroup()
                .addGroup(panelKKPreviewFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblV1AlzrUnselll)
                    .addComponent(lblGenViaPHP)
                    .addComponent(lblGaveAwayPr))
                .addGap(14, 14, 14)
                .addComponent(lblCommentsLine1)
                .addGroup(panelKKPreviewFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelKKPreviewFLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelKKPreviewFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblRegDate)
                            .addComponent(lblFlagLine))
                        .addGap(31, 31, 31)
                        .addGroup(panelKKPreviewFLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel16)
                            .addComponent(LBLMDIF)
                            .addComponent(LBLUpidCsum)
                            .addComponent(lblUPID8)
                            .addComponent(lblNumercArea)))
                    .addGroup(panelKKPreviewFLayout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addComponent(lblKcode)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(LBLCsum)
                .addGap(62, 62, 62))
        );

        previewVers1.addTab("Vorderseite", panelKKPreviewF);

        txaCommRest.setColumns(20);
        txaCommRest.setRows(5);
        jScrollPane2.setViewportView(txaCommRest);

        javax.swing.GroupLayout panelKKPreviewBLayout = new javax.swing.GroupLayout(panelKKPreviewB);
        panelKKPreviewB.setLayout(panelKKPreviewBLayout);
        panelKKPreviewBLayout.setHorizontalGroup(
            panelKKPreviewBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelKKPreviewBLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
                .addContainerGap())
        );
        panelKKPreviewBLayout.setVerticalGroup(
            panelKKPreviewBLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
        );

        previewVers1.addTab("Rückseite", panelKKPreviewB);

        btnSubmitToDb.setText(".submit()");
        btnSubmitToDb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSubmitToDbActionPerformed(evt);
            }
        });

        mdfyrow.setText("x  |x  |X  |X  |");

        DependencyDataset.setText("XXXXXXXX|XXXXXXXX");

        ival_alzr_src.setText("X   |X  |X");

        CommExists.setText("X");

        RwgDAteV2.setText("XXXX|XX");

        BuyDateV2.setText("|XXXX|XX");

        FlagRow.setText("|X|X|X|X|X|X|X|X|X|X|");

        KKV2.setText("XXXX");

        jLabel17.setText("O");

        MFIDV2.setText("|XXXX|");

        UpidCsum2.setText("XX|XX|");

        upid8v2.setText("XXXX|XXXX|");

        upidNumVals.setText("XX|XX");

        txaCsumV2.setColumns(40);
        txaCsumV2.setRows(1);
        jScrollPane5.setViewportView(txaCsumV2);

        jLabel21.setText("2");

        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()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(mdfyrow)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(DependencyDataset))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(RwgDAteV2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(BuyDateV2)
                                .addGap(18, 18, 18)
                                .addComponent(FlagRow)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 34, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                    .addGap(0, 0, Short.MAX_VALUE)
                                    .addComponent(CommExists, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap())
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addComponent(ival_alzr_src)
                                    .addGap(21, 21, 21)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                                .addComponent(KKV2)
                                .addContainerGap())))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel17)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(MFIDV2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(UpidCsum2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(upid8v2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(upidNumVals)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel21)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE))))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(mdfyrow)
                    .addComponent(DependencyDataset)
                    .addComponent(ival_alzr_src))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(CommExists)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(KKV2)
                    .addComponent(FlagRow)
                    .addComponent(BuyDateV2)
                    .addComponent(RwgDAteV2))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel17)
                            .addComponent(MFIDV2)
                            .addComponent(UpidCsum2)
                            .addComponent(upid8v2)
                            .addComponent(upidNumVals))
                        .addGap(0, 18, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jLabel21)))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        previewVers2.addTab("Vorderseite", jPanel2);

        CommV2.setColumns(20);
        CommV2.setRows(5);
        jScrollPane3.setViewportView(CommV2);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)
        );

        previewVers2.addTab("Rückseite", jPanel1);

        javax.swing.GroupLayout pPreviewLayout = new javax.swing.GroupLayout(pPreview);
        pPreview.setLayout(pPreviewLayout);
        pPreviewLayout.setHorizontalGroup(
            pPreviewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pPreviewLayout.createSequentialGroup()
                .addGroup(pPreviewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pPreviewLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(pPreviewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(previewVers1)
                            .addComponent(previewVers2)))
                    .addGroup(pPreviewLayout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addComponent(btnSubmitToDb, javax.swing.GroupLayout.PREFERRED_SIZE, 386, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(1002, Short.MAX_VALUE))
        );
        pPreviewLayout.setVerticalGroup(
            pPreviewLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pPreviewLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(previewVers1, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(previewVers2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnSubmitToDb)
                .addContainerGap(400, Short.MAX_VALUE))
        );

        tpOVW.addTab("Preview", pPreview);

        lblIVAl.setText("X|XX");

        lblSrcB.setText("X");

        lblRegDatBrow.setText("XXXX|XX");

        lblFlagsRow.setText("X|  |X|X|  |  |X|X|X");

        upid20V1.setText("O|XXXX|XX|XX|XXXX|XXXX|XX|XX");

        SCV1.setText("XXX");

        BCSUM1.setText("XXXXX");

        lblGaveAwayBrow.setText("X");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(BCSUM1))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(lblRegDatBrow)
                        .addGap(105, 105, 105)
                        .addComponent(lblFlagsRow)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 45, Short.MAX_VALUE)
                        .addComponent(SCV1)))
                .addGap(26, 26, 26))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(19, 19, 19)
                .addComponent(upid20V1, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(9, 9, 9)
                .addComponent(lblGaveAwayBrow)
                .addGap(18, 18, 18)
                .addComponent(lblIVAl)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(lblSrcB)
                .addGap(42, 42, 42))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lblSrcB)
                    .addComponent(lblIVAl)
                    .addComponent(lblGaveAwayBrow))
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(39, 39, 39)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblRegDatBrow)
                            .addComponent(lblFlagsRow))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE)
                        .addComponent(upid20V1)
                        .addGap(36, 36, 36))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGap(31, 31, 31)
                        .addComponent(SCV1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(BCSUM1)
                        .addContainerGap())))
        );

        tpReadV1.addTab("Vorne", jPanel3);

        CommV1b.setColumns(20);
        CommV1b.setRows(5);
        jScrollPane8.setViewportView(CommV1b);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 310, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane8, javax.swing.GroupLayout.DEFAULT_SIZE, 160, Short.MAX_VALUE)
        );

        tpReadV1.addTab("Hinten", jPanel4);

        lblTopFlagsV2.setText("X|X|X|X|");

        lblIVAlFlagsV2.setText("XXX|X|X");

        lblCommFlag.setText("X");

        lblDates.setText("XXXX|XX|XXXX|XX");

        LblUPID20.setText("O|XXXX|XX|XX|XXXX|XXXX|XX|XX|");

        lblShortCode.setText("XXXX");

        lblCsumV2_14_28.setText("XXXXXXXXXXXXXX");

        lblcsumv2_28.setText("XXXXXXXXXXXX");

        lblCsumV20_14.setText("XXXXXXXXXXXXXX");

        lblFlagsV.setText("|X|X|X|X|X|X|X|X|X|X|");

        jLabel22.setText("2");

        javax.swing.GroupLayout panelViewV2vorneLayout = new javax.swing.GroupLayout(panelViewV2vorne);
        panelViewV2vorne.setLayout(panelViewV2vorneLayout);
        panelViewV2vorneLayout.setHorizontalGroup(
            panelViewV2vorneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelViewV2vorneLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelViewV2vorneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelViewV2vorneLayout.createSequentialGroup()
                        .addComponent(lblTopFlagsV2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblIVAlFlagsV2))
                    .addGroup(panelViewV2vorneLayout.createSequentialGroup()
                        .addGap(67, 67, 67)
                        .addComponent(LblUPID20)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 76, Short.MAX_VALUE)
                        .addComponent(jLabel22))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelViewV2vorneLayout.createSequentialGroup()
                        .addComponent(lblDates)
                        .addGap(18, 18, 18)
                        .addComponent(lblFlagsV)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(lblShortCode))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelViewV2vorneLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(panelViewV2vorneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblcsumv2_28)
                            .addGroup(panelViewV2vorneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(lblCommFlag, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(lblCsumV2_14_28, javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(lblCsumV20_14, javax.swing.GroupLayout.Alignment.TRAILING)))))
                .addContainerGap())
        );
        panelViewV2vorneLayout.setVerticalGroup(
            panelViewV2vorneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelViewV2vorneLayout.createSequentialGroup()
                .addGroup(panelViewV2vorneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblTopFlagsV2)
                    .addGroup(panelViewV2vorneLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(lblIVAlFlagsV2)))
                .addGroup(panelViewV2vorneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(panelViewV2vorneLayout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addComponent(lblCommFlag)
                        .addGap(8, 8, 8)
                        .addComponent(lblShortCode)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel22))
                    .addGroup(panelViewV2vorneLayout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addGroup(panelViewV2vorneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblDates)
                            .addComponent(lblFlagsV))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(LblUPID20)))
                .addGap(1, 1, 1)
                .addComponent(lblCsumV20_14)
                .addGap(3, 3, 3)
                .addComponent(lblCsumV2_14_28)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblcsumv2_28)
                .addContainerGap(16, Short.MAX_VALUE))
        );

        tpReadV2.addTab("Vorne", panelViewV2vorne);

        CommV2b.setColumns(20);
        CommV2b.setEditable(false);
        CommV2b.setRows(5);
        jScrollPane7.setViewportView(CommV2b);

        javax.swing.GroupLayout panehViewV2HintenLayout = new javax.swing.GroupLayout(panehViewV2Hinten);
        panehViewV2Hinten.setLayout(panehViewV2HintenLayout);
        panehViewV2HintenLayout.setHorizontalGroup(
            panehViewV2HintenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panehViewV2HintenLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 309, Short.MAX_VALUE)
                .addContainerGap())
        );
        panehViewV2HintenLayout.setVerticalGroup(
            panehViewV2HintenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panehViewV2HintenLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane7, javax.swing.GroupLayout.DEFAULT_SIZE, 138, Short.MAX_VALUE)
                .addContainerGap())
        );

        tpReadV2.addTab("HInten", panehViewV2Hinten);

        LSTUPids.setModel(new javax.swing.DefaultListModel());
        LSTUPids.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                LSTUPidsMouseClicked(evt);
            }
        });
        jScrollPane6.setViewportView(LSTUPids);

        jLabel19.setText("List of avail UPIDs");

        btnRefresh.setText("Refresh");
        btnRefresh.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRefreshActionPerformed(evt);
            }
        });

        jSeparator2.setOrientation(javax.swing.SwingConstants.VERTICAL);
        jSeparator2.setToolTipText("");

        javax.swing.GroupLayout pBrowseLayout = new javax.swing.GroupLayout(pBrowse);
        pBrowse.setLayout(pBrowseLayout);
        pBrowseLayout.setHorizontalGroup(
            pBrowseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pBrowseLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pBrowseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel19)
                    .addComponent(btnRefresh)
                    .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(pBrowseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(tpReadV1, javax.swing.GroupLayout.PREFERRED_SIZE, 335, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tpReadV2, javax.swing.GroupLayout.PREFERRED_SIZE, 334, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(838, Short.MAX_VALUE))
        );
        pBrowseLayout.setVerticalGroup(
            pBrowseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pBrowseLayout.createSequentialGroup()
                .addGroup(pBrowseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pBrowseLayout.createSequentialGroup()
                        .addGap(26, 26, 26)
                        .addComponent(tpReadV1, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(tpReadV2, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(pBrowseLayout.createSequentialGroup()
                        .addGap(7, 7, 7)
                        .addComponent(btnRefresh)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel19)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 521, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(219, Short.MAX_VALUE))
            .addComponent(jSeparator2)
        );

        tpOVW.addTab("Browse", pBrowse);

        jScrollPane4.setViewportView(tpOVW);

        jLabel18.setText("Reserved for Future Use");

        btnSwitchMode.setText("Modus wexxeln");
        btnSwitchMode.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSwitchModeActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(69, 69, 69)
                .addComponent(jLabel18)
                .addContainerGap())
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnSwitchMode, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(btnSwitchMode)
                .addGap(92, 92, 92)
                .addComponent(jLabel18)
                .addContainerGap(493, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 1201, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 870, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel5, 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()
                .addGap(33, 33, 33)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 622, Short.MAX_VALUE)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(26, 26, 26)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(30, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // <editor-fold defaultstate="collapsed" desc="evthandlers">
    
    private void SignActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SignActionPerformed
        //Variablen einlesen
        values = new HashMap<>();
        if(!cXoverride.isSelected())
            validateKK(false);//UPID-included Cheksum erzeugen
        String kommentar = "";
        //Flags speichern: flags.put(Name, Wert)
        //Hässliches IfElse-Konstrukt
        //Flags mit jede Menge Ifs (Java-Meise)
        //<editor-fold defaultstate="collapsed" desc="Nasty Code">
        flags.put("SRC", "J");//Hardcoded für CreatedByJava-Flag
        if(cXoverride.isSelected()) flags.put("src"," ");
        /*
        if(arightsNA.isSelected())
        {    
            flags.put("Arights","D");//D Durch Csum-Null ersetzen da dieser leeres Feld ersetzt!!!!!!!!!!!!
        }
        else
        {
            if(arightsU.isSelected())
            {
                flags.put("Arights","X");
            }
            else
            {
                if(arightsNV.isSelected())
                {
                    flags.put("Arights","N");
                }
                else
                {
                    flags.put("Arights","D");//Default
                }
            }
        }*/
        //############
       /* if(vitA.isSelected())
        {
            flags.put("VIT","X");
        }
        else
        {
            if(vitL.isSelected())
            {
                flags.put("VIT","L");
            }
            else
            {
                if(vitNA.isSelected())
                {
                    flags.put("VIT","D");
                }
                else
                {
                    if(vitNV.isSelected())
                    {
                        flags.put("VIT","N");
                    }
                    else
                    {
                        flags.put("VIT","D");
                    }
                }
            }
        }
        //
        if(nse1U.isSelected())
        {
            flags.put("NSE1","X");
        }
        else
        {
            if(nse1L.isSelected())
            {
                flags.put("NSE1","L");
            }
            else
            {
                if(nse1NA.isSelected())
                {
                    flags.put("NSE1","D");
                }
                else
                {
                    if(nse1NV.isSelected())
                    {
                        flags.put("NSE1","N");
                    }
                    else
                    {
                        flags.put("NSE1","D");
                    }
                }
            }
        }
        
        
        if(nse2U.isSelected())
        {
            flags.put("NSE2","X");
        }
        else
        {
            if(nse2L.isSelected())
            {
                flags.put("NSE2","L");
            }
            else
            {
                if(nse2NA.isSelected())
                {
                    flags.put("NSE2","D");
                }
                else
                {
                    if(nse2NV.isSelected())
                    {
                        flags.put("NSE2","N");
                    }
                    else
                    {
                        flags.put("NSE2","D");
                    }
                }
            }
        }
        
        
        
        if(alzrU.isSelected())
        {
            flags.put("ALZR","X");
        }
        else
        {
            if(alzrL.isSelected())
            {
                flags.put("ALZR","L");
            }
            else
            {
                if(alzrNA.isSelected())
                {
                    flags.put("ALZR","D");
                }
                else
                {
                    if(alzrNV.isSelected())
                    {
                        flags.put("ALZR","N");
                    }
                    else
                    {
                        if(alzrI.isSelected())
                        {
                            flags.put("ALZR","I");
                        }
                        else
                        {
                            flags.put("ALZR","D");
                        }
                    }    
                }
            }
        }
        
        if(arightsNA.isSelected())
        {
            flags.put("Arights","D");
        }
        else
        {
            if(arightsNV.isSelected())
            {
                flags.put("Arights","N");
            }
            else
            {
                if(arightsU.isSelected())
                {
                    flags.put("Arights","X");
                }
                else
                {
                    flags.put("Arights","D");
                }
            }
        }
        
        
        if(nonsellableNA.isSelected())
        {
            flags.put("Nonsellable","D");
        }
        else
        {
            if(nonsellableU.isSelected())
            {
                flags.put("Nonsellable","X");
            }
            else
            {
                flags.put("Nonsellable","D");
            }
        }
        
        if(gaveAway2EXP.isSelected())
        {
            flags.put("gaveAway","B");
        }
        else
        {
            if(gaveAwayU.isSelected())
            {
                flags.put("gaveAway","X");
            }
            else
            {
                flags.put("gaveAway","D");
            }
        }
        
        if(mdfyU.isSelected())
        {
            flags.put("MDFY","X");
        }
        else
        {
            if(mdfyNV.isSelected())
            {
                flags.put("MDFY","N");
            }
            else
            {
                flags.put("MDFY","D");
            }
        }*/
        //</editor-fold>
        String upidtmp = txfUPID.getText();
        values.put("UPIDPRE",upidtmp);
        upidtmp = upidtmp.replace("-","");
        values.put("UPIDCSE",upidtmp);
        Tools.DebugHelperPrint(upidtmp, true, "UpidTK.enableDebug");
        if(upidtmp.length()==20||upidtmp.length()==22)
        {
            upid.put("MFID",upidtmp.substring(0, 4));//String-Segmente laden
            upid.put("PSC",upidtmp.substring(4, 6));
            upid.put("UPID6",upidtmp.substring(6, 12));
            upid.put("ZSC",upidtmp.substring(12, 14));
            upid.put("SRC",upidtmp.substring(14, 16));
            upid.put("CSUM",upidtmp.substring(16, 20));
            if(upidtmp.length()==22)
            {
                upid.put("ADD",upidtmp.substring(20, 22));
            }
            upidtmp = null;
        }
        else
        {
            if(upidtmp.length()==21||upidtmp.length()==23)
            {
                upid.put("MFID",upidtmp.substring(0, 4));//String-Segmente laden
                upid.put("PSC",upidtmp.substring(4, 6));
                upid.put("UPID6",upidtmp.substring(6, 13));
                upid.put("ZSC",upidtmp.substring(13, 15));
                upid.put("SRC",upidtmp.substring(15, 17));
                upid.put("CSUM",upidtmp.substring(17, 21));
                if(upidtmp.length()==23)
                {
                    upid.put("ADD",upidtmp.substring(21, 23));
                }
                upidtmp = null;
            }
            else
            {
                Tools.dlg(true, "Error in Upid", "die Länge stimmt nicht!!!");
                return;//TODO Add ereor-TRAP;
            }
        }
        if(Version1)
        {
            values.put("CSUM", upidcsum.getText());
            values.put("CSUM2", kkCsum.getText());
        }
        if(cxError.isSelected())
        {
            values.put("Err","1");
        }
        else
        {
            values.put("Err","0");
        }
        //parseComments
        values.put("COMMC",Tools.getSHAString(Comment.getText()));
        values.put("COMM",Comment.getText());
        values.put("RDATC",Tools.getSHAString(regDAteN.getText()));
        values.put("RDAT",regDAteN.getText());
        values.put("BDAT",txBDAT.getText());
        String val = internalValueN.getText();
        val = val.replace(",",".");//akzeptiert Komma und Punkt;keine dezimaltrenner
        values.put("IVAL", val);
        //bakeFlags
        String bakFlags1 = "";
        for (String fs : FlagsAvail)
        {
            bakFlags1 += (flags.get(fs));
        }
        //length|cnt;
        String bakFlags = bakFlags1.length()+"|"+bakFlags1;
        Tools.DebugHelperPrint(bakFlags, true, "UpidTK.enableDebug");
        values.put("BKFlag",bakFlags);
        
        String sKKvalidated = upidcsum.getText(); 
        if(!cXoverride.isSelected())
        {
        sKKvalidated = validateKKC();
        }
        //values.put
        
        values.put("DPT","NotNeeded");
        /*if(cxDepsNEeded.isSelected())
        {
            values.put("DPT","Enabled");
        }*/
                
        
        
        tpOVW.setEnabledAt(1, true);
        boolean cntne = Tools.dlg(true,"Csum berechnet: "+sKKvalidated,"Karteikaartenvorachau anzeigen?");
        updatePreview();
        if(cntne)
        {
            tpOVW.setSelectedIndex(1);
        }
        
    }//GEN-LAST:event_SignActionPerformed
   
    private void UPAssistantActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_UPAssistantActionPerformed
    {//GEN-HEADEREND:event_UPAssistantActionPerformed

        new Thread(new Runnable()
        {
            
            @Override
            @SuppressWarnings({"CallToThreadDumpStack"})
            public void run()
            {
                //PublicStorage.l.unlock();
                      try
               {
                   // Thread.sleep(100);
                    PublicStorage.l.lock();
                }
                catch (InterruptedException ex)
                {
                    ex.printStackTrace();
                }
               new UPIDAssistant().setVisible(true);
                //UPIDAssistant.main(null);
            }
        }).start();
      /*  try
        {
            Thread.sleep(1000);
            
        }
        catch (InterruptedException ex)
        {
            System.err.println("Fick");
            ex.printStackTrace();
        }*/
        
        new Thread(new Runnable()
        {

            @SuppressWarnings("CallToThreadDumpStack")
            @Override
            public void run()
            {
                try
                {
                  /*  while (!PublicStorage.ready)
                    {
                        Thread.sleep(5)
                    };*/
                    Thread.sleep(1000);
                    Tools.DebugHelperPrint("Fotze", true, "UpidTK.enableDebug");
                    PublicStorage.l.lock();
                    PublicStorage.l.unlock();//Erkennung ob fertig
                    Object[] oupid = (Object[]) PublicStorage.STO.get("upid");
                    String upid = ((String) oupid[0]) + ((String) oupid[1]) + ((String) oupid[2])
                            + Tools.padLeft(2, ((Integer) oupid[3]).toString(), '0')
                            + Tools.padLeft(2, ((Integer) oupid[4]).toString(), '0');
                    txfUPID.setText(upid);
                }
                catch (Exception ex)
                {
                    ex.printStackTrace();
                }
            }
        }).start();
    }//GEN-LAST:event_UPAssistantActionPerformed

    private void PreVerifyActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_PreVerifyActionPerformed
    {//GEN-HEADEREND:event_PreVerifyActionPerformed
        validateKK();
    }//GEN-LAST:event_PreVerifyActionPerformed

    private void versToggActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_versToggActionPerformed
    {//GEN-HEADEREND:event_versToggActionPerformed
        Version1 = !Version1;
        cXoverride.setVisible(Version1);
        //cxDepsNEeded.setVisible(Version1);
        btnEnabOVR.setVisible(Version1);
        lblBDAT.setVisible(!Version1);
        txBDAT.setVisible(!Version1);
        PreVerify.setEnabled(Version1);
        if(Version1)
        {
            versTogg.setText("Version 1");
        }
        else
        {
            versTogg.setText("Version 2");
        }
    }//GEN-LAST:event_versToggActionPerformed

    private void regDAteNActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_regDAteNActionPerformed
    {//GEN-HEADEREND:event_regDAteNActionPerformed
        if(regDAteN.getText().equals("DD.MM.YY"))
        {
            regDAteN.setText("");
        }
    }//GEN-LAST:event_regDAteNActionPerformed

    private void btnSubmitToDbActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnSubmitToDbActionPerformed
    {//GEN-HEADEREND:event_btnSubmitToDbActionPerformed
        int version=2;
        if(Version1) version=1;
        String statement = "INSERT INTO upidlst(UPID20,version)Values('"+values.get("UPIDCSE")+"',"+version+")";
        String getLinkageIDQuery = "SELECT LinkageID FROM upidlst where UPID20='"+values.get("UPIDCSE")+"'";
        dbc.write(statement);
        String LinkageID = dbc.querySingleCell(getLinkageIDQuery);
        if(Version1)
        {
            createV1Dataset(LinkageID);

            versToggActionPerformed(null);
        }
        else
        {
            createV2Dataset(LinkageID);
        }
        
        txfUPID.setText("");
        upidcsum.setText("");
        kkCsum.setText("");
        cxError.setSelected(false);
        cXoverride.setSelected(false);
        cXoverride.setEnabled(false);
        Comment.setText("");
        regDAteN.setText("DD.MM.YY");
        internalValueN.setText("");
        txBDAT.setText("DD.MM.YY");
        btnRefreshActionPerformed(evt);
    }//GEN-LAST:event_btnSubmitToDbActionPerformed

    private void btnPachUpidAssistActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnPachUpidAssistActionPerformed
    {//GEN-HEADEREND:event_btnPachUpidAssistActionPerformed
        new UpdateAssistant().setVisible(true);
    }//GEN-LAST:event_btnPachUpidAssistActionPerformed

    private void btnRefreshActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnRefreshActionPerformed
    {//GEN-HEADEREND:event_btnRefreshActionPerformed
        ((DefaultListModel)(LSTUPids.getModel())).clear();
        String[] availUPIDs = dbc.querySIngleColumn("Select UPID20 from upidlst");
        
        for (String elem : availUPIDs)
        {
            ((DefaultListModel)(LSTUPids.getModel())).addElement(elem);
        }
        
    }//GEN-LAST:event_btnRefreshActionPerformed

    private void LSTUPidsMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_LSTUPidsMouseClicked
    {//GEN-HEADEREND:event_LSTUPidsMouseClicked
        loadDataSet((String)LSTUPids.getSelectedValue());
    }//GEN-LAST:event_LSTUPidsMouseClicked

    private void btnEnabOVRActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnEnabOVRActionPerformed
    {//GEN-HEADEREND:event_btnEnabOVRActionPerformed
        cXoverride.setEnabled(true);
    }//GEN-LAST:event_btnEnabOVRActionPerformed

    private void btnSwitchModeActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_btnSwitchModeActionPerformed
    {//GEN-HEADEREND:event_btnSwitchModeActionPerformed
        Ifatzeh.sel.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_btnSwitchModeActionPerformed
    
    //</editor-fold>

    // <editor-fold defaultstate="collapsed" desc="Manual Codessssss">
    private boolean CSUMMED = false;
    public String validateKK()
    {
        return validateKK(true);
    }
    
    public String validateKK(boolean all)
    {
        
        @SuppressWarnings("LocalVariableHidesMemberVariable")
        String upid = txfUPID.getText();
        //if(CSUMMED)
       // {
            int ml=16;
            if(!(upid.length()-4<ml))
            {
                ml=upid.length()-4;
            }
            upid=upid.substring(0,ml);//entfernt womöglich schon berechnete CSUM
       // }
        CSUMMED=true;
        String ret = Tools.runSingleCmd(false, true,true, "X:\\cpltoExx\\upidgen.exe "+upid+" X");
        Tools.DebugHelperPrint(ret, true, "UpidTK.enableDebug");
        String[] CSUMS = ret.split("\\|");
        boolean setErr = false;
        
        try
        {
        kkCsum.setText(CSUMS[2]);
        if(all) 
            values.put("KKSC",CSUMS[2]);
        }
        catch(Exception e)//HACK um SVNP abzufangen
        {
          //  e.printStackTrace();//war ne Fliegenklatsche :-)
            setErr=true;
        }
        if(setErr)
        {
            int csulength = CSUMS[0].length();
            CSUMS[0] = CSUMS[0].substring(csulength-4);
            if(all)values.put("KKSC","---");
        }
        
        
        txfUPID.setText(upid+CSUMS[0]);
        if(all)
        {
            upidcsum.setText(CSUMS[1]);
            values.put("KKCS",CSUMS[1]);
            cxError.setSelected(setErr);
        }
        
        
               
        return CSUMS[1];
    }
    
    public String[] ValuesAvailToBake = {"UPIDCSE","CSUM","CSUM2","Err","COMM","RDAT","BDAT","IVAL","BKFlag"};//BKflag=bakedflags
    public String validateKKC()
    {
        if(Version1)
        {
            return validateKK();
        }
        String bakedAll = "";
        for (String sel : ValuesAvailToBake)
        {
            bakedAll+=values.get(sel);
        }
        String CSum = Tools.getSHAString(bakedAll);
        values.put("CSUM",CSum);
        String SC = CSum.substring(0,4);
        //Kurzcode in HExxx
        values.put("CSUM2",SC);
        return CSum;
    }
    
    public void updatePreview()
    {
        String lulpid=values.get("UPIDCSE");
        LBLMDIF.setText("|"+lulpid.substring(0,4)+"|");
        MFIDV2.setText("|"+lulpid.substring(0,4)+"|");
        
        //#######
        String upcs = lulpid.substring(lulpid.length()-4);
        LBLUpidCsum.setText(""+upcs.substring(0,2)+"|"+upcs.substring(2)+"|");
        UpidCsum2.setText(""+upcs.substring(0,2)+"|"+upcs.substring(2)+"|");
        
        lblUPID8.setText(lulpid.substring(4,8)+"|"+lulpid.substring(8,12)+"|");
        upid8v2.setText(lulpid.substring(4,8)+"|"+lulpid.substring(8,12)+"|");
        
        lblNumercArea.setText(lulpid.substring(12,14)+"|"+lulpid.substring(14,16));
        upidNumVals.setText(lulpid.substring(12,14)+"|"+lulpid.substring(14,16));
        
        LBLCsum.setText(values.get("CSUM"));
        txaCsumV2.setText(values.get("CSUM"));
        
        lblKcode.setText(values.get("CSUM2"));
        KKV2.setText(values.get("CSUM2"));
        if(values.get("Err").equals("1"))
        {
            lblKcode.setText("---");
        }
        
        
        String regDate = values.get("RDAT");
        Tools.DebugHelperPrint(regDate, true, "UpidTK.enableDebug");
        regDate=regDate.substring(0,2)+"|"+regDate.substring(3,5)+"|"+regDate.substring(6);
        Tools.DebugHelperPrint(regDate, true, "UpidTK.enableDebug");
        lblRegDate.setText(regDate);
        regDate = regDate.substring(0,2)+regDate.substring(3);
        RwgDAteV2.setText(regDate);
        
        String Buydat = values.get("BDAT");
        try{
        Buydat = Buydat.substring(0,2)+Buydat.substring(3,5)+"|"+Buydat.substring(6);
        BuyDateV2.setText(Buydat);
        }
        catch (Exception e)
        {
            
        }
        //verfügbare flags: {"SRC","VIT","NSE1","NSE2","ALZR","Arights","Nonsellable","gaveAway","MDFY"};
        String FlagList = values.get("BKFlag").substring(2);
        lblV1AlzrUnselll.setText(FlagList.substring(6,7)+"|"+values.get("IVAL"));
        lblFlagLine.setText(FlagList.substring(4,5)+"|  |"+FlagList.substring(8,9)+"|"+FlagList.substring(5,6)+"|  |  |"
                    +FlagList.substring(2,3)+"|"+FlagList.substring(3,4)+"|"+FlagList.substring(1,2)+"|");
        lblGaveAwayPr.setText(FlagList.substring(7,8));
        ival_alzr_src.setText(values.get("IVAL")+"|"+FlagList.substring(4,5)+"|"+FlagList.substring(0,1));
        FlagRow.setText("|"+FlagList.substring(2,3)+"|"+FlagList.substring(3,4)+"|"+FlagList.substring(1,2)+"|"+FlagList.substring(6,7)+"|X|X|X|X|X|X|");
        //NSE1|2|VIT|Unsellble
        
        String depNeeded = "D";
        if(values.get("DPT").equals("Enabled"))
            depNeeded="X";
        
        mdfyrow.setText(FlagList.substring(8,9)+"|"+FlagList.substring(7,8)+"|"+FlagList.substring(5,6)+"|"+depNeeded);
        //MDFY|GaveAway|Arighta
        //ival_alzr_src

        
        //maXlabelLength=50 zeichen
        //#######################
        String comment =values.get("COMM");
        CommV2.setText(comment);
        String commentFrontPP= "", CommFront = "",COmmRest = "";
        try
        {
        commentFrontPP = comment.substring(0,50);
        CommFront = "";
        COmmRest = comment.substring(50);
        Tools.DebugHelperPrint(commentFrontPP, true, "UpidTK.enableDebug");
        }
        catch(Exception e)
        {
        commentFrontPP = comment;
        CommFront = "";
        COmmRest = "";
        }
              
        String[] commentL1 = commentFrontPP.split("\n");
        Tools.DebugHelperPrint(commentL1[0]+"|"+commentL1[1], true, "UpidTK.enableDebug");
        String CommentRest = "";
        if(commentL1.length>1)
        {
            CommFront = commentL1[0];
            for (int i = 1; i < commentL1.length; i++)
            {
                CommentRest += commentL1[i]+"\n";
                
            }
            
            COmmRest = CommentRest+COmmRest;
        }
        else//splittet auf Leerzeichen
        {            
            String[] CommLZS = commentFrontPP.split(" ");
            COmmRest = CommLZS[CommLZS.length-1]; 
            if(CommLZS.length>1)
            {
                for (int i = 0; i < CommLZS.length-2; i++)
                {
                    CommFront += CommLZS[i]+" ";
                }
                CommFront += CommLZS[CommLZS.length-2];
            }
        }
    lblCommentsLine1.setText(CommFront);
    txaCommRest.setText(COmmRest);
    if(Version1)
    {
        previewVers1.setVisible(true);
        previewVers2.setVisible(false);
    }
    else
    {
        previewVers1.setVisible(false);
        previewVers2.setVisible(true);
    }
    
        
        
    }
    
    //valuepalette = {"UPIDCSE","CSUM","CSUM2","Err","COMM","RDAT","BDAT","IVAL","BKFlag"};//BKflag=bakedflags
    
    public void createV1Dataset(String LinkageID)
    {
        if(values.get("Err").equals("1"))
        {
            values.put("CSUM2","-1");
        }
        //UPID20,LinkageID,CSUM,Shortcode,Eingangsdatum,FlagValues,Remarks,Version=1
        String writeIn = "INSERT INTO objreg1 values('"+values.get("UPIDCSE")+"',\n"
                +LinkageID+","+values.get("CSUM")+",\n"
                +values.get("CSUM2")+",'"+values.get("RDAT")+"',\n"
                +"'"+values.get("BKFlag")+"',\n"
                +"'"+values.get("COMM")+"',1,"+values.get("IVAL")+")";//TODO:Db erledigen
        dbc.write(writeIn);
        
    }
    
    //UPID20,LinakgeID,CSUM,Shortcode,EIngangsdatum,Kaufdatum,FlagVals,Remarks,Version,DependencyLinks
    public void createV2Dataset(String LinkageID)
    {
        String writeIn = "INSERT INTO objreg2 values('"+values.get("UPIDCSE")+"',\n"
                +LinkageID+",'"+values.get("CSUM")+"',\n'"
                +values.get("CSUM2")+"','"+values.get("RDAT")+"',\n"+
                "'"+values.get("BDAT")+"','"+values.get("BKFlag")+"',\n"
                +"'"+values.get("COMM")+"',2,'"+values.get("DPT")+"',"+values.get("IVAL")+")";
        dbc.write(writeIn);
        
    }        
    
    public void loadDataSet(String UPID)
    {
        String Version = dbc.querySingleCell("SELECT Version FROM upidlst where UPID20='"+UPID+"'");
        int vv = Integer.valueOf(Version);
        String[] row = null;
        if(vv>1)
        {
            row = dbc.querySingleRow("Select * from  objreg2 where UPID20='"+UPID+"';",11);
            //UPID20,LinkageID,CSUM,Shortcode,kaufdatum,Registrierdatum,FlagValues,Remarks,Version,DependencyValues,IVAL;
            CommV2b.setText(row[7]);
            Tools.DebugHelperPrint(row[7], true, "UpidTK.enableDebug");
            String temp = row[0];
            String UPID20P = "|O|"+temp.substring(0,4)+"|"+temp.substring(16,18)+"|"+temp.substring(18,20)+"|"
                    +temp.substring(4,8)+"|"+temp.substring(8,12)+"|"+temp.substring(12,14)+"|"+temp.substring(14,16)+"|";
            LblUPID20.setText(UPID20P);
            temp = row[2];
            Tools.DebugHelperPrint(temp, true, "UpidTK.enableDebug");
            lblCsumV20_14.setText(temp.substring(0,14));
            lblCsumV2_14_28.setText(temp.substring(14,28));
            lblcsumv2_28.setText(temp.substring(28));
            lblShortCode.setText(row[3]);
            String FlagList = row[6].substring(2);
            lblFlagsV.setText("|"+FlagList.substring(2,3)+"|"+FlagList.substring(3,4)+"|"+FlagList.substring(1,2)+"|"+FlagList.substring(6,7)+"|X|X|X|X|X|X|");
                    
                    
                    //FlagList.substring(4,5)+"|  |"+FlagList.substring(8,9)+"|"+FlagList.substring(3,4)+"|  |  |"
                   // +FlagList.substring(2,3)+"|"+FlagList.substring(3,4)+"|"+FlagList.substring(1,2)+"|");
        
            lblIVAlFlagsV2.setText(row[10]+"|"+FlagList.substring(4,5)+"|"+FlagList.substring(0,1));
            
            String depExists = "D";
            if(row[8].equals("NotImplementedYet"))
                depExists="N";
            if(row[8].equals("Enabled"))
                depExists="X";
            
            
            lblTopFlagsV2.setText(FlagList.substring(8,9)+"|"+FlagList.substring(7,8)+"|"+FlagList.substring(5,6)+"|"+depExists);
            String buydate= row[4];//4
            String regdate= row[5];//5
            String dates=buydate.substring(0,2)+buydate.substring(3,5)+"|"+buydate.substring(6,8)+"|"
                    +regdate.substring(0,2)+regdate.substring(3,5)+"|"+regdate.substring(6,8);
            lblDates.setText(dates);
            tpReadV2.setVisible(true);
            tpReadV1.setVisible(false);
        }
        else
        {
            String temp;                        //
            //UPID20,LinkageID,CSUM,Shortcode,Eingangsdatum,FlagValues,Remarks,Version,IVAL
            row = dbc.querySingleRow("Select * from  objreg1 where UPID20='"+UPID+"';",9);
            CommV1b.setText(row[6]);
            temp=row[0];
            String UPID20P = "|O|"+temp.substring(0,4)+"|"+temp.substring(16,18)+"|"+temp.substring(18,20)+"|"
                    +temp.substring(4,8)+"|"+temp.substring(8,12)+"|"+temp.substring(12,14)+"|"+temp.substring(14,16)+"|";
            upid20V1.setText(UPID20P);
            BCSUM1.setText(row[2]);
            temp = row[3];
            if(temp.equals("-1")) temp="---";
            SCV1.setText(temp);
            String FlagList = row[5].substring(2);
            lblFlagsRow.setText(FlagList.substring(4,5)+"|  |"+FlagList.substring(8,9)+"|"+FlagList.substring(5,6)+"|  |  |"
                    +FlagList.substring(2,3)+"|"+FlagList.substring(3,4)+"|"+FlagList.substring(1,2)+"|");
            lblIVAl.setText(FlagList.substring(6,7)+"|"+row[8]);
            lblGaveAwayBrow.setText(FlagList.substring(7,8));
            lblSrcB.setText(FlagList.substring(0,1));
            String regdate=row[4];
            lblRegDatBrow.setText(regdate.substring(0,2)+regdate.substring(3,5)+"|"+regdate.substring(6,8));
            tpReadV1.setVisible(true);
            tpReadV2.setVisible(false);
        }       
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new IfatzehChgFlag().setVisible(true);
            }
        });
    }
    //</editor-fold>
    
    // <editor-fold defaultstate="collapsed" desc="GUI_Vars">
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup ALZRBG;
    private javax.swing.ButtonGroup ArightsBG;
    private javax.swing.JLabel BCSUM1;
    private javax.swing.JLabel BuyDateV2;
    private javax.swing.JLabel CommExists;
    private javax.swing.JTextArea CommV1b;
    private javax.swing.JTextArea CommV2;
    private javax.swing.JTextArea CommV2b;
    private javax.swing.JTextArea Comment;
    private javax.swing.JLabel DependencyDataset;
    private javax.swing.JLabel FlagRow;
    private javax.swing.JPanel FlagsnStuff;
    private javax.swing.ButtonGroup GaveAWayBG;
    private javax.swing.JLabel KKV2;
    private javax.swing.JLabel LBLCsum;
    private javax.swing.JLabel LBLMDIF;
    private javax.swing.JLabel LBLUpidCsum;
    private javax.swing.JList LSTUPids;
    private javax.swing.JLabel LblUPID20;
    private javax.swing.JPanel LowerCOntainer;
    private javax.swing.ButtonGroup MDFYBG;
    private javax.swing.JLabel MFIDV2;
    private javax.swing.ButtonGroup NSE1BG;
    private javax.swing.ButtonGroup NSE2BG;
    private javax.swing.ButtonGroup NonsellableBG;
    private javax.swing.JButton PreVerify;
    private javax.swing.JLabel RegDate;
    private javax.swing.JLabel RwgDAteV2;
    private javax.swing.JLabel SCV1;
    private javax.swing.JButton Sign;
    private javax.swing.JButton UPAssistant;
    private javax.swing.JLabel UpidCsum2;
    private javax.swing.JPanel UpperArea;
    private javax.swing.ButtonGroup VIT1BG;
    private javax.swing.JButton btnEnabOVR;
    private javax.swing.JButton btnPachUpidAssist;
    private javax.swing.JButton btnRefresh;
    private javax.swing.JButton btnSubmitToDb;
    private javax.swing.JButton btnSwitchMode;
    private javax.swing.JCheckBox cXoverride;
    private javax.swing.JCheckBox cxError;
    private javax.swing.JLabel internalValue;
    private javax.swing.JTextField internalValueN;
    private javax.swing.JLabel ival_alzr_src;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JScrollPane jScrollPane9;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    private javax.swing.JTable jTable1;
    private javax.swing.JTextField kkCsum;
    private javax.swing.JLabel lblBDAT;
    private javax.swing.JLabel lblCommFlag;
    private javax.swing.JLabel lblCommentsLine1;
    private javax.swing.JLabel lblCsumV20_14;
    private javax.swing.JLabel lblCsumV2_14_28;
    private javax.swing.JLabel lblDates;
    private javax.swing.JLabel lblFlagLine;
    private javax.swing.JLabel lblFlagsRow;
    private javax.swing.JLabel lblFlagsV;
    private javax.swing.JLabel lblGaveAwayBrow;
    private javax.swing.JLabel lblGaveAwayPr;
    private javax.swing.JLabel lblGenViaPHP;
    private javax.swing.JLabel lblIVAl;
    private javax.swing.JLabel lblIVAlFlagsV2;
    private javax.swing.JLabel lblKcode;
    private javax.swing.JLabel lblNumercArea;
    private javax.swing.JLabel lblRegDatBrow;
    private javax.swing.JLabel lblRegDate;
    private javax.swing.JLabel lblShortCode;
    private javax.swing.JLabel lblSrcB;
    private javax.swing.JLabel lblTopFlagsV2;
    private javax.swing.JLabel lblUPID8;
    private javax.swing.JLabel lblV1AlzrUnselll;
    private javax.swing.JLabel lblcsumv2_28;
    private javax.swing.JLabel mdfyrow;
    private javax.swing.JPanel pBrowse;
    private javax.swing.JPanel pIp;
    private javax.swing.JPanel pPreview;
    private javax.swing.JPanel panehViewV2Hinten;
    private javax.swing.JPanel panelKKPreviewB;
    private javax.swing.JPanel panelKKPreviewF;
    private javax.swing.JPanel panelViewV2vorne;
    private javax.swing.JTabbedPane previewVers1;
    private javax.swing.JTabbedPane previewVers2;
    private javax.swing.JTextField regDAteN;
    private javax.swing.JTabbedPane tpOVW;
    private javax.swing.JTabbedPane tpReadV1;
    private javax.swing.JTabbedPane tpReadV2;
    private javax.swing.JTextField txBDAT;
    private javax.swing.JTextArea txaCommRest;
    private javax.swing.JTextArea txaCsumV2;
    private javax.swing.JTextField txfUPID;
    private javax.swing.JLabel upid20V1;
    private javax.swing.JLabel upid8v2;
    private javax.swing.JLabel upidNumVals;
    private javax.swing.JTextField upidcsum;
    private javax.swing.JToggleButton versTogg;
    // End of variables declaration//GEN-END:variables
    //</editor-fold>
}