forked from nehbha/JMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBilling.java
335 lines (264 loc) · 9.63 KB
/
Billing.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.io.*;
class Billing extends JFrame implements ActionListener
{
JInternalFrame iFrameBilling = new JInternalFrame("Add New Billing Item",true,true,true,true);
Connection con;
Connection con1;
Statement stmt;
Statement stmt1;
Statement stmtCustom;
ResultSet rs;
ResultSet rs1;
ResultSet res;
LayoutManager lm = null;
JTextField Customer_Id = new JTextField(10);
JTextField Job_Id = new JTextField(10);
JTextField Bill_Date = new JTextField(10);
JTextField Stone_Numbers = new JTextField(5);
JTextField Weight = new JTextField(10);
JTextField Net_Weight = new JTextField(10);
JTextField Gross_Err = new JTextField(10);
JTextField Weight_Err = new JTextField(10);
JTextField Gold_Purity = new JTextField(10);
JTextField Total_Price = new JTextField(12);
//JTextField Advance = new JTextField(12);
JTextField Discount = new JTextField(12);
JTextField Details = new JTextField(255);
JTextField Net_Due = new JTextField(10);
String Mode_list[] = {
"Cash", "Credit Card", "Cheque", "Demand Draft"
};
JComboBox Mode_Payment = new JComboBox(Mode_list);
String com = "Cash";
JButton submit = new JButton("Submit");
public Billing()
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:JMS");
}
catch(Exception ae)
{
System.out.println("NO CONNECTION");
ae.printStackTrace();
}
}
public JInternalFrame BillingFrame(JDesktopPane desktop)
{
iFrameBilling.setLayout(lm);
iFrameBilling.setLocation(25,25);
iFrameBilling.setSize(600,450);
Border border = new CompoundBorder(new BevelBorder(BevelBorder.RAISED),new EtchedBorder(EtchedBorder.RAISED));
iFrameBilling.setBorder(border);
JLabel l_Billing_Id =new JLabel(" Billing's Information");
Font labelFont = new Font("Arial", Font.BOLD, 20);
l_Billing_Id.setFont(labelFont);
//l_Billing_Id.setColor(Color BLUE);
l_Billing_Id.setBounds(20,20,500,20);
iFrameBilling.add(l_Billing_Id);
JLabel l_Customer_Id =new JLabel(" Customer ID :");
l_Customer_Id.setBounds(50,60,120,20);
iFrameBilling.add(l_Customer_Id);
Customer_Id.setBounds(170,60,60,20);
iFrameBilling.add(Customer_Id);
JLabel l_Job_Id =new JLabel(" Job ID :");
l_Job_Id.setBounds(60,90,120,20);
iFrameBilling.add(l_Job_Id);
Job_Id.setBounds(170,90,80,20);
iFrameBilling.add(Job_Id);
JLabel l_Bill_Date =new JLabel(" Bill Date :");
l_Bill_Date.setBounds(65,120,120,20);
iFrameBilling.add(l_Bill_Date);
Bill_Date.setBounds(170,120,80,20);
iFrameBilling.add(Bill_Date);
JLabel l_inc_date =new JLabel("dd / mm / yyyy");
l_inc_date.setBounds(270,120,100,20);
iFrameBilling.add(l_inc_date);
JLabel l_Stone_Numbers =new JLabel(" Number of Stones :");
l_Stone_Numbers.setBounds(20,150,150,20);
iFrameBilling.add(l_Stone_Numbers);
Stone_Numbers.setBounds(170,150,80,20);
iFrameBilling.add(Stone_Numbers);
JLabel l_Mode_Payment =new JLabel(" Payment Mode :");
l_Mode_Payment.setBounds(330,60,120,20);
iFrameBilling.add(l_Mode_Payment);
Mode_Payment.setMaximumRowCount(5);
Mode_Payment.setBounds(440,60,120,20);
Mode_Payment.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent a)
{
com = Mode_list[Mode_Payment.getSelectedIndex()];
}
});
iFrameBilling.add(Mode_Payment);
JLabel l_Weight =new JLabel(" Weight :");
l_Weight.setBounds(80,180,100,20);
iFrameBilling.add(l_Weight);
Weight.setBounds(170,180,80,20);
iFrameBilling.add(Weight);
JLabel l_Net_Weight = new JLabel(" Net Weight :");
l_Net_Weight.setBounds(70,210,120,20);
iFrameBilling.add(l_Net_Weight);
Net_Weight.setBounds(170,210,80,20);
iFrameBilling.add(Net_Weight);
JLabel l_Weight_Err = new JLabel(" Weight Error:");
l_Weight_Err.setBounds(280,210,120,20);
iFrameBilling.add(l_Weight_Err);
Weight_Err.setBounds(380,210,80,20);
iFrameBilling.add(Weight_Err);
JLabel l_Gross_Err =new JLabel(" Gross Error :");
l_Gross_Err.setBounds(50,240,150,20);
iFrameBilling.add(l_Gross_Err);
Gross_Err.setBounds(170,240,80,20);
iFrameBilling.add(Gross_Err);
JLabel l_Gold_Purity =new JLabel(" Gold Purity :");
l_Gold_Purity.setBounds(50,270,120,20);
iFrameBilling.add(l_Gold_Purity);
Gold_Purity.setBounds(170,270,100,20);
iFrameBilling.add(Gold_Purity);
JLabel l_Total_Price =new JLabel(" Total Price :");
l_Total_Price.setBounds(30,300,120,20);
iFrameBilling.add(l_Total_Price);
Total_Price.setBounds(170,300,100,20);
iFrameBilling.add(Total_Price);
JLabel l_Discount =new JLabel(" Discount :");
l_Discount.setBounds(280,300,100,20);
iFrameBilling.add(l_Discount);
Discount.setBounds(380,300,70,20);
iFrameBilling.add(Discount);
JLabel l_Details =new JLabel(" Details :");
l_Details.setBounds(50,330,120,20);
iFrameBilling.add(l_Details);
Details.setBounds(170,330,300,20);
iFrameBilling.add(Details);
Border border12 = new CompoundBorder(new BevelBorder(BevelBorder.RAISED),new EtchedBorder(EtchedBorder.RAISED));
submit.setBounds(240,370,140,30);
iFrameBilling.add(submit);
submit.setBorder(border12);
submit.addActionListener(this);
desktop.add(iFrameBilling);
return(iFrameBilling);
//iFrameBilling.show();
}
public void actionPerformed(ActionEvent e)
{
String Advance;
String sCustomer_Id = Customer_Id.getText();
String sJob_Id = Job_Id.getText();
String sBill_Date = Bill_Date.getText();
String sStone_Numbers = Stone_Numbers.getText();
String sWeight = Weight.getText();
String sNet_Weight = Net_Weight.getText();
String sGross_Err = Gross_Err.getText();
String sWeight_Err= Weight_Err.getText();
String sGold_Purity = Gold_Purity.getText();
String sTotal_Price = Total_Price.getText();
//String sAdvance = Advance.getText();
String sDiscount = Discount.getText();
String sDetails = Details.getText();
if(sCustomer_Id.equals(""))
{
JOptionPane.showMessageDialog(this,"Customer Id is Missing.");
return;
}
//int Cust = Integer.parseInt(sCustomer_Id);
//System.out.println("sCustomer_Id="+Cust);
//if(!(sCustomer_Id.equals("")))
{
System.out.println("sCustomer_Id="+sCustomer_Id);
try
{
String qCustom = "SELECT Customer_ID FROM Job_Card WHERE Customer_ID = '"+sCustomer_Id+"'";
stmtCustom = con.createStatement();
res = stmtCustom.executeQuery ( qCustom );
System.out.println("the res = "+res);
if(!(res.next()))
{
JOptionPane.showMessageDialog(this,"Customer not Present add to customer Data base.");
setTitle("No Record to Display");
return;
}
}
catch(Exception ae)
{
ae.printStackTrace();
}
}
if(sJob_Id.equals(""))
{
JOptionPane.showMessageDialog(this,"Job Id is Missing.");
setTitle("No Record to Display");
return;
}
if(sBill_Date.equals(""))
{
JOptionPane.showMessageDialog(this,"Bill Date is Missing.");
setTitle("No Record to Display");
return;
}
if(sStone_Numbers.equals(""))
{
JOptionPane.showMessageDialog(this,"Number of Stones Id is Missing.");
setTitle("No Record to Display");
return;
}
if(sNet_Weight.equals(""))
{
JOptionPane.showMessageDialog(this,"Net Weight is Missing.");
setTitle("No Record to Display");
return;
}
if(sGross_Err.equals(""))
{
JOptionPane.showMessageDialog(this,"Gross Error is Missing.");
setTitle("No Record to Display");
return;
}
if(sWeight_Err.equals(""))
{
JOptionPane.showMessageDialog(this,"Weight Error is Missing.");
setTitle("No Record to Display");
return;
}
if(sGold_Purity.equals(""))
{
JOptionPane.showMessageDialog(this,"Gold Purity is Missing.");
setTitle("No Record to Display");
return;
}
if(sTotal_Price.equals(""))
{
JOptionPane.showMessageDialog(this,"Total Price is Missing.");
setTitle("No Record to Display");
return;
}
String query =new String(" INSERT INTO Billing(Customer_ID,Job_ID,Bill_Date,Stone_Numbers,Weight,Net_Weight,Gross_error,Weight_error,Gold_purity,Total_Price,Payment_Mode,Discount,Details) VALUES ('"+sCustomer_Id+"','"+sJob_Id+"','"+sBill_Date+"','"+sStone_Numbers+"','"+sWeight+"','"+sNet_Weight+"','"+sGross_Err+"','"+sWeight_Err+"','"+sGold_Purity+"','"+sTotal_Price+"','"+com+"','"+sDiscount+"','"+sDetails+"')");
String query1 = new String("SELECT Amount_Advance FROM Job_Card WHERE Job_ID = "+sJob_Id+"");
try
{
stmt = con.createStatement();
int result = stmt.executeUpdate ( query );
stmt1 = con.createStatement();
rs1 = stmt1.executeQuery ( query1 );
//System.out.println(" result1="+rs1);
if(rs1.next())
{
Advance = rs1.getString(1);
System.out.println("Systems output is "+Advance);
}
}
catch(Exception ae)
{
ae.printStackTrace();
}
//iFrameBilling.setVisible(false);
//Addenq1 p = new Addenq1();Amount_Advance
}
}