示例#1
0
    public bool InsertarCredito(string producto, int plazo, int monto, string cedula)
    {
        float tea                 = this.GetTEA(producto);
        float tnm                 = this.GetTNM(tea);
        int   anualidad           = this.CalculateAnualidad(monto, plazo, tnm);
        int   totalInteres        = this.CalculateTotalInteres(anualidad, plazo, monto);
        int   totalMontoIntereses = monto + totalInteres;

        sqlCommand.CommandType = CommandType.StoredProcedure;
        sqlCommand.CommandText = "crearCredito";
        sqlCommand.Parameters.AddWithValue("@Plazo", plazo);
        sqlCommand.Parameters.AddWithValue("@Monto", monto);
        sqlCommand.Parameters.AddWithValue("@TotalInteres", totalInteres);
        sqlCommand.Parameters.AddWithValue("@Anualidad", anualidad);
        sqlCommand.Parameters.AddWithValue("@Tnm", tnm);
        sqlCommand.Parameters.AddWithValue("@Tea", tea);
        sqlCommand.Parameters.AddWithValue("@Cedula", cedula);
        sqlCommand.Parameters.AddWithValue("@TotalMontoIntereses", totalMontoIntereses);
        sqlCommand.Parameters.AddWithValue("@Nombre", this.TrasnformProductName(producto));

        bool consultaExitosa = conexionSQL.ExecuteStoreProcedure(sqlCommand);

        sqlCommand = null;

        if (consultaExitosa)
        {
            return(true);
        }
        else
        {
            this.Error = conexionSQL.ErrorMessage;
            return(false);
        }
    }
示例#2
0
    public List <ClienteModel> ListarClientes()
    {
        sqlCommand.CommandType = CommandType.StoredProcedure;
        sqlCommand.CommandText = "listarClientes";

        bool consultaExitosa = conexionSQL.ExecuteStoreProcedure(sqlCommand);

        sqlCommand = null;
        List <ClienteModel> lista = new List <ClienteModel> {
        };

        if (consultaExitosa)
        {
            if (conexionSQL.data.Rows.Count > 0)
            {
                foreach (DataRow row in conexionSQL.data.Rows)
                {
                    lista.Add(new ClienteModel()
                    {
                        IdCliente = row["id_cliente"].ToString(),
                        Cedula    = row["cedula"].ToString(),
                        Nombre    = row["nombre"].ToString(),
                        Direccion = row["direccion"].ToString(),
                        Ingresos  = Int32.Parse(row["ingresos"].ToString()),
                        Egresos   = Int32.Parse(row["egresos"].ToString()),
                        Pasivos   = Int32.Parse(row["pasivos"].ToString()),
                        Scoring   = Int32.Parse(row["scoring"].ToString()),
                    });
                }
            }
            else
            {
                lista.Add(new ClienteModel()
                {
                    Error = "No hay clientes en la base de datos"
                });
            }
        }
        else
        {
            lista.Add(new ClienteModel()
            {
                Error = conexionSQL.ErrorMessage
            });
        }
        return(lista);
    }