Esempio n. 1
0
        public async Task <CreditoDetalle> getCurp(string curp)
        {
            ConsultaSQL    sql   = new ConsultaSQL(_appSettings);
            CreditoDetalle datos = await sql.getCurp(curp);

            return(datos);
        }
Esempio n. 2
0
        public async Task <CreditoDetalle> getCurp(string curp)
        {
            CreditoDetalle consulta = new CreditoDetalle();

            using (SqlConnection connection = new SqlConnection(_appSettings.cadenaConexionSQLServer))
            {
                SqlParameter[] Parameters =
                {
                    new SqlParameter("@Curp", SqlDbType.VarChar, 18)
                    {
                        Value = curp
                    }
                };

                DataTable exec = Helpers.SqlHelper.ExecuteDataTable(connection, CommandType.StoredProcedure, _appSettings.procedureConsultaCurp, Parameters, 1);

                foreach (DataRow dataRow in exec.Rows)
                {
                    if (consulta.creditos is null)
                    {
                        consulta.primerNombre    = dataRow[0].ToString();
                        consulta.segundoNombre   = dataRow[1].ToString();
                        consulta.apellidoPaterno = dataRow[2].ToString();
                        consulta.apellidoMaterno = dataRow[3].ToString();
                        consulta.fechaNacimiento = DateTime.Parse(dataRow[4].ToString());
                        //consulta.rfc = dataRow[5].ToString();
                        consulta.creditosActivos = exec.Rows.Count;
                        consulta.creditos        = new List <Credito>();
                        consulta.telefono        = dataRow[12].ToString();
                    }

                    if (String.IsNullOrEmpty(consulta.rfc))
                    {
                        consulta.rfc = dataRow[5].ToString();
                    }

                    if (consulta.creditos != null)
                    {
                        Credito credito = new Credito();
                        credito.sistema       = dataRow[6].ToString();
                        credito.noCda         = int.Parse(dataRow[7].ToString());
                        credito.importeTotal  = decimal.Parse(dataRow[8].ToString());
                        credito.saldoActual   = decimal.Parse(dataRow[9].ToString());
                        credito.saldoAtrasado = decimal.Parse(dataRow[10].ToString());
                        credito.diasAtraso    = int.Parse(dataRow[11].ToString());
                        consulta.creditos.Add(credito);
                    }
                }
            }

            return(consulta);
        }
// ##########################################################################################
// ###############   Recuperar un crédito a partir de su id   ###############################
// ##########################################################################################

        public static Credito select(int id)
        {
            Credito credito = new Credito();

            credito.id = id;

            string query;
            List <SqlParameter> parameters;


            // ####  Recuperar la información del crédito   #####

            query = "select codigo, id_asociado, tipo, monto, interes, cuota, " +
                    "plazo, forma_pago, fecha, aportacion, cuota_social, garantia_aportacion, activo " +
                    "from asociados.credito where id = @id";
            parameters = new List <SqlParameter>()
            {
                new SqlParameter("id", credito.id)
            };
            SqlDataReader dataReader = Queries.getDataReader(query, parameters);

            while (dataReader.Read())
            {
                credito.codigo              = dataReader.GetString(0);
                credito.idAsociado          = dataReader.GetInt32(1);
                credito.tipo                = dataReader.GetString(2);
                credito.monto               = dataReader.GetDecimal(3);
                credito.interes             = dataReader.GetByte(4);
                credito.cuota               = dataReader.GetDecimal(5);
                credito.plazo               = dataReader.GetByte(6);
                credito.forma_pago          = dataReader.GetString(7);
                credito.fecha               = dataReader.GetDateTime(8);
                credito.aportacion          = dataReader.GetDecimal(9);
                credito.cuota_social        = dataReader.GetDecimal(10);
                credito.garantia_aportacion = dataReader.GetBoolean(11);
                credito.activo              = dataReader.GetBoolean(12);
            }
            dataReader.Close();


            // ####   Recuperar los pagos de este crédito   #####

            credito.detallesPago = new List <CreditoDetalle>();

            query = "select monto_pagado, aportacion, cuota_social, capital, interes, fecha, saldoParcial from asociados.creditodetalle " +
                    "where id_credito = @id order by fecha";
            parameters = new List <SqlParameter>()
            {
                new SqlParameter("id", credito.id)
            };
            dataReader = Queries.getDataReader(query, parameters);
            while (dataReader.Read())
            {
                CreditoDetalle detalle = new CreditoDetalle(dataReader.GetDecimal(0), dataReader.GetDecimal(1),
                                                            dataReader.GetDecimal(2), dataReader.GetDateTime(5));
                detalle.capital      = dataReader.GetDecimal(3);
                detalle.interes      = dataReader.GetDecimal(4);
                detalle.saldoParcial = dataReader.GetDecimal(6);
                credito.detallesPago.Add(detalle);
            }
            dataReader.Close();

            // ##### Recupera la información del asociado (parcialmente, solo la que se usa)  ####

            credito.asociado = AsociadoServicio.selectParcial(credito.idAsociado);


            // #### Recupera el objeto CreditoDescuento  #####

            credito.creditoDescuento = new CreditoDescuento();

            query      = "select cuota_ingreso, escrituracion, seguro, papeleria from asociados.creditodescuento where id_credito = @id";
            parameters = new List <SqlParameter>()
            {
                new SqlParameter("id", credito.id)
            };
            dataReader = Queries.getDataReader(query, parameters);
            while (dataReader.Read())
            {
                credito.creditoDescuento.cuota_ingreso = dataReader.GetDecimal(0);
                credito.creditoDescuento.escrituracion = dataReader.GetDecimal(1);
                credito.creditoDescuento.seguro        = dataReader.GetDecimal(2);
                credito.creditoDescuento.papeleria     = dataReader.GetDecimal(3);
            }
            dataReader.Close();

            return(credito);
        }