protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (e.Parameter != null && e.Parameter is Tapahtuma)
            {
                float yht_hinta = 0;

                tapahtuma        = (Tapahtuma)e.Parameter;
                Tuotenimi.Text   = "";
                Tuotemaara.Text  = "";
                Yhteishinta.Text = "";
                foreach (MyyntiArtikkeli ma in tapahtuma.myyntitapahtuma.ostoslista.myyntiArtikkelit)
                {
                    if (ma.maara > 0)
                    {
                        Tuotenimi.Text   = Tuotenimi.Text + ma.nimi + "\n";
                        Tuotemaara.Text  = Tuotemaara.Text + ma.maara.ToString() + " " + Localization.GetLocalizedText("pcs") + "\n";
                        Yhteishinta.Text = Yhteishinta.Text + (ma.maara * ma.hinta).ToString() + " " + Settings.getCurrency() + "\n";
                        yht_hinta       += (ma.maara * ma.hinta);
                    }
                    SumBlock.Text = yht_hinta.ToString();
                }
                EuroaBlock.Text  = Settings.getCurrency();
                Euroa2Block.Text = Settings.getCurrency();
                Euroa3Block.Text = Settings.getCurrency();
            }
        }
 protected override void OnNavigatedTo(NavigationEventArgs e)
 {
     if (e.Parameter != null)
     {
         tapahtuma = Tapahtuma.getTapahtuma();
         if (tapahtuma == null)
         {
             if (e.Parameter is Tapahtuma)
             {
                 tapahtuma = (Tapahtuma)e.Parameter;
             }
             else if (e.Parameter is Hinnasto)
             {
                 listArtikkelit.ItemsSource = null;
             }
             else
             {
                 /* Problem */
                 throw new NotImplementedException();
             }
         }
         if (tapahtuma != null)
         {
             listArtikkelit.ItemsSource = tapahtuma.myyntitapahtuma.ostoslista.myyntiArtikkelit;
             calculateSum();
         }
         EuroaBlock.Text = Settings.getCurrency();
     }
 }
Пример #3
0
        public static async Task <List <Tapahtuma> > ReadTapahtumatFromXmlFilesAsyncToList(string filePrefix)
        {
            List <Tapahtuma>            Tapahtumat = new List <Tapahtuma>();
            IReadOnlyList <StorageFile> files      = await ApplicationData.Current.LocalFolder.GetFilesAsync();

            foreach (StorageFile file in files)
            {
                if (file.Name.Substring(0, filePrefix.Length) == filePrefix && file.Name.Substring(file.Name.Length - 3, 3) == "xml")
                {
                    Tapahtuma t = await ReadObjectFromXmlFileAsync <Tapahtuma>(file.Name);

                    if (t != null)
                    {
                        Tapahtumat.Add(t);
                    }
                }
            }

/*
 *          string s = await GetNextFileName(filePrefix);
 *          UInt16 i;
 *          string ii = s.Substring(filePrefix.Length, s.Length - filePrefix.Length - 4);
 *          bool parsed = UInt16.TryParse(ii, out i);
 *          if(parsed)
 *          {
 *              for(UInt16 j=1; j<i; j++)
 *              {
 *                  string filename = filePrefix + j.ToString() + ".xml";
 *                  Tapahtuma t = await ReadObjectFromXmlFileAsync<Tapahtuma>(filename);
 *                  Tapahtumat.Add(t);
 *              }
 *          }*/
            return(Tapahtumat);
        }
Пример #4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            BackStackClass.SetBackButtonVisibility();
            BackStackClass.Navigate(typeof(Laskin2Projected), e.Parameter);

            if (e.Parameter != null && e.Parameter is Tapahtuma)
            {
                float yht_hinta = 0;

                tapahtuma          = (Tapahtuma)e.Parameter;
                TapahtumaNimi.Text = Localization.GetLocalizedTextWithVariables("EventX", tapahtuma.nimi);
                //TapahtumaNimi.Text = "Tapahtuma:\n" + tapahtuma.nimi;
                Tuotenimi.Text   = "";
                Tuotemaara.Text  = "";
                Yhteishinta.Text = "";
                foreach (MyyntiArtikkeli ma in tapahtuma.myyntitapahtuma.ostoslista.myyntiArtikkelit)
                {
                    if (ma.maara > 0)
                    {
                        Tuotenimi.Text   = Tuotenimi.Text + ma.nimi + "\n";
                        Tuotemaara.Text  = Tuotemaara.Text + ma.maara.ToString() + " " + Localization.GetLocalizedText("pcs") + "\n";
                        Yhteishinta.Text = Yhteishinta.Text + (ma.maara * ma.hinta).ToString() + " " + Settings.getCurrency() + "\n";
                        yht_hinta       += (ma.maara * ma.hinta);
                    }
                    SumBlock.Text = yht_hinta.ToString();
                }
                EuroaBlock.Text  = Settings.getCurrency();
                Euroa2Block.Text = Settings.getCurrency();
                Euroa3Block.Text = Settings.getCurrency();
            }
        }
 public void UpdatePage(string field, string text)
 {
     if (tapahtuma == null)
     {
         tapahtuma = Tapahtuma.getTapahtuma();
     }
     if (tapahtuma != null)
     {
         /* Reffress list */
         listArtikkelit.ItemsSource = null;
         listArtikkelit.ItemsSource = tapahtuma.myyntitapahtuma.ostoslista.myyntiArtikkelit;
         calculateSum();
     }
 }
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            BackStackClass.SetBackButtonVisibility();
            if (e.NavigationMode == NavigationMode.Back)
            {
                /* Asynkroninen operaatio ilman varoituksia. */
                string s    = Localization.GetLocalizedTextWithVariables("EventXStoppedMsg", Tapahtuma.getTapahtuma().nimi);
                Task   task = new MessageDialog(s).ShowAsync().AsTask();
                /* Sulje tapahtuma*/
                Tapahtuma.hylkääTapahtuma();
                BackStackClass.Navigate(typeof(StartupProjected));
            }

            try
            {
                Hinnastot = await InputOutput.ReadObjectFromXmlFileAsync <List <Hinnasto> >("KioskiLaskinHinnastot.xml");

                ChangeCurrencies(Hinnastot);
                defineLastUid();
            }
            catch (Exception ex) when(ex is System.IO.FileNotFoundException || ex is System.InvalidOperationException)
            {
                Hinnastot = new List <Hinnasto>();
            }
            if (Hinnastot == null)
            {
                Hinnastot = new List <Hinnasto>();
            }

            EditBox2.Visibility       = Visibility.Collapsed;
            EditBox2Header.Visibility = Visibility.Collapsed;
            ArtikkeliQuery.Visibility = Visibility.Collapsed;
            EditBox.Visibility        = Visibility.Collapsed;
            EditBoxHeader.Visibility  = Visibility.Collapsed;
            HinnastoQuery.Visibility  = Visibility.Collapsed;

            if (Hinnastot.Count > 0)
            {
                listHinnasto.ItemsSource   = Hinnastot;
                listHinnasto.SelectedIndex = 0;
                EditBox.Visibility         = Visibility.Collapsed;
            }
            else
            {
                listHinnasto.ItemsSource = null;
                LuoEnsimmainenHinnasto();
            }
        }
Пример #7
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            BackStackClass.SetBackButtonVisibility();

            if (e.Parameter != null)
            {
                tapahtuma = Tapahtuma.getTapahtuma();
                if (tapahtuma == null)
                {
                    if (e.Parameter is Tapahtuma)
                    {
                        tapahtuma = (Tapahtuma)e.Parameter;
                        Tapahtuma.UpdateTapahtuma(tapahtuma);
                    }
                    else if (e.Parameter is Hinnasto)
                    {
                        tapahtuma = new Tapahtuma();
                        DateTime localDate = DateTime.Today;
                        tapahtuma.Paivamaara = localDate.Date.Day.ToString() + "-" + localDate.Date.Month.ToString() + "-" + localDate.Date.Year.ToString();
                        {
                            tapahtuma.MaaritaHinnasto((Hinnasto)e.Parameter);
                            NimiTapahtumalle();
                        }
                    }
                    else
                    {
                        /* Problem */
                        throw new NotImplementedException();
                    }
                }
                if (tapahtuma.myyntitapahtuma == null)
                {
                    tapahtuma.LisaaMyyntiTapahtuma();
                }
                if (listArtikkelit.Visibility == Visibility.Visible)
                {
                    PiilotaEditori();
                    PageEnabled(true);
                }

                EuroaBlock.Text = Settings.getCurrency();
                BackStackClass.Navigate(typeof(Laskin_Projected), e.Parameter);
                calculateSum();
            }
        }
Пример #8
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            float yht_hinta = 0;

            BackStackClass.SetBackButtonVisibility();
            Myyntitapahtuma TapahtumanMyyntiTapahtumat = new Myyntitapahtuma();

            if (e.Parameter is Tapahtuma)
            {
                Tapahtuma t = (Tapahtuma)e.Parameter;
                TapahtumanMyyntiTapahtumat.uusiOstoslista(t.hinnasto);
                foreach (Myyntitapahtuma mt in t.Myyntitapahtumat)
                {
                    foreach (MyyntiArtikkeli ma in mt.ostoslista.myyntiArtikkelit)
                    {
                        foreach (MyyntiArtikkeli tma in TapahtumanMyyntiTapahtumat.ostoslista.myyntiArtikkelit)
                        {
                            if (ma.nimi == tma.nimi)
                            {
                                tma.maara += ma.maara;
                            }
                        }
                    }
                }
                TapahtumanNimi.Text = "Tapahtuma: " + t.nimi;
                Tuotenimi.Text      = "";
                Tuotemaara.Text     = "";
                Yhteishinta.Text    = "";
                foreach (MyyntiArtikkeli ma in TapahtumanMyyntiTapahtumat.ostoslista.myyntiArtikkelit)
                {
                    Tuotenimi.Text   = Tuotenimi.Text + ma.nimi + "\n";
                    Tuotemaara.Text  = Tuotemaara.Text + ma.maara.ToString() + " " + Localization.GetLocalizedText("pcs") + "\n";
                    Yhteishinta.Text = Yhteishinta.Text + (ma.maara * ma.hinta).ToString() + " " + Settings.getCurrency() + "\n";
                    yht_hinta       += (ma.maara * ma.hinta);
                    SumBlock.Text    = yht_hinta.ToString();
                }
                EuroaBlock.Text = Settings.getCurrency();
            }
            else
            {
                /* Problem */
                throw new NotImplementedException();
            }
        }
Пример #9
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            BackStackClass.SetBackButtonVisibility();

            if (e.Parameter != null)
            {
                if (e.NavigationMode == NavigationMode.Back)
                {
                    if (e.Parameter is UseCaseType && (UseCaseType)e.Parameter == UseCaseType.jatkaPaivaa)
                    {
                        /* Asynkroninen operaatio ilman varoituksia. */
                        string s    = Localization.GetLocalizedTextWithVariables("EventXStoppedInListMsg", Tapahtuma.getTapahtuma().nimi);
                        Task   task = new MessageDialog(s).ShowAsync().AsTask();
                        /* Sulje tapahtuma*/
                        Tapahtuma.hylkääTapahtuma();
                    }
                    BackStackClass.Navigate(typeof(StartupProjected));
                }
                if (e.Parameter is UseCaseType)
                {
                    UseCase    = (UseCaseType)e.Parameter;
                    tapahtumat = await InputOutput.ReadTapahtumatFromXmlFilesAsyncToList("Tapahtuma");

                    listTapahtumat.ItemsSource = tapahtumat;
                    /* List creates Tapahtuma objects and last read Tapahtuma is stored to static lastThis variable in Tapahtuma. It needs to be discarded. */
                    Tapahtuma.hylkääTapahtuma();
                }
                else
                {
                    /* Problem */
                    throw new NotImplementedException();
                }
                if (UseCase == UseCaseType.poista)
                {
                    ValmisButton.Content    = Localization.GetLocalizedText("Delete");
                    ValmisButton.Background = new SolidColorBrush(Colors.Red);
                }
            }
        }
Пример #10
0
 public Tapahtuma(string name)
 {
     nimi     = name;
     uid      = LastUid++;
     lastThis = this;
 }
Пример #11
0
 internal static void UpdateTapahtuma(Tapahtuma tapahtuma)
 {
     lastThis = tapahtuma;
 }
Пример #12
0
 public static void hylkääTapahtuma()
 {
     lastThis = null;
 }