コード例 #1
0
        public IList ListarPorIdProcessoArquivado(Int32 _IdProcesso, String _Arquivado)
        {
            using (SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBGesDoc"].ConnectionString))
            {
                try
                {
                    objConn.Open();

                    IList lst = new List <Documento>();

                    SqlCommand    cmd = new SqlCommand("SELECT idDocumento,idTipoDocumento,numero,nomePortador,vencimentoVigencia,dataEmissao FROM tbDocumentos WHERE setorAtual = " + _IdProcesso + " And arquivado = '" + _Arquivado + "' And ativo = 'S' Order By dataCadastro DESC", objConn);
                    SqlDataReader dr  = cmd.ExecuteReader();

                    TipoDocumentoDAL tdDAL = new TipoDocumentoDAL();

                    while (dr.Read())
                    {
                        DateTime dtVencimentoVigencia = new DateTime(1900, 1, 1);
                        DateTime dtEmissao            = new DateTime(1900, 1, 1);

                        if (dr["vencimentoVigencia"] != DBNull.Value)
                        {
                            dtVencimentoVigencia = Convert.ToDateTime(dr["vencimentoVigencia"]);
                        }

                        if (dr["dataEmissao"] != DBNull.Value)
                        {
                            dtVencimentoVigencia = Convert.ToDateTime(dr["dataEmissao"]);
                        }

                        lst.Add(
                            new Documento()
                        {
                            IdDocumento        = Convert.ToInt32(dr["idDocumento"]),
                            TipoDocumento      = tdDAL.ObterDadosPorId(Convert.ToInt32(dr["idTipoDocumento"])),
                            Descricao          = dr["numero"].ToString(),
                            NomePortador       = dr["nomePortador"].ToString(),
                            VencimentoVigencia = dtVencimentoVigencia,
                            DataEmissao        = dtEmissao
                        }
                            );
                    }

                    return(lst);
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    objConn.Close();
                }
            }
        }
コード例 #2
0
        public Documento CarregarDadosUltimoCadastrado()
        {
            using (SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBGesDoc"].ConnectionString))
            {
                try
                {
                    objConn.Open();

                    TipoDocumentoDAL tdDAL = new TipoDocumentoDAL();

                    Documento d = new Documento();

                    SqlCommand    cmd1 = new SqlCommand("SELECT MAX(idDocumento) AS idDocumento FROM tbDocumentos", objConn);
                    SqlDataReader dr1  = cmd1.ExecuteReader();

                    if (dr1.Read())
                    {
                        SqlCommand    cmd2 = new SqlCommand("SELECT idDocumento,idTipoDocumento,numero,nomePortador,rg,numeroInss,cpfCnpj,vigencia,vencimentoVigencia,dataEmissao,dataEmissao,dataAssinatura,dataCadastro,descarte,setorAtual,arquivado,alertaVencimentoVigencia,dataPagamentoRecebimento,numeroParcelas,valorPrevistoParcela,arquivo,ativo FROM tbDocumentos WHERE idDocumento = " + dr1["idDocumento"].ToString(), objConn);
                        SqlDataReader dr2  = cmd2.ExecuteReader();

                        if (dr2.Read())
                        {
                            d.IdDocumento   = Convert.ToInt32(dr2["idDocumento"]);
                            d.TipoDocumento = tdDAL.ObterDadosPorId(Convert.ToInt32(dr2["idTipoDocumento"]));
                            d.Descricao     = dr2["numero"].ToString();
                            d.NomePortador  = dr2["nomePortador"].ToString();
                            d.RG            = dr2["rg"].ToString();
                            d.NumeroINSS    = dr2["numeroInss"].ToString();
                            d.CPFCNPJ       = dr2["cpfCnpj"].ToString();
                            d.Vigencia      = Convert.ToInt32(dr2["vigencia"]);

                            if (dr2["vencimentoVigencia"] != DBNull.Value)
                            {
                                d.VencimentoVigencia = Convert.ToDateTime(dr2["vencimentoVigencia"]);
                            }

                            if (dr2["dataEmissao"] != DBNull.Value)
                            {
                                d.DataEmissao = Convert.ToDateTime(dr2["dataEmissao"]);
                            }

                            if (dr2["dataAssinatura"] != DBNull.Value)
                            {
                                d.DataAssinatura = Convert.ToDateTime(dr2["dataAssinatura"]);
                            }

                            d.DataCadastro = Convert.ToDateTime(dr2["dataCadastro"]);

                            if (dr2["descarte"] != DBNull.Value)
                            {
                                d.Descarte = Convert.ToDateTime(dr2["descarte"]);
                            }

                            d.SetorAtual = Convert.ToInt32(dr2["setorAtual"]);
                            d.Arquivado  = dr2["arquivado"].ToString();
                            d.AlertaVencimentoVigencia = dr2["alertaVencimentoVigencia"].ToString();

                            if (dr2["dataPagamentoRecebimento"] != DBNull.Value)
                            {
                                d.DataPagamentoRecebimento = Convert.ToDateTime(dr2["dataPagamentoRecebimento"]);
                            }

                            d.NumeroParcelas       = dr2["numeroParcelas"].ToString();
                            d.ValorPrevistoParcela = dr2["valorPrevistoParcela"].ToString();
                            d.Arquivo = dr2["arquivo"].ToString();
                            d.Ativo   = dr2["ativo"].ToString();
                        }
                    }

                    return(d);
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    objConn.Close();
                }
            }
        }
コード例 #3
0
        public IList Buscar(Int32 _IdProcesso, String _Descricao, DateTime _DataCadastro, Int32 _IdTipoDocumento)
        {
            using (SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBGesDoc"].ConnectionString))
            {
                try
                {
                    objConn.Open();

                    IList lst = new List <Documento>();

                    Boolean bolWhere = false;
                    String  strSQL   = "SELECT idDocumento,idTipoDocumento,numero,nomePortador,vencimentoVigencia,dataEmissao FROM tbDocumentos WHERE";

                    if (_IdProcesso != 0)
                    {
                        strSQL  += " setorAtual = " + _IdProcesso;
                        bolWhere = true;
                    }

                    if (_Descricao != "")
                    {
                        if (bolWhere)
                        {
                            strSQL += " AND numero LIKE '%" + _Descricao + "%'";
                        }
                        else
                        {
                            strSQL += " numero LIKE '%" + _Descricao + "%'";
                        }

                        bolWhere = true;
                    }

                    if (_DataCadastro != new DateTime(1, 1, 1))
                    {
                        if (bolWhere)
                        {
                            strSQL += " AND dataCadastro = '" + _DataCadastro.Month + "/" + _DataCadastro.Day + "/" + _DataCadastro.Year + "'";
                        }
                        else
                        {
                            strSQL += " dataCadastro = '" + _DataCadastro.Month + "/" + _DataCadastro.Day + "/" + _DataCadastro.Year + "'";
                        }

                        bolWhere = true;
                    }

                    if (_IdTipoDocumento != 0)
                    {
                        if (bolWhere)
                        {
                            strSQL += " AND idTipoDocumento = " + _IdTipoDocumento;
                        }
                        else
                        {
                            strSQL += " idTipoDocumento = " + _IdTipoDocumento;
                        }

                        bolWhere = true;
                    }

                    if (bolWhere)
                    {
                        strSQL += " AND arquivado = '0' Order By dataCadastro DESC";
                    }
                    else
                    {
                        strSQL += " arquivado = '0' Order By dataCadastro DESC";
                    }

                    //HttpContext.Current.Response.Write(strSQL);

                    SqlCommand    cmd = new SqlCommand(strSQL, objConn);
                    SqlDataReader dr  = cmd.ExecuteReader();

                    TipoDocumentoDAL tdDAL = new TipoDocumentoDAL();

                    while (dr.Read())
                    {
                        DateTime dtVencimentoVigencia = new DateTime(1900, 1, 1);
                        DateTime dtEmissao            = new DateTime(1900, 1, 1);

                        if (dr["vencimentoVigencia"] != DBNull.Value)
                        {
                            dtVencimentoVigencia = Convert.ToDateTime(dr["vencimentoVigencia"]);
                        }

                        if (dr["dataEmissao"] != DBNull.Value)
                        {
                            dtEmissao = Convert.ToDateTime(dr["dataEmissao"]);
                        }

                        lst.Add(
                            new Documento()
                        {
                            IdDocumento        = Convert.ToInt32(dr["idDocumento"]),
                            TipoDocumento      = tdDAL.ObterDadosPorId(Convert.ToInt32(dr["idTipoDocumento"])),
                            Descricao          = dr["numero"].ToString(),
                            NomePortador       = dr["nomePortador"].ToString(),
                            VencimentoVigencia = dtVencimentoVigencia,
                            DataEmissao        = dtEmissao
                        }
                            );
                    }

                    return(lst);
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    objConn.Close();
                }
            }
        }