Esempio n. 1
0
 private void removeBtn_Click(object sender, RoutedEventArgs e)
 {
     if (tasksListBox.SelectedIndex == -1)
     {
         outputBox.Background = Brushes.Red;
         outputBox.Text       = "Nie zaznaczono elementu";
     }
     else
     {
         int tmpID = tasksList[tasksListBox.SelectedIndex].ID;
         outputBox.Background = Brushes.Green;
         outputBox.Text       = "Usunięto";
         using (var ctx = new JTTTdbcontext())
         {
             JTTTdb tmp = new JTTTdb()
             {
                 ID = tmpID
             };
             ctx.task.Attach(tmp);
             ctx.task.Remove(tmp);
             ctx.SaveChanges();
         }
         updateList();
     }
 }
Esempio n. 2
0
        public void addToDb(JTTTdbcontext context)
        {
            JTTTdb task;

            // task = new JTTTdb() { task = new JTTT { url = "http://demotywatory.pl", text = "autobus", mail = "*****@*****.**" } };
            task = new JTTTdb()
            {
                URL = "http://demotywatory.pl", text = "autobus", mail = "*****@*****.**"
            };
            context.task.Add(task);

            context.SaveChanges();
        }
Esempio n. 3
0
        protected override void Seed(JTTTdbcontext context)
        {
            JTTTdb task;

            // task = new JTTTdb() { task = new JTTT { url = "http://demotywatory.pl", text = "autobus", mail = "*****@*****.**" } };
            task = new JTTTdb()
            {
                URL = "http://demotywatory.pl", text = "autobus", mail = "*****@*****.**"
            };
            context.task.Add(task);

            context.SaveChanges();
            base.Seed(context);
        }
Esempio n. 4
0
        public void addTask()
        {
            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
            {
                JTTT newTask = new JTTT();
                newTask.url  = urlBox.Text;
                newTask.text = textBox.Text;
                newTask.mail = mailBox.Text;
                newTask.city = urlBox.Text;
                if (numberTextBox.Text != "" && numberTextBox.Text != "Podaj warunek temperaturowy")
                {
                    newTask.tempCase = Int32.Parse(numberTextBox.Text);
                }
                else
                {
                    newTask.tempCase = 0;
                }

                if (taskComboBox.SelectedItem == item4)
                {
                    newTask.tasktype = "find";
                }
                if (taskComboBox.SelectedItem == item5)
                {
                    newTask.tasktype = "weather";
                }

                if (responseComboBox.SelectedItem == item1)
                {
                    newTask.responsetype = "mail";
                }
                if (responseComboBox.SelectedItem == item2)
                {
                    newTask.responsetype = "saveas";
                }
                if (responseComboBox.SelectedItem == item3)
                {
                    newTask.responsetype = "display";
                }
                if ((taskComboBox.SelectedItem == item4 && (urlBox.Text == "" || urlBox.Text == "Wprowadź URL strony" || textBox.Text == "" || textBox.Text == "Podaj tekst do wyszukania")) ||
                    (taskComboBox.SelectedItem == item5 && (urlBox.Text == "" || urlBox.Text == "Wprowadź nazwę miasta" || numberTextBox.Text == "" || numberTextBox.Text == "Podaj warunek temperaturowy")) ||
                    (responseComboBox.SelectedItem == item1 && (mailBox.Text == "" || mailBox.Text == "Podaj mail do wysłania obrazka" || mailBox.Text == "Podaj mail do wysłania pogody")))
                {
                    outputBox.Background = Brushes.Red;
                    outputBox.Text       = "Wypełnij wszystkie pola";
                    return;
                }
                else
                {
                    using (var ctx = new JTTTdbcontext())
                    {
                        JTTTdb tmpTask = new JTTTdb {
                            URL = newTask.url, mail = newTask.mail, text = newTask.text, city = newTask.city, tasktype = newTask.tasktype, responsetype = newTask.responsetype, tempCase = newTask.tempCase
                        };
                        ctx.task.Add(tmpTask);
                        ctx.SaveChanges();
                    }
                    updateList();
                }
            }));
        }