Beispiel #1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     err.Visibility = Visibility.Hidden;
     if (com.SelectedIndex < 0 || com.SelectedIndex >= com.Items.Count ||
         com2.SelectedIndex < 0 || com2.SelectedIndex > 1 || !Int32.TryParse(txtCnt.Text, out int cnt))
     {
         err.Visibility = Visibility.Visible;
         return;
     }
     if (!parent.ChangeTicket(com.SelectedIndex, cnt))
     {
         err.Visibility = Visibility.Visible;
     }
     else
     {
         int    si = com.SelectedIndex;
         string s  = com.SelectedItem.ToString();
         for (int i = 0; i < ticket.cnt; ++i)
         {
             if (s.Contains(ticket.ticketKind[i]))
             {
                 ticket.num[i]    -= cnt;
                 com.Items[si]     = ticket.ticketKind[i] + "  " + (mode == 0 ? TryFindResource("ticket.left") as string : TryFindResource("ticket.booked") as string) + " " + (ticket.num[i]).ToString() + " " + TryFindResource("ticket.ticket") as string + "  ¥" + ticket.price[i].ToString();
                 com.SelectedIndex = si;
             }
         }
         parent.Reset();
     }
 }