Aplicação para celular

Boa Tarde galera…
na empresa que eu trabalho, uma pessoa desenvolveu uma aplicação para rodar em um nextel.
No emulador rodado no computador, ele funciona. Porem quando tentamos rodar no aparelho, ele nao funciona e diz que falta alguma coisa.

Poderia ajudar?

/*
 * mPedidos.java
 *
 * Created on 1 de Novembro de 2007, 15:00
 */

package pMain;

import javax.microedition.rms.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import java.io.*;
import java.util.*;


/**
 *
 * @author reginaldo
 */
public class mPedidos extends MIDlet implements CommandListener, ItemCommandListener {
    
   private Command aboutCommand;
    
    /** Creates a new instance of mPedidos */
    public mPedidos() {
        initialize();
    }
   
    Display display; 
    private Random random;
    private String Site;
    private Form frmLogin;                     
    private Command cancelCommand1;
    private Command OkComand;
    private TextField tfUser;
    private TextField tfSenha;
    private Spacer spacer1;
    private Spacer spacer2;
    private StringItem mensagem;
    private Spacer spacer3;
    private Form frmDigit;
    private TextField tfCliente;
    private Command cmdLeCliente;
    private TextField tfProduto;
    private Ticker tickerCliente;
    private Command LeProduto;
    private StringItem strProduto;
    private StringItem strPreco;
    private TextField tfVlVenda;
    private Command cmdVoltar;
    private Font fPequena;
    private TextField tfQte;
    private Command cmdGravar;
    private Command cmdRelacao;
    private Command cmdFechaRelacao;
    private Command cmdSalvaPedido;
    private Command cmdExcluiItem;
    private Command cmdEditaItem;
    private List lstPedido;
    private Command cmdVoltaDig;
    private Form frmEdicao;
    private StringItem strProdutoAtual;
    private TextField vlVendaAtual;
    private TextField qteAtual;
    private Command cmdVoltarRelacao;
    private Command cmdSalvaEdicao;
    private Alert alertPedido;
    private Command cmdJogaPedidoFora;
    private Command cmdVoltaPraDigitacao;
    private Form frmUpLoad;
    private StringItem strCliente;
    private StringItem strTotal;
    private ChoiceGroup grCondPgto;
    private Command cmdUpload;
    private StringItem strNrPedido;
    private Alert alAuxiliar;
    private StringItem strOpcoes;
    private Alert alFinaliza;
    private Command cmdFinalizada;
    private javax.microedition.m2g.SVGImage svgImage1;                   
    public boolean ClienteLogado = false;
    private boolean logado = false;
    private RecordStore rs = null;
    static final String REC_STORE = "pedidosdb";
    private String registro;
    private String registronovo;
    private String usuario;
    private float vlitem;
    private String vltotal = "0.00";    
    private String ClienteAtual;
    private List registros;
    private String CodClienteAtual;
    private boolean basealterada = false;
    private boolean registrosalterados = false;
    private String use_cod;
    public String retornoServidor;
    public int registroemtransmissao;
    
                     

    /** Called by the system to indicate that a command has been invoked on a particular item.                       
     * @param command the Command that ws invoked
     * @param item the Item on which the command was invoked
     */
    public void commandAction(Command command, Item item) {                     
        float fvlvenda, fqte;      
        int i;
// Insert global pre-action code here
        if (item == tfProduto) {                      
            if (command == LeProduto) {                    
                String url = Site + "/produtos.asp?codpro=" + tfProduto.getString();
                Conecta cn = new Conecta( url, this, 3 );
                cn.start(); 
                // Do nothing                         
            }                        
        } else if (item == tfCliente) {
            if (command == cmdLeCliente) {                      
                if ( !basealterada ) 
                   VerificaCliente();   
                else
                {
                  getDisplay().setCurrent(get_alAuxiliar());
                  this.alAuxiliar.setTitle("Pedido aberto");
                  this.alAuxiliar.setString("Há um pedido em aberto sendo digitado. Verifique, por favor.");
                  this.tfCliente.setString(this.CodClienteAtual); 
                }
                
                // Do nothing                         
                // Insert post-action code here
            }                        
        } else if (item == tfQte) {
            if (command == cmdGravar) {                      
                if (( !this.tfQte.getString().trim().equals("")) &
                    ( !this.ClienteAtual.trim().equals("")) &    
                    ( !this.tfVlVenda.getString().trim().equals("")) &
                    ( !this.tfProduto.getString().trim().equals(""))) {
                
                    registro =  this.tfProduto.getString() + " : " +
                            this.strProduto.getText()  + " : " +
                            this.tfVlVenda.getString() + " : " +
                            this.tfQte.getString()+      " :";
                    
                    //this.writeRecord( registro ); 
                    lstPedido.append(registro, null);
                    basealterada = true;                
                    fvlvenda = Float.valueOf( this.tfVlVenda.getString()).floatValue();
                    fqte = Float.valueOf( this.tfQte.getString()).floatValue();
                    this.vlitem =  this.vlitem + ( fvlvenda * fqte );
                    this.vltotal =  String.valueOf( this.vlitem ).toString();
                    this.tickerCliente.setString( this.ClienteAtual + " - Total:  " + this.vltotal );
                    this.tfVlVenda.setString("");
                    this.tfQte.setString("");
                    this.strProduto.setText("");
                    this.strPreco.setText("");
                    this.tfProduto.setString("");

                    try
                     {
                        //  getDisplay().setCurrentItem(tfProduto);
                     }
                     catch  (Exception e)
                    {
                    }
                }    
                // Do nothing                         
                // Insert post-action code here
            }                        
        } else if (item == strOpcoes) {
            if (command == cmdRelacao) {                      
                //lstPedido.deleteAll();                 
                //registros =  this.readRecords();
                //for ( i = 0; i < registros.size(); i++ )        
                //     lstPedido.append(registros.getString(i), null);
                getDisplay().setCurrent(lstPedido);                
                // Insert pre-action code here
                // Do nothing                          
                // Insert post-action code here
            } else if (command == cmdSalvaPedido) {                        
                Conecta cn = new Conecta( Site + "/cdpgt.asp", this, 5 );
                cn.start(); 
                // Do nothing                          
                // Insert post-action code here
            }                         
        }                       
    // Insert global post-action code here
}                    
    public void SalvaPedido(boolean Header, int tela, String retorno ){
      int i, acao = 0;
      String url = "";  // Inicializa a variavel para o compilador ficar contente.
      if ( Header ) 
      {
          acao = 6;
          //registros =  this.readRecords();
       
          registroemtransmissao = -1;        
          url = Site + "/salvapedido.asp?acao=1&clicod=" + this.CodClienteAtual +
                           "&" + "codped="  + this.strNrPedido.getText() +
                           "&" + "codvend=" + this.use_cod +
                           "&" + "pgtcod="  + String.valueOf(grCondPgto.getSelectedIndex() + 1).toString() +
                           "&" + "valped="  + this.vltotal.replace(',','.');
       
      }       
      else
      {
        registroemtransmissao++;
        if ( registroemtransmissao < lstPedido.size() )
        {
            acao = 6;
            registro =  this.lstPedido.getString( registroemtransmissao );
            url = Site + "/salvapedido.asp?acao=2&codped="  + this.strNrPedido.getText() +
                            "&" + "clicod=" + this.CodClienteAtual +
                            "&" + "procod=" + GetToken( registro, 1, ":").trim() +
                            "&" + "proqte=" + GetToken( registro, 4, ":").trim() +
                            "&" + "vlun="   + GetToken( registro, 3, ":").trim();
        }
        else
        {
          if ( retorno.equals("Ok"))
             {
               basealterada = false;
               this.ClienteLogado = false;
               this.tfUser.setString("");
               this.tfSenha.setString("");
               this.mensagem.setText("");
               this.tfVlVenda.setString("");
               this.tfQte.setString("");
               this.tickerCliente.setString("");
               this.strProduto.setText("");
               this.strPreco.setText("");
               this.tfCliente.setString("");
               this.tfProduto.setString("");
               lstPedido.deleteAll();
               //this.closeRecStore();
               //this.deleteRecStore();                
               //this.openRecStore();                   
               getDisplay().setCurrent( get_alFinaliza());                        
              }    
         }
     } 
     if ( !url.equals("")) {
        Conecta cn = new Conecta( url, this, acao );
        cn.start(); 
     }
   }
    
    public String GetToken( String TokenString, int TokenPos, String Delim ) {
        int x,i,j,l; 
        {
          x = i = j = 0;
          while ( i < TokenPos )
          {
             l = TokenString.length();
             j = x;
             while (( x < l ) & ( !TokenString.substring(x,x+1).equals(Delim))) x++;
             i++;
             x++;
          } 
        }
        return TokenString.substring( j, x - 1 );
    }
    public void SetRetornoServidor( int tela, String str){
        int x, i;
        if ( tela == 5 )
        {
          if ( str.equals("NotOk"))
          {
             getDisplay().setCurrent(get_alAuxiliar());
             this.alAuxiliar.setTitle("Forma de Pagamento");
             this.alAuxiliar.setString("Formas de pagamento não foram localizadas.");
          }
          else
          {
             this.retornoServidor = str;
             getDisplay().setCurrent(get_frmUpLoad());
             this.strCliente.setLabel(this.CodClienteAtual + " - ");
             this.strCliente.setText(this.ClienteAtual);
             this.strTotal.setText(vltotal);
            
             i = Integer.valueOf(GetToken( str,1,";" )).intValue() + 1;
             this.strNrPedido.setText(String.valueOf(i).toString());
            
             x = 2;
             grCondPgto.deleteAll();
             while ( !GetToken( str,x,";" ).equals(""))
             {
               this.grCondPgto.append( GetToken( str,x,";" ), null);
               x++;
             }
          }
        }
    }
    
    public void SetMensagem( int tela, String str){
         if ( tela == 1 )
         {
            if  ( str.equals("NotOk"))
            {
             this.mensagem.setText("Usuário não autorizado.");
             this.tfSenha.setString("");
             this.tfUser.setString("");
            }
            else
            {
             this.use_cod = str;
             ClienteAtual = "";
             basealterada = false;
             registrosalterados = false;             
             this.usuario = tfUser.getString();
             this.logado = true;
             //this.openRecStore();
             getDisplay().setCurrent(get_frmDigit());                        
            }
         }
         else if ( tela == 2 )
         {
            
            if  ( str.equals("NotOk"))
            {
                this.ClienteAtual = "";
                this.ClienteLogado = false;
                this.CodClienteAtual = "";
                this.tickerCliente.setString("Cliente não localizado.");
            }
            else
            {
               this.ClienteLogado = true;
               this.CodClienteAtual = this.tfCliente.getString();
               this.ClienteAtual = str;
               this.tickerCliente.setString(str + " - Total: " + vltotal );
               try
               {
                 //getDisplay().setCurrentItem( tfProduto );
               }
               catch (Exception e)
               {
               }
              // display.setCurrentItem(tfProduto);
            }
         }
          else if ( tela == 3 )
         {
            if  ( str.equals("NotOk"))
            {
                this.strPreco.setText("");
                this.strProduto.setText("Produto não localizado.");
            }
            else
            {
                this.strProduto.setText(GetToken( str, 1, ";"));
                this.strPreco.setText(GetToken( str, 2, ";"));
                try
                {
                //getDisplay().setCurrentItem(tfVlVenda);
                }
                catch  (Exception e)
                {
                }
                this.tfVlVenda.setString( GetToken( str, 2, ";").replace(',','.'));                
                this.tfQte.setString("");
            }
         }
     }
     
    
    /** Called by the system to indicate that a command has been invoked on a particular displayable.                      
     * @param command the Command that ws invoked
     * @param displayable the Displayable on which the command was invoked
     */
    public void commandAction(Command command, Displayable displayable) {                    
         float fvlvenda, fqte;
         int position;
         String nrpedido;
         if (displayable == frmLogin) {                     
             if (command == OkComand) {                   
                 VerificaSenha(); 
                 // Do nothing                        
             } else if (command == cancelCommand1) {                      
                // Insert pre-action code here
                 exitMIDlet();                       
                // Insert post-action code here
             }                      
         } else if (displayable == frmDigit) {
             if (command == cmdVoltar) {                    
                if ( basealterada ) 
                    getDisplay().setCurrent( get_alertPedido()); 
                else
                {
                    this.ClienteLogado = false;
                    this.tfUser.setString("");
                    this.tfSenha.setString("");
                    this.mensagem.setText("");
                    this.tfVlVenda.setString("");
                    this.tfQte.setString("");
                    this.tickerCliente.setString("");
                    this.strProduto.setText("");
                    this.strPreco.setText("");
                    this.tfCliente.setString("");
                    this.tfProduto.setString("");
                    getDisplay().setCurrent(get_frmLogin());
                }
                // Do nothing                        
                 // Insert post-action code here
             }                       
         } else if (displayable == lstPedido) {
             if (command == cmdExcluiItem) {                     
                // Insert pre-action code here
                lstPedido.delete(lstPedido.getSelectedIndex());
                //this.closeRecStore();
                //this.deleteRecStore();                
                //this.openRecStore();                   
                //for ( position = 0; position < lstPedido.size(); position++ )
                //     this.writeRecord( lstPedido.getString(position));
                // Do nothing                         
                // Insert post-action code here
             } else if (command == cmdEditaItem) {                       
                getDisplay().setCurrent(get_frmEdicao());                         
                registro = lstPedido.getString(lstPedido.getSelectedIndex());
                this.strProdutoAtual.setText( GetToken( registro, 2, ":").trim());
                this.vlVendaAtual.setString(GetToken( registro, 3, ":").trim());
                this.qteAtual.setString(GetToken( registro, 4, ":").trim());                

                // Do nothing                         
                // Insert post-action code here
             } else if (command == cmdVoltaDig) {                       
               if( registrosalterados ) 
                 { 
                   registrosalterados = false;
                   //this.closeRecStore();
                   //this.deleteRecStore();                
                   //this.openRecStore();                   
                   //for ( position = 0; position < lstPedido.size(); position++ )
                   //    this.writeRecord( lstPedido.getString(position));
                 }
               getDisplay().setCurrent(get_frmDigit());                         
                // Insert post-action code here
             }                        
         } else if (displayable == frmEdicao) {
             if (command == cmdVoltarRelacao) {                      
                 getDisplay().setCurrent(lstPedido);                         
                // Insert post-action code here
             } else if (command == cmdSalvaEdicao) {                       
                
                position = lstPedido.getSelectedIndex();
                registro = lstPedido.getString( position );
                lstPedido.delete( position );
                fvlvenda = Float.valueOf(GetToken( registro, 3, ":").trim()).floatValue();
                fqte =  Float.valueOf(GetToken( registro, 4, ":").trim()).floatValue();
                this.vlitem =  this.vlitem - ( fvlvenda * fqte );
                
                fvlvenda = Float.valueOf( this.vlVendaAtual.getString()).floatValue();
                fqte =  Float.valueOf( this.qteAtual.getString()).floatValue();
                this.vlitem =  this.vlitem + ( fvlvenda * fqte );

                this.vltotal =  String.valueOf( this.vlitem ).toString();
                this.tickerCliente.setString( this.ClienteAtual + " - Total:  " + this.vltotal );
                
                registronovo = GetToken( registro, 1, ":").trim() + " : " +
                     this.strProdutoAtual.getText() + " : " +
                     this.vlVendaAtual.getString() + " : " +
                     this.qteAtual.getString() + " : ";   
                lstPedido.insert(position, registronovo, null);
                registrosalterados = true;
                getDisplay().setCurrent(lstPedido);                         
                // Do nothing                         
                // Insert post-action code here
             }                        
         } else if (displayable == alertPedido) {
             if (command == cmdJogaPedidoFora) {                      
                lstPedido.deleteAll();                 

                //this.closeRecStore();

                //this.deleteRecStore();                
                
                this.ClienteLogado = false;
                this.tfUser.setString("");
                this.tfSenha.setString("");
                this.mensagem.setText("");
                this.tfVlVenda.setString("");
                this.tfQte.setString("");
                this.tickerCliente.setString("");
                this.strProduto.setText("");
                this.strPreco.setText("");
                this.tfCliente.setString("");
                this.tfProduto.setString("");
                getDisplay().setCurrent(get_frmLogin());
                 
                // Do nothing                         
                 // Insert post-action code here
             } else if (command == cmdVoltaPraDigitacao) {                       
                getDisplay().setCurrent(get_frmDigit());
                // Do nothing                         
                 // Insert post-action code here
             }                        
         } else if (displayable == frmUpLoad) {
             if (command == cmdVoltaDig) {                      
                 getDisplay().setCurrent(get_frmDigit());
                 // Do nothing                         
                 // Insert post-action code here
             } else if (command == cmdUpload) {                       
                  SalvaPedido(true, 6, "" ); 
                  // Do nothing                         
             }                        
         } else if (displayable == alFinaliza) {
             if (command == cmdFinalizada) {                      
                 // Insert pre-action code here
                 getDisplay().setCurrent(get_frmDigit());                         
                 // Insert post-action code here
             }                        
         }                      
    // Insert global post-action code here
}                   

    /** This method initializes UI of the application.                        
     */
    private void initialize() {                      
        // Insert pre-init code here
         Site = "http://127.0.0.1/wma";
         lstPedido = new List("Itens do Pedido", Choice.IMPLICIT, new String[0], new Image[0]);                       
         lstPedido.addCommand(get_cmdExcluiItem());
         lstPedido.addCommand(get_cmdEditaItem());
         lstPedido.addCommand(get_cmdVoltaDig());
         lstPedido.setCommandListener(this);
         lstPedido.setTicker(get_tickerCliente());
         lstPedido.setSelectedFlags(new boolean[0]);
         lstPedido.setSelectCommand(null);
         lstPedido.setFitPolicy(Choice.TEXT_WRAP_DEFAULT);
         strNrPedido = new StringItem("Numero Pedido:", "");
         getDisplay().setCurrent(get_frmLogin());                     
        // Insert post-init code here
    }                     
 
   private void VerificaSenha()
  {
     HttpConnection http = null;
     InputStream iStrm = null;    
     boolean ret = false;

    String url = Site + "/usuarios.asp?id=" + tfUser.getString() + "&" + "senha=" + tfSenha.getString();
    
    this.mensagem.setText("");
    
    Conecta cn = new Conecta( url, this, 1 );
    cn.start(); 
   
  }
   
   
   private void VerificaCliente()
  {
     HttpConnection http = null;
     InputStream iStrm = null;    
     boolean ret = false;

    String url = Site + "/clientes.asp?codigo=" + tfCliente.getString();
    
  
    Conecta cn = new Conecta( url, this, 2 );
    cn.start(); 
   
  }
   
    /**
     * This method should return an instance of the display.
     */
    public Display getDisplay() {                         
        return Display.getDisplay(this);
    }                        
    
    /**
     * This method should exit the midlet.
     */
    public void exitMIDlet() {                         
        getDisplay().setCurrent(null);
        destroyApp(true);
        notifyDestroyed();
    }                        
    /** This method returns instance for cancelCommand1 component and should be called instead of accessing cancelCommand1 field directly.                        
     * @return Instance for cancelCommand1 component
     */
    public Command get_cancelCommand1() {
        if (cancelCommand1 == null) {                      
            // Insert pre-init code here
            cancelCommand1 = new Command("Fechar", Command.CANCEL, 1);                      
            // Insert post-init code here
        }                      
        return cancelCommand1;
    }                    

    /** This method returns instance for OkComand component and should be called instead of accessing OkComand field directly.                         
     * @return Instance for OkComand component
     */
    public Command get_OkComand() {
        if (OkComand == null) {                       
            // Insert pre-init code here
            OkComand = new Command("Ok", Command.OK, 1);                       
            // Insert post-init code here
        }                       
        return OkComand;
    }                     

    /** This method returns instance for tfUser component and should be called instead of accessing tfUser field directly.                         
     * @return Instance for tfUser component
     */
    public TextField get_tfUser() {
        if (tfUser == null) {                       
            // Insert pre-init code here
            tfUser = new TextField("Usuario:", null, 18, TextField.ANY);                       
            // Insert post-init code here
        }                       
        return tfUser;
    }                     

    /** This method returns instance for tfSenha component and should be called instead of accessing tfSenha field directly.                         
     * @return Instance for tfSenha component
     */
    public TextField get_tfSenha() {
        if (tfSenha == null) {                       
            // Insert pre-init code here
            tfSenha = new TextField("Senha:", null, 10, TextField.NUMERIC | TextField.PASSWORD);                       
            // Insert post-init code here
        }                       
        return tfSenha;
    }                     

    /** This method returns instance for spacer1 component and should be called instead of accessing spacer1 field directly.                         
     * @return Instance for spacer1 component
     */
    public Spacer get_spacer1() {
        if (spacer1 == null) {                       
            // Insert pre-init code here
            spacer1 = new Spacer(1000, 60);                       
            // Insert post-init code here
        }                       
        return spacer1;
    }                     
 
    /** This method returns instance for frmLogin component and should be called instead of accessing frmLogin field directly.                        
     * @return Instance for frmLogin component
     */
    public Form get_frmLogin() {
        if (frmLogin == null) {                      
            // Insert pre-init code here
            frmLogin = new Form("Login", new Item[] {                       
                get_spacer1(),
                get_tfUser(),
                get_spacer3(),
                get_tfSenha(),
                get_spacer2(),
                get_mensagem()
            });
            frmLogin.addCommand(get_cancelCommand1());
            frmLogin.addCommand(get_OkComand());
            frmLogin.setCommandListener(this);                     
// Insert post-init code here
        }                      
        return frmLogin;
    }                    
 
    /** This method returns instance for spacer2 component and should be called instead of accessing spacer2 field directly.                         
     * @return Instance for spacer2 component
     */
    public Spacer get_spacer2() {
        if (spacer2 == null) {                       
            // Insert pre-init code here
            spacer2 = new Spacer(1000, 2);                       
            // Insert post-init code here
        }                       
        return spacer2;
    }                     

    /** This method returns instance for mensagem component and should be called instead of accessing mensagem field directly.                         
     * @return Instance for mensagem component
     */
    public StringItem get_mensagem() {
        if (mensagem == null) {                       
            // Insert pre-init code here
            mensagem = new StringItem("", "");                       
            // Insert post-init code here
        }                       
        return mensagem;
    }                     

    /** This method returns instance for spacer3 component and should be called instead of accessing spacer3 field directly.                         
     * @return Instance for spacer3 component
     */
    public Spacer get_spacer3() {
        if (spacer3 == null) {                       
            // Insert pre-init code here
            spacer3 = new Spacer(1000, 5);                       
            // Insert post-init code here
        }                       
        return spacer3;
    }                     
    /** This method returns instance for frmDigit component and should be called instead of accessing frmDigit field directly.                         
     * @return Instance for frmDigit component
     */
    public Form get_frmDigit() {
        if (frmDigit == null) {                       
            // Insert pre-init code here
            frmDigit = new Form(null, new Item[] {                        
                get_tfCliente(),
                get_tfProduto(),
                get_strProduto(),
                get_strPreco(),
                get_tfVlVenda(),
                get_tfQte(),
                get_strOpcoes()
            });
            frmDigit.addCommand(get_cmdVoltar());
            frmDigit.setCommandListener(this);
            frmDigit.setTicker(get_tickerCliente());                      
            // Insert post-init code here
        }                       
        return frmDigit;
    }                     

        
    /** This method returns instance for tfCliente component and should be called instead of accessing tfCliente field directly.                         
     * @return Instance for tfCliente component
     */
    public TextField get_tfCliente() {
        if (tfCliente == null) {                       
            // Insert pre-init code here
            tfCliente = new TextField("Cliente:", null, 10, TextField.NUMERIC);                        
            tfCliente.addCommand(get_cmdLeCliente());
            tfCliente.setItemCommandListener(this);                      
            // Insert post-init code here
        }                       
        return tfCliente;
    }                     
  
    
    /** This method returns instance for cmdLeCliente component and should be called instead of accessing cmdLeCliente field directly.                         
     * @return Instance for cmdLeCliente component
     */
    public Command get_cmdLeCliente() {
        if (cmdLeCliente == null) {                       
            // Insert pre-init code here
            cmdLeCliente = new Command("Cliente", Command.OK, 1);                       
            // Insert post-init code here
        }                       
        return cmdLeCliente;
    }                     
  
    /** This method returns instance for tfProduto component and should be called instead of accessing tfProduto field directly.                         
     * @return Instance for tfProduto component
     */
    public TextField get_tfProduto() {
        if (tfProduto == null) {                       
            // Insert pre-init code here
            tfProduto = new TextField("Produto:", null, 10, TextField.NUMERIC);                        
            tfProduto.addCommand(get_LeProduto());
            tfProduto.setItemCommandListener(this);                      
            // Insert post-init code here
        }                       
        return tfProduto;
    }                     

    /** This method returns instance for tickerCliente component and should be called instead of accessing tickerCliente field directly.                         
     * @return Instance for tickerCliente component
     */
    public Ticker get_tickerCliente() {
        if (tickerCliente == null) {                       
            // Insert pre-init code here
            tickerCliente = new Ticker("");                       
            // Insert post-init code here
        }                       
        return tickerCliente;
    }                     
 
    /** This method returns instance for LeProduto component and should be called instead of accessing LeProduto field directly.                         
     * @return Instance for LeProduto component
     */
    public Command get_LeProduto() {
        if (LeProduto == null) {                       
            // Insert pre-init code here
            LeProduto = new Command("Produto", Command.OK, 1);                       
            // Insert post-init code here
        }                       
        return LeProduto;
    }                     

    /** This method returns instance for strProduto component and should be called instead of accessing strProduto field directly.                         
     * @return Instance for strProduto component
     */
    public StringItem get_strProduto() {
        if (strProduto == null) {                       
            // Insert pre-init code here
            strProduto = new StringItem("Descricao:", "");                        
            strProduto.setFont(get_fPequena());                      
            // Insert post-init code here
        }                       
        return strProduto;
    }                     
    /** This method returns instance for strPreco component and should be called instead of accessing strPreco field directly.                         
     * @return Instance for strPreco component
     */
    public StringItem get_strPreco() {
        if (strPreco == null) {                       
            // Insert pre-init code here
            strPreco = new StringItem("Pre\u00E7o:", "");                        
            strPreco.setFont(get_fPequena());                      
            // Insert post-init code here
        }                       
        return strPreco;
    }                     

    /** This method returns instance for tfVlVenda component and should be called instead of accessing tfVlVenda field directly.                         
     * @return Instance for tfVlVenda component
     */
    public TextField get_tfVlVenda() {
        if (tfVlVenda == null) {                       
            // Insert pre-init code here
            tfVlVenda = new TextField("Valor:", "", 10, TextField.DECIMAL);                       
            // Insert post-init code here
        }                       
        return tfVlVenda;
    }                     

    /** This method returns instance for cmdVoltar component and should be called instead of accessing cmdVoltar field directly.                         
     * @return Instance for cmdVoltar component
     */
    public Command get_cmdVoltar() {
        if (cmdVoltar == null) {                       
            // Insert pre-init code here
            cmdVoltar = new Command("Voltar", Command.BACK, 2);                       
            // Insert post-init code here
        }                       
        return cmdVoltar;
    }                     

    /** This method returns instance for fPequena component and should be called instead of accessing fPequena field directly.                         
     * @return Instance for fPequena component
     */
    public Font get_fPequena() {
        if (fPequena == null) {                       
            // Insert pre-init code here
            fPequena = Font.getFont(Font.FACE_SYSTEM, 0x0, Font.SIZE_SMALL);                       
            // Insert post-init code here
        }                       
        return fPequena;
    }                     

    /** This method returns instance for tfQte component and should be called instead of accessing tfQte field directly.                         
     * @return Instance for tfQte component
     */
    public TextField get_tfQte() {
        if (tfQte == null) {                       
            // Insert pre-init code here
            tfQte = new TextField("Qte:", null, 4, TextField.NUMERIC);                        
            tfQte.addCommand(get_cmdGravar());
            tfQte.setItemCommandListener(this);                      
            // Insert post-init code here
        }                       
        return tfQte;
    }                     

    /** This method returns instance for cmdGravar component and should be called instead of accessing cmdGravar field directly.                         
     * @return Instance for cmdGravar component
     */
    public Command get_cmdGravar() {
        if (cmdGravar == null) {                       
            // Insert pre-init code here
            cmdGravar = new Command("Gravar", Command.SCREEN, 1);                       
            // Insert post-init code here
        }                       
        return cmdGravar;
    }                     

    /** This method returns instance for cmdRelacao component and should be called instead of accessing cmdRelacao field directly.                         
     * @return Instance for cmdRelacao component
     */
    public Command get_cmdRelacao() {
        if (cmdRelacao == null) {                       
            // Insert pre-init code here
            cmdRelacao = new Command("Rela\u00E7\u00E3o", Command.OK, 1);                       
            // Insert post-init code here
        }                       
        return cmdRelacao;
    }                     
 
    /** This method returns instance for cmdFechaRelacao component and should be called instead of accessing cmdFechaRelacao field directly.                         
     * @return Instance for cmdFechaRelacao component
     */
    public Command get_cmdFechaRelacao() {
        if (cmdFechaRelacao == null) {                       
            // Insert pre-init code here
            cmdFechaRelacao = new Command("Voltar", Command.CANCEL, 2);                       
            // Insert post-init code here
        }                       
        return cmdFechaRelacao;
    }                     

    /** This method returns instance for cmdSalvaPedido component and should be called instead of accessing cmdSalvaPedido field directly.                         
     * @return Instance for cmdSalvaPedido component
     */
    public Command get_cmdSalvaPedido() {
        if (cmdSalvaPedido == null) {                       
            // Insert pre-init code here
            cmdSalvaPedido = new Command("Salva Pedido", Command.SCREEN, 1);                       
            // Insert post-init code here
        }                       
        return cmdSalvaPedido;
    }                     

    /** This method returns instance for cmdExcluiItem component and should be called instead of accessing cmdExcluiItem field directly.                         
     * @return Instance for cmdExcluiItem component
     */
    public Command get_cmdExcluiItem() {
        if (cmdExcluiItem == null) {                       
            // Insert pre-init code here
            cmdExcluiItem = new Command("Excluir", Command.SCREEN, 1);                       
            // Insert post-init code here
        }                       
        return cmdExcluiItem;
    }                     

    /** This method returns instance for cmdEditaItem component and should be called instead of accessing cmdEditaItem field directly.                         
     * @return Instance for cmdEditaItem component
     */
    public Command get_cmdEditaItem() {
        if (cmdEditaItem == null) {                       
            // Insert pre-init code here
            cmdEditaItem = new Command("Alterar", Command.SCREEN, 1);                       
            // Insert post-init code here
        }                       
        return cmdEditaItem;
    }                     

    /** This method returns instance for cmdVoltaDig component and should be called instead of accessing cmdVoltaDig field directly.                          
     * @return Instance for cmdVoltaDig component
     */
    public Command get_cmdVoltaDig() {
        if (cmdVoltaDig == null) {                        
            // Insert pre-init code here
            cmdVoltaDig = new Command("Voltar", Command.BACK, 2);                        
            // Insert post-init code here
        }                        
        return cmdVoltaDig;
    }                      

    /** This method returns instance for frmEdicao component and should be called instead of accessing frmEdicao field directly.                          
     * @return Instance for frmEdicao component
     */
    public Form get_frmEdicao() {
        if (frmEdicao == null) {                        
            // Insert pre-init code here
            frmEdicao = new Form("Edi\u00E7\u00E3o Produto:", new Item[] {                         
                get_strProdutoAtual(),
                get_vlVendaAtual(),
                get_qteAtual()
            });
            frmEdicao.addCommand(get_cmdVoltarRelacao());
            frmEdicao.addCommand(get_cmdSalvaEdicao());
            frmEdicao.setCommandListener(this);
            frmEdicao.setTicker(get_tickerCliente());                       
            // Insert post-init code here
        }                        
        return frmEdicao;
    }                      

    /** This method returns instance for strProdutoAtual component and should be called instead of accessing strProdutoAtual field directly.                          
     * @return Instance for strProdutoAtual component
     */
    public StringItem get_strProdutoAtual() {
        if (strProdutoAtual == null) {                        
            // Insert pre-init code here
            strProdutoAtual = new StringItem("", "");                        
            // Insert post-init code here
        }                        
        return strProdutoAtual;
    }                      

    /** This method returns instance for vlVendaAtual component and should be called instead of accessing vlVendaAtual field directly.                          
     * @return Instance for vlVendaAtual component
     */
    public TextField get_vlVendaAtual() {
        if (vlVendaAtual == null) {                        
            // Insert pre-init code here
            vlVendaAtual = new TextField("Valor de Venda:", null, 15, TextField.DECIMAL);                        
            // Insert post-init code here
        }                        
        return vlVendaAtual;
    }                      

    /** This method returns instance for qteAtual component and should be called instead of accessing qteAtual field directly.                          
     * @return Instance for qteAtual component
     */
    public TextField get_qteAtual() {
        if (qteAtual == null) {                        
            // Insert pre-init code here
            qteAtual = new TextField("Qte:", null, 10, TextField.NUMERIC);                        
            // Insert post-init code here
        }                        
        return qteAtual;
    }                      

    /** This method returns instance for cmdVoltarRelacao component and should be called instead of accessing cmdVoltarRelacao field directly.                          
     * @return Instance for cmdVoltarRelacao component
     */
    public Command get_cmdVoltarRelacao() {
        if (cmdVoltarRelacao == null) {                        
            // Insert pre-init code here
            cmdVoltarRelacao = new Command("Voltar", Command.BACK, 2);                        
            // Insert post-init code here
        }                        
        return cmdVoltarRelacao;
    }                      

    /** This method returns instance for cmdSalvaEdicao component and should be called instead of accessing cmdSalvaEdicao field directly.                          
     * @return Instance for cmdSalvaEdicao component
     */
    public Command get_cmdSalvaEdicao() {
        if (cmdSalvaEdicao == null) {                        
            // Insert pre-init code here
            cmdSalvaEdicao = new Command("Salvar", Command.OK, 1);                        
            // Insert post-init code here
        }                        
        return cmdSalvaEdicao;
    }                      

    /** This method returns instance for alertPedido component and should be called instead of accessing alertPedido field directly.                          
     * @return Instance for alertPedido component
     */
    public Alert get_alertPedido() {
        if (alertPedido == null) {                        
            // Insert pre-init code here
            alertPedido = new Alert("Confirma\u00E7\u00E3o", "O pedido ainda n\u00E3o foi salvo. Tem certeza de que n\u00E3o deseja salva-lo?", null, AlertType.CONFIRMATION);                         
            alertPedido.addCommand(get_cmdJogaPedidoFora());
            alertPedido.addCommand(get_cmdVoltaPraDigitacao());
            alertPedido.setCommandListener(this);
            alertPedido.setTimeout(-2);                       
            // Insert post-init code here
        }                        
        return alertPedido;
    }                      

    /** This method returns instance for cmdJogaPedidoFora component and should be called instead of accessing cmdJogaPedidoFora field directly.                          
     * @return Instance for cmdJogaPedidoFora component
     */
    public Command get_cmdJogaPedidoFora() {
        if (cmdJogaPedidoFora == null) {                        
            // Insert pre-init code here
            cmdJogaPedidoFora = new Command("N\u00E3o Salva", Command.OK, 1);                        
            // Insert post-init code here
        }                        
        return cmdJogaPedidoFora;
    }                      

    /** This method returns instance for cmdVoltaPraDigitacao component and should be called instead of accessing cmdVoltaPraDigitacao field directly.                          
     * @return Instance for cmdVoltaPraDigitacao component
     */
    public Command get_cmdVoltaPraDigitacao() {
        if (cmdVoltaPraDigitacao == null) {                        
            // Insert pre-init code here
            cmdVoltaPraDigitacao = new Command("Cancelar", Command.BACK, 2);                        
            // Insert post-init code here
        }                        
        return cmdVoltaPraDigitacao;
    }                      

    /** This method returns instance for frmUpLoad component and should be called instead of accessing frmUpLoad field directly.                          
     * @return Instance for frmUpLoad component
     */
    public Form get_frmUpLoad() {
        if (frmUpLoad == null) {                        
            // Insert pre-init code here
            frmUpLoad = new Form("Salva pedidos", new Item[] {                         
                get_strCliente(),
                strNrPedido,
                get_strTotal(),
                get_grCondPgto()
            });
            frmUpLoad.addCommand(get_cmdVoltaDig());
            frmUpLoad.addCommand(get_cmdUpload());
            frmUpLoad.setCommandListener(this);                       
            // Insert post-init code here
        }                        
        return frmUpLoad;
    }                      

    /** This method returns instance for strCliente component and should be called instead of accessing strCliente field directly.                          
     * @return Instance for strCliente component
     */
    public StringItem get_strCliente() {
        if (strCliente == null) {                        
            // Insert pre-init code here
            strCliente = new StringItem("", "");                        
            // Insert post-init code here
        }                        
        return strCliente;
    }                      

    /** This method returns instance for strTotal component and should be called instead of accessing strTotal field directly.                          
     * @return Instance for strTotal component
     */
    public StringItem get_strTotal() {
        if (strTotal == null) {                        
            // Insert pre-init code here
            strTotal = new StringItem("Valor Total Pedido:", "");                        
            // Insert post-init code here
        }                        
        return strTotal;
    }                      

    /** This method returns instance for grCondPgto component and should be called instead of accessing grCondPgto field directly.                          
     * @return Instance for grCondPgto component
     */
    public ChoiceGroup get_grCondPgto() {
        if (grCondPgto == null) {                        
            // Insert pre-init code here
            grCondPgto = new ChoiceGroup("Condi\u00E7\u00E3o Pagamento:", Choice.EXCLUSIVE, new String[0], new Image[0]);                         
            grCondPgto.setSelectedFlags(new boolean[0]);                       
            // Insert post-init code here
        }                        
        return grCondPgto;
    }                      

    /** This method returns instance for cmdUpload component and should be called instead of accessing cmdUpload field directly.                          
     * @return Instance for cmdUpload component
     */
    public Command get_cmdUpload() {
        if (cmdUpload == null) {                        
            // Insert pre-init code here
            cmdUpload = new Command("Transmite", Command.OK, 1);                        
            // Insert post-init code here
        }                        
        return cmdUpload;
    }                      
 
    /** This method returns instance for alAuxiliar component and should be called instead of accessing alAuxiliar field directly.                          
     * @return Instance for alAuxiliar component
     */
    public Alert get_alAuxiliar() {
        if (alAuxiliar == null) {                        
            // Insert pre-init code here
            alAuxiliar = new Alert("", "", null, AlertType.ERROR);                         
            alAuxiliar.setTimeout(-2);                       
            // Insert post-init code here
        }                        
        return alAuxiliar;
    }                      
 
    /** This method returns instance for strOpcoes component and should be called instead of accessing strOpcoes field directly.                          
     * @return Instance for strOpcoes component
     */
    public StringItem get_strOpcoes() {
        if (strOpcoes == null) {                        
            // Insert pre-init code here
            strOpcoes = new StringItem("Outras op\u00E7oes", "");                         
            strOpcoes.addCommand(get_cmdRelacao());
            strOpcoes.addCommand(get_cmdSalvaPedido());
            strOpcoes.setItemCommandListener(this);
            strOpcoes.setDefaultCommand(get_cmdRelacao());
            strOpcoes.setFont(get_fPequena());                       
            // Insert post-init code here
        }                        
        return strOpcoes;
    }                      

    /** This method returns instance for alFinaliza component and should be called instead of accessing alFinaliza field directly.                          
     * @return Instance for alFinaliza component
     */
    public Alert get_alFinaliza() {
        if (alFinaliza == null) {                        
            // Insert pre-init code here
            alFinaliza = new Alert("Transmiss\u00E3o", "    Transmiss\u00E3o finalizada com sucesso.", null, AlertType.INFO);                         
            alFinaliza.addCommand(get_cmdFinalizada());
            alFinaliza.setCommandListener(this);
            alFinaliza.setTimeout(-2);                       
            // Insert post-init code here
        }                        
        return alFinaliza;
    }                      

    /** This method returns instance for cmdFinalizada component and should be called instead of accessing cmdFinalizada field directly.                          
     * @return Instance for cmdFinalizada component
     */
    public Command get_cmdFinalizada() {
        if (cmdFinalizada == null) {                        
            // Insert pre-init code here
            cmdFinalizada = new Command("Voltar", Command.OK, 1);                        
            // Insert post-init code here
        }                        
        return cmdFinalizada;
    }                      
     /** This method returns instance for svgImage1 component and should be called instead of accessing svgImage1 field directly.                          
     * @return Instance for svgImage1 component
     */
    public javax.microedition.m2g.SVGImage get_svgImage1() {
        if (svgImage1 == null) {                        
            // Insert pre-init code here
            try {                         
                svgImage1 = (javax.microedition.m2g.SVGImage) javax.microedition.m2g.SVGImage.createImage((String) null, null);
            } catch (java.io.IOException exception) {
                exception.printStackTrace();
            }                       
            // Insert post-init code here
        }                        
        return svgImage1;
    }                      
 
        
    
    public void startApp() {
    }
    
    
    public void pauseApp() {
    }
    
    public void destroyApp(boolean unconditional) {
    }
    
    
    
    
   public void openRecStore()
   {
    try
    {
      rs = RecordStore. openRecordStore(REC_STORE, true );
    }
    catch (Exception e)
    {
      db(e.toString());
    }
  }    
  
  public void closeRecStore()
  {
    try
    {
      rs.closeRecordStore();
    }
    catch (Exception e)
    {
      db(e.toString());
    }
  }

  public void deleteRecStore()
  {
    if (RecordStore.listRecordStores() != null)
    {
      try
      {
        RecordStore.deleteRecordStore(REC_STORE);
      }
      catch (Exception e)
      {
        db(e.toString());
      }
    }      
  }

  public void writeRecord(String str)
  {
    byte[] rec = str.getBytes();

    try
    {
      rs.addRecord(rec, 0, rec.length);
    }
    catch (Exception e)
    {
      db(e.toString());
    }
  }

  public List readRecords()
  {
    String record;
    List v= new List("Itens:", List.IMPLICIT);
    try
    {
      // Intentionally make this too small to test code below
      byte[] recData = new byte[5]; 
      int len;

      for (int i = 1; i <= rs.getNumRecords(); i++)      
      {
        if (rs.getRecordSize(i) > recData.length)
          recData = new byte[rs.getRecordSize(i)];
       
        len = rs.getRecord(i, recData, 0);
        record =  new String(recData, 0, len);
        v.append(record.toString(), null);
      }
    }
    catch (Exception e)
    {
      db(e.toString());
    }
    return v;
  }
  
  private void db(String str)
  {
    System.err.println("Msg: " + str);
  }
}

/*
 * Conecta
 *
 * Created on 5 de Novembro de 2007, 15:00
 */


class Conecta implements Runnable
{
  private int tela;
  private String url;
  private boolean downloadSuccess = false;  
  private String errorMsg = null;
  public String mensagem;
  private mPedidos MIDlet;
  
  public Conecta(String url, mPedidos MIDlet, int tela )
  { 
    this.url = url;
    this.MIDlet = MIDlet;
    this.tela = tela;
    
  }

  public void run() 
  {
    try
    {
      ConsultaServidor(url);
    }
    catch (Exception e)
    { 
      System.err.println("Msg: " + e.toString());
    }      
  }
  public void start()
  {
    Thread thread = new Thread(this);
    try
    {
      thread.start();
    }
    catch (Exception e)
    {
    }
  }
  
  private void ConsultaServidor(String url) throws IOException
  {
    HttpConnection http = null;
    InputStream iStrm = null;    
    boolean ret = false;
                 
    try
    {
      	http = (HttpConnection) Connector.open(url);
      	http.setRequestMethod(HttpConnection.GET);
      	iStrm = http.openInputStream();      
      	ret = processServerResponse(http, iStrm);
    }
    finally
    {
      // Clean up
      if (iStrm != null)
        iStrm.close();
      if (http != null)
        http.close();
    }
  }

  private boolean processServerResponse(HttpConnection http, InputStream iStrm) throws IOException
  {
    errorMsg = null;
    if (http.getResponseCode() == HttpConnection.HTTP_OK)
    {
      int length = (int) http.getLength();
      String str;
      if (length != -1)
      {
        byte servletData[] = new byte[length];
        iStrm.read(servletData);
        str = new String(servletData);
      }
      else  // Length not available...
      {
        ByteArrayOutputStream bStrm = new ByteArrayOutputStream();
        
        int ch;
        while ((ch = iStrm.read()) != -1)
          bStrm.write(ch);

        str = new String(bStrm.toByteArray());
        bStrm.close();
      }
      
      this.mensagem = str;
      if ( tela < 5 )
         MIDlet.SetMensagem( tela, str );
      else
      {
         if ( tela == 5 )
           MIDlet.SetRetornoServidor(tela, str );
         else
           MIDlet.SalvaPedido(false, tela, str );
      }
     
     return true;
    }
    else
      errorMsg = new String( http.getResponseMessage());

    return false;      
  }
} 

[]'s

/*

  • mPedidos.java
  • Created on 1 de Novembro de 2007, 15:00
    */

package pMain;

import javax.microedition.rms.;
import javax.microedition.midlet.
;
import javax.microedition.lcdui.;
import javax.microedition.io.
;
import java.io.;
import java.util.
;

/**
*

  • @author reginaldo
    */
    public class mPedidos extends MIDlet implements CommandListener, ItemCommandListener {

    private Command aboutCommand;

    /** Creates a new instance of mPedidos */
    public mPedidos() {
    initialize();
    }

    Display display;
    private Random random;
    private String Site;
    private Form frmLogin;
    private Command cancelCommand1;
    private Command OkComand;
    private TextField tfUser;
    private TextField tfSenha;
    private Spacer spacer1;
    private Spacer spacer2;
    private StringItem mensagem;
    private Spacer spacer3;
    private Form frmDigit;
    private TextField tfCliente;
    private Command cmdLeCliente;
    private TextField tfProduto;
    private Ticker tickerCliente;
    private Command LeProduto;
    private StringItem strProduto;
    private StringItem strPreco;
    private TextField tfVlVenda;
    private Command cmdVoltar;
    private Font fPequena;
    private TextField tfQte;
    private Command cmdGravar;
    private Command cmdRelacao;
    private Command cmdFechaRelacao;
    private Command cmdSalvaPedido;
    private Command cmdExcluiItem;
    private Command cmdEditaItem;
    private List lstPedido;
    private Command cmdVoltaDig;
    private Form frmEdicao;
    private StringItem strProdutoAtual;
    private TextField vlVendaAtual;
    private TextField qteAtual;
    private Command cmdVoltarRelacao;
    private Command cmdSalvaEdicao;
    private Alert alertPedido;
    private Command cmdJogaPedidoFora;
    private Command cmdVoltaPraDigitacao;
    private Form frmUpLoad;
    private StringItem strCliente;
    private StringItem strTotal;
    private ChoiceGroup grCondPgto;
    private Command cmdUpload;
    private StringItem strNrPedido;
    private Alert alAuxiliar;
    private StringItem strOpcoes;
    private Alert alFinaliza;
    private Command cmdFinalizada;
    private javax.microedition.m2g.SVGImage svgImage1;
    public boolean ClienteLogado = false;
    private boolean logado = false;
    private RecordStore rs = null;
    static final String REC_STORE = “pedidosdb”;
    private String registro;
    private String registronovo;
    private String usuario;
    private float vlitem;
    private String vltotal = “0.00”;
    private String ClienteAtual;
    private List registros;
    private String CodClienteAtual;
    private boolean basealterada = false;
    private boolean registrosalterados = false;
    private String use_cod;
    public String retornoServidor;
    public int registroemtransmissao;

    /** Called by the system to indicate that a command has been invoked on a particular item.

    • @param command the Command that ws invoked

    • @param item the Item on which the command was invoked
      */
      public void commandAction(Command command, Item item) {
      float fvlvenda, fqte;
      int i;
      // Insert global pre-action code here
      if (item == tfProduto) {
      if (command == LeProduto) {
      String url = Site + “/produtos.asp?codpro=” + tfProduto.getString();
      Conecta cn = new Conecta( url, this, 3 );
      cn.start();
      // Do nothing
      }
      } else if (item == tfCliente) {
      if (command == cmdLeCliente) {
      if ( !basealterada )
      VerificaCliente();
      else
      {
      getDisplay().setCurrent(get_alAuxiliar());
      this.alAuxiliar.setTitle(“Pedido aberto”);
      this.alAuxiliar.setString(“Há um pedido em aberto sendo digitado. Verifique, por favor.”);
      this.tfCliente.setString(this.CodClienteAtual);
      }

           // Do nothing                         
           // Insert post-action code here
       }                        
      

      } else if (item == tfQte) {
      if (command == cmdGravar) {
      if (( !this.tfQte.getString().trim().equals("")) &
      ( !this.ClienteAtual.trim().equals("")) &
      ( !this.tfVlVenda.getString().trim().equals("")) &
      ( !this.tfProduto.getString().trim().equals(""))) {

               registro =  this.tfProduto.getString() + " : " +
                       this.strProduto.getText()  + " : " +
                       this.tfVlVenda.getString() + " : " +
                       this.tfQte.getString()+      " :";
               
               //this.writeRecord( registro ); 
               lstPedido.append(registro, null);
               basealterada = true;                
               fvlvenda = Float.valueOf( this.tfVlVenda.getString()).floatValue();
               fqte = Float.valueOf( this.tfQte.getString()).floatValue();
               this.vlitem =  this.vlitem + ( fvlvenda * fqte );
               this.vltotal =  String.valueOf( this.vlitem ).toString();
               this.tickerCliente.setString( this.ClienteAtual + " - Total:  " + this.vltotal );
               this.tfVlVenda.setString("");
               this.tfQte.setString("");
               this.strProduto.setText("");
               this.strPreco.setText("");
               this.tfProduto.setString("");
      
               try
                {
                   //  getDisplay().setCurrentItem(tfProduto);
                }
                catch  (Exception e)
               {
               }
           }    
           // Do nothing                         
           // Insert post-action code here
       }                        
      

      } else if (item == strOpcoes) {
      if (command == cmdRelacao) {
      //lstPedido.deleteAll();
      //registros = this.readRecords();
      //for ( i = 0; i < registros.size(); i++ )
      // lstPedido.append(registros.getString(i), null);
      getDisplay().setCurrent(lstPedido);
      // Insert pre-action code here
      // Do nothing
      // Insert post-action code here
      } else if (command == cmdSalvaPedido) {
      Conecta cn = new Conecta( Site + “/cdpgt.asp”, this, 5 );
      cn.start();
      // Do nothing
      // Insert post-action code here
      }
      }
      // Insert global post-action code here
      }
      public void SalvaPedido(boolean Header, int tela, String retorno ){
      int i, acao = 0;
      String url = “”; // Inicializa a variavel para o compilador ficar contente.
      if ( Header )
      {
      acao = 6;
      //registros = this.readRecords();

      registroemtransmissao = -1;
      url = Site + “/salvapedido.asp?acao=1&clicod=” + this.CodClienteAtual +
      “&” + “codped=” + this.strNrPedido.getText() +
      “&” + “codvend=” + this.use_cod +
      “&” + “pgtcod=” + String.valueOf(grCondPgto.getSelectedIndex() + 1).toString() +
      “&” + “valped=” + this.vltotal.replace(’,’,’.’);

    }
    else
    {
    registroemtransmissao++;
    if ( registroemtransmissao < lstPedido.size() )
    {
    acao = 6;
    registro = this.lstPedido.getString( registroemtransmissao );
    url = Site + “/salvapedido.asp?acao=2&codped=” + this.strNrPedido.getText() +
    “&” + “clicod=” + this.CodClienteAtual +
    “&” + “procod=” + GetToken( registro, 1, “:”).trim() +
    “&” + “proqte=” + GetToken( registro, 4, “:”).trim() +
    “&” + “vlun=” + GetToken( registro, 3, “:”).trim();
    }
    else
    {
    if ( retorno.equals(“Ok”))
    {
    basealterada = false;
    this.ClienteLogado = false;
    this.tfUser.setString("");
    this.tfSenha.setString("");
    this.mensagem.setText("");
    this.tfVlVenda.setString("");
    this.tfQte.setString("");
    this.tickerCliente.setString("");
    this.strProduto.setText("");
    this.strPreco.setText("");
    this.tfCliente.setString("");
    this.tfProduto.setString("");
    lstPedido.deleteAll();
    //this.closeRecStore();
    //this.deleteRecStore();
    //this.openRecStore();
    getDisplay().setCurrent( get_alFinaliza());
    }
    }
    }
    if ( !url.equals("")) {
    Conecta cn = new Conecta( url, this, acao );
    cn.start();
    }
    }

    public String GetToken( String TokenString, int TokenPos, String Delim ) {
    int x,i,j,l;
    {
    x = i = j = 0;
    while ( i < TokenPos )
    {
    l = TokenString.length();
    j = x;
    while (( x < l ) & ( !TokenString.substring(x,x+1).equals(Delim))) x++;
    i++;
    x++;
    }
    }
    return TokenString.substring( j, x - 1 );
    }
    public void SetRetornoServidor( int tela, String str){
    int x, i;
    if ( tela == 5 )
    {
    if ( str.equals(“NotOk”))
    {
    getDisplay().setCurrent(get_alAuxiliar());
    this.alAuxiliar.setTitle(“Forma de Pagamento”);
    this.alAuxiliar.setString(“Formas de pagamento não foram localizadas.”);
    }
    else
    {
    this.retornoServidor = str;
    getDisplay().setCurrent(get_frmUpLoad());
    this.strCliente.setLabel(this.CodClienteAtual + " - ");
    this.strCliente.setText(this.ClienteAtual);
    this.strTotal.setText(vltotal);

          i = Integer.valueOf(GetToken( str,1,";" )).intValue() + 1;
          this.strNrPedido.setText(String.valueOf(i).toString());
         
          x = 2;
          grCondPgto.deleteAll();
          while ( !GetToken( str,x,";" ).equals(""))
          {
            this.grCondPgto.append( GetToken( str,x,";" ), null);
            x++;
          }
       }
     }
    

    }

    public void SetMensagem( int tela, String str){
    if ( tela == 1 )
    {
    if ( str.equals(“NotOk”))
    {
    this.mensagem.setText(“Usuário não autorizado.”);
    this.tfSenha.setString("");
    this.tfUser.setString("");
    }
    else
    {
    this.use_cod = str;
    ClienteAtual = “”;
    basealterada = false;
    registrosalterados = false;
    this.usuario = tfUser.getString();
    this.logado = true;
    //this.openRecStore();
    getDisplay().setCurrent(get_frmDigit());
    }
    }
    else if ( tela == 2 )
    {

         if  ( str.equals("NotOk"))
         {
             this.ClienteAtual = "";
             this.ClienteLogado = false;
             this.CodClienteAtual = "";
             this.tickerCliente.setString("Cliente não localizado.");
         }
         else
         {
            this.ClienteLogado = true;
            this.CodClienteAtual = this.tfCliente.getString();
            this.ClienteAtual = str;
            this.tickerCliente.setString(str + " - Total: " + vltotal );
            try
            {
              //getDisplay().setCurrentItem( tfProduto );
            }
            catch (Exception e)
            {
            }
           // display.setCurrentItem(tfProduto);
         }
      }
       else if ( tela == 3 )
      {
         if  ( str.equals("NotOk"))
         {
             this.strPreco.setText("");
             this.strProduto.setText("Produto não localizado.");
         }
         else
         {
             this.strProduto.setText(GetToken( str, 1, ";"));
             this.strPreco.setText(GetToken( str, 2, ";"));
             try
             {
             //getDisplay().setCurrentItem(tfVlVenda);
             }
             catch  (Exception e)
             {
             }
             this.tfVlVenda.setString( GetToken( str, 2, ";").replace(',','.'));                
             this.tfQte.setString("");
         }
      }
    

    }

    /** Called by the system to indicate that a command has been invoked on a particular displayable.

    • @param command the Command that ws invoked

    • @param displayable the Displayable on which the command was invoked
      */
      public void commandAction(Command command, Displayable displayable) {
      float fvlvenda, fqte;
      int position;
      String nrpedido;
      if (displayable == frmLogin) {
      if (command == OkComand) {
      VerificaSenha();
      // Do nothing
      } else if (command == cancelCommand1) {
      // Insert pre-action code here
      exitMIDlet();
      // Insert post-action code here
      }
      } else if (displayable == frmDigit) {
      if (command == cmdVoltar) {
      if ( basealterada )
      getDisplay().setCurrent( get_alertPedido());
      else
      {
      this.ClienteLogado = false;
      this.tfUser.setString("");
      this.tfSenha.setString("");
      this.mensagem.setText("");
      this.tfVlVenda.setString("");
      this.tfQte.setString("");
      this.tickerCliente.setString("");
      this.strProduto.setText("");
      this.strPreco.setText("");
      this.tfCliente.setString("");
      this.tfProduto.setString("");
      getDisplay().setCurrent(get_frmLogin());
      }
      // Do nothing
      // Insert post-action code here
      }
      } else if (displayable == lstPedido) {
      if (command == cmdExcluiItem) {
      // Insert pre-action code here
      lstPedido.delete(lstPedido.getSelectedIndex());
      //this.closeRecStore();
      //this.deleteRecStore();
      //this.openRecStore();
      //for ( position = 0; position < lstPedido.size(); position++ )
      // this.writeRecord( lstPedido.getString(position));
      // Do nothing
      // Insert post-action code here
      } else if (command == cmdEditaItem) {
      getDisplay().setCurrent(get_frmEdicao());
      registro = lstPedido.getString(lstPedido.getSelectedIndex());
      this.strProdutoAtual.setText( GetToken( registro, 2, “:”).trim());
      this.vlVendaAtual.setString(GetToken( registro, 3, “:”).trim());
      this.qteAtual.setString(GetToken( registro, 4, “:”).trim());

           // Do nothing                         
           // Insert post-action code here
        } else if (command == cmdVoltaDig) {                       
          if( registrosalterados ) 
            { 
              registrosalterados = false;
              //this.closeRecStore();
              //this.deleteRecStore();                
              //this.openRecStore();                   
              //for ( position = 0; position < lstPedido.size(); position++ )
              //    this.writeRecord( lstPedido.getString(position));
            }
          getDisplay().setCurrent(get_frmDigit());                         
           // Insert post-action code here
        }                        
      

      } else if (displayable == frmEdicao) {
      if (command == cmdVoltarRelacao) {
      getDisplay().setCurrent(lstPedido);
      // Insert post-action code here
      } else if (command == cmdSalvaEdicao) {

           position = lstPedido.getSelectedIndex();
           registro = lstPedido.getString( position );
           lstPedido.delete( position );
           fvlvenda = Float.valueOf(GetToken( registro, 3, ":").trim()).floatValue();
           fqte =  Float.valueOf(GetToken( registro, 4, ":").trim()).floatValue();
           this.vlitem =  this.vlitem - ( fvlvenda * fqte );
           
           fvlvenda = Float.valueOf( this.vlVendaAtual.getString()).floatValue();
           fqte =  Float.valueOf( this.qteAtual.getString()).floatValue();
           this.vlitem =  this.vlitem + ( fvlvenda * fqte );
      
           this.vltotal =  String.valueOf( this.vlitem ).toString();
           this.tickerCliente.setString( this.ClienteAtual + " - Total:  " + this.vltotal );
           
           registronovo = GetToken( registro, 1, ":").trim() + " : " +
                this.strProdutoAtual.getText() + " : " +
                this.vlVendaAtual.getString() + " : " +
                this.qteAtual.getString() + " : ";   
           lstPedido.insert(position, registronovo, null);
           registrosalterados = true;
           getDisplay().setCurrent(lstPedido);                         
           // Do nothing                         
           // Insert post-action code here
        }                        
      

      } else if (displayable == alertPedido) {
      if (command == cmdJogaPedidoFora) {
      lstPedido.deleteAll();

           //this.closeRecStore();
      
           //this.deleteRecStore();                
           
           this.ClienteLogado = false;
           this.tfUser.setString("");
           this.tfSenha.setString("");
           this.mensagem.setText("");
           this.tfVlVenda.setString("");
           this.tfQte.setString("");
           this.tickerCliente.setString("");
           this.strProduto.setText("");
           this.strPreco.setText("");
           this.tfCliente.setString("");
           this.tfProduto.setString("");
           getDisplay().setCurrent(get_frmLogin());
            
           // Do nothing                         
            // Insert post-action code here
        } else if (command == cmdVoltaPraDigitacao) {                       
           getDisplay().setCurrent(get_frmDigit());
           // Do nothing                         
            // Insert post-action code here
        }                        
      

      } else if (displayable == frmUpLoad) {
      if (command == cmdVoltaDig) {
      getDisplay().setCurrent(get_frmDigit());
      // Do nothing
      // Insert post-action code here
      } else if (command == cmdUpload) {
      SalvaPedido(true, 6, “” );
      // Do nothing
      }
      } else if (displayable == alFinaliza) {
      if (command == cmdFinalizada) {
      // Insert pre-action code here
      getDisplay().setCurrent(get_frmDigit());
      // Insert post-action code here
      }
      }
      // Insert global post-action code here
      }

    /** This method initializes UI of the application.
    */
    private void initialize() {
    // Insert pre-init code here
    Site = “http://127.0.0.1/wma”;
    lstPedido = new List(“Itens do Pedido”, Choice.IMPLICIT, new String[0], new Image[0]);
    lstPedido.addCommand(get_cmdExcluiItem());
    lstPedido.addCommand(get_cmdEditaItem());
    lstPedido.addCommand(get_cmdVoltaDig());
    lstPedido.setCommandListener(this);
    lstPedido.setTicker(get_tickerCliente());
    lstPedido.setSelectedFlags(new boolean[0]);
    lstPedido.setSelectCommand(null);
    lstPedido.setFitPolicy(Choice.TEXT_WRAP_DEFAULT);
    strNrPedido = new StringItem(“Numero Pedido:”, “”);
    getDisplay().setCurrent(get_frmLogin());
    // Insert post-init code here
    }

    private void VerificaSenha()
    {
    HttpConnection http = null;
    InputStream iStrm = null;
    boolean ret = false;

    String url = Site + “/usuarios.asp?id=” + tfUser.getString() + “&” + “senha=” + tfSenha.getString();

    this.mensagem.setText("");

    Conecta cn = new Conecta( url, this, 1 );
    cn.start();

}

private void VerificaCliente()
{
HttpConnection http = null;
InputStream iStrm = null;
boolean ret = false;

String url = Site + "/clientes.asp?codigo=" + tfCliente.getString();


Conecta cn = new Conecta( url, this, 2 );
cn.start(); 

}

/**
 * This method should return an instance of the display.
 */
public Display getDisplay() {                         
    return Display.getDisplay(this);
}                        

/**
 * This method should exit the midlet.
 */
public void exitMIDlet() {                         
    getDisplay().setCurrent(null);
    destroyApp(true);
    notifyDestroyed();
}                        
/** This method returns instance for cancelCommand1 component and should be called instead of accessing cancelCommand1 field directly.                        
 * @return Instance for cancelCommand1 component
 */
public Command get_cancelCommand1() {
    if (cancelCommand1 == null) {                      
        // Insert pre-init code here
        cancelCommand1 = new Command("Fechar", Command.CANCEL, 1);                      
        // Insert post-init code here
    }                      
    return cancelCommand1;
}                    

/** This method returns instance for OkComand component and should be called instead of accessing OkComand field directly.                         
 * @return Instance for OkComand component
 */
public Command get_OkComand() {
    if (OkComand == null) {                       
        // Insert pre-init code here
        OkComand = new Command("Ok", Command.OK, 1);                       
        // Insert post-init code here
    }                       
    return OkComand;
}                     

/** This method returns instance for tfUser component and should be called instead of accessing tfUser field directly.                         
 * @return Instance for tfUser component
 */
public TextField get_tfUser() {
    if (tfUser == null) {                       
        // Insert pre-init code here
        tfUser = new TextField("Usuario:", null, 18, TextField.ANY);                       
        // Insert post-init code here
    }                       
    return tfUser;
}                     

/** This method returns instance for tfSenha component and should be called instead of accessing tfSenha field directly.                         
 * @return Instance for tfSenha component
 */
public TextField get_tfSenha() {
    if (tfSenha == null) {                       
        // Insert pre-init code here
        tfSenha = new TextField("Senha:", null, 10, TextField.NUMERIC | TextField.PASSWORD);                       
        // Insert post-init code here
    }                       
    return tfSenha;
}                     

/** This method returns instance for spacer1 component and should be called instead of accessing spacer1 field directly.                         
 * @return Instance for spacer1 component
 */
public Spacer get_spacer1() {
    if (spacer1 == null) {                       
        // Insert pre-init code here
        spacer1 = new Spacer(1000, 60);                       
        // Insert post-init code here
    }                       
    return spacer1;
}                     

/** This method returns instance for frmLogin component and should be called instead of accessing frmLogin field directly.                        
 * @return Instance for frmLogin component
 */
public Form get_frmLogin() {
    if (frmLogin == null) {                      
        // Insert pre-init code here
        frmLogin = new Form("Login", new Item[] {                       
            get_spacer1(),
            get_tfUser(),
            get_spacer3(),
            get_tfSenha(),
            get_spacer2(),
            get_mensagem()
        });
        frmLogin.addCommand(get_cancelCommand1());
        frmLogin.addCommand(get_OkComand());
        frmLogin.setCommandListener(this);                     

// Insert post-init code here
}
return frmLogin;
}

/** This method returns instance for spacer2 component and should be called instead of accessing spacer2 field directly.                         
 * @return Instance for spacer2 component
 */
public Spacer get_spacer2() {
    if (spacer2 == null) {                       
        // Insert pre-init code here
        spacer2 = new Spacer(1000, 2);                       
        // Insert post-init code here
    }                       
    return spacer2;
}                     

/** This method returns instance for mensagem component and should be called instead of accessing mensagem field directly.                         
 * @return Instance for mensagem component
 */
public StringItem get_mensagem() {
    if (mensagem == null) {                       
        // Insert pre-init code here
        mensagem = new StringItem("", "");                       
        // Insert post-init code here
    }                       
    return mensagem;
}                     

/** This method returns instance for spacer3 component and should be called instead of accessing spacer3 field directly.                         
 * @return Instance for spacer3 component
 */
public Spacer get_spacer3() {
    if (spacer3 == null) {                       
        // Insert pre-init code here
        spacer3 = new Spacer(1000, 5);                       
        // Insert post-init code here
    }                       
    return spacer3;
}                     
/** This method returns instance for frmDigit component and should be called instead of accessing frmDigit field directly.                         
 * @return Instance for frmDigit component
 */
public Form get_frmDigit() {
    if (frmDigit == null) {                       
        // Insert pre-init code here
        frmDigit = new Form(null, new Item[] {                        
            get_tfCliente(),
            get_tfProduto(),
            get_strProduto(),
            get_strPreco(),
            get_tfVlVenda(),
            get_tfQte(),
            get_strOpcoes()
        });
        frmDigit.addCommand(get_cmdVoltar());
        frmDigit.setCommandListener(this);
        frmDigit.setTicker(get_tickerCliente());                      
        // Insert post-init code here
    }                       
    return frmDigit;
}                     

    
/** This method returns instance for tfCliente component and should be called instead of accessing tfCliente field directly.                         
 * @return Instance for tfCliente component
 */
public TextField get_tfCliente() {
    if (tfCliente == null) {                       
        // Insert pre-init code here
        tfCliente = new TextField("Cliente:", null, 10, TextField.NUMERIC);                        
        tfCliente.addCommand(get_cmdLeCliente());
        tfCliente.setItemCommandListener(this);                      
        // Insert post-init code here
    }                       
    return tfCliente;
}                     


/** This method returns instance for cmdLeCliente component and should be called instead of accessing cmdLeCliente field directly.                         
 * @return Instance for cmdLeCliente component
 */
public Command get_cmdLeCliente() {
    if (cmdLeCliente == null) {                       
        // Insert pre-init code here
        cmdLeCliente = new Command("Cliente", Command.OK, 1);                       
        // Insert post-init code here
    }                       
    return cmdLeCliente;
}                     

/** This method returns instance for tfProduto component and should be called instead of accessing tfProduto field directly.                         
 * @return Instance for tfProduto component
 */
public TextField get_tfProduto() {
    if (tfProduto == null) {                       
        // Insert pre-init code here
        tfProduto = new TextField("Produto:", null, 10, TextField.NUMERIC);                        
        tfProduto.addCommand(get_LeProduto());
        tfProduto.setItemCommandListener(this);                      
        // Insert post-init code here
    }                       
    return tfProduto;
}                     

/** This method returns instance for tickerCliente component and should be called instead of accessing tickerCliente field directly.                         
 * @return Instance for tickerCliente component
 */
public Ticker get_tickerCliente() {
    if (tickerCliente == null) {                       
        // Insert pre-init code here
        tickerCliente = new Ticker("");                       
        // Insert post-init code here
    }                       
    return tickerCliente;
}                     

/** This method returns instance for LeProduto component and should be called instead of accessing LeProduto field directly.                         
 * @return Instance for LeProduto component
 */
public Command get_LeProduto() {
    if (LeProduto == null) {                       
        // Insert pre-init code here
        LeProduto = new Command("Produto", Command.OK, 1);                       
        // Insert post-init code here
    }                       
    return LeProduto;
}                     

/** This method returns instance for strProduto component and should be called instead of accessing strProduto field directly.                         
 * @return Instance for strProduto component
 */
public StringItem get_strProduto() {
    if (strProduto == null) {                       
        // Insert pre-init code here
        strProduto = new StringItem("Descricao:", "");                        
        strProduto.setFont(get_fPequena());                      
        // Insert post-init code here
    }                       
    return strProduto;
}                     
/** This method returns instance for strPreco component and should be called instead of accessing strPreco field directly.                         
 * @return Instance for strPreco component
 */
public StringItem get_strPreco() {
    if (strPreco == null) {                       
        // Insert pre-init code here
        strPreco = new StringItem("Pre\u00E7o:", "");                        
        strPreco.setFont(get_fPequena());                      
        // Insert post-init code here
    }                       
    return strPreco;
}                     

/** This method returns instance for tfVlVenda component and should be called instead of accessing tfVlVenda field directly.                         
 * @return Instance for tfVlVenda component
 */
public TextField get_tfVlVenda() {
    if (tfVlVenda == null) {                       
        // Insert pre-init code here
        tfVlVenda = new TextField("Valor:", "", 10, TextField.DECIMAL);                       
        // Insert post-init code here
    }                       
    return tfVlVenda;
}                     

/** This method returns instance for cmdVoltar component and should be called instead of accessing cmdVoltar field directly.                         
 * @return Instance for cmdVoltar component
 */
public Command get_cmdVoltar() {
    if (cmdVoltar == null) {                       
        // Insert pre-init code here
        cmdVoltar = new Command("Voltar", Command.BACK, 2);                       
        // Insert post-init code here
    }                       
    return cmdVoltar;
}                     

/** This method returns instance for fPequena component and should be called instead of accessing fPequena field directly.                         
 * @return Instance for fPequena component
 */
public Font get_fPequena() {
    if (fPequena == null) {                       
        // Insert pre-init code here
        fPequena = Font.getFont(Font.FACE_SYSTEM, 0x0, Font.SIZE_SMALL);                       
        // Insert post-init code here
    }                       
    return fPequena;
}                     

/** This method returns instance for tfQte component and should be called instead of accessing tfQte field directly.                         
 * @return Instance for tfQte component
 */
public TextField get_tfQte() {
    if (tfQte == null) {                       
        // Insert pre-init code here
        tfQte = new TextField("Qte:", null, 4, TextField.NUMERIC);                        
        tfQte.addCommand(get_cmdGravar());
        tfQte.setItemCommandListener(this);                      
        // Insert post-init code here
    }                       
    return tfQte;
}                     

/** This method returns instance for cmdGravar component and should be called instead of accessing cmdGravar field directly.                         
 * @return Instance for cmdGravar component
 */
public Command get_cmdGravar() {
    if (cmdGravar == null) {                       
        // Insert pre-init code here
        cmdGravar = new Command("Gravar", Command.SCREEN, 1);                       
        // Insert post-init code here
    }                       
    return cmdGravar;
}                     

/** This method returns instance for cmdRelacao component and should be called instead of accessing cmdRelacao field directly.                         
 * @return Instance for cmdRelacao component
 */
public Command get_cmdRelacao() {
    if (cmdRelacao == null) {                       
        // Insert pre-init code here
        cmdRelacao = new Command("Rela\u00E7\u00E3o", Command.OK, 1);                       
        // Insert post-init code here
    }                       
    return cmdRelacao;
}                     

/** This method returns instance for cmdFechaRelacao component and should be called instead of accessing cmdFechaRelacao field directly.                         
 * @return Instance for cmdFechaRelacao component
 */
public Command get_cmdFechaRelacao() {
    if (cmdFechaRelacao == null) {                       
        // Insert pre-init code here
        cmdFechaRelacao = new Command("Voltar", Command.CANCEL, 2);                       
        // Insert post-init code here
    }                       
    return cmdFechaRelacao;
}                     

/** This method returns instance for cmdSalvaPedido component and should be called instead of accessing cmdSalvaPedido field directly.                         
 * @return Instance for cmdSalvaPedido component
 */
public Command get_cmdSalvaPedido() {
    if (cmdSalvaPedido == null) {                       
        // Insert pre-init code here
        cmdSalvaPedido = new Command("Salva Pedido", Command.SCREEN, 1);                       
        // Insert post-init code here
    }                       
    return cmdSalvaPedido;
}                     

/** This method returns instance for cmdExcluiItem component and should be called instead of accessing cmdExcluiItem field directly.                         
 * @return Instance for cmdExcluiItem component
 */
public Command get_cmdExcluiItem() {
    if (cmdExcluiItem == null) {                       
        // Insert pre-init code here
        cmdExcluiItem = new Command("Excluir", Command.SCREEN, 1);                       
        // Insert post-init code here
    }                       
    return cmdExcluiItem;
}                     

/** This method returns instance for cmdEditaItem component and should be called instead of accessing cmdEditaItem field directly.                         
 * @return Instance for cmdEditaItem component
 */
public Command get_cmdEditaItem() {
    if (cmdEditaItem == null) {                       
        // Insert pre-init code here
        cmdEditaItem = new Command("Alterar", Command.SCREEN, 1);                       
        // Insert post-init code here
    }                       
    return cmdEditaItem;
}                     

/** This method returns instance for cmdVoltaDig component and should be called instead of accessing cmdVoltaDig field directly.                          
 * @return Instance for cmdVoltaDig component
 */
public Command get_cmdVoltaDig() {
    if (cmdVoltaDig == null) {                        
        // Insert pre-init code here
        cmdVoltaDig = new Command("Voltar", Command.BACK, 2);                        
        // Insert post-init code here
    }                        
    return cmdVoltaDig;
}                      

/** This method returns instance for frmEdicao component and should be called instead of accessing frmEdicao field directly.                          
 * @return Instance for frmEdicao component
 */
public Form get_frmEdicao() {
    if (frmEdicao == null) {                        
        // Insert pre-init code here
        frmEdicao = new Form("Edi\u00E7\u00E3o Produto:", new Item[] {                         
            get_strProdutoAtual(),
            get_vlVendaAtual(),
            get_qteAtual()
        });
        frmEdicao.addCommand(get_cmdVoltarRelacao());
        frmEdicao.addCommand(get_cmdSalvaEdicao());
        frmEdicao.setCommandListener(this);
        frmEdicao.setTicker(get_tickerCliente());                       
        // Insert post-init code here
    }                        
    return frmEdicao;
}                      

/** This method returns instance for strProdutoAtual component and should be called instead of accessing strProdutoAtual field directly.                          
 * @return Instance for strProdutoAtual component
 */
public StringItem get_strProdutoAtual() {
    if (strProdutoAtual == null) {                        
        // Insert pre-init code here
        strProdutoAtual = new StringItem("", "");                        
        // Insert post-init code here
    }                        
    return strProdutoAtual;
}                      

/** This method returns instance for vlVendaAtual component and should be called instead of accessing vlVendaAtual field directly.                          
 * @return Instance for vlVendaAtual component
 */
public TextField get_vlVendaAtual() {
    if (vlVendaAtual == null) {                        
        // Insert pre-init code here
        vlVendaAtual = new TextField("Valor de Venda:", null, 15, TextField.DECIMAL);                        
        // Insert post-init code here
    }                        
    return vlVendaAtual;
}                      

/** This method returns instance for qteAtual component and should be called instead of accessing qteAtual field directly.                          
 * @return Instance for qteAtual component
 */
public TextField get_qteAtual() {
    if (qteAtual == null) {                        
        // Insert pre-init code here
        qteAtual = new TextField("Qte:", null, 10, TextField.NUMERIC);                        
        // Insert post-init code here
    }                        
    return qteAtual;
}                      

/** This method returns instance for cmdVoltarRelacao component and should be called instead of accessing cmdVoltarRelacao field directly.                          
 * @return Instance for cmdVoltarRelacao component
 */
public Command get_cmdVoltarRelacao() {
    if (cmdVoltarRelacao == null) {                        
        // Insert pre-init code here
        cmdVoltarRelacao = new Command("Voltar", Command.BACK, 2);                        
        // Insert post-init code here
    }                        
    return cmdVoltarRelacao;
}                      

/** This method returns instance for cmdSalvaEdicao component and should be called instead of accessing cmdSalvaEdicao field directly.                          
 * @return Instance for cmdSalvaEdicao component
 */
public Command get_cmdSalvaEdicao() {
    if (cmdSalvaEdicao == null) {                        
        // Insert pre-init code here
        cmdSalvaEdicao = new Command("Salvar", Command.OK, 1);                        
        // Insert post-init code here
    }                        
    return cmdSalvaEdicao;
}                      

/** This method returns instance for alertPedido component and should be called instead of accessing alertPedido field directly.                          
 * @return Instance for alertPedido component
 */
public Alert get_alertPedido() {
    if (alertPedido == null) {                        
        // Insert pre-init code here
        alertPedido = new Alert("Confirma\u00E7\u00E3o", "O pedido ainda n\u00E3o foi salvo. Tem certeza de que n\u00E3o deseja salva-lo?", null, AlertType.CONFIRMATION);                         
        alertPedido.addCommand(get_cmdJogaPedidoFora());
        alertPedido.addCommand(get_cmdVoltaPraDigitacao());
        alertPedido.setCommandListener(this);
        alertPedido.setTimeout(-2);                       
        // Insert post-init code here
    }                        
    return alertPedido;
}                      

/** This method returns instance for cmdJogaPedidoFora component and should be called instead of accessing cmdJogaPedidoFora field directly.                          
 * @return Instance for cmdJogaPedidoFora component
 */
public Command get_cmdJogaPedidoFora() {
    if (cmdJogaPedidoFora == null) {                        
        // Insert pre-init code here
        cmdJogaPedidoFora = new Command("N\u00E3o Salva", Command.OK, 1);                        
        // Insert post-init code here
    }                        
    return cmdJogaPedidoFora;
}                      

/** This method returns instance for cmdVoltaPraDigitacao component and should be called instead of accessing cmdVoltaPraDigitacao field directly.                          
 * @return Instance for cmdVoltaPraDigitacao component
 */
public Command get_cmdVoltaPraDigitacao() {
    if (cmdVoltaPraDigitacao == null) {                        
        // Insert pre-init code here
        cmdVoltaPraDigitacao = new Command("Cancelar", Command.BACK, 2);                        
        // Insert post-init code here
    }                        
    return cmdVoltaPraDigitacao;
}                      

/** This method returns instance for frmUpLoad component and should be called instead of accessing frmUpLoad field directly.                          
 * @return Instance for frmUpLoad component
 */
public Form get_frmUpLoad() {
    if (frmUpLoad == null) {                        
        // Insert pre-init code here
        frmUpLoad = new Form("Salva pedidos", new Item[] {                         
            get_strCliente(),
            strNrPedido,
            get_strTotal(),
            get_grCondPgto()
        });
        frmUpLoad.addCommand(get_cmdVoltaDig());
        frmUpLoad.addCommand(get_cmdUpload());
        frmUpLoad.setCommandListener(this);                       
        // Insert post-init code here
    }                        
    return frmUpLoad;
}                      

/** This method returns instance for strCliente component and should be called instead of accessing strCliente field directly.                          
 * @return Instance for strCliente component
 */
public StringItem get_strCliente() {
    if (strCliente == null) {                        
        // Insert pre-init code here
        strCliente = new StringItem("", "");                        
        // Insert post-init code here
    }                        
    return strCliente;
}                      

/** This method returns instance for strTotal component and should be called instead of accessing strTotal field directly.                          
 * @return Instance for strTotal component
 */
public StringItem get_strTotal() {
    if (strTotal == null) {                        
        // Insert pre-init code here
        strTotal = new StringItem("Valor Total Pedido:", "");                        
        // Insert post-init code here
    }                        
    return strTotal;
}                      

/** This method returns instance for grCondPgto component and should be called instead of accessing grCondPgto field directly.                          
 * @return Instance for grCondPgto component
 */
public ChoiceGroup get_grCondPgto() {
    if (grCondPgto == null) {                        
        // Insert pre-init code here
        grCondPgto = new ChoiceGroup("Condi\u00E7\u00E3o Pagamento:", Choice.EXCLUSIVE, new String[0], new Image[0]);                         
        grCondPgto.setSelectedFlags(new boolean[0]);                       
        // Insert post-init code here
    }                        
    return grCondPgto;
}                      

/** This method returns instance for cmdUpload component and should be called instead of accessing cmdUpload field directly.                          
 * @return Instance for cmdUpload component
 */
public Command get_cmdUpload() {
    if (cmdUpload == null) {                        
        // Insert pre-init code here
        cmdUpload = new Command("Transmite", Command.OK, 1);                        
        // Insert post-init code here
    }                        
    return cmdUpload;
}                      

/** This method returns instance for alAuxiliar component and should be called instead of accessing alAuxiliar field directly.                          
 * @return Instance for alAuxiliar component
 */
public Alert get_alAuxiliar() {
    if (alAuxiliar == null) {                        
        // Insert pre-init code here
        alAuxiliar = new Alert("", "", null, AlertType.ERROR);                         
        alAuxiliar.setTimeout(-2);                       
        // Insert post-init code here
    }                        
    return alAuxiliar;
}                      

/** This method returns instance for strOpcoes component and should be called instead of accessing strOpcoes field directly.                          
 * @return Instance for strOpcoes component
 */
public StringItem get_strOpcoes() {
    if (strOpcoes == null) {                        
        // Insert pre-init code here
        strOpcoes = new StringItem("Outras op\u00E7oes", "");                         
        strOpcoes.addCommand(get_cmdRelacao());
        strOpcoes.addCommand(get_cmdSalvaPedido());
        strOpcoes.setItemCommandListener(this);
        strOpcoes.setDefaultCommand(get_cmdRelacao());
        strOpcoes.setFont(get_fPequena());                       
        // Insert post-init code here
    }                        
    return strOpcoes;
}                      

/** This method returns instance for alFinaliza component and should be called instead of accessing alFinaliza field directly.                          
 * @return Instance for alFinaliza component
 */
public Alert get_alFinaliza() {
    if (alFinaliza == null) {                        
        // Insert pre-init code here
        alFinaliza = new Alert("Transmiss\u00E3o", "    Transmiss\u00E3o finalizada com sucesso.", null, AlertType.INFO);                         
        alFinaliza.addCommand(get_cmdFinalizada());
        alFinaliza.setCommandListener(this);
        alFinaliza.setTimeout(-2);                       
        // Insert post-init code here
    }                        
    return alFinaliza;
}                      

/** This method returns instance for cmdFinalizada component and should be called instead of accessing cmdFinalizada field directly.                          
 * @return Instance for cmdFinalizada component
 */
public Command get_cmdFinalizada() {
    if (cmdFinalizada == null) {                        
        // Insert pre-init code here
        cmdFinalizada = new Command("Voltar", Command.OK, 1);                        
        // Insert post-init code here
    }                        
    return cmdFinalizada;
}                      
 /** This method returns instance for svgImage1 component and should be called instead of accessing svgImage1 field directly.                          
 * @return Instance for svgImage1 component
 */
public javax.microedition.m2g.SVGImage get_svgImage1() {
    if (svgImage1 == null) {                        
        // Insert pre-init code here
        try {                         
            svgImage1 = (javax.microedition.m2g.SVGImage) javax.microedition.m2g.SVGImage.createImage((String) null, null);
        } catch (java.io.IOException exception) {
            exception.printStackTrace();
        }                       
        // Insert post-init code here
    }                        
    return svgImage1;
}                      

    

public void startApp() {
}


public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

public void openRecStore()
{
try
{
rs = RecordStore. openRecordStore(REC_STORE, true );
}
catch (Exception e)
{
db(e.toString());
}
}

public void closeRecStore()
{
try
{
rs.closeRecordStore();
}
catch (Exception e)
{
db(e.toString());
}
}

public void deleteRecStore()
{
if (RecordStore.listRecordStores() != null)
{
try
{
RecordStore.deleteRecordStore(REC_STORE);
}
catch (Exception e)
{
db(e.toString());
}
}
}

public void writeRecord(String str)
{
byte[] rec = str.getBytes();

try
{
  rs.addRecord(rec, 0, rec.length);
}
catch (Exception e)
{
  db(e.toString());
}

}

public List readRecords()
{
String record;
List v= new List(“Itens:”, List.IMPLICIT);
try
{
// Intentionally make this too small to test code below
byte[] recData = new byte[5];
int len;

  for (int i = 1; i <= rs.getNumRecords(); i++)      
  {
    if (rs.getRecordSize(i) > recData.length)
      recData = new byte[rs.getRecordSize(i)];
   
    len = rs.getRecord(i, recData, 0);
    record =  new String(recData, 0, len);
    v.append(record.toString(), null);
  }
}
catch (Exception e)
{
  db(e.toString());
}
return v;

}

private void db(String str)
{
System.err.println("Msg: " + str);
}
}

/*

  • Conecta
  • Created on 5 de Novembro de 2007, 15:00
    */

class Conecta implements Runnable
{
private int tela;
private String url;
private boolean downloadSuccess = false;
private String errorMsg = null;
public String mensagem;
private mPedidos MIDlet;

public Conecta(String url, mPedidos MIDlet, int tela )
{
this.url = url;
this.MIDlet = MIDlet;
this.tela = tela;

}

public void run()
{
try
{
ConsultaServidor(url);
}
catch (Exception e)
{
System.err.println("Msg: " + e.toString());
}
}
public void start()
{
Thread thread = new Thread(this);
try
{
thread.start();
}
catch (Exception e)
{
}
}

private void ConsultaServidor(String url) throws IOException
{
HttpConnection http = null;
InputStream iStrm = null;
boolean ret = false;

try
{
  	http = (HttpConnection) Connector.open(url);
  	http.setRequestMethod(HttpConnection.GET);
  	iStrm = http.openInputStream();      
  	ret = processServerResponse(http, iStrm);
}
finally
{
  // Clean up
  if (iStrm != null)
    iStrm.close();
  if (http != null)
    http.close();
}

}

private boolean processServerResponse(HttpConnection http, InputStream iStrm) throws IOException
{
errorMsg = null;
if (http.getResponseCode() == HttpConnection.HTTP_OK)
{
int length = (int) http.getLength();
String str;
if (length != -1)
{
byte servletData[] = new byte[length];
iStrm.read(servletData);
str = new String(servletData);
}
else // Length not available…
{
ByteArrayOutputStream bStrm = new ByteArrayOutputStream();

    int ch;
    while ((ch = iStrm.read()) != -1)
      bStrm.write(ch);

    str = new String(bStrm.toByteArray());
    bStrm.close();
  }
  
  this.mensagem = str;
  if ( tela < 5 )
     MIDlet.SetMensagem( tela, str );
  else
  {
     if ( tela == 5 )
       MIDlet.SetRetornoServidor(tela, str );
     else
       MIDlet.SalvaPedido(false, tela, str );
  }
 
 return true;
}
else
  errorMsg = new String( http.getResponseMessage());

return false;      

}
}