Example #1
0
        private async System.Threading.Tasks.Task <bool> ConfirmSaveChanges()
        {
            ContentDialog saveChangesDialog = new ContentDialog
            {
                Title               = "Changes detected",
                Content             = "Do you want to save changes?",
                PrimaryButtonText   = "Yes",
                SecondaryButtonText = "No",
                CloseButtonText     = "Cancel"
            };

            ContentDialogResult result = await saveChangesDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                RemoveChangesNotifySettings();
                FirmaDAL.ArtiklDalProvider dalProvider = artiklModel.DalProvider;

                dalProvider.UpdateItem(artiklModel);
                inEditMode = false;
                UpdateTextBoxStates();

                return(true);
            }
            else if (result == ContentDialogResult.Secondary)
            {
                RemoveChangesNotifySettings();
                artiklModel.NazArtikla   = originalArtikl.NazArtikla;
                artiklModel.JedMjere     = originalArtikl.JedMjere;
                artiklModel.CijArtkila   = originalArtikl.CijArtkila;
                artiklModel.ZastUsluga   = originalArtikl.ZastUsluga;
                artiklModel.SlikaArtikla = originalArtikl.SlikaArtikla;
                artiklModel.TekstArtikla = originalArtikl.TekstArtikla;

                inEditMode = false;
                UpdateTextBoxStates();

                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        private async void BackRequested(object sender, System.ComponentModel.HandledEventArgs e)
        {
            ContentDialog saveChangesDialog = new ContentDialog
            {
                Title               = "Save artikl",
                Content             = "Do you want to save this item?",
                PrimaryButtonText   = "Save",
                SecondaryButtonText = "Don't save",
                CloseButtonText     = "Cancel"
            };

            ContentDialogResult result = await saveChangesDialog.ShowAsync();

            bool backConfirmed = false;

            if (result == ContentDialogResult.Primary)
            {
                FirmaDAL.ArtiklDalProvider dalProvider = artiklModel.DalProvider;
                dalProvider.AddItem(artiklModel);

                backConfirmed = true;
            }
            else if (result == ContentDialogResult.Primary)
            {
                backConfirmed = true;
            }

            if (backConfirmed)
            {
                Frame rootFrame = Window.Current.Content as Frame;
                if (rootFrame.CanGoBack)
                {
                    rootFrame.GoBack();
                }
            }
        }
Example #3
0
        private void InitializeData()
        {
            // initial data fetch:
            FirmaDAL.DokumentDalProvider dokumentDalProvider = new FirmaDAL.DokumentDalProvider();
            List <FirmaDAL.Dokument>     fetchedDokumentList = dokumentDalProvider.FetchAll();

            dokumentLookupList = new List <FirmaBLL.Models.LookupModel>();
            //currentStavkeList = new ObservableCollection<Models.StavkaLookupModel>();

            // dokuments & lookup
            foreach (FirmaDAL.Dokument dokument in fetchedDokumentList)
            {
                dokumentList.Add(dokument);
                dokumentLookupList.Add(new FirmaBLL.Models.LookupModel {
                    ID = dokument.IdDokumenta, Value = dokument.LookupData
                });
            }
            dokumentLookupList.Add(new FirmaBLL.Models.LookupModel {
                ID = -1, Value = "- Nije odabrano -"
            });

            // partner lookup:
            FirmaDAL.PartnerDalProvider partnerDalProvider = new FirmaDAL.PartnerDalProvider();
            partnerLookupList = new List <FirmaBLL.Models.LookupModel>();
            foreach (KeyValuePair <int, string> kv in partnerDalProvider.FetchLookup())
            {
                partnerLookupList.Add(new FirmaBLL.Models.LookupModel {
                    ID = kv.Key, Value = kv.Value
                });
            }
            partnerLookupList.Add(new FirmaBLL.Models.LookupModel {
                ID = -1, Value = "-Odaberi partnera-"
            });

            // artikl lookup:
            FirmaDAL.ArtiklDalProvider artiklDalProvider = new FirmaDAL.ArtiklDalProvider();
            //var artiklDict = artiklDalProvider.FetchLookup();
            artiklList       = artiklDalProvider.FetchAll();
            artiklLookupList = new List <FirmaBLL.Models.LookupModel>();
            foreach (var art in artiklList)
            {
                artiklLookupList.Add(new FirmaBLL.Models.LookupModel {
                    ID = art.SifArtikla, Value = art.NazArtikla
                });
            }
            artiklLookupList.Add(new FirmaBLL.Models.LookupModel {
                ID = -1, Value = "-Odaberi artikl"
            });

            // counter:
            TotalCountTextBlock.Text = fetchedDokumentList.Count.ToString();
            currentId   = 0;
            displayedId = 0;

            currentDokument = new Models.DokumentLookupModel(dokumentList[displayedId], partnerLookupList, dokumentLookupList, artiklLookupList, artiklList);
            UpdateDocumentData();

            SaveDokumentButton.Visibility   = Visibility.Collapsed;
            CancelDokumentButton.Visibility = Visibility.Collapsed;
            NewStavkaButton.Visibility      = Visibility.Collapsed;

            UpdateNavigation(null, null);
        }