Skip to content

Commit

Permalink
in retry mode, button spam-clicking is not allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
jiangyi1985 committed Aug 30, 2021
1 parent 163e57b commit 03093fd
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions JatyzxBooking/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ private async Task DoGetCourtStatus(string courtDate = null)

private async void btnCreateOrder_Click(object sender, RoutedEventArgs e)
{
//btnCreateOrder.IsEnabled = false;
int? retryDuration = chbRetry.IsChecked.Value ? Int32.Parse(txtRetryDuration.Text) : null;

if (retryDuration.HasValue)//in retry mode, button spam-clicking is not allowed
btnCreateOrder.IsEnabled = false;

try
{
Expand All @@ -161,15 +164,15 @@ private async void btnCreateOrder_Click(object sender, RoutedEventArgs e)

var court = courtList.FirstOrDefault(c => c.VenueName == cbbVenue.SelectedItem.ToString());
var startTime = timeList.FirstOrDefault(t => t.TimeStartName == cbbStartTime.Text);
int? retryDuration = chbRetry.IsChecked.Value ? Int32.Parse(txtRetryDuration.Text) : null;
await DoCreateOrder(txtCourtDate.Text.Trim(), court.SysID, startTime.StartTime, retryDuration);
}
catch (Exception exception)
{
txtLog.AppendText(exception.Message + Environment.NewLine + exception.StackTrace + Environment.NewLine);
}

//btnCreateOrder.IsEnabled = true;
if (!btnCreateOrder.IsEnabled)
btnCreateOrder.IsEnabled = true;
}

private async Task DoCreateOrder(string courtDate, string venueId, int startTime, int? retryDuration)
Expand Down

0 comments on commit 03093fd

Please sign in to comment.