Esempio n. 1
0
 private void gvPesquisa_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         if (e.RowIndex > -1 && e.RowIndex < gvPesquisa.Rows.Count)
         {
             int cod = 0;
             cod = int.Parse(gvPesquisa.Rows[e.RowIndex].Cells[0].Value.ToString());
             if (cod != 0)
             {
                 TabControl1.SelectedIndex = 0;
                 txtPesquisar.Text         = "";
                 objCom.com_codigo         = cod;
                 objCom.localizar(objCom.com_codigo.ToString(), "com_codigo");
                 txtCodigo.Text = objCom.com_codigo.ToString();
                 txtCodigo.Text = objCom.com_codigo.ToString();
                 txtNumero_Leave(sender, e);
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
 }
Esempio n. 2
0
 private void txtCompra_Leave(object sender, EventArgs e)
 {
     try
     {
         // Localizar usuário
         int cod;
         int.TryParse(txtCompra.Text, out cod);
         if (cod != 0)
         {
             objCAP.limpar();
             objCAP.localizarLeave(cod.ToString(), "cp_compras");
             //if (objCAP.cp_codigo != 0)
             //{
             //    carregaCampos();
             //    txtCodigo.Enabled = false;
             //}
             //else //não há registros em contas a pagar, mas pode ter uma compra
             //{
             objCom = new ComprasBLL();    //
             objCom.localizar(cod.ToString(), "com_codigo");
             if (objCom.com_codigo != 0)
             {
                 FornecedoresBLL objFor = new FornecedoresBLL();
                 objFor.localizar(objCom.com_fornecedor.ToString(), "for_codigo");
                 if (objFor.for_tipo == "Não")
                 {
                     cbPrestServ.Checked = false;
                 }
                 else
                 {
                     cbPrestServ.Checked = true;
                 }
                 //if (objFor.for_tipo_fornecedor == "Pessoa Jurídica")
                 //    cbPessoaJuridica.Checked = true;
                 //else
                 //    cbPessoaJuridica.Checked = false;
                 cbFornPresServ.SelectedValue = objFor.for_codigo;
                 //cbPessoaJuridica.Enabled = false;
                 cbPrestServ.Enabled    = false;
                 cbFornPresServ.Enabled = false;
                 //}
             }
         }
         else
         {
             limpar();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
     }
 }
Esempio n. 3
0
        public void carregaPropriedades()
        {
            try
            {
                if (txtCodigo.Text != "")
                {
                    objCAP.cp_codigo = int.Parse(txtCodigo.Text);
                }
                else
                {
                    objCAP.cp_codigo = 0;
                }
                if (!cbPrestServ.Checked)  //Fornecedores
                {
                    if (txtCompra.Text != "")
                    {
                        objCom = new ComprasBLL();
                        objCom.localizar(txtCompra.Text, "com_codigo");
                        if (objCom.com_codigo == 0)
                        {
                            throw new Exception("Compra inexistente, por favor, selecione uma compra válida");
                        }
                        objCAP.cp_compras = objCom.com_codigo;
                        objCom            = null;
                    }
                    else
                    {
                        throw new Exception("Não é possível gerar uma conta a pagar sem o número da compra do Fornecedor");
                    }
                }
                else  //Prestadores de Serviço
                if (txtCompra.Text != "")
                {
                    throw new Exception("Não é possivel referenciar uma compra para um prestador de serviço");
                }
                else
                {
                    objCAP.cp_compras = 0;
                }
                if (cbFornPresServ.SelectedValue == null)
                {
                    throw new Exception("Fornecedor não encontrado na base de dados");
                }
                else
                {
                    objCAP.cp_fornecedor = int.Parse(cbFornPresServ.SelectedValue.ToString());
                }
                txtTitulo.Text = txtTitulo.Text.Trim();
                if (txtTitulo.Text != "")
                {
                    objCAP.cp_titulo = txtTitulo.Text;
                }
                else
                {
                    throw new Exception("Título é um campo obrigatório");
                }
                if (txtSerie.Text != "")
                {
                    objCAP.cp_serie = txtSerie.Text;
                }
                else
                {
                    throw new Exception("Série é um campo obrigatório");
                }
                if (txtDataEmissao.Text != "  /  /")
                {
                    objCAP.cp_emissao = DateTime.Parse(txtDataEmissao.Text);
                }
                else
                {
                    throw new Exception("Date de emissão é um campo obrigatório");
                }
                if (txtDataValidade.Text != "  /  /")
                {
                    objCAP.cp_vencimento = DateTime.Parse(txtDataValidade.Text);
                }
                else
                {
                    throw new Exception("Date de vencimento é um campo obrigatório");
                }

                String x = "";
                for (int i = 0; i <= txtValor.Text.Length - 1; i++)
                {
                    if ((txtValor.Text[i] >= '0' &&
                         txtValor.Text[i] <= '9') ||
                        txtValor.Text[i] == ',')
                    {
                        x += txtValor.Text[i];
                    }
                }
                txtValor.Text = x;

                if (txtValor.Text != "")
                {
                    objCAP.cp_valor = decimal.Parse(txtValor.Text);
                }
                else
                {
                    throw new Exception("Valor é um campo obrigatório");
                }
                if (cbSituacao.SelectedIndex == -1)
                {
                    throw new Exception("Por favor, selecione a situação da conta");
                }
                else
                {
                    objCAP.cp_status = cbSituacao.SelectedItem.ToString();
                }
                if (objCAP.cp_status == "Aberto")
                {
                    objCAP.cp_dataPagamento = null;
                }
                else
                {
                    objCAP.cp_dataPagamento = DateTime.Now.Date;
                }
                txtObservacoes.Text  = txtObservacoes.Text.Trim();
                objCAP.cp_observacao = txtObservacoes.Text;
            }
            catch (Exception)
            {
                throw;
            }
        }