Ejemplo n.º 1
0
        public int Insert(Remboursement model)
        {
            int result = -1;

            connexion.Open(); using (SqlCommand cmd = connexion.CreateCommand()) {
                result = this.ExecuteInsert(cmd, model);
            } connexion.Close();

            return(result);
        }
Ejemplo n.º 2
0
        private int ExecuteInsert(SqlCommand cmd, Remboursement model)
        {
            cmd.CommandText = "INSERT INTO Remboursement VALUES(@val1, @val2, @val3, @val4, @val5, @val6)";
            cmd.Parameters.AddWithValue("@val1", model.Id);
            cmd.Parameters.AddWithValue("@val2", model.Pret.ToString());
            cmd.Parameters.AddWithValue("@val3", model.DateRemboursement);
            cmd.Parameters.AddWithValue("@val4", model.Montant);
            cmd.Parameters.AddWithValue("@val5", model.Interet);
            cmd.Parameters.AddWithValue("@val6", model.Fait);

            return(cmd.ExecuteNonQuery());
        }
Ejemplo n.º 3
0
        // METHODS :

        private int ExecuteUpdate(SqlCommand cmd, Remboursement model)
        {
            cmd.CommandText = "UPDATE Remboursement SET pret=@val1, dateRemboursement=@val2, montant=@val3, interet=@val4, fait=@val5 WHERE id=@val6";
            cmd.Parameters.AddWithValue("@val1", model.Pret.ToString());
            cmd.Parameters.AddWithValue("@val2", model.DateRemboursement);
            cmd.Parameters.AddWithValue("@val3", model.Montant);
            cmd.Parameters.AddWithValue("@val4", model.Interet);
            cmd.Parameters.AddWithValue("@val5", model.Fait);
            cmd.Parameters.AddWithValue("@val6", model.Id);

            return(cmd.ExecuteNonQuery());
        }
Ejemplo n.º 4
0
        public Remboursement SelectOne(String condition)
        {
            Remboursement result = null;

            if (connexion.State == ConnectionState.Open)
            {
                connexion = new SqlConnection(connexion.ConnectionString + "Password=itu");
            }
            connexion.Open();
            using (SqlCommand cmd = connexion.CreateCommand()) {
                result = this.ExecuteSelectOne(cmd, condition);
            } connexion.Close();

            return(result);
        }
Ejemplo n.º 5
0
        private Remboursement ExecuteSelectOne(SqlCommand cmd, String condition)
        {
            Remboursement result = null;

            string cond = "";

            if (condition != null)
            {
                cond = " " + condition;
            }
            cmd.CommandText = "SELECT * FROM Remboursement" + cond;
            using (SqlDataReader reader = cmd.ExecuteReader()) {
                if (reader.Read())
                {
                    result = this.Map(reader);
                }
            } return(result);
        }
Ejemplo n.º 6
0
        // METHODS :

        public bool Equals(Remboursement cmp)
        {
            return(this.id == cmp.Id);
        }