private void ReturnListDataGrid_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { ReturnListItem rli = ReturnListDataGrid.SelectedItem as ReturnListItem; if (rli != null) { SelectNumWindow snw = new SelectNumWindow(rli); snw.rw = this; snw.ShowDialog(); } }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { BindingGroup bindingGroup = (BindingGroup)value; ReturnListItem eli = (ReturnListItem)bindingGroup.Items[0]; int reamin = eli.Remain; int num = eli.Num; if (num < 0) { return(new ValidationResult(false, "输入的数字不合法")); } if (num > reamin) { return(new ValidationResult(false, "归还数量超过租赁数量")); } else { return(new ValidationResult(true, null)); } }
private void Button_Click(object sender, RoutedEventArgs e) { lrlis = new List <ReturnListItem>(); using (var context = new EMDBEntities()) { List <Record> lrs = new List <Record>(); string card = CardPhoneTextBox.Text.Trim(); double totalMoney = 0; if (Combobox1.SelectedIndex == 1) { lrs = context.Records.Where(m => m.Card == "NO." + card).Where(m => m.Finish == 0).ToList(); } else { lrs = context.Records.Where(m => m.Phone == "Phone." + card).Where(m => m.Finish == 0).ToList(); } foreach (var item in lrs) { ReturnListItem rli = new ReturnListItem(); rli.id = item.Id; rli.IsReturn = true; rli.dateTime = Convert.ToDateTime(item.Start); rli.time = Convert.ToInt32((DateTime.Now - rli.dateTime).TotalMinutes); rli.name = item.Equipment.Name; rli.Remain = item.LendNum; rli.Num = item.LendNum; rli.Equipment = item.Equipment; // 计算钱数 rli.Money = rli.GetTotal(); totalMoney += rli.Money; lrlis.Add(rli); } ReturnListDataGrid.DataContext = lrlis; TotalMoneyTextBlock.Text = totalMoney.ToString(); if (lrlis.Count == 0) { MessageBox.Show("没有检测到租赁记录"); } } }