public void Inserir(IDespachoDePatentes despachoDePatentes)
        {
            var sql = new StringBuilder();
            IDBHelper DBHelper;

            DBHelper = ServerUtils.getDBHelper();

            despachoDePatentes.IdDespachoDePatente = GeradorDeID.getInstancia().getProximoID();

            sql.Append("INSERT INTO MP_DESPACHO_PATENTE (");
            sql.Append("IDDESPACHOPATENTE, CODIGO, DESCRICAO, TITULO, SITUACAO, PRAZO, PROVIDENCIA, DESATIVAPROCESSO, AGENDAPAGAMENTO) ");
            sql.Append("VALUES (");
            sql.Append(String.Concat(despachoDePatentes.IdDespachoDePatente.Value.ToString(), ", "));
            sql.Append(String.Concat("'", UtilidadesDePersistencia.FiltraApostrofe(despachoDePatentes.Codigo), "', "));

            sql.Append(string.IsNullOrEmpty(despachoDePatentes.Descricao)
                           ? "NULL, "
                           : String.Concat("'", UtilidadesDePersistencia.FiltraApostrofe(despachoDePatentes.Descricao),
                                           "', "));

            sql.Append(String.Concat("'", UtilidadesDePersistencia.FiltraApostrofe(despachoDePatentes.Titulo), "', "));

            sql.Append(string.IsNullOrEmpty(despachoDePatentes.Situacao)
                           ? "NULL, "
                           : String.Concat("'", UtilidadesDePersistencia.FiltraApostrofe(despachoDePatentes.Situacao),
                                           "', "));

            sql.Append(!despachoDePatentes.PrazoProvidencia.HasValue
                           ? "NULL, "
                           : String.Concat(despachoDePatentes.PrazoProvidencia.Value.ToString(),
                                           ", "));

            sql.Append(string.IsNullOrEmpty(despachoDePatentes.TipoProvidencia)
                           ? "NULL, "
                           : String.Concat("'", UtilidadesDePersistencia.FiltraApostrofe(despachoDePatentes.TipoProvidencia),
                                           "', "));

            sql.Append(despachoDePatentes.DesativaProcesso ? String.Concat("'", 1, "', ") : String.Concat("'", 0, "', "));
            sql.Append(despachoDePatentes.AgendarPagamento ? String.Concat("'", 1, "') ") : String.Concat("'", 0, "') "));

            DBHelper.ExecuteNonQuery(sql.ToString());

            if (despachoDePatentes.TemplateDeEmail != null)
                ModificarTemplate(despachoDePatentes);
        }
        public void Modificar(IDespachoDePatentes despachoDePatentes)
        {
            var sql = new StringBuilder();
            IDBHelper DBHelper;

            DBHelper = ServerUtils.getDBHelper();

            sql.Append("UPDATE MP_DESPACHO_PATENTE SET ");
            sql.Append(String.Concat("CODIGO = '", UtilidadesDePersistencia.FiltraApostrofe(despachoDePatentes.Codigo), "', "));

            sql.Append(string.IsNullOrEmpty(despachoDePatentes.Descricao)
                           ? "DESCRICAO = NULL, "
                           : String.Concat("DESCRICAO = '", UtilidadesDePersistencia.FiltraApostrofe(despachoDePatentes.Descricao),
                                           "', "));

            sql.Append(String.Concat("TITULO = '", UtilidadesDePersistencia.FiltraApostrofe(despachoDePatentes.Titulo), "', "));

            sql.Append(string.IsNullOrEmpty(despachoDePatentes.Situacao)
                          ? "SITUACAO = NULL, "
                          : String.Concat("SITUACAO= '", UtilidadesDePersistencia.FiltraApostrofe(despachoDePatentes.Situacao),
                                          "', "));

            sql.Append(string.IsNullOrEmpty(despachoDePatentes.TipoProvidencia)
                           ? "PROVIDENCIA = NULL, "
                           : String.Concat("PROVIDENCIA= '", UtilidadesDePersistencia.FiltraApostrofe(despachoDePatentes.TipoProvidencia),
                                           "', "));

            sql.Append(!despachoDePatentes.PrazoProvidencia.HasValue
                           ? "PRAZO = NULL, "
                           : String.Concat("PRAZO = ", despachoDePatentes.PrazoProvidencia.Value.ToString(),
                                           ", "));

            sql.Append(despachoDePatentes.DesativaProcesso ? String.Concat("DESATIVAPROCESSO = '", 1, "', ") : String.Concat("DESATIVAPROCESSO = '", 0, "', "));
            sql.Append(despachoDePatentes.AgendarPagamento ? String.Concat("AGENDAPAGAMENTO = '", 1, "', ") : String.Concat("AGENDAPAGAMENTO = '", 0, "' "));
            sql.Append(String.Concat("WHERE IDDESPACHOPATENTE = ", despachoDePatentes.IdDespachoDePatente.Value.ToString()));

            DBHelper.ExecuteNonQuery(sql.ToString());

            ModificarTemplate(despachoDePatentes);
        }
        public void Modificar(IDespachoDePatentes despachoDePatentes)
        {
            ServerUtils.setCredencial(_Credencial);

            var mapeador = FabricaGenerica.GetInstancia().CrieObjeto<IMapeadorDeDespachoDePatentes>();

            try
            {
                ServerUtils.BeginTransaction();
                mapeador.Modificar(despachoDePatentes);
                ServerUtils.CommitTransaction();
            }
            catch
            {
                ServerUtils.RollbackTransaction();
                throw;
            }
            finally
            {
                ServerUtils.libereRecursos();
            }
        }
        public void ModificarTemplate(IDespachoDePatentes despacho)
        {
            IDBHelper DBHelper;

            DBHelper = ServerUtils.getDBHelper();

            var sql = new StringBuilder();

            sql.Append("UPDATE MP_DESPACHO_PATENTE SET ");

            if (despacho.TemplateDeEmail == null || string.IsNullOrWhiteSpace(despacho.TemplateDeEmail.Template))
                sql.Append("TEMPLATEEMAIL = NULL");
            else
                sql.Append(String.Concat("TEMPLATEEMAIL = '",
                                         UtilidadesDePersistencia.FiltraApostrofe(despacho.TemplateDeEmail.Template), "'"));

            sql.Append(String.Concat(" WHERE IDDESPACHOPATENTE = ", despacho.IdDespachoDePatente.Value.ToString()));

            DBHelper.ExecuteNonQuery(sql.ToString(), false);
        }
        private void MostreDespacho(IDespachoDePatentes despacho)
        {
            ctrlDespachoDePatentes.DespachoDePatentesSelecionada = despacho;
            ctrlDespachoDePatentes.CodigoDespachoDePatentes = despacho.Codigo;

            txtProvidencia.Text = despacho.TipoProvidencia;
            txtPrazoParaProvidencia.Text = despacho.PrazoProvidencia.ToString();
            txtSituacaoDoProcesso.Text = despacho.Situacao;
            txtDescricaoDoDespacho.Text = despacho.Descricao;
        }
 public void CarregueObjetoReal()
 {
     _ObjetoReal = RepositorioDeDespachoDePatentes.obtenhaInstancia().obtenhaDespachoDePatentesPeloId(_ID);
 }
        private void MostreDespachoDePatentes(IDespachoDePatentes despachodepatentes)
        {
            ViewState[ID_OBJETO] = despachodepatentes.IdDespachoDePatente.Value.ToString();

            ctrlDespachoDePatentes.DespachoDePatentesSelecionada = despachodepatentes;
            ctrlDespachoDePatentes.CodigoDespachoDePatentes = despachodepatentes.Codigo;
            txtDescricao.Text = despachodepatentes.Descricao;
            txtProvidencia.Text = despachodepatentes.TipoProvidencia;
            txtPrazoProvidencia.Value = despachodepatentes.PrazoProvidencia;
            txtSituacao.Text = despachodepatentes.Situacao;
            txtTitulo.Text = despachodepatentes.Titulo;

            rblAgendaPagamento.SelectedValue = despachodepatentes.AgendarPagamento ? "1" : "0";
            rblDesativaProcesso.SelectedValue = despachodepatentes.DesativaProcesso ? "1" : "0";

            if (despachodepatentes.TemplateDeEmail != null)
                ctrlTemplateDeEmail.TextoDoTemplate = despachodepatentes.TemplateDeEmail.Template;

            ExibaTelaConsultar();
        }