예제 #1
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_RES_BLD.RES_BLD_Building.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_RES_BLD.RES_BLD_Building.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "RES_BLD_BuildingID", _RES_BLD_BuildingID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_CurrentAverageRentPrice_per_sqm_RefID", _Building_CurrentAverageRentPrice_per_sqm_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "BuildingRevisionHeader_RefID", _BuildingRevisionHeader_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_BalconyPortionPercent", _Building_BalconyPortionPercent);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_Name", _Building_Name);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_DocumentationStructure_RefID", _Building_DocumentationStructure_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsContaminationSuspected", _IsContaminationSuspected);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfFloors", _Building_NumberOfFloors);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_ElevatorCoveragePercent", _Building_ElevatorCoveragePercent);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfAppartments", _Building_NumberOfAppartments);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfOccupiedAppartments", _Building_NumberOfOccupiedAppartments);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfOffices", _Building_NumberOfOffices);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfRetailUnits", _Building_NumberOfRetailUnits);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfProductionUnits", _Building_NumberOfProductionUnits);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Building_NumberOfOtherUnits", _Building_NumberOfOtherUnits);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw ex;
            }

            return(retStatus);
        }
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_HEC_BIL.HEC_BIL_PotentialCode_2_PotentialProcedure.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_HEC_BIL.HEC_BIL_PotentialCode_2_PotentialProcedure.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "AssignmentID", _AssignmentID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "HEC_BIL_PotentialCode_RefID", _HEC_BIL_PotentialCode_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "HEC_TRE_PotentialProcedure_RefID", _HEC_TRE_PotentialProcedure_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Modification_Timestamp", _Modification_Timestamp);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
예제 #3
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_LOG.LOG_ProductTrackingInstance.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_LOG.LOG_ProductTrackingInstance.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "LOG_ProductTrackingInstanceID", _LOG_ProductTrackingInstanceID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "TrackingInstanceTakenFromSourceTrackingInstance_RefID", _TrackingInstanceTakenFromSourceTrackingInstance_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "TrackingCode", _TrackingCode);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "SerialNumber", _SerialNumber);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "BatchNumber", _BatchNumber);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "OwnedBy_BusinessParticipant_RefID", _OwnedBy_BusinessParticipant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_PRO_Product_RefID", _CMN_PRO_Product_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_PRO_Product_Variant_RefID", _CMN_PRO_Product_Variant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_PRO_Product_Release_RefID", _CMN_PRO_Product_Release_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ExpirationDate", _ExpirationDate);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "InitialQuantityOnTrackingInstance", _InitialQuantityOnTrackingInstance);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CurrentQuantityOnTrackingInstance", _CurrentQuantityOnTrackingInstance);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "R_ReservedQuantity", _R_ReservedQuantity);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "R_FreeQuantity", _R_FreeQuantity);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
예제 #4
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = !Status_IsAlreadySaved || Component_Name.IsDirty || Component_Description.IsDirty;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    loader.Append(Component_Name, TableName);
                    loader.Append(Component_Description, TableName);

                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_HEC_PRO.HEC_PRO_Component.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_HEC_PRO.HEC_PRO_Component.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "HEC_PRO_ComponentID", _HEC_PRO_ComponentID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "GlobalPropertyMatchingID", _GlobalPropertyMatchingID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ComponentMatterState", _ComponentMatterState);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "AbsoluteCompositionValue_Unit_RefID", _AbsoluteCompositionValue_Unit_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "AbsoluteCompositionValue", _AbsoluteCompositionValue);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "RelativeCompositionValue_Unit_RefID", _RelativeCompositionValue_Unit_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "RelativeCompositionValue", _RelativeCompositionValue);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "BreadUnitContainedAmount", _BreadUnitContainedAmount);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "EthanolContained_VolumePercentage", _EthanolContained_VolumePercentage);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ComponentEneryValue_in_kJ", _ComponentEneryValue_in_kJ);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Component_SimpleName", _Component_SimpleName);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Component_Name", _Component_Name.DictionaryID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Component_Description", _Component_Description.DictionaryID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ComponentDisposalSpeedStatus", _ComponentDisposalSpeedStatus);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "GalenicalTypeInsidePackageStatus", _GalenicalTypeInsidePackageStatus);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ComponentExcipientStatus", _ComponentExcipientStatus);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "GalenicalType_RelativeComposition", _GalenicalType_RelativeComposition);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Modification_Timestamp", _Modification_Timestamp);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw ex;
            }

            return(retStatus);
        }
예제 #5
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_LOG_WRH.LOG_WRH_Shelf.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_LOG_WRH.LOG_WRH_Shelf.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "LOG_WRH_ShelfID", _LOG_WRH_ShelfID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "GlobalPropertyMatchingID", _GlobalPropertyMatchingID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Rack_RefID", _Rack_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "R_Warehouse_RefID", _R_Warehouse_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "R_Area_RefID", _R_Area_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Shelf_Name", _Shelf_Name);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CoordinateCode", _CoordinateCode);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CoordinateX", _CoordinateX);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CoordinateY", _CoordinateY);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CoordinateZ", _CoordinateZ);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ShelfCapacity_Unit_RefID", _ShelfCapacity_Unit_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ShelfCapacity_Maximum", _ShelfCapacity_Maximum);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "R_ShelfCapacity_Free", _R_ShelfCapacity_Free);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "R_ShelfCapacity_Used", _R_ShelfCapacity_Used);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "LimitShelfContent_ToOneProduct", _LimitShelfContent_ToOneProduct);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "LimitShelfContent_ToOneProductVariant", _LimitShelfContent_ToOneProductVariant);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "LimitShelfContent_ToOneProductRelease", _LimitShelfContent_ToOneProductRelease);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsShelfLocked", _IsShelfLocked);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Predefined_Product_RefID", _Predefined_Product_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Predefined_Product_Variant_RefID", _Predefined_Product_Variant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Predefined_Product_Release_RefID", _Predefined_Product_Release_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
예제 #6
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_PRO.CMN_PRO_SubscribedCatalog.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_PRO.CMN_PRO_SubscribedCatalog.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_PRO_SubscribedCatalogID", _CMN_PRO_SubscribedCatalogID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CatalogCodeITL", _CatalogCodeITL);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "SubscribedCatalog_Language_RefID", _SubscribedCatalog_Language_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "SubscribedCatalog_Currency_RefID", _SubscribedCatalog_Currency_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "SubscribedCatalog_Name", _SubscribedCatalog_Name);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "SubscribedCatalog_Description", _SubscribedCatalog_Description);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "SubscribedCatalog_CurrentRevision", _SubscribedCatalog_CurrentRevision);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PublishingSupplier_RefID", _PublishingSupplier_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "SubscribedBy_BusinessParticipant_RefID", _SubscribedBy_BusinessParticipant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "SubscribedCatalog_PricelistRelease_RefID", _SubscribedCatalog_PricelistRelease_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "SubscribedCatalog_ValidFrom", _SubscribedCatalog_ValidFrom);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "SubscribedCatalog_ValidThrough", _SubscribedCatalog_ValidThrough);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsCatalogValid", _IsCatalogValid);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsCatalogPublic", _IsCatalogPublic);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
예제 #7
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = !Status_IsAlreadySaved || ShiftTemplate_Name.IsDirty;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    loader.Append(ShiftTemplate_Name, TableName);

                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_PPS.CMN_PPS_ShiftTemplate.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_PPS.CMN_PPS_ShiftTemplate.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_PPS_ShiftTemplateID", _CMN_PPS_ShiftTemplateID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ShiftTemplate_ShortName", _ShiftTemplate_ShortName);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ShiftTemplate_Name", _ShiftTemplate_Name.DictionaryID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_STR_Office_RefID", _CMN_STR_Office_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_STR_Workarea_RefID", _CMN_STR_Workarea_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_STR_Workplace_RefID", _CMN_STR_Workplace_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Default_StartTime_in_sec", _Default_StartTime_in_sec);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsWorkPattern", _IsWorkPattern);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Default_AllowedBreakTimeTemplate_RefID", _Default_AllowedBreakTimeTemplate_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "DisplayColor", _DisplayColor);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw ex;
            }

            return(retStatus);
        }
예제 #8
0
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_ORD_CUO_RFP.ORD_CUO_RFP_IssuedProposalResponse_Position.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_ORD_CUO_RFP.ORD_CUO_RFP_IssuedProposalResponse_Position.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ORD_CUO_RFP_IssuedProposalResponse_PositionID", _ORD_CUO_RFP_IssuedProposalResponse_PositionID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "ProposalResponsePositionITPL", _ProposalResponsePositionITPL);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IssuedProposalResponseHeader_RefID", _IssuedProposalResponseHeader_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_PRO_Product_RefID", _CMN_PRO_Product_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_PRO_Product_Variant_RefID", _CMN_PRO_Product_Variant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_PRO_Product_Release_RefID", _CMN_PRO_Product_Release_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CreatedFrom_RequestForProposal_Position_RefID", _CreatedFrom_RequestForProposal_Position_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Quantity", _Quantity);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "TotalPrice_WithoutTax", _TotalPrice_WithoutTax);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "TotalPrice_IncludingTax", _TotalPrice_IncludingTax);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PricePerUnit_WithoutTax", _PricePerUnit_WithoutTax);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "PricePerUnit_IncludingTax", _PricePerUnit_IncludingTax);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsReplacementProduct", _IsReplacementProduct);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw;
            }

            return(retStatus);
        }
        protected FR_Base Save(DbConnection Connection, DbTransaction Transaction, string ConnectionString)
        {
            //Standard return type
            FR_Base retStatus = new FR_Base();

            bool cleanupConnection  = false;
            bool cleanupTransaction = false;

            try
            {
                bool saveDictionary = false;
                bool saveORMClass   = !Status_IsAlreadySaved || Status_IsDirty;


                //If Status Is Dirty (Meaning the data has been changed) or Status_IsAlreadySaved (Meaning the data is in the database, when loaded) just return
                if (saveORMClass == false && saveDictionary == false)
                {
                    return(FR_Base.Status_OK);
                }


                #region Verify/Create Connections
                //Create Connection if Connection is null
                if (Connection == null)
                {
                    cleanupConnection = true;
                    Connection        = CSV2Core_MySQL.Support.DBSQLSupport.CreateConnection(ConnectionString);
                    Connection.Open();
                }

                //Create Transaction if null
                if (Transaction == null)
                {
                    cleanupTransaction = true;
                    Transaction        = Connection.BeginTransaction();
                }

                #endregion

                #region Dictionary Management

                //Save dictionary management
                if (saveDictionary == true)
                {
                    var loader = new CSV2Core_MySQL.Dictionaries.MultiTable.Loader.DictionaryLoader(Connection, Transaction);
                    //Save the dictionary or update based on if it has already been saved to the database
                    if (Status_IsAlreadySaved)
                    {
                        loader.Update();
                    }
                    else
                    {
                        loader.Save();
                    }
                }
                #endregion

                #region Command Execution
                if (saveORMClass == true)
                {
                    //Retrieve Querry
                    string Query = "";

                    if (Status_IsAlreadySaved == true)
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_BPT_STR.CMN_BPT_STR_Office_SettingsProfile.SQL.Update.sql")).ReadToEnd();
                    }
                    else
                    {
                        Query = new System.IO.StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("CL1_CMN_BPT_STR.CMN_BPT_STR_Office_SettingsProfile.SQL.Insert.sql")).ReadToEnd();
                    }

                    DbCommand command = Connection.CreateCommand();
                    command.Connection     = Connection;
                    command.Transaction    = Transaction;
                    command.CommandText    = Query;
                    command.CommandTimeout = QueryTimeout;

                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "CMN_BPT_STR_Office_SettingsProfileID", _CMN_BPT_STR_Office_SettingsProfileID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Office_RefID", _Office_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "AdulthoodAge", _AdulthoodAge);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "RestWarningThreshold_Adults_in_mins", _RestWarningThreshold_Adults_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "RestWarningThreshold_NonAdults_in_mins", _RestWarningThreshold_NonAdults_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "RestMinimumThresholdl_Adults_in_mins", _RestMinimumThresholdl_Adults_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "RestMinimumThresholdl_NonAdults_in_mins", _RestMinimumThresholdl_NonAdults_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "WorkTimeWarningTreshold_Adults_in_mins", _WorkTimeWarningTreshold_Adults_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "WorkTimeWarningTreshold_NonAdults_in_mins", _WorkTimeWarningTreshold_NonAdults_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "WorkTimeMaximumTreshold_Adults_in_mins", _WorkTimeMaximumTreshold_Adults_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "WorkTimeMaximumTreshold_NonAdults_in_mins", _WorkTimeMaximumTreshold_NonAdults_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "WorkStartTimeWarning_NonAdults_in_mins", _WorkStartTimeWarning_NonAdults_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "WorkStartTimeMinimum_NonAdults_in_mins", _WorkStartTimeMinimum_NonAdults_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "WorkEndTimeWarning_NonAdults_in_mins", _WorkEndTimeWarning_NonAdults_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "WorkEndTimeMaximum_NonAdults_in_mins", _WorkEndTimeMaximum_NonAdults_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "WorktimeBalancePeriod_in_months", _WorktimeBalancePeriod_in_months);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "WorkdayStart_in_mins", _WorkdayStart_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "RoosterGridMinimumPlanningUnit_in_mins", _RoosterGridMinimumPlanningUnit_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "MaximumPreWork_Period_in_mins", _MaximumPreWork_Period_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "MaximumPostWork_Period_in_mins", _MaximumPostWork_Period_in_mins);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Creation_Timestamp", _Creation_Timestamp);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "Tenant_RefID", _Tenant_RefID);
                    CSV2Core_MySQL.Support.DBSQLSupport.SetParameter(command, "IsDeleted", _IsDeleted);


                    try
                    {
                        var dbChangeCount = command.ExecuteNonQuery();
                        Status_IsAlreadySaved = true;
                        Status_IsDirty        = false;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    #endregion

                    #region Cleanup Transaction/Connection
                    //If we started the transaction, we will commit it
                    if (cleanupTransaction && Transaction != null)
                    {
                        Transaction.Commit();
                    }

                    //If we opened the connection we will close it
                    if (cleanupConnection && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                try
                {
                    if (cleanupTransaction == true && Transaction != null)
                    {
                        Transaction.Rollback();
                    }
                }
                catch { }

                try
                {
                    if (cleanupConnection == true && Connection != null)
                    {
                        Connection.Close();
                    }
                }
                catch { }

                throw ex;
            }

            return(retStatus);
        }