Exemplo n.º 1
0
        private void deleteButton_Click(object sender, RoutedEventArgs e)
        {
            int index = Global.data.journeys.IndexOf(currentJourney);

            Global.data.journeys.Remove(currentJourney);

            NotificationScreen notificationScreen = new NotificationScreen(3);

            notificationScreen.Owner = Window.GetWindow(this);
            notificationScreen.Show();

            commandExecutionHandler?.Invoke(3, saveID);
        }
Exemplo n.º 2
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.notificationScreen = ((WeSplit.NotificationScreen)(target));

            #line 19 "..\..\NotificationScreen.xaml"
                this.notificationScreen.Loaded += new System.Windows.RoutedEventHandler(this.notificationScreen_Loaded);

            #line default
            #line hidden
                return;

            case 2:
                this.textBlock = ((System.Windows.Controls.TextBlock)(target));
                return;
            }
            this._contentLoaded = true;
        }
        private void saveButton_Click(object sender, RoutedEventArgs e)
        {
            newJourney         = new Journey();
            newJourney.members = new List <Member>();

            newJourney.id = currentJourney.id;
            if (string.IsNullOrEmpty(journeyNameBox.Text) || string.IsNullOrWhiteSpace(journeyNameBox.Text))
            {
                journeyNameBox.Text = "(Chưa cập nhật)";
            }
            newJourney.journeyName = journeyNameBox.Text;

            if (string.IsNullOrEmpty(placeBox.Text) || string.IsNullOrWhiteSpace(placeBox.Text))
            {
                placeBox.Text = "(Chưa cập nhật)";
            }
            newJourney.place = placeBox.Text;

            newJourney.stage = stageBox.SelectedIndex;

            newJourney.images = createRelativePaths(imageAbsolutePaths);
            copyImages(imageAbsolutePaths);

            for (int i = 0; i < membersPanel.Children.Count; i++)
            {
                Member member = new Member();
                member.expenses = new List <Expense>();

                StackPanel panel1 = membersPanel.Children[i] as StackPanel;
                StackPanel panel2 = panel1.Children[0] as StackPanel;
                StackPanel panel3 = panel1.Children[1] as StackPanel;
                StackPanel panel4 = panel3.Children[0] as StackPanel;
                TextBox    box1   = panel2.Children[1] as TextBox;

                if (string.IsNullOrEmpty(box1.Text) || string.IsNullOrWhiteSpace(box1.Text))
                {
                    box1.Text = "(Chưa cập nhật)";
                }
                member.memberName = box1.Text;

                for (int j = 0; j < panel4.Children.Count; j++)
                {
                    StackPanel panel5 = panel4.Children[j] as StackPanel;
                    StackPanel panel6 = panel5.Children[0] as StackPanel;
                    StackPanel panel7 = panel5.Children[1] as StackPanel;
                    TextBox    box2   = panel6.Children[1] as TextBox;
                    TextBox    box3   = panel7.Children[1] as TextBox;

                    if (string.IsNullOrEmpty(box2.Text) || string.IsNullOrWhiteSpace(box2.Text))
                    {
                        box2.Text = "(Chưa cập nhật)";
                    }

                    if (string.IsNullOrEmpty(box3.Text) || string.IsNullOrWhiteSpace(box3.Text))
                    {
                        box3.Text = "0";
                    }
                    member.expenses.Add(new Expense {
                        spendingName = box2.Text, cost = int.Parse(box3.Text)
                    });
                }

                newJourney.members.Add(member);
            }

            if (saveCommand == 0)
            {
                newJourney.id = searchValidID();
                saveID        = newJourney.id;
                Global.data.journeys.Add(newJourney);
            }

            else if (saveCommand == 1)
            {
                int index = Global.data.journeys.IndexOf(currentJourney);
                Global.data.journeys[index] = newJourney;
            }

            NotificationScreen notificationScreen = new NotificationScreen(saveCommand);

            notificationScreen.Owner = Window.GetWindow(this);
            notificationScreen.Show();

            commandExecutionHandler?.Invoke(4, saveID);
        }