Пример #1
0
        public DataTable listaFormulario(int idCaso, string cliente, string cpf, string tipo_demanda)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select f.id_caso, f.cliente, f.cpf, f.nro_processo, f.nro_linha, f.nro_contrato, f.estado, f.cidade ");
            sql.Append(",(select tf.tipo from TbTipoFormulario tf where tf.id = f.tipoFormularioId) as formulario ");
            sql.Append("from TbFormulario f ");
            sql.Append("where f.atendido = 'true' ");

            if (idCaso != 0)
            {
                sql.Append("and f.id_caso=" + idCaso + " ");
            }

            if (cliente != null)
            {
                sql.Append("and f.cliente like '%" + cliente + "%' ");
            }

            if (cpf != null)
            {
                sql.Append("and f.cpf='" + cpf + "' ");
            }

            if (tipo_demanda != "0")
            {
                sql.Append("and f.tipo_demanda='" + tipo_demanda + "' ");
            }

            sql.Append("order by f.id_caso desc ");

            return(ConexaoAdo.ExecutaSqlRetorno(sql.ToString()));
        }
Пример #2
0
        public async Task <DataTable> readDt(int formularioId, int nro_pergunta, int?sub_nro)
        {
            try
            {
                StringBuilder sql = new StringBuilder();
                sql.Append("select id, imgRedimensionada ");
                sql.Append("from TbImagem ");
                sql.Append("where formularioId=" + formularioId + " ");
                sql.Append("and nro_pergunta=" + nro_pergunta + " ");

                if (sub_nro == null)
                {
                    sql.Append("and sub_nro is null ");
                }
                else
                {
                    sql.Append("and sub_nro=" + sub_nro + "");
                }

                return(await ConexaoAdo.ExecutaSqlRetornoAsync(sql.ToString()));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Пример #3
0
        public List <object> readImages(int formularioId, int nro_pergunta, int?sub_nro)
        {
            try
            {
                StringBuilder sql = new StringBuilder();
                sql.Append("select id, imgRedimensionada ");
                sql.Append("from TbImagem ");
                sql.Append("where formularioId=" + formularioId + " ");
                sql.Append("and nro_pergunta=" + nro_pergunta + " ");

                if (sub_nro == null)
                {
                    sql.Append("and sub_nro is null ");
                }
                else
                {
                    sql.Append("and sub_nro=" + sub_nro + " ");
                }

                var reult = (from rw in ConexaoAdo.ExecutaSqlRetorno(sql.ToString()).AsEnumerable()
                             select new
                {
                    id = rw["id"],
                    imgRedimensionada = (rw["imgRedimensionada"] != DBNull.Value ? Convert.ToBase64String((Byte[])rw["imgRedimensionada"]) : null)
                }).ToList();

                return(reult.ConvertAll <object>(o => (object)o));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Пример #4
0
        public List <ImagemRelatorio> read(int id, int nro_pergunta, int?sub_nro)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select id, img ");
            sql.Append("from TbImagem ");
            sql.Append("where formularioId=" + id + " ");
            sql.Append("and nro_pergunta=" + nro_pergunta + " ");

            if (sub_nro == null)
            {
                sql.Append("and sub_nro is null ");
            }
            else
            {
                sql.Append("and sub_nro=" + sub_nro + "");
            }

            return((from rw in ConexaoAdo.ExecutaSqlRetorno(sql.ToString()).AsEnumerable()
                    select new ImagemRelatorio
            {
                id = Convert.ToInt32(rw["id"]),
                img = Convert.ToBase64String((Byte[])rw["img"])
            }).ToList());
        }
Пример #5
0
        public void deleteFormulario(int id, string tabela)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("delete from");
            sql.Append(" " + tabela + " ");
            sql.Append("where id=" + id + " ");

            ConexaoAdo.ExecutaSql(sql.ToString());
        }
Пример #6
0
        public DataTable cabecalhoPdf(int idCaso, int id_tipo_formulario)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select id, cliente, cpf, nro_linha, nro_contrato, nro_processo, resumo_reclamacao, reclamacao_cliente ");
            sql.Append(", observacoes, empresa, produto, escritorio ");
            sql.Append("from TbFormulario ");
            sql.Append("where id_caso=" + idCaso + " ");
            sql.Append("and tipoFormularioId=" + id_tipo_formulario + " ");

            return(ConexaoAdo.ExecutaSqlRetorno(sql.ToString()));
        }
Пример #7
0
 public string readPendente(int id)
 {
     try
     {
         StringBuilder sql = new StringBuilder();
         sql.Append("select PendenteValor from TbQuestao7 where formularioId=" + id + " ");
         return(ConexaoAdo.ExecutaSqlRetornoRegistro(sql.ToString())["PendenteValor"].ToString());
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex.InnerException);
     }
 }
Пример #8
0
 public byte[] loadImageById(int id)
 {
     try
     {
         StringBuilder sql = new StringBuilder();
         sql.Append("select id,img from TbImagem where id=" + id + " ");
         return((byte[])ConexaoAdo.ExecutaSqlRetornoRegistro(sql.ToString())["img"]);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex.InnerException);
     }
 }
Пример #9
0
 public async Task <DataTable> listAsync()
 {
     try
     {
         StringBuilder sql = new StringBuilder();
         sql.Append("select id,nome from TbAreaCausadora");
         return(await ConexaoAdo.ExecutaSqlRetornoAsync(sql.ToString()));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex.InnerException);
     }
 }
Пример #10
0
 public async Task <DataTable> listAsync(int motivoId)
 {
     try
     {
         StringBuilder sql = new StringBuilder();
         sql.Append("select id, nome from TbSubMotivo where motivoId=" + motivoId);
         return(await ConexaoAdo.ExecutaSqlRetornoAsync(sql.ToString()));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message, ex.InnerException);
     }
 }
Пример #11
0
        public void delete(int id)
        {
            try
            {
                StringBuilder sql = new StringBuilder();
                sql.Append("Delete from TbImagem ");
                sql.Append("where id=" + id + " ");

                ConexaoAdo.ExecutaSql(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }
Пример #12
0
        public List <Formulario1> apiTeste()
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select id, cliente, cpf ");
            sql.Append("from TbFormulario where id_caso=12312312 ");

            return((from rw in ConexaoAdo.ExecutaSqlRetorno(sql.ToString()).AsEnumerable()
                    select new Formulario1
            {
                cliente = rw["cliente"].ToString(),
                cpf = rw["cpf"].ToString(),
                id = rw["id"].ToString()
            }).ToList());
        }
Пример #13
0
        public void update(int id, string nro_linha, string nro_contrato, bool atendido)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("update TbFormulario ");
            sql.Append("set nro_linha='" + nro_linha + "' ");
            sql.Append(",nro_contrato='" + nro_contrato + "' ");

            if (atendido)
            {
                sql.Append(",atendido='true' ");
            }

            sql.Append("where id=" + id + " ");

            ConexaoAdo.ExecutaSql(sql.ToString());
        }
Пример #14
0
        public async Task copyImage(int[] ids, int nQuestao, int?subQuestao)
        {
            try
            {
                StringBuilder sql = new StringBuilder();
                sql.Append("select formularioId, img, imgRedimensionada ");
                sql.Append("from TbImagem ");
                sql.Append("where id in (");


                for (int x = 0; x < ids.Length; x++)
                {
                    if (x != ids.Length - 1)
                    {
                        sql.Append(ids[x] + ", ");
                    }
                    else
                    {
                        sql.Append(ids[x] + ")");
                    }
                }

                await Task.Run(() =>
                {
                    DataTable images = ConexaoAdo.ExecutaSqlRetorno(sql.ToString());
                    foreach (DataRow item in images.Rows)
                    {
                        Imagem i            = new Imagem();
                        i.formularioId      = Convert.ToInt32(item["formularioId"]);
                        i.img               = (byte[])item["img"];
                        i.imgRedimensionada = (byte[])item["imgRedimensionada"];
                        i.nro_pergunta      = nQuestao;
                        i.sub_nro           = (subQuestao == 0 ? (int?)null : subQuestao);
                        save(i);
                    }
                });
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }