public override bool MajLigne(Ligne ligne)
 {
     throw new NotImplementedException();
 }
        public override bool MajLigne(Ligne ligne)
        {
            RaiseLogEvent($"[{ligne.PKValue}] " + (ligne.IsInsert ? "INSERT" : "UPDATE"));
            using (var cnxTarget = new SqlConnection(targetDb.cnxString))
            {
                cnxTarget.Open();
                var transaction = cnxTarget.BeginTransaction();
                try
                {
                    using (var cnxSource = new SqlConnection(sourceDb.cnxString))
                    {
                        cnxSource.Open();
                        using (var cmdSource = GetSelectCmdFromCnx(
                                   cnxSource,
                                   "F_CATALOGUE",
                                   new List <string>()
                        {
                            "CL_No", "CL_Intitule", "CL_Code", "CL_Stock", "CL_NoParent", "CL_Niveau"
                        },
                                   ligne.PKValue
                                   ))
                        {
                            using (var reader = cmdSource.ExecuteReader(CommandBehavior.SingleRow))
                            {
                                reader.Read();

                                // S'assure qu'il n'y aura pas de doublons de parent CL_No+CL_Intitule
                                using (var cmdTarget = cnxTarget.CreateCommand())
                                {
                                    cmdTarget.Transaction = transaction;
                                    cmdTarget.CommandText = $"UPDATE {cnxTarget.Database}.[dbo].[F_CATALOGUE] SET CL_Intitule = 'TEMPSYNC' + @clNo WHERE CL_NoParent = @clNoParent AND CL_Intitule = @clIntitule";
                                    cmdTarget.Parameters.AddWithValue("@clNo", ligne.PKValue);
                                    cmdTarget.Parameters.AddWithValue("@clNoParent", reader["CL_NoParent"]);
                                    cmdTarget.Parameters.AddWithValue("@clIntitule", reader["CL_Intitule"]);
                                    cmdTarget.CommandTimeout = CmdTimeOut;
                                    cmdTarget.ExecuteNonQuery();
                                }

                                if (ligne.IsInsert)
                                {
                                    InsertRowFromReader("F_CATALOGUE", reader, transaction);
                                }
                                else
                                {
                                    UpdateRowFromReader("F_CATALOGUE", reader, transaction);
                                }
                            }
                        }
                    }

                    transaction.Commit();

                    UpdateSyncState(ligne);
                    return(true);
                }
                catch (Exception ex)
                {
                    RaiseLogEvent($"Commit Exception: {ex}");
                    try
                    {
                        transaction.Rollback();
                    }
                    catch (Exception ex2)
                    {
                        RaiseLogEvent($"Rollback Exception Type: {ex2}");
                    }
                }
                return(false);
            }
        }
        public override bool MajLigne(Ligne ligne)
        {
            RaiseLogEvent($"[{ligne.PKValue}] " + (ligne.IsInsert ? "INSERT": "UPDATE"));
            using (var cnxTarget = new SqlConnection(targetDb.cnxString))
            {
                cnxTarget.Open();
                var transaction = cnxTarget.BeginTransaction();
                try
                {
                    using (var cnxSource = new SqlConnection(sourceDb.cnxString))
                    {
                        cnxSource.Open();

                        //
                        // F_MODELER
                        //
                        // Champs à renseigner obligatoirement lors de l’ajout: MR_No, MR_Intitule
                        // Champs non modifiables: MR_No
                        using (var cmdSource = GetSelectCmdFromCnx(cnxSource, "F_MODELER", new List <string>()
                        {
                            "MR_Intitule"
                        }, ligne.PKValue))
                        {
                            using (var reader = cmdSource.ExecuteReader(CommandBehavior.SingleRow))
                            {
                                reader.Read();

                                if (ligne.IsInsert)
                                {
                                    InsertRowFromReader("F_MODELER", reader, transaction);
                                }
                                else
                                {
                                    UpdateRowFromReader("F_MODELER", reader, transaction);
                                }
                            }
                        }

                        //
                        // F_EMODELER
                        //
                        Delete("F_EMODELER", transaction, "MR_No", ligne.PKValue);
                        CopySourceToTarget(
                            cnxSource,
                            "F_EMODELER",
                            new List <string>()
                        {
                            "MR_No", "N_Reglement", "ER_Condition", "ER_NbJour", "ER_JourTb01", "ER_JourTb02",
                            "ER_JourTb03", "ER_JourTb04", "ER_JourTb05", "ER_JourTb06", "ER_TRepart", "ER_VRepart"
                        },
                            ligne.PKValue,
                            transaction);
                    }

                    transaction.Commit();
                    UpdateSyncState(ligne);
                    return(true);
                }
                catch (Exception ex)
                {
                    RaiseLogEvent($"Commit Exception: {ex}");
                    try
                    {
                        transaction.Rollback();
                    }
                    catch (Exception ex2)
                    {
                        RaiseLogEvent($"Rollback Exception Type: {ex2}");
                    }
                }

                return(false);
            }
        }