import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import javax.swing.JOptionPane; import javax.swing.JPanel;
/* import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; import javax.swing.JOptionPane;*/
@SuppressWarnings("serial") public class ItemDetails extends javax.swing.JFrame {
String ID; // 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.JLabel jLabel7; private javax.swing.JButton SaveBTN; private javax.swing.JButton BackBTN; private javax.swing.JTextField ItemcodeTF; private javax.swing.JTextField TypeTF; private javax.swing.JTextField ItemnameTF; private javax.swing.JTextField DescriptionTF; private javax.swing.JTextField ManufaturerTF; private javax.swing.JTextField CostTF;
// End of variables declaration//GEN-END:variables /* public ItemDetails() { initComponents(); }*/
public ItemDetails(String id) { ID= id; initComponents(); // TODO Auto-generated constructor stub } private void initComponents(){ jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); ItemcodeTF = new javax.swing.JTextField(); TypeTF = new javax.swing.JTextField(); ItemnameTF = new javax.swing.JTextField(); DescriptionTF = new javax.swing.JTextField(); ManufaturerTF = new javax.swing.JTextField(); CostTF = new javax.swing.JTextField(); SaveBTN = new javax.swing.JButton(); BackBTN = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("DETAIL FORM"); setResizable(false); getContentPane().setLayout(new AbsoluteLayout()); jLabel1.setFont(new java.awt.Font("Tahoma", 1, 36)); jLabel1.setForeground(new java.awt.Color(153, 0, 153)); jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel1.setText("ADD NEW ITEMS"); getContentPane().add(jLabel1,new AbsoluteConstraints(100, 20, -1, -1)); jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); jLabel2.setForeground(new java.awt.Color(153, 0, 153)); jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel2.setText("Item Code"); getContentPane().add(jLabel2,new AbsoluteConstraints(27, 140, 100, 20)); jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); jLabel3.setForeground(new java.awt.Color(153, 0, 153)); jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel3.setText("Item Name"); getContentPane().add(jLabel3,new AbsoluteConstraints(27, 180, 100, 30)); jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); jLabel4.setForeground(new java.awt.Color(153, 0, 153)); jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel4.setText("Description"); getContentPane().add(jLabel4,new AbsoluteConstraints(35, 220, 80, 20)); jLabel7.setFont(new java.awt.Font("Tahoma", 1, 16)); jLabel7.setForeground(new java.awt.Color(153, 0, 153)); jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel7.setText("Type"); getContentPane().add(jLabel7,new AbsoluteConstraints(360, 260, 80, 20)); jLabel5.setBackground(new java.awt.Color(249, 239, 242)); jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); jLabel5.setForeground(new java.awt.Color(153, 0, 153)); jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel5.setText("Manufacturer"); getContentPane().add(jLabel5, new AbsoluteConstraints(30,260, 100, 20)); jLabel6.setBackground(new java.awt.Color(249, 239, 242)); jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); jLabel6.setForeground(new java.awt.Color(153, 0, 153)); jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel6.setText("Cost(RS.)"); jLabel6.setOpaque(true); getContentPane().add(jLabel6, new AbsoluteConstraints(30, 300, 100, -1)); ItemcodeTF.setFont(new java.awt.Font("Tahoma", 0, 12)); ItemcodeTF.setForeground(new java.awt.Color(153, 0, 153)); getContentPane().add(ItemcodeTF, new AbsoluteConstraints(150, 140, 180, -1)); ItemnameTF.setFont(new java.awt.Font("Tahoma", 0, 12)); ItemnameTF.setForeground(new java.awt.Color(153, 0, 153)); getContentPane().add(ItemnameTF,new AbsoluteConstraints(150, 180, 180, -1)); DescriptionTF.setFont(new java.awt.Font("Tahoma", 0, 12)); DescriptionTF.setForeground(new java.awt.Color(153, 0, 153)); getContentPane().add(DescriptionTF, new AbsoluteConstraints(150, 220, 390, -1)); ManufaturerTF.setFont(new java.awt.Font("Tahoma", 0, 12)); ManufaturerTF.setForeground(new java.awt.Color(153, 0, 153)); getContentPane().add(ManufaturerTF, new AbsoluteConstraints(150,260, 180, -1)); CostTF.setFont(new java.awt.Font("Tahoma", 0, 12)); CostTF.setForeground(new java.awt.Color(153, 0, 153)); getContentPane().add(CostTF,new AbsoluteConstraints(150, 300, 180, -1)); TypeTF.setFont(new java.awt.Font("Tahoma", 0, 12)); TypeTF.setForeground(new java.awt.Color(153, 0, 153)); final String labels[] = { "Tablets", "Capsules", "Syrup" }; final DefaultComboBoxModel model = new DefaultComboBoxModel(labels); final JPanel TypeTF = new JPanel(); JComboBox comboBox1 = new JComboBox(model); comboBox1.setEditable(false); TypeTF.add(comboBox1); getContentPane().add(TypeTF,new AbsoluteConstraints(430, 255, 180, -1)); SaveBTN.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.highlight")); SaveBTN.setFont(new java.awt.Font("Times New Roman", 1, 16)); SaveBTN.setForeground(new java.awt.Color(102, 0, 102)); SaveBTN.setText("SUBMIT"); SaveBTN.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(255, 204, 255), new java.awt.Color(255, 204, 255), new java.awt.Color(153, 0, 153), new java.awt.Color(153, 0, 153))); SaveBTN.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { SaveBTNActionPerformed(evt); } }); getContentPane().add(SaveBTN, new AbsoluteConstraints(110, 380, 90, 40)); BackBTN.setBackground(javax.swing.UIManager.getDefaults().getColor("Button.highlight")); BackBTN.setFont(new java.awt.Font("Times New Roman", 1, 16)); BackBTN.setForeground(new java.awt.Color(102, 0, 102)); BackBTN.setText("BACK"); BackBTN.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(255, 204, 255), new java.awt.Color(255, 204, 255), new java.awt.Color(153, 0, 153), new java.awt.Color(153, 0, 153))); BackBTN.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { BackBTNActionPerformed(evt); } }); getContentPane().add(BackBTN, new AbsoluteConstraints(260, 380, 90, 40)); this.setSize(600, 600); //pack(); } private void SaveBTNActionPerformed(java.awt.event.ActionEvent evt){ try{ Class.forName("com.mysql.jdbc.Driver"); String database = "jdbc:mysql://localhost:3306/medicalstore"; Connection conn = DriverManager.getConnection(database, "root", "sunil"); Statement stmt = conn.createStatement(); String sql = "insert into addnewitem values ( '" + ItemcodeTF.getText() + "','" + ItemnameTF.getText() + "' ,'" + DescriptionTF.getText() + "' , '" + ManufaturerTF.getText() + "' , '" + TypeTF.getText() + "' , '" + CostTF.getText() + "' )" ; stmt.executeUpdate(sql); stmt.close(); conn.close(); } catch( Exception e) { JOptionPane.showMessageDialog(null,"" + e); } } private void BackBTNActionPerformed(java.awt.event.ActionEvent evt){ add m = new add(ID); this.setVisible(false); m.setVisible(true); } /* public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new ItemDetails().setVisible(true); } }); }*/
}
Ads