diff --git a/README.md b/README.md index e674b94..1f12db5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,46 @@ -# Buffer_2.0 -Buffer_2.0 repo to submit your projects to.Repository containing folder-wise code for all submissions to Buffer : A Project Series, conducted between April, 2021 - June, 2020. +**SUPERMARKET MANAGEMENT SYSTEM** + +**OBJECTIVE:** + +* We have tried to implement all the main functions that are required to run a supermarket.This includes billing, maintaining stock details, managing information about products, dealers and employees. +* Our project simulates the job of each and every member working in the supermarket. Every employee will get a different access to the application according to his/her role in the supermarket. +* It reduces the time and manpower required for management and maintenance of different tasks as the entire system is fully computerized. + +**DATA STRUCTURE:** + +We used a Singly Linked List to represent the list of products, dealers, customers and employees that are associated with the Supermarket because: +* They are dynamic in nature. +* Insertion order is maintained. +* This is ideal for our application where we have a large data and unknown number of objects so by using it + insertion and deletion operations can be easily implemented. + + **WHAT WE HAVE LEARNT:** + + * How to manage databases using MySQL. + * How to implement JDBC. + * How to implement linked lists using user defined functions. + + **WHAT WE CAN ADD FURTHER:** + + * We can define function for calculating Profit and Loss. + * We can give login credentials to the employees. + * We can make a UI by using JAVA Swing. + + **TEAM MEMBERS:** + + * Gouri Ghurka (SY IT) + * Himanshi Methwani (SY IT) + * Ruchita Herlekar (SY IT) + * Muskan Singhal (SY IT) + + **MENTOR:** + + * Bhavana Mache (B.Tech Comp) + + + + + + -Each folder should contain a separate README to describe the files and project objective diff --git a/SuperMarketPPT.pptx b/SuperMarketPPT.pptx new file mode 100644 index 0000000..e7346c6 Binary files /dev/null and b/SuperMarketPPT.pptx differ diff --git a/src/billing_package/BillContents.java b/src/billing_package/BillContents.java new file mode 100644 index 0000000..f6e4137 --- /dev/null +++ b/src/billing_package/BillContents.java @@ -0,0 +1,36 @@ +package billing_package; + +public class BillContents +{ + + private String prod_brand; + private int qty_purchased; + private double mrp; + private double tot_item_price; + + public String getProd_brand() { + return prod_brand; + } + public void setProd_brand(String prod_brand) { + this.prod_brand = prod_brand; + } + public int getQty_purchased() { + return qty_purchased; + } + public void setQty_purchased(int qty_purchased) { + this.qty_purchased = qty_purchased; + } + public double getMrp() { + return mrp; + } + public void setMrp(double mrp) { + this.mrp = mrp; + } + public double getTot_item_price() { + return tot_item_price; + } + public void setTot_item_price(double tot_item_price) { + this.tot_item_price = tot_item_price; + } + +} diff --git a/src/billing_package/Billing.java b/src/billing_package/Billing.java new file mode 100644 index 0000000..5c3be80 --- /dev/null +++ b/src/billing_package/Billing.java @@ -0,0 +1,385 @@ +package billing_package; +import product_package.ProductImplementation; +import linkedlist_package.LinkedList; +import linkedlist_package.Node; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; +import java.time.LocalDate; +import java.time.LocalTime; +import java.util.Scanner; +import java.util.regex.Pattern; + + +public class Billing +{ + private int prod_id; + private int total_items; + private double tot_price; + private double total; + private double tax=0.0; + private double discount=0.0; + private double grand_total; + private static double gst=0.12; + private int curr_points=0; + private int tot_points=0; + private long bill_no=0; + private static long billNoGenerator=000001; + private String phoneno; + private String customername; + + //Scanner sc = new Scanner(System.in); + public LinkedList cll=new LinkedList(); + public LinkedList pll=new LinkedList(); + + public void retrieve() + { + Connection con; + Statement st; + ResultSet rs; + try + { + Class.forName("com.mysql.cj.jdbc.Driver"); + con=DriverManager.getConnection("jdbc:mysql://localhost:3306/supermarket", + "root","root"); + st=con.createStatement(); + rs=st.executeQuery("select * from customers"); + while(rs.next()) + { + Customer cobj=new Customer(); + cobj.setC_name(rs.getString(1)); + cobj.setC_phone_no(rs.getString(2)); + cobj.setTot_points(rs.getInt(3)); + cll.insertLast(cobj); + } + rs.close(); + st.close(); + con.close(); + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + public String acceptCustomerPhoneNO(Scanner sc) + { + Boolean bool=true; + String phone=""; + String temp=""; + System.out.println("Enter Customer's Contact number"); + sc.nextLine(); + do + { + phone=sc.nextLine(); + if(phone.isBlank()) + { + bool = false; + } + else + { + bool = Pattern.matches("[6789]{1}[0-9]{9}", phone); + } + if(bool == false) + { + System.out.println("Please Enter Valid Contact Number"); + } + }while(!bool); + + return phone; + } + + public void billGeneration(ProductImplementation product,Scanner sc) + { + this.bill_no=Billing.billNoGenerator++; + phoneno=this.acceptCustomerPhoneNO(sc); + Node currentNode=cll.getHead(); + int flag=0; + while(currentNode!=null && flag==0) + { + Customer c=(Customer) currentNode.getData(); + if(phoneno.equals(c.getC_phone_no())) + { + customername=c.getC_name(); + tot_points=c.getTot_points(); + flag=1; + } + currentNode=currentNode.getNext(); + } + + if(flag==1) + { + boolean verify=false; + String yorn=""; + System.out.println("**VERIFY CUSTOMER NAME.ENTER Y OR y FOR YES , N OR n FOR NO.**"); + System.out.println("Customer Name:"+customername); + do + { + verify=sc.hasNext(); + if(verify) + { + yorn=sc.next(); + } + else + { + System.out.println("Please enter a valid input"); + } + if(!(yorn.equalsIgnoreCase("y")||yorn.equalsIgnoreCase("n"))) + { + verify=false; + System.out.println("Please enter y-yes or n-no"); + } + }while(!verify); + + if(yorn.equalsIgnoreCase("n")) + { + this.acceptCustomerPhoneNO(sc); + } + } + + if(flag==0) + { + addCustomer(phoneno,sc); + } + + billCalculation(product,sc); + printBill(); + } + + private void billCalculation(ProductImplementation product,Scanner sc) + { + String yorn=""; + Boolean bool=true; + int avaiQty=0; + do + { + String temp=""; + BillContents obj=new BillContents(); + System.out.println("Enter Product id:"); + do + { + bool=sc.hasNextInt(); + if(bool) + { + prod_id=sc.nextInt(); + if(prod_id<=0) + { + System.out.println("Please enter valid product ID"); + bool=false; + } + } + else + { + temp=sc.next(); + System.out.println("Please enter valid product ID"); + } + }while(!bool); + + try + { + Connection con; + Statement st; + ResultSet rs; + Class.forName("com.mysql.cj.jdbc.Driver"); + con=DriverManager.getConnection("jdbc:mysql://localhost:3306/supermarket", + "root","root"); + st=con.createStatement(); + rs=st.executeQuery("select productBrand,productMrp,productQuantity from products where productID="+prod_id); + while(rs.next()) + { + obj.setProd_brand(rs.getString(1)); + obj.setMrp(rs.getDouble(2)); + avaiQty=rs.getInt(3); + } + rs.close(); + st.close(); + con.close(); + } + catch(Exception e) + { + e.printStackTrace(); + } + + System.out.println("Enter quantity of product:"); + do + { + bool=sc.hasNextInt(); + if(bool) + { + obj.setQty_purchased(sc.nextInt()); + if(obj.getQty_purchased()<=0||obj.getQty_purchased()>avaiQty) + { + System.out.println("Please enter quantity between 1 and "+avaiQty); + bool=false; + } + } + else + { + temp=sc.next(); + System.out.println("Please enter valid product quantity"); + } + }while(!bool); + + obj.setTot_item_price((float) (obj.getQty_purchased()*obj.getMrp())); + pll.insertLast(obj); + total_items=total_items+obj.getQty_purchased(); + + product.subQuantity(prod_id, obj.getQty_purchased()); + + tot_price=tot_price+obj.getTot_item_price(); + System.out.println("Enter y if there is another product.Enter n if there are no more products"); + do + { + bool=sc.hasNext(); + if(bool) + { + yorn=sc.next(); + } + else + { + System.out.println("Please enter a valid input"); + } + if(!(yorn.equalsIgnoreCase("y")||yorn.equalsIgnoreCase("n"))) + { + bool=false; + System.out.println("Please enter y-yes or n-no"); + } + }while(!bool); + }while(yorn.equalsIgnoreCase("y")); + + if(tot_price >= 0.0 && tot_price < 100 ) + { + curr_points=0; + } + else + { + curr_points=(int) (tot_price/100);//1 point for every 100 Rs. + } + + tot_points = tot_points+curr_points; + + if(tot_points>=100) + { + discount=tot_price * 0.15;// 15% discount for every 100 points + total = tot_price - discount; + tot_points=tot_points-100; + } + else + { + discount = 0.0; + total=tot_price; + } + updatePoints(); + + tax=total*gst; + grand_total=total+tax; + } + + private void updatePoints() + { + int flag=0; + Node currentNode=cll.getHead(); + while(currentNode!=null && flag==0) + { + Customer c=(Customer) currentNode.getData(); + if(phoneno.equals(c.getC_phone_no())) + { + c.setTot_points(tot_points); + flag=1; + } + currentNode=currentNode.getNext(); + } + } + + private void printBill() + { + System.out.println("\tALL IN ONE Supermarket"); + System.out.println("Bill NO.:"+bill_no); + + LocalDate d=LocalDate.now(); + System.out.print(d+"\t"); + LocalTime t=LocalTime.now(); + System.out.println(t); + System.out.println(); + + System.out.format("%15s %5s %6s %8s\n","PRODUCT","QTY","MRP","TOTAL"); + System.out.println("-----------------------------------------------"); + //System.out.println("PRODUCT\t\tQTY\tMRP\tTOTAL"); + Node currentNode=pll.getHead(); + + while(currentNode!=null) + { + + BillContents b=(BillContents) currentNode.getData(); + //ll.display(b) + System.out.format("%15s %5d %6.2f %8.2f\n",b.getProd_brand(),b.getQty_purchased(),b.getMrp(),b.getTot_item_price()); + currentNode=currentNode.getNext(); + } + System.out.println("-----------------------------------------------"); + System.out.format("%15s %5d %6s %8.2f\n","TOTAL",total_items," ",tot_price); + System.out.format("%15s %5s %6s %8.2f\n","DISCOUNT"," "," ",discount); + System.out.println("-----------------------------------------------"); + System.out.format("%15s %5s %6s %8.2f\n","TOTAL"," "," ",total); + System.out.format("%15s %5s %6s %8.2f\n","TAX"," "," ",tax); + System.out.println("-----------------------------------------------"); + System.out.format("%15s %5s %6s %8.2f\n","GRAND TOTAL"," "," ",grand_total); + System.out.println("-----------------------------------------------"); + System.out.format("%30s","*THANK YOU.VISIT AGAIN*\n"); + pll.setHead(null); + } + + public void loadIntoDatabase() + { + Connection con; + Statement st; + try + { + Class.forName("com.mysql.cj.jdbc.Driver"); + con=DriverManager.getConnection("jdbc:mysql://localhost:3306/supermarket", "root","root"); + st=con.createStatement(); + st.executeUpdate("delete from customers"); + Node currentNode=cll.getHead(); + while(currentNode!=null) + { + Customer c=(Customer) currentNode.getData(); + st.executeUpdate("insert into customers values ('"+c.getC_name()+"',"+c.getC_phone_no()+","+c.getTot_points()+")"); + currentNode=currentNode.getNext(); + } + st.close(); + con.close(); + } + catch(Exception e) + { + e.printStackTrace(); + } + } + + private void addCustomer(String phno,Scanner sc) + { + boolean bool=true; + System.out.println("**New Customer.Accept details.**"); + System.out.println("Enter Customer Name:"); + //sc.nextLine(); + do + { + + customername=sc.nextLine(); + if(customername.isBlank()) + { + System.out.println("Please enter valid customer name"); + bool=false; + } + else + { + bool=true; + } + }while(!bool); + + Customer cobj=new Customer(); + cobj.setC_name(customername); + cobj.setC_phone_no(phno); + cobj.setTot_points(0);//new customer points are always zero + cll.insertLast(cobj); + } +} diff --git a/src/billing_package/Customer.java b/src/billing_package/Customer.java new file mode 100644 index 0000000..11bee90 --- /dev/null +++ b/src/billing_package/Customer.java @@ -0,0 +1,27 @@ +package billing_package; + +public class Customer +{ + private String c_name; + private String c_phone_no; + private int tot_points; + public String getC_name() { + return c_name; + } + public void setC_name(String c_name) { + this.c_name = c_name; + } + public String getC_phone_no() { + return c_phone_no; + } + public void setC_phone_no(String c_phone_no) { + this.c_phone_no = c_phone_no; + } + public int getTot_points() { + return tot_points; + } + public void setTot_points(int tot_points) { + this.tot_points = tot_points; + } + +} diff --git a/src/dealer_package/Dealer.java b/src/dealer_package/Dealer.java new file mode 100644 index 0000000..2eaa277 --- /dev/null +++ b/src/dealer_package/Dealer.java @@ -0,0 +1,101 @@ +package dealer_package; + +public class Dealer +{ + private int d_id; + private String d_name; + private String d_category; + private String d_prod_name; + private String d_company; + private String d_contact_no; + private String d_email; + private String d_address; + private int d_qty_available; + private double price_per_piece; + private double d_discount; + private double d_finalPrice; + private static int idGenerator=0; + + public static int getIdGenerator() { + return idGenerator; + } + public void setD_id(int d_id) { + this.d_id = d_id; + } + public static void setIdGenerator(int idGenerator) { + Dealer.idGenerator = idGenerator; + } + public int getD_id() + { + return d_id; + } + public String getD_name() { + return d_name; + } + public String getD_category() { + return d_category; + } + public String getD_prod_name() { + return d_prod_name; + } + public String getD_company() { + return d_company; + } + public String getD_contact_no() { + return d_contact_no; + } + public String getD_email() { + return d_email; + } + public String getD_address() { + return d_address; + } + public int getD_qty_available() { + return d_qty_available; + } + public double getPrice_per_piece() { + return price_per_piece; + } + public double getD_discount() { + return d_discount; + } + public double getD_finalPrice() + { + return d_finalPrice; + } + + public void setD_name(String d_name) { + this.d_name = d_name; + } + public void setD_category(String d_category) { + this.d_category = d_category; + } + public void setD_prod_name(String d_prod_name) { + this.d_prod_name = d_prod_name; + } + public void setD_company(String d_company) { + this.d_company = d_company; + } + public void setD_contact_no(String d_contact_no) { + this.d_contact_no = d_contact_no; + } + public void setD_email(String d_email) { + this.d_email = d_email; + } + public void setD_address(String d_address) { + this.d_address = d_address; + } + public void setD_qty_available(int d_qty_available) { + this.d_qty_available = d_qty_available; + } + public void setPrice_per_piece(double price_per_piece) { + this.price_per_piece = price_per_piece; + } + public void setD_discount(double d_discount) { + this.d_discount = d_discount; + } + public void setD_finalPrice(double d_finalPrice) { + this.d_finalPrice = d_finalPrice; + } +} + \ No newline at end of file diff --git a/src/dealer_package/DealerImplementation.java b/src/dealer_package/DealerImplementation.java new file mode 100644 index 0000000..23c862c --- /dev/null +++ b/src/dealer_package/DealerImplementation.java @@ -0,0 +1,636 @@ +package dealer_package; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Scanner; +import java.util.regex.Pattern; +import linkedlist_package.LinkedList; +import linkedlist_package.Node; + +public class DealerImplementation +{ + + public LinkedList ll=new LinkedList(); + public void retrieve()//to retrieve the existing data from database + { + + Connection con=null; + Statement st=null; + ResultSet rs=null; + + try + { + Class.forName("com.mysql.cj.jdbc.Driver"); + con=DriverManager.getConnection("jdbc:mysql://localhost:3306/SuperMarket","root","root"); + st=con.createStatement(); + rs=st.executeQuery("select * from Dealer"); + while(rs.next()) + { + Dealer dretrieve=new Dealer(); + dretrieve.setD_id(rs.getInt(1)); + dretrieve.setD_name(rs.getString(2)); + dretrieve.setD_category(rs.getString(3)); + dretrieve.setD_prod_name(rs.getString(4)); + dretrieve.setD_company(rs.getString(5)); + dretrieve.setD_contact_no(rs.getString(6)); + dretrieve.setD_email(rs.getString(7)); + dretrieve.setD_address(rs.getString(8)); + dretrieve.setD_qty_available(rs.getInt(9)); + dretrieve.setPrice_per_piece(rs.getDouble(10)); + dretrieve.setD_discount(rs.getDouble(11)); + ll.insertLast(dretrieve); + Dealer.setIdGenerator(dretrieve.getD_id());//to set id generator to last id value + + } + + rs.close(); + st.close(); + con.close(); + } + catch(Exception e) + { + System.out.println(e); + } + + } + + private Dealer acceptDealerDetails(Scanner sc) + { + Dealer d=new Dealer(); + boolean check=false; + String temp; + System.out.println("Enter Dealer Name"); + sc.nextLine(); + + do + { + String name=sc.nextLine(); + if(name.isBlank()) + { + System.out.println("Please Enter Appropriate Name!!!"); + check=false; + + } + else + { + d.setD_name(name); + check=true; + } + }while(check==false); + + System.out.println("Enter Dealer Category"); + + do + { + check=false; + String cat=sc.nextLine(); + if(cat.isBlank()) + { + System.out.println("Please Enter Appropriate Category!!!"); + + } + else + { + d.setD_category(cat); + check=true; + } + + }while(check==false); + + System.out.println("Enter Product Name sold"); + + do + { + check=false; + String p_name=sc.nextLine(); + if(p_name.isBlank()) + { + System.out.println("Please Enter Appropriate Product Name!!!"); + } + else + { + d.setD_prod_name(p_name); + check=true; + } + + }while(check==false); + + System.out.println("Enter Dealer Company Name"); + + do + { + check=false; + String brand=sc.nextLine(); + if(brand.isBlank()) + { + System.out.println("Please Enter Appropriate Company Name!!!"); + } + else + { + d.setD_company(brand); + check=true; + } + + }while(check==false); + + System.out.println("Enter Dealer Contact Number"); + + do + { + check=false; + String contactNo=sc.nextLine(); + if(contactNo.isBlank()) + { + check=false; + } + else//when alphabets are entered + { + check=Pattern.matches("[6789]{1}[0-9]{9}",contactNo); + if(check) + { + check=true; + d.setD_contact_no(contactNo);//contact number starts with 6,7,8,9 and have 10 digits + } + else + { + check=false; + } + } + if(check==false) + { + System.out.println("Please Enter Appropriate Contact Number!!!"); + } + + }while(check==false); + + System.out.println("Enter Email-Address"); + + do + { + check=false; + String email=sc.nextLine(); + if(email.isBlank()) + { + check=false; + } + else + { + check=Pattern.matches("[a-zA-Z0-9_+&*-]+(?:\\."+"[a-zA-Z0-9_+&*-]+)*@" +"(?:[a-zA-Z0-9-]+\\.)+[a-z" +"A-Z]{2,7}$",email); + if(check) + { + check=true; + d.setD_email(email); + } + else + { + check=false; + } + } + if(check==false) + { + System.out.println("Please Enter Appropriate Email-Address!!!"); + } + + }while(check==false); + + System.out.println("Enter Dealer Address"); + + do + { + check=false; + String address=sc.nextLine(); + if(address.isBlank()) + { + System.out.println("Please Enter Appropriate Address!!!"); + + } + else + { + d.setD_address(address); + check=true; + } + + }while(check==false); + + System.out.println("Enter Quantity of Product available with the dealer"); + + do + { + check=sc.hasNextInt(); + + if(check) + { + d.setD_qty_available(sc.nextInt()); + if(d.getD_qty_available()>=0) + { + check=true;//when quantity entered by user is integer and positive + } + + } + else if(sc.hasNextDouble())//to check quantity entered is of type double or not + { + @SuppressWarnings("unused") + double temp1; + temp1=(sc.nextDouble()); + } + else//to check quantity entered is of type String + { + temp=sc.next(); + if(temp.isBlank()) + { + System.out.println("Please Enter Appropriate Quantity!!!"); + } + check=false; + + } + if(check==false) + { + System.out.println("Please Enter Appropriate Quantity!!!"); + } + }while(check==false); + + System.out.println("Enter Price per piece"); + + do + { + check=false;//check turns true when appropriate value of price is entered + + check=sc.hasNextDouble(); + if(check) + { + d.setPrice_per_piece(sc.nextDouble()); + if(d.getPrice_per_piece()>0) + { + check=true;//when entered value is decimal and positive + } + } + else//entered value is string + { + temp=sc.next(); + } + if(check==false) + { + System.out.println("Please Enter Appropriate Price!!!"); + } + + }while(check==false); + + System.out.println("Enter Discount provided"); + + do + { + check=false;//check turns true when appropriate discount value is entered + + + check=sc.hasNextDouble(); + if(check) + { + d.setD_discount(sc.nextDouble()); + if(d.getD_discount()>=0&&d.getD_discount()<100) + { + check=true;//when entered value is decimal and positive + } + } + else//when entered value is string + { + temp=sc.next(); + } + if(check==false) + { + System.out.println("Please Enter Appropriate Values for Discount!!!"); + + } + }while(check==false); + + return d; + } + public void addNewDealer(Scanner sc) + { + Node temp=ll.getHead(); + + int flag=0;//turns 1 when dealer with same contact number,product and brand already exists + System.out.println("Enter Details of Dealer"); + Dealer d=this.acceptDealerDetails(sc); + while(temp!=null) + { + if((d.getD_contact_no()).equals(((Dealer)(temp.getData())).getD_contact_no()) && (d.getD_name()).equalsIgnoreCase(((Dealer)(temp.getData())).getD_name())) + { + if((d.getD_prod_name()).equalsIgnoreCase(((Dealer)(temp.getData())).getD_prod_name())) + { + if((d.getD_company()).equalsIgnoreCase(((Dealer)(temp.getData())).getD_company())) + { + flag=1; + break; + } + } + } + temp=temp.getNext(); + } + if(flag==1) + { + System.out.println("Such Dealer Already Exists"); + } + else + { + int id=Dealer.getIdGenerator(); + id++; + Dealer.setIdGenerator(id); + d.setD_id(id); + ll.insertLast(d); + System.out.println("Data of New Dealer inserted to the list successfully"); + } + } + private Node partition(Node front,Node back) + { + Node pivot=back; + Node present=front; + Dealer temp=null; + while(front!=pivot) + { + if(((Dealer)front.getData()).getD_finalPrice()<((Dealer)pivot.getData()).getD_finalPrice()) + { + temp=(Dealer)front.getData(); + front.setData(present.getData()); + present.setData(temp); + present=present.getNext(); + } + front=front.getNext(); + } + temp=(Dealer)pivot.getData(); + pivot.setData(present.getData()); + present.setData(temp); + return present; + } + private void quickSort(Node front,Node back) + { + if(front!=back&&front!=back.getNext()) + { + Node pivot=partition(front,back); + Node temp=front; + if(pivot!=front) + { + while(temp.getNext()!=pivot) + { + temp=temp.getNext(); + } + } + quickSort(front,temp); + quickSort(pivot.getNext(),back); + + } + } + public Dealer sort(LinkedList ll)//sort the dealers on the basis of final price + { + Node temp=ll.getHead(); + while(temp.getNext()!=null) + { + temp=temp.getNext(); + } + quickSort(ll.getHead(),temp); + return ((Dealer)ll.getHead().getData()); + + } + public Dealer compareDealers(int quantityReq,String company,String p_name) + { + Node temp=ll.getHead(); + LinkedList temp_ll=new LinkedList();//list of dealers having enough quantity of the product of particular brand + Dealer d_min=new Dealer(); + while(temp!=null) + { + + if(p_name.equalsIgnoreCase(((Dealer)temp.getData()).getD_prod_name())&&company.equalsIgnoreCase(((Dealer)temp.getData()).getD_company())&&(quantityReq<=((Dealer)temp.getData()).getD_qty_available())) + { + double total_price=0.0; + double finalPrice=0.0; + total_price=quantityReq*(((Dealer)temp.getData()).getPrice_per_piece()); + finalPrice=total_price-(total_price)*(((Dealer)temp.getData()).getD_discount()/100); + ((Dealer)temp.getData()).setD_finalPrice(finalPrice); + temp_ll.insertLast(temp.getData()); + } + temp=temp.getNext(); + } + if(temp_ll.getHead()==null) + { + d_min=null;//no dealer exist with enough quantity + } + else if(temp_ll.getHead().getNext()==null) + { + d_min=((Dealer)temp_ll.getHead().getData()); //only single dealer available with enough quantity + } + else + { + d_min=sort(temp_ll); + } + return d_min; + } + public void displayBest(Dealer best) + { + System.out.println("***********************************************************************"); + System.out.println("ORDER IS PLACED WITH :"); + System.out.println("***********************************************************************"); + System.out.println("NAME "+best.getD_name()); + System.out.println("ID "+best.getD_id()); + System.out.println("TOTAL PRICE "+(best.getD_finalPrice()/(1-(best.getD_discount()/100)))); + System.out.println("DISCOUNT "+(best.getD_finalPrice()/(1-(best.getD_discount()/100)))*(best.getD_discount()/100)); + System.out.println("FINAL PRICE: "+best.getD_finalPrice()); + System.out.println("***********************************************************************"); + } + public Node searchWithId(int id) + { + Node result=null; + if(ll.getHead()==null) + { + System.out.println("Empty List,Cannot Search"); + } + else + { + Node temp=ll.getHead(); + + while(temp!=null) + { + if(((Dealer)temp.getData()).getD_id()==id) + { + result=temp; + break; + } + temp=temp.getNext(); + } + } + return result; + } + public void displayWithId(Scanner sc) + { + boolean check=false;//check turns true when appropriate id is entered + int id=0;//accept id entered by user + System.out.println("Enter ID of the Dealer whose details you want to Display"); + + do + { + check=sc.hasNextInt(); + + if(check) + { + id=sc.nextInt(); + if(id>0) + { + check=true;//when id entered by user is integer and positive + } + + } + else if(sc.hasNextDouble())//when id entered by user is of type double + { + @SuppressWarnings("unused") + double temp1; + temp1=(sc.nextDouble()); + } + else//when id entered by user is of type double + { + @SuppressWarnings("unused") + String temp=sc.next(); + + } + if(check==false) + { + System.out.println("Please Enter Appropriate ID!!!"); + } + }while(check==false); + Node temp=searchWithId(id); + if(temp!=null) + { + + System.out.println("************************************************************************************************************************************************************************************************************************************************"); + + System.out.printf("%-30s %-30s %-30s %-30s %-30s %-40s %-30s", "NAME", "PRODUCT_CATEGORY", "PRODUCT_NAME", "PRDOUCT_BRAND", "CONTACT_NUMBER", "EMAIL_ADDRESS", "ADDRESS"); + System.out.println(); + System.out.format("%-30s %-30s %-30s %-30s %-30s %-40s %-30s",((Dealer)temp.getData()).getD_name(),((Dealer)temp.getData()).getD_category(), + ((Dealer)temp.getData()).getD_prod_name(),((Dealer)temp.getData()).getD_company(),((Dealer)temp.getData()).getD_contact_no(), + ((Dealer)temp.getData()).getD_email(),((Dealer)temp.getData()).getD_address()); + System.out.println(); + System.out.println("************************************************************************************************************************************************************************************************************************************************"); + + } + else + { + System.out.println("Data of Dealer with Id "+id+" doesn't exist!!!"); + } + } + + + public void displayList() + { + + if(ll.getHead()==null)//list is empty + { + System.out.println("No Dealer Exists in the List"); + } + else + { + System.out.println("************************************************************************************************************************************************************************************************************************************************"); + + System.out.printf("%-30s %-30s %-30s %-30s %-30s %-40s %-30s", "NAME", "PRODUCT_CATEGORY", "PRODUCT_NAME", "PRDOUCT_BRAND", "CONTACT_NUMBER", "EMAIL_ADDRESS", "ADDRESS"); + System.out.println(); + System.out.println("************************************************************************************************************************************************************************************************************************************************"); + Node temp=ll.getHead(); + while(temp!=null) + { + + System.out.format("%-30s %-30s %-30s %-30s %-30s %-40s %-30s",((Dealer)temp.getData()).getD_name(),((Dealer)temp.getData()).getD_category(), + ((Dealer)temp.getData()).getD_prod_name(),((Dealer)temp.getData()).getD_company(),((Dealer)temp.getData()).getD_contact_no(), + ((Dealer)temp.getData()).getD_email(),((Dealer)temp.getData()).getD_address()); + System.out.println(); + + temp=temp.getNext(); + } + System.out.println("************************************************************************************************************************************************************************************************************************************************"); + } + } + + + + public void deleteWithId(Scanner sc) + { + boolean check=false;//check turns true when appropriate id is entered + int id=0; //accept id no. entered by user + System.out.println("Enter ID of the Dealer whose details you want to Delete"); + + do + { + check=sc.hasNextInt(); + + if(check) + { + id=sc.nextInt(); + if(id>0) + { + check=true;////when id entered by user is integer and positive + } + + } + else if(sc.hasNextDouble())//when id entered by user is of type double + { + @SuppressWarnings("unused") + double temp1; + temp1=(sc.nextDouble()); + } + else//when id entered by user is of type string + { + @SuppressWarnings("unused") + String temp=sc.next(); + + } + if(check==false) + { + System.out.println("Please Enter Appropriate ID!!!"); + } + }while(check==false); + Node temp=searchWithId(id);//return null when data associated with entered id is not found + if(temp!=null) + { + ll.deleteNode(temp); + System.out.println("Data deleted Successfully"); + } + else + { + System.out.println("Data of Dealer with Id "+id+" is Not Found!!!"); + } + + } + public void addToDatabase()//to load the data present in the linked list back to database + { + Connection con=null; + Statement st=null; + + if(ll.getHead()!=null) + { + + try + { + Class.forName("com.mysql.cj.jdbc.Driver"); + con=DriverManager.getConnection("jdbc:mysql://localhost:3306/SuperMarket","root","root"); + st=con.createStatement(); + st.executeUpdate("delete from Dealer"); + Node temp=ll.getHead(); + while(temp!=null) + { + Dealer d=(Dealer)(temp.getData()); + st.executeUpdate("insert into Dealer values("+d.getD_id()+",'"+d.getD_name()+"','"+d.getD_category()+"','"+d.getD_prod_name()+"','"+ + d.getD_company()+"','"+d.getD_contact_no()+"','"+d.getD_email()+"','"+d.getD_address()+"',"+ + d.getD_qty_available()+","+d.getPrice_per_piece()+","+d.getD_discount()+")"); + temp=temp.getNext(); + } + st.close(); + con.close(); + } + catch(Exception e) + { + e.printStackTrace(); + } + + + } + } +} + + diff --git a/src/employee_package/Employee.java b/src/employee_package/Employee.java new file mode 100644 index 0000000..299d918 --- /dev/null +++ b/src/employee_package/Employee.java @@ -0,0 +1,83 @@ +package employee_package; +import java.util.Scanner; +//import java.util.regex.*; +public class Employee +{ + private String e_name; + private int e_id; + private String e_role; + private String e_contact_no; + private String e_email; + private String e_address; + private double e_salary; + private static int IDgenerator=0; + Scanner sc=new Scanner(System.in); + public Employee() //default constructor + { + // IDgenerator++; + // e_id = IDgenerator; + } + //Getter and Setter Method for instance variables + public String getE_name() { + return e_name; + } + + public void setE_name(String e_name) { + this.e_name = e_name; + } + public int getE_id() + { + return e_id; + } + public void setE_id(int e_id) + { + this.e_id=e_id; + } + + public String getE_role() { + return e_role; + } + + public void setE_role(String e_role) { + this.e_role = e_role; + } + + public String getE_contact_no() { + return e_contact_no; + } + + public void setE_contact_no(String e_contact_no) { + this.e_contact_no = e_contact_no; + } + + public String getE_email() { + return e_email; + } + + public void setE_email(String e_email) { + this.e_email = e_email; + } + + public String getE_address() { + return e_address; + } + + public void setE_address(String e_address) { + this.e_address = e_address; + } + + public double getE_salary() { + return e_salary; + } + + public void setE_salary(double e_salary) { + this.e_salary = e_salary; + } + public static int getIDgenerator() { + return IDgenerator; + } + + public static void setIDgenerator(int iDgenerator) { + IDgenerator = iDgenerator; + } +} diff --git a/src/employee_package/EmployeeImplementation.java b/src/employee_package/EmployeeImplementation.java new file mode 100644 index 0000000..19dd044 --- /dev/null +++ b/src/employee_package/EmployeeImplementation.java @@ -0,0 +1,431 @@ +package employee_package; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.Statement; +import java.util.Scanner; +import java.util.regex.Pattern; +import linkedlist_package.LinkedList; +import linkedlist_package.Node; +public class EmployeeImplementation +{ + public LinkedList ll = new LinkedList(); + public void addEmployee(Scanner sc) + { + Employee emp=new Employee(); + this.acceptEmployeeDetails(emp,sc); + this.checkIfAlreadyPesent(emp); + //System.out.println("Executing"); + } + private void acceptEmployeeDetails(Employee emp,Scanner sc) + { + String temp; + //System.out.println("Enter Employee Id"); + //e_id=sc.nextInt(); + boolean bool=true; + System.out.println("Enter Employee Name"); + sc.nextLine(); + do { + bool=false; + String name=sc.nextLine(); + if(name.isBlank()) + System.out.println("Please Enter Appropriate Employee Name"); + else + { + emp.setE_name(name); + bool=true; + + } + }while(bool==false); + System.out.println("Enter Employee Contact Number"); + bool = true; + do + { + bool=false; + String contactNo=sc.nextLine(); + if(contactNo.isBlank()) + { + bool=false; + } + else//when alphabets are entered + { + bool=Pattern.matches("[6789]{1}[0-9]{9}",contactNo); + if(bool) + { + bool=true; + emp.setE_contact_no(contactNo);//contact number starts with 6,7,8,9 and have 10 digits + } + else + { + bool=false; + } + } + if(bool==false) + { + System.out.println("Please Enter Appropriate Contact Number!!!"); + } + + }while(bool==false); + //sc.nextLine(); + System.out.println("Enter Employee Role"); + do { + bool=false; + String role=sc.nextLine(); + if(role.isBlank()) + System.out.println("Please Enter Appropriate Employee Role"); + else + { + emp.setE_role(role); + bool=true; + + } + }while(bool==false); + System.out.println("Enter Employee Salary"); + do { + bool=false; + bool=sc.hasNextDouble(); + if(bool) + { + emp.setE_salary(sc.nextDouble()); + if(emp.getE_salary()>0) + { + //System.out.println(emp.getE_salary()); + bool=true; + } + else + bool=false; + + } + else + { + temp=sc.next(); + } + if(bool==false) + System.out.println("Please Enter Appropriate Salary"); + } + while(bool==false); + sc.nextLine(); + System.out.println("Enter Employee Address"); + do { + bool=false; + String add=sc.nextLine(); + if(add.isBlank()) + System.out.println("Please Enter Appropriate Address"); + else + { + emp.setE_address(add); + bool=true; + + } + } + while(bool==false); + + System.out.println("Enter Employee e-mail address"); + bool=true; + do + { + bool=false; + bool=sc.hasNext("[a-zA-Z0-9_+&*-]+(?:\\."+"[a-zA-Z0-9_+&*-]+)*@" +"(?:[a-zA-Z0-9-]+\\.)+[a-z" +"A-Z]{2,7}$"); + + if(bool) + { + emp.setE_email(sc.next()); + bool=true; + } + else + { + temp=sc.next(); + System.out.println("Please enter a valid Email address"); + } + + }while(!bool); + + } + public void displayEmployeeDetails(Employee em) + { + + System.out.format("%-30d %-30s %-30s %-30s %-30f %-40s %-30s",em.getE_id(),em.getE_name(),em.getE_role(),em.getE_contact_no(),em.getE_salary(),em.getE_address(),em.getE_email()); + System.out.println(); + } + public void checkIfAlreadyPesent(Employee emp) + { + int flag = 0;//turns 1 if an employee is found + Node temp = ll.getHead(); + // System.out.println("temp is"+temp); + while(temp!=null) + { + Employee etemp = (Employee)temp.getData(); + if(emp.getE_contact_no().equals(etemp.getE_contact_no())) + { + flag = 1; + //System.out.println(flag); + + } + if(flag==1) + { + temp = null;//loop termination + } + else + { + temp = temp.getNext(); + } + } + if(flag==0)//no match was found + { + int id = Employee.getIDgenerator(); + //System.out.println(id ); + id++; + Employee.setIDgenerator(id); + emp.setE_id(id); + ll.insertLast(emp); + + } + } + + public void deleteEmployee(Scanner sc) + { + int id = 0; + Boolean bool = true; + System.out.println("Enter the employee ID for the employee to be deleted"); + do + { + bool = sc.hasNextInt(); + if(bool) + { + id = sc.nextInt(); + } + else + { + String s = sc.next(); + System.out.println("Please enter a valid ID"); + } + + }while(!bool); + + Node result=searchEmployeeBasedOnID(id); + ll.deleteNode(result); + } + public Node searchEmployeeBasedOnID(int id) + { + Node result=null; + + if(ll.getHead()==null) + { + System.out.println("Empty list. Cannot search"); + } + else + { + + Node temp = ll.getHead(); + while(temp!=null) //traverse till the end + { + if((((Employee)temp.getData()).getE_id())==id) + { + result=temp; + } + temp = temp.getNext(); + } + } + return result; + + } + + + public void displayList() + { + if(ll.getHead()==null) + { + System.out.println("Empty list"); + } + else + { + Node temp = ll.getHead(); + System.out.println("********************************************************************************************************************************************************************************************************************************************************"); + System.out.printf("%-30s %-30s %-30s %-30s %-30s %-40s %-30s","EMPLOYEE_ID","EMPLOYEE_NAME","EMPLOYEE_ROLE","EMPLOYEE_CONTACT_NUMBER","EMPLOYEE_SALARY","EMPLOYEE_ADDRESS","EMPLOYEE_EMAIL_ADRESS"); + System.out.println(); + System.out.println("********************************************************************************************************************************************************************************************************************************************************"); + while(temp!=null) //traverse till the end + { + this.displayEmployeeDetails((Employee)temp.getData()); + temp = temp.getNext(); + } + System.out.println("********************************************************************************************************************************************************************************************************************************************************"); + + } + } + public void searchEmployee(Scanner sc) + { + boolean result = false; + int id = 0; + int flag=0; + if(ll.getHead()==null) + { + System.out.println("Empty list. Cannot search"); + } + else + { + System.out.println("Enter the Employee ID that has to be searched"); + id = sc.nextInt(); + Node temp = ll.getHead(); + while(temp!=null) //traverse till the end + { + if((((Employee)temp.getData()).getE_id())==id) + { + + if(flag==0) + { + System.out.format("%-30s %-30s %-30s %-30s %-30s %-40s %-30s","Employee Id","Employee Name","Employee Role","Employee Contact No.","Employee Salary","Employee Address","Employee Email Id"); + System.out.println(); + flag=1; + } + this.displayEmployeeDetails((Employee)temp.getData()); + result = true;//employee found + } + temp = temp.getNext(); + } + } + if(result==false) + { + System.out.println("The employee could not be found"); + } + + } + public void addToDatabase() + { + Connection con ; + Statement st; + try + { + Class.forName("com.mysql.cj.jdbc.Driver"); + con=DriverManager.getConnection("jdbc:mysql://localhost:3306/supermarket","root","root"); + st=con.createStatement(); + st.executeUpdate("delete from empdata"); + Node temp=ll.getHead(); + while(temp!=null) + { + Employee e = (Employee) temp.getData(); + + st.executeUpdate("insert into empdata(ID,NAME,CONTACT,ROLE,SALARY,ADDRESS,EMAILID)values("+e.getE_id()+",'"+e.getE_name()+"','"+e.getE_contact_no()+"','"+e.getE_role()+"',"+e.getE_salary()+",'"+e.getE_address()+"','"+e.getE_email()+"')"); + temp=temp.getNext(); + } + st.close(); + con.close(); + } + catch(Exception e) + { + System.out.println(e); + } + } + public void retrieveFromDataBase() + { + Connection con=null; + Statement st=null; + ResultSet rs=null; + //LinkedList ll=new LinkedList(); + try + { + Class.forName("com.mysql.cj.jdbc.Driver"); + con=DriverManager.getConnection("jdbc:mysql://localhost:3306/supermarket","root","root"); + st=con.createStatement(); + rs=st.executeQuery("select * from empdata"); + //System.out.println("rs is"+rs.next()); + while(rs.next()) + { + + Employee em=new Employee(); + //System.out.println("em"); + em.setE_id(rs.getInt(1)); + em.setE_name(rs.getString(2)); + em.setE_contact_no(rs.getString(3)); + em.setE_role(rs.getString(4)); + em.setE_salary(rs.getDouble(5)); + em.setE_address(rs.getString(6)); + em.setE_email(rs.getString(7)); + ll.insertLast(em); + + Employee.setIDgenerator(em.getE_id()); + } + rs.close(); + st.close(); + con.close(); + } + catch(Exception e) + { + //System.out.println("Exception is being thrown from retrieve database"); + System.out.println(e); + } + } + + public void searchEmployeeOnBasisOfRole(Scanner sc) + { + boolean result =false; + String temprole; + boolean bool=true; + int flag=0; + if(ll.getHead()==null) { + System.out.println("Empty list. Cannot search"); } + else + { + + System.out.println("Enter Employee Role"); + sc.nextLine(); + do { + bool=false; + temprole=sc.nextLine(); + if(temprole.isBlank()) + System.out.println("Please Enter Appropriate Employee Role"); + else + { + + bool=true; + + } + }while(bool==false); + + Node temp = ll.getHead(); + while(temp!=null) + { + if((((Employee)temp.getData()).getE_role().equals(temprole))) + { + if(flag==0) + { + System.out.format("%-30s %-30s %-30s %-30s %-30s %-40s %-30s","Employee Id","Employee Name","Employee Role","Employee Contact No.","Employee Salary","Employee Address","Employee Email Id"); + System.out.println(); + + flag=1; + } + this.displayEmployeeDetails((Employee)temp.getData()); + + result = true;//employee found + } + temp = temp.getNext(); + } + } + if(result==false) + { + System.out.println("There is no employee undder this role"); + } + } + + + public void higest_salary() + { + boolean result =false; + double maximum=0; + double maxi=0; + if(ll.getHead()==null) { + System.out.println("Empty list. Cannot search"); } + else { + Node temp = ll.getHead(); + Node after=temp.getNext(); + while(after!=null) + { + maxi=Double.max(((Employee)temp.getData()).getE_salary(),((Employee)after.getData()).getE_salary()); + maximum=Double.max(maximum,maxi); + temp=temp.getNext(); + after=after.getNext(); + } + System.out.println("Highest Salary of the employee is "+maximum); + } + } +} diff --git a/src/linkedlist_package/LinkedList.java b/src/linkedlist_package/LinkedList.java new file mode 100644 index 0000000..7ecea25 --- /dev/null +++ b/src/linkedlist_package/LinkedList.java @@ -0,0 +1,58 @@ +package linkedlist_package; + +public class LinkedList +{ + private Node head; + + + public Node getHead() { + return head; + } + + public void setHead(Node head) { + this.head = head; + } + + + public void insertLast(Object obj) + { + Node newnode=new Node(); + newnode.setData(obj); + if (head==null) + { + head=newnode; + } + else + { + Node temp=head; + while(temp.getNext()!=null) + { + temp=temp.getNext(); + } + temp.setNext(newnode); + } + } + + public void deleteNode(Node node) + { + if(head==null) + { + return; + } + if(node.equals(head)) + { + head=head.getNext(); + return; + } + Node temp=head; + while(temp!=null) + { + if(node.equals(temp.getNext())) + { + temp.setNext(temp.getNext().getNext()); + return; + } + temp=temp.getNext(); + } + } +} diff --git a/src/linkedlist_package/Node.java b/src/linkedlist_package/Node.java new file mode 100644 index 0000000..09e9913 --- /dev/null +++ b/src/linkedlist_package/Node.java @@ -0,0 +1,19 @@ +package linkedlist_package; + +public class Node +{ + private Object data; + private Node next; + public Object getData() { + return data; + } + public void setData(Object data) { + this.data = data; + } + public Node getNext() { + return next; + } + public void setNext(Node next) { + this.next = next; + } +} diff --git a/src/product_package/Product.java b/src/product_package/Product.java new file mode 100644 index 0000000..271bf36 --- /dev/null +++ b/src/product_package/Product.java @@ -0,0 +1,100 @@ +package product_package; + +import java.util.Scanner; + +public class Product +{ + private int productID; + private int productQuantity; + private String productName; + private String productBrand; + private String productCategory; + private double productCostPrice; + private double productMrp; + private static int IDgenerator = 0; + + public Product() //default constructor + { + //IDgenerator++; + //productID = IDgenerator; + } + + //getter methods + + public int getProductQuantity() + { + return productQuantity; + } + + public int getProductID() + { + return productID; + } + public String getProductName() + { + return productName; + } + public double getMrp() + { + return productMrp; + } + public String getBrand() + { + return productBrand; + } + public String getCategory() + { + return productCategory; + } + public double getCostPrice() + { + return productCostPrice; + } + public void setProductQuantity(int productQuantity) + { + this.productQuantity = productQuantity; + } + + public void setProductCategory(String productCategory) + { + this.productCategory = productCategory; + } + + public void setProductCostPrice(double productCostPrice) + { + this.productCostPrice = productCostPrice; + } + + public void setProductMrp(double productMrp) + { + this.productMrp = productMrp; + } + + + + + + public void setProductID(int productID) + { + this.productID = productID; + } + + public void setProductName(String productName) + { + this.productName = productName; + } + + public void setProductBrand(String productBrand) + { + this.productBrand = productBrand; + } + + + public static int getIDgenerator() { + return IDgenerator; + } + + public static void setIDgenerator(int iDgenerator) { + IDgenerator = iDgenerator; + } +} diff --git a/src/product_package/ProductImplementation.java b/src/product_package/ProductImplementation.java new file mode 100644 index 0000000..0b20cee --- /dev/null +++ b/src/product_package/ProductImplementation.java @@ -0,0 +1,639 @@ + +package product_package; +import linkedlist_package.*; + +import java.util.Scanner; + +import java.sql.*; + +public class ProductImplementation +{ + public LinkedList ll = new LinkedList(); + + public void addProduct(Scanner sc) + { + Product p = new Product(); + this.acceptNameBrandQuantity(sc,p); + this.checkIfAlreadyPesent(p,sc); + } + + //accept these details to check if the product is existing or not + public void acceptNameBrandQuantity(Scanner sc,Product p) + { + String temp = ""; + Boolean bool = true; + System.out.println("Enter the Product name"); + temp = sc.nextLine(); + if(temp.isEmpty()) + { + do + { + temp = sc.nextLine(); + if(temp.isBlank()) + { + System.out.println("Please enter a valid product name"); + bool = false; + } + else + { + p.setProductName(temp); + bool = true; + } + }while(bool==false); + } + else + { + do + { + if(temp.isBlank()) + { + System.out.println("Please enter a valid product name"); + temp = sc.nextLine(); + bool = false; + } + else + { + p.setProductName(temp); + bool = true; + } + }while(bool==false); + } + + System.out.println("Enter the Product brand"); + temp = sc.nextLine(); + if(temp.isEmpty()) + { + do + { + temp = sc.nextLine(); + if(temp.isBlank()) + { + System.out.println("Please enter a valid product brand"); + bool = false; + } + else + { + p.setProductBrand(temp); + bool = true; + } + }while(bool==false); + } + else + { + do + { + if(temp.isBlank()) + { + System.out.println("Please enter a valid product brand"); + temp = sc.nextLine(); + bool = false; + } + else + { + p.setProductBrand(temp); + bool = true; + } + }while(bool==false); + } + + System.out.println("Enter the Product Quantity"); + do + { + bool = sc.hasNextInt(); + if(bool) + { + p.setProductQuantity(sc.nextInt()); + } + else + { + temp = sc.next(); + System.out.println("Please enter a valid Quantity"); + } + + }while(!bool); + } + + //accept these details only if the product does not exist + public void acceptCategoryCpMrp(Scanner sc,Product p) + { + Boolean bool = true; + String temp = ""; + System.out.println("Enter the Product category"); + temp = sc.nextLine(); + if(temp.isEmpty()) + { + do + { + temp = sc.nextLine(); + if(temp.isBlank()) + { + System.out.println("Please enter a valid product category"); + bool = false; + } + else + { + p.setProductCategory(temp); + bool = true; + } + }while(bool==false); + } + else + { + do + { + if(temp.isBlank()) + { + System.out.println("Please enter a valid product category"); + temp = sc.nextLine(); + bool = false; + } + else + { + p.setProductBrand(temp); + bool = true; + } + }while(bool==false); + } + + System.out.println("Enter the Product Cost Price"); + do + { + bool = sc.hasNextDouble(); + if(bool) + { + p.setProductCostPrice(sc.nextDouble()); + } + else + { + temp = sc.next(); + System.out.println("Please enter a valid cost price"); + } + + }while(!bool); + + System.out.println("Enter the Product MRP"); + do + { + bool = sc.hasNextInt(); + if(bool) + { + p.setProductMrp(sc.nextDouble()); + } + else + { + temp = sc.next(); + System.out.println("Please enter a valid MRP"); + } + + }while(!bool); + + } + + public void displayProductDetails(Product p) + { + String s = String.format("\n|%-15d", p.getProductID()); + System.out.print(s); + s = String.format("|%-15s", p.getProductName()); + System.out.print(s); + s = String.format("|%-15s", p.getBrand()); + System.out.print(s); + s = String.format("|%-20s", p.getCategory()); + System.out.print(s); + s = String.format("|%-15f", p.getCostPrice()); + System.out.print(s); + s = String.format("|%-15f", p.getMrp()); + System.out.print(s); + s = String.format("|%-15d", p.getProductQuantity()); + System.out.print(s+"|"); + } + + public void checkIfAlreadyPesent(Product p, Scanner sc) + { + int flag = 0;//turns 1 if an identical product is found + Node temp = ll.getHead(); + while(temp!=null) + { + Product ptemp = (Product)temp.getData(); + if(p.getBrand().equalsIgnoreCase(ptemp.getBrand())) + { + if(p.getProductName().equalsIgnoreCase(ptemp.getProductName())) + { + addQuantity(temp,p.getProductQuantity()); + flag = 1; + } + } + if(flag==1) + { + temp = null;//loop termination + } + else + { + temp = temp.getNext(); + } + } + if(flag==0)//no match was found + { + int id = Product.getIDgenerator(); + id++; + Product.setIDgenerator(id); + p.setProductID(id); + this.acceptCategoryCpMrp(sc, p); + ll.insertLast(p); + } + } + + public void deleteProduct(Scanner sc) + { + int id = 0; + Boolean bool = true; + System.out.println("Enter the product ID for the product to be deleted"); + do + { + bool = sc.hasNextInt(); + if(bool) + { + id = sc.nextInt(); + } + else + { + String s = sc.next(); + System.out.println("Please enter a valid ID"); + } + + }while(!bool); + + Node result=searchProductBasedOnID(id); + ll.deleteNode(result); + } + + public void displayList() + { + if(ll.getHead()==null) + { + System.out.println("Empty list"); + } + else + { + System.out.printf("|%-15s|%-15s|%-15s|%-20s|%-15s|%-15s|%-15s|", "PRODUCT ID","PRODUCT NAME","PRODUCT BRAND","PRODUCT CATEGORY","COST PRICE","MRP","QUANTITY"); + System.out.printf("\n|%-15s|%-15s|%-15s|%-20s|%-15s|%-15s|%-15s|", " "," "," "," "," "," "," "); + Node temp = ll.getHead(); + while(temp!=null) //traverse till the end + { + this.displayProductDetails((Product)temp.getData()); + temp = temp.getNext(); + } + } + + } + + public void printProductDetailsBasedOnID(Scanner sc) + { + int id = 0; + System.out.println("Enter the product ID that has to be searched"); + id = sc.nextInt(); + Node result=searchProductBasedOnID(id); + if(result==null) + { + System.out.println("The product could not be found"); + } + else + { + //Headings are displayed only once since ID is unique. + System.out.printf("\n|%-15s|%-15s|%-15s|%-20s|%-15s|%-15s|%-15s|", "PRODUCT ID","PRODUCT NAME","PRODUCT BRAND","PRODUCT CATEGORY","COST PRICE","MRP","QUANTITY"); + System.out.printf("\n|%-15s|%-15s|%-15s|%-20s|%-15s|%-15s|%-15s|", " "," "," "," "," "," "," "); + this.displayProductDetails((Product) result.getData()); + } + } + + private Node searchProductBasedOnID(int id) + { + Node result = null; + + if(ll.getHead()==null) + { + System.out.println("Empty list. Cannot search"); + } + else + { + + Node temp = ll.getHead(); + while(temp!=null) //traverse till the end + { + if((((Product)temp.getData()).getProductID())==id) + { + result = temp; + } + temp = temp.getNext(); + } + } + return result; + + } + + public void searchProductBasedOnBrand(Scanner sc) + { + boolean result = false; + int flag = 0;//becomes 1 if headings are printed once + String brand = null; + if(ll.getHead()==null) + { + System.out.println("Empty list. Cannot search"); + } + else + { + System.out.println("Enter the product brand that has to be searched"); + brand = sc.next(); + Node temp = ll.getHead(); + + while(temp!=null) //traverse till the end + { + if((((Product)temp.getData()).getBrand()).equalsIgnoreCase(brand)) + { + if(flag==0) + { + System.out.printf("\n|%-15s|%-15s|%-15s|%-20s|%-15s|%-15s|%-15s|", "PRODUCT ID","PRODUCT NAME","PRODUCT BRAND","PRODUCT CATEGORY","COST PRICE","MRP","QUANTITY"); + System.out.printf("\n|%-15s|%-15s|%-15s|%-20s|%-15s|%-15s|%-15s|", " "," "," "," "," "," "," "); + flag = 1; + } + this.displayProductDetails((Product)temp.getData()); + result = true;//product found + + } + temp = temp.getNext(); + } + } + if(result==false) + { + System.out.println("\nThe product could not be found"); + } + + } + + public void addToDataBase() + { + + + Connection con = null; + Statement st = null; + try + { + Class.forName("com.mysql.cj.jdbc.Driver"); + con=DriverManager.getConnection("jdbc:mysql://localhost:3306/supermarket","root","root"); + st=con.createStatement(); + st.executeUpdate("delete from products"); + if(ll.getHead()==null) + { + System.out.println("The list is empty. Cannot add to database."); + } + else + { + //adding entire linked list + + Node temp = ll.getHead();//used for traversing the linked list + while(temp!=null) + { + Product p = (Product) temp.getData(); + + st.executeUpdate("insert into products(productID,productName,productBrand,productCategory,productCostPrice,productMrp,productQuantity) values ("+p.getProductID()+",'"+p.getProductName()+"','"+p.getBrand()+"','"+p.getCategory()+"',"+p.getCostPrice()+","+p.getMrp()+","+p.getProductQuantity()+")"); + temp = temp.getNext(); + } + + st.close(); + con.close(); + } + } + catch(Exception e) + { + //System.out.println("Hello"); + System.out.println(e); + } + } + + public void retrieveFromDataBase() + { + Connection con = null; + Statement st = null; + ResultSet rs = null; + try + { + Class.forName("com.mysql.cj.jdbc.Driver"); + con=DriverManager.getConnection("jdbc:mysql://localhost:3306/supermarket","root","root"); + st=con.createStatement(); + rs=st.executeQuery("select * from products"); + while(rs.next())//this loop executes till the table contents are exhausted. Doesn't stop at the end of a row + { + Product p = new Product(); + p.setProductID(rs.getInt(1)); + p.setProductName(rs.getString(2)); + p.setProductBrand(rs.getString(3)); + p.setProductCategory(rs.getString(4)); + p.setProductCostPrice(rs.getDouble(5)); + p.setProductMrp(rs.getDouble(6)); + p.setProductQuantity(rs.getInt(7)); + ll.insertLast(p); + Product.setIDgenerator(p.getProductID()); + } + rs.close(); + st.close(); + con.close(); + } + catch(Exception e) + { + //System.out.println("Hello"); + System.out.println(e); + } + } + + public void addQuantity(Node node,int newQuantity) + { + int updatedQuantity = 0; + updatedQuantity = ((Product) node.getData()).getProductQuantity()+newQuantity; + ((Product) node.getData()).setProductQuantity(updatedQuantity); + } + + public void subQuantity(int id,int quantitySold)//gouri will send productID and sold quantity + { + int updatedQuantity = 0; + Node result=searchProductBasedOnID(id); + if(result==null) + { + System.out.println("The product could not be found"); + } + else + { + updatedQuantity = ((Product) result.getData()).getProductQuantity()-quantitySold; + ((Product)result.getData()).setProductQuantity(updatedQuantity); + } + } + + + public Node mergeSort() + { + LinkedList sorted = new LinkedList(); + //since we do not want to change the original linked list, copying into the sorted list + Node temp = ll.getHead(); + while(temp!=null) + { + sorted.insertLast((Object)temp.getData()); + temp = temp.getNext(); + } + + if(sorted.getHead()==null) + { + System.out.println("Empty list. Cannot sort"); + } + else + { + if(sorted.getHead().getNext()==null) + { + System.out.println("There is only 1 element in the list. No need to sort"); + } + else + { + sorted.setHead(split(sorted.getHead())); + } + } + return sorted.getHead(); + } + + private Node split(Node head) + { + Node mid = null; + Node nextOfMid = null; + Node result = null; + Node head1 = null; + Node head2 = null; + + if(head==null || head.getNext()==null)//there is no list left or there is a single element left. + { + result = head; + } + else + { + mid = calculateMid(head); + nextOfMid = mid.getNext(); + mid.setNext(null);//indicates end of divided list(1st half) + + //head holds 1st node of 1st half + //nextOfMid holds 1st node of 2nd half + + head1 = split(head); + head2 = split(nextOfMid); + result = merge(head1,head2); + } + return result; + } + + private Node merge(Node head1,Node head2) + { + Node head = null;//will store the head of two merged lists + int q1 = 0;//stores quantity of head1 + int q2 = 0;//stores quantity of head2 + if(head1==null) + { + head = head2;//if head1 is empty, no need to sort head2 + } + else + { + if(head2==null) + { + head = head1;//if head2 is empty, no need to sort head1 + } + else + { + //sorting in ascending order based on quantity available of the product + q1 = ((Product) head1.getData()).getProductQuantity(); + q2 = ((Product) head2.getData()).getProductQuantity(); + if(q1>q2) + { + head = head2; + head.setNext(merge(head1,head2.getNext())); + } + else + { + head = head1; + head.setNext(merge(head1.getNext(),head2)); + } + } + } + return head; + } + + private Node calculateMid(Node head) + { + //slow moves at half the speed of fast. + //till fast reaches the end of the list, slow points to the mid node + + Node slow = null; + Node fast = null; + if (head!=null) + { + slow = head; + fast = head; + + while ((fast.getNext() != null) && (fast.getNext().getNext() != null)) + { + slow = slow.getNext(); + fast = fast.getNext().getNext(); + } + } + return slow; + } + + //just written if in case no of products in the market has to be known + public int calculateLengthOfLinkedList(LinkedList templl) + { + int len = 0; + Node temp = templl.getHead(); + while(temp!=null) + { + len++; + temp = temp.getNext(); + } + return len; + } + + public void displayProductsAboutToFinish() + { + int flag = 0;//becomes 1 if headings are printed once + if(ll.getHead()==null) + { + System.out.println("Empty list"); + } + else + { + Node temp = ll.getHead(); + while(temp!=null) //traverse till the end + { + if(((Product)temp.getData()).getProductQuantity()<=15) + { + if(flag==0) + { + System.out.printf("\n|%-15s|%-15s|%-15s|%-20s|%-15s|%-15s|%-15s|", "PRODUCT ID","PRODUCT NAME","PRODUCT BRAND","PRODUCT CATEGORY","COST PRICE","MRP","QUANTITY"); + System.out.printf("\n|%-15s|%-15s|%-15s|%-20s|%-15s|%-15s|%-15s|", " "," "," "," "," "," "," "); + flag = 1; + } + this.displayProductDetails((Product)temp.getData()); + } + temp = temp.getNext(); + } + } + } + + public void updateCost(int id,double mrp,double cost) + { + Node nodeToBeUpdated = null; + nodeToBeUpdated = this.searchProductBasedOnID(id); + if(nodeToBeUpdated==null) + { + System.out.println("Product not found"); + } + else + { + ((Product)nodeToBeUpdated.getData()).setProductMrp(mrp); + ((Product)nodeToBeUpdated.getData()).setProductCostPrice(cost); + } + + } + +} diff --git a/src/stock_package/Stock.java b/src/stock_package/Stock.java new file mode 100644 index 0000000..74e474a --- /dev/null +++ b/src/stock_package/Stock.java @@ -0,0 +1,81 @@ +package stock_package; +import java.util.Scanner; +import product_package.*; +import dealer_package.*; +import linkedlist_package.Node; +public class Stock +{ + Scanner sc=new Scanner(System.in); + public void checkStock(ProductImplementation piobj,DealerImplementation dobj) + { + String pdtBrand=""; + String pdtName=""; + String yorn=""; + int qtyReq=0; + boolean bool=true; + boolean result = false; + + if(piobj.ll.getHead()==null) + { + System.out.println("Empty list. Cannot search"); + } + else + { + Node temp = piobj.ll.getHead(); + while(temp!=null) //traverse till the end + { + if((((Product)temp.getData()).getProductQuantity())<=15) + { + pdtBrand=((Product)temp.getData()).getBrand(); + pdtName=((Product)temp.getData()).getProductName(); + System.out.println(); + System.out.printf("|%-15s|%-15s|%-15s|%-20s|%-15s|%-15s|%-15s|", "PRODUCT ID","PRODUCT NAME","PRODUCT BRAND","PRODUCT CATEGORY","COST PRICE","MRP","QUANTITY"); + System.out.printf("\n|%-15s|%-15s|%-15s|%-20s|%-15s|%-15s|%-15s|", " "," "," "," "," "," "," "); + piobj.displayProductDetails((Product)temp.getData()); + + System.out.println(); + System.out.println(); + System.out.println("WOULD LIKE TO ORDER THIS PRODUCT? ENTER Y FOR YES N FOR NO"); + do + { + bool=sc.hasNext(); + if(bool) + { + yorn=sc.next(); + } + else + { + System.out.println("Please enter a valid input"); + } + if(!(yorn.equalsIgnoreCase("y")||yorn.equalsIgnoreCase("n"))) + { + bool=false; + System.out.println("Please enter y-yes or n-no"); + } + }while(!bool); + + if(yorn.equalsIgnoreCase("y")) + { + System.out.println("Enter the quantity required :"); + qtyReq=sc.nextInt(); + Dealer best_dealer=dobj.compareDealers(qtyReq,pdtBrand,pdtName); + if(best_dealer==null) + { + System.out.println("NO DEALER AVAILABLE FOR THIS PRODUCT"); + } + else + { + dobj.displayBest(best_dealer); + } + } + result = true;//product found + } + temp = temp.getNext(); + } + } + if(result==false) + { + System.out.println("NO PRODUCT WITH QUANTITY LESS THAN 15."); + } + } +} diff --git a/src/user_package/User.java b/src/user_package/User.java new file mode 100644 index 0000000..4417328 --- /dev/null +++ b/src/user_package/User.java @@ -0,0 +1,381 @@ +package user_package; +import java.util.Scanner; + +import billing_package.Billing; +import dealer_package.DealerImplementation; +import employee_package.EmployeeImplementation; +import product_package.ProductImplementation; +import stock_package.Stock; + +public class User +{ + public static void main(String[] args) + { + ProductImplementation piobj = new ProductImplementation(); + EmployeeImplementation empobj = new EmployeeImplementation(); + Billing bobj = new Billing(); + Stock sobj = new Stock(); + DealerImplementation diobj = new DealerImplementation(); + + int roleChoice = 0; + int functionChoice = 0; + int inventoryChoice=0; + int billingch=0; + int salesChoice=0; + Boolean bool = false; + int open = 0;//if 1 then it is open + Scanner sc = new Scanner(System.in); + + //retrieving all the data from the data base into the linked lists + piobj.retrieveFromDataBase(); + empobj.retrieveFromDataBase(); + bobj.retrieve(); + diobj.retrieve(); + + do + { + System.out.println("SELECT AN OPTION: "); + System.out.println("1. OPEN"); + System.out.println("0. CLOSE"); + System.out.println("ENTER CHOICE:"); + do + { + bool = sc.hasNextInt(); + if(bool) + { + open = sc.nextInt(); + } + else + { + String s = sc.next(); + System.out.println("Please enter a valid choice"); + } + + }while(!bool); + + System.out.println(); + + switch(open) + { + case 1: + System.out.println("WELCOME!"); + do + { + System.out.println("ROLES:"); + System.out.println("1. STORE MANAGER"); + System.out.println("2. INVENTORY CONTROL SPECIALIST"); + System.out.println("3. CASHIER"); + System.out.println("4. SALES ASSOCIATE"); + System.out.println("5. VIEW PROFILE"); + System.out.println("0. EXIT"); + System.out.println("ENTER YOUR ROLE: "); + do + { + bool = sc.hasNextInt(); + if(bool) + { + roleChoice = sc.nextInt(); + } + else + { + String s = sc.next(); + System.out.println("Please enter a valid choice"); + } + + }while(!bool); + + System.out.println(); + + switch(roleChoice) + { + case 1: + do + { + System.out.println(); + System.out.println("FUNCTIONS:"); + System.out.println("1. DISPLAY THE PRODUCT LIST"); + System.out.println("2. DISPLAY THE EMPLOYEE LIST"); + System.out.println("3. DISPLAY THE DEALER LIST"); + System.out.println("4. DISPLAY THE PRODUCTS OF A PARTICULAR BRAND"); + System.out.println("5. CHECK STOCK FOR PRODUCTS WITH QUANTITY LESS THAN 15"); + System.out.println("6. ADD A NEW EMPLOYEE"); + System.out.println("7. REMOVE AN EMPLOYEE"); + System.out.println("8. SEARCH EMPLOYEE ON THE BASIS OF ROLE"); + System.out.println("9. HIGHEST EMPLOYEE SALARY"); + System.out.println("0. EXIT"); + System.out.println("PLEASE ENTER A CHOICE FROM THE ABOVE MENU: "); + do + { + bool = sc.hasNextInt(); + if(bool) + { + functionChoice = sc.nextInt(); + } + else + { + String s = sc.next(); + System.out.println("Please enter a valid choice"); + } + + }while(!bool); + + System.out.println(); + + switch(functionChoice) + { + case 1: piobj.displayList(); + System.out.println("\n Total Number of products in the market are: "+piobj.calculateLengthOfLinkedList(piobj.ll)); + break; + case 2: empobj.displayList(); + break; + case 3: diobj.displayList(); + break; + case 4: piobj.searchProductBasedOnBrand(sc); + break; + case 5: piobj.displayProductsAboutToFinish(); + break; + case 6: empobj.addEmployee(sc); + break; + case 7: empobj.deleteEmployee(sc); + break; + case 8: empobj.searchEmployeeOnBasisOfRole(sc); + break; + case 9: empobj.higest_salary(); + break; + case 0: System.out.println("Exiting..."); + break; + default:System.out.println("*INVALID CHOICE*"); + } + }while(functionChoice!=0); + break; + + case 2: + do + { + System.out.println(); + System.out.println("FUNCTIONS:"); + System.out.println("1. DISPLAY PRODUCT LIST"); + System.out.println("2. CHECK STOCK"); + System.out.println("3. ADD DETAILS OF NEW DEALER"); + System.out.println("4. DISPLAY DETAILS OF A PARTICULAR DEALER"); + System.out.println("5. DELETE DETAILS OF A PARTICULAR DEALER"); + System.out.println("6. DISPLAY THE DEALER LIST"); + System.out.println("7. ADD NEW PRODUCT"); + System.out.println("8. UPDATE PRICE OF A PARTICULAR PRODUCT"); + System.out.println("9. DISPLAY DETAILS OF A PRODUCT BASED ON ID "); + System.out.println("10. DISPLAY DETAILS OF PRODUCT BASED ON BRAND"); + System.out.println("11. DELETE DETAILS OF A PARTICULAR PRODUCT"); + System.out.println("0. EXIT"); + System.out.println("PLEASE ENTER A CHOICE FROM THE ABOVE MENU: "); + do + { + bool = sc.hasNextInt(); + if(bool) + { + inventoryChoice = sc.nextInt(); + } + else + { + String s = sc.next(); + System.out.println("Please enter a valid choice"); + } + + }while(!bool); + + System.out.println(); + + switch(inventoryChoice) + { + case 1: piobj.displayList(); + System.out.println("Number of products in the market are: "+piobj.calculateLengthOfLinkedList(piobj.ll)); + break; + case 2: sobj.checkStock(piobj,diobj); + break; + case 3: diobj.addNewDealer(sc); + break; + case 4: diobj.displayWithId(sc); + break; + case 5: diobj.deleteWithId(sc); + break; + case 6: diobj.displayList(); + break; + case 7: piobj.addProduct(sc); + break; + case 8: + int id = 0; + double mrp = 0.0; + double cost = 0.0; + System.out.println("Enter the product ID of the product for which the cost is to be updated"); + do + { + bool = sc.hasNextInt(); + if(bool) + { + id = sc.nextInt(); + } + else + { + String s = sc.next(); + System.out.println("Please enter a valid ID"); + } + + }while(!bool); + + System.out.println("Enter its MRP"); + + do + { + bool = sc.hasNextDouble(); + if(bool) + { + mrp = sc.nextDouble(); + } + else + { + String s = sc.next(); + System.out.println("Please enter a valid MRP"); + } + + }while(!bool); + + System.out.println("Enter its cost price"); + + do + { + bool = sc.hasNextDouble(); + if(bool) + { + cost = sc.nextDouble(); + } + else + { + String s = sc.next(); + System.out.println("Please enter a valid cost price"); + } + + }while(!bool); + + piobj.updateCost(id,mrp,cost); + break; + case 9: piobj.printProductDetailsBasedOnID(sc); + break; + case 10: piobj.searchProductBasedOnBrand(sc); + break; + case 11: piobj.deleteProduct(sc); + break; + case 0: System.out.println("Exiting..."); + break; + default: + System.out.println("INVALID CHOICE"); + + } + }while(inventoryChoice!=0); + break; + + + case 3: + do + { + System.out.println(); + System.out.println("FUNCTIONS"); + System.out.println("1.GENERATE A BILL"); + System.out.println("0.EXIT"); + System.out.println("ENTER CHOICE :"); + do + { + bool = sc.hasNextInt(); + if(bool) + { + billingch = sc.nextInt(); + } + else + { + String s = sc.next(); + System.out.println("Please enter a valid choice"); + } + }while(!bool); + + System.out.println(); + + switch(billingch) + { + case 1: + bobj.billGeneration(piobj,sc); + break; + case 0: + System.out.println("EXITING..."); + break; + default: + System.out.println("INVALID CHOICE"); + } + }while(billingch!=0); + break; + case 4: + do + { + System.out.println(); + System.out.println("FUNCTIONS:"); + System.out.println("1. VIEW PRODUCT DETAILS BASED ON ID"); + System.out.println("2. VIEW PRODUCT DETAILS BASED ON BRAND"); + System.out.println("0. EXIT"); + System.out.println(" PLEASE ENTER CHOICE "); + do + { + bool = sc.hasNextInt(); + if(bool) + { + salesChoice = sc.nextInt(); + } + else + { + String s = sc.next(); + System.out.println("Please enter a valid choice"); + } + + }while(!bool); + + System.out.println(); + + switch(salesChoice) + { + case 1: piobj.printProductDetailsBasedOnID(sc); + break; + case 2: piobj.searchProductBasedOnBrand(sc); + break; + case 0: System.out.println("Exiting.."); + break; + default:System.out.println("*INVALID CHOICE*"); + } + }while(salesChoice!=0); + + break; + case 5: + empobj.searchEmployee(sc); + break; + case 0: + System.out.println("EXITING..."); + break; + + default: + System.out.println("*INVALID CHOICE*"); + } + }while(roleChoice != 0);//while corresponding to roles + break; + + case 0: + piobj.addToDataBase(); + empobj.addToDatabase(); + diobj.addToDatabase(); + bobj.loadIntoDatabase(); + System.out.println("CLOSING..."); + break; + + default: + System.out.println("*INVALID CHOICE*"); + + } + }while(open != 0); + } + +} + diff --git a/supermarket.sql b/supermarket.sql new file mode 100644 index 0000000..b87934c --- /dev/null +++ b/supermarket.sql @@ -0,0 +1,142 @@ +-- MySQL dump 10.13 Distrib 8.0.23, for Win64 (x86_64) +-- +-- Host: localhost Database: supermarket +-- ------------------------------------------------------ +-- Server version 8.0.23 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `customers` +-- + +DROP TABLE IF EXISTS `customers`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `customers` ( + `c_name` varchar(30) NOT NULL, + `c_phone_no` varchar(10) NOT NULL, + `c_points` int NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `customers` +-- + +LOCK TABLES `customers` WRITE; +/*!40000 ALTER TABLE `customers` DISABLE KEYS */; +INSERT INTO `customers` VALUES ('manisha','9121343222',100),('anahita','9121343223',1),('ruchika','9121343224',50),('jagdish','9394093604',2),('vanshika','8796325401',5),('chetan','6014533378',0),('vantika','7032145698',1),('krishna','6841230079',0),('radha','9908444482',1); +/*!40000 ALTER TABLE `customers` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `dealer` +-- + +DROP TABLE IF EXISTS `dealer`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `dealer` ( + `ID` int NOT NULL, + `Name` varchar(50) NOT NULL, + `Category` varchar(20) NOT NULL, + `Product_Name` varchar(20) NOT NULL, + `Company` varchar(50) NOT NULL, + `Contact_number` varchar(10) NOT NULL, + `Email_id` varchar(50) NOT NULL, + `Address` varchar(50) NOT NULL, + `Quantity_Available` int NOT NULL, + `Price_per_piece` float NOT NULL, + `Discount` float NOT NULL, + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `dealer` +-- + +LOCK TABLES `dealer` WRITE; +/*!40000 ALTER TABLE `dealer` DISABLE KEYS */; +INSERT INTO `dealer` VALUES (1,'Ramesh','Brevrages','Pepsi','Pepsi','9876543210','ramesh@gmail.com','Saket,Delhi',45,15,6),(2,'Vikas','Groceries','Bread','Britania','8765432190','vikas23@ymail.com','MG Road,Pune',40,40.5,4),(3,'Suresh','Cosmetics','Shampoo','Sunsilk','6789012345','suresh47@yahoo.com','GanshiNagar,Gujarat',60,40,8),(4,'Amit','Biscuits','Parle-G','Parle-G','9087654321','amit003@gmail.com','Adarsh Nagar,Delhi',100,10,5),(5,'Himanshu','Edible Oil','Olive Oil','Figaro','8905673214','himanshu89@gmail.com','Sikri Road,Delhi',20,80,10),(6,'Gourav','Groceries','Flour','Ashirwad','7865904321','gourav34@yahoo.com','Suchetapuri,Mumbai',55,65,10),(7,'Shyam','Drinks','Bournvita','Catbury','8765009432','shyamlal@ymail.com','Krishna Nagar,Pune',30,35,7),(8,'Pankaj','Dairy','Milk','Jersy','6758493021','pankaj@gmail.com','Karvenagar,Pune',50,40,6),(9,'Piyush','Groceries','Maggi','Nestle','6574839012','piyush56@gmail.com','Malviya Nagar,Delhi',200,8,3),(10,'Prem','Soap','Handwash','Detol','9807563421','premprem@gmail.com','Green Park,Pune',90,20,8),(11,'Vipin','Diary','Cheese','Amul','7860945123','vipins0098@yahoo.com','Botanical Garden,Noida',50,15,6),(12,'Mukesh','Stationary','Pen','Cello','7689504332','mukesh67@ymail.com','Dilshad Garden,Delhi',60,10,5),(13,'Deepak','Brevrages','Orange Juice','Real','9876045213','deepak915@gmail.com','Govindpuram,Indore',9,15,10),(14,'Shubham','Groceries','Flour','Ashirwad','8905764123','shubham100@ymail.com','Indirapuram,Delhi',40,70,6),(15,'Vishesh','Brevrages','Orange Juice','Real','7869012345','visheshG@gmail.com','Rkpuram,Ghaziabad',14,17,9),(16,'Nishant','Groceries','Bread','Britania','8976503410','nishant@ymail.com','Kawade Road,Pune',35,37,8),(17,'Jagdish','Dairy','Milk','Jersy','9087564321','jagdish568@yahoo.com','Gautam Budh Nagar,Delhi',30,35,7),(18,'Yogendra','Stationary','Pen','Cello','6758940032','yogendra45@yahoo.com','Sarojini Nagar,Delhi',50,11,3),(19,'Manoj','Groceries','Bread','Britania','8900665544','manoj4@ymail.com','Hapur Road,Mumbai',12,36,9),(20,'Mohit','Brevrages','Orange Juice','Real','7896054100','mohit67@gmail.com','Dwarka,Delhi',12,16,10),(21,'Rahul','Stationary','Pen','Cello','7809563412','rahulrr@ymail.com','Rajiv Chowk,Delhi',55,12,4),(22,'Raman','Brevrages','Orange Juice','Real','8011223367','raman890@yahoo.com','Sanjay Nagar,Gujarat',10,18,5),(23,'Avinash','Groceries','Bread','Britania','8905643674','avi657@gmail.com','Near Friends Society,Pune',30,35,10),(24,'Aryan','Stationary','Pen','Cello','6700347712','aryan546@gmail.com','Sanjeevni Estate,Mumbai',40,10,4),(25,'Ankit','Dairy','Milk','Jersy','8907890345','ankit34@gmail.com','Vaishviya Nagar,Mumbai',55,37,5); +/*!40000 ALTER TABLE `dealer` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `empdata` +-- + +DROP TABLE IF EXISTS `empdata`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `empdata` ( + `ID` int NOT NULL, + `NAME` varchar(50) NOT NULL, + `CONTACT` varchar(10) NOT NULL, + `role` varchar(50) NOT NULL, + `SALARY` decimal(10,0) NOT NULL, + `ADDRESS` varchar(50) NOT NULL, + `EMAILID` varchar(50) NOT NULL, + PRIMARY KEY (`ID`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `empdata` +-- + +LOCK TABLES `empdata` WRITE; +/*!40000 ALTER TABLE `empdata` DISABLE KEYS */; +INSERT INTO `empdata` VALUES (1,'Himanshi Methwani','9874563210','Cashier',15000,'Begumpet,Hyderabad','himanshi@gmail.com'),(2,'Muskan Singhal','8475963210','Store Manager',25000,'Somajiguda,Hyderabad','muskan@gmail.com'),(3,'Gouri Ghurka','8796350142','Inventory Control Specialist',20000,'Begumpet,Hyderabad','gouri@gmail.com'),(4,'Ruchita Herlekar','6805124976','Cashier',15000,'Himayat Nagar,Hyderabad','ruchita@gmail.com'),(5,'Rakesh Sharma','8793652014','Sales Associate',10000,'M.G.Road,Hyderabad','rakesh@gmail.com'),(6,'Varun Reddy','8796301254','Sales Associate',10000,'Begumpet,Hyderabad','varun@gmail.com'),(7,'Sai Ramesh','6012223457','Cashier',15000,'Somajiguda,Hyderabad','ramesh@gmail.com'),(8,'Rashmi Jadav','7000123649','Sales Associate',10000,'Ameerpet,Hyderabad','rashmi@gmail.com'),(9,'Shri Harsha','8765410032','Inventory Control Specialist',20000,'Police Line,Hyderabad','harsha@gmail.com'),(10,'Lakshmi Patel','8002233664','Sales Associate',10000,'Ameerpet,Hyderabad','lakshmi@gmail.com'); +/*!40000 ALTER TABLE `empdata` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `products` +-- + +DROP TABLE IF EXISTS `products`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `products` ( + `productID` int NOT NULL AUTO_INCREMENT, + `productName` varchar(30) NOT NULL, + `productBrand` varchar(30) NOT NULL, + `productCategory` varchar(30) NOT NULL, + `productCostPrice` double(7,2) NOT NULL, + `productMrp` double(7,2) NOT NULL, + `productQuantity` int NOT NULL, + PRIMARY KEY (`productID`) +) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `products` +-- + +LOCK TABLES `products` WRITE; +/*!40000 ALTER TABLE `products` DISABLE KEYS */; +INSERT INTO `products` VALUES (1,'shampoo','sunsilk','cosmetics',40.00,50.00,31),(2,'bread','britania','groceries',35.00,40.00,9),(3,'parle-g','parle-g','biscuits',10.00,15.00,52),(4,'olive oil','figaro','edible oil',80.00,100.00,47),(5,'flour','ashirwad','groceries',65.00,72.00,28),(6,'bournvita','catbury','drinks',35.00,40.00,20),(7,'milk','jersy','dairy',35.00,40.00,15),(8,'maggi','nestle','groceries',8.00,10.00,100),(9,'pepsi','pepsi','brevrages',15.00,20.00,40),(10,'handwash','detol','soap',20.00,25.00,90),(11,'cheese','amul','diary',15.00,20.00,45),(13,'pen','cello','stationary',10.00,20.00,4),(14,'Orange juice','real','brevrages',15.00,20.00,12); +/*!40000 ALTER TABLE `products` ENABLE KEYS */; +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2021-05-31 19:18:54