The Save Transaction button depicted in the screen attached is used to save relevant data to the sales table and the salesdetails tables from the depicted schema. When this button is clicked it calls the saveTransaction() function that is within the PosDAO class, it passes to this function an ArrayList of salesdetails object, this list contains the data entered into the jTable which is the products and qty being sold. Write the saveTransaction function. You are to loop through the items and get the total sales, next you are to insert the current date and the total sales into the sales table. Reminder that the sales table SalesNumber field is set to AUTO-INCREMENT, hence the reason for only entering the total sales and current date in sales table.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The Save Transaction button depicted in the screen attached is used to save relevant data to the sales table and the salesdetails tables from the depicted schema. When this button is clicked it calls the saveTransaction() function that is within the PosDAO class, it passes to this function an ArrayList of salesdetails object, this list contains the data entered into the jTable which is the products and qty being sold.
Write the saveTransaction function. You are to loop through the items and get the total sales, next you are to insert the current date and the total sales into the sales table. Reminder that the sales table SalesNumber field is set to AUTO-INCREMENT, hence the reason for only entering the total sales and current date in sales table.

public class PosDAO {
}
private Connection conn;
PreparedStatement stmt = null;
public boolean openConnection(){
try {
// db parameters
String url = "jdbc:mysql://localhost: 4306/swen2005";
String user = "root";
String password = "";
// create a connection to the database
conn - DriverManager.getConnection(url, user, password);
if (conn!= null)
return true;
}
catch(SQLException e) {
System.out.println(e.getMessage());
}
|}
return false;
}
public void closeConnection ()
return false;
try
{
}
if (conn!=null)
conn.close();
catch(SQLException ex) {
System.out.println(ex.getMessage());
}
public void saveTransaction(List <Salesdetails> items) throws SQLException{
}
public List<Pos> getSales (String fromDate, String toDate) {
VO swen2005 sales
SalesNumber: int(10)
SalesDate : date
# Sales Total: decimal(7,2)
v swen2005 salesdetails
number: int(10)
# SalesNumber: int(10)
prodid: varchar(20)
# price : decimal(7,2)
# qty: int(10)
V
class Product{
public int number;
public String prodID;
public String prodName;
public float prodPrice;
public int prodOnHand;
Product(int num, String id, String name, float price, int qty)
{
number-num;
prodID=id;
prodName=name;
prodPrice-price;
prodonHand-qty;
}
class Salesdetails {
public String prodcode;
public String prodname;
public double unit;
public int qty;
public Salesdetails(String pcode, String pname, double ucost, int q)
{
this.prodcode = pcode;
this.qty = q;
this.prodname = pname;
this.unit = ucost;
swen2005 products
number: int(11)
prodid: varchar(20)
prodname : varchar(30)
#price: decimal(10,2)
#onhand int(11)
public class Pos {
public String salesDate;
public int sales Number;
public String prodcode;
public String prodname;
public double salesTotal;
public double unit;
public int qty;
public Pos (String sd,int sn, String pcode, String pname,double ucost, int q, double st)
this.salesDate = sd;
this.salesNumber - sn;
this.prodcode - pcode;
this.qty = 9;
this.prodname - pname;
this.unit = ucost;
this.salesTotal = st;
Transcribed Image Text:public class PosDAO { } private Connection conn; PreparedStatement stmt = null; public boolean openConnection(){ try { // db parameters String url = "jdbc:mysql://localhost: 4306/swen2005"; String user = "root"; String password = ""; // create a connection to the database conn - DriverManager.getConnection(url, user, password); if (conn!= null) return true; } catch(SQLException e) { System.out.println(e.getMessage()); } |} return false; } public void closeConnection () return false; try { } if (conn!=null) conn.close(); catch(SQLException ex) { System.out.println(ex.getMessage()); } public void saveTransaction(List <Salesdetails> items) throws SQLException{ } public List<Pos> getSales (String fromDate, String toDate) { VO swen2005 sales SalesNumber: int(10) SalesDate : date # Sales Total: decimal(7,2) v swen2005 salesdetails number: int(10) # SalesNumber: int(10) prodid: varchar(20) # price : decimal(7,2) # qty: int(10) V class Product{ public int number; public String prodID; public String prodName; public float prodPrice; public int prodOnHand; Product(int num, String id, String name, float price, int qty) { number-num; prodID=id; prodName=name; prodPrice-price; prodonHand-qty; } class Salesdetails { public String prodcode; public String prodname; public double unit; public int qty; public Salesdetails(String pcode, String pname, double ucost, int q) { this.prodcode = pcode; this.qty = q; this.prodname = pname; this.unit = ucost; swen2005 products number: int(11) prodid: varchar(20) prodname : varchar(30) #price: decimal(10,2) #onhand int(11) public class Pos { public String salesDate; public int sales Number; public String prodcode; public String prodname; public double salesTotal; public double unit; public int qty; public Pos (String sd,int sn, String pcode, String pname,double ucost, int q, double st) this.salesDate = sd; this.salesNumber - sn; this.prodcode - pcode; this.qty = 9; this.prodname - pname; this.unit = ucost; this.salesTotal = st;
Point of Sales Screen
Product Code 4225
Code
9813
3700
Product Name
Wine Muscadet Sur Lie
Compound - Rum
Save Transaction
Cancel Transaction
Quantity 20
Unit Price
34.1
32.15
I
Qty Total
15
26
X
511.5
835.9
1347.40
Transcribed Image Text:Point of Sales Screen Product Code 4225 Code 9813 3700 Product Name Wine Muscadet Sur Lie Compound - Rum Save Transaction Cancel Transaction Quantity 20 Unit Price 34.1 32.15 I Qty Total 15 26 X 511.5 835.9 1347.40
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Table
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education