Esempio n. 1
0
        private void AddTripImageButton_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog();

            dialog.Multiselect = true;
            dialog.DefaultExt  = ".png";
            dialog.Filter      = "All Images Files (*.png;*.jpeg;*.gif;*.jpg;*.bmp;*.tiff;*.tif)|*.png;*.jpeg;*.gif;*.jpg;*.bmp;*.tiff;*.tif"
                                 + "|PNG Portable Network Graphics (*.png)|*.png"
                                 + "|JPEG File Interchange Format (*.jpg *.jpeg *jfif)|*.jpg;*.jpeg;*.jfif"
                                 + "|BMP Windows Bitmap (*.bmp)|*.bmp"
                                 + "|TIF Tagged Imaged File Format (*.tif *.tiff)|*.tif;*.tiff"
                                 + "|GIF Graphics Interchange Format (*.gif)|*.gif";
            if (true == dialog.ShowDialog())
            {
                foreach (string FileName in dialog.FileNames)
                {
                    string imageName = System.IO.Path.GetFileName(FileName);
                    string imageRP   = "Images/" + imageName;
                    string imagePath = AppDomain.CurrentDomain.BaseDirectory + imageRP;
                    var    prefix    = 0;
                    while (File.Exists(imagePath))
                    {
                        prefix   += 1;
                        imageRP   = "Images/i" + prefix + imageName;
                        imagePath = AppDomain.CurrentDomain.BaseDirectory + imageRP;
                    }
                    File.Copy(FileName, imagePath);
                    SelectedTrip.Images.Add(imageRP);
                }

                TripDAO.Update(SelectedTrip);
                ImagesListView.Items.Refresh();
            }
        }
Esempio n. 2
0
 private void AddExpenseButton_Click(object sender, RoutedEventArgs e)
 {
     if (MembersListView.SelectedIndex >= 0)
     {
         Debug.WriteLine(SelectedTrip.Members[MembersListView.SelectedIndex].ToString());
         TripExpense expense = new TripExpense();
         expense.Description = ExpenseDescriptionTextBox.Text;
         string ct   = ExpenseCostTextBox.Text.Replace(" ", string.Empty);
         double cost = 0;
         if (double.TryParse(ct, out cost) && cost > 0)
         {
             expense.Cost = cost;
             SelectedTrip.Members[MembersListView.SelectedIndex].Expenses.Add(expense);
             ExpenseDescriptionTextBox.Text = "";
             ExpenseCostTextBox.Text        = "";
             TripDAO.Update(SelectedTrip);
             ExpensesListView.Items.Refresh();
             DrawChart();
         }
         else
         {
             ShowErrorDialog("Chi phí là một số lớn hơn không    ");
         }
     }
 }
Esempio n. 3
0
        private void AddStepButton_Click(object sender, RoutedEventArgs e)
        {
            string step = StepNameTextBox.Text;

            if (!string.IsNullOrEmpty(step) && !SelectedTrip.Step.Exists(x => x.Equals(step)))
            {
                SelectedTrip.Step.Add(step);
                TripDAO.Update(SelectedTrip);
                StepNameTextBox.Text = "";
                StepListView.Items.Refresh();
            }
        }
Esempio n. 4
0
        private void AddMemberButton_Click(object sender, RoutedEventArgs e)
        {
            Member mem = new Member();

            mem.Name     = MemberNameTextBox.Text;
            mem.Expenses = new List <TripExpense>();
            if (!string.IsNullOrEmpty(mem.Name) && !SelectedTrip.Members.Exists(x => x.Name.Equals(mem.Name)))
            {
                SelectedTrip.Members.Add(mem);
                TripDAO.Update(SelectedTrip);
                MemberNameTextBox.Text = "";
                MembersListView.Items.Refresh();
                DrawChart();
            }
        }