Пример #1
0
        /// <summary>
        /// returns a dataset with only necessary data
        /// depending on the parameter removeEmptyTables, the empty tables are not returned
        /// all rows that are not changed are not returned
        /// </summary>
        /// <returns>a new dataset with only modified data
        /// </returns>
        public virtual TTypedDataSet GetChangesTyped(Boolean removeEmptyTables)
        {
            TTypedDataSet ds = (TTypedDataSet)base.GetChanges();

            if (ds == null)
            {
                return(null);
            }

            ds.InitVars();
            ds.MapTables();

            ds.ThrowAwayAfterSubmitChanges     = ThrowAwayAfterSubmitChanges;
            ds.DontThrowAwayAfterSubmitChanges = DontThrowAwayAfterSubmitChanges;

            // need to copy over the enabled/disabled status of relations
            foreach (TTypedRelation relNew in ds.FRelations)
            {
                foreach (TTypedRelation relOrig in this.FRelations)
                {
                    if (relOrig.FName == relNew.FName)
                    {
                        relNew.FEnabled = relOrig.FEnabled;
                    }
                }
            }

            if (removeEmptyTables == true)
            {
                ds.RemoveEmptyTables();
            }

            // TODO: REMOVING OF EMPTY FIELDS NOT DONE BECAUSE WE CURRENTLY CAN'T HANDLE THIS PROPERLY ON THE SERVER SIDE...

            ds.EnableConstraints();
            ds.EnableRelations();
            ds.EnforceConstraints = true;
            return(ds);
        }
        /// <summary>
        /// Processes the result of a data submission to the Server where the result of that operation is
        /// <see cref="TSubmitChangesResult.scrOK" />. (Overload for Typed DataSets.)
        /// </summary>
        /// <param name="ACallingFormOrUserControl"></param>
        /// <param name="ALocalTDS"></param>
        /// <param name="ASubmitTDS"></param>
        /// <param name="APetraUtilsObject"></param>
        /// <param name="AVerificationResults"></param>
        /// <param name="ASetPrimaryKeyOnlyMethod"></param>
        /// <param name="AMasterDataTableSaveCall"></param>
        /// <param name="ACalledFromUserControl"></param>
        /// <param name="ACallAcceptChangesOnReturnedDataBeforeMerge"></param>
        public static void ProcessSubmitChangesResultOK(IFrmPetra ACallingFormOrUserControl, TTypedDataSet ALocalTDS,
            TTypedDataSet ASubmitTDS, TFrmPetraEditUtils APetraUtilsObject, TVerificationResultCollection AVerificationResults,
            Action <bool>ASetPrimaryKeyOnlyMethod, bool AMasterDataTableSaveCall, bool ACalledFromUserControl,
            bool ACallAcceptChangesOnReturnedDataBeforeMerge = false)
        {
            if (AMasterDataTableSaveCall)
            {
                // Call AcceptChanges to get rid now of any deleted columns before we Merge with the result from the Server
                ALocalTDS.AcceptChanges();

                // Merge back with data from the Server (eg. for getting Sequence values)
                if (ACallAcceptChangesOnReturnedDataBeforeMerge)
                {
                    ASubmitTDS.AcceptChanges();
                }

                ALocalTDS.Merge(ASubmitTDS, false);

                // Need to accept any new modification ID's
                ALocalTDS.AcceptChanges();

                if (ASetPrimaryKeyOnlyMethod != null)
                {
                    // Ensure the Primary-Key(s)-containing Controls are disabled to prevent further modification of Primary Key values
                    ASetPrimaryKeyOnlyMethod(true);
                }
            }

            CommonPostMergeOperations(ACallingFormOrUserControl, APetraUtilsObject,
                AVerificationResults, ACalledFromUserControl);
        }