コード例 #1
0
        public FCCusto_Cadastro()
        {
            InitializeComponent();

            this.Shown += delegate
            {
                try
                {
                    if (Modo == Modo.Cadastrar)
                    {
                        CCusto = new TB_FIN_CENTROCUSTO();
                    }
                    else if (Modo == Modo.Alterar)
                    {
                        if (CCusto == null)
                        {
                            Excessoes.Alterar();
                        }

                        teIdentificador.Text = CCusto.ID_CENTROCUSTO.ToString();
                        teDescricao.Text     = CCusto.NM.Validar();
                    }
                }
                catch (Exception excessao)
                {
                    excessao.Validar();
                }
            };
        }
コード例 #2
0
        public void Deletar(TB_FIN_CENTROCUSTO CCusto, ref int posicaoTransacao)
        {
            try
            {
                Conexao.Iniciar(ref posicaoTransacao);

                var existente = Conexao.BancoDados.TB_FIN_CENTROCUSTOs.FirstOrDefault(a => a.ID_CENTROCUSTO == CCusto.ID_CENTROCUSTO);

                existente.ST_ATIVO = false;
                Conexao.Enviar();

                Conexao.Finalizar(ref posicaoTransacao);
            }
            catch (Exception excessao)
            {
                Conexao.Voltar(ref posicaoTransacao);
                throw excessao;
            }
        }
コード例 #3
0
        public override void Gravar()
        {
            try
            {
                Validar();

                CCusto = new TB_FIN_CENTROCUSTO();

                CCusto.ID_CENTROCUSTO = teIdentificador.Text.ToInt32().Padrao();
                CCusto.NM             = teDescricao.Text.Validar(true);

                var posicaoTransacao = 0;
                new QCCusto().Gravar(CCusto, ref posicaoTransacao);

                base.Gravar();
            }
            catch (Exception excessao)
            {
                excessao.Validar();
            }
        }
コード例 #4
0
        public void Gravar(TB_FIN_CENTROCUSTO CCusto, ref int posicaoTransacao)
        {
            try
            {
                Conexao.Iniciar(ref posicaoTransacao);

                var existente = Conexao.BancoDados.TB_FIN_CENTROCUSTOs.FirstOrDefault(a => a.ID_CENTROCUSTO == CCusto.ID_CENTROCUSTO);

                #region Inserção

                if (existente == null)
                {
                    CCusto.ID_CENTROCUSTO = (Conexao.BancoDados.TB_FIN_CENTROCUSTOs.Any() ? Conexao.BancoDados.TB_FIN_CENTROCUSTOs.Max(a => a.ID_CENTROCUSTO) : 0) + 1;
                    Conexao.BancoDados.TB_FIN_CENTROCUSTOs.InsertOnSubmit(CCusto);
                }

                #endregion

                #region Atualização

                else
                {
                    existente.NM                 = CCusto.NM;
                    existente.TP                 = CCusto.TP;
                    existente.ST_ATIVO           = CCusto.ST_ATIVO;
                    existente.ID_CENTROCUSTO_PAI = CCusto.ID_CENTROCUSTO_PAI;
                }

                #endregion

                Conexao.Enviar();

                Conexao.Finalizar(ref posicaoTransacao);
            }
            catch (Exception excessao)
            {
                Conexao.Voltar(ref posicaoTransacao);
                throw excessao;
            }
        }