KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > grid > ed > VBPartner


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.grid.ed;
15
16 import java.awt.*;
17 import java.awt.event.*;
18 import javax.swing.*;
19 import java.sql.*;
20 import java.util.*;
21
22 import org.compiere.apps.*;
23 import org.compiere.util.*;
24 import org.compiere.model.*;
25 import org.compiere.plaf.*;
26 import org.compiere.swing.*;
27
28 /**
29  * Business Partner Editor
30  *
31  * @author Jorg Janke
32  * @version $Id: VBPartner.java,v 1.13 2003/07/19 05:19:43 jjanke Exp $
33  */

34 public final class VBPartner extends JDialog implements ActionListener
35 {
36     /**
37      * Constructor.
38      * Requires LoadBPartner
39      * @param frame parent
40      * @param WindowNo Window No
41      */

42     public VBPartner(Frame frame, int WindowNo)
43     {
44         super(frame, Msg.translate(Env.getCtx(), "C_BPartner_ID"), true);
45         Log.trace(Log.l1_User, "VBPartner");
46         m_WindowNo = WindowNo;
47         try
48         {
49             jbInit();
50         }
51         catch(Exception JavaDoc ex)
52         {
53             Log.error("VBPartner - " + ex.getMessage());
54         }
55         initBPartner();
56         //
57
AEnv.positionCenterWindow(frame, this);
58     } // VBPartner
59

60     private int m_WindowNo;
61     private int m_C_BPartner_ID = 0;
62     private Integer JavaDoc m_AD_User_ID = null;
63     private Integer JavaDoc m_C_BPartner_Location_ID = null;
64
65     private Insets m_labelInsets = new Insets(2,15,2,0); // top,left,bottom,right
66
private Insets m_fieldInsets = new Insets(2,5,2,10); // top,left,bottom,right
67
private GridBagConstraints m_gbc = new GridBagConstraints();
68     private int m_line;
69     private Object JavaDoc[] m_greeting;
70     //
71
private VString fValue, fName, fName2, fContact, fTitle, fPhone, fFax, fPhone2, fEMail;
72     private VLocation fAddress;
73     private String JavaDoc OldValue="", OldName="", OldName2="", OldContact="", OldTitle="",
74         OldPhone="", OldFax="", OldPhone2="", OldEMail="";
75     private JComboBox fGreetingBP, fGreetingC;
76     private int OldGreetingBP = -1, OldGreetingC = -1;
77     //
78
private CPanel mainPanel = new CPanel();
79     private BorderLayout mainLayout = new BorderLayout();
80     private CPanel centerPanel = new CPanel();
81     private CPanel southPanel = new CPanel();
82     private GridBagLayout centerLayout = new GridBagLayout();
83     private ConfirmPanel confirmPanel = new ConfirmPanel(true);
84     private BorderLayout southLayout = new BorderLayout();
85
86     /**
87      * Static Init
88      * @throws Exception
89      */

90     void jbInit() throws Exception JavaDoc
91     {
92         mainPanel.setLayout(mainLayout);
93         southPanel.setLayout(southLayout);
94         centerPanel.setLayout(centerLayout);
95         mainLayout.setVgap(5);
96         getContentPane().add(mainPanel);
97         mainPanel.add(centerPanel, BorderLayout.CENTER);
98         mainPanel.add(southPanel, BorderLayout.SOUTH);
99         southPanel.add(confirmPanel, BorderLayout.CENTER);
100         //
101
confirmPanel.addActionListener(this);
102     } // jbInit
103

104     /**
105      * Dynamic Init
106      */

107     private void initBPartner()
108     {
109         // Get Data
110
m_greeting = fillGreeting();
111
112         // Display
113
m_gbc.anchor = GridBagConstraints.NORTHWEST;
114         m_gbc.gridx = 0;
115         m_gbc.gridy = 0;
116         m_gbc.gridwidth = 1;
117         m_gbc.weightx = 0;
118         m_gbc.weighty = 0;
119         m_gbc.fill = GridBagConstraints.NONE;
120         m_gbc.ipadx = 0;
121         m_gbc.ipady = 0;
122         m_line = 0;
123
124         // Value
125
fValue = new VString("Value", true, false, true, 30, 60, "");
126         createLine (fValue, "Value", true, false);
127         // Greeting Business Partner
128
fGreetingBP = new JComboBox (m_greeting);
129         createLine (fGreetingBP, "Greeting");
130         // Name
131
fName = new VString("Name", true, false, true, 30, 60, "");
132         createLine (fName, "Name");
133         //
134
fName2 = new VString("Name2", false, false, true, 30, 60, "");
135         createLine (fName2, "Name2");
136         // Greeting Contact
137
fGreetingC = new JComboBox (m_greeting);
138         createLine (fGreetingC, "Greeting", true, false);
139         // Contact
140
fContact = new VString("Contact", false, false, true, 30, 60, "");
141         createLine (fContact, "Contact");
142         //
143
fTitle = new VString("Title", false, false, true, 30, 60, "");
144         createLine(fTitle, "Title");
145         // Location
146
fAddress = new VLocation ("C_Location_ID", false, false, true, new MLocation (Env.getCtx(), m_WindowNo));
147         fAddress.setValue (null);
148         createLine (fAddress, "C_Location_ID", true, true);
149         // Phone
150
fPhone = new VString("Phone", false, false, true, 30, 40, "");
151         createLine (fPhone, "Phone", true, false);
152         //
153
fPhone2 = new VString("Phone2", false, false, true, 30, 40, "");
154         createLine (fPhone2, "Phone2");
155         //
156
fFax = new VString("Fax", false, false, true, 30, 40, "");
157         createLine (fFax, "Fax");
158         //
159
fEMail = new VString("EMail", false, false, true, 30, 40, "");
160         createLine (fEMail, "EMail");
161     } // initBPartner
162

163     /**
164      * Create Line
165      * @param field field
166      * @param title label value
167      */

168     private void createLine (JComponent field, String JavaDoc title)
169     {
170         createLine (field, title, false, false);
171     }
172
173     /**
174      * Create Line
175      * @param field field
176      * @param title label value
177      * @param addSpace add more space
178      * @param fill fill horizontal
179      */

180     private void createLine (JComponent field, String JavaDoc title, boolean addSpace, boolean fill)
181     {
182         if (addSpace)
183         {
184             m_gbc.gridy = m_line++;
185             m_gbc.gridx = 1;
186             m_gbc.insets = m_fieldInsets;
187             centerPanel.add (Box.createHorizontalStrut(6), m_gbc);
188         }
189
190         // Line
191
m_gbc.gridy = m_line++;
192
193         // Label
194
m_gbc.gridx = 0;
195         m_gbc.insets = m_labelInsets;
196         m_gbc.fill = GridBagConstraints.HORIZONTAL;
197         VLabel label = new VLabel(Msg.translate(Env.getCtx(), title));
198         centerPanel.add(label, m_gbc);
199
200         // Field
201
m_gbc.gridx = 1;
202         m_gbc.insets = m_fieldInsets;
203         if (fill)
204             m_gbc.fill = GridBagConstraints.HORIZONTAL;
205         else
206             m_gbc.fill = GridBagConstraints.NONE;
207         centerPanel.add(field, m_gbc);
208     } // createLine
209

210     /**
211      * Fill Greeting
212      * @return KeyNamePair Array of Greetings
213      */

214     private Object JavaDoc[] fillGreeting()
215     {
216         ArrayList list = new ArrayList();
217         // Optional
218
list.add (new KeyNamePair(-1, " "));
219
220         String JavaDoc SQL = "SELECT C_Greeting_ID, Name FROM C_Greeting";
221
222         try
223         {
224             Statement stmt = DB.createStatement();
225             ResultSet rs = stmt.executeQuery(SQL);
226             while (rs.next())
227             {
228                 int key = rs.getInt("C_Greeting_ID");
229                 String JavaDoc name = rs.getString("Name");
230                 list.add (new KeyNamePair(key, name));
231             }
232             rs.close();
233             stmt.close();
234         }
235         catch (SQLException e)
236         {
237             Log.error("VBPartner.fillGreeting", e);
238         }
239         return list.toArray();
240     } // fillGreeting
241

242     /**
243      * Search m_greeting for key
244      * @param key C_Greeting_ID
245      * @return Greeting
246      */

247     private KeyNamePair getGreeting (int key)
248     {
249         for (int i = 0; i < m_greeting.length; i++)
250         {
251             KeyNamePair p = (KeyNamePair)m_greeting[i];
252             if (p.getKey() == key)
253                 return p;
254         }
255         return new KeyNamePair(-1, " ");
256     } // getGreeting
257

258     /**
259      * Load BPartner
260      * @param C_BPartner_ID - existing BPartner or 0 for new
261      * @return true if loaded
262      */

263     public boolean loadBPartner (int C_BPartner_ID)
264     {
265         Log.trace(Log.l3_Util, "VBPartner.load - " + C_BPartner_ID);
266         // we have it already
267
if (C_BPartner_ID == m_C_BPartner_ID)
268             return true;
269         // new bpartner
270
if (C_BPartner_ID == 0)
271         {
272             m_C_BPartner_ID = C_BPartner_ID;
273             return true;
274         }
275
276         m_C_BPartner_ID = C_BPartner_ID;
277         String JavaDoc SQL = "SELECT p.Value,p.C_Greeting_ID AS C_GreetingBP_ID,p.Name,p.Name2,"
278             + "c.Name AS Contact,c.C_Greeting_ID,c.Title,"
279             + "l.Phone,l.Phone2,l.Fax, c.EMail, l.C_Location_ID,"
280             + "c.AD_User_ID, l.C_BPartner_Location_ID "
281             + "FROM C_BPartner p, AD_User c, C_BPartner_Location l "
282             + "WHERE p.C_BPartner_ID=c.C_BPartner_ID(+)"
283             + " AND p.C_BPartner_ID=l.C_BPartner_ID(+)"
284             + " AND p.C_BPartner_ID=?" // 1
285
+ " ORDER BY l.IsBillTo Desc"; // BillTo first
286
try
287         {
288             PreparedStatement pstmt = DB.prepareStatement(SQL);
289             pstmt.setInt(1, m_C_BPartner_ID);
290             ResultSet rs = pstmt.executeQuery();
291             if (!rs.next())
292             {
293                 ADialog.error(m_WindowNo, this, "BPartnerNotFound");
294                 rs.close();
295                 pstmt.close();
296                 return false;
297             }
298             // Load values
299
OldValue = rs.getString("Value");
300             if (OldValue == null)
301                 OldValue = "";
302             fValue.setText(OldValue);
303             //
304
OldGreetingBP = rs.getInt("C_GreetingBP_ID");
305             if (rs.wasNull())
306                 OldGreetingBP = -1;
307             fGreetingBP.setSelectedItem(getGreeting(OldGreetingBP));
308             //
309
OldName = rs.getString("Name");
310             if (OldName == null)
311                 OldName = "";
312             fName.setText(OldName);
313             //
314
OldName2 = rs.getString("Name2");
315             if (OldName2 == null)
316                 OldName2 = "";
317             fName2.setText(OldName2);
318             //
319
OldGreetingC = rs.getInt("C_Greeting_ID");
320             if (rs.wasNull())
321                 OldGreetingC = -1;
322             fGreetingC.setSelectedItem(getGreeting(OldGreetingC));
323             //
324
OldContact = rs.getString("Contact");
325             if (OldContact == null)
326                 OldContact = "";
327             fContact.setText(OldContact);
328             //
329
OldTitle = rs.getString("Title");
330             if (OldTitle == null)
331                 OldTitle = "";
332             fTitle.setText(OldTitle);
333             //
334
OldPhone = rs.getString("Phone");
335             if (OldPhone == null)
336                 OldPhone = "";
337             fPhone.setText(OldPhone);
338             //
339
OldPhone2 = rs.getString("Phone2");
340             if (OldPhone2 == null)
341                 OldPhone2 = "";
342             fPhone2.setText(OldPhone2);
343             //
344
OldFax = rs.getString("Fax");
345             if (OldFax == null)
346                 OldFax = "";
347             fFax.setText(OldFax);
348             //
349
OldEMail = rs.getString("EMail");
350             if (OldEMail == null)
351                 OldEMail = "";
352             fEMail.setText(OldEMail);
353             //
354
int location = rs.getInt("C_Location_ID");
355             fAddress.setValue (new Integer JavaDoc(location));
356             //
357
m_AD_User_ID = new Integer JavaDoc (rs.getInt("AD_User_ID"));
358             if (rs.wasNull())
359                 m_AD_User_ID = null;
360             m_C_BPartner_Location_ID = new Integer JavaDoc (rs.getInt("C_BPartner_Location_ID"));
361             if (rs.wasNull())
362                 m_C_BPartner_Location_ID = null;
363             //
364
rs.close();
365             pstmt.close();
366         }
367         catch (SQLException e)
368         {
369             Log.error("VBPartner.loadBPartner", e);
370             ADialog.error(m_WindowNo, this, "BPartnerNotFound", e.getLocalizedMessage());
371             return false;
372         }
373         return true;
374     } // loadBPartner
375

376
377     /**
378      * Action Listener
379      * @param e event
380      */

381     public void actionPerformed(ActionEvent e)
382     {
383         // OK pressed
384
if (e.getActionCommand().equals(ConfirmPanel.A_OK) && actionSave())
385             dispose();
386         // Cancel pressed
387
else if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
388             dispose();
389     } // actionPerformed
390

391     /**
392      * Save.
393      * Checks mandatory fields and saves Partner, Contact and Location
394      * @return true if saved
395      */

396     private boolean actionSave()
397     {
398         Log.trace(Log.l3_Util, "VBPartner.save");
399
400         // Check Mandatory fields
401
String JavaDoc value = fValue.getText();
402         if (value == null)
403             value = "";
404         String JavaDoc name = fName.getText();
405         if (value.equals("") || name.equals(""))
406         {
407             if (value.equals(""))
408                 fValue.setBackground(CompierePLAF.getFieldBackground_Error());
409             if (name.equals(""))
410                 fName.setBackground(CompierePLAF.getFieldBackground_Error());
411             return false;
412         }
413
414         String JavaDoc SQL = "";
415         try
416         {
417             Statement stmt = DB.createStatement();
418             int AD_Client_ID = Integer.parseInt(Env.getContext(Env.getCtx(), "#AD_Client_ID"));
419             int AD_Org_ID = Integer.parseInt(Env.getContext(Env.getCtx(), "#AD_Org_ID"));
420             int UpdatedBy = Integer.parseInt(Env.getContext(Env.getCtx(), "#AD_User_ID"));
421
422             KeyNamePair p = (KeyNamePair)fGreetingBP.getSelectedItem();
423             int greetingBP = p.getKey();
424             p = (KeyNamePair)fGreetingC.getSelectedItem();
425             int greetingC = p.getKey();
426
427             // === Insert Business Partner ===
428
if (m_C_BPartner_ID == 0)
429             {
430                 m_C_BPartner_ID = DB.getKeyNextNo(Env.getCtx(), m_WindowNo, "C_BPartner");
431                 Log.trace(Log.l4_Data, "Insert BPartner " + m_C_BPartner_ID);
432                 String JavaDoc gr = "NULL";
433                 if (greetingBP > 0)
434                     gr = "" + greetingBP;
435                 SQL = "INSERT INTO C_BPartner"
436                     + "(C_BPartner_ID,"
437                     + "AD_Client_ID,AD_Org_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,"
438                     + "Value,Name,Name2,C_Greeting_ID,IsSummary,IsOneTime,IsProspect,IsVendor,IsCustomer,IsEmployee,IsSalesRep,"
439                     + "AD_Language,C_BP_Group_ID,C_InvoiceSchedule_ID,C_PaymentTerm_ID,"
440                     + "M_PriceList_ID,M_DiscountSchema_ID,C_Dunning_ID,DocumentCopies,PaymentRule,"
441                     + "SO_CreditLimit, SO_CreditUsed) "
442                     //
443
+ "SELECT " + m_C_BPartner_ID + ","
444                     + AD_Client_ID + "," + AD_Org_ID + ",'Y',SysDate," + UpdatedBy + ",SysDate," + UpdatedBy + ","
445                     + DB.TO_STRING(value) + "," + DB.TO_STRING(name) + "," + DB.TO_STRING(fName2.getText())
446                     + "," + gr + ",'N','N','N','N','Y','N','N',"
447                     + "AD_Language,C_BP_Group_ID,C_InvoiceSchedule_ID,C_PaymentTerm_ID,"
448                     + "p.M_PriceList_ID,M_DiscountSchema_ID,C_Dunning_ID,DocumentCopies,PaymentRule,"
449                     + "0,0 "
450                     + "FROM C_BPartner p, AD_ClientInfo c "
451                     + "WHERE c.AD_Client_ID=" + AD_Client_ID
452                     + " AND p.C_BPartner_ID(+)=c.C_BPartnerCashTrx_ID";
453                 int i = stmt.executeUpdate(SQL);
454                 if (i != 1)
455                     ADialog.error(m_WindowNo, this, "BPartnerNotSaved", "\nPartner I#=" + i + ", SQL=" + SQL);
456             }
457             // === Update Business Partner === (value/greeting/name/name2)
458
else if (!(OldValue.equals(value) && OldGreetingBP==greetingBP && OldName.equals(name)
459                 && OldName2.equals(fName2.getText()) ))
460             {
461                 Log.trace(Log.l4_Data, "Update BPartner " + m_C_BPartner_ID);
462                 Integer JavaDoc gr = new Integer JavaDoc(greetingBP);
463                 SQL = "UPDATE C_BPartner SET "
464                     + "Value=" + DB.TO_STRING(value) + ","
465                     + "C_Greeting_ID=" + (greetingBP == -1 ? "NULL" : gr.toString()) + ","
466                     + "Name=" + DB.TO_STRING(name) + ","
467                     + "Name2=" + DB.TO_STRING(fName2.getText()) + ","
468                     + "Updated=SysDate, UpdatedBy=" + UpdatedBy
469                     + " WHERE C_BPartner_ID=" + m_C_BPartner_ID;
470                 int i = stmt.executeUpdate(SQL);
471                 if (i != 1)
472                     ADialog.error(m_WindowNo, this, "BPartnerNotSaved", "\nPartner U#=" + i + ", SQL=" + SQL);
473             }
474
475             // === Insert New BPartner_Location ===
476
if (m_C_BPartner_Location_ID == null && !fAddress.getValue().equals(new Integer JavaDoc(0)))
477             {
478                 m_C_BPartner_Location_ID = new Integer JavaDoc (DB.getKeyNextNo(Env.getCtx(), m_WindowNo, "C_BPartner_Location"));
479                 Log.trace(Log.l4_Data, "Insert BPartner Location " + m_C_BPartner_Location_ID + " (" + fAddress.getValue() + ")");
480                 SQL = "INSERT INTO C_BPartner_Location"
481                     + "(C_BPartner_Location_ID, C_BPartner_ID,"
482                     + "AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,"
483                     + "Name, C_Location_ID, Phone, Phone2, Fax)"
484                     + " VALUES "
485                     + "(" + m_C_BPartner_Location_ID + "," + m_C_BPartner_ID + ","
486                     + AD_Client_ID + "," + AD_Org_ID + ",'Y',SysDate," + UpdatedBy + ",SysDate," + UpdatedBy + ","
487                     + DB.TO_STRING(fAddress.getName()) + "," + fAddress.getValue() + ","
488                     + DB.TO_STRING(fPhone.getText()) + "," + DB.TO_STRING(fPhone2.getText()) + ","
489                     + DB.TO_STRING(fFax.getText()) + ")";
490                 int i = stmt.executeUpdate(SQL);
491                 if (i != 1)
492                     ADialog.error(m_WindowNo, this, "BPartnerNotSaved", "\nLocation I#=" + i + ", SQL=" + SQL);
493             }
494             // === Update BPartner_Location ===
495
else if (m_C_BPartner_Location_ID != null &&
496                 !(fAddress.getValue().equals(m_C_BPartner_Location_ID)
497                 && OldPhone.equals(fPhone.getText()) && OldPhone2.equals(fPhone2.getText())
498                 && OldFax.equals(fFax.getText()) ))
499             {
500                 Log.trace(Log.l4_Data, "Update BPartner Location " + m_C_BPartner_Location_ID);
501                 SQL = "UPDATE C_BPartner_Location SET "
502                     + "C_Location_ID=" + fAddress.getValue() + ","
503                     + "Phone=" + DB.TO_STRING(fPhone.getText()) + ","
504                     + "Phone2=" + DB.TO_STRING(fPhone2.getText()) + ","
505                     + "Fax=" + DB.TO_STRING(fFax.getText()) + ","
506                     + "Updated=SysDate, UpdatedBy=" + UpdatedBy
507                     + " WHERE C_BPartner_Location_ID=" + m_C_BPartner_Location_ID;
508                 int i = stmt.executeUpdate(SQL);
509                 if (i != 1)
510                     ADialog.error(m_WindowNo, this, "BPartnerNotSaved", "\nLocation U#=" + i + ", SQL=" + SQL);
511             }
512
513             // === Insert new BPartner_Contact === only if contact/email entered
514
if (!fEMail.getText().equals("") && fContact.getText().equals(""))
515                 fContact.setText(fName.getText());
516             if (m_AD_User_ID == null && !fContact.getText().equals("")
517               &&
518                 !(OldContact.equals(fContact.getText()) && OldTitle.equals(fTitle.getText())
519                 && OldPhone.equals(fPhone.getText()) && OldPhone2.equals(fPhone2.getText())
520                 && OldFax.equals(fFax.getText()) && OldEMail.equals(fEMail.getText()) ))
521             {
522                 m_AD_User_ID = new Integer JavaDoc (DB.getKeyNextNo(Env.getCtx(), m_WindowNo, "AD_User"));
523                 Log.trace(Log.l4_Data, "Insert BPartner User/Contact " + m_AD_User_ID);
524                 String JavaDoc gr = "NULL";
525                 if (greetingC > 0)
526                     gr = "" + greetingC;
527                 SQL = "INSERT INTO AD_User"
528                     + "(AD_User_ID, C_BPartner_ID,"
529                     + "AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated, UpdatedBy,"
530                     + "Name, C_Greeting_ID, Title, Phone, Phone2, Fax, EMail)"
531                     + " VALUES "
532                     + "(" + m_AD_User_ID + "," + m_C_BPartner_ID + ","
533                     + AD_Client_ID + "," + AD_Org_ID + ",'Y',SysDate," + UpdatedBy + ",SysDate," + UpdatedBy + ","
534                     + DB.TO_STRING(fContact.getText()) + "," + gr + ","
535                     + DB.TO_STRING(fTitle.getText()) + "," + DB.TO_STRING(fPhone.getText()) + ","
536                     + DB.TO_STRING(fPhone2.getText()) + "," + DB.TO_STRING(fFax.getText()) + ","
537                     + DB.TO_STRING(fEMail.getText()) + ")";
538                 int i = stmt.executeUpdate(SQL);
539                 if (i != 1)
540                     ADialog.error(m_WindowNo, this, "BPartnerNotSaved", "\nContact I#=" + i + ", SQL=" + SQL);
541             }
542             // === Update BPartner_Contact ===
543
else if (m_AD_User_ID != null &&
544                 !(OldContact.equals(fContact.getText()) && OldTitle.equals(fTitle.getText())
545                 && OldPhone.equals(fPhone.getText()) && OldPhone2.equals(fPhone2.getText())
546                 && OldFax.equals(fFax.getText()) && OldEMail.equals(fEMail.getText())
547                 && OldGreetingC==greetingC ))
548             {
549                 Log.trace(Log.l4_Data, "Update BPartner User/Contact " + m_AD_User_ID);
550                 // We need to have a Name
551
if (fContact.getText().equals(""))
552                     fContact.setText(name);
553                 Integer JavaDoc gr = new Integer JavaDoc(greetingC);
554                 SQL = "UPDATE AD_User SET "
555                     + "Name=" + DB.TO_STRING(fContact.getText()) + ","
556                     + "C_Greeting_ID=" + (greetingC == -1 ? "NULL" : gr.toString()) + ","
557                     + "Title=" + DB.TO_STRING(fTitle.getText()) + ","
558                     + "Phone=" + DB.TO_STRING(fPhone.getText()) + ","
559                     + "Phone2=" + DB.TO_STRING(fPhone2.getText()) + ","
560                     + "Fax=" + DB.TO_STRING(fFax.getText()) + ","
561                     + "EMail=" + DB.TO_STRING(fEMail.getText()) + ","
562                     + "Updated=SysDate, UpdatedBy=" + UpdatedBy
563                     + " WHERE AD_User_ID=" + m_AD_User_ID;
564                 int i = stmt.executeUpdate(SQL);
565                 if (i != 1)
566                     ADialog.error(m_WindowNo, this, "BPartnerNotSaved", "\nContact U#=" + i + ", SQL=" + SQL);
567             }
568
569         }
570         catch (SQLException e)
571         {
572             Log.error("VBPartner.actionSave\nSQL=" + SQL, e);
573             ADialog.error(m_WindowNo, this, "BPartnerNotSaved", e.getLocalizedMessage());
574             m_C_BPartner_ID = 0;
575             return false;
576         }
577
578         return true;
579     } // actionSave
580

581
582     /**
583      * Returns BPartner ID
584      * @return C_BPartner)ID (0 = not saved)
585      */

586     public int getBPartner_ID()
587     {
588         return m_C_BPartner_ID;
589     } // getBPartner_ID
590

591
592     /**************************************************************************
593      * VLabel
594      */

595     class VLabel extends JLabel
596     {
597         public VLabel (String JavaDoc text)
598         {
599             super (text);
600             this.setHorizontalAlignment(JLabel.RIGHT);
601         }
602     } // VLabel
603

604 } // VBPartner
605

606
Popular Tags