PageRenderTime 1165ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/src/umsa/capricornio/gui/transacciones/DiagCertifPpto.java

https://gitlab.com/Alexs14/capricornio-re-sabs
Java | 330 lines | 261 code | 42 blank | 27 comment | 19 complexity | a9cf6dd66841a65839dceedc445f9d9f MD5 | raw file
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. /*
  6. * DiagCertifPpto.java
  7. *
  8. * Created on 21-11-2011, 06:10:27 PM
  9. */
  10. package umsa.capricornio.gui.transacciones;
  11. import java.awt.event.KeyEvent;
  12. import java.rmi.RemoteException;
  13. import java.util.Map;
  14. import javax.swing.event.TableModelEvent;
  15. import javax.swing.table.DefaultTableCellRenderer;
  16. import javax.swing.table.JTableHeader;
  17. import javax.swing.table.TableColumn;
  18. import javax.xml.rpc.ServiceException;
  19. import umsa.capricornio.gui.ConnectPPTO.PptoWSServiceLocator;
  20. import umsa.capricornio.gui.ConnectPPTO.PptoWS_PortType;
  21. import umsa.capricornio.domain.Ppto;
  22. import umsa.capricornio.gui.menu.FrmMenu;
  23. import umsa.capricornio.gui.transacciones.tablas.TablaSolPptoConcluidos;
  24. /**
  25. *
  26. * @author julian
  27. */
  28. public class DiagCertifPpto extends javax.swing.JDialog {
  29. TablaSolPptoConcluidos datos_ppto;
  30. int gestion;
  31. private Runtime r;
  32. Ppto ppto;
  33. /** Creates new form DiagCertifPpto */
  34. public DiagCertifPpto(FrmMenu menu, int gestion) {
  35. super(menu, true);
  36. initComponents();
  37. this.gestion=gestion;
  38. ConstruyeTablaSolicitudesPpto();
  39. }
  40. private void ConstruyeTablaSolicitudesPpto(){
  41. datos_ppto = new TablaSolPptoConcluidos();
  42. TblCertifPpto.setAutoCreateColumnsFromModel(false);
  43. TblCertifPpto.setModel(datos_ppto);
  44. for (int k = 0; k < TablaSolPptoConcluidos.m_columns.length; k++) {
  45. DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
  46. renderer.setHorizontalAlignment(TablaSolPptoConcluidos.m_columns[k].m_alignment);
  47. TableColumn column = new TableColumn(k, TablaSolPptoConcluidos.m_columns[k].m_width, renderer, null);
  48. TblCertifPpto.addColumn(column);
  49. }
  50. JTableHeader header = TblCertifPpto.getTableHeader();
  51. header.setUpdateTableInRealTime(true);
  52. header.setReorderingAllowed(true);
  53. PnlCertif.getViewport().add(TblCertifPpto);
  54. }
  55. void CerearTablaSolicitud(){
  56. int f = TblCertifPpto.getRowCount();
  57. for (int i=f-1 ;i>=0;i--){
  58. if (datos_ppto.delete(i)) {
  59. TblCertifPpto.tableChanged(new TableModelEvent(
  60. datos_ppto, i, i, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT));
  61. }
  62. }
  63. }
  64. private void LlenaSolicitudesConcluidas(){
  65. String hojaruta=null;
  66. String nro = null;
  67. String Palabra = null;
  68. if ("".equals(TxtSolPpto.getText())
  69. && "".equals(TxtHojaRuta.getText())
  70. && "".equals(TxtDetalle.getText())){
  71. javax.swing.JOptionPane.showMessageDialog(this,"<html> NO INTRODUJO NINGUN PARAMETRO DE BUSQUEDA,<BR> DEBE INTRODUCIR POR LO MENOS UNO","CAJA PAGADORA",
  72. javax.swing.JOptionPane.ERROR_MESSAGE);
  73. return;
  74. }
  75. if (!"".equals(TxtSolPpto.getText())){
  76. try { int n = new Integer(TxtSolPpto.getText().trim());
  77. nro="'"+TxtSolPpto.getText().trim()+"'";
  78. }
  79. catch (NumberFormatException e) {}
  80. }
  81. if (!"".equals(TxtHojaRuta.getText()))
  82. hojaruta="'"+TxtHojaRuta.getText().trim()+"'";
  83. if (!"".equals(TxtDetalle.getText()))
  84. Palabra="'"+TxtDetalle.getText().trim()+"'";
  85. try{
  86. PptoWSServiceLocator servicio = new PptoWSServiceLocator();
  87. PptoWS_PortType puerto = servicio.getPptoWS();
  88. CerearTablaSolicitud();
  89. Map[] datos=puerto.getSolicitudesPptoConcluidos(nro,hojaruta,Palabra,gestion);
  90. if (datos!=null){
  91. for (int c=0;c<datos.length;c++){
  92. datos_ppto.insert(c);
  93. TblCertifPpto.tableChanged(new TableModelEvent(datos_ppto, c, c, TableModelEvent.ALL_COLUMNS,TableModelEvent.INSERT));
  94. /*TblCertifPpto.setValueAt(datos[c].get("id_sol"),c,0);
  95. TblCertifPpto.setValueAt(datos[c].get("apert"),c,1);
  96. TblCertifPpto.setValueAt(datos[c].get("hoja_ruta"),c,2);
  97. TblCertifPpto.setValueAt(datos[c].get("detalle"),c,3);
  98. TblCertifPpto.setValueAt(datos[c].get("monto_ejec"),c,4);*/
  99. TblCertifPpto.setValueAt(datos[c].get("id_sol"),c,0);
  100. TblCertifPpto.setValueAt(datos[c].get("hoja_ruta"),c,1);
  101. TblCertifPpto.setValueAt(datos[c].get("apert"),c,2);
  102. TblCertifPpto.setValueAt(datos[c].get("detalle"),c,3);
  103. TblCertifPpto.setValueAt(datos[c].get("fuente"),c,4);
  104. TblCertifPpto.setValueAt(datos[c].get("monto_ejec"),c,5);
  105. }
  106. }
  107. }
  108. catch (RemoteException e){
  109. javax.swing.JOptionPane.showMessageDialog(this,"<html> error de conexion con el servidor <br> "+e,"CAJA PAGADORA",
  110. javax.swing.JOptionPane.ERROR_MESSAGE);
  111. }
  112. catch (ServiceException e){ System.out.println(e);}
  113. }
  114. public void AbreDialogo(){
  115. setVisible(true);
  116. }
  117. public Ppto Certif_Ppto() {
  118. return ppto;
  119. }
  120. /** This method is called from within the constructor to
  121. * initialize the form.
  122. * WARNING: Do NOT modify this code. The content of this method is
  123. * always regenerated by the Form Editor.
  124. */
  125. @SuppressWarnings("unchecked")
  126. // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  127. private void initComponents() {
  128. jPanel1 = new javax.swing.JPanel();
  129. TxtSolPpto = new javax.swing.JTextField();
  130. jLabel1 = new javax.swing.JLabel();
  131. TxtHojaRuta = new javax.swing.JTextField();
  132. TxtDetalle = new javax.swing.JTextField();
  133. jLabel2 = new javax.swing.JLabel();
  134. BtnBuscar = new javax.swing.JButton();
  135. jLabel3 = new javax.swing.JLabel();
  136. PnlCertif = new javax.swing.JScrollPane();
  137. TblCertifPpto = new javax.swing.JTable();
  138. jPanel2 = new javax.swing.JPanel();
  139. BtnSalir = new javax.swing.JButton();
  140. setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
  141. addWindowListener(new java.awt.event.WindowAdapter() {
  142. public void windowOpened(java.awt.event.WindowEvent evt) {
  143. formWindowOpened(evt);
  144. }
  145. });
  146. getContentPane().setLayout(null);
  147. jPanel1.setBackground(new java.awt.Color(217, 228, 216));
  148. jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
  149. jPanel1.setLayout(null);
  150. TxtSolPpto.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
  151. TxtSolPpto.addKeyListener(new java.awt.event.KeyAdapter() {
  152. public void keyPressed(java.awt.event.KeyEvent evt) {
  153. TxtSolPptoKeyPressed(evt);
  154. }
  155. });
  156. jPanel1.add(TxtSolPpto);
  157. TxtSolPpto.setBounds(60, 10, 80, 20);
  158. jLabel1.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
  159. jLabel1.setText("Sol. Ppto");
  160. jPanel1.add(jLabel1);
  161. jLabel1.setBounds(60, 30, 70, 14);
  162. TxtHojaRuta.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
  163. TxtHojaRuta.addKeyListener(new java.awt.event.KeyAdapter() {
  164. public void keyPressed(java.awt.event.KeyEvent evt) {
  165. TxtHojaRutaKeyPressed(evt);
  166. }
  167. });
  168. jPanel1.add(TxtHojaRuta);
  169. TxtHojaRuta.setBounds(210, 10, 100, 20);
  170. TxtDetalle.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
  171. TxtDetalle.addKeyListener(new java.awt.event.KeyAdapter() {
  172. public void keyPressed(java.awt.event.KeyEvent evt) {
  173. TxtDetalleKeyPressed(evt);
  174. }
  175. });
  176. jPanel1.add(TxtDetalle);
  177. TxtDetalle.setBounds(380, 10, 200, 20);
  178. jLabel2.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
  179. jLabel2.setText("Detalle de transaccion");
  180. jPanel1.add(jLabel2);
  181. jLabel2.setBounds(380, 30, 120, 14);
  182. BtnBuscar.setFont(new java.awt.Font("Arial", 1, 11)); // NOI18N
  183. BtnBuscar.setForeground(new java.awt.Color(0, 102, 51));
  184. BtnBuscar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/umsa/capricornio/gui/images/magnifier.png"))); // NOI18N
  185. BtnBuscar.setText("Buscar");
  186. BtnBuscar.addActionListener(new java.awt.event.ActionListener() {
  187. public void actionPerformed(java.awt.event.ActionEvent evt) {
  188. BtnBuscarActionPerformed(evt);
  189. }
  190. });
  191. jPanel1.add(BtnBuscar);
  192. BtnBuscar.setBounds(650, 10, 120, 30);
  193. jLabel3.setFont(new java.awt.Font("Arial", 0, 11)); // NOI18N
  194. jLabel3.setText("Hoja Ruta");
  195. jPanel1.add(jLabel3);
  196. jLabel3.setBounds(210, 30, 70, 14);
  197. getContentPane().add(jPanel1);
  198. jPanel1.setBounds(10, 10, 830, 50);
  199. TblCertifPpto.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
  200. TblCertifPpto.addMouseListener(new java.awt.event.MouseAdapter() {
  201. public void mouseClicked(java.awt.event.MouseEvent evt) {
  202. TblCertifPptoMouseClicked(evt);
  203. }
  204. });
  205. TblCertifPpto.addKeyListener(new java.awt.event.KeyAdapter() {
  206. public void keyPressed(java.awt.event.KeyEvent evt) {
  207. TblCertifPptoKeyPressed(evt);
  208. }
  209. });
  210. PnlCertif.setViewportView(TblCertifPpto);
  211. getContentPane().add(PnlCertif);
  212. PnlCertif.setBounds(10, 60, 830, 110);
  213. jPanel2.setBackground(new java.awt.Color(217, 228, 216));
  214. jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
  215. jPanel2.setLayout(null);
  216. BtnSalir.setFont(new java.awt.Font("Arial", 1, 11)); // NOI18N
  217. BtnSalir.setForeground(new java.awt.Color(0, 102, 51));
  218. BtnSalir.setMnemonic('S');
  219. BtnSalir.setText("Cancelar");
  220. BtnSalir.addActionListener(new java.awt.event.ActionListener() {
  221. public void actionPerformed(java.awt.event.ActionEvent evt) {
  222. BtnSalirActionPerformed(evt);
  223. }
  224. });
  225. jPanel2.add(BtnSalir);
  226. BtnSalir.setBounds(350, 10, 120, 30);
  227. getContentPane().add(jPanel2);
  228. jPanel2.setBounds(10, 170, 830, 50);
  229. setSize(new java.awt.Dimension(867, 263));
  230. setLocationRelativeTo(null);
  231. }// </editor-fold>//GEN-END:initComponents
  232. private void TxtSolPptoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TxtSolPptoKeyPressed
  233. if(evt.getKeyCode() == KeyEvent.VK_ENTER ) {
  234. BtnBuscar.doClick();
  235. }
  236. }//GEN-LAST:event_TxtSolPptoKeyPressed
  237. private void TxtHojaRutaKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TxtHojaRutaKeyPressed
  238. if(evt.getKeyCode() == KeyEvent.VK_ENTER ) {
  239. BtnBuscar.doClick();
  240. }
  241. }//GEN-LAST:event_TxtHojaRutaKeyPressed
  242. private void TxtDetalleKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TxtDetalleKeyPressed
  243. if(evt.getKeyCode() == KeyEvent.VK_ENTER ) {
  244. BtnBuscar.doClick();
  245. }
  246. }//GEN-LAST:event_TxtDetalleKeyPressed
  247. private void BtnBuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnBuscarActionPerformed
  248. LlenaSolicitudesConcluidas();
  249. TxtDetalle.setText("");
  250. TxtHojaRuta.setText("");
  251. TxtSolPpto.setText("");
  252. }//GEN-LAST:event_BtnBuscarActionPerformed
  253. private void BtnSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtnSalirActionPerformed
  254. System.gc();
  255. r = Runtime.getRuntime();
  256. long mem1 = r.freeMemory();
  257. dispose();
  258. }//GEN-LAST:event_BtnSalirActionPerformed
  259. private void TblCertifPptoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TblCertifPptoKeyPressed
  260. }//GEN-LAST:event_TblCertifPptoKeyPressed
  261. private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
  262. ppto =new Ppto();
  263. }//GEN-LAST:event_formWindowOpened
  264. private void TblCertifPptoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_TblCertifPptoMouseClicked
  265. if (evt.getClickCount() == 2){
  266. int fila = TblCertifPpto.getSelectedRow();
  267. ppto.setCertif_ppto(TblCertifPpto.getValueAt(fila, 0).toString());
  268. ppto.setHoja_ruta(TblCertifPpto.getValueAt(fila, 1).toString());
  269. ppto.setMonto(Double.parseDouble(TblCertifPpto.getValueAt(fila, 5).toString()));
  270. ppto.setFuente(TblCertifPpto.getValueAt(fila, 4).toString());
  271. BtnSalir.doClick();
  272. }
  273. }//GEN-LAST:event_TblCertifPptoMouseClicked
  274. // Variables declaration - do not modify//GEN-BEGIN:variables
  275. private javax.swing.JButton BtnBuscar;
  276. private javax.swing.JButton BtnSalir;
  277. private javax.swing.JScrollPane PnlCertif;
  278. private javax.swing.JTable TblCertifPpto;
  279. private javax.swing.JTextField TxtDetalle;
  280. private javax.swing.JTextField TxtHojaRuta;
  281. private javax.swing.JTextField TxtSolPpto;
  282. private javax.swing.JLabel jLabel1;
  283. private javax.swing.JLabel jLabel2;
  284. private javax.swing.JLabel jLabel3;
  285. private javax.swing.JPanel jPanel1;
  286. private javax.swing.JPanel jPanel2;
  287. // End of variables declaration//GEN-END:variables
  288. }