Skip to content

Commit

Permalink
Additions to Finances and some fixes in datahandler
Browse files Browse the repository at this point in the history
  • Loading branch information
niconunez committed May 1, 2015
1 parent ffe71c9 commit 7661a61
Show file tree
Hide file tree
Showing 28 changed files with 157 additions and 42 deletions.
Binary file modified desktop/classes/.data/desktop.cdi
Binary file not shown.
Binary file modified desktop/classes/desktop/DataHandler.class
Binary file not shown.
Binary file modified desktop/classes/desktop/Employee.class
Binary file not shown.
Binary file modified desktop/classes/desktop/Finance$1.class
Binary file not shown.
Binary file modified desktop/classes/desktop/Finance$2.class
Binary file not shown.
Binary file modified desktop/classes/desktop/Finance$3.class
Binary file not shown.
Binary file modified desktop/classes/desktop/Finance$4.class
Binary file not shown.
Binary file modified desktop/classes/desktop/Finance$5.class
Binary file not shown.
Binary file modified desktop/classes/desktop/Finance$6.class
Binary file not shown.
Binary file modified desktop/classes/desktop/Finance$7.class
Binary file not shown.
Binary file modified desktop/classes/desktop/Finance.class
Binary file not shown.
Binary file modified desktop/classes/desktop/ManagerProfile$1.class
Binary file not shown.
Binary file modified desktop/classes/desktop/ManagerProfile$2.class
Binary file not shown.
Binary file modified desktop/classes/desktop/ManagerProfile$3.class
Binary file not shown.
Binary file modified desktop/classes/desktop/ManagerProfile$4.class
Binary file not shown.
Binary file modified desktop/classes/desktop/ManagerProfile$5.class
Binary file not shown.
Binary file modified desktop/classes/desktop/ManagerProfile$6.class
Binary file not shown.
Binary file modified desktop/classes/desktop/ManagerProfile$7.class
Binary file not shown.
Binary file modified desktop/classes/desktop/ManagerProfile$8.class
Binary file not shown.
Binary file modified desktop/classes/desktop/ManagerProfile$9.class
Binary file not shown.
Binary file modified desktop/classes/desktop/ManagerProfile.class
Binary file not shown.
Binary file modified desktop/classes/desktop/ViewTable.class
Binary file not shown.
9 changes: 9 additions & 0 deletions desktop/desktop.jpr
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@
<list n="url-path"/>
</hash>
</hash>
<hash n="oracle.jdeveloper.runner.RunConfigurations">
<hash n="runConfigurationDefinitions">
<hash n="Default">
<value n="custom" v="false"/>
<value n="name" v="Default"/>
<value n="targetURL"/>
</hash>
</hash>
</hash>
<hash n="oracle.jdevimpl.config.JProjectLibraries">
<list n="exportedReferences">
<hash>
Expand Down
34 changes: 31 additions & 3 deletions desktop/src/desktop/DataHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,40 @@ public ResultSet getAllEmployees() throws SQLException{
public ResultSet getDailySales() throws SQLException{
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
query = "SELECT * FROM Sales WHERE sale_date = '"+fmt.format(date)+"'";
String tempdate = fmt.format(date).toString();
tempdate = tempdate.toUpperCase();
query = "SELECT * FROM Sales WHERE to_char(sale_date, 'MON/DD/YYYY') = '"+tempdate+"'";
System.out.println("\nExecuting query: " + query);
rset = stmt.executeQuery(query);
return rset;
}

//=================================================================
//Method that returns all DailySales
//=================================================================
public ResultSet getWeeklySales() throws SQLException{
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
query = "SELECT * FROM Sales WHERE sale_date = '"+fmt.format(date)+"'";
System.out.println("\nExecuting query: " + query);
rset = stmt.executeQuery(query);
return rset;
}

//=================================================================
//Method that returns all DailySales
//=================================================================
public ResultSet getMonthlySales() throws SQLException{
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
query = "SELECT * FROM Sales WHERE sale_date = '"+fmt.format(date)+"'";
System.out.println("\nExecuting query: " + query);
rset = stmt.executeQuery(query);
return rset;
}




public ResultSet getAllProducts() throws SQLException{
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
Expand Down Expand Up @@ -458,8 +486,8 @@ public static void main(String[] args) throws SQLException {
// System.out.println(datahandler.getRows("Employee"));
// System.out.println(datahandler.getEmployeePicture(1));
// String temp = datahandler.getLoginData(1);
System.out.println(datahandler.fmt.format(datahandler.date));
datahandler.printDailySales();
//System.out.println(datahandler.fmt.format(datahandler.date));
// datahandler.printDailySales();

}
}
22 changes: 12 additions & 10 deletions desktop/src/desktop/Finance.form
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="jButton1" min="-2" pref="122" max="-2" attributes="0"/>
</Group>
<Component id="jSplitPane1" pref="996" max="32767" attributes="0"/>
<Component id="jSplitPane1" pref="867" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
</Group>
Expand All @@ -55,7 +55,7 @@
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jSplitPane1" min="-2" pref="143" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane2" pref="288" max="32767" attributes="0"/>
<Component id="jScrollPane2" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton1" min="-2" pref="46" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
Expand Down Expand Up @@ -170,9 +170,12 @@
</Property>
<Property name="text" type="java.lang.String" value="Daily Sales"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton4ActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JLayeredPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JLayeredPaneSupportLayout$JLayeredPaneConstraintsDescription">
<JLayeredPaneConstraints x="20" y="10" width="140" height="40" layer="0" position="-1"/>
<JLayeredPaneConstraints x="20" y="10" width="140" height="30" layer="0" position="-1"/>
</Constraint>
</Constraints>
</Component>
Expand All @@ -189,9 +192,12 @@
</Property>
<Property name="text" type="java.lang.String" value="Weekly Sales"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton5ActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JLayeredPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JLayeredPaneSupportLayout$JLayeredPaneConstraintsDescription">
<JLayeredPaneConstraints x="20" y="50" width="140" height="40" layer="0" position="-1"/>
<JLayeredPaneConstraints x="20" y="50" width="140" height="30" layer="0" position="-1"/>
</Constraint>
</Constraints>
</Component>
Expand All @@ -213,7 +219,7 @@
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JLayeredPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JLayeredPaneSupportLayout$JLayeredPaneConstraintsDescription">
<JLayeredPaneConstraints x="20" y="90" width="140" height="40" layer="0" position="-1"/>
<JLayeredPaneConstraints x="20" y="90" width="140" height="30" layer="0" position="-1"/>
</Constraint>
</Constraints>
</Component>
Expand Down Expand Up @@ -279,7 +285,7 @@
<Editor/>
<Renderer/>
</Column>
<Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="false">
<Column maxWidth="-1" minWidth="-1" prefWidth="600" resizable="false">
<Title/>
<Editor/>
<Renderer/>
Expand All @@ -299,10 +305,6 @@
<TableHeader reorderingAllowed="false" resizingAllowed="false"/>
</Property>
</Properties>
<Events>
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="AllSalesTableMouseClicked"/>
<EventHandler event="mouseEntered" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="AllSalesTableMouseEntered"/>
</Events>
</Component>
</SubComponents>
</Container>
Expand Down
128 changes: 101 additions & 27 deletions desktop/src/desktop/Finance.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

/**
*
* @author Nicolas Nunez, Martin Bruckner AKA Le Mangonevic
*/
public class Finance extends javax.swing.JFrame {
ImageIcon img = new ImageIcon("C:\\Users\\Nicolas Nunez\\Desktop\\tabit\\desktop\\src\\desktop\\tabitIcon.png");
Font bfont = new Font("Verdana", Font.BOLD, 26);
Font bfont = new Font("Verdana", Font.BOLD, 20);
SimpleDateFormat fmt = new SimpleDateFormat("MMM/dd/yyyy");
DataHandler databit;
String args[] = { };
Expand All @@ -29,7 +30,7 @@ public Finance() throws SQLException {
initComponents();
this.jLabel1.setFont(bfont);
this.jLabel1.setText("Tabit - Finances");
setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH);
//setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH);
this.setLocationRelativeTo(getRootPane());
}

Expand Down Expand Up @@ -92,14 +93,24 @@ public boolean isCellEditable(int rowIndex, int columnIndex) {
jButton4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButton4.setForeground(new java.awt.Color(255, 255, 255));
jButton4.setText("Daily Sales");
jButton4.setBounds(20, 10, 140, 40);
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jButton4.setBounds(20, 10, 140, 30);
jDesktopPane1.add(jButton4, javax.swing.JLayeredPane.DEFAULT_LAYER);

jButton5.setBackground(new java.awt.Color(0, 0, 153));
jButton5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jButton5.setForeground(new java.awt.Color(255, 255, 255));
jButton5.setText("Weekly Sales");
jButton5.setBounds(20, 50, 140, 40);
jButton5.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton5ActionPerformed(evt);
}
});
jButton5.setBounds(20, 50, 140, 30);
jDesktopPane1.add(jButton5, javax.swing.JLayeredPane.DEFAULT_LAYER);

jButton6.setBackground(new java.awt.Color(0, 0, 153));
Expand All @@ -111,7 +122,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton6ActionPerformed(evt);
}
});
jButton6.setBounds(20, 90, 140, 40);
jButton6.setBounds(20, 90, 140, 30);
jDesktopPane1.add(jButton6, javax.swing.JLayeredPane.DEFAULT_LAYER);

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
Expand Down Expand Up @@ -165,18 +176,11 @@ public boolean isCellEditable(int rowIndex, int columnIndex) {
AllSalesTable.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
AllSalesTable.getTableHeader().setResizingAllowed(false);
AllSalesTable.getTableHeader().setReorderingAllowed(false);
AllSalesTable.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
AllSalesTableMouseClicked(evt);
}
public void mouseEntered(java.awt.event.MouseEvent evt) {
AllSalesTableMouseEntered(evt);
}
});
jScrollPane2.setViewportView(AllSalesTable);
AllSalesTable.getColumnModel().getColumn(0).setResizable(false);
AllSalesTable.getColumnModel().getColumn(1).setResizable(false);
AllSalesTable.getColumnModel().getColumn(2).setResizable(false);
AllSalesTable.getColumnModel().getColumn(2).setPreferredWidth(600);
AllSalesTable.getColumnModel().getColumn(3).setResizable(false);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
Expand All @@ -194,7 +198,7 @@ public void mouseEntered(java.awt.event.MouseEvent evt) {
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 996, Short.MAX_VALUE))
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 867, Short.MAX_VALUE))
.addGap(28, 28, 28))
);
layout.setVerticalGroup(
Expand All @@ -205,7 +209,7 @@ public void mouseEntered(java.awt.event.MouseEvent evt) {
.addGap(28, 28, 28)
.addComponent(jSplitPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 288, Short.MAX_VALUE)
.addComponent(jScrollPane2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(19, 19, 19))
Expand All @@ -214,24 +218,68 @@ public void mouseEntered(java.awt.event.MouseEvent evt) {
pack();
}//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
// TODO add your handling code here:
ManagerProfile.main(args);
super.dispose();
}//GEN-LAST:event_jButton1ActionPerformed
DefaultTableModel dtm = (DefaultTableModel) this.AllSalesTable.getModel();
int rows = 0;
try {

rows = databit.getRows("Sales");
System.out.println(rows);
int rowsInTable = this.AllSalesTable.getRowCount();
System.out.println(rowsInTable);
while(rowsInTable < rows){
dtm.addRow(new Object[]{null, null, null, null});
rowsInTable++;
}
loadDailyTable(AllSalesTable, rows);
}catch (SQLException e) {}

}//GEN-LAST:event_jButton4ActionPerformed

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
// TODO add your handling code here:
//WEEKLY
DefaultTableModel dtm = (DefaultTableModel) this.AllSalesTable.getModel();
int rows = 0;
try {

rows = databit.getRows("Sales");
System.out.println(rows);
int rowsInTable = this.AllSalesTable.getRowCount();
System.out.println(rowsInTable);
while(rowsInTable < rows){
dtm.addRow(new Object[]{null, null, null, null});
rowsInTable++;
}
loadWeeklyTable(AllSalesTable, rows);
}catch (SQLException e) {}

}//GEN-LAST:event_jButton5ActionPerformed

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
// TODO add your handling code here:
//Monthly
DefaultTableModel dtm = (DefaultTableModel) this.AllSalesTable.getModel();
int rows = 0;
try {

rows = databit.getRows("Sales");
System.out.println(rows);
int rowsInTable = this.AllSalesTable.getRowCount();
System.out.println(rowsInTable);
while(rowsInTable < rows){
dtm.addRow(new Object[]{null, null, null, null});
rowsInTable++;
}
loadMonthlyTable(AllSalesTable, rows);
}catch (SQLException e) {}
}//GEN-LAST:event_jButton6ActionPerformed

private void AllSalesTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_AllSalesTableMouseClicked
// TODO add your handling code here:
System.out.println(this.AllSalesTable.getSelectedRow() + " " + this.AllSalesTable.getSelectedColumn());
}//GEN-LAST:event_AllSalesTableMouseClicked

private void AllSalesTableMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_AllSalesTableMouseEntered
// TODO add your handling code here:
}//GEN-LAST:event_AllSalesTableMouseEntered
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
ManagerProfile.main(args);
super.dispose(); // TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed

void loadDailyTable(JTable jt, int rows) throws SQLException {
ResultSet dailySales = databit.getDailySales();
Expand All @@ -245,6 +293,32 @@ void loadDailyTable(JTable jt, int rows) throws SQLException {
i++;
}
}

void loadWeeklyTable(JTable jt, int rows) throws SQLException {
ResultSet dailySales = databit.getDailySales();
int i = 0;

while (dailySales.next()) {
jt.getModel().setValueAt(dailySales.getInt(1), i, 0);
jt.getModel().setValueAt(fmt.format(dailySales.getDate(2)), i, 1);
jt.getModel().setValueAt(dailySales.getString(3), i, 2);
jt.getModel().setValueAt(dailySales.getDouble(4), i, 3);
i++;
}
}

void loadMonthlyTable(JTable jt, int rows) throws SQLException {
ResultSet dailySales = databit.getDailySales();
int i = 0;

while (dailySales.next()) {
jt.getModel().setValueAt(dailySales.getInt(1), i, 0);
jt.getModel().setValueAt(fmt.format(dailySales.getDate(2)), i, 1);
jt.getModel().setValueAt(dailySales.getString(3), i, 2);
jt.getModel().setValueAt(dailySales.getDouble(4), i, 3);
i++;
}
}

/**
* @param args the command line arguments
Expand Down
2 changes: 2 additions & 0 deletions desktop/src/desktop/ManagerProfile.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

package desktop;

import desktop.TableList;

import static java.lang.String.valueOf;

import javax.swing.ImageIcon;
Expand Down
4 changes: 2 additions & 2 deletions sqlscripts/addSales.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ VALUES
INSERT
INTO Sales
VALUES
( 4, sysdate, '2 Tacos Asada, 3 Tortas Pollo, 1 Jarrito Mandarina', 15.25, 1);
( 4, sysdate, '2 Tacos Asada, 5 Duvalin, 1 Jarrito Fresa', 8.33, 1);

INSERT
INTO Sales
VALUES
( 5, sysdate, '2 Tacos Asada, 3 Tortas Pollo, 1 Jarrito Mandarina', 15.25, 1);
( 5, sysdate, '1 Tacos Chorizo, 3 Tortas Lengua, 1 Jarrito Toronja', 9.99, 2);

0 comments on commit 7661a61

Please sign in to comment.