示例#1
0
        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;
        }
示例#2
0
        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;
        }
示例#3
0
        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;
        }
示例#4
0
 public bool Equals(User other)
 {
     return this.id == other.id;
 }