Ejemplo n.º 1
0
        public static List <PaisDTO> ListadoPais()
        {
            DataTable pobjDataTable = new DataTable();

            YouCom.DTO.PaisDTO        thePaisDTO;
            List <YouCom.DTO.PaisDTO> collPais = new List <PaisDTO>();

            if (YouCom.Comun.DAL.Accesos.Pais.ListadoPais(ref pobjDataTable))
            {
                foreach (DataRow wobjDataRow in pobjDataTable.Rows)
                {
                    thePaisDTO                     = new PaisDTO();
                    thePaisDTO.IdPais              = wobjDataRow["idPais"] != null ? wobjDataRow["idPais"].ToString() : string.Empty;
                    thePaisDTO.Descripcion         = wobjDataRow["nombre"] != null ? wobjDataRow["nombre"].ToString() : string.Empty;
                    thePaisDTO.UsuarioIngreso      = wobjDataRow["usuario_ingreso"] != null ? wobjDataRow["usuario_ingreso"].ToString() : string.Empty;
                    thePaisDTO.FechaIngreso        = wobjDataRow["fecha_ingreso"] != null ? wobjDataRow["fecha_ingreso"].ToString() : string.Empty;
                    thePaisDTO.UsuarioModificacion = wobjDataRow["usuario_modificacion"] != null ? wobjDataRow["usuario_modificacion"].ToString() : string.Empty;
                    thePaisDTO.FechaModificacion   = wobjDataRow["fecha_modificacion"] != null ? wobjDataRow["fecha_modificacion"].ToString() : string.Empty;
                    thePaisDTO.IdCondominio        = !string.IsNullOrEmpty(wobjDataRow["empresa"].ToString())  ? decimal.Parse(wobjDataRow["empresa"].ToString()) : 0;
                    thePaisDTO.Estado              = wobjDataRow["estado"] != null ? wobjDataRow["estado"].ToString() : string.Empty;

                    collPais.Add(thePaisDTO);
                }
            }
            return(collPais);
        }
Ejemplo n.º 2
0
        public static bool ValidaEliminacionPais(PaisDTO thePaisDTO, ref DataTable pobjDatable)
        {
            bool retorno = false;

            YouCom.Service.BD.SQLHelper wobjSQLHelper = new YouCom.Service.BD.SQLHelper();



            wobjSQLHelper.SetParametro("@idpais", SqlDbType.VarChar, 20, thePaisDTO.IdPais);

            try
            {
                //====================================================================================
                if (wobjSQLHelper.Ejecutar("validaEliminacionPais", "YouCom", pobjDatable) <= 0)
                {
                    retorno = true;
                }
                else
                {
                    retorno = false;
                }
                //====================================================================================
            }
            catch (Exception eobjException)
            {
                throw eobjException;
            }
            return(retorno);
        }
Ejemplo n.º 3
0
        public static List <YouCom.DTO.RegionDTO> getListadoRegion()
        {
            DataTable pobjDataTable = new DataTable();

            YouCom.DTO.RegionDTO        theRegionDTO;
            List <YouCom.DTO.RegionDTO> collRegion = new List <RegionDTO>();

            if (YouCom.DAL.RegionDAL.getListadoRegion(ref pobjDataTable))
            {
                foreach (DataRow wobjDataRow in pobjDataTable.Rows)
                {
                    theRegionDTO          = new RegionDTO();
                    theRegionDTO.IdRegion = wobjDataRow["idRegion"] != null?decimal.Parse(wobjDataRow["idRegion"].ToString()) : 0;

                    theRegionDTO.NombreRegion      = wobjDataRow["nombreRegion"] != null ? wobjDataRow["nombreRegion"].ToString() : string.Empty;
                    theRegionDTO.DescripcionRegion = wobjDataRow["descripcionRegion"] != null ? wobjDataRow["descripcionRegion"].ToString() : string.Empty;

                    PaisDTO myPaisDTO = new PaisDTO();
                    myPaisDTO.IdPais = wobjDataRow["idPais"] != null?decimal.Parse(wobjDataRow["idPais"].ToString()) : 0;

                    myPaisDTO.NombrePais    = wobjDataRow["nombrePais"] != null ? wobjDataRow["nombrePais"].ToString() : string.Empty;
                    theRegionDTO.ThePaisDTO = myPaisDTO;

                    theRegionDTO.UsuarioIngreso      = wobjDataRow["usuario_ingreso"] != null ? wobjDataRow["usuario_ingreso"].ToString() : string.Empty;
                    theRegionDTO.FechaIngreso        = wobjDataRow["fecha_ingreso"] != null ? wobjDataRow["fecha_ingreso"].ToString() : string.Empty;
                    theRegionDTO.UsuarioModificacion = wobjDataRow["usuario_modificacion"] != null ? wobjDataRow["usuario_modificacion"].ToString() : string.Empty;
                    theRegionDTO.FechaModificacion   = wobjDataRow["fecha_modificacion"] != null ? wobjDataRow["fecha_modificacion"].ToString() : string.Empty;
                    theRegionDTO.Estado = wobjDataRow["estado"] != null ? wobjDataRow["estado"].ToString() : string.Empty;


                    collRegion.Add(theRegionDTO);
                }
            }
            return(collRegion);
        }
Ejemplo n.º 4
0
    protected void rptPaisInactivo_OnItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Activar")
        {
            HiddenField hdnTipoSistema = new HiddenField();
            hdnTipoSistema = (HiddenField)e.Item.FindControl("HdnTipoSistema");

            HiddenField hdnDescripcion = new HiddenField();
            hdnDescripcion = (HiddenField)e.Item.FindControl("hdnDescripcion");

            PaisDTO thePaisDTO = new PaisDTO();

            thePaisDTO.IdPais         = decimal.Parse(hdnTipoSistema.Value);
            thePaisDTO.UsuarioIngreso = myUsuario.Rut;

            bool respuesta = YouCom.bll.PaisBLL.ActivaPais(thePaisDTO);
            if (respuesta)
            {
                cargarPaisInactivo();
                if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                {
                    string script = "alert('Pais Activado correctamente.');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                }
            }
            else
            {
            }
        }
    }
Ejemplo n.º 5
0
    protected void btnEditar_Click(object sender, EventArgs e)
    {
        btnEditar.Visible = false;
        btnGrabar.Visible = true;

        RegionDTO theRegionDTO = new RegionDTO();

        theRegionDTO.IdRegion = decimal.Parse(HidIdRegion.Value);

        PaisDTO myPaisDTO = new PaisDTO();

        myPaisDTO.IdPais        = decimal.Parse(ddlPais.SelectedValue);
        theRegionDTO.ThePaisDTO = myPaisDTO;

        theRegionDTO.DescripcionRegion = txtRegion.Text.ToUpper();
        theRegionDTO.UsuarioIngreso    = myUsuario.Rut;
        bool respuesta = YouCom.bll.RegionBLL.Update(theRegionDTO);

        if (respuesta)
        {
            cargarRegiones();

            txtRegion.Text = string.Empty;

            if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
            {
                string script = "alert('Region editado correctamente.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
            }
        }
        else
        {
        }
    }
Ejemplo n.º 6
0
        /// <summary>
        /// Obtiene un listado de paises
        /// </summary>
        /// <returns>Un objeto de tipo PaisResponseDTO</returns>
        public PaisResponseDTO GetPaisList()
        {
            PaisResponseDTO response = new PaisResponseDTO()
            {
                PaisList = new List <PaisDTO>()
            };

            PaisDTO pais = null;

            Func <PaisResponseDTO> action = () =>
            {
                using (var conexion = new SqlConnection(Helper.Connection()))
                {
                    conexion.Open();
                    var cmd = new SqlCommand(App_GlobalResources.StoredProcedures.usp_EPROCUREMENT_Pais_GETL, conexion)
                    {
                        CommandType = CommandType.StoredProcedure
                    };

                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        pais        = new PaisDTO();
                        pais.IdPais = Convert.ToInt32(reader["IdPais"]);
                        pais.Nombre = reader["Nombre"].ToString();
                        response.PaisList.Add(pais);
                    }
                }
                response.Success = true;
                return(response);
            };

            return(tryCatch.SafeExecutor(action));
        }
Ejemplo n.º 7
0
        public static bool ActivaPais(PaisDTO thePaisDTO)
        {
            bool retorno = false;

            YouCom.Service.BD.SQLHelper wobjSQLHelper = new YouCom.Service.BD.SQLHelper();



            wobjSQLHelper.SetParametro("@usuarioIngreso", SqlDbType.VarChar, 20, thePaisDTO.UsuarioIngreso);
            wobjSQLHelper.SetParametro("@PidPais", SqlDbType.VarChar, 20, thePaisDTO.IdPais);


            try
            {
                //====================================================================================
                switch (wobjSQLHelper.EjecutarNQ("Activa_Pais", "YouCom"))
                {
                case 0:
                    throw new Exception("No se pudo grabar.");

                case -1:
                    throw new Exception("Hubo un error.");

                case -2:
                    throw new Exception("Hubo un error.");
                }
                //====================================================================================
                retorno = true;
            }
            catch (Exception eobjException)
            {
                throw eobjException;
            }
            return(retorno);
        }
Ejemplo n.º 8
0
        public ActionResult Details(string NombrePais)
        {
            List <PaisDTO> _paisesTmp = CachePaises.GetInstance().Paises;

            PaisDTO pais = _paisesTmp.Where(x => x.name == NombrePais).FirstOrDefault <PaisDTO>();

            return(View("~/Views/Home/Pais.cshtml", pais));
        }
Ejemplo n.º 9
0
        internal override DTOBase PopulateDTO(SqlDataReader reader)
        {
            PaisDTO pais = new PaisDTO();

            // PaisCodigo
            if (!reader.IsDBNull(Ord_PaisCodigo))
            {
                pais.PaisCodigo = reader.GetString(Ord_PaisCodigo);
            }
            // PaisNombre
            if (!reader.IsDBNull(Ord_PaisNombre))
            {
                pais.PaisNombre = reader.GetString(Ord_PaisNombre);
            }
            // PaisContinente
            if (!reader.IsDBNull(Ord_PaisContinente))
            {
                pais.PaisContinente = reader.GetString(Ord_PaisContinente);
            }
            // PaisRegion
            if (!reader.IsDBNull(Ord_PaisRegion))
            {
                pais.PaisRegion = reader.GetString(Ord_PaisRegion);
            }

            // PaisPoblacion
            if (!reader.IsDBNull(Ord_PaisPoblacion))
            {
                pais.PaisPoblacion = reader.GetInt32(Ord_PaisPoblacion);
            }

            // PaisNombreLocal
            if (!reader.IsDBNull(Ord_PaisNombreLocal))
            {
                pais.PaisNombreLocal = reader.GetString(Ord_PaisNombreLocal);
            }
            // PaisGobierno
            if (!reader.IsDBNull(Ord_PaisGobierno))
            {
                pais.PaisGobierno = reader.GetString(Ord_PaisGobierno);
            }
            // PaisJefeDeEstado
            if (!reader.IsDBNull(Ord_PaisJefeDeEstado))
            {
                pais.PaisJefeDeEstado = reader.GetString(Ord_PaisJefeDeEstado);
            }
            // PaisCapital
            if (!reader.IsDBNull(Ord_PaisCapital))
            {
                pais.PaisCapital = reader.GetInt32(Ord_PaisCapital);
            }
            // PaisCodigo2
            if (!reader.IsDBNull(Ord_PaisCodigo2))
            {
                pais.PaisCodigo2 = reader.GetString(Ord_PaisCodigo2);
            }
            return(pais);
        }
Ejemplo n.º 10
0
        public JsonResult Update(PaisDTO PaisDTO)
        {
            var result = new
            {
                PaisDTOid = PaisService.EditPais(Mapper.Map <SistemaSLS.Domain.Entities.Pais>(PaisDTO))
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 11
0
        public static PaisDTO Traduzir(this Pais item, int idIdioma)
        {
            var dto = new PaisDTO()
            {
                Id        = item.Id,
                Descricao = item.Descricoes.FirstOrDefault(x => x.IdIdioma == idIdioma).Descricao
            };

            return(dto);
        }
Ejemplo n.º 12
0
        public PaisDTO MapDTO(Pais pais)
        {
            var paisDTO = new PaisDTO();

            paisDTO.Id        = pais.Id;
            paisDTO.Nome      = pais.Nome;
            paisDTO.Descricao = pais.Descricao;

            return(paisDTO);
        }
Ejemplo n.º 13
0
 public bool Excluir(PaisDTO dto)
 {
     if (dao.Eliminar(dto))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 14
0
 public PaisDTO Salvar(PaisDTO dto)
 {
     if (dto.Codigo > 0)
     {
         return(dao.Alterar(dto));
     }
     else
     {
         return(dao.Adicionar(dto));
     }
 }
Ejemplo n.º 15
0
        public IList <String> SaveInfo(PaisDTO obj)
        {
            List <String> list = new List <String>();

            try
            {
                using (Conn = new Connection().Conexion)
                {
                    IDbCommand       comm = Conn.CreateCommand();
                    IDbDataParameter dp   = comm.CreateParameter();
                    comm.Connection  = Conn;
                    comm.CommandType = CommandType.StoredProcedure;
                    comm.CommandText = "guardarPais";


                    //AÑADIR PARAMETROS AL PROCEDIMIENTO ALMACENADO
                    dp = comm.CreateParameter();
                    dp.ParameterName = "@Id";
                    dp.Value         = obj.id;
                    comm.Parameters.Add(dp);

                    dp = comm.CreateParameter();
                    dp.ParameterName = "@Nombre";
                    dp.Value         = obj.nombre;
                    comm.Parameters.Add(dp);


                    dp = comm.CreateParameter();
                    dp.ParameterName = "@Descripcion";
                    dp.Value         = obj.descripcion;
                    comm.Parameters.Add(dp);



                    Conn.Open();
                    IDataReader dr      = comm.ExecuteReader(CommandBehavior.CloseConnection);
                    int         columns = dr.FieldCount;

                    while (dr.Read())
                    {
                        for (int i = 0; i < columns; i++)
                        {
                            list.Add(dr.GetValue(i).ToString().Trim());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                list.Add(String.Format("Error: {0}", ex.Message));
            }

            return(list);
        }
Ejemplo n.º 16
0
    protected void btnGrabar_Click(object sender, EventArgs e)
    {
        List <RegionDTO> region = new List <RegionDTO>();

        region = (Session["regiones"] as List <RegionDTO>);

        RegionDTO theRegionDTO = new RegionDTO();

        theRegionDTO.DescripcionRegion = txtRegion.Text.ToUpper();
        theRegionDTO.NombreRegion      = txtRegion.Text.ToUpper();

        PaisDTO myPaisDTO = new PaisDTO();

        myPaisDTO.IdPais        = decimal.Parse(ddlPais.SelectedValue);
        theRegionDTO.ThePaisDTO = myPaisDTO;

        theRegionDTO.UsuarioIngreso = myUsuario.Rut;


        region = region.Where(x => x.DescripcionRegion == theRegionDTO.DescripcionRegion).ToList();
        if (region.Any())
        {
            foreach (var item in region)
            {
                if (item.Estado == "2")
                {
                    string script = "alert('Region Existe pero Fue Eliminado Para Activarlo dirigase a Papelera.');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                    return;
                }
                else
                {
                    string script = "alert('Region ya Existe .');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                    return;
                }
            }
        }


        bool respuesta = YouCom.bll.RegionBLL.Insert(theRegionDTO);

        if (respuesta)
        {
            txtRegion.Text = string.Empty;
            string script = "alert('Region Ingresado correctamente.');";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
            cargarRegiones();
        }
        else
        {
        }
    }
Ejemplo n.º 17
0
    protected void rptPais_OnItemCommand(object sender, RepeaterCommandEventArgs e)
    {
        if (e.CommandName == "Editar")
        {
            HiddenField hdnTipoSistema = new HiddenField();
            hdnTipoSistema = (HiddenField)e.Item.FindControl("HdnTipoSistema");

            HiddenField hdnDescripcion = new HiddenField();
            hdnDescripcion = (HiddenField)e.Item.FindControl("hdnDescripcion");


            HidIdPais.Value   = hdnTipoSistema.Value;
            txtPais.Text      = hdnDescripcion.Value;
            btnGrabar.Visible = false;
            btnEditar.Visible = true;
        }
        if (e.CommandName == "Eliminar")
        {
            HiddenField hdnTipoSistema = new HiddenField();
            hdnTipoSistema = (HiddenField)e.Item.FindControl("HdnTipoSistema");

            HiddenField hdnDescripcion = new HiddenField();
            hdnDescripcion = (HiddenField)e.Item.FindControl("hdnDescripcion");

            PaisDTO thePaisDTO = new PaisDTO();
            thePaisDTO.IdPais         = decimal.Parse(hdnTipoSistema.Value);
            thePaisDTO.UsuarioIngreso = myUsuario.Rut;

            bool validacionIntegridad = YouCom.bll.PaisBLL.ValidaEliminacionPais(thePaisDTO);
            if (validacionIntegridad)
            {
                string script = "alert(' No es posible eliminar un Pais Con regiones Asociadas.');";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                return;
            }
            else
            {
                bool respuesta = YouCom.bll.PaisBLL.Delete(thePaisDTO);
                if (respuesta)
                {
                    cargarPaises();
                    if (!Page.ClientScript.IsClientScriptBlockRegistered("SET"))
                    {
                        string script = "alert('Pais Eliminado correctamente.');";
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                    }
                }
                else
                {
                }
            }
        }
    }
Ejemplo n.º 18
0
 public override void BotaoInserir()
 {
     try
     {
         PaisSelected = new PaisDTO();
         IsEditar     = true;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Alerta do sistema", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Ejemplo n.º 19
0
 public override void BotaoCancelar()
 {
     try
     {
         BotaoLocalizar();
         IsEditar     = false;
         PaisSelected = null;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Alerta do sistema", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Ejemplo n.º 20
0
        public static bool ValidaEliminacionPais(PaisDTO thePaisDTO)
        {
            DataTable pobjDataTable = new DataTable();
            bool      retorno       = false;

            if (YouCom.mantenedores.DAL.MantenedoresDAL.ValidaEliminacionPais(thePaisDTO, ref pobjDataTable))
            {
                foreach (DataRow wobjDataRow in pobjDataTable.Rows)
                {
                    retorno = true;
                }
            }
            return(retorno);
        }
Ejemplo n.º 21
0
 /// <summary>
 /// Este metodo convierte un DAL a DTO
 /// </summary>
 /// <param name="DAL">Parametro DAL</param>
 /// <returns>Objeto tipo DTO</returns>
 public static PaisDTO MapeoDALToDTO(Pais DAL)
 {
     try
     {
         PaisDTO c = new PaisDTO();
         c.Nombre = DAL.Nombre;
         c.PaisId = DAL.PaisId;
         return(c);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Este metodo convierte un DTO a DAL
 /// </summary>
 /// <param name="DTO">Parametro DTO</param>
 /// <returns>Objeto tipo DAL</returns>
 public static Pais MapeoDTOToDAL(PaisDTO DTO)
 {
     try
     {
         Pais c = new Pais();
         c.Nombre = DTO.Nombre;
         c.PaisId = DTO.PaisId;
         return(c);
     }
     catch (Exception)
     {
         return(null);
     }
 }
Ejemplo n.º 23
0
 public void ExcluirPais()
 {
     try
     {
         using (ServiceServidor Servico = new ServiceServidor())
         {
             Servico.DeletePais(PaisSelected);
             PaisSelected = null;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 24
0
 public void SalvarAtualizarPais()
 {
     try
     {
         using (ServiceServidor Servico = new ServiceServidor())
         {
             Servico.SalvarAtualizarPais(PaisSelected);
             PaisSelected = null;
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Ejemplo n.º 25
0
        public async Task <bool> UpdateAsync(PaisDTO entityDTO)
        {
            if (!_executeValidation.ExecuteValidatorClass(new PaisValidator(), entityDTO))
            {
                return(false);
            }
            if (await _paisRepository.Exists(entityDTO.Descricao))
            {
                _notify.AddNotification(new NotificationMessage("País informado já está registrado."));
                return(false);
            }
            await _paisRepository.UpdateAsync(_mapper.Map <Pais>(entityDTO));

            return(await _unitOfWork.Commit());
        }
Ejemplo n.º 26
0
    protected void btnGrabar_Click(object sender, EventArgs e)
    {
        List <PaisDTO> pais = new List <PaisDTO>();

        pais = (Session["paises"] as List <PaisDTO>);

        PaisDTO thePaisDTO = new PaisDTO();

        thePaisDTO.DescripcionPais = txtPais.Text.ToUpper();
        thePaisDTO.UsuarioIngreso  = myUsuario.Rut;


        pais = pais.Where(x => x.DescripcionPais == thePaisDTO.DescripcionPais).ToList();
        if (pais.Any())
        {
            foreach (var item in pais)
            {
                if (item.Estado == "2")
                {
                    string script = "alert('Pais Existe pero Fue Eliminado Para Activarlo dirigase a Papelera.');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                    return;
                }
                else
                {
                    string script = "alert('Pais ya Existe .');";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
                    return;
                }
            }
        }


        bool respuesta = YouCom.bll.PaisBLL.Insert(thePaisDTO);

        if (respuesta)
        {
            txtPais.Text = string.Empty;
            string script = "alert('Pais Ingresado correctamente.');";
            Page.ClientScript.RegisterStartupScript(this.GetType(), "SET", script, true);
            cargarPaises();
        }
        else
        {
        }
    }
        public ActionResult SaveInfo(int id, String nombre, String descripcion)
        {
            /*Se define el DTO (Clase que solo define datos, no funciones que lo diferencia del modelo)*/
            PaisDTO objDTO = new PaisDTO(id, nombre, descripcion);
            /*Se recibe en una lista generica el resultado del login definida en el service y obligada por el contract*/
            IEnumerable <String> info = ContractService.SaveInfo(objDTO);
            /*Lista temporal que contendra la respuesta que se le dara al cliente*/
            IList <String> res = new List <String>();

            /*Se valida si la consulta SQL retorno valores*/
            if (info != null && info.Count() > 0)
            {
                res.Add("Status");
                res.Add("Success");
            }
            /*Se para la lista de la respuesta a JSON*/
            return(Json(new { d = res }));
        }
Ejemplo n.º 28
0
        public ActionResult Adicionar(PaisDTO _params)
        {
            string mensaje = string.Empty;

            if (!ModelState.IsValid)
            {
                return(View(_params));
            }

            try
            {
                IAgregarPais pais = new PaisRepositorio();
                pais.AgregarPais(_params, out mensaje);
            }
            catch (Exception ex)
            {
            }
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 29
0
        public void AtualizarListaPais(int pagina)
        {
            try
            {
                using (ServiceServidor Servico = new ServiceServidor())
                {
                    if (pagina == 0)
                    {
                        IndiceNavegacao = 0;
                    }
                    else if (pagina > 0 && ListaPais.Count == QuantidadePagina)
                    {
                        IndiceNavegacao += QuantidadePagina;
                    }
                    else if (pagina < 0 && IndiceNavegacao != 0)
                    {
                        IndiceNavegacao -= QuantidadePagina;
                    }

                    PaisDTO Pais = new PaisDTO();
                    if (!Filtro.Trim().Equals(""))
                    {
                        Pais.NomePtbr = Filtro;
                    }

                    IList <PaisDTO> ListaServ = Servico.SelectPaisPagina(IndiceNavegacao, true, QuantidadePagina, true, Pais);

                    ListaPais.Clear();

                    foreach (PaisDTO objAdd in ListaServ)
                    {
                        ListaPais.Add(objAdd);
                    }
                    PaisSelected = null;
                }
                QuantidadeCarregada = ListaPais.Count;
                ControlarNavegacao();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 30
0
        public static void SavePais(ref PaisDTO Pais)
        {
            SqlCommand command;

            if (Pais.IsNew)
            {
                command = GetDbSprocCommand("usp_Paises_Insert");
                command.Parameters.Add(CreateOutputParameter("@IDPais", SqlDbType.Int));
            }
            else
            {
                command = GetDbSprocCommand("usp_Paises_Update");
                command.Parameters.Add(CreateParameter("@IDPais", Pais.PaisCodigo, 3));
            }


            command.Parameters.Add(CreateParameter("@PaisCapital", Pais.PaisCapital));
            command.Parameters.Add(CreateParameter("@idPais2", Pais.PaisCodigo2, 3));
            command.Parameters.Add(CreateParameter("@PaisContinente", Pais.PaisContinente, 50));
            command.Parameters.Add(CreateParameter("@PaisGobierno", Pais.PaisGobierno, 45));

            command.Parameters.Add(CreateParameter("@PaisJefeDeEstado", Pais.PaisJefeDeEstado, 60));
            command.Parameters.Add(CreateParameter("@PaisNombre", Pais.PaisNombre, 52));
            command.Parameters.Add(CreateParameter("@PaisNombreLocal", Pais.PaisNombreLocal, 45));
            command.Parameters.Add(CreateParameter("@PaisPoblacion", Pais.PaisPoblacion));

            command.Parameters.Add(CreateParameter("@PaisRegion", Pais.PaisRegion, 26));



            // Run the command.
            command.Connection.Open();
            command.ExecuteNonQuery();
            command.Connection.Close();

            // If this is a new record, let's set the ID so the object
            // will have it.
            if (Pais.IsNew)
            {
                Pais.PaisCodigo = (string)command.Parameters["@IDPais"].Value;
            }
        }
Ejemplo n.º 31
0
Archivo: hcrDAO.cs Proyecto: royds4/HCR
        public Paises PaisesGrid()
        {
            Paises userse = new Paises();
            string connectionString = UtilSh.strCnn2; //System.Configuration.ConfigurationManager.ConnectionStrings["cnnSql2"].ToString();
            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                using (SqlCommand command = new SqlCommand())
                {
                    command.Connection = connection;
                    command.CommandText = "Exec dbo.PaisGrid";
                    command.CommandType = CommandType.Text;
                    connection.Open();

                    using (SqlDataReader dataReader = command.ExecuteReader())
                    {
                        PaisDTO user;
                        while (dataReader.Read())
                        {
                            user = new PaisDTO();//Creación de un nuevo objeto del tipo de nuestro DTO en donde cargaremos toda la información proveniente de nuestro comando de DB, discriminando cada elemento con 'request'
                            user.ID = Convert.ToInt32(dataReader["ID"]);
                            user.NPais = Convert.ToString(dataReader["Pais"]);
                            userse.Add(user);
                        }
                    }

                    //Convert.ToInt32(paramTotalRecords.Value);
                }
            }
            return userse;
        }