@page "/add/invoice"
@code {
    @inject IInOutInvoiceDao inOutInvoiceDao;
    @inject DialogService dialogService;
    RadzenDataGrid grid;
    bool isLoading;
    int count;
    private IEnumerable? _forecasts;
    string InvoiceNo;
    DateTime InvoiceDate = DateTime.MinValue;
    void OnCurrentDateChanged(DateTime args)
    {
        InvoiceDate = new DateTime(args.Year, args.Month, args.Day);
    }
    async Task LoadData(LoadDataArgs args)
    {
        isLoading = true;
        var result = await inOutInvoiceDao.GetAllInvoiceByType(InvoiceNo, InvoiceDate, args.Top, args.Skip, 1);
        // Update the Data property
        _forecasts = result.Desserts;
        // Update the count
        count = result.TotalDesserts;
        isLoading = false;
    }
    async Task reloadGrid()
    {
        InvoiceNo = "";
        InvoiceDate = DateTime.MinValue;
        await grid.Reload();
    }
    async Task InvoiceSelected(InOutInvoice oi)
    {
        var b = await dialogService.OpenAsync(
                $"调拨入库详情",
              new Dictionary() { { "invoice", oi } },
              new DialogOptions() { Width = "85vw", Resizable = true, Draggable = true, ShowClose = false }
        );
        if (b)
        {
            await reloadGrid();
        }
    }
    
}