Vous êtes sur la page 1sur 6

CASE 1

CASE 2

CASE 3

CASE 4
CASE 5

CASE 6
CASE 7

CASE 8
CASE 9

CASE 10
CASE11

CODES

LOGIN.java
LOGIN_PANEL METHODS
BUTTON_LOGIN
try { void Select(String query) throws SQLException {
Select("Select * from Employees where Firstname ||' '|| Lastname='" + conn = null;
username.getModel().getSelectedItem().toString().trim()+ "' and AccountPassword ='" stmt = null;
+ password.getText().trim() + "'"); rs = null;
if(rs.next()==true){ conn = DriverManager.getConnection(URL, null, null);
JOptionPane.showMessageDialog(null, "Logged in Successfully!"); stmt = conn.createStatement();
if(rs.getString("Position").equals("Admin") || rs.getString("Position").equals("Manager")){ rs = stmt.executeQuery(query);
Main.admin=true; }
} void insertt(String query) throws SQLException{
Main.cashier=username.getModel().getSelectedItem().toString(); conn = null;
Main.address=rs.getString("Address"); stmt = null;
Main c = new Main(); rs = null;
c.setVisible(true); conn = DriverManager.getConnection(URL, null, null);
this.hide(); stmt = conn.createStatement();
}else{ i= stmt.executeUpdate(query);
JOptionPane.showMessageDialog(null, "Logged in ERROR!"); }
}
CloseConn(); void CloseConn() throws SQLException {
rs.close();
} stmt.close();
catch (HeadlessException e){ conn.close();
} }
catch (SQLException ex) {
Logger.getLogger(LogIn.class.getName()).log(Level.SEVERE, null, ex);
}

REGISTER_PANEL REGISTER_PANEL REGISTER_PANEL


FORM_WINDOW_OPENED BUTTON_SAVE BUTTON_BACK
DefaultComboBoxModel b = new DefaultComboBoxModel(); Enter a = new Enter(); preg.setVisible(false);
try { a.fn=txtfn.getText().trim(); txtfn.setText(null);
Select("Select Firstname ||' '|| Lastname as Nms from a.mn=txtmn.getText().trim(); txtmn.setText(null);
Employees"); a.ln=txtln.getText().trim(); txtln.setText(null);
while(rs.next()){ a.age=Integer.parseInt(sage.getValue().toString().trim()); txtbd.setText(null);
b.addElement(rs.getString("Nms")); a.gen=cbogen.getSelectedItem().toString().trim(); txtadd.setText(null);
} a.bd=txtbd.getText().trim(); txtem.setText(null);
username.setModel(b); a.add=txtadd.getText().trim(); txtph.setText(null);
CloseConn(); a.em=txtem.getText().trim();
} catch (SQLException ex) { a.ph=txtph.getText().trim();
Logger.getLogger(LogIn.class.getName()).log(Level.SEVERE, DECLARATIONS
null, ex); a.doe=DateFormat.getDateInstance(DateFormat.SHORT).format(ja static String URL = "jdbc:derby://localhost:1527/SALES";
} va.lang.System.currentTimeMillis()).trim(); public static Connection conn;
preg.setVisible(false); a.pos=cbopos.getSelectedItem().toString().trim(); Statement stmt;
a.setVisible(true); ResultSet rs;
int i;
MAIN.java
DECLARATIONS BUTTON_SEARCH
DecimalFormat df = new DecimalFormat("#,###,##0.00"); void search() {
DecimalFormat f = new DecimalFormat("000"); DefaultListModel md = new DefaultListModel();
static String URL = "jdbc:derby://localhost:1527/SALES"; md.clear();
public static Connection conn; if (txtsearch.getText() != null) {
Statement stmt; try {
ResultSet rs; Select("Select * from Products where ProductName LIKE '%" +
int qty, transno = 0, prodno, i = 0,stock; txtsearch.getText().trim() + "%'");
double price, subto, total, change, amount, cash; if (rs.next() == true) {
public static String prodname, no, cashier, date, address; while (rs.next()) {
boolean a = true; md.addElement(rs.getString("ProductName"));
public static boolean admin; }
}
lstprod.setModel(md);
BUTTON_SELECT CloseConn();
void sel() { } catch (HeadlessException e) {
qty = } catch (SQLException ex) {
Integer.parseInt(JOptionPane.showInputDialog("Quantity?")); Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
if (qty > 0) { }
try { }
if(stock>0){ }
if(stock>qty){
insertt("update Products set Stock=" + (stock - JLIST_ItemValueChanged void lst() {
qty) +" where Productname='" + prodname +"'"); try {
prodno = prodno + 1; Select("Select * from Products where ProductName='"
addorder(); + lstprod.getSelectedValue() + "'");
} if (rs.next() == true) {
else{ lblprice.setText("Php " + rs.getString("Price") +
JOptionPane.showMessageDialog(null, ".00");
"Product out of price = Double.parseDouble(rs.getString("Price"));
stock.","SELECT",JOptionPane.WARNING_MESSAGE); prodname = rs.getString("ProductName");
} stock=rs.getInt("Stock");
} }
else{ CloseConn();
JOptionPane.showMessageDialog(null, "Product } catch (HeadlessException e) {
out of stock.","SELECT",JOptionPane.WARNING_MESSAGE); } catch (SQLException ex) {
}
CloseConn(); Logger.getLogger(Main.class.getName()).log(Level.SEVERE,
} catch (SQLException ex) { null, ex);
} catch (Exception ex) { }
} };
} }
}

BUTTON_CASH_PAYMENT JLIST_ItemValueChanged void lst() {


void ok() { try {
Select("Select * from Products where ProductName='"
if (a == true) { + lstprod.getSelectedValue() + "'");
btnok.setText("NEW TRANSACTION"); if (rs.next() == true) {
btnsel.setEnabled(false); lblprice.setText("Php " + rs.getString("Price") +
txtsearch.setEnabled(false); ".00");
btnsearch.setEnabled(false); price = Double.parseDouble(rs.getString("Price"));
lstprod.setEnabled(false); prodname = rs.getString("ProductName");
a = false; stock=rs.getInt("Stock");
EndTrans(); }
try { CloseConn();
Save(); } catch (HeadlessException e) {
} catch (SQLException ex) { } catch (SQLException ex) {

Logger.getLogger(Main.class.getName()).log(Level.SEVERE, Logger.getLogger(Main.class.getName()).log(Level.SEVERE,
null, ex); null, ex);
} }
};
} else { }
btnsel.setEnabled(true);
txtsearch.setEnabled(true);
btnsearch.setEnabled(true);
lstprod.setEnabled(true);
a = true;
transno = +1;
try {
NewTrans();
} catch (SQLException ex) {

Logger.getLogger(Main.class.getName()).log(Level.SEVERE,
null, ex);
}
btnok.setText("CASH PAYMENT");
}
}

Vous aimerez peut-être aussi