Package clips.service.discount.card

Source Code of clips.service.discount.card.DialogNewDiscountCard

/*
* DialogNewDiscountCard.java
*
* Created on 29 Июль 2008 г., 16:42
*/
package clips.service.discount.card;

import clips.delegate.client.ClientLocal;
import clips.delegate.service.discount.DiscountCardLocal;
import cli_fmw.main.PageContainer;
import cli_fmw.utils.ModalDialog;
import cli_fmw.main.ClipsException;
import cli_fmw.main.audit.AuditManager;
import cli_fmw.utils.MessageBox;
import cli_fmw.utils.table_config_states.StateSaver;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.Toolkit;

/**
*
* @author  petr
*/
public class DialogNewDiscountCard extends ModalDialog {

    private DiscountCardLocal newCard;
    private ClientLocal client;
    private PanelDiscountCard panelDiscountCard;

    public DialogNewDiscountCard(PageContainer parent, ClientLocal client, AuditManager am) throws ClipsException {
        super((Frame) parent, "Создание новой дисконтной карты", am);
        initComponents();
        newCard = new DiscountCardLocal(client);
        panelDiscountCard = new PanelDiscountCard(parent, newCard);
        pnlDiscountCard.add(panelDiscountCard, BorderLayout.CENTER);
        pnlDiscountCard.revalidate();

        //диалог посередине, занимает 0,25 от плошади экрана
        Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
        this.setBounds(new Rectangle((int) (0.5 * scrSize.width), (int) (0.5 *
                scrSize.height)));
        Rectangle dlgSize = this.getBounds();
        this.setLocation((scrSize.width - dlgSize.width) / 2, (scrSize.height -
                dlgSize.height) / 2);
        this.client = client;
    StateSaver.attachTo(this);
    }

    /** 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() {

        pnlDiscountCard = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        btOK = new javax.swing.JButton();
        btCancel = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        pnlDiscountCard.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        pnlDiscountCard.setLayout(new java.awt.BorderLayout());
        getContentPane().add(pnlDiscountCard, java.awt.BorderLayout.CENTER);

        btOK.setText("Принять");
        btOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btOKActionPerformed(evt);
            }
        });
        jPanel2.add(btOK);

        btCancel.setText("Отмена");
        btCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btCancelActionPerformed(evt);
            }
        });
        jPanel2.add(btCancel);

        getContentPane().add(jPanel2, java.awt.BorderLayout.PAGE_END);

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

private void btOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btOKActionPerformed
    try {
        if (newCard.getCardType().getID() == 0) {
            MessageBox.showWarning("Не указан тип дисконтной карты");
            return;
        }
        panelDiscountCard.save();
        this.setVisible(false);       
        setDlgResult(ModalDialog.DLG_OK);
        client.addDiscountCardToCache(newCard);
    } catch (ClipsException ex) {
        MessageBox.showException(ex);
    }
}//GEN-LAST:event_btOKActionPerformed

private void btCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCancelActionPerformed
    newCard = null;
    this.setVisible(false);
}//GEN-LAST:event_btCancelActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btCancel;
    private javax.swing.JButton btOK;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel pnlDiscountCard;
    // End of variables declaration//GEN-END:variables
}
TOP

Related Classes of clips.service.discount.card.DialogNewDiscountCard

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.