public StepTwoControl()
 {
     InitializeComponent();
     //LocationListComboBox.ItemsSource = HomeScreen.GetDatabaseEntities().LOCATIONS.ToList();
     CostIncurredListComboBox.ItemsSource = HomeScreen.GetDatabaseEntities().COSTINCURREDS.ToList();
     this.DataContext = AddNewTripViewModel.Instance;
 }
Exemplo n.º 2
0
        private void ReturnDatePickerClosingEventHandler(object sender, DialogClosingEventArgs eventArgs)
        {
            if (eventArgs.Parameter is bool parameter &&
                parameter == false)
            {
                return;
            }

            //OK, lets cancel the close...
            eventArgs.Cancel();

            //...now, lets update the "session" with some new content!
            eventArgs.Session.UpdateContent(new SampleProgressDialog());
            //note, you can also grab the session when the dialog opens via the DialogOpenedEventHandler

            //lets run a fake operation for 3 seconds then close this baby.
            Task.Delay(TimeSpan.FromSeconds(3))
            .ContinueWith((t, _) => eventArgs.Session.Close(false), null,
                          TaskScheduler.FromCurrentSynchronizationContext());

            var isValid = this.ReturnDatePickerViewModel.SelectedDate >= this.SelectedTrip.TOGODATE;

            if (isValid)
            {
                var db            = HomeScreen.GetDatabaseEntities();
                var trip          = db.TRIPS.Find(this.SelectedTrip.TRIP_ID);
                var newReturnDate = this.ReturnDatePickerViewModel.SelectedDate;
                trip.TOGODATE = newReturnDate;
                db.SaveChanges();
            }
            else
            {
                MessageBox.Show("Ngày về không hợp lệ");
            }
        }
        public static bool isAddOk()
        {
            bool ageOk = AddNewTripViewModel.Instance.AddTrip.TRIP_MEMBER.Count != 0;

            if (ageOk)
            {
                TRIP temp = AddNewTripViewModel.Instance.AddTrip;
                temp.ISDONE = temp.RETURNDATE < DateTime.Now;
                temp.TITTLE = temp.TITTLE.Trim();
                HomeScreen.GetDatabaseEntities().TRIPS.Add(temp);
                HomeScreen.GetDatabaseEntities().SaveChanges();
                if ((bool)temp.ISDONE)
                {
                    HaveTakenTripsListViewModel.Instance.AddTrip(temp);
                }
                else
                {
                    BeingTakenTripsListViewModel.Instance.AddTrip(temp);
                }
                SettingsViewModel.Instance.UpdateTripSortMethod();
                MessageBox.Show("Thêm thành công");
            }
            else
            {
                MessageBox.Show("Nhập thiếu trường dữ liệu");
            }
            return(ageOk);
        }
Exemplo n.º 4
0
        private void ExecuteAddNewImageDialog(object obj)
        {
            var fileDialog = new OpenFileDialog
            {
                Filter = "Images (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|" +
                         "All files (*.*)|*.*",

                Multiselect = true,
                Title       = "My Image Browser"
            };

            DialogResult dr = fileDialog.ShowDialog();

            if (dr == DialogResult.OK)
            {
                var result = new List <string>();

                foreach (string file in fileDialog.FileNames)
                {
                    try
                    {
                        result.Add(file);
                    }
                    catch (SecurityException ex)
                    {
                        MessageBox.Show("Security error. Please contact your administrator for details.\n\n" +
                                        "Error message: " + ex.Message + "\n\n" +
                                        "Details (send to Support):\n\n" + ex.StackTrace
                                        );
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Cannot display the image: " + file.Substring(file.LastIndexOf('\\'))
                                        + ". You may not have permission to read the file, or " +
                                        "it may be corrupt.\n\nReported error: " + ex.Message);
                    }
                }
                if (result != null)
                {
                    var db = HomeScreen.GetDatabaseEntities();

                    result.ForEach(file => {
                        if (file.Contains(AppDomain.CurrentDomain.BaseDirectory))
                        {
                            file = "\\" + file.Remove(0, AppDomain.CurrentDomain.BaseDirectory.Length);
                        }
                        var newTripImages = new TRIP_IMAGES
                        {
                            TRIP_ID = this.SelectedTrip.TRIP_ID,
                            IMAGE   = file
                        };
                        //this.SelectedTrip.TRIP_IMAGES.Add(newTripImages);
                        db.TRIP_IMAGES.Add(newTripImages);
                    });

                    db.SaveChanges();
                }
            }
        }
 public AddNewTripViewModel() : base()
 {
     AddTrip                 = new TRIP();
     AddTrip.TOTALCOSTS      = 0;
     AddTrip.CURRENTPROCEEDS = 0;
     MEMBERs                 = new ObservableCollection <MEMBER>(HomeScreen.GetDatabaseEntities().MEMBERS.ToList());
     LOCATIONs               = new ObservableCollection <LOCATION>(HomeScreen.GetDatabaseEntities().LOCATIONS.ToList());
     Instance                = this;
 }
Exemplo n.º 6
0
        private void CancelDescriptionAction()
        {
            var db   = HomeScreen.GetDatabaseEntities();
            var trip = db.TRIPS.Find(this.SelectedTrip.TRIP_ID);

            db.Entry(trip).Reload();

            ChangeEditingDescriptionVisibility();
        }
Exemplo n.º 7
0
        private void SaveDescriptionAction()
        {
            var db   = HomeScreen.GetDatabaseEntities();
            var trip = db.TRIPS.Find(this.SelectedTrip.TRIP_ID);

            trip.DESCRIPTION = this.SelectedTrip.DESCRIPTION;
            db.SaveChanges();

            ChangeEditingDescriptionVisibility();
        }
Exemplo n.º 8
0
        private void SaveTitleAction()
        {
            var db   = HomeScreen.GetDatabaseEntities();
            var trip = db.TRIPS.Find(this.SelectedTrip.TRIP_ID);

            trip.TITTLE = this.SelectedTrip.TITTLE;
            db.SaveChanges();

            ChangeEditingTitleVisibility();
        }
Exemplo n.º 9
0
        private LocationListViewModel()
        {
            MySort = new Dictionary <string, Delegate> {
                { "Mặc định", new Func <List <LOCATION> >(SetDefaultPosition) },
                { "Tên tăng dần", new Func <List <LOCATION> >(SetAscendingPositionAccordingToName) },
                { "Tên giảm đần", new Func <List <LOCATION> >(SetDescendingPositionAccordingToName) }
            };

            this.LOCATIONS       = new ObservableCollection <LOCATION>(HomeScreen.GetDatabaseEntities().LOCATIONS.ToList());
            this.searchLOCATIONS = this.LOCATIONS;
        }
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            int locationId = Convert.ToInt32((sender as Button).Tag);

            if (locationId != 0)
            {
                LOCATION reloadLocation = HomeScreen.GetDatabaseEntities().LOCATIONS.FirstOrDefault(item => item.LOCATION_ID == locationId);
                HomeScreen.GetDatabaseEntities().Entry(reloadLocation).Reload();
                LocationListControl.updateUI();
            }
        }
Exemplo n.º 11
0
        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            int memberId = Convert.ToInt32((sender as Button).Tag);

            if (memberId != 0)
            {
                MEMBER reloadMember = HomeScreen.GetDatabaseEntities().MEMBERS.FirstOrDefault(item => item.MEMBER_ID == memberId);
                HomeScreen.GetDatabaseEntities().Entry(reloadMember).Reload();
                MemberListControl.updateMemberList();
            }
        }
Exemplo n.º 12
0
        private void CancelTitleAction()
        {
            var db   = HomeScreen.GetDatabaseEntities();
            var trip = db.TRIPS.Find(this.SelectedTrip.TRIP_ID);

            db.Entry(trip).Reload();
            ChangeEditingTitleVisibility();

            /*trip.TITTLE = this._clonedTrip.TITTLE;
             * db.SaveChanges();*/
            //this.SelectedTrip.TITTLE = this._clonedTrip.TITTLE;
        }
Exemplo n.º 13
0
        public override void YesCommandAction()
        {
            if (!string.IsNullOrEmpty(NewMember.NAME) &&
                !string.IsNullOrEmpty(NewMember.PHONENUMBER) &&
                !string.IsNullOrEmpty(NewMember.AVATAR))
            {
                if (NewMember.GENDER == null)
                {
                    NewMember.GENDER = false;
                }
                NewMember.NAME = NewMember.NAME.Trim();
                if (type == "add")
                {
                    HomeScreen.GetDatabaseEntities().MEMBERS.Add(NewMember);

                    // trường hợp đang làm trong màn hình AddTrip <=> refresh list Members
                    if (AddNewTripViewModel.Instance != null)
                    {
                        AddNewTripViewModel.Instance.MEMBERs.Add(NewMember);
                    }
                    //trường hợp đang làm trong màn hình MemberList <=> refresh list Members
                    MemberListViewModel.Instance.updateList(NewMember);
                    SettingsViewModel.Instance.UpdateMemberMaxPaging();
                }
                else
                {
                    MEMBER member = HomeScreen.GetDatabaseEntities().MEMBERS.First(item => item.MEMBER_ID == NewMember.MEMBER_ID);
                    member = NewMember;
                }
                HomeScreen.GetDatabaseEntities().SaveChanges();
                SettingsViewModel.Instance.UpdateMemberSortMethod(); // gọi lại hàm sort cho Items, bao gồm search lại nếu có
                MessageBox.Show("Thành công");
            }
            else
            {
                MessageBox.Show("Điền thiếu dữ liệu !");
            }
        }
        public override void YesCommandAction()
        {
            if (!string.IsNullOrEmpty(NewLocation.NAME) &&
                !string.IsNullOrEmpty(NewLocation.ADDRESS) &&
                !string.IsNullOrEmpty(NewLocation.DESCRIPTION))
            {
                if (NewLocation.TYPE == null)
                {
                    NewLocation.TYPE = false;
                }
                NewLocation.NAME = NewLocation.NAME.Trim();
                if (type == "add")
                {
                    HomeScreen.GetDatabaseEntities().LOCATIONS.Add(NewLocation);

                    // trường hợp đang làm trong màn hình AddTrip <=> refresh list Locations
                    if (AddNewTripViewModel.Instance != null)
                    {
                        AddNewTripViewModel.Instance.LOCATIONs.Add(NewLocation);
                    }
                    //trường hợp đang làm trong màn hình LocationList <=> refresh list Location
                    LocationListViewModel.Instance.updateList(NewLocation);
                    SettingsViewModel.Instance.UpdateLocationMaxPaging();
                }
                else
                {
                    LOCATION location = HomeScreen.GetDatabaseEntities().LOCATIONS.First(item => item.LOCATION_ID == NewLocation.LOCATION_ID);
                    location = NewLocation;
                }
                HomeScreen.GetDatabaseEntities().SaveChanges();
                SettingsViewModel.Instance.UpdateLocationSortMethod();
                MessageBox.Show("Thành công");
            }
            else
            {
                MessageBox.Show("Điền thiếu dữ liệu !");
            }
        }