Beruflich Dokumente
Kultur Dokumente
/* * To change this template, choose Tools | Templates * and open the template in the editor. */
/** * * @author AMAL BABY */ public class billing extends javax.swing.JFrame { int c=0; int pri=0; int l;
/** * Creates new form billing */ public billing() { initComponents(); CurrentDate(); } public void CurrentDate(){ Calendar cal=new GregorianCalendar(); int day=cal.get(Calendar.DAY_OF_MONTH); int month=cal.get(Calendar.MONTH); int year=cal.get(Calendar.YEAR); jLabel11.setText(day+"/"+(month+1)+"/"+year);
/** * 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")
pdtn = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jPanel1 = new javax.swing.JPanel(); prc = new javax.swing.JTextField(); qty = new javax.swing.JTextField(); pdt = new javax.swing.JTextField(); jLabel6 = new javax.swing.JLabel(); jButton3 = new javax.swing.JButton(); cpy = new javax.swing.JTextField(); pdtn1 = new javax.swing.JTextField(); jLabel5 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jButton1 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jLabel12 = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); jTextField2 = new javax.swing.JTextField(); jLabel9 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel(); jLabel10 = new javax.swing.JLabel(); jLabel13 = new javax.swing.JLabel(); jLabel11 = new javax.swing.JLabel(); jLabel14 = new javax.swing.JLabel(); jComboBox1 = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
pdtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { pdtnActionPerformed(evt); } }); pdtn.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { pdtnKeyPressed(evt); } public void keyReleased(java.awt.event.KeyEvent evt) { pdtnKeyReleased(evt); } });
}, new String [] { "Product ID", "Product Name", "Company", "Quantity", "Price" } ){ Class[] types = new Class [] { java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Integer.class, java.lang.Integer.class };
jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.b order.BevelBorder.RAISED));
prcActionPerformed(evt); } });
qty.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { qtyActionPerformed(evt); } }); qty.addKeyListener(new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent evt) { qtyKeyReleased(evt); } });
jButton3.setIcon(new
javax.swing.ImageIcon(getClass().getResource("/edit_clear.png"))); // NOI18N jButton3.setText("RESET"); jButton3.setHorizontalAlignment(javax.swing.SwingConstants.LEADING); jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); jButton3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } });
jButton1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/add_to_shopping_cart.png")) ); // NOI18N jButton1.setText("Add To Cart"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } });
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap(27, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addComponent(jButton1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED ) .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(8, 8, 8)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING) .addComponent(jLabel2) .addComponent(jLabel7) .addComponent(jLabel4)
.addComponent(jLabel5) .addComponent(jLabel6)) .addGap(48, 48, 48) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.LEADING, false) .addComponent(pdt) .addComponent(pdtn1) .addComponent(cpy) .addComponent(qty) .addComponent(prc, javax.swing.GroupLayout.PREFERRED_SIZE, 164, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap()))) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADI NG) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGap(25, 25, 25) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(jLabel2)
.addComponent(pdt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(jLabel7) .addComponent(pdtn1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(jLabel4) .addComponent(cpy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(jLabel5) .addComponent(qty, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton4)) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE)
.addComponent(jLabel6) .addComponent(prc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 38, Short.MAX_VALUE) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Align ment.BASELINE) .addComponent(jButton1) .addComponent(jButton3)) .addGap(42, 42, 42)) );
jButton2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N jButton2.setText("Print"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } });
jLabel9.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jLabel8.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 18)); // NOI18N jLabel8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Products%20Add.jpg"))); // NOI18N jLabel8.setText("Add To Cart"); jLabel8.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jLabel10.setFont(new java.awt.Font("Tw Cen MT Condensed Extra Bold", 1, 18)); // NOI18N jLabel10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/add-to-cart-icon.jpg"))); // NOI18N jLabel10.setText("Cart"); jLabel10.setBorder(javax.swing.BorderFactory.createEtchedBorder());
jLabel13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Arrow%20back.png"))); // NOI18N jLabel13.setText("Back"); jLabel13.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jLabel13.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jLabel13MouseClicked(evt);
} });
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(182, 182, 182) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 168, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(210, 210, 210) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 273, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(206, 206, 206) .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 88, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(79, 79, 79)
.addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(267, 267, 267) .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(79, 79, 79) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addGroup(layout.createSequentialGroup() .addGap(144, 144, 144) .addComponent(pdtn, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addGap(48, 48, 48) .addComponent(jLabel3)) .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(62, 62, 62) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 624, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup()
.addGap(839, 839, 839) .addComponent(jLabel12) .addGap(10, 10, 10) .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(10, 10, 10) .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(10, 10, 10) .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addGroup(layout.createSequentialGroup() .addGap(11, 11, 11) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addComponent(jLabel1) .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addGap(22, 22, 22) .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(41, 41, 41) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addComponent(jLabel8) .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(11, 11, 11) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addGroup(layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addGroup(layout.createSequentialGroup() .addGap(29, 29, 29) .addComponent(pdtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup() .addGap(31, 31, 31) .addComponent(jLabel3))) .addGap(18, 18, 18) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 453, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LE ADING) .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup() .addGap(2, 2, 2) .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TR AILING, false) .addComponent(jTextField2, javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap(24, Short.MAX_VALUE))
);
private void pdtnActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
private void pdtnKeyReleased(java.awt.event.KeyEvent evt) { String m=pdtn.getText(); DefaultTableModel model=(DefaultTableModel) jTable1.getModel(); try
{ Class.forName("java.sql.DriverManager"); Connection con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/ p2p_library","root","tiger"); Statement stmt=(Statement) con.createStatement(); String query="SELECT *FROM amal1 where product_name='"+m+"';";
ResultSet rs=stmt.executeQuery(query);
} } catch(Exception e) {
JOptionPane.showMessageDialog(this, e.getMessage());
private void prcActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
private void qtyActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
private void pdtActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { qty.setText(""); prc.setText(""); pdt.setText(""); pdtn.setText(""); pdtn1.setText(""); qty.setText("");
private void cpyActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
private void pdtn1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: }
cpy.setText("");
try { Class.forName("java.sql.DriverManager"); Connection con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/ p2p_library","root","tiger"); Statement stmt=(Statement) con.createStatement(); String query="INSERT INTO report VALUES('"+a+"','"+b+"','"+f+"','"+am+"','"+amd+"','"+q+"','"+y+"');"; stmt.executeUpdate(query);
} catch(Exception e) { JOptionPane.showMessageDialog(this,e.getMessage());
private void jLabel13MouseClicked(java.awt.event.MouseEvent evt) { this.setVisible(false); } // TODO add your handling code here:
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { String j=jTextField2.getText(); MessageFormat header=new MessageFormat("ATS GLOBAL SUPERMARKET"); MessageFormat footer=new MessageFormat("TOTAL = '"+j+"'/-"); try { jTable1.print(JTable.PrintMode.NORMAL, header, footer);
} catch(java.awt.print.PrinterException e){ System.err.format("canot print", e.getMessage()); }// TODO add your handling code here: }
try { Class.forName("java.sql.DriverManager"); Connection con=(Connection)DriverManager.getConnection("jdbc:mysql://localhost:3306/ p2p_library","root","tiger"); Statement stmt=(Statement)con.createStatement(); String query="SELECT PRICE,QUANTITY FROM amal1 WHERE product_name='"+pd+"';"; ResultSet rs=stmt.executeQuery(query); if(rs.next()) {
if(pr>=amd) { c=amd*qti;
String b=Integer.toString(c); prc.setText(b); int pm=pr-amd; String qury="UPDATE amal1 SET QUANTITY='"+pm+"' where product_name='"+pd+"';";
stmt.executeUpdate(qury);
} else {
JOptionPane.showMessageDialog(null,"No Stock"); }
/** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(billing.class.getName()).log(java.util.loggin g.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(billing.class.getName()).log(java.util.loggin g.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(billing.class.getName()).log(java.util.loggin g.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(billing.class.getName()).log(java.util.loggin g.Level.SEVERE, null, ex);
} //</editor-fold>
/* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new billing().setVisible(true); } }); } // Variables declaration - do not modify private javax.swing.JTextField cpy; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JButton jButton3; private javax.swing.JButton jButton4; private javax.swing.JComboBox jComboBox1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel14; 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.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable jTable1; private javax.swing.JTextField jTextField2; private javax.swing.JTextField pdt; private javax.swing.JTextField pdtn; private javax.swing.JTextField pdtn1; private javax.swing.JTextField prc; private javax.swing.JTextField qty; // End of variables declaration }