Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions 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;
}
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
Transcribed Image Text:swen2005 sales SalesNumber: int(10) SalesDate : date # Sales Total : decimal(7,2) V swen2005 salesdetails number: int(10) # SalesNumber : int(10) C prodid: varchar(20) # price : decimal(7,2) # qty: int(10) swen2005 products number : int(11) prodid: varchar(20) C prodname : varchar(30) # price : decimal(10,2) #onhand int(11)
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY