private void buttonCleanList_Click(object sender, EventArgs e) { list.Clear(); updateList(); // czyszczenie tabel w bazie dych var db = new JTTTDBContext(); foreach (var el in db.IfThatActions) { db.IfThatActions.Remove(el); } foreach (var el in db.fow) { db.fow.Remove(el); } foreach (var el in db.sb) { db.sb.Remove(el); } foreach (var el in db.sm) { db.sm.Remove(el); } db.SaveChanges(); }
private void DeserialButton_Click(object sender, EventArgs e) { jtttLog.log("Wcisnieto przycisk deserializacji."); using (var tmp = new JTTTDBContext()) { foreach (var item in listOFTasks) { JTTTAction action = tmp.JTTTActions.Find(item.Id); if (action != null) { tmp.JTTTActions.Remove(action); } } listOFTasks = (BindingList <JTTTRecipe>)serializer.Deserialize("JTTTser.dat"); foreach (var item in listOFTasks) { tmp.JTTTRecipes.Add(item); jtttLog.log(string.Format("Dodano zdarzenie: {0}.", item)); } tmp.SaveChanges(); tasksListBox.DataSource = listOFTasks; } }
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) { } }
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); } } }
public void AddTask(Task NewTask) { _DB.Tasks.Add(NewTask); _DB.SaveChanges(); lists = new ObservableCollection <Task>(_DB.Tasks.ToList()); }
private void buttonMake_Click(object sender, EventArgs e) { if (znajdzNaStronie.Visible && wyslijMaila.Visible) { var find = new FindOnWebsite(znajdzNaStronie.Url, znajdzNaStronie.MatchWord); var send = new SendEmail(wyslijMaila.Subject, wyslijMaila.Email, "Client"); var con_act = new IfThenActions(find, send, textBoxName.Text); if (!send.AddressOK) { logger.Write("buttonMake_Click", "Błąd adresu email"); Debug.WriteLine("Error: Email address corrupt"); return; } // list.Add(con_act); // dodanie akcji do bazy danych var db = new JTTTDBContext(); db.IfThatActions.Add(con_act); db.SaveChanges(); updateList(); } else if (znajdzNaStronie.Visible && comboBoxTHEN.Text == "Wyświetl w przeglądarce") { var find = new FindOnWebsite(znajdzNaStronie.Url, znajdzNaStronie.MatchWord); var show = new ShowOnBrowser(find); var con_act = new IfThenActions(find, show, textBoxName.Text); // list.Add(con_act); // dodanie akcji do bazy danych var db = new JTTTDBContext(); db.IfThatActions.Add(con_act); db.SaveChanges(); updateList(); } else if (sprawdzPogode1.Visible && wyslijMaila.Visible) { var checker = new CheckTemp(sprawdzPogode1.City, sprawdzPogode1.Temp); var send = new SendEmail(wyslijMaila.Subject, wyslijMaila.Email, "Client"); var con_act = new IfThenActions(checker, send, textBoxName.Text); if (!send.AddressOK) { logger.Write("buttonMake_Click", "Błąd adresu email"); Debug.WriteLine("Error: Email address corrupt"); return; } // list.Add(con_act); // dodanie akcji do bazy danych var db = new JTTTDBContext(); db.IfThatActions.Add(con_act); db.SaveChanges(); updateList(); } else if (sprawdzPogode1.Visible && comboBoxTHEN.Text == "Wyświetl w przeglądarce") { var checker = new CheckTemp(sprawdzPogode1.City, sprawdzPogode1.Temp); var show = new ShowOnBrowser(); var con_act = new IfThenActions(checker, show, textBoxName.Text); // list.Add(con_act); // dodanie akcji do bazy danych var db = new JTTTDBContext(); db.IfThatActions.Add(con_act); db.SaveChanges(); updateList(); } else { MessageBox.Show("Nie wybrano akcji lub warunku.", "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error); } }