Ass1 Java
Ass1 Java
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
public Customer() {}
@Override
public boolean register() {
boolean registered = false;
PreparedStatement ps = null;
ResultSet rs;
String query = "SELECT * FROM customer WHERE customer_username
= ?";
try {
ps = [Link]().prepareStatement(query);
[Link](1, [Link]);
rs = [Link]();
if ([Link]()) {
[Link](null, "This Username Already
Exists");
[Link]();
return registered;
} else {
query = "INSERT INTO `customer`(`customer_username`,
`customer_mobile`, `customer_password`, `customer_name`,
`customer_address`, `customer_id`, `customer_listOfOrders`) VALUES
(?,?,?,?,?,?,?)";
ps = [Link]().prepareStatement(query);
String encrypted = [Link]([Link]);
[Link](1, [Link]);
[Link](2, [Link]);
[Link](3, encrypted);
[Link](4, [Link]);
[Link](5, [Link]);
[Link](6, [Link]);
[Link](7, null);
[Link] = encrypted;
if ([Link]() > 0) {
CustomerWelcomeForm cf = new CustomerWelcomeForm(this,
null);
[Link](true);
registered = true;
}
}
} catch (SQLException ex) {
[Link]([Link]()).log([Link], null,
ex);
}
return registered;
}
@Override
public boolean login(String cuserName, String cPassword) {
boolean loggedIn = false;
PreparedStatement ps;
ResultSet rs;
String query = "SELECT * FROM customer WHERE
customer_username=? AND customer_password=?";
try {
ps = [Link]().prepareStatement(query);
String encrypted = [Link](cPassword);
[Link](1, cuserName);
[Link](2, encrypted);
rs = [Link]();
if ([Link]()) {
String cphone = [Link]("customer_mobile");
String cname = [Link]("customer_name");
String caddress = [Link]("customer_address");
int cid = [Link]("customer_id");
String ordersString = [Link]("customer_listOfOrders");
if (ordersString != null) {
[Link] = convertStringtoOrders(ordersString);
}
Customer c = new Customer(cid, cname, cuserName, cphone,
cPassword, caddress, [Link]);
CustomerWelcomeForm cf = new CustomerWelcomeForm(c,
ordersString);
[Link](true);
loggedIn = true;
} else {
[Link]();
[Link](null, "Username or password
incorrect.", "Login Failed", JOptionPane.ERROR_MESSAGE);
}
} catch (SQLException ex) {
[Link]([Link]()).log([Link], null,
ex);
}
return loggedIn;
}
[Link] :-
package customerPackage;
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
*
* @author Dell
*/
public class BillForm extends [Link]
{
//Order order = new Order();
Bill bill;
String ordersS;
int totalCash;
int rate;
static boolean returned = false;
Voucher exceed1000 = new Voucher("Exceed1000", 20);
boolean rated=false;
boolean pressedStatusBtn=false;
static boolean delivered=false;
/**
* Creates new form BillForm
*/
public BillForm()
{
initComponents();
pnl_rate.setVisible(false);
pnl_bill.setVisible(true);
lbl_complain.setVisible(false);
txt_complainMessege.setVisible(false);
btn_closeRating.setVisible(false);
}
}//GEN-LAST:event_btn_finishRateActionPerformed
private void
btn_nextRateActionPerformed([Link] evt) {//GEN-
FIRST:event_btn_nextRateActionPerformed
// TODO add your handling code here:
if ("".equals(txt_getRate.getText()))
{
if ([Link]() > 1)
{
lbl_complain.setVisible(true);
txt_complainMessege.setVisible(true);
btn_closeRating.setVisible(true);
}
else
{
[Link](this, "Please rate at least
one element", "Error", JOptionPane.ERROR_MESSAGE);
}
}
else
{
[Link]([Link](cbx_ChooseItemToR
[Link]()), [Link](txt_getRate.getText()));
txt_getRate.setText("");
}
}//GEN-LAST:event_btn_nextRateActionPerformed
private void
btn_cancelOrderActionPerformed([Link] evt)
{//GEN-FIRST:event_btn_cancelOrderActionPerformed
// cancel order
[Link]();
}//GEN-LAST:event_btn_cancelOrderActionPerformed
private void
btn_orderStatusActionPerformed([Link] evt)
{//GEN-FIRST:event_btn_orderStatusActionPerformed
// TODO add your handling code here:
if ([Link]([Link]))
{
[Link]([Link]().size()
+" we are in the orderStatusBtn");
[Link]().remove([Link]
);
[Link]([Link]().size()
+" we are in the orderStatusBtn");
[Link](true);
//[Link]([Link]);
delivered=true;
[Link](this, "Your order is done",
"Served", JOptionPane.OK_OPTION);
}
else
{
[Link](this, "Your order is being
cooked", "Loading...", JOptionPane.OK_OPTION);
}
[Link]([Link]);
pressedStatusBtn=true;
}//GEN-LAST:event_btn_orderStatusActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[])
{
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel
setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with
the default look and feel.
* For details see
[Link]
l
*/
try
{
for ([Link] info :
[Link]())
{
if ("Nimbus".equals([Link]()))
{
[Link]([Link]());
break;
}
}
} catch (ClassNotFoundException ex)
{
[Link]([Link]()).log(java.u
[Link], null, ex);
} catch (InstantiationException ex)
{
[Link]([Link]()).log(java.u
[Link], null, ex);
} catch (IllegalAccessException ex)
{
[Link]([Link]()).log(java.u
[Link], null, ex);
} catch ([Link] ex)
{
[Link]([Link]()).log(java.u
[Link], null, ex);
}
//</editor-fold>
Manager :-
[Link] :-
/*
* To change this license header, choose License Headers in Project
Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package managerPackage;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
/**
*
* @author PC
*/
public class Manager extends User
{
public Manager()
{
PreparedStatement preparedStmt =
[Link]().prepareStatement(Query);
[Link](1, [Link]());
[Link](2, [Link]());
[Link](3, [Link]([Link]()));
[Link](4, [Link]([Link]()));
[Link](5, 1);
[Link](6, null);
[Link](7, null);
[Link]();
if
([Link](CategoryName).get(i).getItemName().equals(ite
mName))
{
[Link](null, "This Item already exists");
itemFound = true;
break;
}
}
if (!itemFound)
{
try
{
//Add new added item into database in menu_item table
query = "INSERT INTO menu_item ( idmenu_item,
namemenu_item,rankmenu_item , pricemenu_item , category )" + "
VALUES(?,?,?,?,?)";
PreparedStatement preparedStmt =
[Link]().prepareStatement(query);
//Set random itemID
itemID = [Link]() + 1;
[Link](1, itemID);
[Link](2, itemName);
[Link](3, 0);
[Link](4, itemPrice);
[Link](5, CategoryName);
if ([Link]() > 0)
{
[Link](null, "New item is added ");
//To add new addded item to my main menu map
[Link](itemID);
[Link](itemName);
[Link](itemPrice);
[Link](0);
[Link](CategoryName).add(menuitem);
//To display new added item info on table
[Link](new Object[]
{
itemID, itemName, 0, 0, avaliable_quantity
});
}
[Link]([Link]()).log([Link],
null, ex);
}
try
{
//Add new inventory info in database in inventory table
query = "INSERT INTO inventory ( item_id , units_sold ,
avaliable_quantity , number_rate)" + " VALUES(?,?,?,?)";
PreparedStatement preparedStmt =
[Link]().prepareStatement(query);
[Link](1, itemID);
[Link](2, 0);
[Link](3, avaliable_quantity);
[Link](4, 0);
[Link]();
//To add new added item in inventory List
[Link](menuitem);
[Link](avaliable_quantity);
[Link](0);
[Link]([Link](), inventory);
}
} catch (Exception e)
{
[Link](null, "Please Choose one
Category");
}
}
if ([Link]() > 0)
{
[Link](null, "Item Deleted");
//Remove menu item from main menu map (main menu map)
MenuItem removedMenuItem = new MenuItem();
removedMenuItem =
[Link](categoryName).remove(i);
}
}
} catch (SQLException ex)
{
[Link]([Link]()).log([Link], null,
ex);
}
try
{
//Delete Inventory Item from inventory table in database
String query = "delete from inventory where item_id= ? ";
PreparedStatement preparedStmt =
[Link]().prepareStatement(query);
[Link](1, deleteId);
[Link]();
} catch (SQLException ex)
{
[Link]([Link]()).log([Link], null,
ex);
}
}
if ([Link]() > 0)
{
//[Link](null, "New User Add");
Manager m = new Manager([Link], [Link],
[Link], [Link]);
ManagerWelcomeForm mf = new ManagerWelcomeForm(m);
[Link](true);
}
}
} catch (SQLException ex)
{
[Link]([Link]()).log([Link], null,
ex);
}
return registered;
}
/**
*
* @param muserName
* @param mPassword
* @return
*/
@Override
public boolean login(String muserName, String mPassword)
{
boolean loggedIn = false;
PreparedStatement ps;
ResultSet rs;
String query = "SELECT * FROM manager WHERE manager_username=?
AND manager_password=?";
try
{
String encrypted = [Link](mPassword);
ps = [Link]().prepareStatement(query);
[Link](1, muserName);
[Link](2, encrypted);
rs = [Link]();
if ([Link]())
{
String mphone = [Link]("manager_mobile");
String mname = [Link]("manager_name");
Manager m = new Manager(mname, muserName, mphone,
mPassword);
ManagerWelcomeForm mf = new ManagerWelcomeForm(m);
[Link](true);
loggedIn = true;
}
else
{
[Link]();
[Link](null, "Username or password
incorrect.", "Login Failed", JOptionPane.ERROR_MESSAGE);
}
Menu:-
[Link] :-
package menuItems;
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import static [Link];
String itemInfo;
String itemName;
String itemPrice;
String itemRate;
String Dots = "";
void createPanel()
{
//Define new tab to hold this tittle & add it to JTabbedPane
pnl_tmp = new JPanel();
pnl_tmp.setLayout(null);
public Menu()
{
initComponents();
showMainMenu();
[Link](null); //center form in screen
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-
BEGIN:initComponents
private void initComponents()
{
setDefaultCloseOperation([Link].DISPOSE_ON_CLOSE
);
setTitle("Main Menu");
setMaximumSize(new [Link](1216, 788));
setPreferredSize(new [Link](1217, 788));
setSize(new [Link](1217, 788));
pnl_LogoBarLayout.createParallelGroup([Link].
LEADING)
.addGroup(pnl_LogoBarLayout.createSequentialGroup()
.addGap(530, 530, 530)
.addComponent(lbl_RsturantName)
.addContainerGap(588, Short.MAX_VALUE))
);
pnl_LogoBarLayout.setVerticalGroup(
pnl_LogoBarLayout.createParallelGroup([Link].
LEADING)
.addGroup(pnl_LogoBarLayout.createSequentialGroup()
.addContainerGap()
.addComponent(lbl_RsturantName)
.addContainerGap(16, Short.MAX_VALUE))
);
tpnl_ViewMainMenu.setTabLayoutPolicy([Link].SCROLL_TA
B_LAYOUT);
tpnl_ViewMainMenu.setToolTipText("");
tpnl_ViewMainMenu.setAutoscrolls(true);
tpnl_ViewMainMenu.setCursor(new
[Link]([Link].DEFAULT_CURSOR));
tpnl_ViewMainMenu.setFont(new [Link]("Rockwell", 3, 24)); //
NOI18N
tpnl_ViewMainMenu.setName(""); // NOI18N
tpnl_ViewMainMenu.setPreferredSize(new [Link](1216,
70));
[Link]("jLabel2");
[Link](new [Link](230, 230));
[Link]("jLabel7");
[Link](new [Link](230, 230));
[Link]([Link]
NG)
.addGroup([Link],
[Link]()
.addContainerGap(75, Short.MAX_VALUE)
.addComponent(jLabel7,
[Link].PREFERRED_SIZE, 230,
[Link].PREFERRED_SIZE)
.addGap(61, 61, 61)
.addComponent(jLabel1,
[Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE,
[Link].PREFERRED_SIZE)
.addGap(63, 63, 63)
.addComponent(jLabel3,
[Link].PREFERRED_SIZE, 230,
[Link].PREFERRED_SIZE)
.addGap(59, 59, 59)
.addComponent(jLabel2,
[Link].PREFERRED_SIZE, 251,
[Link].PREFERRED_SIZE)
.addContainerGap())
);
[Link](
[Link]([Link]
ING)
.addGroup([Link],
[Link]()
.addGap(329, 329, 329)
.addGroup([Link]([Link]
[Link])
.addComponent(jLabel7,
[Link].PREFERRED_SIZE, 230,
[Link].PREFERRED_SIZE)
.addGroup([Link]([Link]
[Link])
.addComponent(jLabel1,
[Link].PREFERRED_SIZE, 244,
[Link].PREFERRED_SIZE)
.addGroup([Link]([Link]
[Link])
.addComponent(jLabel2,
[Link].PREFERRED_SIZE, 230,
[Link].PREFERRED_SIZE)
.addComponent(jLabel3,
[Link].PREFERRED_SIZE, 230,
[Link].PREFERRED_SIZE))))
.addContainerGap(63, Short.MAX_VALUE))
);
tpnl_ViewMainMenu.addTab("tab1", jPanel2);
[Link]([Link])
.addComponent(pnl_LogoBar,
[Link].DEFAULT_SIZE,
[Link].DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(tpnl_ViewMainMenu,
[Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE,
[Link].PREFERRED_SIZE)
);
[Link](
[Link]([Link])
.addGroup([Link]()
.addComponent(pnl_LogoBar,
[Link].PREFERRED_SIZE,
[Link].DEFAULT_SIZE,
[Link].PREFERRED_SIZE)
.addPreferredGap([Link].R
ELATED)
.addComponent(tpnl_ViewMainMenu,
[Link].PREFERRED_SIZE, 679,
[Link].PREFERRED_SIZE))
);
tpnl_ViewMainMenu.getAccessibleContext().setAccessibleName("");
pack();
}// </editor-fold>//GEN-END:initComponents
[Link]([Link]()).log([Link]
[Link], null, ex);
} catch (InstantiationException ex)
{
[Link]([Link]()).log([Link]
[Link], null, ex);
} catch (IllegalAccessException ex)
{
[Link]([Link]()).log([Link]
[Link], null, ex);
} catch ([Link] ex)
{
[Link]([Link]()).log([Link]
[Link], null, ex);
}
//</editor-fold>
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
public static [Link] jLabel1;
public static [Link] jLabel2;
public static [Link] jLabel3;
public static [Link] jLabel7;
private [Link] jPanel2;
private [Link] lbl_RsturantName;
private [Link] pnl_LogoBar;
public static [Link] tpnl_ViewMainMenu;
// End of variables declaration//GEN-END:variables
}