Exemple #1
0
  private void TableMouseClicked(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_TableMouseClicked
    try {
      ResultSet rs2;
      PreparedStatement ps2;
      Connection con;

      con = DbConn.dbConnection();
      int row = Table.getSelectedRow();
      String table_click = Table.getModel().getValueAt(row, 1).toString();

      String sql =
          "select item_name,item_category,item_code,selling_rate,purchase_rate,warranty,supplier_name,opening_stock,re_order,brand_company from item where item_code like '"
              + table_click
              + "'";
      ps2 = con.prepareStatement(sql);
      rs2 = ps2.executeQuery();
      if (rs2.next()) {
        String add1 = rs2.getString("item_name");
        itemName.setText(add1);
        String add2 = rs2.getString("item_category");
        itemCombo.setSelectedItem(add2);
        String add3 = rs2.getString("item_code");
        itemcode.setText(add3);
        String add4 = rs2.getString("selling_rate");
        sellR.setText(add4);
        String add5 = rs2.getString("purchase_rate");
        purchaseR.setText(add5);
        String add6 = rs2.getString("warranty");
        warranty.setText(add6);
        String add7 = rs2.getString("supplier_name");
        supplierNa.setSelectedItem(add7);
        String add8 = rs2.getString("opening_stock");
        openSto.setText(add8);
        String add9 = rs2.getString("re_order");
        reOrder.setText(add9);
        String add10 = rs2.getString("brand_company");
        brandCompany.setSelectedItem(add10);
      }
    } catch (Exception ex) {
      JOptionPane.showMessageDialog(this, ex);
    }
  } // GEN-LAST:event_TableMouseClicked
Exemple #2
0
  public void loadCombo2() {
    try {
      Connection con = DbConn.dbConnection();
      Statement stmt = con.createStatement();
      List plist = new ArrayList();
      ResultSet rs =
          stmt.executeQuery("select distinct(brand_name) from brand order by brand_name");
      while (rs.next()) {
        plist.add(rs.getString("brand_name"));
      }
      brandCompany.setModel(new DefaultComboBoxModel(plist.toArray()));
      brandCompany.insertItemAt("Select Brand", 0);
      brandCompany.setSelectedIndex(0);

    } catch (Exception e) {

      e.printStackTrace();
    }
  }
Exemple #3
0
  /** Creates new form AddItem */
  public AddItem() {
    initComponents();
    con = DbConn.dbConnection();

    getData();
    itemName.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            supplierNa.requestFocusInWindow();
          }
        });
    supplierNa.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            brandCompany.requestFocusInWindow();
          }
        });
    brandCompany.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            openSto.requestFocusInWindow();
          }
        });
    openSto.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            purchaseR.requestFocusInWindow();
          }
        });
    purchaseR.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            sellR.requestFocusInWindow();
          }
        });
    sellR.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            warranty.requestFocusInWindow();
          }
        });

    warranty.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            reOrder.requestFocusInWindow();
          }
        });
    reOrder.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            itemCombo.requestFocusInWindow();
          }
        });

    loadCombo();
    loadCombo1();
    loadCombo2();
  }