示例#1
0
        private void barBtnSalvar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var funcao    = cbFuncao.SelectedItem as Funcao;
            var idFuncao  = funcao != null ? funcao.IdFuncao : 0;
            var historico = new HistoricoFuncao(funcao, memoEditHistorico.Text);


            //se existe a data de demissao

            if (ValidadorDTO.ValidateWarning(func) && ValidadorDTO.ValidateWarning(historico))
            {
                if (idFuncao == this.func.IdFuncao)
                {
                    XMessageIts.Advertencia("A função selecionada deve ser diferente da função atual");
                }
                else
                {
                    if (new HistoricoFuncionarioManager().UpdateFuncao(func, historico))
                    {
                        XMessageIts.Mensagem("Função alterada com sucesso");
                        //atualiza o objeto de onde foi chamado
                        this.func.Funcao = funcao;
                        this.Dispose();
                    }
                }
            }
        }
        public ValidadorDTO ValidaFecha(TimeSpan _diferencia)
        {
            ValidadorDTO _salida = new ValidadorDTO()
            {
                Clasificador = "Semanas", Texto = ""
            };
            int diff = Math.Abs((int)_diferencia.TotalDays);

            if (diff <= 30)
            {
                int semanas = diff / 7;
                if (semanas <= 1)
                {
                    _salida.Texto = $"{semanas} Semana";
                    return(_salida);
                }
                _salida.Texto = $"{semanas} Semanas";
                return(_salida);
            }

            if (Siguiente != null)
            {
                return(Siguiente.ValidaFecha(_diferencia));
            }

            return(_salida);
        }
        public ValidadorDTO ValidaFecha(TimeSpan _diferencia)
        {
            ValidadorDTO _salida = new ValidadorDTO()
            {
                Clasificador = "Bimestre", Texto = ""
            };
            int diff      = Math.Abs((int)_diferencia.TotalDays);
            int meses     = diff / 30;
            int bimestres = meses / 2;

            if (bimestres <= 6)
            {
                if (bimestres == 1)
                {
                    _salida.Texto = $"{bimestres} Bimestre";
                    return(_salida);
                }
                _salida.Texto = $"{bimestres} Bimestres";
                return(_salida);
            }
            if (Siguiente != null)
            {
                return(Siguiente.ValidaFecha(_diferencia));
            }

            return(_salida);
        }
示例#4
0
        private void btnSalvar_Click(object sender, System.EventArgs e)
        {
            CliFor c = indexarCliFor();

            //validando o cliente
            if (ValidadorDTO.ValidateWarningAll(c) && validarCpfCnpj())
            {
                /* if (endResd == null && endComercial == null && endCorresp == null)
                 * {
                 *   XMessageIts.Advertencia("Informe pelo menos um endereço", "Atenção");
                 *   return;
                 * }*/
                var ctx = new BalcaoContext();

                if (cliForAnt == null)
                {
                    if (ctx.CliForDao.Save(c))
                    {
                        XMessageIts.Mensagem("Cliente cadastrado com sucesso");
                        this.Dispose();
                    }
                }
                else
                {
                    //ação de atualizar
                    updateCliFor(c, ctx);
                }
            }
        }
        private void barBtnSalvar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var depto   = cbDepartamento.SelectedItem as Departamento;
            var idDepto = depto != null ? depto.IdDepartamento : 0;

            HistoricoDepartamento historico = new HistoricoDepartamento(depto, memoEditHistorico.Text);

            //se existe a data de demissao

            if (ValidadorDTO.ValidateWarning(func) && ValidadorDTO.ValidateWarning(historico))
            {
                if (idDepto == this.func.IdDepartamento)
                {
                    XMessageIts.Advertencia("O departamento selecionado deve ser diferente da departamento atual");
                }
                else
                {
                    if (new HistoricoFuncionarioManager().UpdateDepartamento(func, historico))
                    {
                        XMessageIts.Mensagem("Departamento alterado com sucesso");
                        //atualiza o objeto de onde foi chamado
                        this.func.Departamento = depto;
                        this.Dispose();
                    }
                }
            }
        }
示例#6
0
        private void btnSalvar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            EmpresaFilial novo = indexarDados();

            if (ValidadorDTO.ValidateWarningAll(novo))
            {
                using (var ctx = new BalcaoContext())
                {
                    if (_filialAnt == null)
                    {
                        if (ctx.EmpresaFilialDao.Save(novo))

                        {
                            XMessageIts.Mensagem("Filial cadastrada com sucesso!");
                            this.Dispose();
                        }
                    }
                    else
                    {
                        var fUpdate = ctx.EmpresaFilialDao.Find(_filialAnt.IdFilial);
                        fUpdate.Update(novo);
                        if (ctx.EmpresaFilialDao.Update(fUpdate))
                        {
                            this._filialAnt.Update(fUpdate);
                            XMessageIts.Mensagem("Filial atualizada com sucesso!");
                            this.Dispose();
                        }
                    }
                }
            }
        }
示例#7
0
 private bool testeConnection(AppConfigIts appCfg)
 {
     if (cbAuthentication.SelectedIndex == 1 && appCfg.User.IsNullOrEmpty())
     {
         XMessageIts.Advertencia("Usuário não informado !");
         return(false);
     }
     if (cbAuthentication.SelectedIndex == 1 && appCfg.Password.IsNullOrEmpty())
     {
         XMessageIts.Advertencia("Senha não informada !");
         return(false);
     }
     if (ValidadorDTO.ValidateWarningAll(appCfg))
     {
         var con = createConnection();
         //terminar
         if (con.OpenConnection())
         {
             XMessageIts.Mensagem("Conexão bem sucedida !");
             con.CloseConnection();
             barBtnAppConfig.Enabled     = true;
             barBtnAddConnection.Enabled = true;
             return(true);
         }
     }
     barBtnAddConnection.Enabled = false;
     barBtnAppConfig.Enabled     = false;
     return(false);
 }
示例#8
0
        public ValidadorDTO ValidaFecha(TimeSpan _diferencia)
        {
            ValidadorDTO _salida = new ValidadorDTO()
            {
                Clasificador = "Dias", Texto = ""
            };
            int diff = Math.Abs((int)_diferencia.TotalDays);

            if (diff <= 6)
            {
                if (diff <= 1)
                {
                    _salida.Texto = $"{diff} Día";
                    return(_salida);
                }
                _salida.Texto = $"{diff} Días";

                return(_salida);
            }

            if (Siguiente != null)
            {
                return(Siguiente.ValidaFecha(_diferencia));
            }

            return(_salida);
        }
示例#9
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            if (btnSalvar.Text.Equals("Salvar"))
            {
                Manutencao novo = indexarDados();

                if (ValidadorDTO.ValidateWarningAll(novo))
                {
                    var dao = new ManutencaoDaoManager();

                    if (this.manutencao == null)
                    {
                        if (dao.SaveManutencao(novo))
                        {
                            XMessageIts.Mensagem("Manutenção arquivada.");
                            this.Dispose();
                        }
                    }
                    else
                    {
                        if (dao.UpdateManutencao(novo))
                        {
                            XMessageIts.Mensagem("Manutenção atualizada.");
                            this.manutencao.Update(novo);
                        }
                    }
                }
            }
            else
            {
                this.Dispose();
            }
        }
示例#10
0
        public ValidadorDTO ValidaFecha(TimeSpan _diferencia)
        {
            ValidadorDTO _salida = new ValidadorDTO()
            {
                Clasificador = "Anios", Texto = ""
            };
            int diff      = Math.Abs((int)_diferencia.TotalDays);
            int meses     = diff / 30;
            int bimestres = meses / 2;

            if (bimestres > 7)
            {
                int anio = bimestres / 6;

                if (anio == 1)
                {
                    _salida.Texto = $"{anio} Año";
                    return(_salida);
                }
                _salida.Texto = $"{anio} Años";
                return(_salida);
            }
            if (Siguiente != null)
            {
                return(Siguiente.ValidaFecha(_diferencia));
            }

            return(_salida);
        }
示例#11
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            var novo = indexarDados();

            if (ValidadorDTO.ValidateWarningAll(novo))
            {
                var manager = new CaixaDaoManager();

                if (_movimento == TypeMovimentacaoMonetaria.Credito)
                {
                    if (manager.AddMovimentoCaixa(novo))
                    {
                        XMessageIts.Mensagem("Depósito efetuado com sucesso.");
                        this.Dispose();
                    }
                }
                else
                {
                    if (manager.GetSaldoDinheiro() >= novo.ValorMovimento)
                    {
                        if (manager.AddMovimentoCaixa(novo))
                        {
                            XMessageIts.Mensagem("Saque efetuado com sucesso.");
                            this.Dispose();
                        }
                    }
                    else
                    {
                        XMessageIts.Advertencia("Saldo insuficiente.", "Aviso");
                    }
                }
            }
        }
示例#12
0
        public bool ImportToDatabase(DataTable dadosOrigem)
        {
            /*  Colunas
             * NOMECLI	 | CIDADE  | UF     | NOMEFANT
             * ENDER	 | INSCEST | BAIRRO	| CGC
             * CEP      | CONTATO | TELEF1	| TELEF2
             * TIPO_CLI | RG	   | LIMITE	| DT_CLI
             */
            if (dadosOrigem != null)
            {
                var           ctx        = new BalcaoContext();
                List <CliFor> cliForSave = new List <CliFor>();
                int           i          = 0;
                try
                {
                    foreach (var cliForItg in dadosOrigem.AsEnumerable())
                    {
                        CliFor         c    = new CliFor();
                        EnderecoCliFor cEnd = new EnderecoCliFor();

                        c.RazaoSocial = cliForItg["NOMECLI"].ToString();
                        c.CpfCnpj     = cliForItg["CGC"].ToString();

                        c.Telefone       = cliForItg["TELEF1"].ToString();
                        c.RG             = cliForItg["RG"].ToString();
                        c.DataNascimento = ParseUtil.ToDate(cliForItg["DT_CLI"]);
                        c.Celular        = cliForItg["TELEF2"].ToString();

                        cEnd.TipoEndereco = "Comercial";
                        cEnd.Complemento  = "N/A";
                        cEnd.Bairro       = cliForItg["BAIRRO"].ToString();
                        cEnd.Cep          = cliForItg["CEP"].ToString();
                        cEnd.Cidade       = cliForItg["CIDADE"].ToString();
                        cEnd.NomeEndereco = cliForItg["ENDER"].ToString();

                        cEnd.Uf = cliForItg["UF"].ToString();
                        ValidadorDTO.ValidateWarningAll(cEnd);

                        c.Enderecos.Add(cEnd);
                        cliForSave.Add(c);
                        ValidadorDTO.ValidateWarningAll(c);
                        bool s = ctx.CliForDao.Save(c);
                        if (s)
                        {
                            i++;
                        }
                    }
                    if (cliForSave.Count == i)
                    {
                        XMessageIts.Mensagem("Clientes importados com sucesso!");
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            return(true);
        }
示例#13
0
        private void barBtnLancarCredito_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var creditoCliente = indexarDados();

            if (ValidadorDTO.ValidateWarningAll(creditoCliente))
            {
                this.creditos.Add(creditoCliente);
                this.gridControl1.DataSource = this.creditos;
                this.gridControl1.RefreshDataSource();
            }
        }
示例#14
0
        public void ImportToDatabase(DataTable dadosOrigem)
        {
            if (dadosOrigem != null)
            {
                var            ctx         = new BalcaoContext();
                List <Produto> produtoSave = new List <Produto>();
                int            i           = 0;
                try
                {
                    Produto pAnt = null;
                    foreach (var produtoItg in dadosOrigem.AsEnumerable())
                    {
                        Produto p = new Produto();
                        p.IdCategoriaProduto     = 18;
                        p.CodigoBarras           = produtoItg["COD_PRO"].ToString();
                        p.DataCadastro           = DateTime.Now;
                        p.DescricaoProduto       = produtoItg["DESC_PRO"].ToString();
                        p.IdUnidadeMedidaProduto = 1;
                        p.Observacao             = "IMPORTADO SISTEMA LSC";
                        p.PrecoVenda             = ParseUtil.ToDecimal(produtoItg["VR_VENDA"]);
                        p.PrecoCompra            = ParseUtil.ToDecimal(produtoItg["CUSTO"]);
                        p.QuantidadeProduto      = ParseUtil.ToDecimal(produtoItg["QTE_PRO"]);
                        p.MargemLucro            = ParseUtil.ToDecimal(produtoItg["MARGEM"]);
                        produtoSave.Add(p);

                        if (pAnt != null)
                        {
                            if (pAnt.DescricaoProduto.Equals(p.DescricaoProduto))
                            {
                                continue;
                            }
                        }
                        if (ValidadorDTO.ValidateWarningAll(p))
                        {
                            bool s = ctx.ProdutoDao.Save(p);
                            pAnt = p;
                            if (s)
                            {
                                i++;
                            }
                        }
                    }
                    if (produtoSave.Count == i)
                    {
                        XMessageIts.Mensagem("Clientes importados com sucesso!");
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
示例#15
0
        private void btnAddEndereco_Click(object sender, EventArgs e)
        {
            int index = tabEnderecos.SelectedTabPageIndex;

            if (index >= 0)
            {
                //cria um endereço com os dados dos campos
                var end = indexarEndereco(index);
                if (ValidadorDTO.ValidateWarningAll(end))
                {
                    flagEndereco(index, "OK", Color.Blue, end);
                }
            }
        }
示例#16
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            var          nome  = txtNomeGrupo.Text;
            GrupoUsuario grupo = new GrupoUsuario(nome);

            if (ValidadorDTO.ValidateWarningAll(grupo))
            {
                if (new BalcaoContext().GrupoUsuarioDao.Save(grupo))
                {
                    XMessageIts.Mensagem("Grupo salvo com sucesso");
                    this.Dispose();
                }
            }
        }
示例#17
0
 private bool isCalcularCheque(Cheque ch)
 {
     if (ValidadorDTO.ValidateWarningAll(ch))
     {
         if (DataUtil.ToDateZerada(ch.DataLancamento) < DataUtil.ToDateZerada(ch.DataVencimento))
         {
             return(ch.Prazo != 0 || ch.Compensacao != 0 &&
                    ch.TaxaJuros != 0 && ch.ValorCheque != 0);
         }
         else
         {
             XMessageIts.Mensagem("Data de lançamento deve ser menor que o vencimento !");
         }
     }
     return(false);
 }
示例#18
0
        private void btnAssistente_Click(object sender, EventArgs e)
        {
            var novo = indexarDados();

            if (ValidadorDTO.ValidateWarningAll(novo))
            {
                var asst = new XFrmAssitenteLancamentoFinanceiro(novo);

                asst.ShowDialog();

                if (!asst.IsCancel)
                {
                    this.Dispose();
                }
            }
        }
示例#19
0
        public bool validar()
        {
            this.Errors = new HashSet <LancamentoFinanceiro>();
            this.Result = new HashSet <LancamentoFinanceiro>();
            for (int i = 0; i < gridViewBase.DataRowCount; i++)
            {
                DataRow row = gridViewBase.GetDataRow(i);


                var dt  = DataUtil.ToDate(row[Data].ToString());
                var vlr = ParseUtil.ToDecimal(row[Valor].ToString().Trim());
                var obs = row[Obs].ToString().Trim();
                var id  = ParseUtil.ToInt(row[ID].ToString().Trim());

                var l = new LancamentoFinanceiro();

                l.DataLancamento   = dt;
                l.DataVencimento   = dt;
                l.ValorLancamento  = vlr;
                l.Observacao       = obs;
                l.IdCentroCusto    = 4;
                l.IdCliFor         = id;
                l.RecCreatedBy     = 2;
                l.IdFilial         = 1;
                l.IdFormaPagamento = (int)TypeFormaPagamento.Cheque;
                try
                {
                    if (ValidadorDTO.Validate(l))
                    {
                        this.Result.Add(l);
                    }
                    else
                    {
                        this.Errors.Add(l);
                    }
                }
                catch (Exception ex)
                {
                    this.Errors.Add(l);
                    LoggerUtilIts.ShowExceptionLogs(ex);
                }
            }
            return(this.Errors.Count == 0);
        }
示例#20
0
        private void btnLogar_Click(object sender, EventArgs e)
        {
            Usuario user = indexarDados();

            //verifica a consistencia dos dados
            if (ValidadorDTO.ValidateWarningAll(user))
            {
                //tenta fazer Login
                IsLogin = action.Login(user.Nome, user.Senha);

                if (IsLogin)
                {
                    this.UserName = user.Nome;
                    this.Password = user.Senha;
                    this.IsCancel = false;
                    //padrao eh true
                    if (this.DisposeOnLogin)
                    {
                        this.Dispose();
                    }

                    else if (this.IsHideOnLogin)
                    {
                        this.Hide();
                    }

                    //else nao faz nada else
                }
                else
                {
                    XMessageIts.Advertencia("Usuário ou senha inválido");
                    if (!string.IsNullOrEmpty(this.UserName))
                    {
                        this.txtSenha.Focus();
                    }
                    else
                    {
                        this.txtNome.Focus();
                    }
                }
            }
        }
示例#21
0
        private void barBtnSalvar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            //cancelada o evento
            if (!this.barBtnSalvar.Enabled)
            {
                return;
            }

            var novo = indexarFuncionario();

            if (ValidadorDTO.ValidateWarningAll(novo))
            {
                var manager = new FuncionarioDaoManager();

                //verifica se o CPF existe
                if (manager.FindByCpf(novo))
                {
                    XMessageIts.Mensagem("CPF " + novo.CPF + " já existe !");
                }
                else
                {
                    if (funcAnt == null)
                    {
                        if (manager.SaveFuncionario(novo))
                        {
                            XMessageIts.Mensagem("Funcionário salvo com sucesso!");
                            this.funcAnt = novo;
                            this.Dispose();
                        }
                    }
                    else
                    {
                        if (manager.UpdateFuncionario(novo))
                        {
                            this.funcAnt.Update(novo);//manda a atualizacao pro objeto do grid
                            XMessageIts.Mensagem("Funcionário atualizado com sucesso!");
                        }
                    }
                }
            }
        }
示例#22
0
        private void barBtnSalvar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var salario = ParseUtil.ToDecimal(txtSalario.Text);
            HistoricoSalarial historico = new HistoricoSalarial(salario, memoEditHistorico.Text);


            if (ValidadorDTO.ValidateWarning(func) && ValidadorDTO.ValidateWarning(historico))
            {
                if (salario == this.func.Salario)
                {
                    XMessageIts.Advertencia("O salário informado deve ser diferente do salário atual");
                }
                else
                {
                    if (new HistoricoFuncionarioManager().UpdateSalario(func, historico))
                    {
                        XMessageIts.Mensagem("Ajuste salárial realizado com sucesso");
                        this.Dispose();
                    }
                }
            }
        }
示例#23
0
        private void btnLogar_Click(object sender, EventArgs e)
        {
            Usuario user = indexarDados();

            //verifica a consistencia dos dados
            if (ValidadorDTO.ValidateWarningAll(user))
            {
                //tenta fazer Login
                IsLogin = action.Login(user.Nome, user.Senha);

                if (IsLogin)
                {
                    this.UserName = user.Nome;
                    this.Password = user.Senha;
                    this.IsCancel = false;
                }
                else
                {
                    XMessageIts.Advertencia("Usuário ou senha inválido");
                }
            }
        }
示例#24
0
        private void btnSalvarEndereco_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            var endereco = indexarEndereco();

            if (ValidadorDTO.ValidateWarningAll(endereco))
            {
                if (_enderecoAnt == null)
                {
                    this.EnderecoAdd = endereco;
                }

                //alteracao
                else
                {
                    this._enderecoAnt.Update(endereco);
                    this.EnderecoAdd = _enderecoAnt;
                }

                //terminar o form
                this.Dispose();
            }
        }
        private void wizardPage1_PageValidating(object sender, DevExpress.XtraWizard.WizardPageValidatingEventArgs e)
        {
            if (e.Direction == DevExpress.XtraWizard.Direction.Forward)
            {
                var vazio = this._lancamentoList.Exists(l => l.TotalLancamento <= 1);

                if (ValidadorDTO.ValidateListWarningAll(_lancamentoList))
                {
                    if (vazio)
                    {
                        XMessageIts.Advertencia("Existem lançamentos com valor menor ou igual que 1!");
                        e.Valid = false;
                    }
                    else if (_lancamentoAtual.IdLancamento != 0 && this._lancamentoList.Sum(l => l.TotalLancamento) >= _lancamentoAtual.TotalLancamento)
                    {
                        XMessageIts.Advertencia(
                            "O parcelamento não deve ser superior ou zerar o valor do lançamento existe!", "Atenção");
                        e.Valid = false;
                    }
                    else if (_lancamentoList.Count < 1)
                    {
                        XMessageIts.Advertencia("O parcelamento mínimo é de 1 parcela!");
                        e.Valid = false;
                    }
                    else
                    {
                        var op = XMessageIts.Confirmacao("Deseja proseguir com criação dos lançamentos informados ?");
                        if (op != DialogResult.Yes)
                        {
                            e.Valid = false;
                        }
                    }
                }
                else
                {
                    e.Valid = false;
                }
            }
        }
示例#26
0
        private void btnSalvar_Click(object sender, System.EventArgs e)
        {
            var conta = indexarConta();

            if (ValidadorDTO.ValidateWarningAll(conta))
            {
                if (ContaBancariaCliForAnt == null)
                {
                    this.ContaBancariaCliForAdd = conta;
                }

                //alteracao
                else
                {
                    this.ContaBancariaCliForAnt.Update(conta);
                    this.ContaBancariaCliForAdd = ContaBancariaCliForAnt;
                }

                //terminar o form
                this.Dispose();
            }
        }
示例#27
0
 private bool isUsuario(Usuario u)
 {
     if (ValidadorDTO.ValidateWarningAll(u))
     {
         if (userLogado != null)
         {
             int admGroup = (int)TypeGroupUser.Administrador;
             //se nao é o usuario adm q esta logado
             //e alguem esta tentando atribuir privilegio a um usuario
             if (userLogado.IdGrupoUsuario != admGroup &&
                 u.IdGrupoUsuario == admGroup)
             {
                 XMessageIts.Erro("Somente o administrador pode conceder privilégios a outros \"Usuários\"!",
                                  "Acesso negado");
             }
             else//ok
             {
                 return(true);
             }
         }
     }
     return(false);
 }
示例#28
0
        private void barBtnSalvar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (creditos.Count > 0)
            {
                var ctx       = new BalcaoContext();
                var validador = new ValidadorDTO();
                int i         = 0;
                foreach (var credito in creditos)
                {
                    if (ValidadorDTO.ValidateWarningAll(credito))
                    {
                        bool flag = ctx.CreditoClienteDao.Save(credito);

                        if (!flag)
                        {
                            XMessageIts.Erro("Falha ao gerar credito valor: " + credito.ValorCredito);
                        }
                        else
                        {
                            i++;
                        }
                    }
                }

                if (i == creditos.Count)
                {
                    var creditoList = ctx.CreditoClienteDao.Where(cd => cd.IdCliFor == cliente.IdCliFor);

                    XFrmOptionPane.ShowListTextArea <CreditoCliente>(creditoList.ToList(), "Crédito(s) gerados com sucesso");
                    this.Dispose();
                }
            }
            else
            {
                XMessageIts.Mensagem("Nenhum crédito lançado");
            }
        }
示例#29
0
        //Salvar nota fiscal
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            var ctx  = new BalcaoContext();
            var util = new MovimentoDaoManager();
            var nf   = this.movimentoCurrent == null?indexarMovimento(true) : this.movimentoCurrent;

            var novaNF = indexarMovimento(true);
            var acao   = this.formTypeAction;

            try
            {
                //se estiver criando uma NF, ctx.Save(T)
                if (formTypeAction != FormTypeAction.Visualizar && ValidadorDTO.ValidateWarningAll(nf))
                {
                    var transaction = new MovimentoDaoManager().SalvarMovimento(nf);
                }

                //senao, ctx.Update(T)
                else
                {
                    var capaEdit = ctx.MovimentoSet.Find(movimentoCurrent.IdMovimento); //recupera a NF do banco
                                                                                        //indexar a nota zerando as referencias
                    nf.IdMovimento = capaEdit.IdMovimento;

                    var traUpdate = new MovimentoDaoManager().UpdateMovimentoFiscal(capaEdit, novaNF, itensRemovidos, currentUser);
                }
            }
            catch (DbUpdateException db)
            {
                XMessageIts.ExceptionMessageDetails(db, "Dados em duplicidade! Vefique todos os campos e se já não existe uma nota fiscal com os mesmos dados!");
            }
            catch (Exception ex)
            {
                XMessageIts.ExceptionMessageDetails(ex, "Ocorreu um erro na inclusão/atualização da nota fiscal");
            }
        }
示例#30
0
        private void barBtnSalvar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            CliFor novo = indexarCliFor();

            //validando o cliente
            if (ValidadorDTO.ValidateWarningAll(novo))
            {
                var manager = new ClienteDaoManager();
                if (_cliForAnt == null)
                {
                    IsSave = manager.Save(novo);

                    if (IsSave)
                    {
                        XMessageIts.Mensagem("Cliente cadastrado com sucesso.");
                        this.ClienteAdd = novo;
                        this.Dispose();
                    }
                }
                else
                {
                    //ação de atualizar
                    if (manager.Update(novo))
                    {
                        //atualiza no grid
                        _cliForAnt.Update(novo);
                        //atualiza os endereços tbm
                        _cliForAnt.Enderecos = novo.Enderecos;
                        //atualizando as contas
                        _cliForAnt.ContasBancariasCliFor = novo.ContasBancariasCliFor;
                        XMessageIts.Mensagem("Os dados do cliente foram atualizados.");
                        this.Dispose();
                    }
                }
            }
        }