Example #1
0
        public static void SetDocumentExpenseForNutrition(Document document)
        {
            try
            {
                using (KindergartenContext db = new KindergartenContext())
                {
                    db.Documents.Add(document);
                    db.SaveChanges();

                    PartyModel.DecreaseParty(document.DocumentDatas);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка! " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #2
0
        public static void SetDocumentFromInvoice(Document document, List <Party> parties)
        {
            try
            {
                using (KindergartenContext db = new KindergartenContext())
                {
                    db.Entry(document).State = document.Id == 0 ? EntityState.Added : EntityState.Modified;
                    db.SaveChanges();

                    parties.ForEach(x =>
                    {
                        x.DocumentId = db.Documents.Local.First().Id;
                    });

                    PartyModel.SetPartyFromInvoice(parties);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка! " + ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }