private async void PART_Stepper_ContinueNavigation(object sender, MaterialDesignExtensions.Controls.StepperNavigationEventArgs args) { int idx = 0; for (; idx < PART_Stepper.Controller.Steps.Length; ++idx) { if (args.CurrentStep == PART_Stepper.Controller.Steps[idx]) { break; // 确定现在在哪个Step } } if (idx == 0) { // 发送申请 ApplicationMaterialListViewModel selected = (ApplicationMaterialListViewModel)MaterialSelectListBox.SelectedItem; if (selected == null) { MainWindow.SetSnackBarContentAndPopup("请选择要申请的物资"); args.Cancel = true; return; } else if (QuantityInputBox.Value == null || QuantityInputBox.Value <= 0) { MainWindow.SetSnackBarContentAndPopup("不合法的数目"); args.Cancel = true; return; } else if (QuantityInputBox.Value > selected.Constraint) { MainWindow.SetSnackBarContentAndPopup("超出数量限制"); args.Cancel = true; return; } NewApplicationResponse response = await NetworkHelper.GetAsync(new NewApplicationRequest() { MaterialId = selected.OriginItem.Id, Quantity = (int)QuantityInputBox.Value, Address = UserInfo.HomeAddress }).Progress(ParentWindow.PART_ProgressBar); ApplicationViewModel = new ApplicationListViewModel(response.Item); ApplicationDetailViewModel = new ApplicationDetailViewModel(await NetworkHelper.GetAsync(new GetApplicationDetailRequest() { ApplicationId = ApplicationViewModel.OriginalItem.ID }).Progress(ParentWindow.PART_ProgressBar)); RefreshApplicationCardView(); } else if (idx == 3) { // 确认 await NetworkHelper.GetAsync(new ConfirmApplicationDoneRequest() { ApplicationId = ApplicationViewModel.OriginalItem.ID }); } }
private void MaterialSelectListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { ApplicationMaterialListViewModel selected = (ApplicationMaterialListViewModel)MaterialSelectListBox.SelectedItem; if (selected != null) { MaterialNameTextBlock.Text = selected.Name; QuantityInputBox.QuantityConstraintHint = $"限量{selected.Constraint}"; MaterialDetailTextBlock.Text = selected.Description; } else { MaterialNameTextBlock.Text = "请选择想要申请的物资"; } }