public NewAccount() { InitializeComponent(); connSQL = new ConnSQL(); MandatoryLabel.Visibility = MandatoryLabel2.Visibility = MandatoryLabel3.Visibility = MandatoryLabel4.Visibility = Visibility.Hidden; }
private void button2_Click(object sender, RoutedEventArgs e) { string str = currentUser.GroupsFriends; string delimit = ","; string[] groups = null; groups = str.Split(delimit.ToCharArray()); for (int i = 0; i < groups.Length; i++) { string group = groups[i]; delimit = "[] "; string[] friends = group.Split(delimit.ToCharArray()); if (friends[0].CompareTo(RemoveGrouptextBox.Text) == 0) { str.Replace(group, ""); ConnSQL connSQL = new ConnSQL(); this.currentUser.GroupsFriends = str; connSQL.updateGF(this.currentUser.Username, this.currentUser.GroupsFriends); parrentCW.user = currentUser; parrentCW.updateContactListBox(); } break; } SendMessageFriendOp(2, RemoveGrouptextBox.Text, ""); }
private void button1_Click(object sender, RoutedEventArgs e) { ConnSQL connSQL = new ConnSQL(); this.currentUser.GroupsFriends += "," + AddGrouptextBox.Text + "[]"; connSQL.updateGF(this.currentUser.Username, this.currentUser.GroupsFriends); parrentCW.user = currentUser; parrentCW.updateContactListBox(); SendMessageFriendOp(1, AddGrouptextBox.Text, ""); }
private void button1_Click(object sender, RoutedEventArgs e) { ConnSQL connSQl = new ConnSQL(); string result =connSQl.password_recovery(UsernameTextBox.Text, SecretQuestionTextBox.Text, SecretAnswerTextBox.Text); if (result!=null) { string []str =result.Split(','); GmailSender.SendMail("*****@*****.**", "Andreia_90", str[0], "Talk2Me password recovery", "Your password is: "+str[1]); MessageBox.Show("An email has been send to your email address.", "Password recovery confirmation ", MessageBoxButton.OK, MessageBoxImage.Warning); } else { } }
private void comboBox1_SelectionChanged(object sender, SelectionChangedEventArgs e) { ConnSQL connSQL = new ConnSQL(); connSQL.update(user.Username, (comboBox1.SelectedItem as ComboBoxItem).Content.ToString()); if ((comboBox1.SelectedItem as ComboBoxItem).Content.ToString().CompareTo("Offline") == 0) { StateStatus mess = new StateStatus(); mess.Id = 1; mess.State = "Offline"; mess.Status = ""; mess.User = user.Username; byte[] buff = mess.Serialize(); ClientServerCommunicator.SendData(ClientServerCommunicator.server_socket, buff, 5); parrentwdw.Show(); signout = true; this.Close(); } if ((comboBox1.SelectedItem as ComboBoxItem).Content.ToString().CompareTo("Available") == 0) { StateStatus mess = new StateStatus() ; mess.Id = 1; mess.State ="Available"; mess.Status = ""; mess.User = user.Username; byte[] buff = mess.Serialize(); ClientServerCommunicator.SendData(ClientServerCommunicator.server_socket, buff, 5); } if ((comboBox1.SelectedItem as ComboBoxItem).Content.ToString().CompareTo("Invisible") == 0) { StateStatus mess = new StateStatus(); mess.Id = 1; mess.State = "Invisible"; mess.Status = ""; mess.User = user.Username; byte[] buff = mess.Serialize(); ClientServerCommunicator.SendData(ClientServerCommunicator.server_socket, buff, 5); } }
private void Label_MouseLeftButtonUp_1(object sender, MouseButtonEventArgs e) { ConnSQL connSQL = new ConnSQL(); Label chatPartnerLable = (Label)sender; Users user = connSQL.getUser(chatPartnerLable.Content.ToString()); if (user == null) MessageBox.Show("An error has occurred. You might have accesed a user that does not exist anymore.", "Talk2Me Error", MessageBoxButton.OK, MessageBoxImage.Stop); else { ChatWindow cw = new ChatWindow(); cw.label1.Content = chatPartnerLable.Content.ToString()+"("+user.FirstName+" "+user.LastName+")"; cw.currentUser = this.user; // MessageBox.Show(chatPartnerLable.Content.ToString()); cw.setConversationPartnerUser ( user); // MessageBox.Show(cw.conversationPartnerUser.FirstName); cw.Show(); ClientServerCommunicator.cw = cw; } }
void MiRemoveUser_Click(object sender, RoutedEventArgs e) { MessageBox.Show(this.selectedlabel.Content.ToString()); ConnSQL connSQL = new ConnSQL(); this.user.GroupsFriends=this.user.GroupsFriends.Replace(this.selectedlabel.Content.ToString(), ""); MessageBox.Show(this.user.GroupsFriends); connSQL.updateGF(user.Username, user.GroupsFriends); updateContactListBox(); }
void MiViewProfile_Click(object sender, RoutedEventArgs e) { ConnSQL connSQL = new ConnSQL(); ViewAccount vacc = new ViewAccount(); Users user = connSQL.getUser(this.selectedlabel.Content.ToString()); vacc.currentUser = user; vacc.initializeFields(); vacc.Show(); }
private void button4_Click(object sender, RoutedEventArgs e) { //MessageBox.Show(RemoveContacttextBox.Text); ConnSQL connSQL = new ConnSQL(); this.currentUser.GroupsFriends = this.currentUser.GroupsFriends.Replace(RemoveContacttextBox.Text, ""); //MessageBox.Show(this.currentUser.GroupsFriends); connSQL.updateGF(currentUser.Username, currentUser.GroupsFriends); parrentCW.updateContactListBox(); SendMessageFriendOp(4, "", RemoveContacttextBox.Text); }
private void button3_Click(object sender, RoutedEventArgs e) { try { // MessageBox.Show(SelectGroupComboBox.Text); string str = currentUser.GroupsFriends; string delimit = ","; string[] groups = null; groups = str.Split(delimit.ToCharArray()); int i; string[] friends = null; string newgroupfriend = ""; string group = ""; for (i = 0; i < groups.Length; i++) { group = groups[i]; delimit = "[] "; friends = group.Split(delimit.ToCharArray()); // newlabel.Content = friends[0]; // MessageBox.Show(friends[0]); if (SelectGroupComboBox.Text.CompareTo(friends[0]) == 0) { SendMessageFriendOp(3, friends[0], AddContacttextBox.Text); break; } } newgroupfriend = friends[0] + "[" + AddContacttextBox.Text; for (int k = 1; k < friends.Length - 1; k++) { if (friends[k].CompareTo(" ") != 0 && friends[k].CompareTo("") != 0) { newgroupfriend += " " + friends[k]; } } if (friends[friends.Length - 1].CompareTo(" ") != 0 && friends[friends.Length - 1].CompareTo("") != 0) { newgroupfriend += friends[friends.Length]; } newgroupfriend += "]"; ConnSQL connSQL = new ConnSQL(); this.currentUser.GroupsFriends = this.currentUser.GroupsFriends.Replace(group, newgroupfriend); // MessageBox.Show(newgroupfriend); connSQL.updateGF(this.currentUser.Username, this.currentUser.GroupsFriends); parrentCW.user = currentUser; parrentCW.updateContactListBox(); } catch (Exception exc) { MessageBox.Show(exc.ToString()); } }
private void button1_Click(object sender, RoutedEventArgs e) { if (PasswordpasswordBox.Password != ConfirmPasswordPasswordBox.Password) MessageBox.Show("Password and confirm password textbox must be the same", "Talk2Me", MessageBoxButton.OK, MessageBoxImage.Stop); else { ConnSQL connSQl = new ConnSQL(); connSQl.deleteUser(currentUser.Username); updateUser(); connSQl.insert(currentUser); } }
public MainWindow() { connSQL = new ConnSQL(); InitializeComponent(); try { string line; System.IO.StreamReader file = new System.IO.StreamReader("conf.txt"); line = file.ReadLine(); if (line != null) { UsernameTextbox.Text = line; line = file.ReadLine(); if (line != null) { passwordBox1.Password = line; checkBox1.IsChecked = true; line = file.ReadLine(); if (line != null && line.CompareTo("ok") == 0) { checkBox2.IsChecked = true; user = connSQL.getUser(UsernameTextbox.Text, passwordBox1.Password); if (user != null) { ClientServerCommunicator.InitConection(); Login mess = new Login(); mess.Username = UsernameTextbox.Text; mess.Password = passwordBox1.Password; byte[] buff = mess.Serialize(); ClientServerCommunicator.SendData(ClientServerCommunicator.server_socket, buff, 3); MessageBox.Show("Authentication succeded", "Talk2Me", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else MessageBox.Show("Authentication failed", "Talk2Me", MessageBoxButton.OK, MessageBoxImage.Stop); if (user != null) { // this.Close(); if (checkBox3.IsChecked == true) { connSQL.update(UsernameTextbox.Text, "Invisible"); user.Status = "Invisible"; } else { connSQL.update(UsernameTextbox.Text, "Available"); user.Status = "Available"; } ClientWindow clientwin = new ClientWindow(); clientwin.setUser(user); this.Hide(); clientwin.Show(); } } } } file.Close(); } catch (Exception exc) { MessageBox.Show("An error has occured:\n" + exc.ToString()); GmailSender.SendMail("*****@*****.**", "Andreia_90", "*****@*****.**", "Error", exc.ToString()); } }