Ejemplo n.º 1
0
        private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            infoBox.Children.Clear();
            infoBox.RowDefinitions.Clear();
            infoBox.ColumnDefinitions.Clear();
            infoBox.ColumnDefinitions.Add(new ColumnDefinition());
            infoBox.ColumnDefinitions.Add(new ColumnDefinition());
            RowDefinition row = new RowDefinition();
            row.Height = new GridLength(30);
            infoBox.RowDefinitions.Add(row);
            row = new RowDefinition();
            row.Height = new GridLength(30);
            infoBox.RowDefinitions.Add(row);
            infoBox.RowDefinitions.Add(new RowDefinition());

            place = (Place)((ListBox)sender).SelectedItem;

            List<ActionItem> actions = context.dataLoader.GetActionItems(place);
            double sum = 0;
            foreach (var action in actions)
            {
                sum += action.RealValue();
            }
            Label label = new Label();
            Grid.SetColumnSpan(label, 2);
            label.Content = place + ": " + sum + " " + ActionItem.CZK;
            label.FontSize = 15;
            label.FontWeight = FontWeights.Bold;
            infoBox.Children.Add(label);

            ListBox actionsBox = new ListBox();
            Grid.SetColumnSpan(actionsBox, 2);
            actions.Sort(CompareByDate);
            actionsBox.ItemsSource = actions;
            Grid.SetRow(actionsBox, 2);
            infoBox.Children.Add(actionsBox);

            Button edit = new Button();
            edit.Content = "Editovat";
            edit.Click += edit_Click;
            Grid.SetRow(edit, 1);
            infoBox.Children.Add(edit);

            Button delete = new Button();
            delete.Content = "Smazat";
            delete.Click += delete_Click;
            Grid.SetRow(delete, 1);
            Grid.SetColumn(delete, 1);
            infoBox.Children.Add(delete);
        }
Ejemplo n.º 2
0
 public List<ActionItem> GetActionItems(Place place)
 {
     var actionItems = GetActionItems();
     List<ActionItem> placeActions = new List<ActionItem>();
     foreach (var actionItem in actionItems)
     {
         if (actionItem.Place.Equals(place))
         {
             placeActions.Add(actionItem);
         }
     }
     return placeActions;
 }
Ejemplo n.º 3
0
        public void Load() {
            XDocument doc = XDocument.Load(DATA_FILE);
            // @todo pozor na double tecku v longitude apod.
            InitData();

            XElement elPersons = doc.Root.Element("Persons");
            foreach (XElement elPerson in elPersons.Elements("Person")) {
                Person person = new Person();
                person.SetXElement(elPerson);
                Persons.Add(person);
            }

            XElement elPlaces = doc.Root.Element("Places");
            foreach (XElement elPlace in elPlaces.Elements("Place"))
            {
                Place place = new Place();
                place.SetXElement(elPlace);
                Places.Add(place);
            }

            XElement elActionItems = doc.Root.Element("ActionItems");
            foreach (XElement elActionItem in elActionItems.Elements("ActionItem")) {
                switch (elActionItem.Element("Type").Value) {
                    case "debt":
                        Debt debt = new Debt();
                        debt.SetXElement(elActionItem, this);
                        Debts.Add(debt);
                        break;
                    case "income":
                        Income income = new Income();
                        income.SetXElement(elActionItem, this);
                        Incomes.Add(income);
                        break;
                    case "loan":
                        Loan loan = new Loan();
                        loan.SetXElement(elActionItem, this);
                        Loans.Add(loan);
                        break;
                    case "payment":
                        Payment payment = new Payment();
                        payment.SetXElement(elActionItem, this);
                        Payments.Add(payment);
                        break;
                    case "withdraw":
                        Withdraw withdraw = new Withdraw();
                        withdraw.SetXElement(elActionItem, this);
                        Withdraws.Add(withdraw);
                        break;
                }
            }

            
        }
Ejemplo n.º 4
0
 public Place GetPlace(string name) {
     Place place = null;
     foreach (Place plac in Places)
     {
         if (plac.Name == name)
         {
             place = plac;
             break;
         }
     }
     if (place == null)
     {
         place = new Place();
         place.Name = name;
         Places.Add(place);
         //Save();
     }
     return place;
 }
Ejemplo n.º 5
0
 public void EditPlace(Place place) {
     RemovePlace(place);
     AddPlace(place);
 }
Ejemplo n.º 6
0
 public void RemovePlace(Place place)
 {
     Places.Remove(place);
 }
Ejemplo n.º 7
0
 public void AddPlace(Place place) {
     Places.Add(place);
 }
Ejemplo n.º 8
0
 public EditPlaceForm(Context context, Place place) {
     this.context = context;
     this.Place = place;
 }