Using the getSales() function as a reference, create a function thatt will take one parameter (string code) which is a product code (or part thereof), and when the search button is pressed, all sales that include this product code (or part thereof) will be displayed in the jTable. The date boxes in the GUI will be replaced with a text box. The schema of the database where the queries are being used is also attached.    public List getSales(String fromDate, String toDate){            List salesList = new ArrayList<>();     try {         String query = "SELECT sales_date, sales_number, prod_code, prod_name, unit_cost, quantity, sales_total "                      + "FROM Sales, SalesDetails, Product "                      + "WHERE Sales.sales_number = SalesDetails.sales_number "                      + "AND SalesDetails.prod_code = Product.prod_id "                      + "AND sales_date BETWEEN ? AND ?";         PreparedStatement stmt = conn.prepareStatement(query);         stmt.setString(1, fromDate);         stmt.setString(2, toDate);         ResultSet rs = stmt.executeQuery();         while (rs.next()) {             String salesDate = rs.getString("sales_date");             int salesNumber = rs.getInt("sales_number");             String prodCode = rs.getString("prod_code");             String prodName = rs.getString("prod_name");             double unitCost = rs.getDouble("unit_cost");             int quantity = rs.getInt("quantity");             double salesTotal = rs.getDouble("sales_total");             Pos pos = new Pos(salesDate, salesNumber, prodCode, prodName, unitCost, quantity, salesTotal);             salesList.add(pos);         }     } catch (SQLException ex) {         System.out.println(ex.getMessage());     }     return salesList;     }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Using the getSales() function as a reference, create a function thatt will take one parameter (string code) which is a product code (or part thereof), and when the search button is pressed, all sales that include this product code (or part thereof) will be displayed in the jTable. The date boxes in the GUI will be replaced with a text box. The schema of the database where the queries are being used is also attached. 
 
public List<Pos> getSales(String fromDate, String toDate){
           List<Pos> salesList = new ArrayList<>();
    try {
        String query = "SELECT sales_date, sales_number, prod_code, prod_name, unit_cost, quantity, sales_total "
                     + "FROM Sales, SalesDetails, Product "
                     + "WHERE Sales.sales_number = SalesDetails.sales_number "
                     + "AND SalesDetails.prod_code = Product.prod_id "
                     + "AND sales_date BETWEEN ? AND ?";
        PreparedStatement stmt = conn.prepareStatement(query);
        stmt.setString(1, fromDate);
        stmt.setString(2, toDate);
        ResultSet rs = stmt.executeQuery();
        while (rs.next()) {
            String salesDate = rs.getString("sales_date");
            int salesNumber = rs.getInt("sales_number");
            String prodCode = rs.getString("prod_code");
            String prodName = rs.getString("prod_name");
            double unitCost = rs.getDouble("unit_cost");
            int quantity = rs.getInt("quantity");
            double salesTotal = rs.getDouble("sales_total");
            Pos pos = new Pos(salesDate, salesNumber, prodCode, prodName, unitCost, quantity, salesTotal);
            salesList.add(pos);
        }
    } catch (SQLException ex) {
        System.out.println(ex.getMessage());
    }
    return salesList;
    }
Sales Finder Screen
Sales date from:
2021-03-09
Sales Date
2021-03-15
2021-03-15
2021-03-15
2021-03-20
2021-03-20
2021-03-20
2021-03-20
2021-03-20
2021-03-21
Sales date to:
2021-03-23
Sales Number Product Code
4 4225
4
9813
4 3700
5 4225
5 9813
5 3700
6 5486
6 6097
7 4225
Search
Product Name
Cheese Feta
Wine Muscadet Sur Lie
Compound - Rum
Cheese Feta
Wine Muscadet Sur Lie
Compound Rum
Plasticknivesblack
Sage Ground Wiberg
Cheese Feta
Price
21.77
34.1
32.15
21.77
34.1
32.15
11.08
16.49
21.77
Qty
15
7
2
10
15
4
12
6
5
Total
X
326.55
238.7
64.3
217.7
511.5
128.6
132.96
98.94
108.85
Transcribed Image Text:Sales Finder Screen Sales date from: 2021-03-09 Sales Date 2021-03-15 2021-03-15 2021-03-15 2021-03-20 2021-03-20 2021-03-20 2021-03-20 2021-03-20 2021-03-21 Sales date to: 2021-03-23 Sales Number Product Code 4 4225 4 9813 4 3700 5 4225 5 9813 5 3700 6 5486 6 6097 7 4225 Search Product Name Cheese Feta Wine Muscadet Sur Lie Compound - Rum Cheese Feta Wine Muscadet Sur Lie Compound Rum Plasticknivesblack Sage Ground Wiberg Cheese Feta Price 21.77 34.1 32.15 21.77 34.1 32.15 11.08 16.49 21.77 Qty 15 7 2 10 15 4 12 6 5 Total X 326.55 238.7 64.3 217.7 511.5 128.6 132.96 98.94 108.85
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)
swen2005 products
number : int(11)
prodid: varchar(20)
Ⓒ prodname : varchar(30)
# price : decimal(10,2)
#onhand int(11)
Transcribed Image Text: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) swen2005 products number : int(11) prodid: varchar(20) Ⓒ prodname : varchar(30) # price : decimal(10,2) #onhand int(11)
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY