public void friendBtnClick(object sender, EventArgs e) { if ((sender as Button).Text == "Añadir amigo") { bool check = _proxy.CreateFriendRequest(Convert.ToInt32((sender as Button).Name), _userID); if (check) { _form.Hide(); Form next = new OtherProfile(Convert.ToInt32((sender as Button).Name)); next.ShowDialog(); _form.Close(); } else { MessageBox.Show("Error al mandar solicitud.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if ((sender as Button).Text == "Eliminar amigo") { User otherUser = _proxy.GetUserById(Convert.ToInt32((sender as Button).Name)); if (MessageBox.Show($"¿Seguro que quieres eliminar a {otherUser.firstName}?", "Eliminar amigo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { bool check = _proxy.DeleteFriendship(_userID, otherUser.ID); if (check) { _form.Hide(); Form next = new OtherProfile(otherUser.ID); next.ShowDialog(); _form.Close(); } else { MessageBox.Show("Error al eliminar amigo.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { User otherUser = _proxy.GetUserById(Convert.ToInt32((sender as Button).Name)); if (MessageBox.Show($"¿Seguro que quieres cancelar la solicitud de amistad a {otherUser.firstName}?", "Cancelar solicitud", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { bool check = _proxy.DeleteFriendshipRequest(otherUser.ID, _userID); if (check) { _form.Hide(); Form next = new FriendSearch(_pattern); next.ShowDialog(); _form.Close(); } else { MessageBox.Show("Error al eliminar solicitud.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void logInBtn_Click(object sender, EventArgs e) { bool correct = false; int res = 0; if (emailTxt.Text != "" && pwdText.Text != "") { string pattern = "^([0-9a-zA-z]([-\\.\\w]*[0-9a-zA-z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)" + "[a-zA-Z]{2,9})$"; if (!Regex.IsMatch(emailTxt.Text, pattern)) { MessageBox.Show("Escribir un correo electrónico válido.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } var logIn = new LogIn(emailTxt.Text, pwdText.Text); var emailHandler = new EmailHandler(); var pwdHandler = new PasswordHandler(); emailHandler.SetNext(pwdHandler); res = Convert.ToInt32(ClientHandler.ClientCode(emailHandler, logIn)); if (res != 0) { correct = true; } } else { MessageBox.Show("Rellenar todos los campos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!correct) { MessageBox.Show("Correo o contraseña incorrectos.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); pwdText.Clear(); return; } else { user = proxy.GetUserById(res); } user.friends = proxy.GetFriends(user.ID); this.Hide(); Form next = new FeedView(); next.ShowDialog(); this.Close(); }
public TagFriends() { user = MainView.user; proxy = MainView.proxy; user = proxy.GetUserById(user.ID); user.friends = proxy.GetFriends(user.ID); InitializeComponent(); }
public FriendRequest() { InitializeComponent(); user = MainView.user; proxy = MainView.proxy; user = proxy.GetUserById(user.ID); requestList = proxy.GetFriendRequests(user.ID); nameBtn.Text = user.firstName; result = new FriendRequestCustom(this, resultsPanel, user.ID, requestList, proxy); result.AddResults(); }
public OtherProfile(int otherUserID) { InitializeComponent(); user = MainView.user; proxy = MainView.proxy; otherUser = proxy.GetUserById(otherUserID); user = proxy.GetUserById(user.ID); otherUser.friends = proxy.GetFriends(otherUser.ID); checkFriendship = proxy.CheckFriendship(user.ID, otherUser.ID); checkRequest = proxy.CheckRequest(user.ID, otherUser.ID); checkInversedRequest = proxy.CheckRequest(otherUser.ID, user.ID); completeNameLabel.Text = otherUser.firstName + " " + otherUser.lastName; dateJoinedLabel.Text = otherUser.dateJoined.ToString("MMMM") + " " + otherUser.dateJoined.Year.ToString(); birthdayDateLabel.Text = otherUser.birthday.Day.ToString() + " de " + otherUser.birthday.ToString("MMMM"); profilePictureImage.Image = Image.FromFile(otherUser.profilePicture); nameBtn.Text = user.firstName; countFriendsLabel.Text = otherUser.friends.Count.ToString(); if (checkRequest) { friendsBtn.Text = "Aceptar solicitud"; } else if (checkInversedRequest) { friendsBtn.Text = "Cancelar solicitud"; } else if (!checkFriendship) { friendsBtn.Text = "Añadir amigo"; } else { friendsBtn.Text = "Eliminar amigo"; } var feedCooker = new FeedCooker(new BuilderProfileFeed(this.refresh, this, postPanel, user.ID, otherUser.ID, proxy)); feedCooker.ObtenerFeed(); if (postPanel.Controls.Count < 2) { noPostLbl.Text = "Sin actividad en su perfil."; } }
public FriendSearch(string search) { InitializeComponent(); nameResultLabel.Text = search; user = MainView.user; proxy = MainView.proxy; user = proxy.GetUserById(user.ID); searchList = proxy.SearchUsers(search, user.ID); nameBtn.Text = user.firstName; result = new FriendSearchResult(this, resultsPanel, user.ID, searchList, proxy, search); result.AddResults(); }
public EditProfile() { user = MainView.user; proxy = MainView.proxy; user = proxy.GetUserById(user.ID); InitializeComponent(); nameRegisterTxt.Text = user.firstName; lastNameRegisterTxt.Text = user.lastName; profilePictureImage.Image = Image.FromFile(user.profilePicture); imageLocation = user.profilePicture; nameBtn.Text = user.firstName; }
public void friendBtnClick(object sender, EventArgs e) { User otherUser = _proxy.GetUserById(Convert.ToInt32((sender as Button).Name)); if (MessageBox.Show($"¿Seguro que quieres eliminar a {otherUser.firstName}?", "Eliminar amigo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { bool check = _proxy.DeleteFriendship(_userID, otherUser.ID); if (check) { _form.Hide(); User temp = _proxy.GetUserById(_userID); temp.friends = _proxy.GetFriends(temp.ID); Form next = new FriendList(temp); next.ShowDialog(); _form.Close(); } else { MessageBox.Show("Error al eliminar amigo.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public FeedView() { user = MainView.user; proxy = MainView.proxy; user = proxy.GetUserById(user.ID); InitializeComponent(); var feedCooker = new FeedCooker(new BuilderMainFeed(this.refresh, this, postPanel, user.ID, user.ID, proxy)); feedCooker.ObtenerFeed(); if (postPanel.Controls.Count < 2) { noPostLbl.Text = "Sin actividad en tu feed."; } nameBtn.Text = user.firstName; imageLocation = "null"; }
public Profile() { InitializeComponent(); user = MainView.user; proxy = MainView.proxy; user = proxy.GetUserById(user.ID); user.friends = proxy.GetFriends(user.ID); completeNameLabel.Text = user.firstName + " " + user.lastName; dateJoinedLabel.Text = user.dateJoined.ToString("MMMM") + " " + user.dateJoined.Year.ToString(); birthdayDateLabel.Text = user.birthday.Day.ToString() + " de " + user.birthday.ToString("MMMM"); profilePictureImage.Image = Image.FromFile(user.profilePicture); nameBtn.Text = user.firstName; countFriendsLabel.Text = user.friends.Count.ToString(); var feedCooker = new FeedCooker(new BuilderProfileFeed(this.refresh, this, postPanel, user.ID, user.ID, proxy)); feedCooker.ObtenerFeed(); if (postPanel.Controls.Count < 2) { noPostLbl.Text = "Sin actividad en tu perfil."; } }