public UsersForm() { InitializeComponent(); activeUser = SharedObjects.userManager.GetActiveUser(); admin = SharedObjects.userManager.GetUser(1); u1 = SharedObjects.userManager.GetUser(2); u2 = SharedObjects.userManager.GetUser(3); u3 = SharedObjects.userManager.GetUser(4); if (!activeUser.isAdmin) { buttonAdmin.Enabled = false; if (!(activeUser.ID==2)) button2.Enabled = false; if (!(activeUser.ID == 3)) button3.Enabled = false; if (!(activeUser.ID == 4)) button4.Enabled = false; } }
public void personSelected(User p) { currentlySelected = p; if (currentlySelected.isAdmin) groupBox1.Enabled = false; else groupBox1.Enabled = true; textBoxIme.Text = p.name; textBoxPrezime.Text = p.surname; maskedTextBoxDate.Text = dateToString(p.birthDate); maskedTextBoxDeath.Text = dateToString(p.deathDate); textBoxAddress.Text = p.address; textBoxCV.Text = p.CV; textBoxTelefon.Text = p.phone; textBoxEmail.Text = p.email; if (p.sex == Person.Sex.Male) radioButtonMale.Checked = true; else if (p.sex == Person.Sex.Female) radioButtonFemale.Checked = true; else radioButtonUnkown.Checked = true; //dodavanje supruznika /* IEnumerable<Person> l =.GetPartners(p.ID); foreach (Person item in l) { textBoxPartner.Text += item.name + " " + item.surname; maskedTextBoxWedding.Text = "00000000"; }*/ pictureBoxImage.Image = p.photo; if (p.photo == null) pictureBoxImage.Image = Properties.Resources.largerperson; textBoxUsername.Text = p.username; if (p.isEnabled) radioButton1.Checked = true; else radioButton2.Checked = true; }
private void DBInit() { OrmLiteConfig.DialectProvider = SqliteOrmLiteDialectProvider.Instance; connectionString = GetFileConnectionString(); if (createDB) { using (IDbConnection db = connectionString.OpenDbConnection()) { // users db.DropTable<User>(); db.CreateTable<User>(); db.DeleteAll<User>(); List<User> users = new List<User>(); User u = new User() { username = "******", password = "******" }; u.isAdmin = true; u.isEnabled = true; users.Add(u); u = new User() { username = "******", password = "******" }; u.isEnabled = false; users.Add(u); u = new User() { username = "******", password = "******" }; u.isEnabled = false; users.Add(u); u = new User() { username = "******", password = "******" }; u.isEnabled = false; users.Add(u); db.InsertAll(users); // queries db.DropTable<Query>(); db.CreateTable<Query>(); db.DeleteAll<Query>(); } } }
public void UpdateUser(User korisnik) { using (IDbConnection db = connectionString.OpenDbConnection()) { db.Update<User>(korisnik); } }
public bool Logoff() { ActiveUser = null; return true; }
public bool Login(string username, string password) { // TODO, dodat password hashing List<User> aktivni = null; using (IDbConnection db = connectionString.OpenDbConnection()) { aktivni = db.Select<User>(x => x.username == username && x.password == password); } if (aktivni.Count != 1) { return false; } ActiveUser = aktivni.ElementAt(0); return true; }
public void AddUser(User korisnik) { List<User> korisnici = null; using (IDbConnection db = connectionString.OpenDbConnection()) { korisnici = db.Select<User>(x => x.username == korisnik.username); if (korisnici.Count() != 0) { throw new System.ArgumentException("Username je vec zauzet"); } db.Insert(korisnik); } }