private void Child_Update()
        {
            if (!IsDirty)
            {
                return;
            }

            var dto = new A08_RegionDto();

            dto.Region_ID   = Region_ID;
            dto.Region_Name = Region_Name;
            using (var dalManager = DalFactoryParentLoad.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnUpdatePre(args);
                var dal = dalManager.GetProvider <IA08_RegionDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Update(dto);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnUpdatePost(args);
                // flushes all pending data operations
                FieldManager.UpdateChildren(this);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Factory method. Loads a <see cref="A08_Region"/> object from the given A08_RegionDto.
        /// </summary>
        /// <param name="data">The <see cref="A08_RegionDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="A08_Region"/> object.</returns>
        internal static A08_Region GetA08_Region(A08_RegionDto data)
        {
            A08_Region obj = new A08_Region();

            obj.Fetch(data);
            obj.LoadProperty(A09_CityObjectsProperty, new A09_CityColl());
            return(obj);
        }
        /// <summary>
        /// Loads a <see cref="A08_Region"/> object from the given <see cref="A08_RegionDto"/>.
        /// </summary>
        /// <param name="data">The A08_RegionDto to use.</param>
        private void Fetch(A08_RegionDto data)
        {
            // Value properties
            LoadProperty(Region_IDProperty, data.Region_ID);
            LoadProperty(Region_NameProperty, data.Region_Name);
            // parent properties
            parent_Country_ID = data.Parent_Country_ID;
            var args = new DataPortalHookArgs(data);

            OnFetchRead(args);
        }
        /// <summary>
        /// Factory method. Loads a <see cref="A08_Region"/> object from the given A08_RegionDto.
        /// </summary>
        /// <param name="data">The <see cref="A08_RegionDto"/>.</param>
        /// <returns>A reference to the fetched <see cref="A08_Region"/> object.</returns>
        internal static A08_Region GetA08_Region(A08_RegionDto data)
        {
            A08_Region obj = new A08_Region();

            // show the framework that this is a child object
            obj.MarkAsChild();
            obj.Fetch(data);
            obj.LoadProperty(A09_CityObjectsProperty, A09_CityColl.NewA09_CityColl());
            obj.MarkOld();
            return(obj);
        }
Esempio n. 5
0
        private A08_RegionDto FetchA08_Region(SafeDataReader dr)
        {
            var a08_Region = new A08_RegionDto();

            // Value properties
            a08_Region.Region_ID   = dr.GetInt32("Region_ID");
            a08_Region.Region_Name = dr.GetString("Region_Name");
            // parent properties
            a08_Region.Parent_Country_ID = dr.GetInt32("Parent_Country_ID");

            return(a08_Region);
        }
Esempio n. 6
0
 /// <summary>
 /// Inserts a new A08_Region object in the database.
 /// </summary>
 /// <param name="a08_Region">The A08 Region DTO.</param>
 /// <returns>The new <see cref="A08_RegionDto"/>.</returns>
 public A08_RegionDto Insert(A08_RegionDto a08_Region)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("AddA08_Region", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Parent_Country_ID", a08_Region.Parent_Country_ID).DbType = DbType.Int32;
             cmd.Parameters.AddWithValue("@Region_ID", a08_Region.Region_ID).Direction  = ParameterDirection.Output;
             cmd.Parameters.AddWithValue("@Region_Name", a08_Region.Region_Name).DbType = DbType.String;
             cmd.ExecuteNonQuery();
             a08_Region.Region_ID = (int)cmd.Parameters["@Region_ID"].Value;
         }
     }
     return(a08_Region);
 }
Esempio n. 7
0
 /// <summary>
 /// Updates in the database all changes made to the A08_Region object.
 /// </summary>
 /// <param name="a08_Region">The A08 Region DTO.</param>
 /// <returns>The updated <see cref="A08_RegionDto"/>.</returns>
 public A08_RegionDto Update(A08_RegionDto a08_Region)
 {
     using (var ctx = ConnectionManager <SqlConnection> .GetManager("DeepLoad"))
     {
         using (var cmd = new SqlCommand("UpdateA08_Region", ctx.Connection))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.AddWithValue("@Region_ID", a08_Region.Region_ID).DbType     = DbType.Int32;
             cmd.Parameters.AddWithValue("@Region_Name", a08_Region.Region_Name).DbType = DbType.String;
             var rowsAffected = cmd.ExecuteNonQuery();
             if (rowsAffected == 0)
             {
                 throw new DataNotFoundException("A08_Region");
             }
         }
     }
     return(a08_Region);
 }
        private void Child_Insert(A06_Country parent)
        {
            var dto = new A08_RegionDto();

            dto.Parent_Country_ID = parent.Country_ID;
            dto.Region_Name       = Region_Name;
            using (var dalManager = DalFactoryParentLoad.GetManager())
            {
                var args = new DataPortalHookArgs(dto);
                OnInsertPre(args);
                var dal = dalManager.GetProvider <IA08_RegionDal>();
                using (BypassPropertyChecks)
                {
                    var resultDto = dal.Insert(dto);
                    LoadProperty(Region_IDProperty, resultDto.Region_ID);
                    args = new DataPortalHookArgs(resultDto);
                }
                OnInsertPost(args);
                // flushes all pending data operations
                FieldManager.UpdateChildren(this);
            }
        }