Exemple #1
0
    def OnEdtCodigo_Killfocus(self, event):
        Rotinas = RotinasGlobais.Rotinas
        ConsSQL = ConsultasSQL.ConsSQL
        ConsCampo = LISTAMSTR()

        if len(self.edtCodigo.GetValue()) > 0:
            if Rotinas.validaCPF(self.edtCodigo.GetValue()):
                sCliente = Rotinas.ConsultaCampoDesc(
                    ConsCampo,
                    ConsSQL.Cliente('S', self.edtCodigo.GetValue(), "", "", "",
                                    "", "", "", "", "", ""),
                    Resource.STR_CLINENC)
                if len(sCliente) == 0:
                    self.edtCodigo.Clear()
                    self.edtCodigo.SetFocus()
                else:
                    self.edtDescricao.SetValue(sCliente)
            else:
                wxMessageBox(Resource.STR_CPFINV, "Erro", wxOK | wxICON_ERROR)
                self.edtCodigo.Clear()
                self.edtCodigo.SetFocus()
        else:
            self.edtDescricao.Clear()

        event.Skip()
Exemple #2
0
    def OnEdtISBN_Killfocus(self, event):
        Rotinas = RotinasGlobais.Rotinas
        ConsSQL = ConsultasSQL.ConsSQL
        ConsCampo = LISTAMSTR()

        if len(self.edtISBN.GetValue()) > 0:
            if Rotinas.validaISBN(self.edtISBN.GetValue()):
                sLivro = Rotinas.ConsultaCampoDesc(
                    ConsCampo,
                    ConsSQL.Livro('Q', self.edtISBN.GetValue(), "", "", "", "",
                                  "", "", "", "", ""), Resource.STR_LIVNENC)
                if len(sLivro) == 0:
                    self.edtISBN.Clear()
                    self.edtISBN.SetFocus()
                else:
                    self.edtLivro.SetValue(sLivro)
                    nQtdEstoque = int(ConsCampo.col[0][3])
                    if nQtdEstoque > 0:
                        Rotinas.sPreco = ConsCampo.col[0][2]
                        Rotinas.sQtdEstoque = ConsCampo.col[0][3]
                    else:
                        wxMessageBox(Resource.STR_LIVNEST, "Erro",
                                     wxOK | wxICON_ERROR)
            else:
                wxMessageBox(Resource.STR_ISBNINV, "Erro", wxOK | wxICON_ERROR)
                self.edtISBN.Clear()
                self.edtISBN.SetFocus()
        else:
            self.edtLivro.Clear()
        event.Skip()
Exemple #3
0
    def OnEdtCodEndereco_Killfocus(self, event):
        ConsCampo = LISTAMSTR()

        if len(self.edtCodEndereco.GetValue()) > 0:
            sLogradouro = RotinasGlobais.Rotinas.ConsultaCampoDesc(
                ConsCampo,
                ConsultasSQL.ConsSQL.Endereco('S',
                                              self.edtCodEndereco.GetValue(),
                                              "", "", "", "", ""),
                Resource.STR_ENDNENC)
            if len(sLogradouro) > 0:
                self.edtLogradouro.SetValue(sLogradouro)
                self.edtBairro.SetValue(ConsCampo.col[0][2])
                self.edtCEP.SetValue(ConsCampo.col[0][3])
                self.edtCidade.SetValue(ConsCampo.col[0][4])
                self.edtEstado.SetValue(ConsCampo.col[0][5])
            else:
                self.edtCodEnd.SetFocus()
                self.edtLogradouro.Clear()
                self.edtBairro.Clear()
                self.edtCEP.Clear()
                self.edtCidade.Clear()
                self.edtEstado.Clear()
        else:
            self.edtLogradouro.Clear()
            self.edtBairro.Clear()
            self.edtCEP.Clear()
            self.edtCidade.Clear()
            self.edtEstado.Clear()
        event.Skip()
 def onEdtCodEndereco_Killfocus(self, sender, sel, ptr):
   self.ConsCampo = LISTAMSTR()
 
   if len(self.edtCodEndereco.getText()) > 0:
     sLogradouro = self.Rotinas.ConsultaCampoDesc(self.ConsCampo, self.ConsSQL.Endereco('S',
     self.edtCodEndereco.getText(),"","","","",""),Resource.STR_ENDNENC)
     if len(sLogradouro) > 0:
       self.edtLogradouro.setText(sLogradouro)
       self.edtBairro.setText(self.ConsCampo.col[0][2])
       self.edtCEP.setText(self.ConsCampo.col[0][3])
       self.edtCidade.setText(self.ConsCampo.col[0][4])
       self.edtEstado.setText(self.ConsCampo.col[0][5])
     else:	    
       self.edtCodEndereco.killFocus()
       showModalErrorBox(self, MBOX_OK, "Erro", Resource.STR_ENDNENC)
       self.edtLogradouro.setText("")
       self.edtBairro.setText("")
       self.edtCEP.setText("")
       self.edtCidade.setText("")
       self.edtEstado.setText("")      
   else:
     self.edtLogradouro.setText("")
     self.edtBairro.setText("")
     self.edtCEP.setText("")
     self.edtCidade.setText("")
     self.edtEstado.setText("")
   return True
    def onEdtISBN_Killfocus(self, sender, sel, ptr):
        self.ConsCampo = LISTAMSTR()

        if len(self.edtISBN.getText()) > 0:
            if self.Rotinas.validaISBN(self.edtISBN.getText()):
                sLivro = self.Rotinas.ConsultaCampoDesc(
                    self.ConsCampo,
                    self.ConsSQL.Livro('Q', self.edtISBN.getText(), "", "", "",
                                       "", "", "", "", "", ""),
                    Resource.STR_LIVNENC)
                if len(sLivro) == 0:
                    self.edtISBN.setText("")
                    self.edtISBN.killFocus()
                    showModalErrorBox(self, MBOX_OK, "Erro",
                                      Resource.STR_LIVNENC)
                else:
                    self.edtLivro.setText(sLivro)
                    nQtdEstoque = int(self.ConsCampo.col[0][3])
                    if nQtdEstoque > 0:
                        self.Rotinas.sPreco = self.ConsCampo.col[0][2]
                        self.Rotinas.sQtdEstoque = self.ConsCampo.col[0][3]
                    else:
                        showModalErrorBox(self, MBOX_OK, "Erro",
                                          Resource.STR_LIVNEST)
            else:
                self.edtISBN.setText("")
                self.edtISBN.killFocus()
                showModalErrorBox(self, MBOX_OK, "Erro", Resource.STR_ISBNINV)
        else:
            self.edtLivro.setText("")
        return True
Exemple #6
0
 def AdicionaCombo(self):
   Campos = LISTAMSTR()
   Rotinas = RotinasGlobais.Rotinas
   if Rotinas.ConsultaDadosLista(Rotinas.gConexao, Campos,
     ConsultasSQL.ConsSQL.Idioma('S',"","")):
     for nLinha in range(0, len(Campos.col)):
 	    self.slIdiomas.col.append(Campos.col[nLinha][0])
 	    self.cmbIdioma.Append(Campos.col[nLinha][1])
    def NovoDado(self, sTextoSql):
        Rotinas = RotinasGlobais.Rotinas
        lstRegs = LISTAMSTR()

        if Rotinas.ConsultaDadosLista(Rotinas.gConexao, lstRegs, sTextoSql):
            self.edtCodigo.SetValue(str(lstRegs.col[0][0]))
            self.edtCodigo.Enable(False)
            self.edtDescricao.SetFocus()
Exemple #8
0
 def NovoDado(self, sTextoSql):
   lstRegs = LISTAMSTR()
 
   if self.Rotinas.ConsultaDadosLista(self.Rotinas.gConexao, 
     lstRegs, sTextoSql):
     self.edtCodigo.setText(lstRegs.col[0][0])
     self.edtCodigo.disable()
     self.edtDescricao.setFocus() 
    def __init__(self, owner, sTitulo):
        FXDialogBox.__init__(self, owner, sTitulo, DECOR_ALL, 0, 0, 385, 263,
                             0, 0, 0, 0, 4, 4)
        self.Rotinas = RotinasGlobais.Rotinas
        self.setIcon(self.Rotinas.lerFigura(self.getApp(), "Livrus.bmp"))

        frame = FXVerticalFrame(self, LAYOUT_FILL_X | LAYOUT_FILL_Y)
        frame1 = FXVerticalFrame(frame, LAYOUT_FILL_X)
        frame2 = FXHorizontalFrame(frame1, LAYOUT_TOP)

        frame3 = FXVerticalFrame(frame2, LAYOUT_LEFT)
        frame3.setPadTop(0)
        frame3.setPadBottom(0)

        frame4 = FXVerticalFrame(frame2, LAYOUT_LEFT | LAYOUT_BOTTOM)
        frame4.setPadTop(0)
        frame4.setPadBottom(0)

        frameBotoesH = FXHorizontalFrame(frame, LAYOUT_BOTTOM | LAYOUT_FILL_X)

        self.labDescricao = FXLabel(frame3, "Descrição:", None, LAYOUT_LEFT, 8,
                                    8, 51, 13)
        self.edtDescricao = FXTextField(
            frame3, 50, None, 0, TEXTFIELD_LIMITED | FRAME_SUNKEN | FRAME_THICK
            | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT, 8, 24, 257, 21, 3, 20)
        btnPesquisar = FXButton(
            frame4, "&Pesquisar", None, self,
            frmConsultas.ID_FRMCONSULTAS_BTNPESQUISAR,
            BUTTON_DEFAULT | FRAME_RAISED | FRAME_THICK | LAYOUT_FIX_WIDTH
            | LAYOUT_FIX_HEIGHT, 272, 24, 75, 25, 15, 15, 3, 3)

        self.gridConsulta = FXTable(
            frame, 2, 3, self, frmConsultas.ID_FRMCONSULTAS_GRIDCONSULTA,
            TABLE_COL_SIZABLE | TABLE_ROW_SIZABLE | LAYOUT_FILL_X
            | LAYOUT_FILL_Y, 0, 56, 355, 125)
        self.Rotinas.IniciaLayoutGrid(self.gridConsulta, 2, 3)

        self.labRegistro = FXLabel(frameBotoesH, "Registro 0 de 0", None,
                                   LAYOUT_LEFT, 8, 16, 144, 13)
        btnFechar = FXButton(
            frameBotoesH, "&Fechar", None, self, FXDialogBox.ID_CANCEL,
            FRAME_RAISED | FRAME_THICK | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT
            | LAYOUT_RIGHT, 75, 13, 75, 25, 15, 15, 3, 3)
        btnLimpar = FXButton(
            frameBotoesH, "&Limpar", None, self,
            frmConsultas.ID_FRMCONSULTAS_BTNLIMPAR, FRAME_RAISED | FRAME_THICK
            | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT | LAYOUT_RIGHT, 16, 13, 75,
            25, 15, 15, 3, 3)

        self.edtDescricao.setFocus()
        self.lstLinhas = LISTAMSTR()
        self.sSelecionado = ""
        self.nRegistro = 0
        self.Rotinas.sCodigoSelecionado = ""
Exemple #10
0
 def AdicionaCombo(self):
   self.ConsCampos = LISTAMSTR()
 
   if self.Rotinas.ConsultaDadosLista(self.Rotinas.gConexao, self.ConsCampos, 
     self.ConsSQL.Idioma('S',"","")):
     self.slIdiomas.col = []
     for nLinha in range(0,self.ConsCampos.tam):
 	    self.slIdiomas.col.append(self.ConsCampos.col[nLinha][0])
 	    self.cmbIdioma.appendItem(self.ConsCampos.col[nLinha][1])   
   if self.ConsCampos.tam < 8:
     self.cmbIdioma.setNumVisible(self.ConsCampos.tam)
Exemple #11
0
 def OnEdtCodAutor_Killfocus(self, event):
   ConsCampo = LISTAMSTR()
 
   if len(self.edtCodAutor.GetValue()) > 0:
     sAutor = RotinasGlobais.Rotinas.ConsultaCampoDesc(ConsCampo, 
       ConsultasSQL.ConsSQL.Autor('S',
       self.edtCodAutor.GetValue(),""),Resource.STR_AUTNENC)    
     if len(sAutor) > 0:
       self.edtAutor.SetValue(sAutor)
     else:
       self.edtCodAutor.Clear()
       self.edtCodAutor.SetFocus()
   else:
     self.edtAutor.Clear()
    def AdicionaValoresLista(self, sTextoSql, lstLista, slCodLista):
        lstCampos = LISTAMSTR()
        nLinha = 0

        lstLista.clearItems()
        slCodLista.col = []
        if self.ConsultaDadosLista(self.gConexao, lstCampos, sTextoSql):
            for nLinha in range(0, lstCampos.tam):
                sCodigo = lstCampos.col[nLinha][0]
                sDesc = lstCampos.col[nLinha][1]

                slCodLista.col.append(lstCampos.col[nLinha][0])
                sItems = sCodigo + ' - ' + sDesc
                lstLista.appendItem(sItems)
Exemple #13
0
 def OnEdtCodAssunto_Killfocus(self, event):
   ConsCampo = LISTAMSTR()
 
   if len(self.edtCodAssunto.GetValue()) > 0:
     sAssunto = RotinasGlobais.Rotinas.ConsultaCampoDesc(ConsCampo, 
       ConsultasSQL.ConsSQL.Assunto('S', self.edtCodAssunto.GetValue(),""),
       Resource.STR_ASSNENC)
     if len(sAssunto) > 0:
       self.edtAssunto.SetValue(sAssunto)
     else:
       self.edtCodAssunto.Clear()
       self.edtCodAssunto.SetFocus()
   else:
     self.edtAssunto.Clear()
Exemple #14
0
 def OnEdtCodEditora_Killfocus(self, event):
   ConsCampo = LISTAMSTR()
 
   if len(self.edtCodEditora.GetValue()) > 0:
     sEditora = RotinasGlobais.Rotinas.ConsultaCampoDesc(ConsCampo, 
     ConsultasSQL.ConsSQL.Editora('S', self.edtCodEditora.GetValue(),""),
     Resource.STR_EDTNENC)
     if len(self.sEditora) > 0:
       self.edtEditora.SetValue(sEditora)
     else:
       self.edtCodEditora.Clear()
       self.edtCodEditora.SetFocus()
   else:
     self.edtEditora.Clear()
Exemple #15
0
    def OnEdtCodPais_Killfocus(self, event):
        ConsCampo = LISTAMSTR()

        if len(self.edtCodPais.GetValue()) > 0:
            sPais = RotinasGlobais.Rotinas.ConsultaCampoDesc(
                ConsCampo,
                ConsultasSQL.ConsSQL.Pais('S', self.edtCodPais.GetValue(), ""),
                Resource.STR_PAISNENC)
            if len(sPais) > 0:
                self.edtPais.SetValue(sPais)
            else:
                self.edtCodPais.Clear()
                self.edtCodPais.SetFocus()
        else:
            self.edtPais.Clear()
        event.Skip()
 def onEdtCodProfissao_Killfocus(self, sender, sel, ptr):
   self.ConsCampo = LISTAMSTR()
 
   if len(self.edtCodProfissao.getText()) > 0:
     sProfissao = self.Rotinas.ConsultaCampoDesc(self.ConsCampo, self.ConsSQL.Profissao('S',
       self.edtCodProfissao.getText(),""),Resource.STR_PROFNENC)    
     if len(sProfissao) > 0:
       self.edtProfissao.setText(sProfissao)
     else:
        self.edtCodProfissao.killFocus()
        showModalErrorBox(self, MBOX_OK, "Erro", Resource.STR_PROFNENC)
        self.edtCodProfissao.setText("")
        self.edtProfissao.setText("")
   else:
     self.edtProfissao.setText("")
   return True
 def onEdtCodPais_Killfocus(self, sender, sel, ptr):
   self.ConsCampo = LISTAMSTR()
 
   if len(self.edtCodPais.getText()) > 0:
     sPais = self.Rotinas.ConsultaCampoDesc(self.ConsCampo, self.ConsSQL.Pais('S',
       self.edtCodPais.getText(),""),Resource.STR_PAISNENC)    
     if len(sPais) > 0:
       self.edtPais.setText(sPais)
     else:      
       self.edtCodPais.killFocus()
       showModalErrorBox(self, MBOX_OK, "Erro", Resource.STR_PAISNENC)
       self.edtCodPais.setText("")
       self.edtPais.setText("")
   else:
     self.edtPais.setText("")
   return True
Exemple #18
0
 def onEdtCodEditora_Killfocus(self, sender, sel, ptr):
   self.ConsCampo = LISTAMSTR()
 
   if len(self.edtCodEditora.getText()) > 0:
     sEditora = self.Rotinas.ConsultaCampoDesc(self.ConsCampo, self.ConsSQL.Editora('S',
       self.edtCodEditora.getText(),""),Resource.STR_EDTNENC)    
     if len(sEditora) > 0:
       self.edtEditora.setText(sEditora)
     else:
       self.edtCodEditora.setText("")
       self.edtEditora.setText("")
       self.edtCodEditora.killFocus()
       showModalErrorBox(self, MBOX_OK, "Erro", Resource.STR_EDTNENC)
   else:
     self.edtEditora.setText("")
   return True
Exemple #19
0
    def OnBtnPesquisarButton(self, event):
        Rotinas = RotinasGlobais.Rotinas
        ConsTotal = LISTAMSTR()

        if Rotinas.ConsultaDadosLista(Rotinas.gConexao, self.lstLinhas,
                                      self.ConsVenda('S')):
            Rotinas.AdicionaLinhasGrid(self.gridVendas, self.lstLinhas, 6)

            if Rotinas.ConsultaDadosLista(Rotinas.gConexao, ConsTotal,
                                          self.ConsVenda('P')):
                if len(ConsTotal.col) > 0:
                    nTemp = float(ConsTotal.col[0][0])
                    sPrecoTotal = fpformat.fix(nTemp, 2)
                    self.edtPrecoTotal.SetValue(sPrecoTotal)
        else:
            wxMessageBox(Resource.STR_VENNENC, "Erro", wxOK | wxICON_ERROR)
        event.Skip()
Exemple #20
0
    def OnEdtCodProfissao_Killfocus(self, event):
        ConsCampo = LISTAMSTR()

        if len(self.edtCodProfissao.GetValue()) > 0:
            sProfissao = RotinasGlobais.Rotinas.ConsultaCampoDesc(
                ConsCampo,
                ConsultasSQL.ConsSQL.Profissao('S',
                                               self.edtCodProfissao.GetValue(),
                                               ""), Resource.STR_PROFNENC)
            if len(sProfissao) > 0:
                self.edtProfissao.SetValue(sProfissao)
            else:
                self.edtCodProfissao.Clear()
                self.edtCodProfissao.SetFocus()
        else:
            self.edtProfissao.Clear()
        event.Skip()
    def AdicionaValoresLista(self, sTextoSql, lstLista, slCodLista):
        Campos = LISTAMSTR()
        sItems = ''
        sCodigo = ''
        sDesc = ''
        nLinha = 0

        lstLista.Clear()
        slCodLista.col = []
        if self.ConsultaDadosLista(self.gConexao, Campos, sTextoSql):
            for nLinha in range(0, len(Campos.col)):
                sCodigo = Campos.col[nLinha][0]
                sDesc = Campos.col[nLinha][1]

                slCodLista.col.append(sCodigo)
                sItems = sCodigo + ' - ' + sDesc
                lstLista.Append(sItems)
Exemple #22
0
 def onEdtCodAutor_Killfocus(self, sender, sel, ptr):
   self.ConsCampo = LISTAMSTR()
 
   if len(self.edtCodAutor.getText()) > 0:
     sAutor = self.Rotinas.ConsultaCampoDesc(self.ConsCampo, self.ConsSQL.Autor('S',
       self.edtCodAutor.getText(),""),Resource.STR_AUTNENC)    
 
     if len(sAutor) > 0:
       self.edtAutor.setText(sAutor)
     else:
       self.edtCodAutor.setText("")
       self.edtAutor.setText("")
       self.edtCodAutor.killFocus()
       showModalErrorBox(self, MBOX_OK, "Erro", Resource.STR_AUTNENC)
   else:
     self.edtAutor.setText("")
   return True
Exemple #23
0
    def onBtnPesquisar(self, sender, sel, ptr):
        ConsTotal = LISTAMSTR()

        if self.Rotinas.ConsultaDadosLista(self.Rotinas.gConexao,
                                           self.lstLinhas,
                                           self.ConsVenda('S')):
            self.Rotinas.AdicionaLinhasGrid(self.gridVendas, self.lstLinhas, 6)

            if self.Rotinas.ConsultaDadosLista(self.Rotinas.gConexao,
                                               ConsTotal, self.ConsVenda('P')):
                if ConsTotal.tam > 0:
                    nTemp = float(ConsTotal.col[0][0])
                    sPrecoTotal = "R$ " + fpformat.fix(nTemp, 2)
                    self.edtPrecoTotal.setText(sPrecoTotal)
                self.setLabRegistros(1)
        else:
            showModalErrorBox(self, MBOX_OK, "Erro", Resource.STR_VENNENC)
        return True
Exemple #24
0
  def __init__(self, clienteMDI, sTitulo, iconeMDI, menuMDI, 
    nFiltroCodigo, bIniciaBotoes, bMostra_edtCodigo=True):  
    FXMDIChild.__init__(self, clienteMDI, sTitulo, iconeMDI, 
      menuMDI, MDI_NORMAL, 0, 0, 345, 180)

    self.Rotinas = RotinasGlobais.Rotinas
    self.frame = FXVerticalFrame(self, LAYOUT_FILL_X | LAYOUT_FILL_Y)
  
    frame1 = FXVerticalFrame(self.frame, LAYOUT_FILL_X)
    self.frame2 = FXHorizontalFrame(frame1, LAYOUT_TOP)
    
    self.frame3 = FXVerticalFrame(self.frame2, LAYOUT_LEFT, 0,0,0,0,0,0,0,0)
  
    frame4 = FXHorizontalFrame(self.frame3, LAYOUT_LEFT, 0,0,0,0,0,0,0,0)
    self.frame5 = FXVerticalFrame(frame4, LAYOUT_LEFT, 0,0,0,0,0,0,0,0)
    frame6 = FXVerticalFrame(frame4, LAYOUT_LEFT|LAYOUT_BOTTOM, 0,0,0,0,0,0,0,0)
  
    self.frame7 = FXHorizontalFrame(self.frame3, LAYOUT_LEFT, 0,0,0,0,0,0,0,0)
    frame8 = FXVerticalFrame(self.frame7, LAYOUT_LEFT, 0,0,0,0,0,0,0,0)
  
    self.labCodigo = FXLabel(self.frame5, "Código:", None, LAYOUT_LEFT, 
      8, 8, 36, 13)
    if bMostra_edtCodigo:
      self.edtCodigo = FXTextField(self.frame5, 10, None, 
        frmCadastros.ID_FRMCADASTROS_EDTCODIGO, TEXTFIELD_LIMITED|
        FRAME_SUNKEN|FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|
        nFiltroCodigo, 8, 24, 121, 21, 3, 20)
    self.btnNovo = FXButton(frame6, "&Novo", None, self, 
      frmCadastros.ID_FRMCADASTROS_BTNNOVO, BUTTON_DEFAULT|FRAME_RAISED|
      FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|
      LAYOUT_BOTTOM, 144, 24, 75, 25, 15, 15, 3, 3 )
    self.labDescricao = FXLabel(frame8, "Descrição:", None, LAYOUT_LEFT, 
      8, 48, 51, 13)
    self.edtDescricao = FXTextField(frame8, 30, None, 0, TEXTFIELD_LIMITED|
      FRAME_SUNKEN|FRAME_THICK|LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT, 
      8, 64, 217, 21, 3, 20)
    self.edtDescricao.disable()
  
    if bIniciaBotoes:
      self.IniciaBotoes()    

    self.lstRegistros = LISTAMSTR()
    self.nLinhaRegistro = 0 
    def onEdtCodigo_Killfocus(self, sender, sel, ptr):
        self.ConsCampo = LISTAMSTR()

        if len(self.edtCodigo.getText()) > 0:
            if self.Rotinas.validaCPF(self.edtCodigo.getText()):
                sCliente = self.Rotinas.ConsultaCampoDesc(
                    self.ConsCampo,
                    self.ConsSQL.Cliente('S', self.edtCodigo.getText(), "", "",
                                         "", "", "", "", "", "", ""),
                    Resource.STR_CLINENC)
                if len(sCliente) == 0:
                    self.edtCodigo.setText("")
                    self.edtCodigo.killFocus()
                    showModalErrorBox(self, MBOX_OK, "Erro",
                                      Resource.STR_CLINENC)
                else:
                    self.edtDescricao.setText(sCliente)
            else:
                self.edtCodigo.setText("")
                self.edtCodigo.killFocus()
                showModalErrorBox(self, MBOX_OK, "Erro", Resource.STR_CPFINV)
        else:
            self.edtDescricao.setText("")
        return True
Exemple #26
0
class frmConVendas(wxPanel):
    lstLinhas = LISTAMSTR()

    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wxPanel.__init__(self,
                         id=wxID_FRMCONVENDAS,
                         name=u'frmConVendas',
                         parent=prnt,
                         pos=wxPoint(379, 218),
                         size=wxSize(480, 310),
                         style=wxTAB_TRAVERSAL)
        self.SetClientSize(wxSize(475, 306))
        EVT_CLOSE(self, self.OnFrmConVendasClose)

        self.labDtHrVenda = wxStaticText(id=wxID_FRMCONVENDASLABDTHRVENDA,
                                         label=u'Data/Hora Venda: ',
                                         name=u'labDtHrVenda',
                                         parent=self,
                                         pos=wxPoint(8, 8),
                                         size=wxSize(91, 13),
                                         style=0)

        self.edtDtHrVenda = wxTextCtrl(id=wxID_FRMCONVENDASEDTDTHRVENDA,
                                       name=u'edtDtHrVenda',
                                       parent=self,
                                       pos=wxPoint(8, 24),
                                       size=wxSize(128, 21),
                                       style=0,
                                       value=u'')
        EVT_KILL_FOCUS(self.edtDtHrVenda, self.OnEdtDtHrVendaKillFocus)

        self.btnPesquisar = wxButton(id=wxID_FRMCONVENDASBTNPESQUISAR,
                                     label=u'&Pesquisar',
                                     name=u'btnPesquisar',
                                     parent=self,
                                     pos=wxPoint(144, 22),
                                     size=wxSize(75, 25),
                                     style=0)
        EVT_BUTTON(self.btnPesquisar, wxID_FRMCONVENDASBTNPESQUISAR,
                   self.OnBtnPesquisarButton)

        self.labISBN = wxStaticText(id=wxID_FRMCONVENDASLABISBN,
                                    label=u'ISBN: ',
                                    name=u'labISBN',
                                    parent=self,
                                    pos=wxPoint(8, 88),
                                    size=wxSize(31, 13),
                                    style=0)

        self.edtISBN = wxTextCtrl(id=wxID_FRMCONVENDASEDTISBN,
                                  name=u'edtISBN',
                                  parent=self,
                                  pos=wxPoint(8, 104),
                                  size=wxSize(128, 21),
                                  style=0,
                                  value=u'')
        EVT_KILL_FOCUS(self.edtISBN, self.OnEdtISBNKillFocus)

        self.labLivro = wxStaticText(id=wxID_FRMCONVENDASLABLIVRO,
                                     label=u'Livro: ',
                                     name=u'labLivro',
                                     parent=self,
                                     pos=wxPoint(142, 88),
                                     size=wxSize(29, 13),
                                     style=0)

        self.edtLivro = wxTextCtrl(id=wxID_FRMCONVENDASEDTLIVRO,
                                   name=u'edtLivro',
                                   parent=self,
                                   pos=wxPoint(142, 104),
                                   size=wxSize(306, 21),
                                   style=0,
                                   value=u'')
        self.edtLivro.Enable(False)

        self.btnPLivro = wxButton(id=wxID_FRMCONVENDASBTNPLIVRO,
                                  label=u'...',
                                  name=u'btnPLivro',
                                  parent=self,
                                  pos=wxPoint(448, 104),
                                  size=wxSize(21, 21),
                                  style=0)
        EVT_BUTTON(self.btnPLivro, wxID_FRMCONVENDASBTNPLIVRO,
                   self.OnBtnPLivroButton)

        self.labCPF = wxStaticText(id=wxID_FRMCONVENDASLABCPF,
                                   label=u'CPF:',
                                   name=u'labCPF',
                                   parent=self,
                                   pos=wxPoint(8, 48),
                                   size=wxSize(23, 13),
                                   style=0)

        self.edtCPF = wxTextCtrl(id=wxID_FRMCONVENDASEDTCPF,
                                 name=u'edtCPF',
                                 parent=self,
                                 pos=wxPoint(8, 64),
                                 size=wxSize(128, 21),
                                 style=0,
                                 value=u'')
        EVT_KILL_FOCUS(self.edtCPF, self.OnEdtCPFKillFocus)

        self.labCliente = wxStaticText(id=wxID_FRMCONVENDASLABCLIENTE,
                                       label=u'Cliente:',
                                       name=u'labCliente',
                                       parent=self,
                                       pos=wxPoint(142, 48),
                                       size=wxSize(35, 13),
                                       style=0)

        self.edtCliente = wxTextCtrl(id=wxID_FRMCONVENDASEDTCLIENTE,
                                     name=u'edtCliente',
                                     parent=self,
                                     pos=wxPoint(142, 64),
                                     size=wxSize(306, 21),
                                     style=0,
                                     value=u'')
        self.edtCliente.Enable(False)

        self.btnPCliente = wxButton(id=wxID_FRMCONVENDASBTNPCLIENTE,
                                    label=u'...',
                                    name=u'btnPCliente',
                                    parent=self,
                                    pos=wxPoint(448, 64),
                                    size=wxSize(21, 21),
                                    style=0)
        EVT_BUTTON(self.btnPCliente, wxID_FRMCONVENDASBTNPCLIENTE,
                   self.OnBtnPClienteButton)

        self.gridVendas = wxGrid(id=wxID_FRMCONVENDASGRIDVENDAS,
                                 name=u'gridVendas',
                                 parent=self,
                                 pos=wxPoint(0, 136),
                                 size=wxSize(472, 104),
                                 style=wxSUNKEN_BORDER)
        self.gridVendas.CreateGrid(1, 6, wxGrid.wxGridSelectRows)
        self.gridVendas.HideCellEditControl()
        self.gridVendas.SetColLabelSize(21)
        EVT_GRID_SELECT_CELL(self.gridVendas, self.OnGridVendasGridSelectCell)
        EVT_GRID_LABEL_LEFT_CLICK(self.gridVendas,
                                  self.OnGridVendasGridLabelLeftClick)

        self.labRegistro = wxStaticText(id=wxID_FRMCONVENDASLABREGISTRO,
                                        label=u'Registro 0 de 0 ',
                                        name=u'labRegistro',
                                        parent=self,
                                        pos=wxPoint(8, 248),
                                        size=wxSize(144, 13),
                                        style=0)

        self.labPrecoTotal = wxStaticText(id=wxID_FRMCONVENDASLABPRECOTOTAL,
                                          label=u'Pre\xe7o Total: ',
                                          name=u'labPrecoTotal',
                                          parent=self,
                                          pos=wxPoint(280, 248),
                                          size=wxSize(61, 13),
                                          style=0)

        self.edtPrecoTotal = wxTextCtrl(id=wxID_FRMCONVENDASEDTPRECOTOTAL,
                                        name=u'edtPrecoTotal',
                                        parent=self,
                                        pos=wxPoint(344, 246),
                                        size=wxSize(127, 21),
                                        style=0,
                                        value=u'')
        self.edtPrecoTotal.Enable(False)

        self.btnLimpar = wxButton(id=wxID_FRMCONVENDASBTNLIMPAR,
                                  label=u'&Limpar',
                                  name=u'btnLimpar',
                                  parent=self,
                                  pos=wxPoint(312, 272),
                                  size=wxSize(75, 25),
                                  style=0)
        EVT_BUTTON(self.btnLimpar, wxID_FRMCONVENDASBTNLIMPAR,
                   self.OnBtnLimparButton)

        self.btnFechar = wxButton(id=wxID_FRMCONVENDASBTNFECHAR,
                                  label=u'&Fechar',
                                  name=u'btnFechar',
                                  parent=self,
                                  pos=wxPoint(392, 272),
                                  size=wxSize(75, 25),
                                  style=0)
        EVT_BUTTON(self.btnFechar, wxID_FRMCONVENDASBTNFECHAR,
                   self.OnBtnFecharButton)

        self.FazLayout()

        nLargura = (120, 100, 220, 100, 280, 80)
        sRotulos = ("Data/Hora Venda", "CPF", "Cliente", "ISBN", "Livro",
                    "Pre\xe7o")

        RotinasGlobais.Rotinas.AdicionaColunasGrid(self.gridVendas, 0, 6,
                                                   nLargura, sRotulos)
        self.gridVendas.EnableEditing(False)
        self.edtCPF.SetMaxLength(14)
        self.edtISBN.SetMaxLength(13)
        self.edtPrecoTotal.SetValue("R$ 0,00")
        self.edtDtHrVenda.SetValue(
            RotinasGlobais.Rotinas.retDataHoraStr(true, true))
        self.edtDtHrVenda.SetFocus()

    def FazLayout(self):
        self.sizer_1 = wxBoxSizer(wxVERTICAL)
        self.sizer_6 = wxBoxSizer(wxVERTICAL)
        self.sizer_22 = wxGridSizer(1, 2, 0, 0)
        self.sizer_23 = wxBoxSizer(wxVERTICAL)
        self.sizer_8 = wxBoxSizer(wxHORIZONTAL)
        self.sizer_7 = wxBoxSizer(wxHORIZONTAL)
        self.sizer_24 = wxBoxSizer(wxVERTICAL)
        self.sizer_4 = wxBoxSizer(wxHORIZONTAL)
        self.grid_sizer_8 = wxGridSizer(2, 1, 0, 0)
        self.grid_sizer_6 = wxGridSizer(2, 1, 0, 0)
        self.grid_sizer_5 = wxGridSizer(2, 1, 0, 0)
        self.sizer_3 = wxBoxSizer(wxHORIZONTAL)
        self.grid_sizer_4 = wxGridSizer(2, 1, 0, 0)
        self.grid_sizer_3 = wxGridSizer(2, 1, 0, 0)
        self.grid_sizer_2 = wxGridSizer(2, 1, 0, 0)
        self.sizer_2 = wxBoxSizer(wxHORIZONTAL)
        self.grid_sizer_1 = wxGridSizer(2, 1, 0, 0)
        self.grid_sizer_1.Add(self.labDtHrVenda, 0, wxALIGN_BOTTOM, 0)
        self.grid_sizer_1.Add(self.edtDtHrVenda, 0, 0, 0)
        self.sizer_2.Add(self.grid_sizer_1, 0, wxLEFT, 2)
        self.sizer_2.Add(self.btnPesquisar, 0, wxLEFT | wxTOP | wxALIGN_BOTTOM,
                         10)
        self.sizer_1.Add(self.sizer_2, 0, 0, 0)
        self.grid_sizer_2.Add(self.labCPF, 0, wxALIGN_BOTTOM, 0)
        self.grid_sizer_2.Add(self.edtCPF, 0, 0, 0)
        self.sizer_3.Add(self.grid_sizer_2, 0, wxLEFT, 2)
        self.grid_sizer_3.Add(self.labCliente, 0, wxALIGN_BOTTOM, 0)
        self.grid_sizer_3.Add(self.edtCliente, 0, 0, 0)
        self.sizer_3.Add(self.grid_sizer_3, 0, wxLEFT, 2)
        self.grid_sizer_4.Add(20, 20, 0, 0, 0)
        self.grid_sizer_4.Add(self.btnPCliente, 0, 0, 0)
        self.sizer_3.Add(self.grid_sizer_4, 0, 0, 0)
        self.sizer_1.Add(self.sizer_3, 0, 0, 0)
        self.grid_sizer_5.Add(self.labISBN, 0, wxALIGN_BOTTOM, 0)
        self.grid_sizer_5.Add(self.edtISBN, 0, 0, 0)
        self.sizer_4.Add(self.grid_sizer_5, 0, wxLEFT, 2)
        self.grid_sizer_6.Add(self.labLivro, 0, wxALIGN_BOTTOM, 0)
        self.grid_sizer_6.Add(self.edtLivro, 0, 0, 0)
        self.sizer_4.Add(self.grid_sizer_6, 0, wxLEFT, 2)
        self.grid_sizer_8.Add(20, 20, 0, 0, 0)
        self.grid_sizer_8.Add(self.btnPLivro, 0, 0, 0)
        self.sizer_4.Add(self.grid_sizer_8, 0, 0, 0)
        self.sizer_1.Add(self.sizer_4, 0, 0, 0)
        self.sizer_1.Add(self.gridVendas, 1, wxALL | wxEXPAND, 2)
        self.sizer_24.Add(self.labRegistro, 0, wxALL, 4)
        self.sizer_24.Add(20, 20, 0, 0, 0)
        self.sizer_22.Add(self.sizer_24, 0, 0, 0)
        self.sizer_7.Add(self.labPrecoTotal, 0, wxALL, 2)
        self.sizer_7.Add(self.edtPrecoTotal, 0, wxALL, 2)
        self.sizer_23.Add(self.sizer_7, 0, wxALL | wxALIGN_RIGHT, 2)
        self.sizer_8.Add(self.btnLimpar, 0,
                         wxALL | wxALIGN_RIGHT | wxALIGN_BOTTOM, 2)
        self.sizer_8.Add(self.btnFechar, 0,
                         wxALL | wxALIGN_RIGHT | wxALIGN_BOTTOM, 2)
        self.sizer_23.Add(self.sizer_8, 0, wxALL | wxALIGN_RIGHT, 2)
        self.sizer_22.Add(self.sizer_23, 1, wxALIGN_RIGHT | wxALIGN_BOTTOM, 0)
        self.sizer_6.Add(self.sizer_22, 0, wxEXPAND, 0)
        self.sizer_1.Add(self.sizer_6, 0, wxEXPAND, 0)
        self.SetAutoLayout(True)
        self.SetSizer(self.sizer_1)
        self.sizer_1.Fit(self)
        self.sizer_1.SetSizeHints(self)

    def __init__(self, parent):
        self._init_ctrls(parent)

    def ConsVenda(self, sOpcao):
        sret = ''
        ConsSQL = ConsultasSQL.ConsSQL
        if len(self.edtDtHrVenda.GetValue()) > 0:
            sDataHora = RotinasGlobais.Rotinas.ConverteDataHoraStr(
                self.edtDtHrVenda.GetValue(), True, "%m/%d/%Y", "%H:%M:%S")
        else:
            sDataHora = ""

        sISBN = self.edtISBN.GetValue()
        sCPF = self.edtCPF.GetValue()

        if sOpcao == 'L':
            sret = ConsSQL.Venda('S', "ZERO", "", "", "", "")
        else:
            sret = ConsSQL.Venda(sOpcao, sISBN, sCPF, sDataHora, "", "")

        return sret

    def OnEdtDtHrVendaKillFocus(self, event):
        if len(self.edtDtHrVenda.GetValue()) > 0:
            if not RotinasGlobais.Rotinas.validaDataHora(
                    self.edtDtHrVenda.GetValue(), False):
                wxMessageBox(Resource.STR_DTHRINV, "Erro", wxOK | wxICON_ERROR)
                self.edtDtHrVenda.SetFocus()
        event.Skip()

    def OnBtnPesquisarButton(self, event):
        Rotinas = RotinasGlobais.Rotinas
        ConsTotal = LISTAMSTR()

        if Rotinas.ConsultaDadosLista(Rotinas.gConexao, self.lstLinhas,
                                      self.ConsVenda('S')):
            Rotinas.AdicionaLinhasGrid(self.gridVendas, self.lstLinhas, 6)

            if Rotinas.ConsultaDadosLista(Rotinas.gConexao, ConsTotal,
                                          self.ConsVenda('P')):
                if len(ConsTotal.col) > 0:
                    nTemp = float(ConsTotal.col[0][0])
                    sPrecoTotal = fpformat.fix(nTemp, 2)
                    self.edtPrecoTotal.SetValue(sPrecoTotal)
        else:
            wxMessageBox(Resource.STR_VENNENC, "Erro", wxOK | wxICON_ERROR)
        event.Skip()

    def OnEdtISBNKillFocus(self, event):
        Rotinas = RotinasGlobais.Rotinas
        ConsCampo = LISTAMSTR()
        if len(self.edtISBN.GetValue()) > 0:
            if Rotinas.validaISBN(self.edtISBN.GetValue()):
                sLivro = Rotinas.ConsultaCampoDesc(
                    ConsCampo,
                    ConsultasSQL.ConsSQL.Livro('Q', self.edtISBN.GetValue(),
                                               "", "", "", "", "", "", "", "",
                                               ""), Resource.STR_LIVNENC)
                if len(sLivro) == 0:
                    self.edtISBN.Clear()
                    self.edtISBN.SetFocus()
                else:
                    self.edtLivro.SetValue(sLivro)
                    nQtdEstoque = int(ConsCampo.col[0][3])
                    if nQtdEstoque > 0:
                        Rotinas.sPreco = ConsCampo.col[0][2]
                    else:
                        wxMessageBox(Resource.STR_LIVNEST, "Erro",
                                     wxOK | wxICON_ERROR)
            else:
                wxMessageBox(Resource.STR_ISBNINV, "Erro", wxOK | wxICON_ERROR)
                self.edtISBN.Clear()
                self.edtISBN.SetFocus()
        else:
            self.edtLivro.Clear()
        event.Skip()

    def OnBtnPLivroButton(self, event):
        fConLivros = ConLivros.create(self)
        fConLivros.ShowModal()
        self.edtISBN.SetValue(RotinasGlobais.Rotinas.sCodigoSelecionado)
        self.OnEdtISBNKillFocus(event)
        event.Skip()

    def OnEdtCPFKillFocus(self, event):
        Rotinas = RotinasGlobais.Rotinas
        ConsSQL = ConsultasSQL.ConsSQL
        ConsCampo = LISTAMSTR()

        if len(self.edtCPF.GetValue()) > 0:
            if Rotinas.validaCPF(self.edtCPF.GetValue()):
                sCliente = Rotinas.ConsultaCampoDesc(
                    ConsCampo,
                    ConsSQL.Cliente('S', self.edtCPF.GetValue(), "", "", "",
                                    "", "", "", "", "", ""),
                    Resource.STR_CLINENC)
                if len(sCliente) == 0:
                    self.edtCPF.Clear()
                    self.edtCPF.SetFocus()
                else:
                    self.edtCliente.SetValue(sCliente)
            else:
                wxMessageBox(Resource.STR_CPFINV, "Erro", wxOK | wxICON_ERROR)
                self.edtCPF.Clear()
                self.edtCPF.SetFocus()
        else:
            self.edtCliente.Clear()

        event.Skip()

    def OnBtnPClienteButton(self, event):
        fConClientes = ConClientes.create(self)
        fConClientes.ShowModal()
        self.edtCPF.SetValue(RotinasGlobais.Rotinas.sCodigoSelecionado)
        self.OnEdtCPFKillFocus(event)
        event.Skip()

    def setLabRegistros(self, nLinha):
        if nLinha >= 0:
            self.labRegistro.SetLabel("Registro " + str(nLinha+1) + " de " +\
              str(self.gridVendas.GetNumberRows()))

    def OnGridVendasGridSelectCell(self, event):
        self.setLabRegistros(event.GetRow())
        event.Skip()

    def OnGridVendasGridLabelLeftClick(self, event):
        self.setLabRegistros(event.GetRow())
        event.Skip()

    def OnBtnLimparButton(self, event):
        self.edtCPF.Clear()
        self.edtCliente.Clear()
        self.edtISBN.Clear()
        self.edtLivro.Clear()
        self.gridVendas.ClearGrid()
        self.gridVendas.DeleteRows(0,
                                   self.gridVendas.GetNumberRows() - 1, True)
        self.edtPrecoTotal.SetValue("R$ 0,00")
        self.edtDtHrVenda.SetValue(
            RotinasGlobais.Rotinas.retDataHoraStr(True, True))
        self.labRegistro.SetLabel("Registro 0 de 0")
        self.edtDtHrVenda.SetFocus()
        event.Skip()

    def OnBtnFecharButton(self, event):
        self.GetParent().Close(True)

    def OnFrmConVendasClose(self, event):
        self.Destroy()
Exemple #27
0
class frmConsultas(wxDialog):
    lstLinhas = LISTAMSTR()
    sSelecionado = ''
    nRegistro = 0

    def _init_ctrls(self, prnt):
        wxDialog.__init__(self,
                          id=wxID_FRMCONSULTAS,
                          name=u'frmConsultas',
                          parent=prnt,
                          pos=wxPoint(0, 0),
                          size=wxSize(355, 263),
                          style=wxDEFAULT_DIALOG_STYLE | wxCAPTION
                          | wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX,
                          title=u'Consulta de ')
        self.SetIcon(wxIcon(Resource.ICO_LIVRUS, wxBITMAP_TYPE_ICO))
        self.SetClientSize(wxSize(355, 263))
        self.Centre(wxBOTH)
        EVT_CLOSE(self, self.OnFrmConsultasClose)

        self.labDescricao = wxStaticText(id=wxID_FRMCONSULTASLABDESCRICAO,
                                         label=u'Descri\xe7\xe3o:',
                                         name=u'labDescricao',
                                         parent=self,
                                         pos=wxPoint(8, 8),
                                         size=wxSize(51, 13),
                                         style=0)

        self.edtDescricao = wxTextCtrl(id=wxID_FRMCONSULTASEDTDESCRICAO,
                                       name=u'edtDescricao',
                                       parent=self,
                                       pos=wxPoint(8, 24),
                                       size=wxSize(257, 21),
                                       style=0,
                                       value=u'')

        self.btnPesquisar = wxButton(id=wxID_FRMCONSULTASBTNPESQUISAR,
                                     label=u'&Pesquisar',
                                     name=u'btnPesquisar',
                                     parent=self,
                                     pos=wxPoint(272, 24),
                                     size=wxSize(75, 25),
                                     style=0)

        self.gridConsulta = wxGrid(id=wxID_FRMCONSULTASGRIDCONSULTA,
                                   name='gridConsulta',
                                   parent=self,
                                   pos=wxPoint(0, 56),
                                   size=wxSize(355, 125),
                                   style=wxSUNKEN_BORDER)
        self.gridConsulta.CreateGrid(1, 2, wxGrid.wxGridSelectRows)
        self.gridConsulta.SetColLabelValue(0, u'C\xf3digo')
        self.gridConsulta.SetColSize(0, 80)
        self.gridConsulta.SetColLabelValue(1, u'Descri\xe7\xe3o')
        self.gridConsulta.SetColSize(1, 180)
        self.gridConsulta.EnableEditing(false)
        self.gridConsulta.HideCellEditControl()
        self.gridConsulta.SetColLabelSize(21)

        self.labRegistro = wxStaticText(id=wxID_FRMCONSULTASLABREGISTRO,
                                        label=u'Registro 0 de 0',
                                        name=u'labRegistro',
                                        parent=self,
                                        pos=wxPoint(8, 16),
                                        size=wxSize(144, 13),
                                        style=0)

        self.btnLimpar = wxButton(id=wxID_FRMCONSULTASBTNLIMPAR,
                                  label=u'&Limpar',
                                  name=u'btnLimpar',
                                  parent=self,
                                  pos=wxPoint(188, 13),
                                  size=wxSize(75, 25),
                                  style=0)

        self.btnFechar = wxButton(id=wxID_FRMCONSULTASBTNFECHAR,
                                  label=u'&Fechar',
                                  name=u'btnFechar',
                                  parent=self,
                                  pos=wxPoint(268, 13),
                                  size=wxSize(75, 25),
                                  style=0)
        EVT_BUTTON(self.btnFechar, wxID_FRMCONSULTASBTNFECHAR,
                   self.OnBtnFecharClick)

        self.FazLayout()

        self.edtDescricao.SetFocus()
        self.nRegistro = 0

    def __init__(self, parent):
        self._init_ctrls(parent)

    def FazLayout(self):
        self.sizer_1 = wxBoxSizer(wxVERTICAL)
        self.gird_sizer_2 = wxGridSizer(1, 2, 0, 0)
        self.sizer_2 = wxBoxSizer(wxHORIZONTAL)
        self.sizer_3 = wxBoxSizer(wxHORIZONTAL)
        self.sizer_4 = wxBoxSizer(wxVERTICAL)
        self.grid_sizer_1 = wxGridSizer(2, 1, 0, 0)
        self.grid_sizer_1.Add(self.labDescricao, 0, wxALIGN_BOTTOM, 0)
        self.grid_sizer_1.Add(self.edtDescricao, 0, 0, 0)
        self.sizer_3.Add(self.grid_sizer_1, 0, wxALL, 2)
        self.sizer_4.Add(20, 20, 0, 0, 0)
        self.sizer_4.Add(self.btnPesquisar, 0, wxLEFT | wxTOP | wxBOTTOM, 5)
        self.sizer_3.Add(self.sizer_4, 0, 0, 0)
        self.sizer_1.Add(self.sizer_3, 0, wxALL, 4)
        self.sizer_1.Add(self.gridConsulta, 1, wxEXPAND, 0)
        self.gird_sizer_2.Add(self.labRegistro, 0, wxALL, 10)
        self.sizer_2.Add(self.btnLimpar, 0, wxALIGN_RIGHT | wxALIGN_BOTTOM, 8)
        self.sizer_2.Add(self.btnFechar, 0,
                         wxLEFT | wxALIGN_RIGHT | wxALIGN_BOTTOM, 8)
        self.gird_sizer_2.Add(self.sizer_2, 1,
                              wxALL | wxALIGN_RIGHT | wxALIGN_BOTTOM, 4)
        self.sizer_1.Add(self.gird_sizer_2, 0,
                         wxALL | wxEXPAND | wxALIGN_BOTTOM, 0)
        self.SetAutoLayout(true)
        self.SetSizer(self.sizer_1)
        self.sizer_1.Fit(self)
        self.sizer_1.SetSizeHints(self)
        self.Layout()

    def OnBtnFecharClick(self, event):
        self.Close(True)

    def OnFrmConsultasClose(self, event):
        self.Destroy()

    def Fecha(self, nIndMenu):
        if len(self.sSelecionado) > 0:
            RotinasGlobais.Rotinas.sCodigoSelecionado = self.sSelecionado
        else:
            RotinasGlobais.Rotinas.sCodigoSelecionado = ""

        if nIndMenu == 0:
            if self.IsModal():
                self.EndModal(True)
            else:
                self.Close()
        else:
            Principal.fPrincipal.BarraDeMenu.GetMenu(1).Enable(nIndMenu, True)

    def LimparDados(self):
        self.labRegistro.SetLabel("Registro 0 de 0")
        self.gridConsulta.ClearGrid()
        self.gridConsulta.DeleteRows(0,
                                     self.gridConsulta.GetNumberRows() - 1,
                                     True)
        self.edtDescricao.Clear()
        self.edtDescricao.SetFocus()

    def PesquisarDados(self, sTextoSql, sMensagemErro, nQtdCol):
        Rotinas = RotinasGlobais.Rotinas
        if Rotinas.ConsultaDadosLista(Rotinas.gConexao, self.lstLinhas,
                                      sTextoSql):
            Rotinas.AdicionaLinhasGrid(self.gridConsulta, self.lstLinhas,
                                       nQtdCol)
        else:
            wxMessageBox(sMensagemErro, "Erro", wxOK | wxICON_ERROR)

    def setLabRegistros(self, nLinha):
        if nLinha >= 0:
            self.labRegistro.SetLabel("Registro " + str(nLinha+1) + " de " +\
              str(self.gridConsulta.GetNumberRows()))
            self.sSelecionado = self.gridConsulta.GetCellValue(nLinha, 0)
Exemple #28
0
    def __init__(self, clienteMDI, iconeMDI, menuMDI):
        frmCadastros.__init__(self, clienteMDI, Resource.STR_CONVENLIVRO,
                              iconeMDI, menuMDI, TEXTFIELD_NORMAL, False)

        self.Rotinas = RotinasGlobais.Rotinas
        self.ConsSQL = ConsultasSQL.ConsSQL

        FXMAPFUNC(self, SEL_COMMAND, frmConVendas.ID_FRMCONVENDAS_BTNPESQUISAR,
                  frmConVendas.onBtnPesquisar)
        FXMAPFUNC(self, SEL_COMMAND, frmConVendas.ID_FRMCONVENDAS_BTNLIMPAR,
                  frmConVendas.onBtnLimpar)
        FXMAPFUNC(self, SEL_COMMAND, frmConVendas.ID_FRMCONVENDAS_BTNFECHAR,
                  frmConVendas.onBtnFechar)
        FXMAPFUNC(self, SEL_CLOSE, 0, frmConVendas.onClose)
        FXMAPFUNC(self, SEL_COMMAND, frmConVendas.ID_FRMCONVENDAS_BTNPCLIENTE,
                  frmConVendas.onBtnPCliente)
        FXMAPFUNC(self, SEL_COMMAND, frmConVendas.ID_FRMCONVENDAS_BTNPLIVRO,
                  frmConVendas.onBtnPLivro)
        FXMAPFUNC(self, SEL_FOCUSOUT,
                  frmConVendas.ID_FRMCONVENDAS_EDTDTHRVENDA,
                  frmConVendas.onEdtDtHrVenda_Killfocus)
        FXMAPFUNC(self, SEL_FOCUSOUT, frmConVendas.ID_FRMCONVENDAS_EDTISBN,
                  frmConVendas.onEdtISBN_Killfocus)
        FXMAPFUNC(self, SEL_FOCUSOUT, frmConVendas.ID_FRMCONVENDAS_EDTCPF,
                  frmConVendas.onEdtCPF_Killfocus)
        FXMAPFUNC(self, SEL_SELECTED, frmConVendas.ID_FRMCONVENDAS_GRIDVENDAS,
                  frmConVendas.onGridSelected)
        FXMAPFUNC(self, SEL_CHANGED, frmConVendas.ID_FRMCONVENDAS_GRIDVENDAS,
                  frmConVendas.onGridChanged)

        self.resize(500, 370)
        self.labCodigo.hide()
        self.edtCodigo.hide()
        self.labDescricao.hide()
        self.edtDescricao.hide()
        self.btnNovo.hide()

        frame10 = FXHorizontalFrame(self.frame3, LAYOUT_LEFT, 0, 0, 0, 0, 0, 0,
                                    0, 0)
        frame11 = FXVerticalFrame(frame10, LAYOUT_LEFT, 0, 0, 0, 0, 0, 0, 0, 0)
        frame12 = FXVerticalFrame(frame10, LAYOUT_LEFT | LAYOUT_BOTTOM, 0, 0,
                                  0, 0, 0, 0, 0, 0)

        frame13 = FXHorizontalFrame(self.frame3, LAYOUT_LEFT, 0, 0, 0, 0, 0, 0,
                                    0, 0)
        frame14 = FXVerticalFrame(frame13, LAYOUT_LEFT, 0, 0, 0, 0, 0, 0, 0, 0)
        frame15 = FXVerticalFrame(frame13, LAYOUT_LEFT, 0, 0, 0, 0, 0, 0, 0, 0)
        frame16 = FXVerticalFrame(frame13, LAYOUT_LEFT | LAYOUT_BOTTOM, 0, 0,
                                  0, 0, 0, 0, 0, 0)

        frame17 = FXHorizontalFrame(self.frame3, LAYOUT_LEFT, 0, 0, 0, 0, 0, 0,
                                    0, 0)
        frame18 = FXVerticalFrame(frame17, LAYOUT_LEFT, 0, 0, 0, 0, 0, 0, 0, 0)
        frame19 = FXVerticalFrame(frame17, LAYOUT_LEFT, 0, 0, 0, 0, 0, 0, 0, 0)
        frame20 = FXHorizontalFrame(frame17, LAYOUT_LEFT | LAYOUT_BOTTOM, 0, 0,
                                    0, 0, 0, 0, 0, 0)

        frame21 = FXVerticalFrame(self.frame,
                                  LAYOUT_LEFT | LAYOUT_FILL_X | LAYOUT_FILL_Y,
                                  0, 0, 0, 0, 0, 0, 0, 0)

        frame22 = FXHorizontalFrame(self.frame, LAYOUT_FILL_X, 0, 0, 0, 0, 0,
                                    0, 0, 0)
        frame23 = FXHorizontalFrame(frame22, LAYOUT_LEFT, 0, 0, 0, 0, 0, 0, 0,
                                    0)
        frame24 = FXHorizontalFrame(frame22, LAYOUT_RIGHT, 0, 0, 0, 0, 0, 0, 0,
                                    0)

        frame25 = FXHorizontalFrame(self.frame, LAYOUT_BOTTOM | LAYOUT_RIGHT)

        labDtHrVenda = FXLabel(frame11, "Data/Hora Venda:", None, LAYOUT_LEFT,
                               8, 8, 91, 13)
        self.edtDtHrVenda = FXTextField(
            frame11, 19, self, frmConVendas.ID_FRMCONVENDAS_EDTDTHRVENDA,
            TEXTFIELD_LIMITED | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FIX_WIDTH
            | LAYOUT_FIX_HEIGHT, 8, 24, 128, 21, 3, 20)

        self.btnPesquisar = FXButton(
            frame12, "&Pesquisar", None, self,
            frmConVendas.ID_FRMCONVENDAS_BTNPESQUISAR,
            FRAME_RAISED | FRAME_THICK | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT
            | LAYOUT_RIGHT, 144, 22, 75, 25, 15, 15, 3, 3)

        labCPF = FXLabel(frame14, "CPF:", None, LAYOUT_LEFT, 8, 48, 48, 13)
        self.edtCPF = FXTextField(
            frame14, 14, self, frmConVendas.ID_FRMCONVENDAS_EDTCPF,
            TEXTFIELD_LIMITED | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FIX_WIDTH
            | LAYOUT_FIX_HEIGHT, 8, 64, 128, 21, 3, 20)

        labCliente = FXLabel(frame15, "Cliente:", None, LAYOUT_LEFT, 142, 48,
                             56, 13)
        self.edtDescricao.hide()
        self.edtCliente = FXTextField(
            frame15, 30, None, 0, TEXTFIELD_LIMITED | FRAME_SUNKEN
            | FRAME_THICK | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT, 142, 64, 306,
            21, 3, 20)
        self.edtCliente.disable()
        self.btnPCliente = FXButton(
            frame16, "...", None, self,
            frmConVendas.ID_FRMCONVENDAS_BTNPCLIENTE, FRAME_RAISED
            | FRAME_THICK | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT | LAYOUT_LEFT,
            448, 64, 21, 21, 10, 10, 3, 3)

        labISBN = FXLabel(frame18, "ISBN:", None, LAYOUT_LEFT, 8, 88, 48, 13)
        self.edtISBN = FXTextField(
            frame18, 13, self, frmConVendas.ID_FRMCONVENDAS_EDTISBN,
            TEXTFIELD_LIMITED | FRAME_SUNKEN | FRAME_THICK | LAYOUT_FIX_WIDTH
            | LAYOUT_FIX_HEIGHT, 8, 104, 128, 21, 3, 20)

        labLivro = FXLabel(frame19, "Livro:", None, LAYOUT_LEFT, 142, 88, 40,
                           13)
        self.edtLivro = FXTextField(
            frame19, 30, None, 0, TEXTFIELD_LIMITED | FRAME_SUNKEN
            | FRAME_THICK | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT, 142, 104,
            306, 21, 3, 20)
        self.edtLivro.disable()
        self.btnPLivro = FXButton(
            frame20, "...", None, self, frmConVendas.ID_FRMCONVENDAS_BTNPLIVRO,
            FRAME_RAISED | FRAME_THICK | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT
            | LAYOUT_LEFT, 448, 104, 21, 21, 10, 10, 3, 3)

        self.gridVendas = FXTable(
            frame21, 2, 7, self, frmConVendas.ID_FRMCONVENDAS_GRIDVENDAS,
            TABLE_COL_SIZABLE | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 136, 355,
            122)
        self.Rotinas.IniciaLayoutGrid(self.gridVendas, 2, 7)

        self.labRegistro = FXLabel(frame23, "Registro 0 de 0", None,
                                   LAYOUT_LEFT, 8, 16, 144, 13)
        labPrecoTotal = FXLabel(frame24, "Preço Total:", None, LAYOUT_LEFT,
                                280, 248, 61, 13)
        self.edtPrecoTotal = FXTextField(
            frame24, 50, None, 0, TEXTFIELD_LIMITED | FRAME_SUNKEN
            | FRAME_THICK | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT, 344, 246,
            127, 21, 3, 20)
        self.edtPrecoTotal.disable()

        self.btnFechar = FXButton(
            frame25, "&Fechar", None, self,
            frmConVendas.ID_FRMCONVENDAS_BTNFECHAR, FRAME_RAISED | FRAME_THICK
            | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT | LAYOUT_RIGHT, 75, 13, 75,
            25, 15, 15, 3, 3)
        self.btnLimpar = FXButton(
            frame25, "&Limpar", None, self,
            frmConVendas.ID_FRMCONVENDAS_BTNLIMPAR, FRAME_RAISED | FRAME_THICK
            | LAYOUT_FIX_WIDTH | LAYOUT_FIX_HEIGHT | LAYOUT_RIGHT, 16, 13, 75,
            25, 15, 15, 3, 3)

        nLargura = [120, 100, 220, 100, 280, 80]
        sRotulos = [
            "Data/Hora Venda", "CPF", "Cliente", "ISBN", "Livro", "Preço"
        ]

        self.Rotinas.AdicionaColunasGrid(self.gridVendas, 1, 6, nLargura,
                                         sRotulos)
        self.edtPrecoTotal.setText("R$ 0,00")
        self.edtDtHrVenda.setText(self.Rotinas.retDataHoraStr(True, True))
        self.edtDtHrVenda.setFocus()

        self.lstLinhas = LISTAMSTR()
Exemple #29
0
class frmCadastros(wxPanel):
    lstRegistros = LISTAMSTR()
    nLinhaRegistro = 0

    def _init_utils(self):
        pass

    def _init_ctrls(self, prnt, nFiltroCodigo, bIniciaBotoes):
        wxPanel.__init__(self,
                         id=wxID_FRMCADASTROS,
                         name=u'frmCadastros',
                         parent=prnt,
                         pos=wxPoint(398, 295),
                         size=wxSize(338, 163),
                         style=wxTAB_TRAVERSAL)
        self._init_utils()
        self.SetClientSize(wxSize(330, 136))
        EVT_CLOSE(self, self.OnFrmcadastrosClose)

        self.labCodigo = wxStaticText(id=wxID_FRMCADASTROSLABCODIGO,
                                      label=u'C\xf3digo:',
                                      name=u'labCodigo',
                                      parent=self,
                                      pos=wxPoint(8, 8),
                                      size=wxSize(36, 13),
                                      style=0)

        self.edtCodigo = wxTextCtrl(id=wxID_FRMCADASTROSEDTCODIGO,
                                    name=u'edtCodigo',
                                    parent=self,
                                    pos=wxPoint(8, 24),
                                    size=wxSize(121, 21),
                                    style=0,
                                    validator=TextValidator(nFiltroCodigo),
                                    value=u'')
        self.edtCodigo.SetMaxLength(10)
        self.btnNovo = wxButton(id=wxID_FRMCADASTROSBTNNOVO,
                                label=u'&Novo',
                                name=u'btnNovo',
                                parent=self,
                                pos=wxPoint(144, 24),
                                size=wxSize(75, 25),
                                style=0)

        self.labDescricao = wxStaticText(id=wxID_FRMCADASTROSLABDESCRICAO,
                                         label=u'Descri\xe7\xe3o:',
                                         name=u'labDescricao',
                                         parent=self,
                                         pos=wxPoint(8, 48),
                                         size=wxSize(51, 13),
                                         style=0)

        self.edtDescricao = wxTextCtrl(id=wxID_FRMCADASTROSEDTDESCRICAO,
                                       name=u'edtDescricao',
                                       parent=self,
                                       pos=wxPoint(8, 64),
                                       size=wxSize(217, 21),
                                       style=0,
                                       value=u'')
        self.edtDescricao.Enable(False)
        self.edtDescricao.SetMaxLength(30)

        if bIniciaBotoes:
            self.IniciaBotoes()
            self.FazLayout()

        self.nLinhaRegistro = 0

    def __init__(self, parent, id, pos, size, style, name):
        self._init_ctrls(parent)

    # Necessario por causa da tabulacao dos campos
    def IniciaBotoes(self):
        self.btnPesquisar = wxButton(id=wxID_FRMCADASTROSBTNPESQUISAR,
                                     label=u'&Pesquisar',
                                     name=u'btnPesquisar',
                                     parent=self,
                                     pos=wxPoint(248, 8),
                                     size=wxSize(75, 25),
                                     style=0)
        self.btnAnterior = wxButton(id=wxID_FRMCADASTROSBTNANTERIOR,
                                    label=u'&Anterior',
                                    name=u'btnAnterior',
                                    parent=self,
                                    pos=wxPoint(248, 40),
                                    size=wxSize(75, 25),
                                    style=0)
        self.btnAnterior.Enable(False)
        self.btnProximo = wxButton(id=wxID_FRMCADASTROSBTNPROXIMO,
                                   label=u'Pr\xf3xi&mo',
                                   name=u'btnProximo',
                                   parent=self,
                                   pos=wxPoint(248, 72),
                                   size=wxSize(75, 25),
                                   style=0)
        self.btnProximo.Enable(False)
        self.btnSalvar = wxButton(id=wxID_FRMCADASTROSBTNSALVAR,
                                  label=u'&Salvar',
                                  name=u'btnSalvar',
                                  parent=self,
                                  pos=wxPoint(8, 104),
                                  size=wxSize(75, 25),
                                  style=0)
        self.btnSalvar.Enable(False)
        self.btnExcluir = wxButton(id=wxID_FRMCADASTROSBTNEXCLUIR,
                                   label=u'&Excluir',
                                   name=u'btnExcluir',
                                   parent=self,
                                   pos=wxPoint(88, 104),
                                   size=wxSize(75, 25),
                                   style=0)
        self.btnExcluir.Enable(False)
        self.btnLimpar = wxButton(id=wxID_FRMCADASTROSBTNLIMPAR,
                                  label=u'&Limpar',
                                  name=u'btnLimpar',
                                  parent=self,
                                  pos=wxPoint(168, 104),
                                  size=wxSize(75, 25),
                                  style=0)
        self.btnFechar = wxButton(id=wxID_FRMCADASTROSBTNFECHAR,
                                  label=u'&Fechar',
                                  name=u'btnFechar',
                                  parent=self,
                                  pos=wxPoint(248, 104),
                                  size=wxSize(75, 25),
                                  style=0)
        self.btnLimparClick()

    def FazLayout(self):
        self.sizer_1 = wxBoxSizer(wxVERTICAL)
        self.sizer_2 = wxBoxSizer(wxHORIZONTAL)
        self.sizer_3 = wxBoxSizer(wxHORIZONTAL)
        self.sizer_4 = wxBoxSizer(wxVERTICAL)
        self.sizer_5 = wxBoxSizer(wxVERTICAL)
        self.grid_sizer_2 = wxGridSizer(2, 1, 0, 0)
        self.grid_sizer_1 = wxGridSizer(2, 2, 0, 1)
        self.grid_sizer_1.Add(self.labCodigo, 0, wxALIGN_BOTTOM, 0)
        self.grid_sizer_1.Add(20, 10, 0, 0, 0)
        self.grid_sizer_1.Add(self.edtCodigo, 0, 0, 0)
        self.grid_sizer_1.Add(self.btnNovo, 0, wxLEFT, 6)
        self.sizer_5.Add(self.grid_sizer_1, 0, 0, 0)
        self.grid_sizer_2.Add(self.labDescricao, 0, wxALIGN_BOTTOM, 0)
        self.grid_sizer_2.Add(self.edtDescricao, 0, 0, 2)
        self.sizer_5.Add(self.grid_sizer_2, 0, 0, 0)
        self.sizer_3.Add(self.sizer_5, 1, 0, 0)
        self.sizer_4.Add(self.btnPesquisar, 0, wxALL | wxALIGN_RIGHT, 2)
        self.sizer_4.Add(self.btnAnterior, 0, wxALL | wxALIGN_RIGHT, 2)
        self.sizer_4.Add(self.btnProximo, 0, wxALL | wxALIGN_RIGHT, 2)
        self.sizer_3.Add(self.sizer_4, 0, wxALIGN_RIGHT, 0)
        self.sizer_1.Add(self.sizer_3, 1, wxALL | wxEXPAND, 4)
        self.sizer_2.Add(self.btnSalvar, 0,
                         wxALL | wxALIGN_RIGHT | wxALIGN_BOTTOM, 2)
        self.sizer_2.Add(self.btnExcluir, 0,
                         wxALL | wxALIGN_RIGHT | wxALIGN_BOTTOM, 2)
        self.sizer_2.Add(self.btnLimpar, 0,
                         wxALL | wxALIGN_RIGHT | wxALIGN_BOTTOM, 2)
        self.sizer_2.Add(self.btnFechar, 0,
                         wxALL | wxALIGN_RIGHT | wxALIGN_BOTTOM, 2)
        self.sizer_1.Add(self.sizer_2, 0,
                         wxALL | wxALIGN_RIGHT | wxALIGN_BOTTOM, 4)
        self.SetAutoLayout(True)
        self.SetSizer(self.sizer_1)
        self.sizer_1.Fit(self)
        self.sizer_1.SetSizeHints(self)

    def InformaLimpaDados(self, bInformar):
        if bInformar:
            self.edtCodigo.SetValue(
                self.lstRegistros.col[self.nLinhaRegistro][0])
            self.edtDescricao.SetValue(
                self.lstRegistros.col[self.nLinhaRegistro][1])
        else:
            self.edtCodigo.Clear()
            self.edtDescricao.Clear()
            self.edtCodigo.Enable(True)
            self.edtCodigo.SetFocus()

    def HabilitaDados(self, bHabilita):
        self.edtDescricao.Enable(bHabilita)

    def btnNovoClick(self):
        self.btnSalvar.Enable(True)
        self.btnExcluir.Enable(False)
        self.btnPesquisar.Enable(False)
        self.btnAnterior.Enable(False)
        self.btnProximo.Enable(False)
        self.btnNovo.Enable(False)

        self.nLinhaRegistro = 0
        self.InformaLimpaDados(False)
        self.HabilitaDados(True)

    def NovoDado(self, sTextoSql):
        Rotinas = RotinasGlobais.Rotinas
        lstRegs = LISTAMSTR()

        if Rotinas.ConsultaDadosLista(Rotinas.gConexao, lstRegs, sTextoSql):
            self.edtCodigo.SetValue(str(lstRegs.col[0][0]))
            self.edtCodigo.Enable(False)
            self.edtDescricao.SetFocus()

    def btnLimparClick(self):
        self.nLinhaRegistro = 0
        self.btnSalvar.Enable(False)
        self.btnExcluir.Enable(False)
        self.btnPesquisar.Enable(True)
        self.btnAnterior.Enable(False)
        self.btnProximo.Enable(False)
        self.btnNovo.Enable(True)

        self.nLinhaRegistro = 0
        self.InformaLimpaDados(False)
        self.HabilitaDados(False)

    def ExcluirDados(self, bValidaDados, sTextoSql):
        if bValidaDados:
            if wxMessageBox(Resource.STR_CERTEXCL, "Confirme",
                            wxICON_QUESTION | wxYES_NO) == wxYES:
                Rotinas = RotinasGlobais.Rotinas
                if Rotinas.AtualizaDados(Rotinas.gConexao, sTextoSql):
                    self.btnLimparClick()
                    return True
        return False

    def PesquisarDados(self, sTextoSql, sMensagemErro):
        if len(self.edtCodigo.GetValue()) == 0:
            self.btnAnterior.Enable(True)
            self.btnProximo.Enable(True)

        Rotinas = RotinasGlobais.Rotinas
        if Rotinas.ConsultaDadosLista(Rotinas.gConexao, self.lstRegistros,
                                      sTextoSql):
            self.InformaLimpaDados(True)
            self.HabilitaDados(True)

            self.btnSalvar.Enable(True)
            self.btnExcluir.Enable(True)
            self.btnPesquisar.Enable(False)
            return True
        else:
            wxMessageBox(sMensagemErro, "Erro", wxOK | wxICON_ERROR)

        return False

    def registroAnterior(self):
        if self.nLinhaRegistro > 0:
            self.nLinhaRegistro = self.nLinhaRegistro - 1
            self.InformaLimpaDados(True)
            return True
        else:
            return False

    def registroProximo(self):
        if self.nLinhaRegistro < (self.lstRegistros.tam - 1):
            self.nLinhaRegistro = self.nLinhaRegistro + 1
            self.InformaLimpaDados(True)
            return True
        else:
            return False

    def SalvarDados(self, bValidaDados, sTextoSql, sTextoUpdate, sTextoInsert,
                    bLimparDados):

        if bValidaDados:
            Rotinas = RotinasGlobais.Rotinas
            if Rotinas.ConsultaDados(Rotinas.gConexao, sTextoSql):
                sArquiva = sTextoUpdate
            else:
                sArquiva = sTextoInsert

            if Rotinas.AtualizaDados(Rotinas.gConexao, sArquiva):
                if bLimparDados:
                    self.btnLimparClick()
                return True

        return False

    def OnFrmcadastrosClose(self, event):
        self.Destroy()