@page "/produccion/pendientes" @inject IProduccionService ProduccionService @inject TooltipService tooltipService @inject DialogService DialogService @inject IPedidoService PedidoService @inject ProtectedSessionStorage ProtectedSessionStore @inject IPeTrazabilidadService PeTrazabilidadService <RadzenCard> <RadzenRow> <RadzenColumn Size="4"> <div> <RadzenDataGrid Data="@produccions" TItem="Produccion" AllowColumnResize="true" Density="Density.Compact" Style="font-family:Calibri; font-size:8px"> <Columns> <RadzenDataGridColumn TItem="Produccion" Property="dFechaEntrega" Title="Entrega" Width="80px" FormatString="{0:d}"> <Template Context="data"> @if (data.dFechaEntrega <= DateTime.Today) { <RadzenText TextStyle="TextStyle.Body1" Style="background-color:lightcoral; color:white;width:80px">@String.Format("{0:d}", data.dFechaEntrega)</RadzenText> } else { @if (data.dFechaEntrega <= DateTime.Today.AddDays(5) && data.dFechaEntrega > DateTime.Today) { <RadzenText TextStyle="TextStyle.Body1" Style="background-color:orange;color:white;width:80px">@String.Format("{0:d}", data.dFechaEntrega)</RadzenText> } else { <RadzenText TextStyle="TextStyle.Body1" Style="width:80px">@String.Format("{0:d}", data.dFechaEntrega)</RadzenText> } } </Template> </RadzenDataGridColumn> <RadzenDataGridColumn TItem="Produccion" Property="cPedido" Title="Pedido" Width="80px"></RadzenDataGridColumn> <RadzenDataGridColumn TItem="Produccion" Title="Detalles" Width="60px"> <Template Context="data"> <RadzenButton ButtonStyle="ButtonStyle.Secondary" Text="Detalle" Variant="Variant.Flat" Shade="Shade.Lighter" MouseEnter="@(args => ShowTooltip(args))" Click="@((x)=>ShowDetalle(data))"> <span class="material-symbols-outlined"> Article </span> </RadzenButton> </Template> </RadzenDataGridColumn> <RadzenDataGridColumn TItem="Produccion" Title="Programar" Width="60px"> <Template Context="data"> <RadzenButton ButtonStyle="ButtonStyle.Secondary" Text="Programar" Variant="Variant.Flat" Shade="Shade.Lighter" MouseEnter="@(args => ShowTooltipAdd(args))" Click="@((x)=>Programar(data))"> <span class="material-symbols-outlined"> Calendar_Month </span> </RadzenButton> </Template> </RadzenDataGridColumn> </Columns> </RadzenDataGrid> </div> </RadzenColumn> <RadzenColumn> <RadzenScheduler @ref="@scheduler" SlotRender="@OnSlotRender" style="height: 768px;" Data="@appointments" TItem="Cita" StartProperty="dInicio" EndProperty="dFin" TextProperty="cPedido" AppointmentSelect=@OnAppointmentSelect AppointmentRender=@OnAppointmentRender SelectedIndex="2"> <RadzenDayView /> <RadzenWeekView /> <RadzenMonthView /> </RadzenScheduler> </RadzenColumn> </RadzenRow> </RadzenCard> @code { IEnumerable<Produccion>? produccions = Enumerable.Empty<Produccion>(); IEnumerable<Produccion>? programa = Enumerable.Empty<Produccion>(); List<Cita> appointments = new List<Cita>(); Dictionary<DateTime, string> events = new Dictionary<DateTime, string>(); RadzenScheduler<Cita>? scheduler = new RadzenScheduler<Cita>(); int iValue = 0; protected override async Task OnInitializedAsync() { try { //produccions = await ProduccionService.GetPendientes(); } catch (Exception ex) { Logs.ErrorSistema("pedidospendientes.razor", "OnInitializedAsync", ex.Message); } } protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { produccions = await ProduccionService.GetPendientes(); programa = await ProduccionService.GetPendientesXMes(DateTime.Today); foreach (Produccion oItem in programa) { Cita oCita = new Cita(); oCita.IdPedido = oItem.IdPedido; oCita.cPedido = oItem.cPedido; oCita.dInicio = oItem.dFechaInicio; oCita.dFin = oItem.dFechaFin; appointments.Add(oCita); } await scheduler.Reload(); StateHasChanged(); } } protected override void OnAfterRender(bool firstRender) { } private void ShowTooltip(ElementReference elementReference, TooltipOptions options = null) => tooltipService.Open(elementReference, "Detalle", options); private void ShowTooltipAdd(ElementReference elementReference, TooltipOptions options = null) => tooltipService.Open(elementReference, "Programar", options); private async Task ShowDetalle(Produccion oItem) { } private async Task Programar(Produccion oItem) { Cita data = await DialogService.OpenAsync<DialogAddPrograma>("Programar", new Dictionary<string, object> { { "vIdPedido", oItem.IdPedido }, { "vcPedido", oItem.cPedido }, { "Start", DateTime.Today }, { "End", DateTime.Today } }); if(data != null) { int iresult = 0; iresult = await ProduccionService.Save(data.dInicio, data.dFin, data.IdPedido); data.cPedido = oItem.cPedido; appointments.Add(data); await scheduler.Reload(); iresult = await PedidoService.CambioStatus(oItem.IdPedido, 52); PeTrazabilidad oTraz = new PeTrazabilidad(); oTraz.IdPedido = oItem.IdPedido; oTraz.IdStatus = 52; Usuario usuario = new Usuario(); var vusuario = await ProtectedSessionStore.GetAsync<Usuario>("ssUser"); usuario = vusuario.Value ?? usuario; oTraz.IdUsuario = usuario.IdUsuario; await PeTrazabilidadService.Save(oTraz); produccions = await ProduccionService.GetPendientes(); } } void OnSlotRender(SchedulerSlotRenderEventArgs args) { // Highlight today in month view if (args.View.Text == "Month" && args.Start.Date == DateTime.Today) { args.Attributes["style"] = "background: rgba(255,220,40,.2);"; } // Highlight working hours (9-18) if ((args.View.Text == "Week" || args.View.Text == "Day") && args.Start.Hour > 8 && args.Start.Hour < 19) { args.Attributes["style"] = "background: rgba(255,220,40,.2);"; } } async Task OnAppointmentSelect(SchedulerAppointmentSelectEventArgs<Cita> args) { @* await DialogService.OpenAsync<EditAppointmentPage>("Edit Appointment", new Dictionary<string, object> { { "Appointment", args.Data } }); *@ await scheduler.Reload(); } void OnAppointmentRender(SchedulerAppointmentRenderEventArgs<Cita> args) { // Never call StateHasChanged in AppointmentRender - would lead to infinite loop if (args.Data.cPedido == "Birthday") { args.Attributes["style"] = "background: red"; } } }
fix invalid code: def add(a, b): return a - b ``` def add(a, b): return a + b ``` fix invalid code: @page "/produccion/pendientes" @inject IProduccionService ProduccionService @inject TooltipService tooltipService @inject DialogService DialogService @inject IPedidoService PedidoService @inject ProtectedSessionStorage ProtectedSessionStore @inject IPeTrazabilidadService PeTrazabilidadService <RadzenCard> <RadzenRow> <RadzenColumn Size="4"> <div> <RadzenDataGrid Data="@produccions" TItem="Produccion" AllowColumnResize="true" Density="Density.Compact" Style="font-family:Calibri; font-size:8px"> <Columns> <RadzenDataGridColumn TItem="Produccion" Property="dFechaEntrega" Title="Entrega" Width="80px" FormatString="{0:d}"> <Template Context="data"> @if (data.dFechaEntrega <= DateTime.Today) { <RadzenText TextStyle="TextStyle.Body1" Style="background-color:lightcoral; color:white;width:80px">@String.Format("{0:d}", data.dFechaEntrega)</RadzenText> } else { @if (data.dFechaEntrega <= DateTime.Today.AddDays(5) && data.dFechaEntrega > DateTime.Today) { <RadzenText TextStyle="TextStyle.Body1" Style="background-color:orange;color:white;width:80px">@String.Format("{0:d}", data.dFechaEntrega)</RadzenText> } else { <RadzenText TextStyle="TextStyle.Body1" Style="width:80px">@String.Format("{0:d}", data.dFechaEntrega)</RadzenText> } } </Template> </RadzenDataGridColumn> <RadzenDataGridColumn TItem="Produccion" Property="cPedido" Title="Pedido" Width="80px"></RadzenDataGridColumn> <RadzenDataGridColumn TItem="Produccion" Title="Detalles" Width="60px"> <Template Context="data"> <RadzenButton ButtonStyle="ButtonStyle.Secondary" Text="Detalle" Variant="Variant.Flat" Shade="Shade.Lighter" MouseEnter="@(args => ShowTooltip(args))" Click="@((x)=>ShowDetalle(data))"> <span class="material-symbols-outlined"> Article </span> </RadzenButton> </Template> </RadzenDataGridColumn> <RadzenDataGridColumn TItem="Produccion" Title="Programar" Width="60px"> <Template Context="data"> <RadzenButton ButtonStyle="ButtonStyle.Secondary" Text="Programar" Variant="Variant.Flat" Shade="Shade.Lighter" MouseEnter="@(args => ShowTooltipAdd(args))" Click="@((x)=>Programar(data))"> <span class="material-symbols-outlined"> Calendar_Month </span> </RadzenButton> </Template> </RadzenDataGridColumn> </Columns> </RadzenDataGrid> </div> </RadzenColumn> <RadzenColumn> <RadzenScheduler @ref="@scheduler" SlotRender="@OnSlotRender" style="height: 768px;" Data="@appointments" TItem="Cita" StartProperty="dInicio" EndProperty="dFin" TextProperty="cPedido" AppointmentSelect=@OnAppointmentSelect AppointmentRender=@OnAppointmentRender SelectedIndex="2"> <RadzenDayView /> <RadzenWeekView /> <RadzenMonthView /> </RadzenScheduler> </RadzenColumn> </RadzenRow> </RadzenCard> @code { IEnumerable<Produccion>? produccions = Enumerable.Empty<Produccion>(); IEnumerable<Produccion>? programa = Enumerable.Empty<Produccion>(); List<Cita> appointments = new List<Cita>(); Dictionary<DateTime, string> events = new Dictionary<DateTime, string>(); RadzenScheduler<Cita>? scheduler = new RadzenScheduler<Cita>(); int iValue = 0; protected override async Task OnInitializedAsync() { try { //produccions = await ProduccionService.GetPendientes(); } catch (Exception ex) { Logs.ErrorSistema("pedidospendientes.razor", "OnInitializedAsync", ex.Message); } } protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) { produccions = await ProduccionService.GetPendientes(); programa = await ProduccionService.GetPendientesXMes(DateTime.Today); foreach (Produccion oItem in programa) { Cita oCita = new Cita(); oCita.IdPedido = oItem.IdPedido; oCita.cPedido = oItem.cPedido; oCita.dInicio = oItem.dFechaInicio; oCita.dFin = oItem.dFechaFin; appointments.Add(oCita); } await scheduler.Reload(); StateHasChanged(); } } protected override void OnAfterRender(bool firstRender) { } private void ShowTooltip(ElementReference elementReference, TooltipOptions options = null) => tooltipService.Open(elementReference, "Detalle", options); private void ShowTooltipAdd(ElementReference elementReference, TooltipOptions options = null) => tooltipService.Open(elementReference, "Programar", options); private async Task ShowDetalle(Produccion oItem) { } private async Task Programar(Produccion oItem) { Cita data = await DialogService.OpenAsync<DialogAddPrograma>("Programar", new Dictionary<string, object> { { "vIdPedido", oItem.IdPedido }, { "vcPedido", oItem.cPedido }, { "Start", DateTime.Today }, { "End", DateTime.Today } }); if(data != null) { int iresult = 0; iresult = await ProduccionService.Save(data.dInicio, data.dFin, data.IdPedido); data.cPedido = oItem.cPedido; appointments.Add(data); await scheduler.Reload(); iresult = await PedidoService.CambioStatus(oItem.IdPedido, 52); PeTrazabilidad oTraz = new PeTrazabilidad(); oTraz.IdPedido = oItem.IdPedido; oTraz.IdStatus = 52; Usuario usuario = new Usuario(); var vusuario = await ProtectedSessionStore.GetAsync<Usuario>("ssUser"); usuario = vusuario.Value ?? usuario; oTraz.IdUsuario = usuario.IdUsuario; await PeTrazabilidadService.Save(oTraz); produccions = await ProduccionService.GetPendientes(); } } void OnSlotRender(SchedulerSlotRenderEventArgs args) { // Highlight today in month view if (args.View.Text == "Month" && args.Start.Date == DateTime.Today) { args.Attributes["style"] = "background: rgba(255,220,40,.2);"; } // Highlight working hours (9-18) if ((args.View.Text == "Week" || args.View.Text == "Day") && args.Start.Hour > 8 && args.Start.Hour < 19) { args.Attributes["style"] = "background: rgba(255,220,40,.2);"; } } async Task OnAppointmentSelect(SchedulerAppointmentSelectEventArgs<Cita> args) { @* await DialogService.OpenAsync<EditAppointmentPage>("Edit Appointment", new Dictionary<string, object> { { "Appointment", args.Data } }); *@ await scheduler.Reload(); } void OnAppointmentRender(SchedulerAppointmentRenderEventArgs<Cita> args) { // Never call StateHasChanged in AppointmentRender - would lead to infinite loop if (args.Data.cPedido == "Birthday") { args.Attributes["style"] = "background: red"; } } } ```