private void cbCheckGiftSert_Click(object sender, RoutedEventArgs e) { double itog = 0; foreach (var item in db.ZakaznBludaNew) { if (item.IdZakaza == idNewZakaz) { itog += (double)item.Price; } } //itog=itog-(itog*()) Доделать использование скидочных карт и подарочных сертификатов как однвременно так и по отдельности и при выборе товара //itog = itog - (itog - (double)((GiftSertificate)cbGiftSertificate.SelectedItem).Nominal); lblItog.Content = itog; if (cbCheckSaleCart.IsChecked == true && cbSaleCart.SelectedItem != null) { SaleCarts saleCart = (SaleCarts)cbSaleCart.SelectedItem; double nominal = int.Parse(saleCart.Nominal); itog = itog - (itog * (nominal / 100)); lblItog.Content = itog.ToString(); } if (cbChekGiftSertificate.IsChecked == true && cbGiftSertificate.SelectedItem != null) { GiftSertificate giftSertificate = (GiftSertificate)cbGiftSertificate.SelectedItem; int nominal = (int)giftSertificate.Nominal; itog = itog - nominal; lblItog.Content = itog.ToString(); } }
private void btnDelete_Click(object sender, RoutedEventArgs e) { if (dgGiftSertificate.SelectedItem != null) { GiftSertificate giftSertificate = (GiftSertificate)dgGiftSertificate.SelectedItem; if (MessageBox.Show("Вы точно хотите удалить?", "Внимание", MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes) { db.GiftSertificate.Remove(giftSertificate); db.SaveChanges(); } var query = from item in db.GiftSertificate select item; dgGiftSertificate.ItemsSource = query.ToList(); } }
private void btnCreateGiftSertificate_Click(object sender, RoutedEventArgs e) { try { GiftSertificate giftSertificate = new GiftSertificate(); giftSertificate.Date = DateTime.Now; string number = "AA-000"; int GS = db.GiftSertificate.LastOrDefault().Id; giftSertificate.Number = number + GS; giftSertificate.Nominal = int.Parse(txtNominal.Text); db.GiftSertificate.Add(giftSertificate); db.SaveChanges(); Close(); } catch { } }