Example #1
0
        public async Task <ContratoDetalle> CarteraContratoDetalle(string userID, long contrato)
        {
            ContratoDetalle contratoDetalle = new ContratoDetalle();

            using (SqlConnection connection = new SqlConnection(_appSettings.cadenaConexionSQLServer))
            {
                SqlParameter[] parameters =
                {
                    new SqlParameter("@contrato", contrato)
                    {
                        SqlDbType = SqlDbType.Int,Direction  = ParameterDirection.Input
                    },
                    new SqlParameter("@userID",   userID)
                    {
                        SqlDbType = SqlDbType.VarChar,Size       =150, Direction = ParameterDirection.Input
                    }
                };

                DataTable exec = Helpers.SqlHelper.ExecuteDataTable(connection, CommandType.StoredProcedure, _appSettings.procedureContratoDetalle, parameters, 2);

                foreach (DataRow dataRow in exec.Rows)
                {
                    if (contratoDetalle.integrantesCant == 0)
                    {
                        contratoDetalle.fechaTermina    = dataRow[0].ToString();
                        contratoDetalle.fechaInicio     = dataRow[1].ToString();
                        contratoDetalle.importe         = double.Parse(dataRow[2].ToString());
                        contratoDetalle.saldoActual     = double.Parse(dataRow[3].ToString());
                        contratoDetalle.saldoAtrazado   = double.Parse(dataRow[4].ToString());
                        contratoDetalle.diasAtrazo      = int.Parse(dataRow[5].ToString());
                        contratoDetalle.pagoXPlazo      = double.Parse(dataRow[6].ToString());
                        contratoDetalle.ultimoPlazoPag  = int.Parse(dataRow[7].ToString());
                        contratoDetalle.plazos          = int.Parse(dataRow[8].ToString());
                        contratoDetalle.capital         = double.Parse(dataRow[9].ToString());
                        contratoDetalle.interes         = double.Parse(dataRow[10].ToString());
                        contratoDetalle.contacto        = dataRow[11].ToString();
                        contratoDetalle.status          = dataRow[12].ToString();
                        contratoDetalle.integrantesCant = exec.Rows.Count;
                        contratoDetalle.integrantes     = new List <Integrante>();
                        contratoDetalle.renovado        = Boolean.Parse(dataRow[20].ToString());
                    }

                    Integrante integrante = new Integrante
                    {
                        cveCli      = dataRow[13].ToString(),
                        nombreCom   = dataRow[14].ToString(),
                        telefonoCel = dataRow[15].ToString(),
                        importeT    = double.Parse(dataRow[16].ToString()),
                        capital     = double.Parse(dataRow[17].ToString()),
                        diaAtr      = int.Parse(dataRow[18].ToString()),
                        noCda       = int.Parse(dataRow[19].ToString()),
                        tesorero    = int.Parse(dataRow[21].ToString()) == 1 ? true : false,
                        presidente  = int.Parse(dataRow[22].ToString()) == 1 ? true : false,
                    };
                    contratoDetalle.integrantes.Add(integrante);
                }
            }

            return(contratoDetalle);
        }
        public async Task <ContratoDetalle> GetCarteraContratoDetalle(string userID, long contrato)
        {
            CarteraSQL      sql             = new CarteraSQL(_appSettings);
            ContratoDetalle contratoDetalle = await sql.CarteraContratoDetalle(userID, contrato);

            return(contratoDetalle);
            //throw new System.NotImplementedException();
        }