Esempio n. 1
0
        private void AddToListButton_Click(object sender, EventArgs e)
        {
            jtttLog.log("Wcisnieto przycisk dodania do listy.");
            try
            {
                JTTTQuestion jTTTQuestion;

                if (tabQuestion.SelectedTab.Text == tabFindText.Text)
                {
                    jTTTQuestion = new FindText(textBoxURL.Text, textBoxTekst.Text, textBoxEmail.Text);
                }
                else
                {
                    jTTTQuestion = new TempCheck(textBoxMiasto.Text, double.Parse(comboBoxTemp.Text));
                }

                JTTTAction jTTTAction;

                if (tabControlAction.SelectedTab.Text == tabPageEmail.Text)
                {
                    jTTTAction = new SendMail(textBoxEmail.Text);
                }
                else
                {
                    jTTTAction = new ShowResult();
                }

                JTTTRecipe jTTTRecipe = new JTTTRecipe(jTTTAction, jTTTQuestion);
                listOFTasks.Add(jTTTRecipe);

                using (var tmp = new JTTTDBContext())
                {
                    tmp.JTTTRecipes.Add(jTTTRecipe);
                    tmp.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
        }
Esempio n. 2
0
        private void buttonDeleteFromDatabase_Click(object sender, EventArgs e)
        {
            jtttLog.log("Wcisnieto przycisk usuniecia zadania z bazy");
            using (var tmp = new JTTTDBContext())
            {
                foreach (JTTTRecipe item in tasksListBox.SelectedItems)
                {
                    JTTTRecipe recipe = tmp.JTTTRecipes.Find(item.Id);
                    if (recipe != null)
                    {
                        tmp.JTTTRecipes.Remove(recipe);
                    }
                }
                tmp.SaveChanges();

                listOFTasks.Clear();
                foreach (var item in tmp.JTTTRecipes.Include("Question").Include("Action"))
                {
                    listOFTasks.Add(item);
                }
            }
        }