@page "/brmaintenance/invtycorrection" @using KWWebInvApp.Data; @inject IDialogService DialogService; @inject UserServices userService; Branch Inventory Correction Branch Inventory Correction Select a specific branch and select the table to edit from the grid. Get Record @if (branchItemLedger != null && branchItemLedger.modelno != null) { Inventory details of @selectedBranch branch @branchItemLedger.itemcode @branchItemLedger.remarks @newRemarks Remarks above is the existing value of remarks on particular item while New Remarks is the remarks that will be added to Remarks after changes had been saved. Edit the details below Update Record Reset } else { No Record to Show } @code { BranchServices.branch[]? branchList; string? selectedBranch, modelNo, newRemarks; BranchItemLedgerServices.branchitemledger? branchItemLedger = null; bool disableStatusGetRecord = false, disableStatusSave = true; BranchServices.BranchServiceClient branchServiceClient = new(); ItemServices.ItemServiceClient itemServiceClient = new(); BranchItemLedgerServices.BranchItemLedgerServiceClient branchItemLedgerServiceClient = new(); protected override async Task OnInitializedAsync() { branchList = await branchServiceClient.GetDataAsync(); } async Task> SearchBranch(string value) { await Task.Delay(1); if (string.IsNullOrEmpty(value)) return branchList.Select(c=>c.brCode); return branchList.Where(c => c.brCode.Contains(value, StringComparison.InvariantCultureIgnoreCase)).Select(c=>c.brCode); } async Task GetRecord() { if(string.IsNullOrEmpty(selectedBranch)) { var dialogParam = new DialogParameters(); dialogParam.Add("ContentText", "No branch. Please enter in the Branch field."); dialogParam.Add("ButtonText", "OK"); dialogParam.Add("Color", Color.Error); DialogService.Show("No Branch", dialogParam); return; } if (string.IsNullOrEmpty(modelNo)) { var dialogParam = new DialogParameters(); dialogParam.Add("ContentText", "No model number. Please enter in the Model Number field"); dialogParam.Add("ButtonText", "OK"); dialogParam.Add("Color", Color.Error); DialogService.Show("No Mode Number", dialogParam); return; } disableStatusGetRecord = true; disableStatusSave = true; branchItemLedger = await branchItemLedgerServiceClient.GetRemoteDataByBrCodeModelnoAsync(selectedBranch, modelNo); newRemarks = $"Manually edit by {userService?.CurrentUser?.fullName}. {DateTime.Now:MM/dd/yyyy hh:mm:sstt}"; disableStatusGetRecord = false; disableStatusSave = false; } async Task SaveBranchItemLedger() { if (branchItemLedger == null) return; disableStatusGetRecord = true; disableStatusSave = true; branchItemLedger.remarks = $"|Manually edit by {userService?.CurrentUser?.fullName}. {DateTime.Now:MM/dd/yyyy hh:mm:sstt} [{branchItemLedger.beginningqty} {branchItemLedger.inqty} {branchItemLedger.outqty} {branchItemLedger.sales} {branchItemLedger.adjustment} {branchItemLedger.endingqty}]"; int result = await branchItemLedgerServiceClient.UpdateRemoteBranchItemLedgerAsync(branchItemLedger); if(result > 0) { var dialogParam = new DialogParameters(); dialogParam.Add("ContentText", "Successfully updated the record"); dialogParam.Add("ButtonText", "OK"); dialogParam.Add("Color", Color.Info); DialogService.Show("Success", dialogParam); await ResetUpdateBranchItemLedger(); } else { var dialogParam = new DialogParameters(); dialogParam.Add("ContentText", "Failed to update the record"); dialogParam.Add("ButtonText", "OK"); dialogParam.Add("Color", Color.Error); DialogService.Show("Failed", dialogParam); disableStatusGetRecord = false; disableStatusSave = false; } } async Task ResetUpdateBranchItemLedger() { await Task.Delay(1); disableStatusGetRecord = false; disableStatusSave = true; branchItemLedger = null; } }