Esempio n. 1
0
        private void Remove(object sender, RoutedEventArgs e)
        {
            if (TootedList.SelectedIndex > -1)
            {
                Tooted.Remove(Tooted[TootedList.SelectedIndex]);

                TootedList.ItemsSource = null;
                TootedList.ItemsSource = Tooted;
            }
            else
            {
                MessageBox.Show("Valige midagi!", "Viga");
            }
        }
Esempio n. 2
0
        private void Lisa(object sender, RoutedEventArgs e)
        {
            string TempNimetus;
            int    TempHind;

            TempNimetus = Nimetus.Text;
            bool result = int.TryParse(Hind.Text, out TempHind);

            if (TempNimetus == "")
            {
                MessageBox.Show("Toote nimetus pole lisatud!", "Viga");
            }
            else
            {
                if (result == false)
                {
                    MessageBox.Show("Vale hind!", "Viga");
                }
                else
                {
                    bool State = true;
                    foreach (var item in Tooted)
                    {
                        if (item.Nimetus == TempNimetus)
                        {
                            State = false;
                        }
                    }
                    if (State == true)
                    {
                        Tooted.Add(new Toode()
                        {
                            Nimetus = TempNimetus, Hind = TempHind, Kogus = 0
                        });
                        Nimetus.Text = Nimetus.Name;
                        Hind.Text    = Hind.Name;
                    }
                    else if (State == false)
                    {
                        MessageBox.Show("Niisugune toode on juba olemas!", "Viga");
                    }
                }
            }

            TootedList.ItemsSource = null;
            TootedList.ItemsSource = Tooted;
        }
Esempio n. 3
0
        public void UpdateTooted()
        {
            string[] TootedText = new string[] { };

            try
            {
                TootedText = File.ReadAllLines("../../../Tooted.txt");
            }
            catch (FileNotFoundException)
            {
                File.Create("../../../Tooted.txt");
            }

            int    i           = 0;
            string TempNimetus = "";
            int    TempHind    = 0;

            foreach (var item in TootedText)
            {
                i++;
                if (i == 1)
                {
                    TempNimetus = item;
                }
                else if (i == 2)
                {
                    TempHind = int.Parse(item);
                    Tooted.Add(new Toode()
                    {
                        Nimetus = TempNimetus, Hind = TempHind, Kogus = 0
                    });
                }
                else if (i == 3)
                {
                    i = 0;
                    //ToDo: Check
                }
            }

            i           = 0;
            TempNimetus = null;
            TempHind    = 0;
        }
Esempio n. 4
0
 public void Toot()
 {
     if (TextCount >= 500 || TextCount <= 0)
     {
         return;
     }
     DraftManager.Add(new DraftModel(_draftId, ReplyStatus)
     {
         Domain      = Settings.CurrentAccount.Domain,
         AccessToken = Settings.CurrentAccount.AccessToken,
         AccountId   = Settings.CurrentAccount.Id,
         Status      = Text.Replace("\r", "\n"),
         Sensitive   = IsSensitive,
         SpoilerText = ContentWarningText,
         Visibility  = TootVisibilityList.VisibilityList[SelectedVisibilityIndex].VisibilityCode,
         Medias      = Medias.ToList()
     });
     Clean();
     Tooted?.Invoke(this, null);
 }