private bool userAlreadyInList(User user) { for (int i = 0; i < dataGridViewAddedUsers.RowCount - 1; i++) { if (user.Equals((User)dataGridViewAddedUsers.Rows[i].Cells[0].Value) && dateTimePicker1.Text == dataGridViewAddedUsers.Rows[i].Cells[1].Value.ToString()) return true; } return false; }
public static User GetUserFromLogin(string login) { ConnectToDsekDb(); User user = new User(); string sql = "SELECT firstname, lastname, id FROM `members` WHERE login LIKE \'" + login + "\'"; MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader rdr = cmd.ExecuteReader(); if (rdr.Read()) { user.login = login; user.realName = rdr.GetString(0) + " " + rdr.GetString(1); user.id = rdr.GetInt32(2); } else { user = null; } rdr.Close(); CloseConnection(); return user; }
public static User GetUserFromId(int id) { ConnectToDsekDb(); User user = new User(); string sql = "SELECT login, firstname, lastname FROM `members` WHERE id = " + id.ToString(); MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader rdr = cmd.ExecuteReader(); rdr.Read(); user.login = rdr.GetString(0); user.realName = rdr.GetString(1) + " " + rdr.GetString(2); user.id = id; rdr.Close(); CloseConnection(); return user; }
public bool Equals(User other) { return this.id == other.id; }