Beispiel #1
0
        public void Edit(Object objectEdited)
        {
            objectEdited.ObjectDeleted = false;
            objectEdited.ObjectEmpty   = false;

            using var cnn = new DatabaseConnection();
            cnn.Execute(Object.SQLUpdate, objectEdited);

            if (objectEdited.GetTypeObject().TypeObjectNeedColumnDefinition)
            {
                // TODO : Add synchronisation des colonnes Here
            }

            AddScriptToObjectAction(objectEdited, SqlAction.Alter);
        }
Beispiel #2
0
        public void Delete(Object objectDel, int numberOfImplementation)
        {
            objectDel.ObjectDeleted = true;

            string sql = numberOfImplementation > 0 ? ObjectWithClientSpecific.SQLDelete : Object.SQLDelete;

            using var cnn = new DatabaseConnection();
            if (objectDel.GetTypeObject().TypeObjectNeedColumnDefinition)
            {
                cnn.Execute(ColumnDefinition.SQLDelete, objectDel);
            }

            cnn.Execute(sql, objectDel);

            AddScriptToObjectAction(objectDel, SqlAction.Delete);
        }
Beispiel #3
0
        public override string ToString()
        {
            if (myobject.TypeObjectId == TypeObject.None)
            { // pas de bras pas de chocolat
                return(string.Empty);
            }

            StringBuilder sql = new StringBuilder();

            sql.AppendLine();
            sql.AppendLine("-------------------------------------------------------------------------------");
            sql.AppendLine($"--- DBComparer {Environment.UserName} le {DateTime.Now:dd/MM/yyyy} à {DateTime.Now:HH:mm} {myobject.GetTypeObject().TypeObjectTilte} {myobject}");
            sql.AppendLine("-------------------------------------------------------------------------------");

            string sepi = string.Empty;

            if (myobject.ClientCodeId > 0)
            {
                sql.AppendLine($"IF (EXISTS (SELECT 1 FROM dbo.CodeClientId({myobject.ClientCodeId})))");
                sql.AppendLine("BEGIN");
                sepi = "    ";
            }

            if (myobject.ObjectDeleted || myAction.SqlActionId == SqlAction.Delete || myAction.SqlActionId == SqlAction.Alter)
            {
                sql.AppendLine(sepi + SQLIfExists());
                sql.AppendLine(sepi + "BEGIN");
                sql.AppendLine(sepi + "    " + SQLDrop());
                sql.AppendLine(sepi + "END");
            }

            if (myAction.SqlActionId != SqlAction.Delete)
            {
                sql.AppendLine();
                sql.AppendLine(sepi + "DECLARE @sql VARCHAR(MAX);");
                sql.AppendLine(sepi + $"SELECT @sql = {SqlFormat.String(myobject.ObjectSql)}");
                sql.AppendLine(sepi + "IF (ISNULL(@sql, '') <> '')");
                sql.AppendLine(sepi + "BEGIN");
                sql.AppendLine(sepi + "    EXEC(@sql);");
                sql.AppendLine(sepi + "END");
            }

            if (myobject.ClientCodeId > 0)
            {
                sql.AppendLine("END");
            }

            sql.AppendLine("-------------------------------------------------------------------------------");
            return(sql.ToString());
        }