protected void Button3_Click(object sender, EventArgs e) { Baza2Context baza = new Baza2Context(); long liczba = Convert.ToInt64(DropDownList1.Text); string postep = (from u in baza.zadanie where u.id_zadanie == liczba select u.postep).FirstOrDefault().ToString(); TextBox3.Text = DateTime.Now.ToString() + " postęp to: " + postep + "%"; }
protected void DeleteButton_Click(object sender, EventArgs e) { int u_id = Int32.Parse(UserList.SelectedValue); Baza2Context baza = new Baza2Context(); var tasks = from u in baza.zadanie where u.uzytkownik_id_uzytkownik == u_id select u; foreach (var t in tasks) { baza.zadanie.Remove(t); } uzytkownik user = (from u in baza.uzytkownik where u.id_uzytkownik == u_id select u).FirstOrDefault(); baza.uzytkownik.Remove(user); baza.SaveChanges(); }
/// <summary> /// Tworzenie nowego zadania /// </summary> /// <param name="number">Liczba do sprawdzenia pierwszości</param> private void nowy(string number) { Baza2Context baza = new Baza2Context(); long id = (from u in baza.uzytkownik where u.login == User.Identity.Name select u.id_uzytkownik).FirstOrDefault(); zadanie nowe = new zadanie(); nowe.status__id_status = 1; nowe.zadana_liczba = number; nowe.uzytkownik_id_uzytkownik = id; nowe.czas_dodania = DateTime.Now; nowe.postep = 0; nowe.wynik2 = "0"; nowe.wynik1="0"; nowe.algorytm_id_algorytm = Int32.Parse(ListaAlgorytmow.SelectedValue); baza.zadanie.Add(nowe); baza.SaveChanges(); Label1.Text = "Dodano pomyślnie"; Label1.Visible = true; }
protected void Button1_Click(object sender, EventArgs e) { Baza2Context baza = new Baza2Context(); long id = (from u in baza.uzytkownik where u.login == User.Identity.Name select u.id_uzytkownik).FirstOrDefault(); long liczba = Convert.ToInt64(DropDownList1.Text); Label1.Visible = true; TextBox1.Visible = true; //TextBox1.Text = (from u in baza.zadanie where u.uzytkownik_id_uzytkownik == id select u.zadana_liczba).FirstOrDefault(); TextBox1.Text = DropDownList1.SelectedItem.ToString(); Label2.Visible = true; TextBox2.Visible = true; TextBox2.Text = (from u in baza.zadanie where u.id_zadanie == liczba select u.wynik1).FirstOrDefault(); Label3.Visible = true; TextBox3.Visible = true; TextBox3.Text = DateTime.Now.ToString() + " postęp to: " + (from u in baza.zadanie where u.id_zadanie == liczba select u.postep).FirstOrDefault().ToString() + "%"; Label4.Visible = true; TextBox4.Visible = true; TextBox4.Text = (from u in baza.zadanie where u.id_zadanie == liczba select u.czas_rozpoczecie).FirstOrDefault().ToString(); Label5.Visible = true; TextBox5.Visible = true; TextBox5.Text = (from u in baza.zadanie where u.id_zadanie == liczba select u.czas_zakonczenia).FirstOrDefault().ToString(); Label6.Visible = true; TextBox6.Visible = true; TextBox6.Text = (from u in baza.zadanie where u.id_zadanie == liczba select u.czas_dodania).FirstOrDefault().ToString(); Button2.Visible = true; Label8.Visible = true; TextBox8.Visible = true; string id_alg = (from u in baza.zadanie where u.id_zadanie == liczba select u.algorytm_id_algorytm).FirstOrDefault().ToString(); if (id_alg == "1") TextBox8.Text = "Miller-Rabin"; if (id_alg == "2") TextBox8.Text = "Fermat"; if (id_alg == "3") TextBox8.Text = "Wszystkie"; Button3.Visible = true; }
protected void UserButton_Click(object sender, EventArgs e) { Baza2Context baza = new Baza2Context(); uzytkownik nowy = new uzytkownik(); nowy.login = LoginBox.Text; nowy.haslo = GetEncriptedPassword(PassBox.Text); nowy.typ_id_typ = 2; try { var u = (from t in baza.uzytkownik where t.login == nowy.login select t).First(); Label1.Text = "Użytkownik o takiej nazwie już istnieje"; } catch { baza.uzytkownik.Add(nowy); baza.SaveChanges(); Label1.Text = "Dodano nowego użytkownika"; } Label1.Visible = true; }
public override string[] GetRolesForUser(string username) { Baza2Context panel = new Baza2Context(); typ upr = null; uzytkownik user1 = null; string[] lista = new string[1]; try { user1 = (from u in panel.uzytkownik where u.login == username select u).First(); upr = (from u in panel.typ where u.id_typ == user1.typ_id_typ select u).FirstOrDefault(); lista[0] = upr.nazwa; return lista; } catch { lista[0] = ""; return lista; } }
public override bool ChangePassword(string username, string oldPassword, string newPassword) { Baza2Context baza = new Baza2Context(); uzytkownik u1 = null; String stare = GetEncriptedPassword(oldPassword); try { u1 = (from u in baza.uzytkownik where u.login == username && u.haslo == stare select u).First(); } catch { u1 = null; } if (u1 != null) { u1.haslo = GetEncriptedPassword(newPassword); baza.SaveChanges(); return true; } else return false; }
public override bool ValidateUser(string username, string password) { Baza2Context panel = new Baza2Context(); uzytkownik u1 = null; String pass = GetEncriptedPassword(password); try { u1 = (from u in panel.uzytkownik where u.login == username && u.haslo == pass select u).First(); } catch { u1 = null; } if (u1 != null) return true; else return false; }
public override bool IsUserInRole(string username, string roleName) { Baza2Context panel = new Baza2Context(); typ upr = new typ(); try { upr = (from u in panel.typ where u.nazwa == roleName select u).First(); } catch { return false; } uzytkownik u1 = null; try { u1 = (from u in panel.uzytkownik where u.login == username && u.typ_id_typ == upr.id_typ select u).First(); } catch { u1 = null; } if (u1 != null ) return true; else return false; }