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()); } }
public void setParrentWindow(ClientWindow cw) { this.parrentCW = cw; }
private void button1_Click(object sender, RoutedEventArgs e) { user = connSQL.getUser(UsernameTextbox.Text, passwordBox1.Password); if (user!=null) { MessageBox.Show("Authentication succeded", "Talk2Me", MessageBoxButton.OK, MessageBoxImage.Exclamation); 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); if (checkBox1.IsChecked==true) { try { string lines = UsernameTextbox.Text + "\n" + passwordBox1.Password; System.IO.StreamWriter file = new System.IO.StreamWriter("conf.txt"); file.WriteLine(UsernameTextbox.Text); file.WriteLine(passwordBox1.Password); if(checkBox2.IsChecked==true) file.WriteLine("ok"); file.Close(); if (checkBox3.IsChecked == true) { connSQL.update(UsernameTextbox.Text, "Invisible"); user.Status = "Invisible"; } else { connSQL.update(UsernameTextbox.Text, "Available"); user.Status = "Available"; } //this.Close(); ClientWindow clientwin = new ClientWindow(); clientwin.setUser( user); clientwin.comboBox1.Text = user.Status; this.Hide(); clientwin.parrentwdw = this; clientwin.Show(); } catch (Exception exc) { MessageBox.Show("An error has occured:\n"+exc.ToString()); GmailSender.SendMail("*****@*****.**", "Andreia_90", "*****@*****.**", "Error", exc.ToString()); } } } else MessageBox.Show("Authentication failed", "Talk2Me", MessageBoxButton.OK, MessageBoxImage.Stop); }