Package clips.service

Source Code of clips.service.DialogTransactionList

/*
* DialogTransactionList.java
*
* Created on 27 Май 2008 г., 18:26
*/

package clips.service;

import clips.delegate.contract.ServisePriceData;
import cli_fmw.main.ClipsException;
import clips.delegate.service.MoneyTransactionLocal;
import clips.delegate.service.SerRenLocal;
import cli_fmw.utils.ModalDialog;
import cli_fmw.utils.table_config_states.StateSaver;
import cli_fmw.utils.table_config_states.TableState;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.util.List;
import javax.swing.ListSelectionModel;

/**
*
* @author  vip
*/
public class DialogTransactionList extends ModalDialog {
    SerRenLocal serRenLocal;
   

   
    /** Creates new form DialogTransactionList */
    public DialogTransactionList(java.awt.Frame parent, SerRenLocal serRenLocal) throws ClipsException {
        super(parent, "Список денежных операций", null);
        initComponents();
        Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
        Rectangle dlgSize = this.getBounds();
        this.setLocation((scrSize.width - dlgSize.width) / 2, (scrSize.height - dlgSize.height) / 2);

        this.serRenLocal = serRenLocal;
       
        setScreenFields();
        reloadTable();
    resizeColumn();
    StateSaver.attachTo(this);
    }

    private void resizeColumn() {
        TableState          state = new TableState();
    state.setPreferredWidth(TableModelTransactionList.COL_DATE,    6);
    state.setPreferredWidth(TableModelTransactionList.COL_CASHIER,  16);
    state.setPreferredWidth(TableModelTransactionList.COL_MONEY,  6);
    state.setPreferredWidth(TableModelTransactionList.COL_DESC,    16);
    state.setPreferredWidth(TableModelTransactionList.COL_ORDERED,  6);
      StateSaver.setDefaultState(this, tableTransaction, state);
  }
  
    private void setScreenFields() throws ClipsException {
        Object s = "";
       
        labServiceName.setText(serRenLocal.getService().getTitle());
        ServisePriceData contractServiceData = serRenLocal.getContractService();

        if (contractServiceData == null) {
            return;
        }
        s = String.format("%.2f",((float)contractServiceData.getPrice())/100);
        labPrice.setText(s.toString());

        s = String.format("%.2f",((float)contractServiceData.getMoney())/100);
        labMoney.setText(s.toString());

        s = Integer.toString(serRenLocal.getCalculatedDiscount());
        labDiscount.setText(s.toString());

        s = String.format("%.2f",((float)serRenLocal.getTransactionSumm())/100);
        labTransactionSumm.setText(s.toString());

        float toPay = Math.round(contractServiceData.getLack() * (1 - (float) serRenLocal.getCalculatedDiscount() / 100));
        labToPayWithDisc.setText(String.format("%.2f", (toPay) / 100));

        float lack = toPay - serRenLocal.getTransactionSumm();
        labTheRest.setText(String.format("%.2f", (lack) / 100));
    }
   
    private void reloadTable() throws ClipsException {
        List<MoneyTransactionLocal> transactionList = serRenLocal.getTransactionList();
        tableTransaction.setModel(new TableModelTransactionList(transactionList));       
        tableTransaction.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);           
    }
   

    /** 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() {
        java.awt.GridBagConstraints gridBagConstraints;

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        labMoney = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        labPrice = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        labDiscount = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        labToPayWithDisc = new javax.swing.JLabel();
        labServiceName = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tableTransaction = new cli_fmw.utils.sorted_table.SortedTable();
        jPanel3 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        labTheRest = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        labTransactionSumm = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel2.setLayout(new java.awt.GridBagLayout());

        jLabel2.setText("Сумма, оплачиваемая по контракту:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 6);
        jPanel2.add(jLabel2, gridBagConstraints);

        labMoney.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        jPanel2.add(labMoney, gridBagConstraints);

        jLabel1.setText("Стоимость услуги:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(jLabel1, gridBagConstraints);

        labPrice.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        jPanel2.add(labPrice, gridBagConstraints);

        jLabel3.setText("Скидка на услугу:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(jLabel3, gridBagConstraints);

        labDiscount.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        jPanel2.add(labDiscount, gridBagConstraints);

        jLabel5.setText("Оплатить с учетом скидки:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel2.add(jLabel5, gridBagConstraints);

        labToPayWithDisc.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 3;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        jPanel2.add(labToPayWithDisc, gridBagConstraints);

        labServiceName.setText("...");
        labServiceName.setBorder(javax.swing.BorderFactory.createTitledBorder("Услуга"));

        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(475, Short.MAX_VALUE)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addComponent(labServiceName, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 737, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(labServiceName)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jScrollPane2.setBorder(javax.swing.BorderFactory.createTitledBorder("Список денежных операций"));

        tableTransaction.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        jScrollPane2.setViewportView(tableTransaction);

        jPanel3.setLayout(new java.awt.GridBagLayout());

        jLabel4.setText("Осталось оплатить:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 13);
        jPanel3.add(jLabel4, gridBagConstraints);

        labTheRest.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        jPanel3.add(labTheRest, gridBagConstraints);

        jLabel6.setText("Оплачено:");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel3.add(jLabel6, gridBagConstraints);

        labTransactionSumm.setText("0");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        jPanel3.add(labTransactionSumm, gridBagConstraints);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 737, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel labDiscount;
    private javax.swing.JLabel labMoney;
    private javax.swing.JLabel labPrice;
    private javax.swing.JLabel labServiceName;
    private javax.swing.JLabel labTheRest;
    private javax.swing.JLabel labToPayWithDisc;
    private javax.swing.JLabel labTransactionSumm;
    private cli_fmw.utils.sorted_table.SortedTable tableTransaction;
    // End of variables declaration//GEN-END:variables
   
}
TOP

Related Classes of clips.service.DialogTransactionList

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.