using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 test_ps : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
	protected void cmd_creer_Click(object sender, EventArgs e)
	{
		string c_string = ConfigurationManager.ConnectionStrings["bancaConnectionString"].ConnectionString;
		SqlConnection cx_annuaire = new SqlConnection(c_string);

		// déclarer la commande
		SqlCommand sql = new SqlCommand("creer_compte", cx_annuaire);
		sql.CommandType = CommandType.StoredProcedure;
		sql.Parameters.Add("@titulaire", SqlDbType.VarChar, 100);
		sql.Parameters.Add(new SqlParameter("@numero", SqlDbType.Int, 4,ParameterDirection.Output , false, 0, 0, "id_compte", DataRowVersion.Default, 0));

		// ouvrir
		cx_annuaire.Open();
		
		// exécuter et lire le paramètre en sortie
		sql.Parameters["@titulaire"].Value = txt_titulaire.Text;
		sql.ExecuteNonQuery();
		int numero = (int)sql.Parameters["@numero"].Value;
		
		// fermer
		cx_annuaire.Close();

		// afficher
		lbl_info.Text = string.Format("Votre numero de compte : {0}", numero);
	}
}
