Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void btnAddActionPerformed(java.awt.event.ActionEvent evt) {
- Connection conn = null;
- PreparedStatement psm = null;
- String cod = txtCod.getText();
- String sql = "SELECT * FROM produtos WHERE cod = "+cod;
- String nome = null;
- float valor = 0;
- String desc = null;
- try{
- conn = DatabaseConnection.MysqlConnection();
- psm = conn.prepareStatement(sql);
- psm.execute();
- ResultSet result = psm.executeQuery(sql);
- while(result.next()){
- nome = result.getString("nome");
- valor = result.getFloat("valor_m2");
- desc = result.getString("descricao");
- }
- if(txtHeight.getText().equals("") && txtWidth.getText().equals("")){
- float a2 = Float.parseFloat(JOptionPane.showInputDialog(rootPane, "Por favor insira a área da peça", "Área", HEIGHT));
- float valorm = a2 * valor;
- MainForm mf = new MainForm();
- mf.addInTable(cod, nome, a2, valor, valorm);
- this.setVisible(false);
- psm.close();
- conn.close();
- }
- else{
- float alt = Float.parseFloat(txtHeight.getText());
- float lag = Float.parseFloat(txtWidth.getText());
- float area = alt * lag;
- float valorm = area * valor;
- MainForm mf = new MainForm();
- mf.addInTable(cod, nome, area, valor, valorm);
- this.setVisible(false);
- psm.close();
- conn.close();
- }
- }
- catch(Exception ex){
- System.out.println(ex);;
- }
- public void addInTable(String cod, String prod, float area, float prec, float precTot){
- String nom = prod;
- String con = cod;
- String are = Float.toString(area);
- String pre = Float.toString(prec);
- String tot = Float.toString(precTot);
- DefaultTableModel model = (DefaultTableModel) tblMain.getModel();
- model.addRow(new Object[]{con, nom, are, pre, tot});
- float total = 0;
- total = total + precTot;
- lblTrue.setText(Float.toString(total));
- public List<EssaClasseVolta> findAll(){
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement