private void LogOutBtn_Click(object sender, EventArgs e) { TabControl1.Hide(); EmailLoginLbl.Show(); PasswordLoginLbl.Show(); LoginBtn.Show(); EmailLoginTxt.Show(); PasswordLoginTxt.Show(); MailTxt.Show(); MailBtn.Show(); PWLbl.Show(); if (role == "User") //Nedan är för att user och admin ska kunna ha olika sidor. { TabControl1.TabPages.Add(tabPage2); TabControl1.TabPages.Add(tabPage3); TabControl1.TabPages.Add(TabPage4); TabControl1.TabPages.Remove(TabPage5); TabControl1.TabPages.Add(TabPage5); TabControl1.TabPages.Add(tabPage6); } PasswordLoginTxt.Clear(); EmailLoginTxt.Clear(); }
private void LoginBtn_Click(object sender, EventArgs e) //Login delen är nedan. { Encrypter.MD5Hash(PasswordLoginTxt.Text); Login.LoginChecker(EmailLoginTxt.Text, hashed); Login.LoginRoleChecker(EmailLoginTxt.Text); if (Log == "Successful") //Om inloggningen går igenom så ska "nästa sida" visas. Då ska inloggninssidan gömmas. { if (role == "User") //Om man har rollen "User" så ska man kunna se vissa saker. { loginEmail = EmailLoginTxt.Text; TabControl1.Show(); TabControl1.TabPages.Remove(tabPage2); TabControl1.TabPages.Remove(tabPage3); TabControl1.TabPages.Remove(TabPage4); TabControl1.TabPages.Remove(tabPage6); EmailLoginLbl.Hide(); PasswordLoginLbl.Hide(); LoginBtn.Hide(); EmailLoginTxt.Hide(); PasswordLoginTxt.Hide(); MailTxt.Hide(); MailBtn.Hide(); PWLbl.Hide(); } else //Är man inte User så är man Admin och då ska man kunna se vissa saker. { loginEmail = EmailLoginTxt.Text; TabControl1.Show(); EmailLoginLbl.Hide(); PasswordLoginLbl.Hide(); LoginBtn.Hide(); EmailLoginTxt.Hide(); PasswordLoginTxt.Hide(); MailTxt.Hide(); MailBtn.Hide(); PWLbl.Hide(); } } else //Annars så ska den skriva att det är fel lösenord eller email. { MessageBox.Show("Wrong Email or password!"); } }
private void MailBtn_Click(object sender, EventArgs e) //Skicka mail ifall man glöm sitt lösenord. { Search.Mail(MailTxt.Text); Login.PasswordChanger(MailTxt.Text); MailTxt.Clear(); if (checker == 1) //Om det är 1 så finns det en användare och lösenordes skickas. { Outlook.Application app = new Outlook.Application(); Outlook.MailItem mailItem = app.CreateItem(Outlook.OlItemType.olMailItem); mailItem.Subject = "Password recovery"; mailItem.To = MailTxt.Text; mailItem.HTMLBody = "Your new password is: " + RecoveryNewPW + ". <br/> If you want to change the password, you need to do following:<ul><li>Login and go to settings tab.</li><li>Write old password in the first textbox.</li><li>Write the new password in the second textbox</li><li>Write the new password again in the third textbox</li><li>Done!</li></ul>"; mailItem.Send(); MessageBox.Show("Sent!"); } else //Annars så finns det ingen användare med den emailen. { MessageBox.Show("Email dosent exist!"); } }