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 eInfoDesigns.dbProvider.MySqlClient;

namespace typesproject
{
	/// <summary>
	/// Summary description for schedule.
	/// </summary>
	public class schedule : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.HyperLink lnkMainMenu;
		protected System.Web.UI.WebControls.Label lblLastRegistered;
		protected System.Web.UI.WebControls.Label lblSuperPowers;
		protected System.Web.UI.WebControls.Label lblTitle;
		protected System.Web.UI.WebControls.TextBox txtName;
		protected System.Web.UI.WebControls.TextBox txtPowers;
		protected System.Web.UI.WebControls.Button btnSave;
		protected System.Web.UI.WebControls.Label lblHelp;
		protected System.Web.UI.WebControls.Label lblName;
	
		private void Page_Load(object sender, System.EventArgs e)
		{
			// Tutaj umieść kod inicjalizacji strony
		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{
			//
			// CODEGEN: This call is required by the ASP.NET Web Form Designer.
			//
			InitializeComponent();
			base.OnInit(e);
		}
		
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{    
			this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
			this.Load += new System.EventHandler(this.Page_Load);

		}
		#endregion

		private void btnSave_Click(object sender, System.EventArgs e)
		{
			string name = txtName.Text;
			string powers = txtPowers.Text;
			string sql = String.Format("insert into superheroes (Name, Powers) values('{0}','{1}')", name, powers);
			MySqlConnection cn = new MySqlConnection("server=localhost;uid=;pwd=;database=csharpvqs;");
			using (cn)
			{
				cn.Open();
				MySqlCommand cmd = new MySqlCommand(sql, cn);
				cmd.ExecuteNonQuery();
			}
			this.txtName.Text = "";
			this.txtPowers.Text = "";
			this.lblLastRegistered.Text = "Last Registered: " + name;
		}
	}
}
