-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVendorDel.java
96 lines (71 loc) · 2.42 KB
/
VendorDel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.io.*;
class VendorDel extends JFrame implements ActionListener
{
JInternalFrame iFrameVendorDel = new JInternalFrame("Delete Vendor Info",true,true,true,true);
Connection con;
Statement stmt;
ResultSet rs;
LayoutManager lm = null;
JTextField VendorDel_Id = new JTextField(10);
JButton Delete = new JButton("Delete");
public VendorDel()
{
}
public JInternalFrame VendorDelFrame(JDesktopPane desktop)
{
iFrameVendorDel.setLayout(lm);
iFrameVendorDel.setLocation(25,25);
iFrameVendorDel.setTitle("Delete Vendor Information");
iFrameVendorDel.setSize(300,80);
Border border = new CompoundBorder(new BevelBorder(BevelBorder.RAISED),new EtchedBorder(EtchedBorder.RAISED));
iFrameVendorDel.setBorder(border);
JLabel l_VendorDel_Id =new JLabel("Vendor ID :");
l_VendorDel_Id.setBounds(20,15,110,20);
iFrameVendorDel.add(l_VendorDel_Id);
VendorDel_Id.setBounds(120,15,60,20);
iFrameVendorDel.add(VendorDel_Id);
Border border12 = new CompoundBorder(new BevelBorder(BevelBorder.RAISED),new EtchedBorder(EtchedBorder.RAISED));
Delete.setBounds(190,15,100,20);
iFrameVendorDel.add(Delete);
Delete.setBorder(border12);
Delete.addActionListener(this);
desktop.add(iFrameVendorDel);
return(iFrameVendorDel);
//iFrameVendorDel.show();
}
public void actionPerformed(ActionEvent e)
{
String delstr = VendorDel_Id.getText();
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:JMS");
int custstr = Integer.parseInt(delstr);
String query = "DELETE * FROM Vendor E WHERE E.Vendor_ID = "+custstr;
stmt = con.createStatement();
int result = stmt.executeUpdate ( query );
System.out.println("result = "+result);
if(result==1)
{
JOptionPane.showMessageDialog(this,"The Vendor Record Deleted");
iFrameVendorDel.setVisible(false);
return;
}
if(result==0)
{
JOptionPane.showMessageDialog(this,"The Vendor Record Not Found Try Again.");
return;
}
}
catch(Exception ae)
{
ae.printStackTrace();
}
//Addenq1 p = new Addenq1();
}
}