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.

Oracle 12c: SQL
3rd Edition
ISBN:9781305251038
Author:Joan Casteel
Publisher:Joan Casteel
Chapter1: Overview Of Database Concepts
Section: Chapter Questions
Problem 4RQ
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
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage