using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Web.Mail; using System.Data.OleDb; namespace Reservation { /// /// Retrieve form. /// Method created: OnRetrieve. ///

Copyright (c) 2002 Alexis Grandemange
/// Mail: alexis.grandemange@pagebox.net

///
This program is free software; you can redistribute it and/or
	/// modify it under the terms of the GNU Lesser General Public
	/// License as published by the Free Software Foundation; version
	/// 2.1 of the License.
	/// This library is distributed in the hope that it will be useful,
	/// but WITHOUT ANY WARRANTY; without even the implied warranty of
	/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
	/// GNU Lesser General Public License for more details.
	/// A copy of the GNU Lesser General Public License lesser.txt should be
	/// included in the distribution.
///
public class Retrieve : System.Web.UI.Page { protected System.Web.UI.WebControls.TextBox tbMail; protected System.Web.UI.WebControls.Button btnRetrieve; protected System.Web.UI.WebControls.Label lblStatus; public Retrieve() { Page.Init += new System.EventHandler(Page_Init); } private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here } private void Page_Init(object sender, EventArgs e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeComponent(); } #region Web Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.btnRetrieve.Click += new System.EventHandler(this.OnRetrieve); this.Load += new System.EventHandler(this.Page_Load); } #endregion /// /// Event fired when the user clicks on the Retrieve button. /// Mails the account data to the user. /// private void OnRetrieve(object sender, System.EventArgs e) { OleDbConnection odc = new OleDbConnection(Global.connectionString); odc.Open(); OleDbCommand odcmd = new OleDbCommand("select * from users where mail='" + tbMail.Text + "' and type=0 and deltime=0", odc); OleDbDataReader odr = odcmd.ExecuteReader(); if (odr.Read()) { MailMessage mm = new MailMessage(); mm.BodyFormat = MailFormat.Text; mm.To = tbMail.Text; mm.From = "support@pagebox.net"; mm.Headers.Add("Reply-To", "support@pagebox.net"); mm.Priority = MailPriority.High; mm.Subject = "Account information for PageBox Reservation"; char[] blank = new char[] { ' ' }; mm.Body = "Hi " + (string)odr["name"] + ",\nHere is your login information for the Reservation application on\n" + Global.url + "\nEmail address:\t" + tbMail.Text + "\nID:\t" + ((string)odr["id"]).TrimEnd(blank) + "\nPassword:\t" + ((string)odr["password"]).TrimEnd(blank); SmtpMail.SmtpServer = Global.smtpServer; try { SmtpMail.Send(mm); lblStatus.Text = "Account retrieved: you should soon receive a mail"; } catch(Exception ex) { lblStatus.Text = "Notification failure: " + ex.Message; } } else lblStatus.Text = "User not found"; odr.Close(); odc.Close(); } } }