private void nextButton1_Click(object sender, EventArgs e) { int canCreateAccount = 1, canProcessNextStep = 1; warning_label.Text = ""; //verific daca exista text in casete if (user_name_text_box.Text.Length == 0) { username_error_label.Show(); canProcessNextStep = 0; } else { username_error_label.Hide(); } if (password_text_box.Text.Length == 0) { password_error_label.Show(); canProcessNextStep = 0; } else { password_error_label.Hide(); } if (confirm_password_text_box.Text.Length == 0) { confirm_password_error_label.Show(); canProcessNextStep = 0; } else { confirm_password_error_label.Hide(); } //verific daca usernameul exista si parolele coincid try { if (canProcessNextStep == 1) { using (var context = new Asociatie_ProprietariEntities()) { var nume_utilizatori = (from c in context.Conturi_de_Utilizator where c.Username.TrimEnd().Equals(user_name_text_box.Text) select new { c.Username }); if (nume_utilizatori.Count() != 0) { if (nume_utilizatori.ToList()[0].Username.ToString().TrimEnd() == user_name_text_box.Text.TrimEnd()) { warning_label.Text = "Userul exista!"; canCreateAccount = 0; } } if (canCreateAccount == 1) { if (password_text_box.Text.Equals(confirm_password_text_box.Text) != true) { warning_label.Text = "Parolele nu coincid!"; canCreateAccount = 0; } } if (canCreateAccount == 1) { user_register_panel.Hide(); personalDataPanel.Show(); nume_error_label.Hide(); prenume_error_label.Hide(); numar_telefon_error_label.Hide(); email_error_label.Hide(); var contNou = new Conturi_de_Utilizator() //salvam datele personale ale utilizatorului { Username = user_name_text_box.Text, Parola = sha256(password_text_box.Text), Tip = "User" }; contUtilizator = contNou; } } } } catch (Exception ex) { File.AppendAllText("errors.txt", "Message :" + ex.Message + "<br/>" + Environment.NewLine + "StackTrace :" + ex.StackTrace + "" + Environment.NewLine + "Date :" + DateTime.Now.ToString()); string New = Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine; File.AppendAllText("errors.txt", New); MessageBox.Show("Contacteaza dezvoltatorul!"); } }
private void nextButton1_Click(object sender, EventArgs e) { int canCreateAccount = 1, canProcessNextStep = 1; warning_label.Text = ""; //verific daca exista text in casete if (user_name_text_box.Text.Length == 0) { username_error_label.Show(); canProcessNextStep = 0; } else { username_error_label.Hide(); } if (password_text_box.Text.Length == 0) { password_error_label.Show(); canProcessNextStep = 0; } else { password_error_label.Hide(); } if (confirm_password_text_box.Text.Length == 0) { confirm_password_error_label.Show(); canProcessNextStep = 0; } else { confirm_password_error_label.Hide(); } //verific daca usernameul exista si parolele coincid if (canProcessNextStep == 1) { using (var context = new Asociatie_ProprietariEntities()) { var nume_utilizatori = (from c in context.Conturi_de_Utilizator where c.Username.TrimEnd().Equals(user_name_text_box.Text) select new { c.Username }); if (nume_utilizatori.Count() != 0) { if (nume_utilizatori.ToList()[0].Username.ToString().TrimEnd() == user_name_text_box.Text.TrimEnd()) { warning_label.Text = "Userul exista!"; canCreateAccount = 0; } } if (canCreateAccount == 1) { if (password_text_box.Text.Equals(confirm_password_text_box.Text) != true) { warning_label.Text = "Parolele nu coincid!"; canCreateAccount = 0; } } if (canCreateAccount == 1) { user_register_panel.Hide(); personalDataPanel.Show(); nume_error_label.Hide(); prenume_error_label.Hide(); numar_telefon_error_label.Hide(); email_error_label.Hide(); var contNou = new Conturi_de_Utilizator() //salvam datele personale ale utilizatorului { Username = user_name_text_box.Text, Parola = sha256(password_text_box.Text), Tip = "User" }; contUtilizator = contNou; } } } }