예제 #1
0
        private void addRouteButton_Click(object sender, RoutedEventArgs e)
        {
            Route route = new Route();

            route.ID_Journey     = _journey.ID_Journey;
            route.Ordinal_Number = ++_ordinal_number;
            route.Route_Status   = 0;

            route.Place = routeStartPlaceTextBox.Text;
            if (route.Place.Length <= 0)
            {
                notiMessageSnackbar.MessageQueue.Enqueue($"Không được bỏ trống địa điểm", "OK", () => { });
                return;
            }
            route.Standard_Place = _appUtilities.getStandardName(route.Place, 30);

            route.Route_Description = descriptionRouteTextBox.Text;
            if (route.Route_Description.Length <= 0)
            {
                notiMessageSnackbar.MessageQueue.Enqueue($"Không được bỏ trống phần mô tả", "OK", () => { });
                return;
            }
            route.Standard_Description = _appUtilities.getStandardName(route.Route_Description, 30);

            route.Province = ((Province)startProvinceRouteComboBox.SelectedItem).Province_Name;

            routeStartPlaceTextBox.Text  = "";
            descriptionRouteTextBox.Text = "";

            _journey.Routes.Add(route);

            routesListView.ItemsSource = _journey.Routes.ToList();
        }
예제 #2
0
        private void addSiteButton_Click(object sender, RoutedEventArgs e)
        {
            Site site = new Site();

            site.ID_Site       = _databaseUtilities.GetMaxIDSite() + 1;
            site.ID_Province   = ((Province)startProvinceComboBox.SelectedItem).ID_Province;
            site.Province_Name = ((Province)startProvinceComboBox.SelectedItem).Province_Name;

            site.Site_Name = siteNameTextBox.Text;
            if (site.Site_Name.Length == 0)
            {
                return;
            }
            site.Standard_Site_Name = _appUtilities.getStandardName(site.Site_Name, 25);

            site.Site_Address = siteAddressTextBox.Text;
            if (site.Site_Address.Length == 0)
            {
                return;
            }
            site.Standard_Site_Address = _appUtilities.getStandardName(site.Site_Address, 28);

            if (_srcAvatarSite == "")
            {
                return;
            }

            site.Site_Description = siteDescriptionTextBox.Text;
            if (site.Site_Description.Length == 0)
            {
                return;
            }
            site.Standard_Site_Description = _appUtilities.getStandardName(site.Site_Description, 50);

            site.Site_Link_Avt = _appUtilities.getTypeOfImage(_srcAvatarSite);

            //Add
            _databaseUtilities.AddNewSite(site.ID_Site, site.ID_Province, site.Site_Name, site.Site_Description, site.Site_Link_Avt, site.Site_Address);

            _appUtilities.createSitesDirectory();
            _appUtilities.copyImageToIDirectory(site.ID_Site, _srcAvatarSite, "", true);

            site.Site_Link_Avt = $"Images/Sites/{site.ID_Site}.{site.Site_Link_Avt}";
            _sites.Add(site);

            notiMessageSnackbar.MessageQueue.Enqueue($"Đã thêm thành công địa danh \"{site.Site_Name}\"", "OK", () => { });

            //Reset Input
            siteNameTextBox.Text        = "";
            siteAddressTextBox.Text     = "";
            siteDescriptionTextBox.Text = "";

            sitesListView.ItemsSource = null;
            sitesListView.ItemsSource = _sites;

            avatarImage.Visibility              = Visibility.Collapsed;
            addSiteAvatarButton.Visibility      = Visibility.Visible;
            startProvinceComboBox.SelectedIndex = 0;
        }
예제 #3
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            //Get journey for update
            _journey = _databaseUtilities.GetJourneyByID(_ID_Journey);

            //Detach List for binding from journey
            Route_For_Binding = new List <Route>(_journey.Route_For_Binding);
            for (int i = 0; i < Route_For_Binding.Count; ++i)
            {
                Route_For_Binding[i].Standard_Place       = _appUtilities.getStandardName(Route_For_Binding[i].Place, 20);
                Route_For_Binding[i].Standard_Description = _appUtilities.getStandardName(Route_For_Binding[i].Route_Description, 20);
            }

            JourneyAttendances   = new List <JourneyAttendance>(_journey.JourneyAttendances.ToList());
            Images_For_Binding   = new List <JourneyImage>(_journey.Images_For_Binding);
            Expens_For_Binding   = new List <Expens>(_journey.Expens_For_Binding);
            Advances_For_Binding = new List <Advance>(_journey.Advances_For_Binding);

            //Set ItemSource
            routesListView.ItemsSource       = Route_For_Binding;
            membersListView.ItemsSource      = JourneyAttendances;
            journeyImageListView.ItemsSource = Images_For_Binding;
            expensesListView.ItemsSource     = Expens_For_Binding;
            advanceListView.ItemsSource      = Advances_For_Binding;

            //For combo box
            _provinces = _databaseUtilities.GetListProvince();
            startProvinceRouteComboBox.ItemsSource = _provinces;
            startProvinceComboBox.ItemsSource      = _provinces;
            endProvinceComboBox.ItemsSource        = _provinces;
            borrowerComboBox.ItemsSource           = JourneyAttendances;
            lenderComboBox.ItemsSource             = JourneyAttendances;

            Province province = _databaseUtilities.GetProvinceByName(_journey.Start_Province);

            startProvinceComboBox.SelectedIndex = province.ID_Province - 1;

            Site site = _databaseUtilities.GetSiteByID(_journey.ID_Site ?? 0);

            endProvinceComboBox.SelectedIndex = site.ID_Province - 1;

            if (Images_For_Binding.Count > 0)
            {
                addImageOption1Button.Visibility = Visibility.Collapsed;
                addImageOption2Button.Visibility = Visibility.Visible;
                journeyImageListView.Visibility  = Visibility.Visible;
            }

            _ordinal_number       = _databaseUtilities.GetMaxOrdinalNumber(_ID_Journey);
            _ordinal_number_image = _databaseUtilities.GetMaxOrdinalNumberImage(_ID_Journey);
            _max_id_member        = _databaseUtilities.GetMaxIDMember();

            DataContext = _journey;
        }
예제 #4
0
        public SplashScreen()
        {
            InitializeComponent();

            int maxID = _databaseUtilities.GetMaxIDSite();

            if (maxID > 0)
            {
                _showSplashScreenFlag = true;

                int randomIndex = _rng.Next(maxID) + 1;

                Site site = _databaseUtilities.GetSiteByID(randomIndex);

                site.Site_Name     = _appUtilities.getStandardName(site.Site_Name, 67);
                site.Site_Name     = site.Site_Name.ToUpper();
                site.Site_Link_Avt = $"Images/Sites/{site.ID_Site}.{site.Site_Link_Avt}";

                DataContext = site;
            }
            else
            {
                _showSplashScreenFlag = false;
            }
        }
예제 #5
0
        public SplashScreen()
        {
            InitializeComponent();

            int maxID = _dbUtilities.GetMaxIDRecipe();

            if (maxID > 0)
            {
                _showSplashScreenFlag = true;

                int randomIndex = _rng.Next(maxID) + 1;

                Recipe recipe = _dbUtilities.GetRecipeById(randomIndex);
                recipe = _appUtilities.getRecipeForBindingInHomePage(recipe);

                recipe.NAME = _appUtilities.getStandardName(recipe.NAME, true);

                DataContext = recipe;
            }
            else
            {
                _showSplashScreenFlag = false;
            }
        }
예제 #6
0
        private void loadPlanedJourneyInHomePageViewType1()
        {
            var sites = _databaseUtilities.GetSiteForBindingInHomePageView(PLANED);

            if (sites.Count >= 1)
            {
                var firstPlaned = sites[0];

                var firstPlanedAvatar = new BitmapImage();
                firstPlanedAvatar.BeginInit();
                firstPlanedAvatar.CacheOption = BitmapCacheOption.OnLoad;
                firstPlanedAvatar.UriSource   = new Uri($"Images/Sites/{firstPlaned.ID_Site}.{firstPlaned.Site_Link_Avt}", UriKind.Relative);
                firstPlanedAvatar.EndInit();

                firstPlanedJourneyAvtImage.Source      = firstPlanedAvatar;
                firstPlanedJourneyAvtHoverImage.Source = firstPlanedAvatar;
                firstPlanedJourneyRoute.Text           = firstPlaned.Distance.ToString() + " km";
                firstPlanedJourneyTitle.Text           = _appUtilities.getStandardName(firstPlaned.Site_Name, 22);
                firstPlanedJourneyViewDetailButton.Tag = firstPlaned.ID_Journey;

                if (sites.Count >= 2)
                {
                    var secondPlaned = sites[1];

                    var secondPlanedAvatar = new BitmapImage();
                    secondPlanedAvatar.BeginInit();
                    secondPlanedAvatar.CacheOption = BitmapCacheOption.OnLoad;

                    secondPlanedAvatar.UriSource = new Uri($"Images/Sites/{secondPlaned.ID_Site}.{secondPlaned.Site_Link_Avt}", UriKind.Relative);

                    secondPlanedAvatar.EndInit();

                    secondPlanedJourneyAvtImage.Source      = secondPlanedAvatar;
                    secondPlanedJourneyAvtHoverImage.Source = secondPlanedAvatar;
                    secondPlanedJourneyRoute.Text           = secondPlaned.Distance.ToString() + " km";
                    secondPlanedJourneyTitle.Text           = _appUtilities.getStandardName(secondPlaned.Site_Name, 22);
                    secondPlanedJourneyViewDetailButton.Tag = secondPlaned.ID_Journey;

                    if (sites.Count >= 3)
                    {
                        var thirdPlaned = sites[2];

                        var thirdPlanedAvatar = new BitmapImage();
                        thirdPlanedAvatar.BeginInit();
                        thirdPlanedAvatar.CacheOption = BitmapCacheOption.OnLoad;

                        thirdPlanedAvatar.UriSource = new Uri($"Images/Sites/{thirdPlaned.ID_Site}.{thirdPlaned.Site_Link_Avt}", UriKind.Relative);

                        thirdPlanedAvatar.EndInit();

                        thirdPlanedJourneyAvtImage.Source      = thirdPlanedAvatar;
                        thirdPlanedJourneyAvtHoverImage.Source = thirdPlanedAvatar;
                        thirdPlanedJourneyRoute.Text           = thirdPlaned.Distance.ToString() + " km";
                        thirdPlanedJourneyTitle.Text           = _appUtilities.getStandardName(thirdPlaned.Site_Name, 22);
                        thirdPlanedJourneyViewDetailButton.Tag = thirdPlaned.ID_Journey;
                    }
                    else
                    {
                        thirdPlanedNotFound.Visibility = Visibility.Visible;
                    }
                }
                else
                {
                    secondPlanedNotFound.Visibility = Visibility.Visible;
                    thirdPlanedNotFound.Visibility  = Visibility.Visible;
                }
            }
            else
            {
                firstPlanedNotFound.Visibility  = Visibility.Visible;
                secondPlanedNotFound.Visibility = Visibility.Visible;
                thirdPlanedNotFound.Visibility  = Visibility.Visible;
            }
        }