Exemple #1
0
        public void ModifyUser(ModelUser user)
        {
            SqlCommand ins = new SqlCommand();

            ins.CommandText = "update Users set Email=@Email,Name=@Name,Password=@Password,Role=@Role where Username=@Username";
            ins.Parameters.AddWithValue("@Username", user.Username);
            ins.Parameters.AddWithValue("@Email", user.Email);
            ins.Parameters.AddWithValue("@Password", user.Password);
            ins.Parameters.AddWithValue("@Role", user.Role);
            ins.Connection = connection;
            connection.Open();
            ins.ExecuteNonQuery();
            connection.Close();
        }
Exemple #2
0
        public void CreateUser(ModelUser user)
        {
            SqlCommand ins = new SqlCommand();

            ins.CommandText = "insert into Users(Username,Password,Email,Role,Created,LastLogin)" +
                              "values(@Username,@Password,@Email,@Role,@Created,@LastLogin)";
            ins.Parameters.AddWithValue("@Username", user.Username);
            ins.Parameters.AddWithValue("@Password", user.Password);
            ins.Parameters.AddWithValue("@Role", user.Role);
            ins.Parameters.AddWithValue("@Email", user.Email);
            ins.Parameters.AddWithValue("@Created", DateTime.Now);
            ins.Parameters.AddWithValue("@LastLogin", DateTime.Now);
            ins.Connection = connection;
            connection.Open();
            ins.ExecuteNonQuery();
            connection.Close();
        }