// Program public PageJoinGroup(Frame mainFrame, TRS_Domain.USER.Data UserData, FormMain main) { mainFrame_ = mainFrame; Main = main; userdata = UserData; InitializeComponent(); }
public PAGE_GroupInformation(TRS_Domain.GROUP.Data Groupdata, TRS_Domain.USER.Data Client, FormMain main) { InitializeComponent(); client = Client; groupdata = Groupdata; Main = main; Lbl_GroupName.Content = Groupdata.Name; }
// Program public PageShowProfile(TRS_Domain.USER.Data client, TRS_Domain.USER.Data selectedUser, Frame userInfo, Frame contentFrame) { _client = client; _selectedUser = selectedUser; _clientInfoFrame = userInfo; _contentFrame = contentFrame; _contentFrame.NavigationService.RemoveBackEntry(); InitializeComponent(); Loaded += PAGE_ShowProfile_Loaded; }
private void PAGE_ShowProfile_Loaded(object sender, RoutedEventArgs e) { // Get new user update: _selectedUser = _userLogic.UpdateUserInformation(_selectedUser); // Check if selecteduser = client: if (_selectedUser.UserId == _client.UserId) { _client = _selectedUser; _clientInfoFrame.Content = new OTHERS.PageUserInformation(_client, _clientInfoFrame, _contentFrame); } // Show selectedUser information: LblName.Content = $"{_selectedUser.Name} {_selectedUser.Surname}"; LblEmail.Content = _selectedUser.Email; LblRegion.Content = $"{_selectedUser.Region}, {_selectedUser.Adres}"; LblPhoneNumber.Content = _selectedUser.Phonenumber; LblFunction.Content = _selectedUser.Department; LblQoute.Content = _selectedUser.Quote; TxtPortfolio.Text = _selectedUser.Portfolio; LoadUserInterestsListBox(_selectedUser.UserId); if (_selectedUser.Img != null) { var image = new BitmapImage(); using (var mem = new MemoryStream(_selectedUser.Img)) { mem.Position = 0; image.BeginInit(); image.CreateOptions = BitmapCreateOptions.PreservePixelFormat; image.CacheOption = BitmapCacheOption.OnLoad; image.UriSource = null; image.StreamSource = mem; image.EndInit(); } image.Freeze(); Rectangle_Picture.Fill = new ImageBrush(image); } // Get all users: AllUsers = _userLogic.AllUsers(); FillLB_Users(AllUsers); // Check if Client has admin rights if (_client.Type == 1 || _client.UserId == _selectedUser.UserId) { Btn_Edit.Visibility = Visibility.Visible; } if (_client.Type == 1) { Btn_AddUser.Visibility = Visibility.Visible; } }
private void BTN_JoinGroup_Click(object sender, RoutedEventArgs e) { if (grouplogic.JoinGroup(client, groupdata)) { BTN_JoinGroup.IsEnabled = false; client = clientLogic.LoadClient((client.UserId)); Main.LB_Groups.Items.Clear(); foreach (var item in client.Groups) { Main.LB_Groups.Items.Add(item); } } }
public TRS_Domain.USER.Data GetUser(int id) { //Define output: TRS_Domain.USER.Data output = new TRS_Domain.USER.Data(); //use try so the code doesn`t crash try { using (MySqlConnection conn = _connectDb.GetConnection()) { // Open Connection: conn.Open(); // the incomplete query MainQuery = "Select * FROM users WHERE UserID = @id"; // DEFINE the paramaters MySqlParameter param1 = new MySqlParameter(); param1.ParameterName = "@id"; param1.Value = id; // build the command MainCommand = new MySqlCommand(MainQuery, conn); // add the parameters to the command MainCommand.Parameters.Add(param1); // use the command using (MySqlDataReader reader = MainCommand.ExecuteReader()) { // if the query finds a result if (reader.HasRows) { // read through the result while (reader.Read()) { //Save all info from user int userId = Convert.ToInt32(reader["UserID"]); string name = Convert.ToString(reader["UserName"]); string surname = Convert.ToString(reader["UserSurname"]); string email = Convert.ToString(reader["UserEmail"]); string region = Convert.ToString(reader["UserRegion"]); string department = Convert.ToString(reader["UserDepartment"]); string phonenumber = Convert.ToString(reader["UserPhoneNumber"]); string quote = Convert.ToString(reader["UserQuote"]); string portfolio = Convert.ToString(reader["UserPortfolio"]); string photolink = Convert.ToString(reader["UserPhotoLink"]); string adres = Convert.ToString(reader["UserAdres"]); int gender = Convert.ToInt32(reader["UserGender"]); int type = Convert.ToInt32(reader["UserType"]); DateTime dob = Convert.ToDateTime(reader["UserDOB"]); byte[] img = null; if (reader["UserProfilePicture"] != DBNull.Value) { img = (byte[])(reader["UserProfilePicture"]); } output = new TRS_Domain.USER.Data(userId, name, surname, email, region, department, phonenumber, quote, portfolio, photolink, adres, gender, type, dob, img); } } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } return(output); }