Documente Academic
Documente Profesional
Documente Cultură
The user can feed the symptoms through the form in the
window page. The system using mainly five type of activity like master
form, purchase form, sale form, purchase report, sale report.
Software Requirement
Hardware Requirement
Ram :- 128 KB
PURCHASING PRODUCT
SALLING PRODUCT
Table 1:-
Table 2:-
Table 3:-
Limitations
This project has all the primary modules which are needed by any
STORE management. This project can be used by any STORE but it has
some limitations such as if STORE usages bar-codes for books and
members, there is no such facility is available to generate bar-codes for
new books and members. This project is also unable to accept bar-codes
and scanning device for scanning the bar-coeds.
Instead of problem discussed above this project is very useful for the
STORE management. And this project can be accepted and run
successfully.
Future scope
This project completely automate the above given stock through the
use of computers instead of old manual system and thus increase the
efficiency of any store management.
ANALYSIS OF THE PROBLEM
AND
DEVELOPMENT OF THE SOLUTION
Computers are extremely versatile and finding their way into every
business, industry and research activity today. Computers have
dynamically changed the way of solving the problems.
An effort was made to build the software but due to lack of time and
experience, some mistakes may creep in.
Feasibility Study
1 Technical Feasibility
2 Operational Feasibility
3 Economical Feasibility
4 Legal Feasibility
5 Technical Feasibility:
Technical feasibility includes risk, resource availability and technologies.
Technical feasibility is the most difficult area to assess at the earlier stage of
system development process. Therefore the process of analysis and
definition of the proposed system was conducted in parallel with the
assessment of technical feasibility. Since the misjudgment at this stage will
be disastrous a cynical attitude was maintained throughout the evaluation
of technical feasibility. The management provides latest hardware and
software facilities for the successful completion of the projects. With these
latest hardware and software support the system will perform extremely
well.
Operational Feasibility:
The development of the system was started because of the requirements
put forward by the management of the concerned end user. This system,
handles the large amount of data in a better way. So, it is sure that the
system developed is operationally feasible.
Economic Feasibility:
It is normal for every organization to choose a system development only if
there is a gain with respect to time and cost overhead. In the economic
feasibility the development cost of the system is evaluated weighing it
against the ultimate benefit derived from the new system. It is found that
the benefit occurred from the new system is more than that cost and time
involved in its development.
Legal Feasibility:
In this feasibility it is checked that whether the system could be
implemented or not within the stipulated time.
FEATURES OF JAVA:
JAVA IS OBJECT-ORIENTED:
In object-oriented programming (OOP), data is treated as objects to which
methods are applied. Java's basic execution unit is the class.
JAVA IS DISTRIBUTED:
Commonly used Internet protocols such as HTTP and FTP as well as calls
for network access are built into Java. Internet programmers can call on the
functions through the supplied libraries and be able to access files on the
Internet as easily as writing to a local file system.
JAVA IS INTERPRETED:
When Java code is compiled, the compiler outputs the Java Byte code
which is an executable for the Java Virtual Machine. The byte code is then
run through a Java interpreter on any given platform that has the
interpreter ported to it. The interpreter converts the code to the target
hardware and executes it.
JAVA IS SECURE:
Java goes to great lengths to address these security issues by putting in
place a very rigorous multilevel system of security:
First and foremost, at compile time, pointers and memory allocation are
removed thereby eliminating the tools that a system breaker could use to
gain access to system resources. Memory allocation is deferred until
runtime.
Even though the Java compiler produces only correct Java code, there is
still the possibility of the code being tampered with between compilation
and runtime. Java guards against this by using the byte code verifier to
check the byte code for language compliance when the code first enters the
interpreter, before it ever even gets the chance to run.
At runtime, the Java interpreter further ensures that classes loaded do not
access the file system except in the manner permitted by the client or the
user.
JAVA IS PORTABLE:
By porting an interpreter for the Java Virtual Machine to any computer
hardware/operating system, one is assured that all code compiled for it will
run on that system. This forms the basis for Java's portability.
JAVA IS DYNAMIC:
By connecting to the Internet, a user immediately has access to thousands
of programs and other computers. During the execution of a program, Java
can dynamically load classes that it requires either from the local hard
drive, from another computer on the local area network or from a
computer somewhere on the Internet.
FEATURES OF MS-ACCESS:
Microsoft Access is a computer application used to create and manage
computer-based databases on desktop computers and/or on connected
computers (a network). Microsoft Access can be used for personal
information management (PIM), in a small business to organize and
manage all data, or in an enterprise to communicate with servers.
SYSTEM ANALYSIS AND DESIGN
SYSTEM ANALYSIS:
During analysis, data are collected on the available files, decision points
and transactions handled by the present system. In this phase a detailed
evaluation of present system is done.
SYSTEM DESIGN:
Testing is done not only from the technical point of view but also from the
usability side. In addition, it is done to ascertain that the presentation is
readable in multiple browsers.
LEVEL OF TESTING:
The basic levels are unit testing, integration testing and acceptance testing.
These different levels of testing attempt to detect different types of faults.
· Unit testing: the level of the testing is called unit testing. In this
different modules are tested against the specifications produced during the
design modules. Unit testing is essentially for the verification of the code.
· Integration testing: the next level of the testing is the integration
testing. In this, many tested modules are combined into sub-systems that
are then tested. The goal here is to see if the modules can be integrated
properly.
· System Testing and Acceptance Testing: here the entire software
system is tested. The reference document for this process is the
requirement document, and is to see if the software meets its requirement.
SYSTEM IMPLEMENTATION
A crucial phase in system development is the successful implementation of
the new system design. Implementation means converting a new system
design into operation. This involves creation of computer-compatible files,
installing hardware, terminals etc before the system is running. This phase
is less creative than system design.
if((ss.equalsIgnoreCase("DEEPAK"))&&(login.equalsIgnoreCase("DEEPAK")))
{
MenuApp aa = new MenuApp();
aa.setSize(780,570);
aa.setVisible(true);
hide();
}
}
else if(o==b2)
{
int x = JOptionPane.showConfirmDialog(Welc.this,"A r e y o u s u r e y
o u w a n t t o E x i t ! "," C o n f i r m a t i o
n",JOptionPane.WARNING_MESSAGE,JOptionPane.YES_NO_OPTION);
if(x==0)
{
hide() ;
System.exit(0);
}
}
}
public void paint(Graphics g)// = getGraphics();
{
g.drawImage(im,180,110,500,100,this);
}
t1.setForeground(Color.magenta);
t2.setForeground(Color.magenta);
t1.addFocusListener(new FocusAdapter()
{
public void focusLost(FocusEvent e)
{
String ss = t1.getText();
checkRec(ss);
}
});
t3.setForeground(Color.magenta);
t4.setForeground(Color.magenta);
t5.setForeground(Color.magenta);
t6.setForeground(Color.magenta);
t7.setForeground(Color.magenta);
b1.addActionListener(new ButtonHandler());
b2.addActionListener(new ButtonHandler());
b3.addActionListener(new ButtonHandler());
t5.addFocusListener(new FocusAdapter()
{
public void focusLost(FocusEvent e)
{
double x = Double.valueOf(t3.getText()).doubleValue();
double y = Double.valueOf(t5.getText()).doubleValue();
t6.setText(""+(x*y));
}
});
f=getContentPane();
f.setBackground(new Color(255,215,255));
f.setLayout(null);
l1.setBounds(60,50,160,30);
l2.setBounds(60,100,160,30);
l3.setBounds(60,150,160,30);
l4.setBounds(60,200,160,30);
l5.setBounds(60,250,160,30);
l6.setBounds(60,300,160,30);
l7.setBounds(60,350,160,30);
t1.setBounds(210,50,70,30);
t2.setBounds(210,100,200,30);
t3.setBounds(210,150,100,30);
t4.setBounds(210,200,140,30);
t5.setBounds(210,250,90,30);
t6.setBounds(210,300,100,30);
t7.setBounds(210,350,180,30);
b1.setBounds(50,420,120,30);
b2.setBounds(190,420,105,30);
b3.setBounds(310,420,100,30);
f.add(l1);
f.add(l2);
f.add(l3);
f.add(l4);
f.add(l5);
f.add(l6);
f.add(l7);
f.add(t1);
t1.setToolTipText("Enter Product Code");
f.add(t2);
t2.setToolTipText("Enter Product Name");
f.add(t3);
t3.setToolTipText("Enter Quantity ");
f.add(t4);
t4.setToolTipText("Enter Proc Date(dd/mm/yyyy)");
f.add(t5);
t5.setToolTipText("Enter Unit Price ");
f.add(t6);
t6.setEditable(false);
f.add(t7);
t7.setEditable(true);
t7.setToolTipText("Enter source ");
f.add(b1);
b1.setToolTipText("Click here to submit data");
f.add(b2);
b3.setToolTipText("Click here to cancel data");
f.add(b3);
b3.setToolTipText("Click here to unload the current form");
pack();
addWindowListener(new WindowEventHandler());
}
void accessDB()
{
try
{
String driver,url;
driver="sun.jdbc.odbc.JdbcOdbcDriver";
url="jdbc:odbc:lib";
Class.forName(driver);
Connection connection=DriverManager.getConnection(url);
Statement s,s1,s2,s3;
s= connection.createStatement();
String sql;
sql = "INSERT INTO purchase VALUES ("+t1.getText()+",'"+t2.getText()
+"'";
sql+=","+t3.getText()+",'"+t4.getText();
sql+="',"+t5.getText()+","+t6.getText();
sql+=",'"+t7.getText()+"')";
boolean hasResults = s.execute(sql);
s1= connection.createStatement();
s2= connection.createStatement();
s3= connection.createStatement();
boolean ss = s1.execute("select * from master where itemcode =
"+t1.getText());
if(ss==true)
{
int i= s2.executeUpdate("update master set
stockinhand=stockinhand+"+t3.getText()+",purchasedate='"+t4.getText()
+"',price="+t5.getText()+" where itemcode = "+t1.getText());
if(i==0)
{
s3.execute("INSERT INTO master VALUES("+t1.getText()
+",'"+t2.getText()+"','"+t4.getText()+"','"+t3.getText()+"',"+t5.getText()+")");
}
}
connection.close();
}
catch(Exception ex)
{
System.out.println("sanaman"+ex);
}
}
boolean checkRec(String xx)
{
int x1=0;
try
{
String driver,url;
driver="sun.jdbc.odbc.JdbcOdbcDriver";
url="jdbc:odbc:lib";
Class.forName(driver);
Connection c1=DriverManager.getConnection(url);
Statement s3;
s3 = c1.createStatement();
s3.execute("select * from master where itemcode="+xx);
ResultSet rs1 = s3.getResultSet();
if(rs1!=null)
{
while(rs1.next())
{
if(xx.equals(rs1.getString(1)))
{
x1=1;
t2.setText(rs1.getString(2));
}
}
}
}
catch(Exception e){System.out.println("--> "+e);}
if(x1==1)
return(true);
else
return(false);
}
}
}
if(s=="Exit")
{
int x = JOptionPane.showConfirmDialog(Purc.this,"A r e y o u s u r e y
o u w a n t t o E x i t ! "," C o n f i r m a t i o
n",JOptionPane.WARNING_MESSAGE,JOptionPane.YES_NO_OPTION);
if(x==0)
hide() ;
}
if(s=="Cancel")
{
t1.setText(" ");
t2.setText(" ");
t3.setText(" ");
t4.setText(" ");
t5.setText(" ");
t6.setText(" ");
t7.setText(" ");
}
}
}
class WindowEventHandler extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
hide();
}
}
}
Sales form
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class Sale extends JFrame
{
int index;
Container f;
int i,x;
String driver,url;
Connection c;
Statement s,s1;
String rr1[],rr2[],rr3[],rr4[],rr5[],rr6[],rr7[],rr8[];
boolean flag = false;
boolean flag1 = false;
String data[];
JList t1;
Font fo = new Font("Courier New",1,17);
bb1.setFont(fo);
bb2.setFont(fo);
bb3.setFont(fo);
bb4.setFont(fo);
b1.setFont(fo);
b2.setFont(fo);
b3.setFont(fo);
t2.setFont(fo);
t3.setFont(fo);
t4.setFont(fo);
t5.setFont(fo);
t6.setFont(fo);
t7.setFont(fo);
t8.setFont(fo);
b1.setBackground(new Color(215,254,171));
b2.setBackground(new Color(215,254,171));
b3.setBackground(new Color(215,254,171));
b1.setForeground(Color.black);
b2.setForeground(Color.black);
b3.setForeground(Color.black);
t1 = new JList(data);
t1.setFont(fo);
t1.setForeground(new Color(0,48,96));
t2.setForeground(new Color(0,48,96));
t3.setForeground(new Color(0,48,96));
t4.setForeground(new Color(0,48,96));
t5.setForeground(new Color(0,48,96));
t6.setForeground(new Color(0,48,96));
t7.setForeground(new Color(0,48,96));
t8.setForeground(new Color(0,48,96));
bb1.setBackground(new Color(215,254,171));
bb2.setBackground(new Color(215,254,171));
bb3.setBackground(new Color(215,254,171));
bb4.setBackground(new Color(215,254,171));
b1.addActionListener(new ButtonHandler());
b2.addActionListener(new ButtonHandler());
b3.addActionListener(new ButtonHandler());
bb1.addActionListener(new ButtonHandler());
bb2.addActionListener(new ButtonHandler());
bb3.addActionListener(new ButtonHandler());
bb4.addActionListener(new ButtonHandler());
checkRec3();
t1=new JList(data);
t1.addFocusListener(new FocusAdapter()
{
public void focusLost(FocusEvent e)
{
String ss=(String)t1.getSelectedValue();
checkRec4(ss);
rec();
}
});
t2.addFocusListener(new FocusAdapter()
{/*for quantity sold*/
public void focusLost(FocusEvent e1)
{
int cc=0;
String y1 = t2.getText();
for(int i=0;i<y1.length();i++)
{
int c = (int)y1.charAt(i);
if(c<48 || c>=57)
cc=1;
}
if(cc==1)
{
JOptionPane.showMessageDialog(Sale.this,"Please Enter Only 0 to 9
Number ....","Data Validation",JOptionPane.WARNING_MESSAGE);
}
else
{
String ss=(String)t1.getSelectedValue();
checkRec2(ss);
// System.out.println(ss);
}
}
});
JScrollPane sc=new JScrollPane(t1);
f=getContentPane();
f.setLayout(null);
f.setBackground(new Color(217,236,255));
l1.setBounds(100,50,160,30);
l2.setBounds(100,100,160,30);
l3.setBounds(100,150,160,30);
l4.setBounds(100,200,160,30);
l5.setBounds(100,250,160,30);
l6.setBounds(100,300,160,30);
l7.setBounds(100,350,160,30);
l8.setBounds(100,400,160,30);
sc.setBounds(235,50,80,25);
t8.setBounds(235,100,200,30);
t2.setBounds(235,150,100,30);
t3.setBounds(235,200,140,30);
t4.setBounds(235,250,200,30);
t5.setBounds(235,300,100,30);
t6.setBounds(235,350,100,30);
t7.setBounds(235,400,120,30);
b1.setBounds(50,460,100,30);
b2.setBounds(170,460,100,30);
b3.setBounds(290,460,100,30);
bb1.setBounds(530,120,120,35);
bb2.setBounds(530,190,120,35);
bb3.setBounds(530,260,120,35);
bb4.setBounds(530,330,120,35);
f.add(l1);
f.add(l2);
f.add(l3);
f.add(l4);
f.add(l5);
f.add(l6);
f.add(l7);
f.add(l8);
f.add(sc);
t1.setToolTipText("Product Code");
f.add(t2);
t2.setToolTipText("Enter Product sold");
f.add(t3);
t3.setToolTipText("Enter Date");
f.add(t4);
t4.setToolTipText("Enter Customer name");
f.add(t5);
t5.setToolTipText("Bill no");
t5.setEditable(false);
f.add(t6);
t6.setToolTipText("Unit price");
f.add(t7);
t7.setToolTipText("Total price");
f.add(t8);
t8.setEditable(false);
t8.setToolTipText("Product Name");
f.add(b1);
b1.setToolTipText("Click here to submit data");
f.add(b2);
b3.setToolTipText("Click here to cancel data");
f.add(b3);
b3.setToolTipText("Click here to unload the current form");
f.add(bb1);
bb1.setToolTipText("Click here to view the First Record");
f.add(bb2);
bb2.setToolTipText("Click here to view the Last Record");
f.add(bb3);
bb3.setToolTipText("Click here to view the Prev Record");
f.add(bb4);
bb4.setToolTipText("Click here to view the Next Record");
pack();
addWindowListener(new WindowEventHandler());
setSize(800,600);
show();
rec();
t5.setText(""+index);
}
void accessDB()/*to insert data into DB*/
{
try
{
String driver,url;
driver="sun.jdbc.odbc.JdbcOdbcDriver";
url="jdbc:odbc:lib";
Class.forName(driver);
c=DriverManager.getConnection(url);
s=c.createStatement();
String sql;
sql = "INSERT INTO sale VALUES ("+(String)t1.getSelectedValue()
+",'"+t8.getText()+"',"+t2.getText()+","+"'"+t3.getText()+"','"+t4.getText()
+"',"+t5.getText()+","+t6.getText()+","+t7.getText()+")";
boolean hasResults = s.execute(sql);
int i= s.executeUpdate("update master set
stockinhand=stockinhand-"+t2.getText()+" where itemcode = "+
(String)t1.getSelectedValue());
c.close();
}
catch(Exception ex)
{
}
}
Class.forName(driver);
c=DriverManager.getConnection(url);
s1 = c.createStatement();
s1.execute("select Itemname from master where itemcode="+xx);
ResultSet rs = s1.getResultSet();
if(rs!=null)
{
while(rs.next())
{
t8.setText(rs.getString(1));
}
}
}
catch(Exception e){System.out.println("--> "+e);}
}/*for putting limitations on sold quantity*/
boolean checkRec1(String xx)
{
int x=0;
try
{
Class.forName(driver);
c=DriverManager.getConnection(url);
s1 = c.createStatement();
s1.execute("select stockinhand from master where itemcode="+xx);
ResultSet rs = s1.getResultSet();
if(rs!=null)
{
while(rs.next())
{
int sc=Integer.parseInt(rs.getString(1));
if(sc<=10)
{
x=1;
}
if(sc<=Integer.parseInt(t2.getText()))
flag1=true;
else
flag1=false;
}
}
}
catch(Exception e){System.out.println("--> "+e);}
if(x==1)
return(true);
else
return(false);
}/*to put records in array & getting the bill no.*/
boolean rec()
{
i=0;
x=0;
index=1;
try
{
driver="sun.jdbc.odbc.JdbcOdbcDriver";
url="jdbc:odbc:lib";
Class.forName(driver);
c=DriverManager.getConnection(url);
s = c.createStatement();
s.execute("select * from sale ORDER BY bill_No");
ResultSet rs = s.getResultSet();
rr1 = new String[300];
rr2 = new String[300];
rr3 = new String[300];
rr4 = new String[300];
rr5 = new String[300];
rr6 = new String[300];
rr7 = new String[300];
rr8 = new String[300];
while(rs.next())
{
index++;
rr1[i]=rs.getString(1);
rr2[i]=rs.getString(2);
rr3[i]=rs.getString(3);
// for Date Column
String ss = rs.getString(4);
char arr[]=new char[10];
arr[0]=ss.charAt(8);
arr[1]=ss.charAt(9);
arr[2]='/';
arr[3]=ss.charAt(5);
arr[4]=ss.charAt(6);
arr[5]='/';
arr[6]=ss.charAt(0);
arr[7]=ss.charAt(1);
arr[8]=ss.charAt(2);
arr[9]=ss.charAt(3);
ss = new String(arr);
rr4[i]=ss;
rr5[i]=rs.getString(5);
rr6[i]=rs.getString(6);
rr7[i]=rs.getString(7);
rr8[i]=rs.getString(8);
x=i;
i++;
}
}
catch(Exception e){System.out.println(" --> "+e);}
t5.setText(""+index);
return(true);
}/*to show records in the textfields*/
void showRec(int a)
{
t1.setSelectedValue(rr1[a],true);
t2.setText(rr3[a]);
t3.setText(rr4[a]);
t4.setText(rr5[a]);
t5.setText(rr6[a]);
t6.setText(rr7[a]);
t7.setText(rr8[a]);
t8.setText(rr2[a]);
}
class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent ev)
{
String s=ev.getActionCommand();
if(s=="Submit")
{
String ss = (String)t1.getSelectedValue();
boolean fla1 = checkRec1(ss);
if(fla1)
{
MyDialog d = new MyDialog(Sale.this,"Data Validation","Cannot Sell as
Instock<10 units");
d.setVisible(false);
}
if(flag1)
{
MyDialog d = new MyDialog(Sale.this,"Data Validation","Cannot
Sell as Instock<Items to be Sold....");
d.setVisible(false);
}
else
{
accessDB();
rec();
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText(""+index);
t6.setText("");
t7.setText("");
t8.setText("");
}
}
if(s=="Exit")
{
int x = JOptionPane.showConfirmDialog(Sale.this,"A r e y o u s u r e y
o u w a n t t o E x i t ! "," C o n f i r m a t i o
n",JOptionPane.WARNING_MESSAGE,JOptionPane.YES_NO_OPTION);
if(x==0)
hide() ;
}
if(s=="Cancel")
{
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
t6.setText("");
t7.setText("");
t8.setText("");
}
if(s.equals("Next"))
{
x++;
if(x>=i)
{
x=i-1;
JOptionPane.showMessageDialog(Sale.this,"I t i s t h e L a s t R e c o r
d . . . ","Data Validation",JOptionPane.WARNING_MESSAGE);
}
showRec(x);
}
if(s.equals("Prev."))
{
x--;
if(x<=0)
{
x=0;
JOptionPane.showMessageDialog(Sale.this,"I t i s t h e F i r s t R e c o
r d . . . ","Data Validation",JOptionPane.WARNING_MESSAGE);
}
showRec(x);
}
if(s.equals("First"))
{
x=0;
showRec(x);
}
if(s.equals("Last"))
{
x=i-1;
showRec(x);
}
}
}
class WindowEventHandler extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(true);
}
}
}
Report form
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
public class Sale extends JFrame
{
int index;
Container f;
int i,x;
String driver,url;
Connection c;
Statement s,s1;
String rr1[],rr2[],rr3[],rr4[],rr5[],rr6[],rr7[],rr8[];
boolean flag = false;
boolean flag1 = false;
String data[];
JList t1;
Font fo = new Font("Courier New",1,17);
bb1.setFont(fo);
bb2.setFont(fo);
bb3.setFont(fo);
bb4.setFont(fo);
b1.setFont(fo);
b2.setFont(fo);
b3.setFont(fo);
t2.setFont(fo);
t3.setFont(fo);
t4.setFont(fo);
t5.setFont(fo);
t6.setFont(fo);
t7.setFont(fo);
t8.setFont(fo);
b1.setBackground(new Color(215,254,171));
b2.setBackground(new Color(215,254,171));
b3.setBackground(new Color(215,254,171));
b1.setForeground(Color.black);
b2.setForeground(Color.black);
b3.setForeground(Color.black);
t1 = new JList(data);
t1.setFont(fo);
t1.setForeground(new Color(0,48,96));
t2.setForeground(new Color(0,48,96));
t3.setForeground(new Color(0,48,96));
t4.setForeground(new Color(0,48,96));
t5.setForeground(new Color(0,48,96));
t6.setForeground(new Color(0,48,96));
t7.setForeground(new Color(0,48,96));
t8.setForeground(new Color(0,48,96));
bb1.setBackground(new Color(215,254,171));
bb2.setBackground(new Color(215,254,171));
bb3.setBackground(new Color(215,254,171));
bb4.setBackground(new Color(215,254,171));
b1.addActionListener(new ButtonHandler());
b2.addActionListener(new ButtonHandler());
b3.addActionListener(new ButtonHandler());
bb1.addActionListener(new ButtonHandler());
bb2.addActionListener(new ButtonHandler());
bb3.addActionListener(new ButtonHandler());
bb4.addActionListener(new ButtonHandler());
checkRec3();
t1=new JList(data);
t1.addFocusListener(new FocusAdapter()
{
public void focusLost(FocusEvent e)
{
String ss=(String)t1.getSelectedValue();
checkRec4(ss);
rec();
}
});
t2.addFocusListener(new FocusAdapter()
{/*for quantity sold*/
public void focusLost(FocusEvent e1)
{
int cc=0;
String y1 = t2.getText();
for(int i=0;i<y1.length();i++)
{
int c = (int)y1.charAt(i);
if(c<48 || c>=57)
cc=1;
}
if(cc==1)
{
JOptionPane.showMessageDialog(Sale.this,"Please Enter Only 0 to 9
Number ....","Data Validation",JOptionPane.WARNING_MESSAGE);
}
else
{
String ss=(String)t1.getSelectedValue();
checkRec2(ss);
// System.out.println(ss);
}
}
});
JScrollPane sc=new JScrollPane(t1);
f=getContentPane();
f.setLayout(null);
f.setBackground(new Color(217,236,255));
l1.setBounds(100,50,160,30);
l2.setBounds(100,100,160,30);
l3.setBounds(100,150,160,30);
l4.setBounds(100,200,160,30);
l5.setBounds(100,250,160,30);
l6.setBounds(100,300,160,30);
l7.setBounds(100,350,160,30);
l8.setBounds(100,400,160,30);
sc.setBounds(235,50,80,25);
t8.setBounds(235,100,200,30);
t2.setBounds(235,150,100,30);
t3.setBounds(235,200,140,30);
t4.setBounds(235,250,200,30);
t5.setBounds(235,300,100,30);
t6.setBounds(235,350,100,30);
t7.setBounds(235,400,120,30);
b1.setBounds(50,460,100,30);
b2.setBounds(170,460,100,30);
b3.setBounds(290,460,100,30);
bb1.setBounds(530,120,120,35);
bb2.setBounds(530,190,120,35);
bb3.setBounds(530,260,120,35);
bb4.setBounds(530,330,120,35);
f.add(l1);
f.add(l2);
f.add(l3);
f.add(l4);
f.add(l5);
f.add(l6);
f.add(l7);
f.add(l8);
f.add(sc);
t1.setToolTipText("Product Code");
f.add(t2);
t2.setToolTipText("Enter Product sold");
f.add(t3);
t3.setToolTipText("Enter Date");
f.add(t4);
t4.setToolTipText("Enter Customer name");
f.add(t5);
t5.setToolTipText("Bill no");
t5.setEditable(false);
f.add(t6);
t6.setToolTipText("Unit price");
f.add(t7);
t7.setToolTipText("Total price");
f.add(t8);
t8.setEditable(false);
t8.setToolTipText("Product Name");
f.add(b1);
b1.setToolTipText("Click here to submit data");
f.add(b2);
b3.setToolTipText("Click here to cancel data");
f.add(b3);
b3.setToolTipText("Click here to unload the current form");
f.add(bb1);
bb1.setToolTipText("Click here to view the First Record");
f.add(bb2);
bb2.setToolTipText("Click here to view the Last Record");
f.add(bb3);
bb3.setToolTipText("Click here to view the Prev Record");
f.add(bb4);
bb4.setToolTipText("Click here to view the Next Record");
pack();
addWindowListener(new WindowEventHandler());
setSize(800,600);
show();
rec();
t5.setText(""+index);
}
void accessDB()/*to insert data into DB*/
{
try
{
String driver,url;
driver="sun.jdbc.odbc.JdbcOdbcDriver";
url="jdbc:odbc:lib";
Class.forName(driver);
c=DriverManager.getConnection(url);
s=c.createStatement();
String sql;
sql = "INSERT INTO sale VALUES ("+(String)t1.getSelectedValue()
+",'"+t8.getText()+"',"+t2.getText()+","+"'"+t3.getText()+"','"+t4.getText()
+"',"+t5.getText()+","+t6.getText()+","+t7.getText()+")";
boolean hasResults = s.execute(sql);
int i= s.executeUpdate("update master set
stockinhand=stockinhand-"+t2.getText()+" where itemcode = "+
(String)t1.getSelectedValue());
c.close();
}
catch(Exception ex)
{
}
}
Class.forName(driver);
c=DriverManager.getConnection(url);
s1 = c.createStatement();
s1.execute("select Itemname from master where itemcode="+xx);
ResultSet rs = s1.getResultSet();
if(rs!=null)
{
while(rs.next())
{
t8.setText(rs.getString(1));
}
}
}
catch(Exception e){System.out.println("--> "+e);}
}/*for putting limitations on sold quantity*/
boolean checkRec1(String xx)
{
int x=0;
try
{
Class.forName(driver);
c=DriverManager.getConnection(url);
s1 = c.createStatement();
s1.execute("select stockinhand from master where itemcode="+xx);
ResultSet rs = s1.getResultSet();
if(rs!=null)
{
while(rs.next())
{
int sc=Integer.parseInt(rs.getString(1));
if(sc<=10)
{
x=1;
}
if(sc<=Integer.parseInt(t2.getText()))
flag1=true;
else
flag1=false;
}
}
}
catch(Exception e){System.out.println("--> "+e);}
if(x==1)
return(true);
else
return(false);
}/*to put records in array & getting the bill no.*/
boolean rec()
{
i=0;
x=0;
index=1;
try
{
driver="sun.jdbc.odbc.JdbcOdbcDriver";
url="jdbc:odbc:lib";
Class.forName(driver);
c=DriverManager.getConnection(url);
s = c.createStatement();
s.execute("select * from sale ORDER BY bill_No");
ResultSet rs = s.getResultSet();
rr1 = new String[300];
rr2 = new String[300];
rr3 = new String[300];
rr4 = new String[300];
rr5 = new String[300];
rr6 = new String[300];
rr7 = new String[300];
rr8 = new String[300];
while(rs.next())
{
index++;
rr1[i]=rs.getString(1);
rr2[i]=rs.getString(2);
rr3[i]=rs.getString(3);
// for Date Column
String ss = rs.getString(4);
char arr[]=new char[10];
arr[0]=ss.charAt(8);
arr[1]=ss.charAt(9);
arr[2]='/';
arr[3]=ss.charAt(5);
arr[4]=ss.charAt(6);
arr[5]='/';
arr[6]=ss.charAt(0);
arr[7]=ss.charAt(1);
arr[8]=ss.charAt(2);
arr[9]=ss.charAt(3);
ss = new String(arr);
rr4[i]=ss;
rr5[i]=rs.getString(5);
rr6[i]=rs.getString(6);
rr7[i]=rs.getString(7);
rr8[i]=rs.getString(8);
x=i;
i++;
}
}
catch(Exception e){System.out.println(" --> "+e);}
t5.setText(""+index);
return(true);
}/*to show records in the textfields*/
void showRec(int a)
{
t1.setSelectedValue(rr1[a],true);
t2.setText(rr3[a]);
t3.setText(rr4[a]);
t4.setText(rr5[a]);
t5.setText(rr6[a]);
t6.setText(rr7[a]);
t7.setText(rr8[a]);
t8.setText(rr2[a]);
}
class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent ev)
{
String s=ev.getActionCommand();
if(s=="Submit")
{
String ss = (String)t1.getSelectedValue();
boolean fla1 = checkRec1(ss);
if(fla1)
{
MyDialog d = new MyDialog(Sale.this,"Data Validation","Cannot Sell as
Instock<10 units");
d.setVisible(false);
}
if(flag1)
{
MyDialog d = new MyDialog(Sale.this,"Data Validation","Cannot
Sell as Instock<Items to be Sold....");
d.setVisible(false);
}
else
{
accessDB();
rec();
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText(""+index);
t6.setText("");
t7.setText("");
t8.setText("");
}
}
if(s=="Exit")
{
int x = JOptionPane.showConfirmDialog(Sale.this,"A r e y o u s u r e y
o u w a n t t o E x i t ! "," C o n f i r m a t i o
n",JOptionPane.WARNING_MESSAGE,JOptionPane.YES_NO_OPTION);
if(x==0)
hide() ;
}
if(s=="Cancel")
{
t2.setText("");
t3.setText("");
t4.setText("");
t5.setText("");
t6.setText("");
t7.setText("");
t8.setText("");
}
if(s.equals("Next"))
{
x++;
if(x>=i)
{
x=i-1;
JOptionPane.showMessageDialog(Sale.this,"I t i s t h e L a s t R e c o r
d . . . ","Data Validation",JOptionPane.WARNING_MESSAGE);
}
showRec(x);
}
if(s.equals("Prev."))
{
x--;
if(x<=0)
{
x=0;
JOptionPane.showMessageDialog(Sale.this,"I t i s t h e F i r s t R e c o
r d . . . ","Data Validation",JOptionPane.WARNING_MESSAGE);
}
showRec(x);
}
if(s.equals("First"))
{
x=0;
showRec(x);
}
if(s.equals("Last"))
{
x=i-1;
showRec(x);
}
}
}
class WindowEventHandler extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
setVisible(true);
}
}
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import java.util.*;
public class PRepo2 extends Frame implements ActionListener
{
MenuBar mb;
Menu m1;
MenuItem i1,i2;
ScrollPane s;
TextPanel7 t1;
Toolkit tool;
PrintJob pj;
public PRepo2()
{
super("Report Sorted by Purchase date.");
mb = new MenuBar();
m1 = new Menu("File");
i1 = new MenuItem("Exit");
i2 = new MenuItem("Print");
m1.add(i2);
m1.add(i1);
mb.add(m1);
tool=getToolkit();
setMenuBar(mb);
i1.addActionListener(this);
i2.addActionListener(this);
s = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
t1 = new TextPanel7();
s.add(t1);
add(s);
setSize(780,580);
setVisible(true);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
}
});
}
public void actionPerformed(ActionEvent e)
{
Object o = e.getSource();
if(o==i1)
setVisible(false);
if(o==i2)
{
Properties prop = new Properties();
pj = tool.getPrintJob(PRepo2.this,"Hello",prop);
if(pj!=null)
{
t1.printAll(pj.getGraphics());
pj.end();
}
}
repaint();
}
public static void main(String aa[])
{
PRepo2 p = new PRepo2();
}
}
class TextPanel7 extends Canvas
{
public Dimension getPreferredSize()
{
return new Dimension(1000, 1000);
}
public void paint(Graphics g)
{
int x=80,y=80;
try
{
String driver,url;
driver="sun.jdbc.odbc.JdbcOdbcDriver";
url="jdbc:odbc:lib";
Class.forName(driver);
Connection c=DriverManager.getConnection(url);
Statement s = c.createStatement();
s.execute("select
hiredate,itemcode,itemname,quantity,unit_price,total_price,source from purchase
order by hiredate");
ResultSet r=s.getResultSet();
ResultSetMetaData rmeta = r.getMetaData();
int numColumns=rmeta.getColumnCount();
g.setFont(new Font("Times new Roman",1,34));
g.setColor(Color.red);
g.drawString("Procurement Status Report by Procurement Date .",30,30);
g.drawLine(30,40,760,40);
g.setFont(new Font("Times new Roman",1,14));
// setBackground(Color.pink);
g.setColor(Color.red);
g.drawString("S.No.",20,80);
for(int i=1;i<=numColumns;++i)
{
String cap=rmeta.getColumnName(i);
g.drawString(cap,x,y);
if(i==1)
x+=80;
else
x+=100;
}
int xx=1;
g.setColor(Color.black);
while(r.next())
{
x=90;
y+=22;
g.drawString(xx+" . ",25,y);
xx++;
for(int i=1;i<=numColumns;++i)
{
String ss=r.getString(i);
if(i==1)
{
char a[]=new char[10];
a[0]=ss.charAt(8);
a[1]=ss.charAt(9);
a[2]=ss.charAt(7);
a[3]=ss.charAt(5);
a[4]=ss.charAt(6);
a[5]=ss.charAt(4);
a[6]=ss.charAt(0);
a[7]=ss.charAt(1);
a[8]=ss.charAt(2);
a[9]=ss.charAt(3);
ss = new String(a);
}
// System.out.print(ss);
if(i==1)
x=65;
g.drawString(ss,x,y);
if(i==1)x+=100;
else if(i==2)x+=70;
else if(i==3)x+=140;
else if(i==4)x+=105;
else if(i==6)x+=75;
else if(i==7)x+=70;
else x+=110;
}
//System.out.println();
}
}
catch(Exception e){System.out.println("--> "+e);}
}
}
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import java.util.*;
public class PRepo2 extends Frame implements ActionListener
{
MenuBar mb;
Menu m1;
MenuItem i1,i2;
ScrollPane s;
TextPanel7 t1;
Toolkit tool;
PrintJob pj;
public PRepo2()
{
super("Report Sorted by Purchase date.");
mb = new MenuBar();
m1 = new Menu("File");
i1 = new MenuItem("Exit");
i2 = new MenuItem("Print");
m1.add(i2);
m1.add(i1);
mb.add(m1);
tool=getToolkit();
setMenuBar(mb);
i1.addActionListener(this);
i2.addActionListener(this);
s = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
t1 = new TextPanel7();
s.add(t1);
add(s);
setSize(780,580);
setVisible(true);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
}
});
}
public void actionPerformed(ActionEvent e)
{
Object o = e.getSource();
if(o==i1)
setVisible(false);
if(o==i2)
{
Properties prop = new Properties();
pj = tool.getPrintJob(PRepo2.this,"Hello",prop);
if(pj!=null)
{
t1.printAll(pj.getGraphics());
pj.end();
}
}
repaint();
}
public static void main(String aa[])
{
PRepo2 p = new PRepo2();
}
}
class TextPanel7 extends Canvas
{
public Dimension getPreferredSize()
{
return new Dimension(1000, 1000);
}
public void paint(Graphics g)
{
int x=80,y=80;
try
{
String driver,url;
driver="sun.jdbc.odbc.JdbcOdbcDriver";
url="jdbc:odbc:lib";
Class.forName(driver);
Connection c=DriverManager.getConnection(url);
Statement s = c.createStatement();
s.execute("select
hiredate,itemcode,itemname,quantity,unit_price,total_price,source from purchase
order by hiredate");
ResultSet r=s.getResultSet();
ResultSetMetaData rmeta = r.getMetaData();
int numColumns=rmeta.getColumnCount();
g.setFont(new Font("Times new Roman",1,34));
g.setColor(Color.red);
g.drawString("Procurement Status Report by Procurement Date .",30,30);
g.drawLine(30,40,760,40);
g.setFont(new Font("Times new Roman",1,14));
// setBackground(Color.pink);
g.setColor(Color.red);
g.drawString("S.No.",20,80);
for(int i=1;i<=numColumns;++i)
{
String cap=rmeta.getColumnName(i);
g.drawString(cap,x,y);
if(i==1)
x+=80;
else
x+=100;
}
int xx=1;
g.setColor(Color.black);
while(r.next())
{
x=90;
y+=22;
g.drawString(xx+" . ",25,y);
xx++;
for(int i=1;i<=numColumns;++i)
{
String ss=r.getString(i);
if(i==1)
{
char a[]=new char[10];
a[0]=ss.charAt(8);
a[1]=ss.charAt(9);
a[2]=ss.charAt(7);
a[3]=ss.charAt(5);
a[4]=ss.charAt(6);
a[5]=ss.charAt(4);
a[6]=ss.charAt(0);
a[7]=ss.charAt(1);
a[8]=ss.charAt(2);
a[9]=ss.charAt(3);
ss = new String(a);
}
// System.out.print(ss);
if(i==1)
x=65;
g.drawString(ss,x,y);
if(i==1)x+=100;
else if(i==2)x+=70;
else if(i==3)x+=140;
else if(i==4)x+=105;
else if(i==6)x+=75;
else if(i==7)x+=70;
else x+=110;
}
//System.out.println();
}
}
catch(Exception e){System.out.println("--> "+e);}
}
}
Report sorted by item description
import java.awt.*;
import java.sql.*;
import java.awt.event.*;
import java.util.*;
public class PRepo4 extends Frame implements ActionListener
{
MenuBar mb;
Menu m1;
MenuItem i1,i2;
ScrollPane s;
TextPanel9 t1;
Toolkit tool;
PrintJob pj;
public PRepo4()
{
super("Report Sorted by Item Desc.");
mb = new MenuBar();
m1 = new Menu("File");
i1 = new MenuItem("Exit");
i2 = new MenuItem("Print");
m1.add(i2);
m1.add(i1);
mb.add(m1);
tool=getToolkit();
setMenuBar(mb);
i1.addActionListener(this);
i2.addActionListener(this);
s = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
t1 = new TextPanel9();
s.add(t1);
add(s);
setSize(780,580);
setVisible(true);
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
setVisible(false);
}
});
}
public void actionPerformed(ActionEvent e)
{
Object o = e.getSource();
if(o==i1)
setVisible(false);
if(o==i2)
{
Properties prop = new Properties();
pj = tool.getPrintJob(PRepo4.this,"Hello",prop);
if(pj!=null)
{
t1.printAll(pj.getGraphics());
pj.end();
}
}
repaint();
}
public static void main(String aa[])
{
PRepo4 p = new PRepo4();
}
}
class TextPanel9 extends Canvas
{
public Dimension getPreferredSize()
{
return new Dimension(1000, 1000);
}
public void paint(Graphics g)
{
int x=80,y=80;
try
{
String driver,url;
driver="sun.jdbc.odbc.JdbcOdbcDriver";
url="jdbc:odbc:lib";
Class.forName(driver);
Connection c=DriverManager.getConnection(url);
Statement s = c.createStatement();
s.execute("select
itemname,itemcode,source,quantity,unit_price,total_price,hiredate from purchase
order by itemname");
ResultSet r=s.getResultSet();
ResultSetMetaData rmeta = r.getMetaData();
int numColumns=rmeta.getColumnCount();
g.setFont(new Font("Times new Roman",1,34));
g.setColor(Color.red);
g.drawString("Procurement Status Report by Product Desc .",30,30);
g.drawLine(30,40,730,40);
g.setFont(new Font("Times new Roman",1,14));
// setBackground(Color.pink);
g.setColor(Color.red);
g.drawString("S.No.",20,80);
for(int i=1;i<=numColumns;++i)
{
String cap=rmeta.getColumnName(i);
g.drawString(cap,x,y);
if(i==1)
x+=120;
else
x+=100;
}
int xx=1;
g.setColor(Color.black);
while(r.next())
{
x=90;
y+=22;
g.drawString(xx+" . ",25,y);
xx++;
for(int i=1;i<=numColumns;++i)
{
String ss=r.getString(i);
if(i==7)
{
char a[]=new char[10];
a[0]=ss.charAt(8);
a[1]=ss.charAt(9);
a[2]=ss.charAt(7);
a[3]=ss.charAt(5);
a[4]=ss.charAt(6);
a[5]=ss.charAt(4);
a[6]=ss.charAt(0);
a[7]=ss.charAt(1);
a[8]=ss.charAt(2);
a[9]=ss.charAt(3);
ss = new String(a);
}
// System.out.print(ss);
if(i==1)
x=65;
g.drawString(ss,x,y);
if(i==1)x+=150;
else if(i==2)x+=70;
else if(i==3)x+=140;
else if(i==4)x+=105;
else if(i==5)x+=85;
else if(i==6)x+=90;
else if(i==7)x+=70;
else x+=110;
}
//System.out.println();
}
}
catch(Exception e){System.out.println("--> "+e);}
}
}
References
Books :-
Java-TM The Complete Reference fifth edition (Herbert Schildt)
Websites :-
www.java.sun.com