using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Data.SqlClient;


public partial class _Default : System.Web.UI.Page 
{
	private System.Data.SqlClient.SqlCommand sqlSelectCommand1;
	private System.Data.SqlClient.SqlConnection sqlConnection1;
	private System.Data.SqlClient.SqlCommand sqlInsertCommand1;
	private System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
	private System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
	private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;

	protected override void OnInit(EventArgs e)
	{
		base.OnInit(e);
		InitializeComponent();
	}

    protected void Page_Load(object sender, EventArgs e)
    {
		DataSet ds = new DataSet();
		sqlDataAdapter1.Fill(ds); // charge la table compte
		GridView1.DataSource = ds;
		GridView1.DataBind();

		// création d'un DataAdapter à partir d'un générateur
		SqlDataAdapter da_operation = new SqlDataAdapter("select * from operation", sqlDataAdapter1.SelectCommand.Connection);
		SqlCommandBuilder builder = new SqlCommandBuilder(da_operation);
		da_operation.Fill(ds); // charge la table operation

		// déclarer une relation
		DataRelation dr = new DataRelation("Compte_Operation", ds.Tables["compte"].Columns["id_compte"], ds.Tables["operation"].Columns["id_compte"]);
		ds.Relations.Add(dr);
		
    }

	#region InitializeComponent
	private void InitializeComponent()
	{
		this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
		this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
		this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
		this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
		this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
		this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
		// 
		// sqlSelectCommand1
		// 
		this.sqlSelectCommand1.CommandText = "SELECT     compte.*\r\nFROM         compte";
		this.sqlSelectCommand1.Connection = this.sqlConnection1;
		// 
		// sqlInsertCommand1
		// 
		this.sqlInsertCommand1.CommandText = "INSERT INTO [compte] ([titulaire], [solde]) VALUES (@titulaire, @solde)";
		this.sqlInsertCommand1.Connection = this.sqlConnection1;
		this.sqlInsertCommand1.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {
            new System.Data.SqlClient.SqlParameter("@titulaire", System.Data.SqlDbType.VarChar, 0, "titulaire"),
            new System.Data.SqlClient.SqlParameter("@solde", System.Data.SqlDbType.Decimal, 0, System.Data.ParameterDirection.Input, false, ((byte)(18)), ((byte)(2)), "solde", System.Data.DataRowVersion.Current, null)});
		// 
		// sqlUpdateCommand1
		// 
		this.sqlUpdateCommand1.CommandText = "UPDATE [compte] SET [titulaire] = @titulaire, [solde] = @solde WHERE (([id_compte" +
			"] = @Original_id_compte))";
		this.sqlUpdateCommand1.Connection = this.sqlConnection1;
		this.sqlUpdateCommand1.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {
            new System.Data.SqlClient.SqlParameter("@titulaire", System.Data.SqlDbType.VarChar, 0, "titulaire"),
            new System.Data.SqlClient.SqlParameter("@solde", System.Data.SqlDbType.Decimal, 0, System.Data.ParameterDirection.Input, false, ((byte)(18)), ((byte)(2)), "solde", System.Data.DataRowVersion.Current, null),
            new System.Data.SqlClient.SqlParameter("@Original_id_compte", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "id_compte", System.Data.DataRowVersion.Original, null)});
		// 
		// sqlDeleteCommand1
		// 
		this.sqlDeleteCommand1.CommandText = "DELETE FROM [compte] WHERE (([id_compte] = @Original_id_compte))";
		this.sqlDeleteCommand1.Connection = this.sqlConnection1;
		this.sqlDeleteCommand1.Parameters.AddRange(new System.Data.SqlClient.SqlParameter[] {
            new System.Data.SqlClient.SqlParameter("@Original_id_compte", System.Data.SqlDbType.Int, 0, System.Data.ParameterDirection.Input, false, ((byte)(0)), ((byte)(0)), "id_compte", System.Data.DataRowVersion.Original, null)});
		// 
		// sqlDataAdapter1
		// 
		this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
		this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
		this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
		this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
            new System.Data.Common.DataTableMapping("Table", "compte", new System.Data.Common.DataColumnMapping[] {
                        new System.Data.Common.DataColumnMapping("id_compte", "id_compte"),
                        new System.Data.Common.DataColumnMapping("titulaire", "titulaire"),
                        new System.Data.Common.DataColumnMapping("solde", "solde")})});
		this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
		// 
		// sqlConnection1
		// 
		this.sqlConnection1.ConnectionString = "Data Source=.\\SQL2005;Initial Catalog=banca;Integrated Security=True;Pooling=Fals" +
			"e";
		this.sqlConnection1.FireInfoMessageEventOnUserErrors = false;

	} 
	#endregion
}
