我有一个名为 GetGridCuentas 的函数,它调用上下文以获取要在我的表格中显示的数据。它第一次工作,但之后它不断获得同一张表并且没有改变。
我只是希望我的表能够正常更新,但它不起作用。我知道这并不是 EmpreseaSeleccionadaValida 没有改变,因为我在调试器中看到它是一个不同的值,也不是说它保持相同的值并且没有改变,因为我在调试器中看到创建新查询时它变成了由于某种原因,它输出的结果与上次相同。
这是我的网格代码:
@page "/Grid"
@using BusinessERPWeb.Data
@using BusinessERPWeb.Models
@using Microsoft.AspNetCore.Identity
@using Microsoft.EntityFrameworkCore
@inject WeatherForecastService ForecastService
@layout MainLayout
@inject DataContext _context
@attribute [Authorize]
<div class="GridMenuContainer">
<div class="ButtonsContainer">
<button class="IconButton" @onclick="GetGridCuentas">
<span class="oi oi-reload Icon"></span>
Refresh
</button>
<button class="IconButton @ColorToggled()" @onclick="ToggleEdit">
<span class="oi oi-wrench Icon"></span>
@if (IsEditing)
{
<span>Cancel Edit</span>
}
else
{
<span>Edit</span>
}
</button>
<button class="IconButton" @onclick="SaveChanges">
<span class="oi oi-data-transfer-upload Icon"></span>
Save
</button>
<button class="IconButton">
<span class="oi oi-circle-x Icon"></span>
Delete
</button>
</div>
<div class="DropdownContainer">
<Dropdown @bind-MenuItems="@Columnas" ButtonText="Seleccion de columnas" DropdownStyle="height: calc(20vh - 3.5rem);" />
</div>
</div>
<div class="TableContainer">
<table class="table">
<thead>
<tr>
<th style="width: 30px;" class="ColumnaSticky">
<input type="checkbox" unchecked @onchange="@(async (ArgumentosDeCambio) =>
ToggleSelectAll(ArgumentosDeCambio))" />
</th>
<th class="ColumnaSticky" style="left: 29px">Codigo de cuenta</th>
@foreach (var column in Columnas)
{
if (column.Seleccionado)
{
<th>@column.Nombre</th>
}
}
</tr>
</thead>
<tbody>
@foreach (var cuenta in Cuentas.Where(c => c.NVEL_CNTA == 1))
{
@RenderRow(cuenta);
}
</tbody>
</table>
</div>
@code {
[CascadingParameter]
public string? EmpresaSeleccionadaValida { get; set; }
private string? AnteriorEmpresaSeleccionadaValida;
[CascadingParameter]
public Task<AuthenticationState> authenticationStateTask { get; set; }
[Inject]
public UserManager<ApplicationUser> UserManager { get; set; }
private List<string> ColumnasDisponibles = new List<string>();
private List<string> ColumnasMostradas = new List<string>();
private List<Columna> Columnas { get; set; } = new List<Columna>();
private List<planes_cuentas> Cuentas = new List<planes_cuentas>();
private ApplicationUser? signeduser = new ApplicationUser();
protected override void OnParametersSet()
{
base.OnParametersSet();
Console.WriteLine("TodosSeleccionados");
if (EmpresaSeleccionadaValida != AnteriorEmpresaSeleccionadaValida)
{
AnteriorEmpresaSeleccionadaValida = EmpresaSeleccionadaValida;
GetGridCuentas();
}
}
protected override void OnInitialized()
{
Console.WriteLine(EmpresaSeleccionadaValida);
foreach (var propiedad in typeof(planes_cuentas).GetProperties())
{
string StringPropiedad = propiedad.Name.ToString();
if (StringPropiedad != "CDGO_CNTA" && StringPropiedad != "Seleccionado")
{
Columnas.Add(new Columna(false, StringPropiedad));
}
}
GetGridCuentas();
}
private async void GetGridCuentas()
{
Cuentas = new List<planes_cuentas>();
Console.WriteLine(Cuentas);
var authState = await authenticationStateTask;
var user = authState.User;
if (user.Identity.IsAuthenticated)
{
signeduser = await UserManager.GetUserAsync(user);
Console.WriteLine(Cuentas);
Console.WriteLine(EmpresaSeleccionadaValida);
var query = await _context.planes_cuentas
.Where(x => x.CDGO_EMPRSA == EmpresaSeleccionadaValida)
.Distinct().OrderBy(n => n.CDGO_CNTA).ToListAsync();
Cuentas = query;
Console.WriteLine(EmpresaSeleccionadaValida);
StateHasChanged();
}
Console.WriteLine(Cuentas);
}
private void ToggleSelectAll(ChangeEventArgs ArgumentosDeCambio)
{
bool EstadoDeSeleccion = (bool)ArgumentosDeCambio.Value;
foreach (var cuenta in Cuentas)
{
cuenta.Seleccionado = EstadoDeSeleccion;
}
}
private void ActualizarColumnasMostradas(ChangeEventArgs ArgumentosDeCambio)
{
var ColumnasSeleccionadas = new List<string>();
foreach (var option in ArgumentosDeCambio.Value.ToString().Split(','))
{
ColumnasSeleccionadas.Add(option.Trim());
}
ColumnasMostradas = ColumnasSeleccionadas;
}
private async Task HandleMenuItemsChanged(List<Columna> newMenuItems)
{
Columnas = newMenuItems;
}
private string GetColumnValue(planes_cuentas cuenta, string columnName)
{
var property = cuenta.GetType().GetProperty(columnName);
if (property != null)
{
return property.GetValue(cuenta)?.ToString() ?? string.Empty;
}
return string.Empty;
}
//Metodos del menu
private bool IsEditing = false;
private void ToggleEdit()
{
IsEditing = !IsEditing;
foreach (var cuenta in Cuentas)
{
cuenta.IsEditable = !cuenta.IsEditable;
}
if (!IsEditing)
{
GetGridCuentas();
CuentasCambiadas = new List<planes_cuentas>();
}
}
private string ColorToggled()
{
return IsEditing ? "ButtonToggled" : string.Empty;
}
private List<planes_cuentas> CuentasCambiadas = new List<planes_cuentas>();
private void HandleCellValueChanged(ChangeEventArgs e, planes_cuentas cuenta, string ColumnaCambiada)
{
// Check if the cuenta object is not null
if (cuenta != null)
{
// Get the type of the cuenta object
Type cuentaType = cuenta.GetType();
// Get the property info based on the column name
var propertyInfo = cuentaType.GetProperty(ColumnaCambiada);
// Check if the property exists and is writable
if (propertyInfo != null && propertyInfo.CanWrite)
{
// Convert the new value to the appropriate type
object newValue = Convert.ChangeType(e.Value?.ToString(), propertyInfo.PropertyType);
int index = CuentasCambiadas.FindIndex(c => c == cuenta);
bool SeHaHechoCambiosSobreEstaCuenta = index != -1;
propertyInfo.SetValue(cuenta, newValue);//Cambio el valor de cuenta para acomodar el cambio que se hizo en la tabla
if (SeHaHechoCambiosSobreEstaCuenta)//Esto es apra que no haya tantos objetos en la lista
{
CuentasCambiadas[index] = cuenta;
}
else
{
// Add the cuenta object to the list of changed cuentas
CuentasCambiadas.Add(cuenta);
}
}
else
{
Console.WriteLine($"Property {ColumnaCambiada} not found or is read-only");
}
}
}
private async Task SaveChanges()
{
foreach (var cuenta in Cuentas)
{
if (cuenta.IsEditable)
{
// Save the changes for the editable rows
// Example: _context.Update(cuenta);
}
}
}
private void ToggleHijosVisibility(planes_cuentas cuenta)
{
cuenta.MostrarHijos = !cuenta.MostrarHijos;
}
///
/// </summary>W
/// Recursive method to render account and its children
/// <param name="cuenta"></param>
/// <returns></returns> <summary>
///
private RenderFragment RenderRow(planes_cuentas cuenta, int nivel = 1, bool EsElUltimo=false)
{
return builder =>
{
var children = Cuentas.Where(c => c.PDRE_CNTA == cuenta.CDGO_CNTA && c.NVEL_CNTA == cuenta.NVEL_CNTA + 1);
int NumeroInstruccion = 0;
// Render parent account
builder.OpenElement(NumeroInstruccion++, "tr");
builder.OpenElement(NumeroInstruccion++, "td");
builder.AddAttribute(NumeroInstruccion++, "class", "ColumnaSticky");
builder.AddAttribute(NumeroInstruccion++, "b-e13smserbq");
builder.OpenElement(NumeroInstruccion++, "input");
builder.AddAttribute(NumeroInstruccion++, "type", "checkbox");
builder.AddAttribute(NumeroInstruccion++, "checked", BindConverter.FormatValue(cuenta.Seleccionado));
builder.AddAttribute(NumeroInstruccion++, "onchange", EventCallback.Factory.CreateBinder<bool>(this, value => cuenta.Seleccionado = value, cuenta.Seleccionado));
builder.CloseElement();
builder.CloseElement(); // Close td
builder.OpenElement(NumeroInstruccion++, "td");
builder.AddAttribute(NumeroInstruccion++, "class", "ColumnaSticky");
builder.AddAttribute(NumeroInstruccion++, "b-e13smserbq");
builder.AddAttribute(NumeroInstruccion++, "style", "left: 29px");
string LineaGuia = "border-left: 2px solid black; margin-top: -10px;padding-top: 10px;";
int NumeroInstruccionEnEstePunto = NumeroInstruccion;
while (NumeroInstruccion - NumeroInstruccionEnEstePunto < nivel*2)//Lo multiplico por 2 por tener en cuenta el numero de instrucciones
{
bool EsElUltimoDiv = NumeroInstruccion - NumeroInstruccionEnEstePunto == nivel * 2 - 1;
builder.OpenElement(NumeroInstruccion++, "div");
if (!EsElUltimo || !EsElUltimoDiv)//Chequea si es el ultimo
{
LineaGuia = LineaGuia + "margin-bottom: -10px;padding-bottom: 10px;";
}
builder.AddAttribute(NumeroInstruccion++, "style", $"display: flex;justify-content: flex-start;position: relative; margin-left: 20px;{LineaGuia}");
}
builder.AddContent(NumeroInstruccion++, "-"); // Connecting line
if (children.Any())
{
builder.OpenElement(NumeroInstruccion++, "button");
builder.AddAttribute(NumeroInstruccion++, "class", "IconButton");
builder.AddAttribute(NumeroInstruccion++, "b-e13smserbq");
builder.AddAttribute(NumeroInstruccion++, "onclick", EventCallback.Factory.Create(this, () => ToggleHijosVisibility(cuenta)));
// Add the span element with the icon inside the button
builder.OpenElement(NumeroInstruccion++, "span");
builder.AddAttribute(NumeroInstruccion++, "class", "oi oi-plus Icon");
builder.CloseElement(); // Close span
builder.CloseElement(); // Close button
}
builder.AddContent(NumeroInstruccion++, cuenta.CDGO_CNTA);
NumeroInstruccionEnEstePunto = NumeroInstruccion;
for (int i = 0; i < nivel; i++)
{
builder.CloseElement();//Cierra los Divs del while anterior
}
builder.CloseElement(); // Close td
foreach (var columna in Columnas)
{
if (columna.Seleccionado)
{
builder.OpenElement(NumeroInstruccion++, "td");
builder.AddAttribute(NumeroInstruccion++, "style", "white-space: nowrap; padding: 0px;");
builder.OpenElement(NumeroInstruccion++, "input");
builder.AddAttribute(NumeroInstruccion++, "style", "margin: 7px;");
if (cuenta.IsEditable)
{
builder.AddAttribute(NumeroInstruccion++, "class", "editable");
builder.AddAttribute(NumeroInstruccion++, "oninput", EventCallback.Factory.Create(this, (ChangeEventArgs e) => HandleCellValueChanged(e, cuenta, columna.Nombre)));
}
else
{
builder.AddAttribute(NumeroInstruccion++, "readonly", "true");
builder.AddAttribute(NumeroInstruccion++, "class", "non-editable");
}
builder.AddAttribute(NumeroInstruccion++, "b-e13smserbq");
builder.AddAttribute(NumeroInstruccion++, "type", "text"); // Specify the type attribute
builder.AddAttribute(NumeroInstruccion++, "value", GetColumnValue(cuenta, columna.Nombre)); // Bind the value attribute to a variable
builder.CloseElement(); // Close the input element
builder.CloseElement(); // Close td
}
}
builder.CloseElement(); // Close tr
// Render children if expanded
if (cuenta.MostrarHijos)
{
bool isLast = false;
foreach (var child in children)
{
if (!isLast && child == children.Last())
{
isLast = true;
}
builder.AddContent(NumeroInstruccion++, RenderRow(child, child.NVEL_CNTA, isLast)); // Recursively render child
}
}
};
}
}
这是我的主要布局:
@inherits LayoutComponentBase
@using BusinessERPWeb.Data
@inject NavigationManager NavigationManager
<PageTitle>BusinessERPWeb</PageTitle>
<div class="page">
<div class="sidebar">
<NavMenu @bind-EmpresaSeleccionadaValida="@EmpresaSeleccionadaValidaSacada" />
</div>
<main style="overflow:auto">
<div class="top-row px-4">
<AuthorizeView>
<Authorized>
<button class="elevated-button" @onclick="NavigateToLogout">
<span class="oi oi-account-logout img_boton"></span>Log out
</button>
</Authorized>
<NotAuthorized>
<button class="elevated-button" @onclick="NavigateToLogin">
<span class="oi oi-account-login img_boton"></span>Log in
</button>
</NotAuthorized>
</AuthorizeView>
</div>
<CascadingValue Value="@EmpresaSeleccionadaValidaSacada">
<article class="content px-4">
@Body
</article>
</CascadingValue>
</main>
</div>
@code {
[CascadingParameter]
private string EmpresaSeleccionadaValidaSacada { get; set; }
/// <summary>
/// Funcion para navegar hacia la pagina de Login
/// </summary>
private void NavigateToLogin()
{
NavigationManager.NavigateTo("/Identity/Account/Login", forceLoad: true);
StateHasChanged();
}
/// <summary>
/// Funcion para hacer Logout
/// </summary>
private void NavigateToLogout()
{
Console.WriteLine(EmpresaSeleccionadaValidaSacada);
NavigationManager.NavigateTo("/Identity/Account/Logout", forceLoad: true);
StateHasChanged();
}
private bool DespliegaDatosEnBaseALaEmpresa()
{
return NavigationManager.Uri.Contains("/Grid", StringComparison.Ordinal);
}
}
我会显示我的导航菜单,但由于字符限制而无法显示 我的数据背景:
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using BusinessERPWeb.Models;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Diagnostics;
using BusinessERPWeb.Services;
namespace BusinessERPWeb.Data
{
public class DataContext : IdentityDbContext<ApplicationUser>
{
public DataContext(DbContextOptions options) : base(options)
{
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
// Enable logging
optionsBuilder.UseLoggerFactory(MyLoggerFactory);
optionsBuilder.AddInterceptors(new QueryInterceptor());
}
public static readonly ILoggerFactory MyLoggerFactory = LoggerFactory.Create(builder =>
{
builder.AddConsole();
});
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<IdentityUserRole<string>>(entity =>
{
entity.ToTable("ASPNETUSERROLES");
entity.Property(e => e.UserId).HasColumnName("USERID");
entity.Property(e => e.RoleId).HasColumnName("ROLEID");
});
modelBuilder.Entity<IdentityRole>(entity =>
{
entity.ToTable("ASPNETROLES");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.Name).HasColumnName("NAME");
entity.Property(e => e.NormalizedName).HasColumnName("NORMALIZEDNAME");
});
/*modelBuilder.Entity<IdentityUserRole<string>>(entity =>
{
});*/
modelBuilder.Entity<IdentityUserClaim<string>>(entity =>
{
entity.ToTable("ASPNETUSERCLAIMS");
entity.Property(e => e.Id).HasColumnName("ID");
entity.Property(e => e.UserId).HasColumnName("USERID");
entity.Property(e => e.ClaimType).HasColumnName("CLAIMTYPE");
entity.Property(e => e.ClaimValue).HasColumnName("CLAIMVALUE");
});
//COnfigurar la tabla "SEG_USRIOS"
modelBuilder.Entity<ApplicationUser>(entity =>
{
entity.ToTable("SEG_USRIOS"); // Set table name
//Propiedades ignoradas:
entity.Ignore(c => c.EmailConfirmed);
//entity.Ignore(c => c.NormalizedEmail);
//entity.Ignore(c => c.NormalizedUserName);
entity.Ignore(c => c.PhoneNumber);
entity.Ignore(c => c.PhoneNumberConfirmed);
entity.Ignore(c => c.Email);
entity.Ignore(c => c.LockoutEnabled);
entity.Ignore(c => c.AccessFailedCount);
entity.Ignore(c => c.ConcurrencyStamp);
entity.Ignore(c => c.LockoutEnd);
//entity.Ignore(c => c.PasswordHash);
entity.Ignore(c => c.SecurityStamp);
entity.Ignore(c => c.TwoFactorEnabled);
//entity.Ignore(c => c.UserName);
//entity.Ignore(c => c.Id);
entity.Ignore(e => e.IsLoggedIn);
// Map properties to columns
entity.HasKey(e => e.Id);
entity.Property(e => e.NormalizedEmail).HasColumnName("EMAIL");
entity.Property(e => e.NormalizedUserName).HasColumnName("CDGO_USRIO");
entity.Property(e => e.Id).HasColumnName("CDGO_NIT");
entity.Property(e => e.ESTDO_USRIO).HasColumnName("ESTDO_USRIO");
entity.Property(e => e.FCHA_CREACION).HasColumnName("FCHA_CREACION");
entity.Property(e => e.PasswordHash).HasColumnName("CNTRSNA");
entity.Property(e => e.RUTA_EXCEL).HasColumnName("RUTA_EXCEL");
entity.Property(e => e.NIF).HasColumnName("NIF");
entity.Property(e => e.UserName).HasColumnName("CDGO_CSTO");
});
//Configurar Bx_usermenu
modelBuilder.Entity<bx_usermenu>(entity =>
{
entity.ToTable("BX_USERMENU", schema: "COMUN"); // Set table name ans schema
entity.HasKey(e => e.ID);
entity.HasKey(e => e.CEMP);
entity.Property(e => e.ID).HasColumnName("ID");
entity.Property(e => e.MODULOS).HasColumnName("MODULOS");
entity.Property(e => e.MENUS).HasColumnName("MENUS");
entity.Property(e => e.CEMP).HasColumnName("CEMP");
entity.Property(e => e.CDGO_AGNCIA).HasColumnName("CDGO_AGNCIA");
entity.Property(e => e.CDGO_CNTA).HasColumnName("CDGO_CNTA");
entity.Property(e => e.CDGO_CSTO).HasColumnName("CDGO_CSTO");
entity.Property(e => e.CLSE_ARTCLO).HasColumnName("CLSE_ARTCLO");
entity.Property(e => e.CDGO_ARTCLO).HasColumnName("CDGO_ARTCLO");
entity.Property(e => e.CDGO_BDGA).HasColumnName("CDGO_BDGA");
entity.Property(e => e.OPCIONES).HasColumnName("OPCIONES");
entity.Property(e => e.OPCIONES).HasColumnType("jsonb");
entity.Property(e => e.PROFILEID).HasColumnName("PROFILEID");
entity.Property(e => e.EXTLOGINS).HasColumnName("EXTLOGINS");
});
//Configurar Bx_user
modelBuilder.Entity<bx_user>(entity =>
{
entity.ToTable("BX_USER", schema: "COMUN"); // Set table name and achema
entity.HasKey(e => e.ID);
entity.Property(e => e.ID).HasColumnName("ID");
entity.Property(e => e.NAME).HasColumnName("NAME");
entity.Property(e => e.ALTERNATE_SQL).HasColumnName("ALTERNATE_SQL");
entity.Property(e => e.PROFILE_ID).HasColumnName("PROFILE_ID");
entity.Property(e => e.OBSERVACIONES).HasColumnName("OBSERVACIONES");
entity.Property(e => e.OPCIONES).HasColumnName("OPCIONES");
entity.Property(e => e.REMOTEPASS).HasColumnName("REMOTEPASS");
entity.Property(e => e.EMPRESA).HasColumnName("EMPRESA");
entity.Property(e => e.FECHACREACION).HasColumnName("FECHACREACION");
entity.Property(e => e.SICFI).HasColumnName("SICFI");
entity.Property(e => e.CDGO_NIT).HasColumnName("CDGO_NIT");
});
//Configurar Empresas
modelBuilder.Entity<Empresas>(entity =>
{
entity.ToTable("EMPRSAS", schema: "COMUN"); // Set table name ans schema
entity.HasKey(e => e.CDGO_EMPRSA);
entity.Property(e => e.CDGO_EMPRSA).HasColumnName("CDGO_EMPRSA");
entity.Property(e => e.NMBRE_EMPRSA).HasColumnName("NMBRE_EMPRSA");
entity.Property(e => e.NMBRE_CORTO).HasColumnName("NMBRE_CORTO");
entity.Property(e => e.CDGO_NIT).HasColumnName("CDGO_NIT");
entity.Property(e => e.USUARIO).HasColumnName("USUARIO");
entity.Property(e => e.USUARIO_NIIF).HasColumnName("USUARIO_NIIF");
entity.Property(e => e.STR_CONN).HasColumnName("STR_CONN");
entity.Property(e => e.DB_LINK).HasColumnName("DB_LINK");
entity.Property(e => e.REGIMEN).HasColumnName("REGIMEN");
entity.Property(e => e.CIUDAD).HasColumnName("CIUDAD");
entity.Property(e => e.SUPERSOC).HasColumnName("SUPERSOC");
entity.Property(e => e.VENTAS).HasColumnType("VENTAS");
entity.Property(e => e.COLOR).HasColumnName("COLOR");
entity.Property(e => e.AUDITORIA).HasColumnName("AUDITORIA");
entity.Property(e => e.EMAILSISTEM).HasColumnName("EMAILSISTEM");
entity.Property(e => e.EMAILCONTAB).HasColumnName("EMAILCONTAB");
entity.Property(e => e.ACT_NIIF).HasColumnName("ACT_NIIF");
entity.Property(e => e.CONFIG).HasColumnName("CONFIG");
});
//Configurar Planes de cuentas
modelBuilder.Entity<planes_cuentas>(entity =>
{
entity.Ignore(e => e.Seleccionado);
entity.Ignore(e => e.MostrarHijos);
entity.Ignore(e => e.IsEditable);
entity.ToTable("PLNES_CNTAS");
entity.HasKey(e => e.CDGO_CNTA);
entity.Property(e => e.CDGO_CNTA).HasColumnName("CDGO_CNTA");
entity.Property(e => e.CDGO_EMPRSA).HasColumnName("CDGO_EMPRSA");
entity.Property(e => e.CDGO_USRIO).HasColumnName("CDGO_USRIO");
entity.Property(e => e.CDGO_CNTA_ALTRNA).HasColumnName("CDGO_CNTA_ALTRNA");
entity.Property(e => e.PDRE_CNTA).HasColumnName("PDRE_CNTA");
entity.Property(e => e.NMBRE_CNTA).HasColumnName("NMBRE_CNTA");
entity.Property(e => e.NTRLZA_CNTA).HasColumnName("NTRLZA_CNTA");
entity.Property(e => e.RQRMNTO1).HasColumnName("RQRMNTO1");
entity.Property(e => e.RQRMNTO2).HasColumnName("RQRMNTO2");
entity.Property(e => e.RQRMNTO3).HasColumnName("RQRMNTO3");
entity.Property(e => e.RQRMNTO4).HasColumnName("RQRMNTO4");
entity.Property(e => e.RQRMNTO5).HasColumnType("RQRMNTO5");
entity.Property(e => e.TPO_CNTA).HasColumnName("TPO_CNTA");
entity.Property(e => e.PYG).HasColumnName("PYG");
entity.Property(e => e.ESTDO_CNTA).HasColumnName("ESTDO_CNTA");
entity.Property(e => e.MVMNTO).HasColumnName("MVMNTO");
entity.Property(e => e.FCHA_GRBCION).HasColumnName("FCHA_GRBCION");
entity.Property(e => e.NVEL_CNTA).HasColumnName("NVEL_CNTA");
entity.Property(e => e.BUSINESS).HasColumnName("BUSINESS");
entity.Property(e => e.CDGO_NIT).HasColumnName("CDGO_NIT");
entity.Property(e => e.MNDA).HasColumnName("MNDA");
entity.Property(e => e.LP).HasColumnName("LP");
entity.Property(e => e.ACCOUNT_NAME).HasColumnName("ACCOUNT_NAME");
entity.Property(e => e.NMBRE_CNTA_ALTRNA).HasColumnName("NMBRE_CNTA_ALTRNA");
entity.Property(e => e.PDRE_CNTA_ALTRNA).HasColumnName("PDRE_CNTA_ALTRNA");
entity.Property(e => e.GRPO_CNTA).HasColumnName("GRPO_CNTA");
});
}
public DbSet<Empresas> Empresas { get; set; }
public DbSet<bx_user> Bx_User { get; set; }
public DbSet<bx_usermenu> Bx_Usermenus { get; set; }
public DbSet<ApplicationUser> Usuarios { get; set; }
public DbSet<planes_cuentas> planes_cuentas { get; set; }
}
}
我的planes_cuentas类及其扩展自的类:
namespace BusinessERPWeb.Models
{
public class planes_cuentas: TablaAMostrar
{
public string? CDGO_CNTA { get; set; }
public string? CDGO_EMPRSA { get; set; }
public string? CDGO_USRIO { get; set; }
public string? CDGO_CNTA_ALTRNA { get; set; }
public string? PDRE_CNTA { get; set; }
public string? NMBRE_CNTA { get; set; }
public string? NTRLZA_CNTA { get; set; }
public string? RQRMNTO1 { get; set; }
public string? RQRMNTO2 { get; set; }
public string? RQRMNTO3 { get; set; }
public string? RQRMNTO4 { get; set; }
public string? RQRMNTO5 { get; set; }
public string? TPO_CNTA { get; set; }
public string? PYG { get; set; }
public string? ESTDO_CNTA { get; set; }
public string? MVMNTO { get; set; }
public DateTime? FCHA_GRBCION { get; set; }
public int NVEL_CNTA { get; set; }
public string? BUSINESS { get; set; }
public string? CDGO_NIT { get; set; }
public string? MNDA { get; set; }
public int? LP { get; set; }
public string? ACCOUNT_NAME { get; set; }
public string? NMBRE_CNTA_ALTRNA { get; set; }
public string? PDRE_CNTA_ALTRNA { get; set; }
public string? GRPO_CNTA { get; set; }
}
}
namespace BusinessERPWeb.Models
{
public class TablaAMostrar
{
//Para cada clase que se extienda de esta clase hay que recordar desmapear estos atributos en el DataContext
public bool Seleccionado { get; set; }
public bool MostrarHijos { get; set; }
public bool IsEditable { get; set; }
}
}
您已经呈现了代码墙,因此很难只见树木。
这肯定会给你带来麻烦:
private async void GetGridCuentas()
您不应在任何 UI 事件处理程序中使用
async void method
模式。
这应该是:
private async Task GetGridCuentas()
请参阅此答案以了解原因 - https://stackoverflow.com/a/74691716/13065781
另请参阅有关该主题的答案 - https://stackoverflow.com/a/76078709/13065781
像这样使用带有
RenderTreeBuilder
的自动增量器是不可行的。您需要手动编号。
builder.OpenElement(NumeroInstruccion++, "tr");