Skip to content
Snippets Groups Projects
Commit 0c423fec authored by Verin Antoine's avatar Verin Antoine
Browse files

Refactor & fix

parent eb4f657a
Branches
1 merge request!35Bugfixs
......@@ -68,7 +68,7 @@ namespace Mango.Controls
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(100, 23);
this.label2.TabIndex = 3;
this.label2.Text = "Email";
this.label2.Text = "Login";
//
// label3
//
......
......@@ -10,12 +10,12 @@ namespace Mango.Controls
InitializeComponent();
}
public String Mail => txtMail.Text;
public String Mail => txtMail.Text + "@etu.unistra.fr";
public String Password => txtMdp.Text;
private void btnLogin_Click(object sender, EventArgs e)
{
Close();
DialogResult = DialogResult.OK;
}
}
}
\ No newline at end of file
......@@ -77,7 +77,6 @@ namespace Mango.Controls.Menu
{
_connection.CreateCommand("COMMIT TRANSACTION").ExecuteNonQuery();
_connection.FetchOffline();
MailManager.SetCredentials();
foreach (DataRowView item in clbInvites.CheckedItems)
{
MailManager.SendMail((string)item["adresseMail"], "Mango: Rejoingez l'évenement " + txtIntitule.Text);
......
......@@ -16,8 +16,21 @@ namespace Mango
public static void SendMail(string address, string obj)
{
if ((mail == null || password == null) && !SetCredentials()) return;
string message = "Bonjour, \n\t Vous avez été invités à rejoindre un évenement Mango afin de participer à la bonne répartition des dépenses dans vos prochains voyages !\n\n\nL'équipe Mango";
MailMessage msg = new MailMessage(mail, address, obj, message);
MailMessage msg;
try
{
msg = new MailMessage(mail, address, obj, message);
}
catch (Exception)
{
MessageBox.Show("Email " + address + " invalide");
return;
}
SmtpClient client = new SmtpClient();
client.Port = 587;
client.Host = "partage.unistra.fr";
......@@ -38,13 +51,14 @@ namespace Mango
}
}
public static void SetCredentials()
public static bool SetCredentials()
{
LoginForm login = new LoginForm();
login.ShowDialog();
if(login.ShowDialog() != DialogResult.OK) return false;
mail = login.Mail;
password = login.Password;
return true;
}
}
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment