-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathFrmAddEditPCategory.java
More file actions
107 lines (99 loc) · 3.07 KB
/
FrmAddEditPCategory.java
File metadata and controls
107 lines (99 loc) · 3.07 KB
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
97
98
99
100
101
102
103
104
105
106
107
package hms;
import javax.swing.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
class FrmAddEditPCategory extends JInternalFrame
{
/**
*
*/
private static final long serialVersionUID = 1L;
JLabel lblPCategoryId,lblPCategoryName;
JTextField txtPCategoryId,txtPCategoryName;
JButton btnSave,btnDiscard;
DConnection dc;
ResultSet rst;
int pcat_id=0;
FrmAddEditPCategory(boolean flag,String query,FrmPCategories fpc)
{
super("Add/Edit Procedure Category",true,true,true,true);
setResizable(false);
dc=new DConnection();
setLayout(new GridLayout(3,2));
lblPCategoryId = new JLabel("Category Id");
lblPCategoryId.setForeground(new Color(64,0,0));
lblPCategoryId.setFont(new Font(Font.SERIF,Font.ITALIC+Font.BOLD,18));
lblPCategoryName = new JLabel("Category Name");
lblPCategoryId.setForeground(new Color(64,0,0));
lblPCategoryId.setFont(new Font(Font.SERIF,Font.ITALIC+Font.BOLD,18));
txtPCategoryId=new JTextField();
txtPCategoryId.setForeground(new Color(49,49,49));
txtPCategoryId.setBackground(new Color(192,192,192));
txtPCategoryId.setFont(new Font(Font.SERIF,Font.ITALIC+Font.BOLD,18));
txtPCategoryId.setEditable(false);
txtPCategoryName=new JTextField();
txtPCategoryName.setForeground(new Color(106,106,106));
txtPCategoryName.setFont(new Font(Font.SERIF,Font.ITALIC+Font.BOLD,18));
try
{
if(flag==true)//add new
{
rst=dc.executeQuery("select max(pcat_id) from pcat");
rst.next();
pcat_id=rst.getInt(1)+1;
txtPCategoryId.setText(pcat_id+"");
dc.close();
btnSave=new JButton("Save");
}
else//edit
{
rst=dc.executeQuery(query);
rst.next();
txtPCategoryId.setText(rst.getString(1));
txtPCategoryName.setText(rst.getString(2));
btnSave=new JButton("Update");
}
}
catch(SQLException e)
{
e.printStackTrace();
}
btnDiscard=new JButton("Discard");
btnDiscard.setForeground(Color.white);
btnDiscard.setBackground(Color.red);
btnDiscard.setFont(new Font(Font.SERIF,Font.ITALIC,22));
btnDiscard.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
dispose();
}
});
btnSave.setForeground(Color.white);
btnSave.setBackground(Color.blue);
btnSave.setFont(new Font(Font.SERIF,Font.ITALIC,22));
btnSave.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent ae)
{
String s1=txtPCategoryId.getText();
String s2=txtPCategoryName.getText();
if(flag==true)
dc.executeOther("Insert into pcat values("+s1+",'"+s2+"')");
else
dc.executeOther("update pcat set pcat_name='"+s2+"' where pcat_id="+s1);
dispose();
fpc.reload();
//fpc.jsp.repaint();
//fpc.repaint();
}
});
add(lblPCategoryId);add(txtPCategoryId);
add(lblPCategoryName);add(txtPCategoryName);
add(btnSave);add(btnDiscard);
setSize(300,200);
setVisible(true);
setLocation(CommonMethods.getCenterPoint(getSize()));
}
}