public static string CarregarDados(int idPessoa)
        {
            JavaScriptSerializer objSerializer = new JavaScriptSerializer();

            System.Data.DataTable dt              = new System.Data.DataTable();
            BLL.Pessoa            objPessoaBLL    = new BLL.Pessoa();
            Entity.Pessoa         objPessoaEntity = new Entity.Pessoa();
            objPessoaEntity.cvIdPessoa = idPessoa;

            dt = objPessoaBLL.Obter(objPessoaEntity);

            List <Dictionary <string, object> > rows = new List <Dictionary <string, object> >();
            Dictionary <string, object>         row  = null;

            foreach (DataRow dr in dt.Rows)
            {
                row = new Dictionary <string, object>();
                foreach (DataColumn col in dt.Columns)
                {
                    row.Add(col.ColumnName, dr[col]);
                }
                rows.Add(row);
            }
            return(objSerializer.Serialize(rows));
        }
        public static int Salvar(Entity.Pessoa Pessoa)
        {
            System.Data.DataTable dt = new System.Data.DataTable();
            Entity.Pessoa         objCriarContaEntity = new Entity.Pessoa();
            BLL.Pessoa            objCriarContaBLL    = new BLL.Pessoa();
            try
            {
                if (Pessoa.ccNascimento != "")
                {
                    Pessoa.cdNascimento = Convert.ToDateTime(Pessoa.ccNascimento);
                }

                objCriarContaEntity = Pessoa;

                if (Pessoa.cvIdPessoa != 0 && Pessoa.cvIdPessoa != null)
                {
                    objCriarContaBLL.Atualizar(objCriarContaEntity);
                }
                else
                {
                    objCriarContaBLL.Criar(objCriarContaEntity);
                }

                return(objCriarContaEntity.cvIdPessoa);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
        public static int Excluir(int cvIdPessoa)
        {
            Entity.Pessoa objCriarContaEntity = new Entity.Pessoa();
            BLL.Pessoa    objCriarContaBLL    = new BLL.Pessoa();
            try
            {
                objCriarContaEntity.cvIdPessoa = cvIdPessoa;

                objCriarContaBLL.Excluir(objCriarContaEntity);

                return(1);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Ejemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            foreach (string file in context.Request.Files)
            {
                HttpPostedFile hpf = context.Request.Files[file];

                String idPessoa = context.Request.QueryString["idPessoa"];

                string savedFileName = Path.Combine(context.Server.MapPath("~/App_Data"), Path.GetFileName(hpf.FileName));

                byte[] imageBytes = new byte[hpf.InputStream.Length + 1];

                hpf.InputStream.Read(imageBytes, 0, imageBytes.Length);

                Entity.Pessoa objPessoaEntity = new Entity.Pessoa();
                BLL.Pessoa    objPessoaBLL    = new BLL.Pessoa();

                objPessoaEntity.ccImage    = imageBytes;
                objPessoaEntity.cvIdPessoa = Convert.ToInt32(idPessoa);

                objPessoaBLL.AtualizarAnexo(objPessoaEntity);
            }
        }