Exemple #1
0
        Update(OleDbConnection dbConn, OleDbTransaction dbTransaction,
               PosteRevenu originalEntry, PosteRevenu newEntry)
        {
            OleDbCommand cmd;

            // if the day is invalid, throw ArgumentException
            PosteRepository.CheckDayRangeOrThrow(newEntry.jourDuMois);

            cmd = new OleDbCommand("UPDATE " + TABLE_NAME
                                   + " SET montant = @amount, codePersonne = @codePer, jourDuMois = @jourDuMois"
                                   + " WHERE codePoste = @codePoste", dbConn, dbTransaction);
            cmd.Parameters.AddWithValue("@amount", newEntry.montant.ToString());
            cmd.Parameters.AddWithValue("@codePersonne", newEntry.codePersonne);
            cmd.Parameters.AddWithValue("@jourDuMois", newEntry.jourDuMois);
            cmd.Parameters.AddWithValue("@codePoste", originalEntry.codePoste);

            cmd.ExecuteNonQuery();

            // if the poste title changed, update it
            if (originalEntry.libPoste_s != null &&
                newEntry.libPoste_s != null &&
                !originalEntry.libPoste_s.Equals(newEntry.libPoste_s))
            {
                PosteRepository.Update(dbConn, dbTransaction, originalEntry.codePoste, newEntry.libPoste_s);
            }
        }
Exemple #2
0
        Create(OleDbConnection dbConn, OleDbTransaction dbTransaction,
               string libPoste, string _comments,
               params KeyValuePair <DateTime, decimal>[] deadLines)
        {
            int transactionCodeType;

            // if there is no comments: put a DBNull value. Otherwise, the comment.
            object comments = _comments == null ? (object)DBNull.Value : _comments;

            // create the Poste
            int codePoste = PosteRepository.Create(dbConn, dbTransaction, libPoste);

            OleDbCommand cmd = new OleDbCommand(
                string.Format(
                    "INSERT INTO [{0}] (codePoste, commentaire) VALUES(@codePoste, @commentaire)", TABLE_NAME),
                dbConn, dbTransaction
                );

            cmd.Parameters.AddWithValue("@codePoste", codePoste);
            cmd.Parameters.AddWithValue("@commentaire", comments);

            Console.WriteLine("<- INSERT INTO PostePonctuel: {0}, {1}", codePoste, comments);
            cmd.ExecuteNonQuery();

            // create the TransactionType
            transactionCodeType =
                TypeTransactionRepository.CreateUsingIncrementalName(ref libPoste, dbConn, dbTransaction);

            foreach (KeyValuePair <DateTime, decimal> deadline in deadLines)
            {
                EcheanceRepository.Create(dbConn,
                                          dbTransaction, ref codePoste, ref transactionCodeType,
                                          ref libPoste, deadline.Key, deadline.Value > 0 ? deadline.Value * -1 : deadline.Value);
            }
        }
Exemple #3
0
        Create(OleDbConnection dbConn, OleDbTransaction transaction,
               string poste, PersonneRepository.PersonneModel beneficiary,
               decimal amount, int everyXOfTheMonth)
        {
            // create the Poste
            int codePoste = PosteRepository.Create(dbConn, transaction, poste);

            OleDbCommand cmd = new OleDbCommand(
                string.Format(
                    @"INSERT INTO [{0}] ( codePoste,  codePersonne,  montant,  jourDuMois)
                                 VALUES (@codePoste, @codePersonne, @montant, @jourDuMois)", TABLE_NAME),
                dbConn, transaction
                );

            cmd.Parameters.AddWithValue("@codePoste", codePoste);
            cmd.Parameters.AddWithValue("@codePersonne", beneficiary.codePersonne);
            cmd.Parameters.AddWithValue("@montant", amount);
            cmd.Parameters.AddWithValue("@jourDuMois", everyXOfTheMonth);

            Console.WriteLine("<- INSERT INTO PosteRevenu: {0}, {1}, {2}, {3}",
                              codePoste, beneficiary.codePersonne, amount, everyXOfTheMonth);
            cmd.ExecuteNonQuery();
        }