Esempio n. 1
0
        public void tasksList_update()
        {
            tasksList.Clear();

            using (var ctx = new JTTTdbcontext())
            {
                var query = from b in ctx.task orderby b.ID select b;

                foreach (var item in query)
                {
                    JTTT tmp = new JTTT();
                    tmp.url          = item.URL;
                    tmp.text         = item.text;
                    tmp.mail         = item.mail;
                    tmp.tasktype     = item.tasktype;
                    tmp.responsetype = item.responsetype;
                    tmp.city         = item.city;
                    tmp.ID           = item.ID;
                    tmp.tempCase     = item.tempCase;
                    tasksList.Add(tmp);
                }
            }
            isListEmpty();
        }
Esempio n. 2
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();
                }
            }));
        }