Ejemplo n.º 1
0
        /// <summary>
        /// Alterar o cadastro de um escritório contábil
        /// </summary>
        /// <param name="reg"></param>
        /// <returns></returns>
        public Exception Alterar_escritorio(Escritoriocontabil reg)
        {
            Exception AppEx = Valida_Escritorio_Contabil(reg);

            if (AppEx != null)
            {
                return(AppEx);
            }
            Empresa_Data obj = new Empresa_Data(_connection);
            Exception    ex  = obj.Alterar_escritorio(reg);

            return(ex);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Validação para gravação do escritório de contabilidade
        /// </summary>
        /// <param name="reg"></param>
        /// <returns></returns>
        public Exception Valida_Escritorio_Contabil(Escritoriocontabil reg)
        {
            Exception AppEx;

            if (String.IsNullOrWhiteSpace(reg.Nomeesc))
            {
                AppEx = new Exception("Digite o nome do escritório");
                return(AppEx);
            }

            if (String.IsNullOrWhiteSpace(reg.Cpf) && String.IsNullOrEmpty(reg.Cnpj))
            {
                AppEx = new Exception("Digite o CPF ou CNPJ.");
                return(AppEx);
            }

            if (!string.IsNullOrWhiteSpace(reg.Cpf) && !bllCore.ValidaCpf(reg.Cpf))
            {
                AppEx = new Exception("CPF inválido.");
                return(AppEx);
            }

            if (!string.IsNullOrWhiteSpace(reg.Cnpj) && !bllCore.ValidaCNPJ(reg.Cnpj))
            {
                AppEx = new Exception("CNPJ inválido.");
                return(AppEx);
            }

            if (String.IsNullOrWhiteSpace(reg.Nomelogradouro) && reg.Codlogradouro == 0)
            {
                AppEx = new Exception("Digite o endereço do escritório.");
                return(AppEx);
            }

            if (reg.Codcidade == 0)
            {
                AppEx = new Exception("Selecione a cidade.");
                return(AppEx);
            }

            if (String.IsNullOrWhiteSpace(reg.UF))
            {
                AppEx = new Exception("Selecione a UF.");
                return(AppEx);
            }

            return(null);
        }
Ejemplo n.º 3
0
        private void GravarButton_Click(object sender, EventArgs e)
        {
            Bairro.Tag     = string.IsNullOrWhiteSpace(Bairro.Tag.ToString()) ? "0" : Bairro.Tag;
            Cidade.Tag     = string.IsNullOrWhiteSpace(Cidade.Tag.ToString()) ? "0" : Cidade.Tag;
            Logradouro.Tag = string.IsNullOrWhiteSpace(Logradouro.Tag.ToString()) ? "0" : Logradouro.Tag;
            IM.Text        = string.IsNullOrWhiteSpace(IM.Text) ? "0" : IM.Text;
            Numero.Text    = string.IsNullOrWhiteSpace(Numero.Text) ? "0" : Numero.Text;

            Escritoriocontabil reg = new Escritoriocontabil();

            reg.Cep            = Cep.Text;
            reg.Cnpj           = CNPJ.Text;
            reg.Codbairro      = Convert.ToInt16(Bairro.Tag);
            reg.Codcidade      = Convert.ToInt32(Cidade.Tag);
            reg.Codigoesc      = Convert.ToInt32(CodigoEscritorio.Text);
            reg.Codlogradouro  = Convert.ToInt32(Logradouro.Tag);
            reg.Complemento    = Complemento.Text;
            reg.Cpf            = CPF.Text;
            reg.Crc            = Crc.Text;
            reg.Email          = Email.Text;
            reg.Im             = Convert.ToInt32(IM.Text);
            reg.Nomeesc        = Nome.Text;
            reg.Nomelogradouro = Logradouro.Text;
            reg.Numero         = Convert.ToInt32(Numero.Text);
            reg.Recebecarne    = RecebeCarneCheck.Checked;
            reg.Telefone       = Fone.Text;
            reg.UF             = UF.Text;

            Empresa_bll empresa_Class = new Empresa_bll(_connection);
            Exception   ex;

            if (bAddNew)
            {
                int nLastCod = empresa_Class.Retorna_Ultimo_Codigo_Escritorio();
                reg.Codigoesc = ++nLastCod;
                ex            = empresa_Class.Incluir_escritorio(reg);
                if (ex != null)
                {
                    ErrorBox eBox = new ErrorBox("Atenção", ex.Message, ex);
                    eBox.ShowDialog();
                }
                else
                {
                    CarregaDados(nLastCod);
                    ControlBehaviour(true);
                }
            }
            else
            {
                reg.Codigoesc = Convert.ToInt32(CodigoEscritorio.Text);
                ex            = empresa_Class.Alterar_escritorio(reg);
                if (ex != null)
                {
                    ErrorBox eBox = new ErrorBox("Atenção", ex.Message, ex);
                    eBox.ShowDialog();
                }
                else
                {
                    ControlBehaviour(true);
                }
            }
        }