Beispiel #1
0
        public JsonResult <ListaBancoResponse> obtenerBancos(string Token)
        {
            ListaBancoResponse respuesta = new ListaBancoResponse(false, 0, string.Empty);

            #region Validar Token
            if (!BusinessLogic.Validacion.TokenValido(Token))
            {
                respuesta = new ListaBancoResponse(true, 9020, "Token no válido");
                return(Json(respuesta));
            }
            #endregion

            #region llamar a BD y obtener las Sucursales
            BusinessEntity.IMPEG.Cobranza.Banco oBancoBE = new BusinessEntity.IMPEG.Cobranza.Banco();
            oBancoBE.Baja = false;

            BusinessEntity.DataHandler oDH = BusinessLogic.Util.Consultar(BusinessEntity.QueryOptions.Consultar_ParaLista, oBancoBE);
            #endregion

            #region Validaciones
            if (oDH.Error)
            {
                respuesta.Error        = true;
                respuesta.ErrorId      = 9021;
                respuesta.MensajeError = "Lo sentimos, ocurrió un problema.";
            }

            if (!oDH.ContieneInformacion)
            {
                respuesta.Error        = true;
                respuesta.ErrorId      = 9022;
                respuesta.MensajeError = "No pudimos obtener el listado de bancos.";
            }
            #endregion

            #region Asignación de información
            foreach (System.Data.DataRow dr in oDH.Resultado.Tables[0].Rows)
            {
                respuesta.Bancos.Add(new Banco(dr));
            }
            #endregion

            return(Json(respuesta));
        }
Beispiel #2
0
        public BusinessEntity.DataHandler Consultar(BusinessEntity.QueryOptions Opcion, BusinessEntity.IMPEG.Cobranza.Banco oBE)
        {
            BusinessEntity.DataHandler oDataHandler = new BusinessEntity.DataHandler();

            try
            {
                DataSet Resultado = new DataSet();
                oComando.CommandText = "Cobranza.spBanco_Consultar";
                oComando.CommandType = System.Data.CommandType.StoredProcedure;

                oComando.Parameters.Clear();
                oParametro       = new System.Data.SqlClient.SqlParameter("@Opcion", System.Data.SqlDbType.SmallInt);
                oParametro.Value = (short)Opcion;
                oComando.Parameters.Add(oParametro);

                oParametro       = new System.Data.SqlClient.SqlParameter("@BancoId", System.Data.SqlDbType.Int);
                oParametro.Value = oBE.BancoId;
                oComando.Parameters.Add(oParametro);

                oParametro       = new System.Data.SqlClient.SqlParameter("@BancoDescripcion", System.Data.SqlDbType.NVarChar);
                oParametro.Value = oBE.BancoDescripcion;
                oComando.Parameters.Add(oParametro);

                oParametro       = new System.Data.SqlClient.SqlParameter("@Clave", System.Data.SqlDbType.NVarChar);
                oParametro.Value = oBE.Clave;
                oComando.Parameters.Add(oParametro);

                oParametro       = new System.Data.SqlClient.SqlParameter("@Baja", System.Data.SqlDbType.Bit);
                oParametro.Value = oBE.Baja;
                oComando.Parameters.Add(oParametro);

                if (this.Conectar())
                {
                    SqlDataAdapter daResultado = new SqlDataAdapter(oComando);
                    daResultado.Fill(oDataHandler.Resultado);
                    Desconectar();
                }
            }
            catch (Exception ex)
            {
                oDataHandler.Error        = true;
                oDataHandler.MensajeError = ex.Message;
            }

            return(oDataHandler);
        }