public static ApporteurAvenant GetApporteurId(int ID_Apporteur) { ApporteurAvenant app = new ApporteurAvenant(); try { string sql = @"SELECT [INV_DIM_Conseiller].[Raison_Sociale],[INV_DIM_Conseiller].[CleSalesForce] FROM [dbo].[INV_DIM_Conseiller] WHERE [INV_DIM_Conseiller].[ID_Conseiller]=@ID"; using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dsnDW_NI"].ConnectionString)) { SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@ID", (object)ID_Apporteur ?? DBNull.Value); con.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { if (dr.Read()) { app.ID_Apporteur = ID_Apporteur; app.Nom = dr["Raison_Sociale"].ToString(); app.CleSalesForce = dr["CleSalesForce"].ToString(); } dr.Close(); } con.Close(); } } catch (Exception) { app = new ApporteurAvenant(); } return(app); }
public override bool Equals(object obj) { ApporteurAvenant other = obj as ApporteurAvenant; return(other != null && other.ID_Apporteur == this.ID_Apporteur); }