private void Button_Click(object sender, RoutedEventArgs e) { Class.ClassSync.Stat.StatNationPopup sn = new Class.ClassSync.Stat.StatNationPopup(); string Name = xNameNation.Text; string QTY = xQTY.Text; if (Name.Length == 0) { new Class.ClassFunctuon().showMessageTime("Пустое знаение "); } else { if (SNP.Find(l => l.NameNation == Name) != null) { new Class.ClassFunctuon().showMessageTime("Такое имя сущ-ет "); } else { int qty = 0; if (int.TryParse(QTY, out qty)) { sn.IdCustomer = Guid.NewGuid(); sn.NameNation = Name; sn.QTY = qty; Class.ClassSync.Stat.StatNationPopup.ins(sn); SNP.Add(sn); CollectionViewSource.GetDefaultView((this.Owner as W_Grid).dataGrid.ItemsSource).Refresh(); foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(W_Stat)) { W_Stat w = (window as W_Stat); w.reload(); } } this.Close(); } else { new Class.ClassFunctuon().showMessageTime("Неверое значние поля QTY "); } } } }
private void Ok_Click(object sender, RoutedEventArgs e) { string sia = (string)xNation.SelectedItem; string namea = sia.Substring(0, sia.IndexOf("..") - 1); Class.ClassSync.Stat.StatNationPopup fa = A.Find(l => l.NameNation == namea); if (fa != null) { fa.QTY += 1; Class.ClassSync.Stat.StatNationPopup.mod(fa); } string sib = (string)xPlaceArround.SelectedItem; string nameb = sib.Substring(0, sib.IndexOf("..") - 1); Class.ClassSync.Stat.StatPlaceArrond fb = B.Find(l => l.NamePlaceArrond == nameb); if (fb != null) { fb.QTY += 1; Class.ClassSync.Stat.StatPlaceArrond.mod(fb); } Class.ClassSync.Stat.StatNation sn = new Class.ClassSync.Stat.StatNation(); sn.CustomerId = Guid.NewGuid(); sn.Date = DateTime.Now; sn.IdArrond = fb != null ? fb.IdCustomer : Guid.Empty; sn.IdNation = fa != null? fa.IdCustomer : Guid.Empty; sn.IdCaisse = Class.ClassGlobalVar.CustumerId; Class.ClassSync.Stat.StatNation.ins(sn); this.Close(); }