Exemple #1
0
        private void bExcluir_Click(object sender, EventArgs e)
        {
            DialogResult resultado = MessageBox.Show("Confirma exclusão deste cliente ?", "Confirma Exclusão", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (resultado == DialogResult.Yes)
            {
                if (dgvCadastro.SelectedRows.Count > 0)
                {
                    cliid = Convert.ToInt32(dgvCadastro.CurrentRow.Cells["cli_id"].Value);
                    endid = Convert.ToInt32(dgvCadastro.CurrentRow.Cells["end_id"].Value);
                    try
                    {
                        if (repCli.Excluir(cliid, endid))
                        {
                            MostrarClientes();//---> Atualiza Data grid view
                            //  DialogHelper.Informacao("Cliente excluido com sucesso.");//, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            Inicializa();
                            Escondecrud();
                        }
                        else
                        {
                            DialogHelper.Alerta("Não é possível excluir esse cliente.");
                        }
                        Inicializa();
                        LimpaTela();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Cliente não pode ser excluido." + ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
            }
        }
Exemple #2
0
 private void bSalvar_Click(object sender, EventArgs e)
 {
     if (editar == false)//Salvar
     {
         try
         {
             if (validaObjeto())
             {
                 AtualizarObjeto();
                 // repCli.cadastrar(Cliente);
                 if (projetoRepository.Cadastrar(Projeto, Endereco))
                 {
                     CarregarDgv(); //---> Atualiza Data grid view
                                    //  DialogHelper.Informacao("Cliente incluido com sucesso.");
                     Inicializa();
                     LimpaTela();
                 }
                 else
                 {
                     DialogHelper.Erro("Cadastro não concluído.");
                 }
                 Inicializa();
                 LimpaTela();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     if (editar == true)//alterar
     {
         try
         {
             if (validaObjeto())
             {
                 AtualizarObjeto();
                 if (projetoRepository.Alterar(Projeto, Endereco))
                 {
                     CarregarDgv(); //---> Atualiza Data grid view
                                    // DialogHelper.Informacao("Cliente alterado com sucesso.");
                     Inicializa();
                     LimpaTela();
                 }
                 else
                 {
                     DialogHelper.Alerta("Reinicie a tela de cadastro.");
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Exemple #3
0
 private void TirarMascara(object sender, EventArgs e)
 {
     try
     {
         TextBox txt = (TextBox)sender;
         txt.Text = txt.Text.Replace("R$", "").Trim();
     }
     catch (Exception ex)
     {
         DialogHelper.Alerta(ex.Message);
         txtEntrada.Focus();
         // throw ex;
     }
 }
Exemple #4
0
        private bool validaObjeto()
        {
            if (txtNomeUsuario.Text.Length > 20)
            {
                DialogHelper.Alerta("O nome de usuário não pode ter mais que 20 caracteres");
                txtNomeUsuario.Focus();
                return(false);
            }
            if (txtNomeUsuario.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe um nome de usuário");
                txtNomeUsuario.Focus();
                return(false);
            }
            if (txtLogin.Text.Length > 20)
            {
                DialogHelper.Alerta("O login de usuário não pode ter mais que 20 caracteres");
                txtLogin.Focus();
                return(false);
            }
            if (txtLogin.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe um login de usuário");
                txtLogin.Focus();
                return(false);
            }
            if (txtSenha.Text.Length > 25)
            {
                DialogHelper.Alerta("A senha de usuário não pode ter mais que 25 caracteres");
                txtSenha.Focus();
                return(false);
            }
            if (txtSenha.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe uma senha de usuário");
                txtSenha.Focus();
                return(false);
            }

            if (CbbFuncionario.SelectedItem == null)
            {
                DialogHelper.Alerta("Selecione um funcionário.");
                CbbFuncionario.Focus();
                return(false);
            }

            return(true);
        }
Exemple #5
0
        private bool AtualizarObjeto()
        {
            string nome = txtNome.Text.Trim();

            if (nome == string.Empty)
            {
                DialogHelper.Alerta("Informe um nome para a empresa.");
                txtNome.Focus();
                return(false);
            }

            string cnpj = txtCnpj.Text.Trim();

            if (cnpj == string.Empty)
            {
                DialogHelper.Alerta("Informe um cnpj.");
                txtCnpj.Focus();
                return(false);
            }

            string caminho = txtDescricao.Text.Trim();

            if (caminho == string.Empty)
            {
                DialogHelper.Alerta("Selecione uma Imagem.");
                bBuscar.Focus();
                return(false);
            }

            MemoryStream memory = new MemoryStream();

            bmp.Save(memory, ImageFormat.Bmp);
            byte[] foto = memory.ToArray();



            if (Parametrizacao == null)
            {
                Parametrizacao = new Parametrizacao();
            }

            // Parametrizacao.id = id;
            Parametrizacao.nome = nome.ToUpper();
            Parametrizacao.cnpj = cnpj;
            Parametrizacao.foto = foto;

            return(true);
        }
Exemple #6
0
        private bool validaObjeto()
        {
            if (txtNome.Text.Length > 20)
            {
                DialogHelper.Alerta("O nome de perfil não pode ter mais que 20 caracteres");
                txtNome.Focus();
                return(false);
            }
            if (txtNome.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe um nome para o perfil");
                txtNome.Focus();
                return(false);
            }

            return(true);
        }
Exemple #7
0
        private void bBaixa_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtLotid.Text.Length == 0)
                {
                    DialogHelper.Alerta("Selecione um pagamento para dar baixa");
                    dgvLotes.Focus();
                    //
                }
                else
                {
                    if (ValidaPagamento())
                    {
                        if (receberRepository.BaixaRecebimento(Receber, Cliente))
                        {
                            txtLotid.Text      = "";
                            txtValorPago.Text  = "";
                            txtValorTotal.Text = "";
                            var selec = cbbCliente.SelectedIndex;
                            bFiltro.PerformClick();
                            cbbCliente.SelectedIndex = selec;
                            dgvLotes.Rows.RemoveAt(pos);

                            DialogHelper.Informacao("Recebimento Efetuado");
                            LimparLabels();
                        }
                        else
                        {
                            DialogHelper.Erro("Erro!");
                        }
                    }
                    else
                    {
                        DialogHelper.Alerta("Valor pago inferior");
                        txtValorPago.Focus();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #8
0
 private void bExcluir_Click(object sender, EventArgs e)
 {
     if (dgvCadastro.SelectedRows.Count > 0)
     {
         proid = Convert.ToInt32(dgvCadastro.CurrentRow.Cells["pro_id"].Value);
         if (!loteRepository.VerificaSeTemLote(proid))//verifica se tem lotes vinculados
         {
             DialogResult resultado = MessageBox.Show("Confirma exclusão deste projeto?", "Confirma Exclusão", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
             if (resultado == DialogResult.Yes)
             {
                 if (dgvCadastro.SelectedRows.Count > 0)
                 {
                     proid = Convert.ToInt32(dgvCadastro.CurrentRow.Cells["pro_id"].Value);
                     endid = Convert.ToInt32(dgvCadastro.CurrentRow.Cells["end_id"].Value);
                     try
                     {
                         if (projetoRepository.Excluir(proid, endid))
                         {
                             CarregarDgv(); //---> Atualiza Data grid view
                                            //  DialogHelper.Informacao("Cliente excluido com sucesso.");//, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                             Inicializa();
                         }
                         else
                         {
                             DialogHelper.Alerta("Não é possível excluir o projeto.");
                         }
                         Inicializa();
                         LimpaTela();
                     }
                     catch (Exception ex)
                     {
                         MessageBox.Show("Projeto não pode ser excluido." + ex.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                     }
                 }
             }
         }
         else
         {
             DialogHelper.Alerta("Há lotes vinculados a esse projeto. Não é possível excluir.");
         }
     }
 }
Exemple #9
0
        private void RetornarMascara(object sender, EventArgs e)
        {
            TextBox txt = (TextBox)sender;

            if (txt.Text == "")
            {
            }
            else
            {
                try
                {
                    txt.Text = double.Parse(txt.Text).ToString("C2");
                }
                catch (Exception ex)
                {
                    DialogHelper.Alerta(ex.Message);
                    txtEntrada.Focus();
                    // throw ex;
                }
            }
        }
Exemple #10
0
        private bool validaObjeto()
        {
            if (txtNome.Text.Length > 22)
            {
                DialogHelper.Alerta("O nome de empresa não pode ser maior que 22 caracteres");
                txtNome.Focus();
                return(false);
            }
            if (txtNome.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe um nome para a empresa");
                txtNome.Focus();
                return(false);
            }


            if (txtCnpj.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe um cnpj para a empresa");
                txtCnpj.Focus();
                return(false);
            }
            ;
            if (!ajuda.ValidaCNPJ(txtCnpj.Text))
            {
                DialogHelper.Alerta("Informe um cnpj valido para a empresa");
                txtCnpj.Focus();
                return(false);
            }

            string caminho = txtDescricao.Text.Trim();

            if (caminho == string.Empty)
            {
                DialogHelper.Alerta("Selecione uma Imagem.");
                bBuscar.Focus();
                return(false);
            }
            return(true);
        }
Exemple #11
0
        private void bEstornar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtLotid.Text.Length == 0)
                {
                    DialogHelper.Alerta("Selecione um pagamento para estornar o pagamento");
                    dgvLotes.Focus();
                    //
                }
                else
                {
                    if (DialogHelper.Confirmacao("Confirma estorno do pagamento?"))
                    {
                        if (receberRepository.EstornarRecebimento(Receber))
                        {
                            txtLotid.Text      = "";
                            txtValorPago.Text  = "";
                            txtValorTotal.Text = "";
                            var selec = cbbCliente.SelectedIndex;
                            bFiltro.PerformClick();
                            cbbCliente.SelectedIndex = selec;
                            dgvLotes.Rows.RemoveAt(pos);

                            DialogHelper.Informacao("Estorno concluído");
                            LimparLabels();
                        }
                        else
                        {
                            DialogHelper.Erro("Erro!");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #12
0
        private bool validaObjeto()
        {
            Ajudas ajudas = new Ajudas();

            string nome = txtNomeProjeto.Text.Trim();

            if (nome == string.Empty)
            {
                DialogHelper.Alerta("Informe um nome para o projeto.");
                txtNomeProjeto.Focus();
                return(false);
            }

            if (editar == false)
            {
                if (projetoRepository.ProcurarPorNome(txtNomeProjeto.Text))
                {
                    DialogHelper.Informacao("Já existe projeto cadastrado com este nome.");
                    txtNomeProjeto.Focus();
                    return(false);
                }
            }


            if (txtNomeProjeto.Text.Length > 149 || txtNomeProjeto.Text.Length < 2)
            {
                DialogHelper.Alerta("O nome do projeto deve ter entre 150 e ser menor que 2 caracteres");
                txtNomeProjeto.Focus();
                return(false);
            }

            if (CbbUf.SelectedItem == null)
            {
                DialogHelper.Alerta("Selecione o estado.");
                CbbUf.Focus();
                return(false);
            }

            if (CbbCidade.SelectedItem == null)
            {
                DialogHelper.Alerta("Selecione a cidade.");
                CbbCidade.Focus();
                return(false);
            }

            string endereco = txtLogradouro.Text.Trim();

            if (endereco == string.Empty)
            {
                DialogHelper.Alerta("Informe um endereço para o projeto.");
                txtLogradouro.Focus();
                return(false);
            }

            string bairro = txtBairro.Text.Trim();

            if (bairro == string.Empty)
            {
                DialogHelper.Alerta("Informe um bairro para o projeto.");
                txtBairro.Focus();
                return(false);
            }

            return(true);
        }
Exemple #13
0
        private void bFiltro_Click(object sender, EventArgs e)
        {
            if (cbbProjeto.SelectedItem == null)
            {
                DialogHelper.Alerta("Selecione um projeto.");
                cbbProjeto.Focus();
            }
            else
            {
                var opcao = 1;
                if (cbbProjeto.SelectedIndex >= 0)// todos entre as datas
                {
                    opcao = 1;
                }
                if (cbbTipoMovimento.SelectedIndex == 1)//Em aberto
                {
                    opcao = 2;
                }
                if (cbbTipoMovimento.SelectedIndex == 2)//vencidos
                {
                    opcao = 3;
                }
                if (cbbTipoMovimento.SelectedIndex == 3)//vencidos
                {
                    opcao = 4;
                }

                switch (opcao)
                {
                case 1:
                {
                    sql.Clear();
                    bEstornar.Enabled = false;
                    bBaixa.Enabled    = true;
                    sql.Append(" where r.pro_id = " + cbbProjeto.SelectedValue + " and dtvencimento >= " + "'" + dtpVencInicial.Value + "'" + " and dtvencimento <= " + "'" + dtpVencFinal.Value + "'");
                    FiltroPagamentos(sql.ToString());
                }
                break;

                case 2:
                {
                    sql.Clear();
                    bEstornar.Enabled = false;
                    bBaixa.Enabled    = true;
                    sql.Append(" where r.pro_id = " + cbbProjeto.SelectedValue + " and valorpago = 0");
                    FiltroPagamentos(sql.ToString());
                }
                break;

                case 3:
                {
                    sql.Clear();
                    bEstornar.Enabled = false;
                    bBaixa.Enabled    = true;
                    sql.Append(" where r.pro_id = " + cbbProjeto.SelectedValue + " and dtvencimento <=  " + "'" + dtpVencFinal.Value + "'" + " and valorpago = 0");
                    FiltroPagamentos(sql.ToString());
                }
                break;

                case 4:
                {
                    sql.Clear();
                    bEstornar.Enabled = true;
                    bBaixa.Enabled    = false;
                    sql.Append(" where r.pro_id = " + cbbProjeto.SelectedValue + " and re.dtpagamento >= " + "'" + dtpVencInicial.Value + "'" + " and re.dtpagamento <= " + "'" + dtpVencFinal.Value + "'");
                    FiltroPagamentos(sql.ToString());
                }
                break;
                }

                carregarClientes();
                cbbCliente.SelectedItem = null;
                SomarValor();
                //---
                cbbProjeto.Enabled       = false;
                cbbTipoMovimento.Enabled = false;
            }
        }
Exemple #14
0
 private void bSalvar_Click(object sender, EventArgs e)
 {
     if (editar == false)//Salvar
     {
         try
         {
             if (validaObjeto())
             {
                 AtualizarObjeto();
                 if (repCli.ProcurarPorCPF(txtCpf.Text))
                 {
                     DialogHelper.Informacao("Já existe cliente cadastrado com este CPF.");//CPF já Cadastrado
                     txtCpf.Focus();
                     return;
                 }
                 // repCli.cadastrar(Cliente);
                 if (repCli.Cadastrar(Cliente, Endereco))
                 {
                     MostrarClientes();//---> Atualiza Data grid view
                     //  DialogHelper.Informacao("Cliente incluido com sucesso.");
                     Inicializa();
                     LimpaTela();
                 }
                 else
                 {
                     DialogHelper.Alerta("Reinicie a tela de cadastro.");
                 }
                 Inicializa();
                 LimpaTela();
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
     if (editar == true)//alterar
     {
         try
         {
             if (validaObjeto())
             {
                 AtualizarObjeto();
                 if (repCli.Alterar(Cliente, Endereco))
                 {
                     MostrarClientes();//---> Atualiza Data grid view
                     // DialogHelper.Informacao("Cliente alterado com sucesso.");
                     Inicializa();
                     LimpaTela();
                 }
                 else
                 {
                     DialogHelper.Alerta("Reinicie a tela de cadastro.");
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Exemple #15
0
        private bool validaObjeto()
        {
            Ajudas ajudas = new Ajudas();

            string nome = txtNome.Text.Trim();

            if (nome == string.Empty)
            {
                DialogHelper.Alerta("Informe um nome para o cliente.");
                txtNome.Focus();
                return(false);
            }

            if (txtNome.Text.Length > 50 || txtNome.Text.Length < 2)
            {
                DialogHelper.Alerta("O nome não pode ter mais que cinquenta caracteres e ser menor que dois caracteres");
                txtNome.Focus();
                return(false);
            }

            string sobrenome = txtSobrenome.Text.Trim();

            if (sobrenome == string.Empty)
            {
                DialogHelper.Alerta("Informe o sobrenome do cliente.");
                txtSobrenome.Focus();
                return(false);
            }

            if (txtSobrenome.Text.Length > 50 || txtSobrenome.Text.Length < 2)
            {
                DialogHelper.Alerta("O sobrenome não pode ter mais que cinquenta caracteres e ser menor que dois caracteres");
                txtSobrenome.Focus();
                return(false);
            }

            if (txtCpf.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe um CPF para o cliente");
                txtCpf.Focus();
                return(false);
            }

            if (!ajudas.ValidaCpf(txtCpf.Text))
            {
                DialogHelper.Alerta("Informe um CPF valido para o cliente");
                txtCpf.Focus();
                return(false);
            }

            if (txtRG.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe um RG para o cliente");
                txtRG.Focus();
                return(false);
            }

            if (dtpDataNasc.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe uma data de nascimento para o cliente");
                dtpDataNasc.Focus();
                return(false);
            }

            else if (!ajudas.ValidaData(dtpDataNasc.Text))
            {
                DialogHelper.Alerta("Informe uma data de nascimento menor que o dia de hoje para o cliente");
                dtpDataNasc.Focus();
                return(false);
            }

            if (txtTelefone1.Text == String.Empty)
            {
                DialogHelper.Alerta("Informe um número de telefone para o cliente");
                txtTelefone1.Focus();
                return(false);
            }

            if (cbCasado.Checked == true)
            {
                string conjuge = txtNomeConjuge.Text.Trim();
                if (conjuge == string.Empty)
                {
                    DialogHelper.Alerta("Informe o nome do cônjuge do cliente.");
                    txtNomeConjuge.Focus();
                    return(false);
                }

                if (txtCpfConjuge.Text == String.Empty)
                {
                    DialogHelper.Alerta("Informe um CPF para o cônjuge");
                    txtCpfConjuge.Focus();
                    return(false);
                }

                if (!ajudas.ValidaCpf(txtCpfConjuge.Text))
                {
                    DialogHelper.Alerta("Informe um CPF valido para o cônjuge");
                    txtCpfConjuge.Focus();
                    return(false);
                }
                if (repCli.ProcurarPorCPF(txtCpfConjuge.Text))
                {
                    DialogHelper.Alerta("CPF do cônjuge já cadastrado");
                    txtCpfConjuge.Focus();
                    return(false);
                }
                if (txtConjugeRg.Text == String.Empty)
                {
                    DialogHelper.Alerta("Informe um RG para o cônjuge");
                    txtCpfConjuge.Focus();
                    return(false);
                }
            }

            if (CbbUf.SelectedItem == null)
            {
                DialogHelper.Alerta("Selecione o estado.");
                CbbUf.Focus();
                return(false);
            }

            if (CbbCidade.SelectedItem == null)
            {
                DialogHelper.Alerta("Selecione a cidade.");
                CbbCidade.Focus();
                return(false);
            }

            string endereco = txtLogradouro.Text.Trim();

            if (endereco == string.Empty)
            {
                DialogHelper.Alerta("Informe um endereço para o cliente.");
                txtLogradouro.Focus();
                return(false);
            }

            string bairro = txtBairro.Text.Trim();

            if (bairro == string.Empty)
            {
                DialogHelper.Alerta("Informe um bairro para o cliente.");
                txtBairro.Focus();
                return(false);
            }

            return(true);
        }