public void AddReduceItem()
        {
            if (selectedReduce != null)
            {
                Journal newJournal = new Journal()
                {
                    Amount = 1,
                    Discount = 0,
                    ID_Partner = selectedReduce.ID_Partner,
                    Partner = selectedReduce,
                    User = User.CurrentUser,
                    ID_User = User.CurrentUser.ID_User,
                    Price = 0,
                    SaleDate = CurrentDate
                };

                JournalItemView view = new JournalItemView();
                view.DataContext = new JournalItemViewModel() { Item = newJournal };
                if (view.ShowDialog() == true)
                {
                    using (DbManager db = new DbManager())
                    {
                        db.BeginTransaction();
                        try
                        {
                            //inser new journal item
                            SqlQuery<Journal> query = new SqlQuery<Journal>(db);
                            query.Insert(newJournal);
                            db.CommitTransaction();
                        }
                        catch
                        {
                            db.RollbackTransaction();
                            throw;
                        }

                    }
                    PropertyChange("JournalList");
                    PropertyChange("DaySum");
                    PropertyChange("InKasaSum");

                }
            }
        }
        public void AddJournalItem()
        {
            if (!CanAddItem)
                return;
            FindWindow findWindow = new FindWindow();
            FindViewModel viewModel = new FindViewModel();
            //viewModel.SelectedTovar = viewModel.TovarList[0];
            findWindow.DataContext = viewModel;
            if (findWindow.ShowDialog() == true)
            {
                if (viewModel.SelectedTovar != null)
                {
                    Journal newJournal = new Journal()
                    {
                        Amount = 1,
                        Discount = 0,
                        ID_Tovar = viewModel.SelectedTovar.ID_Tovar,
                        Tovar = viewModel.SelectedTovar,
                        User = User.CurrentUser,
                        ID_User = User.CurrentUser.ID_User,
                        Price = viewModel.SelectedTovar.CinaProdazh,
                        SaleDate = CurrentDate
                    };
                    JournalItemView view = new JournalItemView();
                    view.DataContext = new JournalItemViewModel() { Item = newJournal };
                    if (view.ShowDialog() == true)
                    {
                        using (DbManager db = new DbManager())
                        {
                            db.BeginTransaction();
                            try
                            {
                                //inser new journal item
                                SqlQuery<Journal> query = new SqlQuery<Journal>(db);
                                query.Insert(newJournal);

                                if (!newJournal.IsRent) // if it's rent - reduce amount is not needed
                                {
                                    //reduce ostatok in tovar
                                    newJournal.Tovar.Ostatok -= (int) newJournal.Amount;
                                    SqlQuery<Tovar> query2 = new SqlQuery<Tovar>(db);
                                    query2.Update(newJournal.Tovar);
                                }
                                db.CommitTransaction();
                            }
                            catch {
                                db.RollbackTransaction();
                                throw;
                            }

                        }
                        PropertyChange("JournalList");
                        PropertyChange("DaySum");
                        PropertyChange("InKasaSum");

                    }
                }

            }
        }