/// <summary> /// 提交更改,api取决于Tag /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void SubmitButton_Click(object sender, RoutedEventArgs e) { SubmitProgressRing.IsActive = true; SubmitButton.IsEnabled = false; bool result = (string)this.Tag == "Add" ? await api.AddFinance(Finance) : await api.UpdateFinance(Finance.Id, Finance); SubmitProgressRing.IsActive = false; SubmitButton.IsEnabled = true; if (result) { await new ContentDialog { Title = ResourceLoader.GetString((string)this.Tag == "Add" ? "AddFinanceSuccessDialog_Title" : "UpdateFinanceSuccessDialog_Title"), PrimaryButtonText = ResourceLoader.GetString((string)this.Tag == "Add" ? "AddFinanceSuccessDialog_PrimaryButtonText" : "UpdateFinanceSuccessDialog_PrimaryButtonText"), //DefaultButton = ContentDialogButton.Primary }.ShowAsync(); OnSubmitedSuccess?.Invoke(true); // 调用委托,更新页面 } else { await new ContentDialog { Title = ResourceLoader.GetString((string)this.Tag == "Add" ? "AddFinanceFailDialog_Title" : "UpdateFinanceFailDialog_Title"), Content = ResourceLoader.GetString((string)this.Tag == "Add" ? "AddFinanceFailDialog_Content" : "UpdateFinanceFailDialog_Content"), PrimaryButtonText = ResourceLoader.GetString((string)this.Tag == "Add" ? "AddFinanceFailDialog_PrimaryButtonText" : "UpdateFinanceFailDialog_PrimaryButtonText"), //DefaultButton = ContentDialogButton.Primary }.ShowAsync(); } }
/// <summary> /// <see cref="DeleteButton"/>被点击,进入删除操作。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void DeleteButton_Click(object sender, RoutedEventArgs e) { var confirmResult = await new ContentDialog { Title = ResourceLoader.GetString("DeleteFinanceDialog_Title"), Content = String.Format(ResourceLoader.GetString("DeleteFinanceDialog_Content"), Finance.Event), PrimaryButtonText = ResourceLoader.GetString("DeleteFinanceDialog_PrimaryButtonText"), SecondaryButtonText = ResourceLoader.GetString("DeleteFinanceDialog_SecondaryButtonText"), //DefaultButton = ContentDialogButton.Primary }.ShowAsync(); if (confirmResult == ContentDialogResult.Primary) { var result = await api.DeleteFinance(Finance); if (result) { await new ContentDialog { Title = ResourceLoader.GetString("DeleteFinanceSuccessDialog_Title"), PrimaryButtonText = ResourceLoader.GetString("DeleteFinanceSuccessDialog_PrimaryButtonText"), //DefaultButton = ContentDialogButton.Primary }.ShowAsync(); OnSubmitedSuccess?.Invoke(true); // 调用委托,更新页面 } else { await new ContentDialog { Title = ResourceLoader.GetString("DeleteFinanceFailDialog_Title"), Content = ResourceLoader.GetString("DeleteFinanceFailDialog_Content"), PrimaryButtonText = ResourceLoader.GetString("DeleteFinanceFailDialog_PrimaryButtonText"), //DefaultButton = ContentDialogButton.Primary }.ShowAsync(); } } }
/// <summary> /// 子控件事件沿父链上传 /// </summary> /// <param name="result"></param> private void ChildEventPostUp(bool result) { OnSubmitedSuccess?.Invoke(true); }