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

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

                        teIdentificador.Text = impressora.ID_IMPRESSORA.ToString();
                        teNM.Text            = impressora.NM.Validar();
                        teCaminho.Text       = impressora.NM_CAMINHO.Validar();
                    }
                }
                catch (Exception excessao)
                {
                    excessao.Validar();
                }
            };
        }
コード例 #2
0
        public void Deletar(TB_GOU_IMPRESSORA impressora, ref int posicaoTransacao)
        {
            try
            {
                Conexao.Iniciar(ref posicaoTransacao);

                var existente = Conexao.BancoDados.TB_GOU_IMPRESSORAs.FirstOrDefault(a => a.ID_IMPRESSORA == impressora.ID_IMPRESSORA);

                Conexao.BancoDados.TB_GOU_IMPRESSORAs.DeleteOnSubmit(impressora);
                Conexao.Enviar();

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

                impressora = new TB_GOU_IMPRESSORA();

                impressora.ID_IMPRESSORA = teIdentificador.Text.ToInt32().Padrao();
                impressora.NM            = teNM.Text.Validar(true);
                impressora.NM_CAMINHO    = teCaminho.Text.Trim().Validar();

                var posicaoTransacao = 0;
                new QImpressora().Gravar(impressora, ref posicaoTransacao);

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

                var existente = Conexao.BancoDados.TB_GOU_IMPRESSORAs.FirstOrDefault(a => a.ID_IMPRESSORA == impressora.ID_IMPRESSORA);

                #region Inserção
                if (existente == null)
                {
                    impressora.ID_IMPRESSORA = (Conexao.BancoDados.TB_GOU_IMPRESSORAs.Any() ? Conexao.BancoDados.TB_GOU_IMPRESSORAs.Max(a => a.ID_IMPRESSORA) : 0) + 1;
                    Conexao.BancoDados.TB_GOU_IMPRESSORAs.InsertOnSubmit(impressora);
                }
                #endregion

                #region Atualização
                else
                {
                    existente.NM            = impressora.NM;
                    existente.ID_IMPRESSORA = impressora.ID_IMPRESSORA;
                    existente.NM_CAMINHO    = impressora.NM_CAMINHO;
                    Conexao.Enviar();
                }

                #endregion

                Conexao.Enviar();

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