0% found this document useful (0 votes)
26 views3 pages

Sales Report

The document contains a Java class named 'reportsales' that manages sales data in a database. It includes methods to count sales records and automatically save new sales entries into a database table. The class uses JDBC for database connectivity and handles exceptions with JOptionPane for error reporting.

Uploaded by

zang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views3 pages

Sales Report

The document contains a Java class named 'reportsales' that manages sales data in a database. It includes methods to count sales records and automatically save new sales entries into a database table. The class uses JDBC for database connectivity and handles exceptions with JOptionPane for error reporting.

Uploaded by

zang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

package jade_pos;

import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.ResultSet;

import java.sql.Statement;

import javax.swing.JOptionPane;

/**

* @author Admin

*/

public class reportsales {

int code=0;

int or=0;

String name="";

int orderNum=0;

double pr = 0.00;

String date="";

String cashier="";

public void count(){

try{

Class.forName(connector.driver);

Connection con = DriverManager.getConnection(connector.url, connector.username,


connector.password);
Statement st = con.createStatement();

String sql="select count(sales_id) from jadedb.sales_table";

ResultSet rs = st.executeQuery(sql);

while (rs.next()){

code = rs.getInt(1);

st.execute(sql);

st.close();

con.close();

rs.close();

}catch(Exception e){

JOptionPane.showMessageDialog(null, e);

public reportsales(int or, String name, int orderNum, double pr, String date, String cashier){

this.or=or;

this.name=name;

this.orderNum=orderNum;

this.pr=pr;

this.date=date;

this.cashier=cashier;

count();

autoSave();

}
public void autoSave(){

try{

Class.forName(connector.driver);

Connection con = DriverManager.getConnection(connector.url, connector.username,


connector.password);

Statement st = con.createStatement();

String sql="insert into jadedb.sales_table values("+code+", "+or+", '"+name+"', "+orderNum+",


"+pr+", '"+date+"', '"+cashier+"')";

st.execute(sql);

st.close();

con.close();

}catch(Exception e){

JOptionPane.showMessageDialog(null, e);

You might also like