void chip_ReadCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { NewGeneralICCard chip = (from p in loader.Res where p.Name.Equals("chip") select p).First() as NewGeneralICCard; chip.ReadCompleted -= chip_ReadCompleted; goPopup.SetPropertyValue("IsOccupied", "False", true); if (chip.State == State.LoadError) { goPopup.SetPropertyValue("Hint", "卡操作失败,请重试。", true); ButtonReadChip.IsEnabled = true; } else { goPopup.SetPropertyValue("Hint", "", true); goPopup.SetPropertyValue("CurGasOnCard", chip.Gas.ToString(), true); int PreGasOnCard = int.Parse(goPopup.GetPropertyValue("PreGasOnCard").ToString()); int GasPurchased = int.Parse(goPopup.GetPropertyValue("GasPurchased").ToString()); int preGasOnCard = int.Parse(goPopup.GetPropertyValue("GasAddedOn").ToString()); if (chip.Gas == PreGasOnCard + GasPurchased + preGasOnCard) { goPopup.SetPropertyValue("IsBalanced", "True", true); goPopup.SetPropertyValue("IsNotBalanced", "False", true); } else { goPopup.SetPropertyValue("IsBalanced", "False", true); goPopup.SetPropertyValue("IsNotBalanced", "True", true); } //为下次写做准备 chip.Gas = PreGasOnCard + GasPurchased + preGasOnCard; } }
//读卡 private void ReadChip(object sender, RoutedEventArgs e) { goPopup.SetPropertyValue("IsOccupied", "True", true); NewGeneralICCard chip = (from p in loader.Res where p.Name.Equals("chip") select p).First() as NewGeneralICCard; chip.ReadCompleted += chip_ReadCompleted; chip.ReadCard(); }
void chip_Completed(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { NewGeneralICCard chip = (from p in loader.Res where p.Name.Equals("chip") select p).First() as NewGeneralICCard; chip.Completed -= chip_Completed; //继续读卡 ReadChip(e, null); }
private void NewGeneralICCard_Completed(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { busy.IsBusy = true; NewGeneralICCard card = (from p in loader.Res where p.Name.Equals("card") select p).First() as NewGeneralICCard; if (card.State == State.LoadError) { //WebClientInfo wci = Application.Current.Resources["server"] as WebClientInfo; //string str = wci.BaseAddress + "returns" + f_userid.Text; //Uri uri = new Uri(str); // WebClient client = new WebClient(); // client.DownloadStringCompleted += client_DownloadStringCompleted; //client.DownloadStringAsync(uri); MessageBox.Show("写卡失败,请读卡核对水量!"); } else { print.Print(); } busy.IsBusy = false; }