Exemple #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());

            person = (Person)((ListBox)sender).SelectedItem;

            List<ActionItem> actions = context.dataLoader.GetActionItems(person);
            double sum = 0;
            foreach (var action in actions) {
                sum += action.RealValue();
            }
            Label label = new Label();
            Grid.SetColumnSpan(label, 2);
            label.Content = person + ": " + 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);
        }
Exemple #2
0
 public List<ActionItem> GetActionItems(Person person) {
     var actionItems = GetActionItems();
     List<ActionItem> personActions = new List<ActionItem>();
     foreach (var actionItem in actionItems) {
         if (actionItem.Person.Equals(person)) {
             personActions.Add(actionItem);
         }
     }
     return personActions;
 }
Exemple #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;
                }
            }

            
        }
Exemple #4
0
 public Person GetPerson(string name) {
     Person person = null;
     foreach (Person pers in Persons) {
         if (pers.Name == name) {
             person = pers;
             break;
         }
     }
     if (person == null) {
         person = new Person();
         person.Name = name;
         Persons.Add(person);
         //Save();
     }
     return person;
 }
Exemple #5
0
 public void EditPerson(Person person)
 {
     RemovePerson(person);
     AddPerson(person);
 }
Exemple #6
0
 public void RemovePerson(Person person) {
     Persons.Remove(person);
 }
Exemple #7
0
 public void AddPerson(Person person) {
     Persons.Add(person);
 }
 public EditPersonForm(Context context, Person person)
 {
     this.context = context;
     this.Person = person;
 }