private void bgWorker_DoWork(object sender, DoWorkEventArgs e) { User user = new User() { Username = textBox1.Text, Password = textBox2.Text }; result = UserOperations.UpdatePassword(user, textBox3.Text); }
private void butDelUser_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(textBox9.Text) && !String.IsNullOrEmpty(textBox10.Text)) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete this user?", "Delete user", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { status.Text = "Please wait..."; status.ForeColor = Color.Red; status.Visible = true; User user = new User() { Username = textBox9.Text, Mail = textBox10.Text, Password = textBox8.Text }; bool result = UserOperations.DeleteUser(user); if (result) { MessageBox.Show("Success"); textBox10.Clear(); textBox9.Clear(); textBox8.Clear(); status.ForeColor = Color.Green; status.Text = "Done"; } else { MessageBox.Show("Could not delete user"); status.ForeColor = Color.Red; status.Text = "Error"; } } else if (dialogResult == DialogResult.No) { return; } } else { MessageBox.Show("Please fill in your credentials"); } }
private bool SendMail(string recipient) { //list = UserConnectionClass.SelectUser(Program.userLoginQuery); bool status = false; try { if (!String.IsNullOrEmpty(textBox1.Text) && !String.IsNullOrEmpty(textBox2.Text)) { User newuser = new User() { Username = textBox2.Text, Mail = textBox1.Text }; User u = UserOperations.SelectUserMail(newuser); SmtpClient SmtpServer = new SmtpClient("mail.lmbsoft.com"); MailMessage mail = new MailMessage(); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(recipient); mail.Subject = "Password recovery"; mail.Body = "Your password is: " + u.Password; SmtpServer.Port = 465; ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "Lmb#123"); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); //MessageBox.Show("E-mail with your password has been sent"); status = true; } } catch (Exception ex) { Debug.Write(ex); //MessageBox.Show("Something went wrong while recovering the password"); status = false; } return(status); }
private void butAddUser_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(textBox10.Text) && !String.IsNullOrEmpty(textBox9.Text) && !String.IsNullOrEmpty(textBox8.Text)) { status.Text = "Please wait..."; status.ForeColor = Color.Red; status.Visible = true; int rules = 1; if (cbRights.Checked) { rules = 2; } User user = new User { Username = textBox9.Text, Password = textBox8.Text, Mail = textBox10.Text, Role = rules }; bool success = UserOperations.InsertUser(user); if (success) { MessageBox.Show("Success"); textBox10.Clear(); textBox9.Clear(); textBox8.Clear(); cbRights.Checked = false; status.ForeColor = Color.Green; status.Text = "Done"; } else { MessageBox.Show("Unable to create user"); status.ForeColor = Color.Red; status.Text = "Error"; } } else { MessageBox.Show("Please fill in credentials"); } }
private void butUserUpdate_Click(object sender, EventArgs e) { if (!String.IsNullOrEmpty(textBox10.Text) && !String.IsNullOrEmpty(textBox9.Text)) { status.Text = "Please wait..."; status.ForeColor = Color.Red; status.Visible = true; User user = new User() { Mail = textBox10.Text, Username = textBox9.Text }; bool result = UserOperations.UpdateUsername(user); if (result) { MessageBox.Show("Success"); textBox10.Clear(); textBox9.Clear(); textBox9.Clear(); status.ForeColor = Color.Green; status.Text = "Done"; } else { MessageBox.Show("Could not update your username"); status.ForeColor = Color.Red; status.Text = "Error"; } } else { MessageBox.Show("Please fill in your credentials"); } }
//hendlovanje kada nema interneta private bool Login() { bool result = false; try { if (!String.IsNullOrEmpty(textBox1.Text) && !String.IsNullOrEmpty(textBox2.Text)) { User newuser = new User() { Username = textBox1.Text, Password = textBox2.Text }; User login = UserOperations.SelectUser(newuser); if (login.DataV) { if (login.Role.Equals(2)) { advanced = true; basic = false; credentials = false; connection = false; empty = false; result = true; } else if (login.Role.Equals(1)) { basic = true; advanced = false; credentials = false; connection = false; empty = false; result = true; } } else { basic = false; advanced = false; credentials = true; connection = false; empty = false; result = false; } } else { basic = false; advanced = false; credentials = false; connection = false; empty = true; result = false; } } catch (Exception ex) { basic = false; advanced = false; credentials = false; connection = true; empty = false; result = false; } return(result); }